Skip to content

Commit 4fb2770

Browse files
authored
fix: obsolete experimental-use-server-side-upsert option (#1125)
1 parent eb73512 commit 4fb2770

File tree

29 files changed

+103
-1357
lines changed

29 files changed

+103
-1357
lines changed

features/record/import.feature

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,12 @@ Feature: record import
123123
And The output error message should match with the pattern: "\[403] \[GAIA_NO01] Using this API token, you cannot run the specified API."
124124

125125
Scenario: API token does not have privilege to view and edit records
126-
Given The CSV file "CliKintoneTest-29.csv" with content as below:
127-
| Text | Number |
128-
| Alice | 11 |
129-
And The app "app_for_import" has some records as below:
126+
Given The app "app_for_import" has some records as below:
130127
| Text | Number |
131128
| Alice | 10 |
129+
And The CSV file "CliKintoneTest-29.csv" with content as below:
130+
| Record_number | Text | Number |
131+
| | Alice | 11 |
132132
And Load app ID of the app "app_for_import" as env var: "APP_ID"
133133
And Load app token of the app "app_for_import" with exact permissions "add" as env var: "API_TOKEN_IMPORT"
134134
When I run the command with args "record import --base-url $$TEST_KINTONE_BASE_URL --app $APP_ID --api-token $API_TOKEN_IMPORT --file-path CliKintoneTest-29.csv --update-key Record_number"

src/cli/record/import.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,6 @@ const builder = (args: yargs.Argv) =>
4545
describe: "The fields to be imported in comma-separated",
4646
type: "string",
4747
requiresArg: true,
48-
})
49-
.option("experimental-use-server-side-upsert", {
50-
describe:
51-
"Use server-side upsert. This option is under early development.",
52-
type: "boolean",
53-
default: false,
5448
});
5549

