intonear-erp-cli 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +68 -7
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -15888,6 +15888,15 @@ var CLIENT_ID = "erp-cli";
|
|
|
15888
15888
|
var SCOPE = "openid erp:read erp:write offline_access";
|
|
15889
15889
|
var DEFAULT_LOOPBACK_PORT = 53682;
|
|
15890
15890
|
var CALLBACK_TIMEOUT_MS = 18e4;
|
|
15891
|
+
var ErpAuthorizationError = class extends Error {
|
|
15892
|
+
constructor(oauthError, oauthMessage) {
|
|
15893
|
+
super(oauthMessage ?? oauthError);
|
|
15894
|
+
this.oauthError = oauthError;
|
|
15895
|
+
this.oauthMessage = oauthMessage;
|
|
15896
|
+
this.name = "ErpAuthorizationError";
|
|
15897
|
+
}
|
|
15898
|
+
code = "ERP_AUTHORIZATION_FAILED";
|
|
15899
|
+
};
|
|
15891
15900
|
function base64Url(value) {
|
|
15892
15901
|
return Buffer.from(value).toString("base64url");
|
|
15893
15902
|
}
|
|
@@ -16006,9 +16015,16 @@ async function loginWithBrowser(dependencies) {
|
|
|
16006
16015
|
throw error51;
|
|
16007
16016
|
}
|
|
16008
16017
|
const callback = await callbackPromise;
|
|
16018
|
+
if (callback.searchParams.get("state") !== state) throw new Error("ERP_AUTH_INVALID_CALLBACK");
|
|
16019
|
+
const oauthError = callback.searchParams.get("error");
|
|
16020
|
+
if (oauthError) {
|
|
16021
|
+
throw new ErpAuthorizationError(
|
|
16022
|
+
oauthError,
|
|
16023
|
+
callback.searchParams.get("error_description") ?? void 0
|
|
16024
|
+
);
|
|
16025
|
+
}
|
|
16009
16026
|
const code = callback.searchParams.get("code");
|
|
16010
|
-
if (!code
|
|
16011
|
-
throw new Error("ERP_AUTH_INVALID_CALLBACK");
|
|
16027
|
+
if (!code) throw new Error("ERP_AUTH_INVALID_CALLBACK");
|
|
16012
16028
|
const response = await dependencies.fetch(`${origin}/auth/token`, {
|
|
16013
16029
|
method: "POST",
|
|
16014
16030
|
headers: { accept: "application/json", "content-type": "application/x-www-form-urlencoded" },
|
|
@@ -16378,16 +16394,23 @@ async function runCli(args2, dependencies) {
|
|
|
16378
16394
|
return 0;
|
|
16379
16395
|
}
|
|
16380
16396
|
} catch (error51) {
|
|
16381
|
-
|
|
16382
|
-
|
|
16383
|
-
|
|
16384
|
-
|
|
16397
|
+
const payload = error51 instanceof ErpAuthorizationError ? {
|
|
16398
|
+
error: error51.code,
|
|
16399
|
+
oauthError: error51.oauthError,
|
|
16400
|
+
...error51.oauthMessage ? { message: error51.oauthMessage } : {}
|
|
16401
|
+
} : { error: error51 instanceof Error ? error51.message : "AUTH_FAILED" };
|
|
16402
|
+
dependencies.stderr(`${JSON.stringify(payload)}
|
|
16403
|
+
`);
|
|
16385
16404
|
return 1;
|
|
16386
16405
|
}
|
|
16387
16406
|
dependencies.stderr(`${JSON.stringify({ error: "UNKNOWN_AUTH_COMMAND" })}
|
|
16388
16407
|
`);
|
|
16389
16408
|
return 1;
|
|
16390
16409
|
}
|
|
16410
|
+
if (args2.length === 2 && args2[0] === "call" && args2[1] === "--help") {
|
|
16411
|
+
dependencies.stdout(callHelp());
|
|
16412
|
+
return 0;
|
|
16413
|
+
}
|
|
16391
16414
|
if (args2[0] === "list") {
|
|
16392
16415
|
const operations2 = Object.values(dependencies.operations).filter(isCallableAgentOperation).sort((left, right) => left.operationId.localeCompare(right.operationId)).map(
|
|
16393
16416
|
({
|
|
@@ -16443,6 +16466,13 @@ async function runCli(args2, dependencies) {
|
|
|
16443
16466
|
`);
|
|
16444
16467
|
return 0;
|
|
16445
16468
|
}
|
|
16469
|
+
if (args2.length === 2 && args2[1] === "--help") {
|
|
16470
|
+
const help2 = commandGroupHelp(args2[0] ?? "", dependencies.operations);
|
|
16471
|
+
if (help2) {
|
|
16472
|
+
dependencies.stdout(help2);
|
|
16473
|
+
return 0;
|
|
16474
|
+
}
|
|
16475
|
+
}
|
|
16446
16476
|
if (args2[0] === "call") {
|
|
16447
16477
|
const operation = args2[1] ? dependencies.operations[args2[1]] : void 0;
|
|
16448
16478
|
if (!operation || !isCallableAgentOperation(operation)) {
|
|
@@ -16511,6 +16541,37 @@ async function runCli(args2, dependencies) {
|
|
|
16511
16541
|
`);
|
|
16512
16542
|
return 1;
|
|
16513
16543
|
}
|
|
16544
|
+
function callHelp() {
|
|
16545
|
+
return `intoNear ERP CLI \xB7 call
|
|
16546
|
+
|
|
16547
|
+
\u7528\u6CD5\uFF1A
|
|
16548
|
+
intonear-erp-cli call <operationId> [--\u53C2\u6570 \u503C]
|
|
16549
|
+
|
|
16550
|
+
\u5148\u8FD0\u884C intonear-erp-cli list \u53D1\u73B0 operationId\uFF0C\u518D\u8FD0\u884C
|
|
16551
|
+
intonear-erp-cli describe <operationId> \u67E5\u770B\u5B8C\u6574\u53C2\u6570\u5951\u7EA6\u3002
|
|
16552
|
+
JSON \u8BF7\u6C42\u4F53\u4F7F\u7528 --body\uFF0C\u6587\u4EF6\u4F7F\u7528 --file\u3002
|
|
16553
|
+
`;
|
|
16554
|
+
}
|
|
16555
|
+
function commandGroupHelp(group, operations2) {
|
|
16556
|
+
const commands = Object.values(operations2).filter(isCallableAgentOperation).flatMap((operation) => {
|
|
16557
|
+
const [candidateGroup, subcommand] = operation.command?.split(" ") ?? [];
|
|
16558
|
+
return candidateGroup === group && subcommand ? [{ operation, subcommand }] : [];
|
|
16559
|
+
}).sort((left, right) => left.subcommand.localeCompare(right.subcommand));
|
|
16560
|
+
if (commands.length === 0) return void 0;
|
|
16561
|
+
const commandLines = commands.map(
|
|
16562
|
+
({ operation, subcommand }) => ` ${subcommand.padEnd(16)} ${operation.summary ?? operation.operationId}`
|
|
16563
|
+
).join("\n");
|
|
16564
|
+
return `intoNear ERP CLI \xB7 ${group}
|
|
16565
|
+
|
|
16566
|
+
\u7528\u6CD5\uFF1A
|
|
16567
|
+
intonear-erp-cli ${group} <\u5B50\u547D\u4EE4> [...]
|
|
16568
|
+
|
|
16569
|
+
\u5B50\u547D\u4EE4\uFF1A
|
|
16570
|
+
${commandLines}
|
|
16571
|
+
|
|
16572
|
+
\u8FD0\u884C intonear-erp-cli describe <operationId> \u67E5\u770B\u5B8C\u6574\u53C2\u6570\u5951\u7EA6\u3002
|
|
16573
|
+
`;
|
|
16574
|
+
}
|
|
16514
16575
|
function parseDomainArguments(operation, args2) {
|
|
16515
16576
|
const pathNames = operation.request.path ? Object.keys(operation.request.path.shape) : [];
|
|
16516
16577
|
const values = {};
|
|
@@ -16670,7 +16731,7 @@ function createCredentialStore(path = defaultCredentialPath(), options = {}) {
|
|
|
16670
16731
|
// package.json
|
|
16671
16732
|
var package_default = {
|
|
16672
16733
|
name: "intonear-erp-cli",
|
|
16673
|
-
version: "0.2.
|
|
16734
|
+
version: "0.2.2",
|
|
16674
16735
|
description: "intoNear ERP \u6E10\u8FDB\u5F0F\u8BFB\u5199\u547D\u4EE4\u884C\u5BA2\u6237\u7AEF",
|
|
16675
16736
|
type: "module",
|
|
16676
16737
|
bin: {
|