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

@kintone/data-loader

Package Overview
Dependencies
Maintainers
8
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.3.0 to 0.4.0

lib/parsers/parseCsv/__tests__/convertToKintoneRecordFormatValue.test.d.ts

27

CHANGELOG.md

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

# [0.4.0](https://github.com/kintone/js-sdk/compare/@kintone/data-loader@0.3.0...@kintone/data-loader@0.4.0) (2021-05-11)
### Bug Fixes
* **data-loader:** apply accurated types to CLI command builder ([#832](https://github.com/kintone/js-sdk/issues/832)) ([8487c12](https://github.com/kintone/js-sdk/commit/8487c12ecb88922b5612270d9489571cfab5c354))
* **deps:** update dependency yargs to v17 ([#856](https://github.com/kintone/js-sdk/issues/856)) ([8b9f290](https://github.com/kintone/js-sdk/commit/8b9f290c7ff0b70a6460843984bdd117a57760ea))
### chore
* drop Node v10 support ([#870](https://github.com/kintone/js-sdk/issues/870)) ([5263389](https://github.com/kintone/js-sdk/commit/526338928e5a89a1f24c7458fc0c7c2452e36cc1))
### Features
* **data-loader:** Support fields in table with CSV ([#760](https://github.com/kintone/js-sdk/issues/760)) ([c727b25](https://github.com/kintone/js-sdk/commit/c727b25e69607eae83e893a4289f57e36cfabc97))
### BREAKING CHANGES
* drop Node v10 support because of the EOL.
# [0.3.0](https://github.com/kintone/js-sdk/compare/@kintone/data-loader@0.2.4...@kintone/data-loader@0.3.0) (2021-04-27)

@@ -8,0 +35,0 @@

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

const rest_api_client_1 = require("@kintone/rest-api-client");
const packageJson = require("../../package.json");
const expectedUa = `${packageJson.name}@${packageJson.version}`;
jest.mock("@kintone/rest-api-client");

@@ -27,2 +29,3 @@ describe("api", () => {

},
userAgent: expectedUa,
});

@@ -46,2 +49,3 @@ });

guestSpaceId: GUEST_SPACE_ID,
userAgent: expectedUa,
});

@@ -58,2 +62,3 @@ });

auth: { apiToken: API_TOKEN },
userAgent: expectedUa,
});

@@ -75,2 +80,3 @@ });

},
userAgent: expectedUa,
});

@@ -99,2 +105,3 @@ });

},
userAgent: expectedUa,
});

@@ -121,2 +128,3 @@ });

},
userAgent: expectedUa,
});

@@ -123,0 +131,0 @@ });

1

lib/api.d.ts

@@ -12,3 +12,4 @@ import { KintoneRestAPIClient } from "@kintone/rest-api-client";

pfxFilePassword?: string;
userAgent?: string;
};
export declare const buildRestAPIClient: (options: RestAPIClientOptions) => KintoneRestAPIClient;

3

lib/api.js

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