5650
type Args = yargs.Arguments<
@@ -71,7 +65,6 @@ const handler = (args: Args) => {
7165
filePath: args["file-path"],
7266
updateKey: args["update-key"],
7367
fields: args.fields?.split(","),
74-
useServerSideUpsert: args["experimental-use-server-side-upsert"],
7568
encoding: args.encoding,
7669
pfxFilePath: args["pfx-file-path"],
7770
pfxFilePassword: args["pfx-file-password"],

src/record/import/index.ts

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@ import type { SupportedImportEncoding } from "../../utils/file";
44
import { extractFileFormat, openFsStreamWithEncode } from "../../utils/file";
55
import { addRecords } from "./usecases/add";
66
import { upsertRecords } from "./usecases/upsert";
7-
import { upsertRecords as upsertRecordsServerSide } from "./usecases/upsertServerSide";
87
import { createSchema } from "./schema";
98
import { noop as defaultTransformer } from "./schema/transformers/noop";
109
import { userSelected } from "./schema/transformers/userSelected";
1110
import { logger } from "../../utils/log";
1211
import { LocalRecordRepositoryFromStream } from "./repositories/localRecordRepositoryFromStream";
1312
import { RunError } from "../error";
1413
import { isMismatchEncoding } from "../../utils/encoding";
15-
import { emitExperimentalWarning } from "../../utils/stability";
1614

1715
export type Options = {
1816
app: string;
@@ -21,7 +19,6 @@ export type Options = {
2119
updateKey?: string;
2220
encoding?: SupportedImportEncoding;
2321
fields?: string[];
24-
useServerSideUpsert?: boolean;
2522
};
2623

2724
export const run: (
@@ -35,7 +32,6 @@ export const run: (
3532
attachmentsDir,
3633
updateKey,
3734
fields,
38-
useServerSideUpsert,
3935
...restApiClientOptions
4036
} = argv;
4137

@@ -64,35 +60,17 @@ export const run: (
6460

6561
const skipMissingFields = !fields;
6662
if (updateKey) {
67-
if (useServerSideUpsert) {
68-
emitExperimentalWarning(
69-
"Use server-side upsert. This option is under early development.",
70-
logger,
71-
);
72-
await upsertRecordsServerSide(
73-
apiClient,
74-
app,
75-
localRecordRepository,
76-
schema,
77-
updateKey,
78-
{
79-
attachmentsDir,
80-
skipMissingFields,
81-
},
82-
);
83-
} else {
84-
await upsertRecords(
85-
apiClient,
86-
app,
87-
localRecordRepository,
88-
schema,
89-
updateKey,
90-
{
91-
attachmentsDir,
92-
skipMissingFields,
93-
},
94-
);
95-
}
63+
await upsertRecords(
64+
apiClient,
65+
app,
66+
localRecordRepository,
67+
schema,
68+
updateKey,
69+
{
70+
attachmentsDir,
71+
skipMissingFields,
72+
},
73+
);
9674
} else {
9775
await addRecords(apiClient, app, localRecordRepository, schema, {
9876
attachmentsDir,

src/record/import/usecases/__tests__/upsert/fixtures/upsertByNumber/expected.ts

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export const expected: TestPattern["expected"] = {
77
type: "update",
88
payload: {
99
app: "1",
10+
upsert: true,
1011
records: [
1112
{
1213
updateKey: {
@@ -25,26 +26,21 @@ export const expected: TestPattern["expected"] = {
2526
},
2627
},
2728
},
28-
],
29-
},
30-
},
31-
{
32-
type: "add",
33-
payload: {
34-
app: "1",
35-
records: [
3629
{
37-
singleLineText: {
38-
value: "value3",
39-
},
40-
number: {
30+
updateKey: {
31+
field: "number",
4132
value: "3",
4233
},
43-
date: {
44-
value: "2022-04-01",
45-
},
46-
singleLineText_nonUnique: {
47-
value: "value1",
34+
record: {
35+
singleLineText: {
36+
value: "value3",
37+
},
38+
date: {
39+
value: "2022-04-01",
40+
},
41+
singleLineText_nonUnique: {
42+
value: "value1",
43+
},
4844
},
4945
},
5046
],

src/record/import/usecases/__tests__/upsert/fixtures/upsertByRecordNumber/expected.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export const expected: TestPattern["expected"] = {
77
type: "update",
88
payload: {
99
app: "1",
10+
upsert: true,
1011
records: [
1112
{
1213
id: "1",
@@ -19,20 +20,15 @@ export const expected: TestPattern["expected"] = {
1920
},
2021
},
2122
},
22-
],
23-
},
24-
},
25-
{
26-
type: "add",
27-
payload: {
28-
app: "1",
29-
records: [
3023
{
31-
singleLineText: {
32-
value: "value3",
33-
},
34-
number: {
35-
value: "3",
24+
id: "3",
25+
record: {
26+
number: {
27+
value: "3",
28+
},
29+
singleLineText: {
30+
value: "value3",
31+
},
3632
},
3733
},
3834
],

src/record/import/usecases/__tests__/upsert/fixtures/upsertByRecordNumberWithAppCode/expected.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export const expected: TestPattern["expected"] = {
77
type: "update",
88
payload: {
99
app: "1",
10+
upsert: true,
1011
records: [
1112
{
1213
id: "1",
@@ -19,20 +20,15 @@ export const expected: TestPattern["expected"] = {
1920
},
2021
},
2122
},
22-
],
23-
},
24-
},
25-
{
26-
type: "add",
27-
payload: {
28-
app: "1",
29-
records: [
3023
{
31-
singleLineText: {
32-
value: "value3",
33-
},
34-
number: {
35-
value: "3",
24+
id: "3",
25+
record: {
26+
number: {
27+
value: "3",
28+
},
29+
singleLineText: {
30+
value: "value3",
31+
},
3632
},
3733
},
3834
],

src/record/import/usecases/__tests__/upsert/fixtures/upsertByRecordNumberWithAppCodeOnKintone/expected.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export const expected: TestPattern["expected"] = {
77
type: "update",
88
payload: {
99
app: "1",
10+
upsert: true,
1011
records: [
1112
{
1213
id: "1",
@@ -19,20 +20,15 @@ export const expected: TestPattern["expected"] = {
1920
},
2021
},
2122
},
22-
],
23-
},
24-
},
25-
{
26-
type: "add",
27-
payload: {
28-
app: "1",
29-
records: [
3023
{
31-
singleLineText: {
32-
value: "value3",
33-
},
34-
number: {
35-
value: "3",
24+
id: "3",
25+
record: {
26+
number: {
27+
value: "3",
28+
},
29+
singleLineText: {
30+
value: "value3",
31+
},
3632
},
3733
},
3834
],

src/record/import/usecases/__tests__/upsert/fixtures/upsertBySingleLineText/expected.ts

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export const expected: TestPattern["expected"] = {
77
type: "update",
88
payload: {
99
app: "1",
10+
upsert: true,
1011
records: [
1112
{
1213
updateKey: {
@@ -25,26 +26,21 @@ export const expected: TestPattern["expected"] = {
2526
},
2627
},
2728
},
28-
],
29-
},
30-
},
31-
{
32-
type: "add",
33-
payload: {
34-
app: "1",
35-
records: [
3629
{
37-
singleLineText: {
30+
updateKey: {
31+
field: "singleLineText",
3832
value: "value3",
3933
},
40-
number: {
41-
value: "3",
42-
},
43-
date: {
44-
value: "2022-04-01",
45-
},
46-
singleLineText_nonUnique: {
47-
value: "value1",
34+
record: {
35+
number: {
36+
value: "3",
37+
},
38+
date: {
39+
value: "2022-04-01",
40+
},
41+
singleLineText_nonUnique: {
42+
value: "value1",
43+
},
4844
},
4945
},
5046
],

0 commit comments

Comments
 (0)