@forjio/fulkruma-cli 0.4.0
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/bin/cli.js +2 -0
- package/dist/commands/addresses.d.ts +5 -0
- package/dist/commands/addresses.js +90 -0
- package/dist/commands/addresses.js.map +1 -0
- package/dist/commands/api-keys.d.ts +5 -0
- package/dist/commands/api-keys.js +78 -0
- package/dist/commands/api-keys.js.map +1 -0
- package/dist/commands/api.generated.d.ts +23 -0
- package/dist/commands/api.generated.js +2003 -0
- package/dist/commands/api.generated.js.map +1 -0
- package/dist/commands/audit-log.d.ts +5 -0
- package/dist/commands/audit-log.js +46 -0
- package/dist/commands/audit-log.js.map +1 -0
- package/dist/commands/auth.d.ts +10 -0
- package/dist/commands/auth.js +116 -0
- package/dist/commands/auth.js.map +1 -0
- package/dist/commands/billing.d.ts +5 -0
- package/dist/commands/billing.js +144 -0
- package/dist/commands/billing.js.map +1 -0
- package/dist/commands/deliveries.d.ts +5 -0
- package/dist/commands/deliveries.js +77 -0
- package/dist/commands/deliveries.js.map +1 -0
- package/dist/commands/integrations.d.ts +5 -0
- package/dist/commands/integrations.js +24 -0
- package/dist/commands/integrations.js.map +1 -0
- package/dist/commands/licenses.d.ts +5 -0
- package/dist/commands/licenses.js +142 -0
- package/dist/commands/licenses.js.map +1 -0
- package/dist/commands/products.d.ts +12 -0
- package/dist/commands/products.js +244 -0
- package/dist/commands/products.js.map +1 -0
- package/dist/commands/shipments.d.ts +6 -0
- package/dist/commands/shipments.js +108 -0
- package/dist/commands/shipments.js.map +1 -0
- package/dist/commands/shipping.d.ts +2 -0
- package/dist/commands/shipping.js +269 -0
- package/dist/commands/shipping.js.map +1 -0
- package/dist/commands/stats.d.ts +5 -0
- package/dist/commands/stats.js +24 -0
- package/dist/commands/stats.js.map +1 -0
- package/dist/commands/stock.d.ts +5 -0
- package/dist/commands/stock.js +112 -0
- package/dist/commands/stock.js.map +1 -0
- package/dist/commands/warehouses.d.ts +5 -0
- package/dist/commands/warehouses.js +111 -0
- package/dist/commands/warehouses.js.map +1 -0
- package/dist/commands/webhooks.d.ts +5 -0
- package/dist/commands/webhooks.js +125 -0
- package/dist/commands/webhooks.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +77 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/apigen-call.d.ts +4 -0
- package/dist/lib/apigen-call.js +34 -0
- package/dist/lib/apigen-call.js.map +1 -0
- package/dist/lib/client.d.ts +21 -0
- package/dist/lib/client.js +41 -0
- package/dist/lib/client.js.map +1 -0
- package/dist/lib/credentials.d.ts +25 -0
- package/dist/lib/credentials.js +158 -0
- package/dist/lib/credentials.js.map +1 -0
- package/dist/lib/output.d.ts +19 -0
- package/dist/lib/output.js +69 -0
- package/dist/lib/output.js.map +1 -0
- package/dist/lib/util.d.ts +18 -0
- package/dist/lib/util.js +65 -0
- package/dist/lib/util.js.map +1 -0
- package/package.json +35 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-command helpers: global option resolution, error formatting,
|
|
3
|
+
* JSON body parsing for commands that accept --body.
|
|
4
|
+
*/
|
|
5
|
+
import { Command } from 'commander';
|
|
6
|
+
import { type GlobalOpts } from './client.js';
|
|
7
|
+
import { type FormatOptions } from './output.js';
|
|
8
|
+
export declare function getGlobalOpts(cmd: Command): GlobalOpts;
|
|
9
|
+
export declare function formatOpts(g: GlobalOpts): FormatOptions;
|
|
10
|
+
export declare function handleError(err: unknown, g: GlobalOpts): never;
|
|
11
|
+
/**
|
|
12
|
+
* Parse `--body` value. Accepts either:
|
|
13
|
+
* - inline JSON string (e.g., `'{"courierCode":"jne"}'`)
|
|
14
|
+
* - `@path/to/file.json` to read from disk
|
|
15
|
+
* - `-` to read from stdin (only when stdin is a pipe)
|
|
16
|
+
*/
|
|
17
|
+
export declare function parseBody(raw: string | undefined): Record<string, unknown> | undefined;
|
|
18
|
+
export declare function parseIntArg(value: string): number;
|
package/dist/lib/util.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { isFulkrumaError } from './client.js';
|
|
3
|
+
import { printError } from './output.js';
|
|
4
|
+
export function getGlobalOpts(cmd) {
|
|
5
|
+
let p = cmd;
|
|
6
|
+
while (p.parent)
|
|
7
|
+
p = p.parent;
|
|
8
|
+
return p.opts();
|
|
9
|
+
}
|
|
10
|
+
export function formatOpts(g) {
|
|
11
|
+
return {
|
|
12
|
+
json: Boolean(g.json),
|
|
13
|
+
noColor: process.env['NO_COLOR'] === '1',
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export function handleError(err, g) {
|
|
17
|
+
// Re-throw test sentinels (vitest stubs `process.exit` to throw with
|
|
18
|
+
// a `__exit:<code>` message). Without this, the action's `try/catch`
|
|
19
|
+
// turns successful runs into spurious failures during testing.
|
|
20
|
+
if (err instanceof Error && err.message.startsWith('__exit:')) {
|
|
21
|
+
throw err;
|
|
22
|
+
}
|
|
23
|
+
if (isFulkrumaError(err)) {
|
|
24
|
+
printError({ code: err.code, message: err.message, requestId: err.requestId }, formatOpts(g));
|
|
25
|
+
process.exit(err.status === 401 || err.status === 403 ? 2 : 1);
|
|
26
|
+
}
|
|
27
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
28
|
+
printError({ code: 'error', message: msg }, formatOpts(g));
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Parse `--body` value. Accepts either:
|
|
33
|
+
* - inline JSON string (e.g., `'{"courierCode":"jne"}'`)
|
|
34
|
+
* - `@path/to/file.json` to read from disk
|
|
35
|
+
* - `-` to read from stdin (only when stdin is a pipe)
|
|
36
|
+
*/
|
|
37
|
+
export function parseBody(raw) {
|
|
38
|
+
if (!raw)
|
|
39
|
+
return undefined;
|
|
40
|
+
let text = raw;
|
|
41
|
+
if (raw.startsWith('@')) {
|
|
42
|
+
text = readFileSync(raw.slice(1), 'utf8');
|
|
43
|
+
}
|
|
44
|
+
else if (raw === '-') {
|
|
45
|
+
text = readFileSync(0, 'utf8');
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
const parsed = JSON.parse(text);
|
|
49
|
+
if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
50
|
+
throw new Error('--body must decode to a JSON object');
|
|
51
|
+
}
|
|
52
|
+
return parsed;
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
56
|
+
throw new Error(`failed to parse --body: ${msg}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
export function parseIntArg(value) {
|
|
60
|
+
const n = Number.parseInt(value, 10);
|
|
61
|
+
if (Number.isNaN(n))
|
|
62
|
+
throw new Error(`invalid integer: ${value}`);
|
|
63
|
+
return n;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/lib/util.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,eAAe,EAAmB,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAsB,UAAU,EAAE,MAAM,aAAa,CAAC;AAE7D,MAAM,UAAU,aAAa,CAAC,GAAY;IACxC,IAAI,CAAC,GAAY,GAAG,CAAC;IACrB,OAAO,CAAC,CAAC,MAAM;QAAE,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9B,OAAO,CAAC,CAAC,IAAI,EAAgB,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,CAAa;IACtC,OAAO;QACL,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;QACrB,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,GAAG;KACzC,CAAC;AACJ,CAAC;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KAAK,GAAG,EAAE,CAAC;QACvB,IAAI,GAAG,YAAY,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IACjC,CAAC;IACD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAChC,IAAI,MAAM,KAAK,IAAI,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAC3E,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACzD,CAAC;QACD,OAAO,MAAiC,CAAC;IAC3C,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,GAAG,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC7D,MAAM,IAAI,KAAK,CAAC,2BAA2B,GAAG,EAAE,CAAC,CAAC;IACpD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,KAAa;IACvC,MAAM,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACrC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,oBAAoB,KAAK,EAAE,CAAC,CAAC;IAClE,OAAO,CAAC,CAAC;AACX,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@forjio/fulkruma-cli",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "CLI for Fulkruma (part of the Forjio commerce suite).",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"fulkruma": "bin/cli.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc -p tsconfig.build.json",
|
|
12
|
+
"dev": "tsc -p tsconfig.build.json --watch",
|
|
13
|
+
"test": "vitest run",
|
|
14
|
+
"lint": "tsc --noEmit",
|
|
15
|
+
"prepublishOnly": "npm run build"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@forjio/fulkruma-node": "^0.5.0",
|
|
19
|
+
"@forjio/sdk": "^0.5.0",
|
|
20
|
+
"chalk": "^5.6.2",
|
|
21
|
+
"commander": "^12.1.0"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@types/node": "^22.0.0",
|
|
25
|
+
"typescript": "^5.6.0",
|
|
26
|
+
"vitest": "^2.1.0"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist",
|
|
30
|
+
"bin"
|
|
31
|
+
],
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=20.0.0"
|
|
34
|
+
}
|
|
35
|
+
}
|