const rest_api_client_1 = require("@kintone/rest-api-client");
const packageJson = require("../package.json");
const buildAuthParam = (options) => {

@@ -38,5 +39,5 @@ const passwordAuthParam = {

const buildRestAPIClient = (options) => {
return new rest_api_client_1.KintoneRestAPIClient(Object.assign(Object.assign(Object.assign({ baseUrl: options.baseUrl, auth: buildAuthParam(options) }, buildBasicAuthParam(options)), buildClientCertAuth(options)), (options.guestSpaceId ? { guestSpaceId: options.guestSpaceId } : {})));
return new rest_api_client_1.KintoneRestAPIClient(Object.assign(Object.assign(Object.assign(Object.assign({ baseUrl: options.baseUrl, auth: buildAuthParam(options) }, buildBasicAuthParam(options)), buildClientCertAuth(options)), (options.guestSpaceId ? { guestSpaceId: options.guestSpaceId } : {})), { userAgent: `${packageJson.name}@${packageJson.version}` }));
};
exports.buildRestAPIClient = buildRestAPIClient;
//# sourceMappingURL=api.js.map

@@ -1,8 +0,34 @@

import { Options } from "../controllers/export";
import { RestAPIClientOptions } from "../api";
declare type Argv = RestAPIClientOptions & Options;
import { ExportFileFormat } from "../controllers/export";
import * as yargs from "yargs";
export declare const command = "export";
export declare const desc = "export the records of the specified app";
export declare const builder: (yargs: any) => any;
export declare const handler: (argv: Argv) => Promise<void>;
export declare const builder: (args: yargs.Argv) => yargs.Argv<yargs.Defined<{
"base-url": string | undefined;
} & {
username: string | undefined;
} & {
password: string | undefined;
} & {
"api-token": string | undefined;
} & {
"basic-auth-username": string | undefined;
} & {
"basic-auth-password": string | undefined;
} & {
app: string | undefined;
} & {
"guest-space-id": string | undefined;
} & {
"attachment-dir": string | undefined;
} & {
format: ExportFileFormat;
} & {
query: string | undefined;
} & {
"pfx-file-path": string | undefined;
} & {
"pfx-file-password": string | undefined;
}, "app" | "base-url">>;
declare type Args = yargs.Arguments<ReturnType<typeof builder> extends yargs.Argv<infer U> ? U : never>;
export declare const handler: (args: Args) => Promise<void>;
export {};

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

exports.desc = "export the records of the specified app";
const builder = (yargs) => yargs
const builder = (args) => args
.option("base-url", {

@@ -15,3 +15,2 @@ describe: "Kintone Base Url",

type: "string",
demandOption: true,
})

@@ -53,3 +52,2 @@ .option("username", {

type: "string",
demandOption: true,
})

@@ -83,6 +81,27 @@ .option("guest-space-id", {

type: "string",
});
})
// NOTE: Since yargs doesn't detect the type correctly by adding `demandOption: true` in `option()`,
// (inferred type always contains `| undefined`)
// related issue: https://github.com/yargs/yargs/issues/1928
// we declare the required params later as a workaround.
.demandOption(["base-url", "app"]);
exports.builder = builder;
const handler = (argv) => export_1.run(argv);
const handler = (args) => {
return export_1.run({
baseUrl: args["base-url"],
username: args.username,
password: args.password,
apiToken: args["api-token"],
basicAuthUsername: args["basic-auth-username"],
basicAuthPassword: args["basic-auth-password"],
app: args.app,
guestSpaceId: args["guest-space-id"],
attachmentDir: args["attachment-dir"],
format: args.format,
query: args.query,
pfxFilePath: args["pfx-file-path"],
pfxFilePassword: args["pfx-file-password"],
});
};
exports.handler = handler;
//# sourceMappingURL=export.js.map

@@ -1,8 +0,29 @@

import { Options } from "../controllers/import";
import { RestAPIClientOptions } from "../api";
declare type Argv = RestAPIClientOptions & Options;
import * as yargs from "yargs";
export declare const command = "import";
export declare const desc = "import the records of the specified app";
export declare const builder: (yargs: any) => any;
export declare const handler: (argv: Argv) => Promise<void>;
export declare const builder: (args: yargs.Argv) => yargs.Argv<yargs.Defined<{
"base-url": string | undefined;
} & {
username: string | undefined;
} & {
password: string | undefined;
} & {
"api-token": string | undefined;
} & {
"basic-auth-username": string | undefined;
} & {
"basic-auth-password": string | undefined;
} & {
app: string | undefined;
} & {
"guest-space-id": string | undefined;
} & {
"file-path": string | undefined;
} & {
"pfx-file-path": string | undefined;
} & {
"pfx-file-password": string | undefined;
}, "app" | "base-url" | "file-path">>;
declare type Args = yargs.Arguments<ReturnType<typeof builder> extends yargs.Argv<infer U> ? U : never>;
export declare const handler: (args: Args) => Promise<void>;
export {};

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

exports.desc = "import the records of the specified app";
const builder = (yargs) => yargs
const builder = (args) => args
.option("base-url", {

@@ -14,3 +14,2 @@ describe: "Kintone Base Url",

type: "string",
demandOption: true,
})

@@ -52,3 +51,2 @@ .option("username", {

type: "string",
demandOption: true,
})

@@ -64,3 +62,2 @@ .option("guest-space-id", {

type: "string",
demandOption: true,
})

