Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@kintone/data-loader

Package Overview
Dependencies
Maintainers
3
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kintone/data-loader - npm Package Compare versions

Comparing version 0.6.0 to 0.7.0

16

CHANGELOG.md

@@ -6,2 +6,18 @@ # Change Log

# [0.7.0](https://github.com/kintone/js-sdk/compare/@kintone/data-loader@0.6.0...@kintone/data-loader@0.7.0) (2022-02-25)
### Bug Fixes
* **data-loader:** export csv correctly when Table value is empty array ([#1349](https://github.com/kintone/js-sdk/issues/1349)) ([0f1371e](https://github.com/kintone/js-sdk/commit/0f1371e54ecdf64b57dba5d3c9307e1b4a6923a1))
### Features
* **data-loader:** support User/Department/Group Selection Field ([#1345](https://github.com/kintone/js-sdk/issues/1345)) ([7ebe9c7](https://github.com/kintone/js-sdk/commit/7ebe9c7b1aa1852569f125736b3e646e4d9e79ad)), closes [#1332](https://github.com/kintone/js-sdk/issues/1332) [#1335](https://github.com/kintone/js-sdk/issues/1335)
# [0.6.0](https://github.com/kintone/js-sdk/compare/@kintone/data-loader@0.5.34...@kintone/data-loader@0.6.0) (2022-02-18)

@@ -8,0 +24,0 @@

@@ -20,4 +20,12 @@ "use strict";

});
expect((0, convertToKintoneRecordFormatValue_1.convertToKintoneRecordFormatValue)({
fieldType: "USER_SELECT",
value: "sato",
})).toEqual([
{
code: "sato",
},
]);
});
});
//# sourceMappingURL=convertToKintoneRecordFormatValue.test.js.map

@@ -13,2 +13,5 @@ "use strict";

subTableCheckbox: "st_sample1",
userSelect: "sato\ntanaka",
organizationSelect: "Development Div",
groupSelect: "Administrators",
},

@@ -20,2 +23,5 @@ {

subTableCheckbox: "st_sample2",
userSelect: "sato\ntanaka",
organizationSelect: "Development Div",
groupSelect: "Administrators",
},

@@ -39,2 +45,26 @@ {

},
userSelect: {
value: [
{
code: "sato",
},
{
code: "tanaka",
},
],
},
groupSelect: {
value: [
{
code: "Administrators",
},
],
},
organizationSelect: {
value: [
{
code: "Development Div",
},
],
},
},

@@ -51,2 +81,26 @@ },

},
userSelect: {
value: [
{
code: "sato",
},
{
code: "tanaka",
},
],
},
groupSelect: {
value: [
{
code: "Administrators",
},
],
},
organizationSelect: {
value: [
{
code: "Development Div",
},
],
},
},

@@ -63,2 +117,11 @@ },

},
userSelect: {
value: [],
},
groupSelect: {
value: [],
},
organizationSelect: {
value: [],
},
},

@@ -65,0 +128,0 @@ },

19

lib/parsers/parseCsv/__tests__/parseCsv.test.js

@@ -12,7 +12,8 @@ "use strict";

