@deepraxis/cli 0.2.1-dev.b4cf519 → 0.2.1-dev.b884f1c
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/praxis.js +87 -17
- package/package.json +1 -1
package/dist/praxis.js
CHANGED
|
@@ -6100,7 +6100,7 @@ file at the root of that directory.`
|
|
|
6100
6100
|
"allow"
|
|
6101
6101
|
],
|
|
6102
6102
|
required: false,
|
|
6103
|
-
description: "skip
|
|
6103
|
+
description: "skip skips while a previous run is still active; allow permits overlapping runs. When omitted, schedule triggers use skip and webhook triggers use allow."
|
|
6104
6104
|
},
|
|
6105
6105
|
{
|
|
6106
6106
|
name: "catchup_window_seconds",
|
|
@@ -6274,7 +6274,7 @@ file at the root of that directory.`
|
|
|
6274
6274
|
"allow"
|
|
6275
6275
|
],
|
|
6276
6276
|
required: false,
|
|
6277
|
-
description: "skip
|
|
6277
|
+
description: "skip skips while a previous run is still active; allow permits overlapping runs. When omitted, schedule triggers use skip and webhook triggers use allow."
|
|
6278
6278
|
},
|
|
6279
6279
|
{
|
|
6280
6280
|
name: "catchup_window_seconds",
|
|
@@ -19868,7 +19868,7 @@ for more details.`
|
|
|
19868
19868
|
resource: "ticket.labels",
|
|
19869
19869
|
method: "create",
|
|
19870
19870
|
summary: "Create or add labels",
|
|
19871
|
-
description: "Create or add labels within the authenticated organization. Obtain resource identifiers from the corresponding list or create response. Writes complete synchronously; read the returned resource to observe the result.
|
|
19871
|
+
description: "Create or add labels within the authenticated organization. Obtain resource identifiers from the corresponding list or create response. Writes complete synchronously; read the returned resource to observe the result. Service authorization applies to the verified human subject.",
|
|
19872
19872
|
http: "POST",
|
|
19873
19873
|
path: "/ticket/v1/labels",
|
|
19874
19874
|
streaming: "no",
|
|
@@ -19910,7 +19910,7 @@ for more details.`
|
|
|
19910
19910
|
resource: "ticket.labels",
|
|
19911
19911
|
method: "delete",
|
|
19912
19912
|
summary: "Remove labels",
|
|
19913
|
-
description: "Remove labels within the authenticated organization. Obtain resource identifiers from the corresponding list or create response. Writes complete synchronously; read the returned resource to observe the result.
|
|
19913
|
+
description: "Remove labels within the authenticated organization. Obtain resource identifiers from the corresponding list or create response. Writes complete synchronously; read the returned resource to observe the result. Service authorization applies to the verified human subject.",
|
|
19914
19914
|
http: "DELETE",
|
|
19915
19915
|
path: "/ticket/v1/labels/{name}",
|
|
19916
19916
|
streaming: "no",
|
|
@@ -19935,7 +19935,7 @@ for more details.`
|
|
|
19935
19935
|
resource: "ticket.labels",
|
|
19936
19936
|
method: "update",
|
|
19937
19937
|
summary: "Update labels",
|
|
19938
|
-
description: "Update labels within the authenticated organization. Obtain resource identifiers from the corresponding list or create response. Writes complete synchronously; read the returned resource to observe the result.
|
|
19938
|
+
description: "Update labels within the authenticated organization. Obtain resource identifiers from the corresponding list or create response. Writes complete synchronously; read the returned resource to observe the result. Service authorization applies to the verified human subject.",
|
|
19939
19939
|
http: "PATCH",
|
|
19940
19940
|
path: "/ticket/v1/labels/{name}",
|
|
19941
19941
|
streaming: "no",
|
|
@@ -32721,6 +32721,26 @@ async function prepareMultipart(op, opts) {
|
|
|
32721
32721
|
opts.body = body;
|
|
32722
32722
|
}
|
|
32723
32723
|
|
|
32724
|
+
// src/core/pagination.ts
|
|
32725
|
+
var PAGE_TOKENS = /^(page_?token|next_?page_?token)$/i;
|
|
32726
|
+
function pageTokenField(op) {
|
|
32727
|
+
return op.query.find((field) => PAGE_TOKENS.test(field.name));
|
|
32728
|
+
}
|
|
32729
|
+
function nextPageToken(result) {
|
|
32730
|
+
const value = result;
|
|
32731
|
+
const token = value?.next_page_token ?? value?.nextPageToken ?? value?.next_cursor;
|
|
32732
|
+
return typeof token === "string" && token ? token : undefined;
|
|
32733
|
+
}
|
|
32734
|
+
function pageOf(result) {
|
|
32735
|
+
const value = result;
|
|
32736
|
+
const arrays = value && typeof value === "object" ? Object.values(value).filter(Array.isArray) : [];
|
|
32737
|
+
const data = Array.isArray(value?.data) ? value.data : Array.isArray(value?.items) ? value.items : arrays.length === 1 ? arrays[0] : undefined;
|
|
32738
|
+
if (!Array.isArray(data))
|
|
32739
|
+
return;
|
|
32740
|
+
const token = nextPageToken(result);
|
|
32741
|
+
return { items: data, ...token ? { token } : {} };
|
|
32742
|
+
}
|
|
32743
|
+
|
|
32724
32744
|
// src/core/bind-args.ts
|
|
32725
32745
|
var globalOptions = [
|
|
32726
32746
|
{ name: "org", type: "string" },
|
|
@@ -32936,7 +32956,7 @@ function bindArgs(parsed, op, data) {
|
|
|
32936
32956
|
(opts.query ??= {})[key] ??= convert(String(globals[name]), { name, type: field.type, enum: field.enum });
|
|
32937
32957
|
}
|
|
32938
32958
|
}
|
|
32939
|
-
if (globals.all && !op.pagination)
|
|
32959
|
+
if (globals.all && !op.pagination && !pageTokenField(op))
|
|
32940
32960
|
throw new UsageError("--all requires a paginated operation");
|
|
32941
32961
|
for (const p of op.pathParams)
|
|
32942
32962
|
if (p !== target && opts.path?.[p.sdkName] === undefined)
|
|
@@ -32962,8 +32982,8 @@ function bindArgs(parsed, op, data) {
|
|
|
32962
32982
|
}
|
|
32963
32983
|
|
|
32964
32984
|
// src/core/help.ts
|
|
32965
|
-
function describeOption(s) {
|
|
32966
|
-
return `--${s.name}${s.type === "boolean" ? " [true|false]" : ` <${s.type}>`}${s.repeated ? " (repeatable)" : ""}${
|
|
32985
|
+
function describeOption(s, required = s.required) {
|
|
32986
|
+
return `--${s.name}${s.type === "boolean" ? " [true|false]" : ` <${s.type}>`}${s.repeated ? " (repeatable)" : ""}${required ? " (required)" : ""}${s.enum ? ` [${s.enum.join(" | ")}]` : ""}${s.description ? ` — ${s.description.replace(/\s+/g, " ")}` : ""}`;
|
|
32967
32987
|
}
|
|
32968
32988
|
function example(command) {
|
|
32969
32989
|
const target = targetParam(command.op);
|
|
@@ -32979,18 +32999,22 @@ function example(command) {
|
|
|
32979
32999
|
args.push("--yes");
|
|
32980
33000
|
return args.join(" ");
|
|
32981
33001
|
}
|
|
33002
|
+
function fieldRequired(op, field, location) {
|
|
33003
|
+
return Boolean(field.required) && (location === "path" || location === "query" || Boolean(op.body?.required));
|
|
33004
|
+
}
|
|
32982
33005
|
function help(commands, prefix, command) {
|
|
32983
33006
|
if (command) {
|
|
32984
33007
|
const target = targetParam(command.op);
|
|
33008
|
+
const parents = operationOptions(command.op).filter((s) => s.location === "path" && s.required).map((s) => ` --${s.name} <${s.field?.name ?? s.sdkName}>`).join("");
|
|
32985
33009
|
return [
|
|
32986
|
-
`praxis ${command.words.join(" ")}${target ? ` <${target.sdkName}>` : ""} [options]`,
|
|
33010
|
+
`praxis ${command.words.join(" ")}${parents}${target ? ` <${target.sdkName}>` : ""} [options]`,
|
|
32987
33011
|
`SDK: ${command.op.resource}.${command.alias ?? command.op.method}`,
|
|
32988
33012
|
`${command.op.http} ${command.op.path}`,
|
|
32989
33013
|
...target ? [`Position: <${target.sdkName}>${target.type ? ` <${target.type}>` : ""} (required target ID)`] : [],
|
|
32990
33014
|
"",
|
|
32991
33015
|
"Options:",
|
|
32992
33016
|
...target?.description ? [` <${target.sdkName}> — ${target.description.replace(/\s+/g, " ")}`] : [],
|
|
32993
|
-
...[...operationOptions(command.op), ...bodyDataOption(command.op), ...globalOptions].map((s) => ` ${describeOption(s)}`),
|
|
33017
|
+
...[...operationOptions(command.op), ...bodyDataOption(command.op), ...globalOptions].map((s) => ` ${describeOption(s, s.required && fieldRequired(command.op, s, s.location ?? "query"))}`),
|
|
32994
33018
|
...command.op.body?.fields.filter((f) => !operationOptions(command.op).some((s) => s.location === "body" && s.field === f) && (f.type === "object" || f.type === "array" && !["string", "number", "integer", "boolean"].includes(f.itemType ?? ""))).map((f) => ` --data: ${f.name} (${f.type}${f.required ? ", required" : ""})`) ?? [],
|
|
32995
33019
|
" -h is an alias of --help",
|
|
32996
33020
|
"PRAXIS_ENV=develop|production (default: develop); no --env option.",
|
|
@@ -34358,9 +34382,11 @@ function renderHuman(result, ctx) {
|
|
|
34358
34382
|
const details = result.details !== undefined ? JSON.stringify(result.details) : undefined;
|
|
34359
34383
|
const detailsLine = details !== undefined ? ` details ${details.length > 2000 ? details.slice(0, 1999) + "…" : details}
|
|
34360
34384
|
` : "";
|
|
34385
|
+
const problemLine = problemLines(result.problem).map((line) => ` ${plain(line)}
|
|
34386
|
+
`).join("");
|
|
34361
34387
|
return { stderr: err.red(`✗ ${plain(result.message)}`) + `
|
|
34362
34388
|
` + err.dim(` code ${plain(result.code)}${result.status !== undefined ? ` · ${result.status}` : ""} · env ${plain(result.env)}${result.request_id ? ` · request ${plain(result.request_id)}` : ""}`) + `
|
|
34363
|
-
` + detailsLine + (result.hint ? ` → ${plain(result.hint)}
|
|
34389
|
+
` + detailsLine + problemLine + (result.hint ? ` → ${plain(result.hint)}
|
|
34364
34390
|
` : "") };
|
|
34365
34391
|
}
|
|
34366
34392
|
case "list":
|
|
@@ -34448,8 +34474,33 @@ ${usage ? `usage: ${JSON.stringify(usage)}
|
|
|
34448
34474
|
}
|
|
34449
34475
|
|
|
34450
34476
|
// src/output/render.ts
|
|
34477
|
+
var PROBLEM_HINTS = ["hint", "errors", "violations", "title", "type"];
|
|
34478
|
+
function serverProblem(raw) {
|
|
34479
|
+
const value = record(raw);
|
|
34480
|
+
const problem = {};
|
|
34481
|
+
for (const member of ["code", "detail", ...PROBLEM_HINTS, "status"]) {
|
|
34482
|
+
const entry = value[member];
|
|
34483
|
+
if (entry !== undefined && entry !== null)
|
|
34484
|
+
problem[member] = entry;
|
|
34485
|
+
}
|
|
34486
|
+
const adds = PROBLEM_HINTS.some((member) => Array.isArray(problem[member]) ? problem[member].length > 0 : problem[member] !== undefined);
|
|
34487
|
+
return adds ? problem : undefined;
|
|
34488
|
+
}
|
|
34489
|
+
function problemLines(problem) {
|
|
34490
|
+
const lines = [];
|
|
34491
|
+
for (const group of [problem?.errors, problem?.violations]) {
|
|
34492
|
+
for (const item of Array.isArray(group) ? group : []) {
|
|
34493
|
+
const entry = record(item);
|
|
34494
|
+
const where = scalar(entry.pointer ?? entry.field);
|
|
34495
|
+
const detail = scalar(entry.detail ?? entry.message ?? entry.reason);
|
|
34496
|
+
if (where || detail)
|
|
34497
|
+
lines.push(`${where ? `${where}: ` : ""}${detail}`);
|
|
34498
|
+
}
|
|
34499
|
+
}
|
|
34500
|
+
return lines;
|
|
34501
|
+
}
|
|
34451
34502
|
function errorJSON(result, ctx) {
|
|
34452
|
-
return JSON.stringify({ error: { code: result.code, ...result.details !== undefined ? { details: result.details } : {}, message: result.message, hint: result.hint ?? null, env: result.env, command: ctx.command ?? null, status: result.status ?? null, request_id: result.request_id ?? null, ...result.credential_source ? { credential_source: result.credential_source } : {} } }) + `
|
|
34503
|
+
return JSON.stringify({ error: { code: result.code, ...result.details !== undefined ? { details: result.details } : {}, message: result.message, hint: result.hint ?? null, env: result.env, command: ctx.command ?? null, status: result.status ?? null, request_id: result.request_id ?? null, ...result.problem !== undefined ? { problem: result.problem } : {}, ...result.credential_source ? { credential_source: result.credential_source } : {} } }) + `
|
|
34453
34504
|
`;
|
|
34454
34505
|
}
|
|
34455
34506
|
function render(result, ctx) {
|
|
@@ -34605,6 +34656,8 @@ function errorInput(error, ctx) {
|
|
|
34605
34656
|
const raw = record(sdk?.raw), nested = record(raw.error);
|
|
34606
34657
|
const candidate = nested.details ?? raw.details;
|
|
34607
34658
|
const details = candidate !== null && typeof candidate === "object" && !Array.isArray(candidate) ? candidate : undefined;
|
|
34659
|
+
const problem = serverProblem(Object.keys(nested).length ? nested : raw);
|
|
34660
|
+
const serverText = (value) => typeof value === "string" && value.trim() ? value : undefined;
|
|
34608
34661
|
let message = error instanceof Error ? error.message : "Unexpected error";
|
|
34609
34662
|
const prefix = message.match(/^([A-Z][A-Z0-9_]+):\s*/)?.[1];
|
|
34610
34663
|
const code = error instanceof UsageError ? error.code : businessCode(raw.code) ?? businessCode(nested.code) ?? businessCode(raw.error_code) ?? prefix ?? businessCode(sdk?.code) ?? (sdk?.status ? `HTTP_${sdk.status}` : sdk ? "API_ERROR" : "RUNTIME_ERROR");
|
|
@@ -34616,11 +34669,14 @@ function errorInput(error, ctx) {
|
|
|
34616
34669
|
if (stripped)
|
|
34617
34670
|
message = `${humanize(code)}${message ? `: ${message}` : ""}`;
|
|
34618
34671
|
const status = sdk?.status, request_id = sdk?.requestId;
|
|
34672
|
+
message = serverText(problem?.detail) ?? serverText(problem?.title) ?? message;
|
|
34619
34673
|
const authFailure = status === 401 || ["NOT_LOGGED_IN", "UNAUTHENTICATED", "TOKEN_REVOKED", "LOGIN_FAILED"].includes(code);
|
|
34620
34674
|
const source = ctx.credentialSource ?? "login";
|
|
34621
34675
|
let hint = genericHint;
|
|
34622
34676
|
if (error instanceof UsageError)
|
|
34623
34677
|
hint = error.hint;
|
|
34678
|
+
else if (serverText(problem?.hint))
|
|
34679
|
+
hint = serverText(problem?.hint);
|
|
34624
34680
|
else if (authFailure)
|
|
34625
34681
|
hint = authHint(source);
|
|
34626
34682
|
else if (status === 404)
|
|
@@ -34631,7 +34687,7 @@ function errorInput(error, ctx) {
|
|
|
34631
34687
|
hint = "Rate limited; retry later.";
|
|
34632
34688
|
else if (status !== undefined && status >= 500)
|
|
34633
34689
|
hint = `Server error; retry later.${request_id ? ` Request id: ${request_id}.` : ""}`;
|
|
34634
|
-
return { kind: "error", code, message, hint, ...details !== undefined ? { details } : {}, env: ctx.env, ...authFailure ? { credential_source: source } : {}, ...status !== undefined ? { status } : {}, ...request_id ? { request_id } : {} };
|
|
34690
|
+
return { kind: "error", code, message, hint, ...details !== undefined ? { details } : {}, ...problem !== undefined ? { problem } : {}, env: ctx.env, ...authFailure ? { credential_source: source } : {}, ...status !== undefined ? { status } : {}, ...request_id ? { request_id } : {} };
|
|
34635
34691
|
}
|
|
34636
34692
|
|
|
34637
34693
|
// src/output/progress.ts
|
|
@@ -34661,7 +34717,7 @@ function startProgress(ctx, write = (text) => writeOutput({ stderr: text })) {
|
|
|
34661
34717
|
}
|
|
34662
34718
|
|
|
34663
34719
|
// src/main.ts
|
|
34664
|
-
var version = "0.2.1-dev.
|
|
34720
|
+
var version = "0.2.1-dev.b884f1c";
|
|
34665
34721
|
var commands = commandTree(operations);
|
|
34666
34722
|
var manual = [...workflows.map((w) => w.words), [API_WORD]];
|
|
34667
34723
|
function route(argv) {
|
|
@@ -34879,7 +34935,7 @@ Examples:
|
|
|
34879
34935
|
let owner = client2;
|
|
34880
34936
|
for (const part of op.resource.split("."))
|
|
34881
34937
|
owner = owner[part];
|
|
34882
|
-
|
|
34938
|
+
let result = await owner[op.method](opts);
|
|
34883
34939
|
const name2 = `${op.resource}.${op.method}`;
|
|
34884
34940
|
const list = (items) => {
|
|
34885
34941
|
const view = clientList(items, op, flags.limit, ctx.mode);
|
|
@@ -34893,7 +34949,21 @@ Examples:
|
|
|
34893
34949
|
const cursor = result instanceof Page ? result.next_cursor : record(result).next_cursor ?? record(result).nextToken;
|
|
34894
34950
|
if (typeof cursor === "string" && cursor)
|
|
34895
34951
|
ctx.nextCommand = nextPageCommand(selected.command, parsed, cursor);
|
|
34896
|
-
|
|
34952
|
+
const pageToken = pageTokenField(op), token = pageToken?.sdkName ?? pageToken?.name;
|
|
34953
|
+
const firstPage = flags.all && !(result instanceof Page) && token ? pageOf(result) : undefined;
|
|
34954
|
+
if (flags.all && !(result instanceof Page) && token && !firstPage)
|
|
34955
|
+
throw new UsageError(`--all cannot find the list in ${op.resource}.${op.method}'s response; page with --${token.replace(/_/g, "-")} instead`);
|
|
34956
|
+
if (firstPage) {
|
|
34957
|
+
const items = [...firstPage.items];
|
|
34958
|
+
const seen = new Set;
|
|
34959
|
+
for (let next = firstPage.token;next && !seen.has(next); next = pageOf(result)?.token) {
|
|
34960
|
+
seen.add(next);
|
|
34961
|
+
result = await owner[op.method]({ ...opts, query: { ...opts.query, [token]: next } });
|
|
34962
|
+
items.push(...pageOf(result)?.items ?? []);
|
|
34963
|
+
}
|
|
34964
|
+
ctx.nextCommand = undefined;
|
|
34965
|
+
emit({ kind: "list", ...list(items), ...ctx.mode === "json" ? { raw: { data: items, next_page_token: null } } : {}, nextCursor: null, op: name2 });
|
|
34966
|
+
} else if (result instanceof Page) {
|
|
34897
34967
|
if (flags.all) {
|
|
34898
34968
|
const items = [];
|
|
34899
34969
|
for await (const item of result)
|
|
@@ -34989,7 +35059,7 @@ Examples:
|
|
|
34989
35059
|
}
|
|
34990
35060
|
}
|
|
34991
35061
|
if (true)
|
|
34992
|
-
process.
|
|
35062
|
+
process.exitCode = await main(process.argv.slice(2));
|
|
34993
35063
|
export {
|
|
34994
35064
|
main
|
|
34995
35065
|
};
|