@@ -74,6 +71,25 @@ .option("pfx-file-path", {

type: "string",
});
})
// NOTE: Since yargs doesn't detect the type correctly by adding `demandOption: true` in `option()`,
// (inferred type always contains `| undefined`)
// related issue: https://github.com/yargs/yargs/issues/1928
// we declare the required params later as a workaround.
.demandOption(["base-url", "app", "file-path"]);
exports.builder = builder;
const handler = (argv) => import_1.run(argv);
const handler = (args) => {
return import_1.run({
baseUrl: args["base-url"],
username: args.username,
password: args.password,
apiToken: args["api-token"],
basicAuthUsername: args["basic-auth-username"],
basicAuthPassword: args["basic-auth-password"],
app: args.app,
guestSpaceId: args["guest-space-id"],
filePath: args["file-path"],
pfxFilePath: args["pfx-file-path"],
pfxFilePassword: args["pfx-file-password"],
});
};
exports.handler = handler;
//# sourceMappingURL=import.js.map

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

const api_1 = require("../api");
const printers_1 = require("../printers");
const printAsJson_1 = require("../printers/printAsJson");
const printAsCsv_1 = require("../printers/printAsCsv");
const run = (argv) => __awaiter(void 0, void 0, void 0, function* () {
const apiClient = api_1.buildRestAPIClient(argv);
const records = yield exportRecords(apiClient, argv);
const printer = printers_1.buildPrinter(argv.format);
printer(records);
yield printRecords({
records,
argv,
apiClient,
});
});

@@ -70,2 +74,19 @@ exports.run = run;

});
function printRecords({ records, argv, apiClient, }) {
return __awaiter(this, void 0, void 0, function* () {
switch (argv.format) {
case "json": {
printAsJson_1.printAsJson(records);
break;
}
case "csv": {
printAsCsv_1.printAsCsv(records, yield apiClient.app.getFormFields(argv));
break;
}
default: {
throw new Error(`Unknown format type. '${argv.format}' is unknown as a format option.`);
}
}
});
}
//# sourceMappingURL=export.js.map

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

const api_1 = require("../api");
const parsers_1 = require("../parsers");
const path_1 = __importDefault(require("path"));
const fs_1 = __importDefault(require("fs"));
const parseJson_1 = require("../parsers/parseJson");
const parseCsv_1 = require("../parsers/parseCsv");
const CHUNK_LENGTH = 100;

@@ -71,14 +72,20 @@ const run = (argv) => __awaiter(void 0, void 0, void 0, function* () {

const type = extractFileType(filePath);
const parser = parsers_1.buildParser(type);
const records = type === "csv"
? parser(content, yield fetchFieldsJson(options))
: // @ts-ignore
parser(content);
const records = yield parseSource({
type,
source: content,
options,
});
yield addAllRecordsChunk(app, records);
});
}
function fetchFieldsJson(options) {
function parseSource({ type, source, options, }) {
return __awaiter(this, void 0, void 0, function* () {
const fieldsJson = yield apiClient.app.getFormFields(options);
return fieldsJson;
switch (type) {
case "json":
return parseJson_1.parseJson(source);
case "csv":
return parseCsv_1.parseCsv(source, yield apiClient.app.getFormFields(options));
default:
throw new Error(`Unexpected file type: ${type} is unacceptable.`);
}
});

@@ -85,0 +92,0 @@ }

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -7,4 +26,11 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

const yargs_1 = __importDefault(require("yargs"));
const commandExport = __importStar(require("./commands/export"));
const commandImport = __importStar(require("./commands/import"));
// eslint-disable-next-line no-unused-expressions
yargs_1.default.commandDir("commands").demandCommand().strict().help().argv;
yargs_1.default
.command(commandExport)
.command(commandImport)
.demandCommand()
.strict()
.help().argv;
//# sourceMappingURL=main.js.map
{
"name": "@kintone/data-loader",
"version": "0.3.0",
"version": "0.4.0",
"publishConfig": {

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

"engines": {
"node": "^10.17.0 || >=11.14"
"node": ">=12"
},

@@ -56,10 +56,10 @@ "devDependencies": {

"cross-env": "^7.0.2",
"pkg": "^5.0.0"
"pkg": "^5.1.0"
},
"dependencies": {
"@kintone/rest-api-client": "^1.13.0",
"@kintone/rest-api-client": "^2.0.0",
"csv-parse": "^4.15.4",
"yargs": "^16.2.0"
"yargs": "^17.0.1"
},
"gitHead": "a1fe9d7dd71403bf6b8367c626898fbf6e1a327c"
"gitHead": "cd7d74f81ec46fea38f2e3e22da1106575915461"
}

@@ -14,3 +14,2 @@ # kintone-data-loader

- User selection, Group selection, Department selection
- Fields in table field

@@ -17,0 +16,0 @@ We plan to support them in the future release.

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