it("should convert csv string to JSON correctly", () => {
const csv = `"recordNumber","updatedTime","dropDown","creator","modifier","richText","singleLineText","number","radioButton","multiLineText","createdTime","checkBox","calc","multiSelect"
const csv = `"recordNumber","updatedTime","dropDown","creator","modifier","richText","singleLineText","number","radioButton","multiLineText","createdTime","checkBox","calc","multiSelect","userSelect","organizationSelect","groupSelect"
"9","2021-02-16T02:43:00Z","sample1","username","username","<div><div>rich text editor<br /></div></div><div>rich text editor<br /></div><div>rich text editor<br /></div>","""single line text""","8","sample2","multi
line
text","2021-02-10T06:14:00Z","""sample2""","16","""sample3""
sample4,sample5"
sample4,sample5","sato
tanaka","Development Div","Administrators"
`;

@@ -22,16 +23,20 @@ expect((0, index_1.parseCsv)(csv, fieldsJson)).toEqual(expectedJson);

it("should convert subtable included csv string to JSON correctly", () => {
const csv = `"*","recordNumber","updatedTime","dropDown","creator","subTable","subTableText","subTableCheckbox","modifier","richText","singleLineText","number","radioButton","multiLineText","createdTime","checkBox","calc","multiSelect"
"*","9","2021-02-16T02:43:00Z","sample1","username","537306","text_line1","st_sample1","username","<div><div>rich text editor<br /></div></div><div>rich text editor<br /></div><div>rich text editor<br /></div>","""single line text""","8","sample2","multi
const csv = `"*","recordNumber","updatedTime","dropDown","creator","subTable","subTableText","subTableCheckbox","userSelect","organizationSelect","groupSelect","modifier","richText","singleLineText","number","radioButton","multiLineText","createdTime","checkBox","calc","multiSelect"
"*","9","2021-02-16T02:43:00Z","sample1","username","537306","text_line1","st_sample1","sato
tanaka","Development Div","Administrators","username","<div><div>rich text editor<br /></div></div><div>rich text editor<br /></div><div>rich text editor<br /></div>","""single line text""","8","sample2","multi
line
text","2021-02-10T06:14:00Z","""sample2""","16","""sample3""
sample4"
,"9","2021-02-16T02:43:00Z","sample1","username","537307","text_line2","st_sample2","username","<div><div>rich text editor<br /></div></div><div>rich text editor<br /></div><div>rich text editor<br /></div>","""single line text""","8","sample2","multi
,"9","2021-02-16T02:43:00Z","sample1","username","537307","text_line2","st_sample2","sato
tanaka","Development Div","Administrators","username","<div><div>rich text editor<br /></div></div><div>rich text editor<br /></div><div>rich text editor<br /></div>","""single line text""","8","sample2","multi
line
text","2021-02-10T06:14:00Z","""sample2""","16","""sample3""
sample4"
"*","10","2021-02-16T02:43:00Z","sample1","username","537308","text_line1","st_sample1","username","<div><div>rich text editor<br /></div></div><div>rich text editor<br /></div><div>rich text editor<br /></div>","""single line text""","8","sample2","multi
"*","10","2021-02-16T02:43:00Z","sample1","username","537308","text_line1","st_sample1","sato
tanaka","Development Div","Administrators","username","<div><div>rich text editor<br /></div></div><div>rich text editor<br /></div><div>rich text editor<br /></div>","""single line text""","8","sample2","multi
line
text","2021-02-10T06:14:00Z","""sample2""","16","""sample3""
sample4"
,"10","2021-02-16T02:43:00Z","sample1","username","537309","text_line2","st_sample2","username","<div><div>rich text editor<br /></div></div><div>rich text editor<br /></div><div>rich text editor<br /></div>","""single line text""","8","sample2","multi
,"10","2021-02-16T02:43:00Z","sample1","username","537309","text_line2","st_sample2","sato
tanaka","Development Div","Administrators","username","<div><div>rich text editor<br /></div></div><div>rich text editor<br /></div><div>rich text editor<br /></div>","""single line text""","8","sample2","multi
line

@@ -38,0 +43,0 @@ text","2021-02-10T06:14:00Z","""sample2""","16","""sample3""

@@ -6,2 +6,4 @@ export declare const convertToKintoneRecordFormatValue: ({ fieldType, value, }: {

code: string;
}[] | {
code: string;
};

@@ -25,2 +25,10 @@ "use strict";

return value ? value.split(constants_1.LINE_BREAK) : [];
case "USER_SELECT":
case "ORGANIZATION_SELECT":
case "GROUP_SELECT":
return value
? value.split(constants_1.LINE_BREAK).map((code) => ({
code,
}))
: [];
default:

@@ -27,0 +35,0 @@ return value;

@@ -5,3 +5,5 @@ import { CsvRows, FieldProperties } from "../../types/kintone";

code: string;
};
} | Array<{
code: string;
}>;
}>;

@@ -8,0 +10,0 @@ export declare const extractSubtableFieldsValue: ({ rows, fieldProperties, }: {

@@ -19,2 +19,5 @@ "use strict";

"CHECK_BOX",
"USER_SELECT",
"ORGANIZATION_SELECT",
"GROUP_SELECT",
].includes(fieldType);

@@ -21,0 +24,0 @@ };

@@ -11,3 +11,3 @@ "use strict";

expect((0, buildHeaderFields_1.buildHeaderFields)(fieldsJson.properties).includes(constants_1.PRIMARY_MARK)).toBe(false);
expect((0, buildHeaderFields_1.buildHeaderFields)(fieldsJson.properties)).toHaveLength(14);
expect((0, buildHeaderFields_1.buildHeaderFields)(fieldsJson.properties)).toHaveLength(17);
expect((0, buildHeaderFields_1.buildHeaderFields)(fileFieldsJson.properties)).toHaveLength(15);

@@ -17,5 +17,5 @@ });

expect((0, buildHeaderFields_1.buildHeaderFields)(subtableFieldsJson.properties).includes(constants_1.PRIMARY_MARK)).toBe(true);
expect((0, buildHeaderFields_1.buildHeaderFields)(subtableFieldsJson.properties)).toHaveLength(19);
expect((0, buildHeaderFields_1.buildHeaderFields)(subtableFieldsJson.properties)).toHaveLength(22);
});
});
//# sourceMappingURL=buildHeaderFields.test.js.map

@@ -11,10 +11,12 @@ "use strict";

const subtableWithoutAttachmentsDirRecords = require("./fixtures/subtable_input_without_attachments_dir.json");
const subtableWithEmptyTable = require("./fixtures/subtable_input_with_empty_table.json");
const subtableFieldsJson = require("./fixtures/subtable_fields.json");
describe("convertKintoneRecordsToCsv", () => {
it("should convert kintone records to csv string correctly", () => {
const expectedCsv = `"recordNumber","updatedTime","dropDown","creator","modifier","richText","singleLineText","number","radioButton","multiLineText","createdTime","checkBox","calc","multiSelect"
const expectedCsv = `"recordNumber","updatedTime","dropDown","creator","modifier","richText","singleLineText","number","radioButton","multiLineText","createdTime","checkBox","calc","multiSelect","userSelect","organizationSelect","groupSelect"
"9","2021-02-16T02:43:00Z","sample1","username","username","<div><div>rich text editor<br /></div></div><div>rich text editor<br /></div><div>rich text editor<br /></div>","""single line text""","8","sample2","multi
line
text","2021-02-10T06:14:00Z","""sample2""","16","""sample3""
sample4"
sample4","sato
tanaka","Development Div","Administrators"
`;

@@ -55,5 +57,6 @@ expect((0, convertKintoneRecordsToCsv_1.convertRecordsToCsv)({

it("should convert kintone records to csv string correctly when SUBTABLE included with attachmentsDir option", () => {
const expectedCsv = `"*","recordNumber","updatedTime","dropDown","creator","subTable","subTableText","subTableCheckbox","subTableFile","modifier","richText","singleLineText","number","radioButton","multiLineText","createdTime","checkBox","calc","multiSelect"
const expectedCsv = `"*","recordNumber","updatedTime","dropDown","creator","subTable","subTableText","subTableCheckbox","subTableFile","userSelect","organizationSelect","groupSelect","modifier","richText","singleLineText","number","radioButton","multiLineText","createdTime","checkBox","calc","multiSelect"
*,"9","2021-02-16T02:43:00Z","sample1","username","537306","text_line1","st_sample1","subTableFile-9-0/test.txt
subTableFile-9-0/test (1).txt","username","<div><div>rich text editor<br /></div></div><div>rich text editor<br /></div><div>rich text editor<br /></div>","""single line text""","8","sample2","multi
subTableFile-9-0/test (1).txt","sato
tanaka","Development Div","Administrators","username","<div><div>rich text editor<br /></div></div><div>rich text editor<br /></div><div>rich text editor<br /></div>","""single line text""","8","sample2","multi
line

@@ -63,3 +66,4 @@ text","2021-02-10T06:14:00Z","""sample2""","16","""sample3""

,"9","2021-02-16T02:43:00Z","sample1","username","537307","text_line2","st_sample2","subTableFile-9-1/test.txt
subTableFile-9-1/test (1).txt","username","<div><div>rich text editor<br /></div></div><div>rich text editor<br /></div><div>rich text editor<br /></div>","""single line text""","8","sample2","multi
subTableFile-9-1/test (1).txt","sato
tanaka","Development Div","Administrators","username","<div><div>rich text editor<br /></div></div><div>rich text editor<br /></div><div>rich text editor<br /></div>","""single line text""","8","sample2","multi
line

@@ -76,5 +80,6 @@ text","2021-02-10T06:14:00Z","""sample2""","16","""sample3""

it("should convert kintone records to csv string correctly when SUBTABLE included without attachmentsDir option", () => {
const expectedCsv = `"*","recordNumber","updatedTime","dropDown","creator","subTable","subTableText","subTableCheckbox","subTableFile","modifier","richText","singleLineText","number","radioButton","multiLineText","createdTime","checkBox","calc","multiSelect"
const expectedCsv = `"*","recordNumber","updatedTime","dropDown","creator","subTable","subTableText","subTableCheckbox","subTableFile","userSelect","organizationSelect","groupSelect","modifier","richText","singleLineText","number","radioButton","multiLineText","createdTime","checkBox","calc","multiSelect"
*,"9","2021-02-16T02:43:00Z","sample1","username","537306","text_line1","st_sample1","test.txt
test.txt","username","<div><div>rich text editor<br /></div></div><div>rich text editor<br /></div><div>rich text editor<br /></div>","""single line text""","8","sample2","multi
test.txt","sato
tanaka","Development Div","Administrators","username","<div><div>rich text editor<br /></div></div><div>rich text editor<br /></div><div>rich text editor<br /></div>","""single line text""","8","sample2","multi
line

@@ -84,3 +89,4 @@ text","2021-02-10T06:14:00Z","""sample2""","16","""sample3""

,"9","2021-02-16T02:43:00Z","sample1","username","537307","text_line2","st_sample2","test.txt
test.txt","username","<div><div>rich text editor<br /></div></div><div>rich text editor<br /></div><div>rich text editor<br /></div>","""single line text""","8","sample2","multi
test.txt","sato
tanaka","Development Div","Administrators","username","<div><div>rich text editor<br /></div></div><div>rich text editor<br /></div><div>rich text editor<br /></div>","""single line text""","8","sample2","multi
line

@@ -95,3 +101,15 @@ text","2021-02-10T06:14:00Z","""sample2""","16","""sample3""

});
it("should convert kintone records to csv string correctly when SUBTABLE value is an empty array", () => {
const expectedCsv = `"*","recordNumber","updatedTime","dropDown","creator","subTable","subTableText","subTableCheckbox","subTableFile","userSelect","organizationSelect","groupSelect","modifier","richText","singleLineText","number","radioButton","multiLineText","createdTime","checkBox","calc","multiSelect"
*,"9","2021-02-16T02:43:00Z","sample1","username",,,,,,,,"username","<div><div>rich text editor<br /></div></div><div>rich text editor<br /></div><div>rich text editor<br /></div>","""single line text""","8","sample2","multi
line
text","2021-02-10T06:14:00Z","""sample2""","16","""sample3""
sample4"
`;
expect((0, convertKintoneRecordsToCsv_1.convertRecordsToCsv)({
records: subtableWithEmptyTable,
fieldProperties: subtableFieldsJson.properties,
})).toBe(expectedCsv);
});
});
//# sourceMappingURL=convertKintoneRecordsToCsv.test.js.map

@@ -19,2 +19,5 @@ "use strict";

subTableFile: `"test.txt\ntest.txt"`,
userSelect: `"sato\ntanaka"`,
organizationSelect: `"Development Div"`,
groupSelect: `"Administrators"`,
});

@@ -26,2 +29,5 @@ expect((0, extractFieldValue_1.extractFieldValue)(record.subTable, "attachmentsDir")[0]).toEqual({

subTableFile: `"subTableFile-9-0/test.txt\nsubTableFile-9-0/test (1).txt"`,
userSelect: `"sato\ntanaka"`,
organizationSelect: `"Development Div"`,
groupSelect: `"Administrators"`,
});

@@ -28,0 +34,0 @@ });

@@ -24,2 +24,5 @@ "use strict";

"SUBTABLE",
"USER_SELECT",
"ORGANIZATION_SELECT",
"GROUP_SELECT",
];

@@ -38,2 +41,5 @@ const supportedFieldTypesInSubtable = [

"FILE",
"USER_SELECT",
"ORGANIZATION_SELECT",
"GROUP_SELECT",
];

@@ -40,0 +46,0 @@ const buildHeaderFields = (fieldProperties) => {

@@ -66,8 +66,10 @@ "use strict";

const rowObjects = subtableFieldCodes.reduce((ret, subtableFieldCode) => {
return ret.concat(recordObject[subtableFieldCode].map((field) => (Object.assign(Object.assign({}, primaryRowObject), Object.keys(field).reduce((rowObject, fieldCode) => {
return Object.assign(Object.assign({}, rowObject), {
// NOTE: If fieldCode is `id`, use field code of subtable itself
// to avoid conflicts between each subtable.
[fieldCode === "id" ? subtableFieldCode : fieldCode]: field[fieldCode] });
}, {})))));
return recordObject[subtableFieldCode].length === 0
? [primaryRowObject]
: ret.concat(recordObject[subtableFieldCode].map((field) => (Object.assign(Object.assign({}, primaryRowObject), Object.keys(field).reduce((rowObject, fieldCode) => {
return Object.assign(Object.assign({}, rowObject), {
// NOTE: If fieldCode is `id`, use field code of subtable itself
// to avoid conflicts between each subtable.
[fieldCode === "id" ? subtableFieldCode : fieldCode]: field[fieldCode] });
}, {})))));
}, []);

@@ -74,0 +76,0 @@ if (rowObjects.length !== 0) {

@@ -35,2 +35,6 @@ "use strict";

}, {}))));
case "USER_SELECT":
case "ORGANIZATION_SELECT":
case "GROUP_SELECT":
return (0, encloseInDoubleQuotes_1.encloseInDoubleQuotes)((0, escapeDoubleQuotes_1.escapeDoubleQuotes)(field.value.map((value) => value.code).join(constants_1.LINE_BREAK)));
default:

@@ -37,0 +41,0 @@ return "";

{
"name": "@kintone/data-loader",
"version": "0.6.0",
"version": "0.7.0",
"publishConfig": {

@@ -62,3 +62,3 @@ "access": "public"

},
"gitHead": "214616592838a7c3855f0594909d9122378ba5b5"
"gitHead": "a3829c5d82e181c92b20191776458230bdfd0ad0"
}

@@ -13,4 +13,2 @@ # kintone-data-loader

- Update records when importing
- When using CSV format, the following fields are not supported
- User selection, Group selection, Department selection

@@ -239,2 +237,12 @@ We plan to support them in the future release.

#### User Selection, Department Selection, Group Selection
If multiple value is selected, separated with line break (\n). (equivalent to `value.code` in REST API).
```csv
"userSelectionField","departmentSelectionField","groupSelectionField"
"John
Bob","Development Div","Administrators"
```
#### Created by, Updated by

@@ -241,0 +249,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc