zinkee 0.1.40 → 0.1.42
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/.github/workflows/npm-publish.yml +77 -0
- package/.github/workflows/pr-checks.yml +36 -0
- package/AGENTS.md +5 -3
- package/README.md +23 -0
- package/dist/index.js +476 -194
- package/dist/index.js.map +1 -1
- package/docs/npm-release.md +34 -65
- package/docs/superpowers/specs/2026-07-30-cli-pr-checks-design.md +37 -0
- package/package.json +5 -1
- package/src/api/formulas.test.ts +65 -0
- package/src/api/formulas.ts +67 -0
- package/src/command-registry.ts +21 -0
- package/src/commands/automations.test.ts +140 -0
- package/src/commands/automations.ts +48 -13
- package/src/commands/formulas.test.ts +194 -0
- package/src/commands/formulas.ts +243 -0
- package/src/program.ts +2 -0
- package/src/utils/examples.ts +54 -0
- package/.claude/settings.local.json +0 -70
package/dist/index.js
CHANGED
|
@@ -9,6 +9,27 @@ import chalk from "chalk";
|
|
|
9
9
|
var readOutput = "table-json";
|
|
10
10
|
var writeOutput = "json-only";
|
|
11
11
|
var commandRegistry = {
|
|
12
|
+
"formulas recompute field": {
|
|
13
|
+
command: "formulas recompute field",
|
|
14
|
+
accessLevel: "write",
|
|
15
|
+
supportsExample: true,
|
|
16
|
+
supportsRaw: false,
|
|
17
|
+
output: writeOutput
|
|
18
|
+
},
|
|
19
|
+
"formulas recompute schema": {
|
|
20
|
+
command: "formulas recompute schema",
|
|
21
|
+
accessLevel: "write",
|
|
22
|
+
supportsExample: true,
|
|
23
|
+
supportsRaw: false,
|
|
24
|
+
output: writeOutput
|
|
25
|
+
},
|
|
26
|
+
"formulas recompute workspace": {
|
|
27
|
+
command: "formulas recompute workspace",
|
|
28
|
+
accessLevel: "write",
|
|
29
|
+
supportsExample: true,
|
|
30
|
+
supportsRaw: false,
|
|
31
|
+
output: writeOutput
|
|
32
|
+
},
|
|
12
33
|
"config path": {
|
|
13
34
|
command: "config path",
|
|
14
35
|
accessLevel: "read",
|
|
@@ -2229,6 +2250,60 @@ function buildCommandExamples(examples) {
|
|
|
2229
2250
|
}
|
|
2230
2251
|
var SAMPLE_UUID = "550e8400-e29b-41d4-a716-446655440001";
|
|
2231
2252
|
var specificExamples = {
|
|
2253
|
+
"formulas recompute field": buildCommandExamples([
|
|
2254
|
+
{
|
|
2255
|
+
description: "Queue a full recalculation of one formula column.",
|
|
2256
|
+
command: "zinkee --json formulas recompute field invoices total",
|
|
2257
|
+
raw: `{
|
|
2258
|
+
"scope": "FIELD",
|
|
2259
|
+
"schema": "invoices",
|
|
2260
|
+
"field": "total"
|
|
2261
|
+
}`,
|
|
2262
|
+
response: `{
|
|
2263
|
+
"requestId": "02ab5d47-cb5f-4eb2-afb8-e9a3a9eb34d4",
|
|
2264
|
+
"scope": "FIELD",
|
|
2265
|
+
"formulaCount": 1,
|
|
2266
|
+
"skippedFormulaCount": 0,
|
|
2267
|
+
"eventsQueued": 1,
|
|
2268
|
+
"status": "QUEUED"
|
|
2269
|
+
}`
|
|
2270
|
+
}
|
|
2271
|
+
]),
|
|
2272
|
+
"formulas recompute schema": buildCommandExamples([
|
|
2273
|
+
{
|
|
2274
|
+
description: "Queue recalculation of every active formula in one schema.",
|
|
2275
|
+
command: "zinkee --json formulas recompute schema invoices --yes",
|
|
2276
|
+
raw: `{
|
|
2277
|
+
"scope": "SCHEMA",
|
|
2278
|
+
"schema": "invoices"
|
|
2279
|
+
}`,
|
|
2280
|
+
response: `{
|
|
2281
|
+
"requestId": "02ab5d47-cb5f-4eb2-afb8-e9a3a9eb34d4",
|
|
2282
|
+
"scope": "SCHEMA",
|
|
2283
|
+
"formulaCount": 8,
|
|
2284
|
+
"skippedFormulaCount": 1,
|
|
2285
|
+
"eventsQueued": 8,
|
|
2286
|
+
"status": "QUEUED"
|
|
2287
|
+
}`
|
|
2288
|
+
}
|
|
2289
|
+
]),
|
|
2290
|
+
"formulas recompute workspace": buildCommandExamples([
|
|
2291
|
+
{
|
|
2292
|
+
description: "Queue recalculation of every active formula in the workspace.",
|
|
2293
|
+
command: "zinkee --json formulas recompute workspace --yes",
|
|
2294
|
+
raw: `{
|
|
2295
|
+
"scope": "WORKSPACE"
|
|
2296
|
+
}`,
|
|
2297
|
+
response: `{
|
|
2298
|
+
"requestId": "02ab5d47-cb5f-4eb2-afb8-e9a3a9eb34d4",
|
|
2299
|
+
"scope": "WORKSPACE",
|
|
2300
|
+
"formulaCount": 24,
|
|
2301
|
+
"skippedFormulaCount": 2,
|
|
2302
|
+
"eventsQueued": 24,
|
|
2303
|
+
"status": "QUEUED"
|
|
2304
|
+
}`
|
|
2305
|
+
}
|
|
2306
|
+
]),
|
|
2232
2307
|
"profiles list": buildCommandExamples([
|
|
2233
2308
|
{
|
|
2234
2309
|
description: "List all local profiles. The CLI always redacts the apiKey to ******** plus the last 4 chars.",
|
|
@@ -6573,7 +6648,7 @@ ${index + 1}. ${example.description}
|
|
|
6573
6648
|
|
|
6574
6649
|
// src/program.ts
|
|
6575
6650
|
import { createRequire } from "module";
|
|
6576
|
-
import { Command as
|
|
6651
|
+
import { Command as Command12 } from "commander";
|
|
6577
6652
|
|
|
6578
6653
|
// src/config.ts
|
|
6579
6654
|
import { mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
@@ -7392,23 +7467,45 @@ function readJsonValueOption(raw, rawFile, rawLabel, rawFileLabel) {
|
|
|
7392
7467
|
function readJsonObjectOption(raw, rawFile, rawLabel, rawFileLabel) {
|
|
7393
7468
|
return readJsonValueOption(raw, rawFile, rawLabel, rawFileLabel) ?? {};
|
|
7394
7469
|
}
|
|
7470
|
+
var NO_VALUE_COMPARATORS = /* @__PURE__ */ new Set([
|
|
7471
|
+
"chg",
|
|
7472
|
+
"changes",
|
|
7473
|
+
"ie",
|
|
7474
|
+
"is_empty",
|
|
7475
|
+
"ine",
|
|
7476
|
+
"is_not_empty"
|
|
7477
|
+
]);
|
|
7478
|
+
function isNoValueComparator(comparator) {
|
|
7479
|
+
return NO_VALUE_COMPARATORS.has(comparator.toLowerCase());
|
|
7480
|
+
}
|
|
7481
|
+
function conditionFormatError(input) {
|
|
7482
|
+
return new CliError(
|
|
7483
|
+
"invalid_cli_usage",
|
|
7484
|
+
`Expected condition in the form field:comparator:value, or field:comparator for comparators without value (chg, ie, ine), received "${input}".`
|
|
7485
|
+
);
|
|
7486
|
+
}
|
|
7395
7487
|
function parseCondition(input) {
|
|
7396
7488
|
const firstSeparator = input.indexOf(":");
|
|
7397
7489
|
const secondSeparator = input.indexOf(":", firstSeparator + 1);
|
|
7398
|
-
if (firstSeparator <= 0
|
|
7399
|
-
throw
|
|
7400
|
-
|
|
7401
|
-
|
|
7402
|
-
);
|
|
7490
|
+
if (firstSeparator <= 0) {
|
|
7491
|
+
throw conditionFormatError(input);
|
|
7492
|
+
}
|
|
7493
|
+
if (secondSeparator === -1) {
|
|
7494
|
+
const field2 = input.slice(0, firstSeparator).trim();
|
|
7495
|
+
const comparator2 = input.slice(firstSeparator + 1).trim();
|
|
7496
|
+
if (!field2 || !comparator2 || !isNoValueComparator(comparator2)) {
|
|
7497
|
+
throw conditionFormatError(input);
|
|
7498
|
+
}
|
|
7499
|
+
return { field: field2, comparator: comparator2, values: [] };
|
|
7500
|
+
}
|
|
7501
|
+
if (secondSeparator <= firstSeparator + 1) {
|
|
7502
|
+
throw conditionFormatError(input);
|
|
7403
7503
|
}
|
|
7404
7504
|
const field = input.slice(0, firstSeparator).trim();
|
|
7405
7505
|
const comparator = input.slice(firstSeparator + 1, secondSeparator).trim();
|
|
7406
7506
|
const value = input.slice(secondSeparator + 1).trim();
|
|
7407
7507
|
if (!field || !comparator || !value) {
|
|
7408
|
-
throw
|
|
7409
|
-
"invalid_cli_usage",
|
|
7410
|
-
`Expected condition in the form field:comparator:value, received "${input}".`
|
|
7411
|
-
);
|
|
7508
|
+
throw conditionFormatError(input);
|
|
7412
7509
|
}
|
|
7413
7510
|
return {
|
|
7414
7511
|
field,
|
|
@@ -7555,10 +7652,11 @@ function normalizeAutomationConditions(conditions, label, options) {
|
|
|
7555
7652
|
const field = typeof condition.field === "string" ? condition.field.trim() : "";
|
|
7556
7653
|
const comparator = typeof condition.comparator === "string" ? condition.comparator.trim() : "";
|
|
7557
7654
|
const values = condition.values;
|
|
7558
|
-
|
|
7655
|
+
const allowsEmptyValues = isNoValueComparator(comparator);
|
|
7656
|
+
if (!field || !comparator || !Array.isArray(values) || values.length === 0 && !allowsEmptyValues) {
|
|
7559
7657
|
throw new CliError(
|
|
7560
7658
|
"invalid_cli_usage",
|
|
7561
|
-
`Expected ${label} ${index + 1} to contain "field", "comparator", and a non-empty "values" array.`
|
|
7659
|
+
`Expected ${label} ${index + 1} to contain "field", "comparator", and a non-empty "values" array (comparators without value, e.g. chg/ie/ine, accept an empty array).`
|
|
7562
7660
|
);
|
|
7563
7661
|
}
|
|
7564
7662
|
return {
|
|
@@ -8035,7 +8133,7 @@ function addTriggerPayloadOptions(command) {
|
|
|
8035
8133
|
[]
|
|
8036
8134
|
).option(
|
|
8037
8135
|
"--condition <field:comparator:value>",
|
|
8038
|
-
"trigger condition",
|
|
8136
|
+
"trigger condition (use field:comparator for comparators without value: chg, ie, ine)",
|
|
8039
8137
|
collectValues,
|
|
8040
8138
|
[]
|
|
8041
8139
|
).option(
|
|
@@ -8062,7 +8160,12 @@ function addActionPayloadOptions(command) {
|
|
|
8062
8160
|
return command.option(
|
|
8063
8161
|
"--type <type>",
|
|
8064
8162
|
"action type (create_record|update_record|search_records|send_message|http_request|execute_plugin|generate_document)"
|
|
8065
|
-
).option("--name <name>", "action name").option("--target-schema <uuid>", "target schema id").option("--map <field=value>", "field mapping", collectValues, []).option("--map-json <field=json>", "JSON field mapping", collectValues, []).option(
|
|
8163
|
+
).option("--name <name>", "action name").option("--target-schema <uuid>", "target schema id").option("--map <field=value>", "field mapping", collectValues, []).option("--map-json <field=json>", "JSON field mapping", collectValues, []).option(
|
|
8164
|
+
"--condition <field:comparator:value>",
|
|
8165
|
+
"action condition (use field:comparator for comparators without value: ie, ine)",
|
|
8166
|
+
collectValues,
|
|
8167
|
+
[]
|
|
8168
|
+
).option("--condition-json <json>", "action condition as JSON", collectValues, []).option("--use-trigger-record", "use the triggering record").option("--method <method>", "HTTP method").option("--url <url>", "HTTP target URL").option("--header <key=value>", "HTTP header", collectValues, []).option("--body <json>", "HTTP request body as JSON").option("--body-file <path>", "path to HTTP request body JSON").option("--content-type <type>", "HTTP content type").option(
|
|
8066
8169
|
"--timeout-ms <n>",
|
|
8067
8170
|
"HTTP timeout in milliseconds",
|
|
8068
8171
|
parseNonNegativeInteger
|
|
@@ -10502,42 +10605,220 @@ function registerFilesCommands(program, options = {}) {
|
|
|
10502
10605
|
});
|
|
10503
10606
|
}
|
|
10504
10607
|
|
|
10505
|
-
// src/commands/
|
|
10608
|
+
// src/commands/formulas.ts
|
|
10506
10609
|
import { InvalidArgumentError as InvalidArgumentError6 } from "commander";
|
|
10507
10610
|
|
|
10508
|
-
// src/api/
|
|
10611
|
+
// src/api/formulas.ts
|
|
10509
10612
|
function selectorValue6(selector) {
|
|
10510
10613
|
return selector.value;
|
|
10511
10614
|
}
|
|
10615
|
+
function toRequestBody(input) {
|
|
10616
|
+
if (input.scope === "FIELD") {
|
|
10617
|
+
return {
|
|
10618
|
+
scope: input.scope,
|
|
10619
|
+
schema: selectorValue6(input.schema),
|
|
10620
|
+
field: selectorValue6(input.field)
|
|
10621
|
+
};
|
|
10622
|
+
}
|
|
10623
|
+
if (input.scope === "SCHEMA") {
|
|
10624
|
+
return {
|
|
10625
|
+
scope: input.scope,
|
|
10626
|
+
schema: selectorValue6(input.schema)
|
|
10627
|
+
};
|
|
10628
|
+
}
|
|
10629
|
+
return { scope: input.scope };
|
|
10630
|
+
}
|
|
10631
|
+
var FormulasApi = class {
|
|
10632
|
+
constructor(client) {
|
|
10633
|
+
this.client = client;
|
|
10634
|
+
}
|
|
10635
|
+
recompute(input) {
|
|
10636
|
+
return this.client.requestJson(
|
|
10637
|
+
"/api/v2/formulas:recompute",
|
|
10638
|
+
{
|
|
10639
|
+
method: "POST",
|
|
10640
|
+
headers: {
|
|
10641
|
+
"content-type": "application/json"
|
|
10642
|
+
},
|
|
10643
|
+
body: JSON.stringify(toRequestBody(input))
|
|
10644
|
+
}
|
|
10645
|
+
);
|
|
10646
|
+
}
|
|
10647
|
+
};
|
|
10648
|
+
|
|
10649
|
+
// src/commands/formulas.ts
|
|
10650
|
+
function getCommandIo7(stdout) {
|
|
10651
|
+
return stdout ?? process.stdout;
|
|
10652
|
+
}
|
|
10653
|
+
function writeLine7(stdout, value) {
|
|
10654
|
+
stdout.write(`${value}
|
|
10655
|
+
`);
|
|
10656
|
+
}
|
|
10657
|
+
function getGlobalOptions7(command) {
|
|
10658
|
+
return command.optsWithGlobals();
|
|
10659
|
+
}
|
|
10660
|
+
function toConfigurationError7(filePath, error) {
|
|
10661
|
+
if (error instanceof CliError) {
|
|
10662
|
+
throw error;
|
|
10663
|
+
}
|
|
10664
|
+
if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
|
|
10665
|
+
throw new CliError("configuration_error", `Config file not found at ${filePath}.`);
|
|
10666
|
+
}
|
|
10667
|
+
if (error instanceof Error) {
|
|
10668
|
+
throw new CliError("configuration_error", error.message);
|
|
10669
|
+
}
|
|
10670
|
+
throw error;
|
|
10671
|
+
}
|
|
10672
|
+
function createFormulasApi(command, filePath) {
|
|
10673
|
+
try {
|
|
10674
|
+
const config = readRuntimeConfig(filePath);
|
|
10675
|
+
const runtime = resolveRuntimeContext(config, getGlobalOptions7(command));
|
|
10676
|
+
if (!runtime.baseUrl) {
|
|
10677
|
+
throw new CliError(
|
|
10678
|
+
"configuration_error",
|
|
10679
|
+
`Resolved profile "${runtime.profile}" is missing a base URL.`
|
|
10680
|
+
);
|
|
10681
|
+
}
|
|
10682
|
+
return {
|
|
10683
|
+
api: new FormulasApi(
|
|
10684
|
+
new ApiClient({
|
|
10685
|
+
baseUrl: runtime.baseUrl,
|
|
10686
|
+
apiKey: runtime.apiKey
|
|
10687
|
+
})
|
|
10688
|
+
),
|
|
10689
|
+
json: runtime.json,
|
|
10690
|
+
readOnly: runtime.readOnly
|
|
10691
|
+
};
|
|
10692
|
+
} catch (error) {
|
|
10693
|
+
toConfigurationError7(filePath, error);
|
|
10694
|
+
}
|
|
10695
|
+
}
|
|
10696
|
+
function ensureWritable6(commandName, readOnly) {
|
|
10697
|
+
if (readOnly) {
|
|
10698
|
+
throw new CliError(
|
|
10699
|
+
"command_not_allowed_in_read_only_mode",
|
|
10700
|
+
`Command "${commandName}" is not allowed in read-only mode.`,
|
|
10701
|
+
{
|
|
10702
|
+
commandMode: "write",
|
|
10703
|
+
executionMode: "read-only"
|
|
10704
|
+
}
|
|
10705
|
+
);
|
|
10706
|
+
}
|
|
10707
|
+
}
|
|
10708
|
+
function ensureConfirmed(commandName, confirmed) {
|
|
10709
|
+
if (!confirmed) {
|
|
10710
|
+
throw new CliError(
|
|
10711
|
+
"invalid_cli_usage",
|
|
10712
|
+
`Command "${commandName}" requires --yes because it may enqueue a large recalculation.`
|
|
10713
|
+
);
|
|
10714
|
+
}
|
|
10715
|
+
}
|
|
10716
|
+
function parseUuidOrSlugSelector6(input) {
|
|
10717
|
+
try {
|
|
10718
|
+
return normalizeUuidOrSlug(input);
|
|
10719
|
+
} catch (error) {
|
|
10720
|
+
const message = error instanceof Error ? error.message : "Invalid selector.";
|
|
10721
|
+
throw new InvalidArgumentError6(message);
|
|
10722
|
+
}
|
|
10723
|
+
}
|
|
10724
|
+
function emitResult(stdout, commandName, result, configPath, json) {
|
|
10725
|
+
if (json) {
|
|
10726
|
+
writeLine7(
|
|
10727
|
+
stdout,
|
|
10728
|
+
JSON.stringify(buildJsonSuccess(result, { command: commandName, configPath }))
|
|
10729
|
+
);
|
|
10730
|
+
return;
|
|
10731
|
+
}
|
|
10732
|
+
writeLine7(
|
|
10733
|
+
stdout,
|
|
10734
|
+
`Queued ${result.eventsQueued} formula recalculation event(s) for ${result.scope.toLowerCase()} scope (request ${result.requestId}).`
|
|
10735
|
+
);
|
|
10736
|
+
}
|
|
10737
|
+
async function recompute(command, commandName, input, options, requireConfirmation, confirmed) {
|
|
10738
|
+
const configPath = options.configPath ?? defaultConfigPath;
|
|
10739
|
+
const stdout = getCommandIo7(options.stdout);
|
|
10740
|
+
const { api, json, readOnly } = createFormulasApi(command, configPath);
|
|
10741
|
+
ensureWritable6(commandName, readOnly);
|
|
10742
|
+
if (requireConfirmation) {
|
|
10743
|
+
ensureConfirmed(commandName, confirmed);
|
|
10744
|
+
}
|
|
10745
|
+
const result = await api.recompute(input);
|
|
10746
|
+
emitResult(stdout, commandName, result, configPath, json);
|
|
10747
|
+
}
|
|
10748
|
+
function registerFormulasCommands(program, options = {}) {
|
|
10749
|
+
const formulas = program.command("formulas").description("Recalculate formula values");
|
|
10750
|
+
const recomputeCommand = formulas.command("recompute").description("Queue a full formula recalculation");
|
|
10751
|
+
recomputeCommand.command("field").description("Queue recalculation of one formula column").argument("<schema>", "schema UUID or slug", parseUuidOrSlugSelector6).argument("<field>", "formula field UUID or slug", parseUuidOrSlugSelector6).action(
|
|
10752
|
+
async function action(schema, field) {
|
|
10753
|
+
await recompute(
|
|
10754
|
+
this,
|
|
10755
|
+
"formulas recompute field",
|
|
10756
|
+
{ scope: "FIELD", schema, field },
|
|
10757
|
+
options,
|
|
10758
|
+
false
|
|
10759
|
+
);
|
|
10760
|
+
}
|
|
10761
|
+
);
|
|
10762
|
+
recomputeCommand.command("schema").description("Queue recalculation of all active formulas in one schema").argument("<schema>", "schema UUID or slug", parseUuidOrSlugSelector6).option("--yes", "confirm the potentially expensive recalculation").action(
|
|
10763
|
+
async function action(schema, commandOptions) {
|
|
10764
|
+
await recompute(
|
|
10765
|
+
this,
|
|
10766
|
+
"formulas recompute schema",
|
|
10767
|
+
{ scope: "SCHEMA", schema },
|
|
10768
|
+
options,
|
|
10769
|
+
true,
|
|
10770
|
+
commandOptions.yes
|
|
10771
|
+
);
|
|
10772
|
+
}
|
|
10773
|
+
);
|
|
10774
|
+
recomputeCommand.command("workspace").description("Queue recalculation of all active formulas in the workspace").option("--yes", "confirm the potentially expensive recalculation").action(async function action(commandOptions) {
|
|
10775
|
+
await recompute(
|
|
10776
|
+
this,
|
|
10777
|
+
"formulas recompute workspace",
|
|
10778
|
+
{ scope: "WORKSPACE" },
|
|
10779
|
+
options,
|
|
10780
|
+
true,
|
|
10781
|
+
commandOptions.yes
|
|
10782
|
+
);
|
|
10783
|
+
});
|
|
10784
|
+
}
|
|
10785
|
+
|
|
10786
|
+
// src/commands/logs.ts
|
|
10787
|
+
import { InvalidArgumentError as InvalidArgumentError7 } from "commander";
|
|
10788
|
+
|
|
10789
|
+
// src/api/logs.ts
|
|
10790
|
+
function selectorValue7(selector) {
|
|
10791
|
+
return selector.value;
|
|
10792
|
+
}
|
|
10512
10793
|
var LogsApi = class {
|
|
10513
10794
|
constructor(client) {
|
|
10514
10795
|
this.client = client;
|
|
10515
10796
|
}
|
|
10516
10797
|
listLogs(schema, recordId) {
|
|
10517
10798
|
return this.client.getJson(
|
|
10518
|
-
`/api/v2/schemas/${
|
|
10799
|
+
`/api/v2/schemas/${selectorValue7(schema)}/records/${recordId}/logs`
|
|
10519
10800
|
);
|
|
10520
10801
|
}
|
|
10521
10802
|
};
|
|
10522
10803
|
|
|
10523
10804
|
// src/commands/logs.ts
|
|
10524
|
-
function
|
|
10805
|
+
function getCommandIo8(stdout) {
|
|
10525
10806
|
return stdout ?? process.stdout;
|
|
10526
10807
|
}
|
|
10527
|
-
function
|
|
10808
|
+
function writeLine8(stdout, value) {
|
|
10528
10809
|
stdout.write(`${value}
|
|
10529
10810
|
`);
|
|
10530
10811
|
}
|
|
10531
|
-
function
|
|
10812
|
+
function getGlobalOptions8(command) {
|
|
10532
10813
|
return command.optsWithGlobals();
|
|
10533
10814
|
}
|
|
10534
10815
|
function emitJson7(stdout, commandName, data, ..._extra) {
|
|
10535
|
-
|
|
10816
|
+
writeLine8(
|
|
10536
10817
|
stdout,
|
|
10537
10818
|
JSON.stringify(buildJsonSuccess(data, { command: commandName }))
|
|
10538
10819
|
);
|
|
10539
10820
|
}
|
|
10540
|
-
function
|
|
10821
|
+
function toConfigurationError8(filePath, error) {
|
|
10541
10822
|
if (error instanceof CliError) {
|
|
10542
10823
|
throw error;
|
|
10543
10824
|
}
|
|
@@ -10552,7 +10833,7 @@ function toConfigurationError7(filePath, error) {
|
|
|
10552
10833
|
function createLogsApi(command, filePath) {
|
|
10553
10834
|
try {
|
|
10554
10835
|
const config = readRuntimeConfig(filePath);
|
|
10555
|
-
const runtime = resolveRuntimeContext(config,
|
|
10836
|
+
const runtime = resolveRuntimeContext(config, getGlobalOptions8(command));
|
|
10556
10837
|
if (!runtime.baseUrl) {
|
|
10557
10838
|
throw new CliError(
|
|
10558
10839
|
"configuration_error",
|
|
@@ -10569,15 +10850,15 @@ function createLogsApi(command, filePath) {
|
|
|
10569
10850
|
json: runtime.json
|
|
10570
10851
|
};
|
|
10571
10852
|
} catch (error) {
|
|
10572
|
-
|
|
10853
|
+
toConfigurationError8(filePath, error);
|
|
10573
10854
|
}
|
|
10574
10855
|
}
|
|
10575
|
-
function
|
|
10856
|
+
function parseUuidOrSlugSelector7(input) {
|
|
10576
10857
|
try {
|
|
10577
10858
|
return normalizeUuidOrSlug(input);
|
|
10578
10859
|
} catch (error) {
|
|
10579
10860
|
const message = error instanceof Error ? error.message : "Invalid selector.";
|
|
10580
|
-
throw new
|
|
10861
|
+
throw new InvalidArgumentError7(message);
|
|
10581
10862
|
}
|
|
10582
10863
|
}
|
|
10583
10864
|
function isJsonObject5(value) {
|
|
@@ -10597,9 +10878,9 @@ function emitTable3(stdout, data) {
|
|
|
10597
10878
|
}
|
|
10598
10879
|
function registerLogsCommands(program, options = {}) {
|
|
10599
10880
|
const filePath = options.configPath ?? defaultConfigPath;
|
|
10600
|
-
const stdout =
|
|
10881
|
+
const stdout = getCommandIo8(options.stdout);
|
|
10601
10882
|
const logs = program.command("logs").description("Inspect record change logs");
|
|
10602
|
-
logs.command("list").description("List change logs for a record").argument("<schema>", "schema uuid or slug",
|
|
10883
|
+
logs.command("list").description("List change logs for a record").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector7).argument("<record>", "record uuid or slug", parseUuidOrSlugSelector7).action(async function action(schema, record) {
|
|
10603
10884
|
const { api, json } = createLogsApi(this, filePath);
|
|
10604
10885
|
const data = await api.listLogs(schema, record.value);
|
|
10605
10886
|
if (json) {
|
|
@@ -10612,7 +10893,7 @@ function registerLogsCommands(program, options = {}) {
|
|
|
10612
10893
|
|
|
10613
10894
|
// src/commands/navigation.ts
|
|
10614
10895
|
import { readFileSync as readFileSync7 } from "fs";
|
|
10615
|
-
import { InvalidArgumentError as
|
|
10896
|
+
import { InvalidArgumentError as InvalidArgumentError8 } from "commander";
|
|
10616
10897
|
|
|
10617
10898
|
// src/api/navigation.ts
|
|
10618
10899
|
function jsonOptions5(body, method) {
|
|
@@ -10624,7 +10905,7 @@ function jsonOptions5(body, method) {
|
|
|
10624
10905
|
body: JSON.stringify(body)
|
|
10625
10906
|
};
|
|
10626
10907
|
}
|
|
10627
|
-
function
|
|
10908
|
+
function selectorValue8(selector) {
|
|
10628
10909
|
return selector.value;
|
|
10629
10910
|
}
|
|
10630
10911
|
var NavigationApi = class {
|
|
@@ -10642,13 +10923,13 @@ var NavigationApi = class {
|
|
|
10642
10923
|
}
|
|
10643
10924
|
updateFolder(folder, body) {
|
|
10644
10925
|
return this.client.requestJson(
|
|
10645
|
-
`/api/v2/navigation/folders/${
|
|
10926
|
+
`/api/v2/navigation/folders/${selectorValue8(folder)}`,
|
|
10646
10927
|
jsonOptions5(body, "PATCH")
|
|
10647
10928
|
);
|
|
10648
10929
|
}
|
|
10649
10930
|
deleteFolder(folder) {
|
|
10650
10931
|
return this.client.requestJson(
|
|
10651
|
-
`/api/v2/navigation/folders/${
|
|
10932
|
+
`/api/v2/navigation/folders/${selectorValue8(folder)}`,
|
|
10652
10933
|
{ method: "DELETE" }
|
|
10653
10934
|
);
|
|
10654
10935
|
}
|
|
@@ -10661,20 +10942,20 @@ var NavigationApi = class {
|
|
|
10661
10942
|
};
|
|
10662
10943
|
|
|
10663
10944
|
// src/commands/navigation.ts
|
|
10664
|
-
function
|
|
10945
|
+
function getCommandIo9(stdout) {
|
|
10665
10946
|
return stdout ?? process.stdout;
|
|
10666
10947
|
}
|
|
10667
|
-
function
|
|
10948
|
+
function writeLine9(stdout, value) {
|
|
10668
10949
|
stdout.write(`${value}
|
|
10669
10950
|
`);
|
|
10670
10951
|
}
|
|
10671
|
-
function
|
|
10952
|
+
function getGlobalOptions9(command) {
|
|
10672
10953
|
return command.optsWithGlobals();
|
|
10673
10954
|
}
|
|
10674
10955
|
function emitJson8(stdout, commandName, data, configPath) {
|
|
10675
|
-
|
|
10956
|
+
writeLine9(stdout, JSON.stringify(buildJsonSuccess(data, { command: commandName, configPath })));
|
|
10676
10957
|
}
|
|
10677
|
-
function
|
|
10958
|
+
function toConfigurationError9(filePath, error) {
|
|
10678
10959
|
if (error instanceof CliError) {
|
|
10679
10960
|
throw error;
|
|
10680
10961
|
}
|
|
@@ -10689,7 +10970,7 @@ function toConfigurationError8(filePath, error) {
|
|
|
10689
10970
|
function createNavigationApi(command, filePath) {
|
|
10690
10971
|
try {
|
|
10691
10972
|
const config = readRuntimeConfig(filePath);
|
|
10692
|
-
const runtime = resolveRuntimeContext(config,
|
|
10973
|
+
const runtime = resolveRuntimeContext(config, getGlobalOptions9(command));
|
|
10693
10974
|
if (!runtime.baseUrl) {
|
|
10694
10975
|
throw new CliError("configuration_error", `Resolved profile "${runtime.profile}" is missing a base URL.`);
|
|
10695
10976
|
}
|
|
@@ -10704,10 +10985,10 @@ function createNavigationApi(command, filePath) {
|
|
|
10704
10985
|
readOnly: runtime.readOnly
|
|
10705
10986
|
};
|
|
10706
10987
|
} catch (error) {
|
|
10707
|
-
|
|
10988
|
+
toConfigurationError9(filePath, error);
|
|
10708
10989
|
}
|
|
10709
10990
|
}
|
|
10710
|
-
function
|
|
10991
|
+
function ensureWritable7(commandName, readOnly, mode) {
|
|
10711
10992
|
if (readOnly) {
|
|
10712
10993
|
throw new CliError(
|
|
10713
10994
|
"command_not_allowed_in_read_only_mode",
|
|
@@ -10716,12 +10997,12 @@ function ensureWritable6(commandName, readOnly, mode) {
|
|
|
10716
10997
|
);
|
|
10717
10998
|
}
|
|
10718
10999
|
}
|
|
10719
|
-
function
|
|
11000
|
+
function parseUuidOrSlugSelector8(input) {
|
|
10720
11001
|
try {
|
|
10721
11002
|
return normalizeUuidOrSlug(input);
|
|
10722
11003
|
} catch (error) {
|
|
10723
11004
|
const message = error instanceof Error ? error.message : "Invalid selector.";
|
|
10724
|
-
throw new
|
|
11005
|
+
throw new InvalidArgumentError8(message);
|
|
10725
11006
|
}
|
|
10726
11007
|
}
|
|
10727
11008
|
function parseInteger(value, flagName) {
|
|
@@ -10800,7 +11081,7 @@ function folderRows2(folders) {
|
|
|
10800
11081
|
}
|
|
10801
11082
|
function registerNavigationCommands(program, options = {}) {
|
|
10802
11083
|
const filePath = options.configPath ?? defaultConfigPath;
|
|
10803
|
-
const stdout =
|
|
11084
|
+
const stdout = getCommandIo9(options.stdout);
|
|
10804
11085
|
const navigation = program.command("navigation").description("Manage workspace navigation");
|
|
10805
11086
|
const folders = navigation.command("folders").description("Manage navigation folders");
|
|
10806
11087
|
folders.command("list").description("List navigation folders").action(async function action() {
|
|
@@ -10812,7 +11093,7 @@ function registerNavigationCommands(program, options = {}) {
|
|
|
10812
11093
|
}
|
|
10813
11094
|
printTable(folderRows2(data), ["id", "order", "name", "resourceCount"], stdout);
|
|
10814
11095
|
});
|
|
10815
|
-
folders.command("get").description("Get a navigation folder by UUID or exact name").argument("<folder>", "folder UUID or exact name",
|
|
11096
|
+
folders.command("get").description("Get a navigation folder by UUID or exact name").argument("<folder>", "folder UUID or exact name", parseUuidOrSlugSelector8).action(async function action(folder) {
|
|
10816
11097
|
const { api, json } = createNavigationApi(this, filePath);
|
|
10817
11098
|
const data = await api.listFolders();
|
|
10818
11099
|
const resolved = resolveFolder2(data, folder);
|
|
@@ -10824,17 +11105,17 @@ function registerNavigationCommands(program, options = {}) {
|
|
|
10824
11105
|
});
|
|
10825
11106
|
folders.command("create").description("Create a navigation folder").requiredOption("--name <name>", "folder name").option("--order <n>", "display order (lower values appear first)").option("--props <json>", 'additionalProperties JSON: free-form client metadata, e.g. {"color":"blue","icon":"chart-line"}').option("--props-file <path>", "path to a file with the additionalProperties JSON").action(async function action(commandOptions) {
|
|
10826
11107
|
const { api, json, readOnly } = createNavigationApi(this, filePath);
|
|
10827
|
-
|
|
11108
|
+
ensureWritable7("navigation folders create", readOnly, "write");
|
|
10828
11109
|
const data = await api.createFolder(buildFolderBody(commandOptions));
|
|
10829
11110
|
if (json) {
|
|
10830
11111
|
emitJson8(stdout, "navigation folders create", data, filePath);
|
|
10831
11112
|
return;
|
|
10832
11113
|
}
|
|
10833
|
-
|
|
11114
|
+
writeLine9(stdout, `Created navigation folder "${String(data.name ?? commandOptions.name)}".`);
|
|
10834
11115
|
});
|
|
10835
|
-
folders.command("update").description("Update a navigation folder").argument("<folder>", "folder UUID or exact name",
|
|
11116
|
+
folders.command("update").description("Update a navigation folder").argument("<folder>", "folder UUID or exact name", parseUuidOrSlugSelector8).option("--name <name>", "folder name").option("--order <n>", "display order (lower values appear first)").option("--props <json>", 'additionalProperties JSON: free-form client metadata, e.g. {"color":"blue","icon":"chart-line"}').option("--props-file <path>", "path to a file with the additionalProperties JSON").action(async function action(folder, commandOptions) {
|
|
10836
11117
|
const { api, json, readOnly } = createNavigationApi(this, filePath);
|
|
10837
|
-
|
|
11118
|
+
ensureWritable7("navigation folders update", readOnly, "write");
|
|
10838
11119
|
const allFolders = await api.listFolders();
|
|
10839
11120
|
const resolved = resolveFolder2(allFolders, folder);
|
|
10840
11121
|
const body = buildFolderBody(commandOptions);
|
|
@@ -10846,11 +11127,11 @@ function registerNavigationCommands(program, options = {}) {
|
|
|
10846
11127
|
emitJson8(stdout, "navigation folders update", data, filePath);
|
|
10847
11128
|
return;
|
|
10848
11129
|
}
|
|
10849
|
-
|
|
11130
|
+
writeLine9(stdout, `Updated navigation folder "${String(data.name ?? resolved.name ?? resolved.id)}".`);
|
|
10850
11131
|
});
|
|
10851
|
-
folders.command("delete").description("Delete a navigation folder").argument("<folder>", "folder UUID or exact name",
|
|
11132
|
+
folders.command("delete").description("Delete a navigation folder").argument("<folder>", "folder UUID or exact name", parseUuidOrSlugSelector8).action(async function action(folder) {
|
|
10852
11133
|
const { api, json, readOnly } = createNavigationApi(this, filePath);
|
|
10853
|
-
|
|
11134
|
+
ensureWritable7("navigation folders delete", readOnly, "destructive");
|
|
10854
11135
|
const allFolders = await api.listFolders();
|
|
10855
11136
|
const resolved = resolveFolder2(allFolders, folder);
|
|
10856
11137
|
const data = await api.deleteFolder({ kind: "uuid", value: resolved.id });
|
|
@@ -10858,15 +11139,15 @@ function registerNavigationCommands(program, options = {}) {
|
|
|
10858
11139
|
emitJson8(stdout, "navigation folders delete", data, filePath);
|
|
10859
11140
|
return;
|
|
10860
11141
|
}
|
|
10861
|
-
|
|
11142
|
+
writeLine9(stdout, `Deleted navigation folder "${resolved.name ?? resolved.id}".`);
|
|
10862
11143
|
});
|
|
10863
11144
|
navigation.command("resources").description("Manage navigation resources").command("move").description(
|
|
10864
11145
|
"Move a schema into a navigation folder. Only schemas can be moved (the navigation menu holds databases); schedules and sub-schemas follow their parent schema. Use the root folder UUID 00000000-0000-0000-0000-000000000000 to move it back to the workspace root."
|
|
10865
11146
|
).argument("<resource>", "schema UUID").requiredOption("--to <folder>", "target folder UUID or exact name").action(async function action(resourceId, commandOptions) {
|
|
10866
11147
|
const { api, json, readOnly } = createNavigationApi(this, filePath);
|
|
10867
|
-
|
|
11148
|
+
ensureWritable7("navigation resources move", readOnly, "write");
|
|
10868
11149
|
const allFolders = await api.listFolders();
|
|
10869
|
-
const resolved = resolveFolder2(allFolders,
|
|
11150
|
+
const resolved = resolveFolder2(allFolders, parseUuidOrSlugSelector8(commandOptions.to));
|
|
10870
11151
|
const data = await api.moveResource({
|
|
10871
11152
|
resourceId,
|
|
10872
11153
|
targetFolderId: resolved.id
|
|
@@ -10875,23 +11156,23 @@ function registerNavigationCommands(program, options = {}) {
|
|
|
10875
11156
|
emitJson8(stdout, "navigation resources move", data, filePath);
|
|
10876
11157
|
return;
|
|
10877
11158
|
}
|
|
10878
|
-
|
|
11159
|
+
writeLine9(stdout, `Moved resource "${resourceId}" to "${resolved.name ?? resolved.id}".`);
|
|
10879
11160
|
});
|
|
10880
11161
|
}
|
|
10881
11162
|
|
|
10882
11163
|
// src/commands/profiles.ts
|
|
10883
|
-
function
|
|
11164
|
+
function getCommandIo10(stdout) {
|
|
10884
11165
|
return stdout ?? process.stdout;
|
|
10885
11166
|
}
|
|
10886
|
-
function
|
|
11167
|
+
function writeLine10(stdout, value) {
|
|
10887
11168
|
stdout.write(`${value}
|
|
10888
11169
|
`);
|
|
10889
11170
|
}
|
|
10890
|
-
function
|
|
11171
|
+
function getGlobalOptions10(command) {
|
|
10891
11172
|
return command.optsWithGlobals();
|
|
10892
11173
|
}
|
|
10893
11174
|
function emitJson9(stdout, commandName, data, configPath) {
|
|
10894
|
-
|
|
11175
|
+
writeLine10(
|
|
10895
11176
|
stdout,
|
|
10896
11177
|
JSON.stringify(buildJsonSuccess(data, { command: commandName, configPath }))
|
|
10897
11178
|
);
|
|
@@ -10947,14 +11228,14 @@ function emitProfilesTable(stdout, data) {
|
|
|
10947
11228
|
}
|
|
10948
11229
|
function registerProfilesCommands(program, options = {}) {
|
|
10949
11230
|
const filePath = options.configPath ?? defaultConfigPath;
|
|
10950
|
-
const stdout =
|
|
11231
|
+
const stdout = getCommandIo10(options.stdout);
|
|
10951
11232
|
const profiles = program.command("profiles").description("Manage local CLI profiles");
|
|
10952
11233
|
profiles.command("list").description("List configured profiles").action(function action() {
|
|
10953
11234
|
const config = readRequiredConfig(filePath);
|
|
10954
11235
|
const data = Object.entries(config.profiles).map(
|
|
10955
11236
|
([name, profile]) => toDisplayProfile(name, profile, config.defaultProfile)
|
|
10956
11237
|
);
|
|
10957
|
-
if (
|
|
11238
|
+
if (getGlobalOptions10(this).json) {
|
|
10958
11239
|
emitJson9(stdout, "profiles list", data, filePath);
|
|
10959
11240
|
return;
|
|
10960
11241
|
}
|
|
@@ -10964,7 +11245,7 @@ function registerProfilesCommands(program, options = {}) {
|
|
|
10964
11245
|
const config = readRequiredConfig(filePath);
|
|
10965
11246
|
const profile = getRequiredProfile(config, profileName);
|
|
10966
11247
|
const data = toDisplayProfile(profileName, profile, config.defaultProfile);
|
|
10967
|
-
if (
|
|
11248
|
+
if (getGlobalOptions10(this).json) {
|
|
10968
11249
|
emitJson9(stdout, "profiles get", data, filePath);
|
|
10969
11250
|
return;
|
|
10970
11251
|
}
|
|
@@ -10979,11 +11260,11 @@ function registerProfilesCommands(program, options = {}) {
|
|
|
10979
11260
|
profile: profileName,
|
|
10980
11261
|
defaultProfile: nextConfig.defaultProfile
|
|
10981
11262
|
};
|
|
10982
|
-
if (
|
|
11263
|
+
if (getGlobalOptions10(this).json) {
|
|
10983
11264
|
emitJson9(stdout, "profiles use", data, filePath);
|
|
10984
11265
|
return;
|
|
10985
11266
|
}
|
|
10986
|
-
|
|
11267
|
+
writeLine10(stdout, `Using profile "${profileName}".`);
|
|
10987
11268
|
});
|
|
10988
11269
|
profiles.command("add").description("Add a profile to the local config").argument("<profile>", "profile name").requiredOption("--api-key <token>", "API key").option("--base-url <url>", "base URL").action(function action(profileName, commandOptions) {
|
|
10989
11270
|
const config = loadConfigForAdd(filePath);
|
|
@@ -11007,11 +11288,11 @@ function registerProfilesCommands(program, options = {}) {
|
|
|
11007
11288
|
nextConfig.profiles[profileName] ?? {},
|
|
11008
11289
|
nextConfig.defaultProfile
|
|
11009
11290
|
);
|
|
11010
|
-
if (
|
|
11291
|
+
if (getGlobalOptions10(this).json) {
|
|
11011
11292
|
emitJson9(stdout, "profiles add", data, filePath);
|
|
11012
11293
|
return;
|
|
11013
11294
|
}
|
|
11014
|
-
|
|
11295
|
+
writeLine10(stdout, `Added profile "${profileName}".`);
|
|
11015
11296
|
});
|
|
11016
11297
|
profiles.command("update").description("Update an existing profile").argument("<profile>", "profile name").option("--api-key <token>", "API key").option("--base-url <url>", "base URL").action(function action(profileName, commandOptions) {
|
|
11017
11298
|
if (commandOptions.apiKey === void 0 && commandOptions.baseUrl === void 0) {
|
|
@@ -11033,11 +11314,11 @@ function registerProfilesCommands(program, options = {}) {
|
|
|
11033
11314
|
nextConfig.profiles[profileName] ?? {},
|
|
11034
11315
|
nextConfig.defaultProfile
|
|
11035
11316
|
);
|
|
11036
|
-
if (
|
|
11317
|
+
if (getGlobalOptions10(this).json) {
|
|
11037
11318
|
emitJson9(stdout, "profiles update", data, filePath);
|
|
11038
11319
|
return;
|
|
11039
11320
|
}
|
|
11040
|
-
|
|
11321
|
+
writeLine10(stdout, `Updated profile "${profileName}".`);
|
|
11041
11322
|
});
|
|
11042
11323
|
profiles.command("remove").description("Remove a profile from the local config").argument("<profile>", "profile name").action(function action(profileName) {
|
|
11043
11324
|
const config = readRequiredConfig(filePath);
|
|
@@ -11048,17 +11329,17 @@ function registerProfilesCommands(program, options = {}) {
|
|
|
11048
11329
|
profile: profileName,
|
|
11049
11330
|
defaultProfile: nextConfig.defaultProfile
|
|
11050
11331
|
};
|
|
11051
|
-
if (
|
|
11332
|
+
if (getGlobalOptions10(this).json) {
|
|
11052
11333
|
emitJson9(stdout, "profiles remove", data, filePath);
|
|
11053
11334
|
return;
|
|
11054
11335
|
}
|
|
11055
|
-
|
|
11336
|
+
writeLine10(stdout, `Removed profile "${profileName}".`);
|
|
11056
11337
|
});
|
|
11057
11338
|
}
|
|
11058
11339
|
|
|
11059
11340
|
// src/commands/records.ts
|
|
11060
11341
|
import { readFileSync as readFileSync8 } from "fs";
|
|
11061
|
-
import { InvalidArgumentError as
|
|
11342
|
+
import { InvalidArgumentError as InvalidArgumentError9 } from "commander";
|
|
11062
11343
|
|
|
11063
11344
|
// src/api/records.ts
|
|
11064
11345
|
function jsonOptions6(body, method) {
|
|
@@ -11070,7 +11351,7 @@ function jsonOptions6(body, method) {
|
|
|
11070
11351
|
body: JSON.stringify(body)
|
|
11071
11352
|
};
|
|
11072
11353
|
}
|
|
11073
|
-
function
|
|
11354
|
+
function selectorValue9(selector) {
|
|
11074
11355
|
return selector.value;
|
|
11075
11356
|
}
|
|
11076
11357
|
var RecordsApi = class {
|
|
@@ -11085,7 +11366,7 @@ var RecordsApi = class {
|
|
|
11085
11366
|
if (query.offset !== void 0) {
|
|
11086
11367
|
params.set("offset", String(query.offset));
|
|
11087
11368
|
}
|
|
11088
|
-
const path = `/api/v2/schemas/${
|
|
11369
|
+
const path = `/api/v2/schemas/${selectorValue9(schema)}/records`;
|
|
11089
11370
|
const queryString = params.toString();
|
|
11090
11371
|
return this.client.getJson(
|
|
11091
11372
|
queryString ? `${path}?${queryString}` : path
|
|
@@ -11094,36 +11375,36 @@ var RecordsApi = class {
|
|
|
11094
11375
|
queryRecords(schema, query) {
|
|
11095
11376
|
const body = this.normalizeQueryInput(query);
|
|
11096
11377
|
return this.client.requestJson(
|
|
11097
|
-
`/api/v2/schemas/${
|
|
11378
|
+
`/api/v2/schemas/${selectorValue9(schema)}/records:query`,
|
|
11098
11379
|
jsonOptions6(body, "POST")
|
|
11099
11380
|
);
|
|
11100
11381
|
}
|
|
11101
11382
|
getRecord(schema, record) {
|
|
11102
11383
|
return this.client.getJson(
|
|
11103
|
-
`/api/v2/schemas/${
|
|
11384
|
+
`/api/v2/schemas/${selectorValue9(schema)}/records/${selectorValue9(record)}`
|
|
11104
11385
|
);
|
|
11105
11386
|
}
|
|
11106
11387
|
createRecords(schema, records) {
|
|
11107
11388
|
return this.client.requestJson(
|
|
11108
|
-
`/api/v2/schemas/${
|
|
11389
|
+
`/api/v2/schemas/${selectorValue9(schema)}/records`,
|
|
11109
11390
|
jsonOptions6({ records }, "POST")
|
|
11110
11391
|
);
|
|
11111
11392
|
}
|
|
11112
11393
|
updateRecord(schema, record, input) {
|
|
11113
11394
|
return this.client.requestJson(
|
|
11114
|
-
`/api/v2/schemas/${
|
|
11395
|
+
`/api/v2/schemas/${selectorValue9(schema)}/records/${selectorValue9(record)}`,
|
|
11115
11396
|
jsonOptions6(input, "PATCH")
|
|
11116
11397
|
);
|
|
11117
11398
|
}
|
|
11118
11399
|
deleteRecords(schema, recordIds) {
|
|
11119
11400
|
return this.client.requestJson(
|
|
11120
|
-
`/api/v2/schemas/${
|
|
11401
|
+
`/api/v2/schemas/${selectorValue9(schema)}/records:delete`,
|
|
11121
11402
|
jsonOptions6({ recordIds }, "POST")
|
|
11122
11403
|
);
|
|
11123
11404
|
}
|
|
11124
11405
|
clearRecords(schema) {
|
|
11125
11406
|
return this.client.requestJson(
|
|
11126
|
-
`/api/v2/schemas/${
|
|
11407
|
+
`/api/v2/schemas/${selectorValue9(schema)}/records:clear`,
|
|
11127
11408
|
{ method: "DELETE" }
|
|
11128
11409
|
);
|
|
11129
11410
|
}
|
|
@@ -11165,7 +11446,7 @@ function jsonOptions7(body, method) {
|
|
|
11165
11446
|
body: JSON.stringify(body)
|
|
11166
11447
|
};
|
|
11167
11448
|
}
|
|
11168
|
-
function
|
|
11449
|
+
function selectorValue10(selector) {
|
|
11169
11450
|
return selector.value;
|
|
11170
11451
|
}
|
|
11171
11452
|
var SchemasApi = class {
|
|
@@ -11176,26 +11457,26 @@ var SchemasApi = class {
|
|
|
11176
11457
|
return this.client.getJson("/api/v2/schemas");
|
|
11177
11458
|
}
|
|
11178
11459
|
getSchema(schema) {
|
|
11179
|
-
return this.client.getJson(`/api/v2/schemas/${
|
|
11460
|
+
return this.client.getJson(`/api/v2/schemas/${selectorValue10(schema)}`);
|
|
11180
11461
|
}
|
|
11181
11462
|
createSchema(input) {
|
|
11182
11463
|
return this.client.requestJson("/api/v2/schemas", jsonOptions7(input, "POST"));
|
|
11183
11464
|
}
|
|
11184
11465
|
updateSchema(schema, input) {
|
|
11185
11466
|
return this.client.requestJson(
|
|
11186
|
-
`/api/v2/schemas/${
|
|
11467
|
+
`/api/v2/schemas/${selectorValue10(schema)}`,
|
|
11187
11468
|
jsonOptions7(input, "PATCH")
|
|
11188
11469
|
);
|
|
11189
11470
|
}
|
|
11190
11471
|
setUniqueFields(schema, input) {
|
|
11191
11472
|
return this.client.requestJson(
|
|
11192
|
-
`/api/v2/schemas/${
|
|
11473
|
+
`/api/v2/schemas/${selectorValue10(schema)}/unique-fields`,
|
|
11193
11474
|
jsonOptions7(input, "PUT")
|
|
11194
11475
|
);
|
|
11195
11476
|
}
|
|
11196
11477
|
deleteSchema(schema) {
|
|
11197
11478
|
return this.client.requestJson(
|
|
11198
|
-
`/api/v2/schemas/${
|
|
11479
|
+
`/api/v2/schemas/${selectorValue10(schema)}`,
|
|
11199
11480
|
{ method: "DELETE" }
|
|
11200
11481
|
);
|
|
11201
11482
|
}
|
|
@@ -11205,47 +11486,47 @@ var SchemasApi = class {
|
|
|
11205
11486
|
}
|
|
11206
11487
|
getField(schema, field) {
|
|
11207
11488
|
return this.client.getJson(
|
|
11208
|
-
`/api/v2/schemas/${
|
|
11489
|
+
`/api/v2/schemas/${selectorValue10(schema)}/fields/${selectorValue10(field)}`
|
|
11209
11490
|
);
|
|
11210
11491
|
}
|
|
11211
11492
|
createField(schema, input) {
|
|
11212
11493
|
return this.client.requestJson(
|
|
11213
|
-
`/api/v2/schemas/${
|
|
11494
|
+
`/api/v2/schemas/${selectorValue10(schema)}/fields`,
|
|
11214
11495
|
jsonOptions7(input, "POST")
|
|
11215
11496
|
);
|
|
11216
11497
|
}
|
|
11217
11498
|
updateField(schema, field, input) {
|
|
11218
11499
|
return this.client.requestJson(
|
|
11219
|
-
`/api/v2/schemas/${
|
|
11500
|
+
`/api/v2/schemas/${selectorValue10(schema)}/fields/${selectorValue10(field)}`,
|
|
11220
11501
|
jsonOptions7(input, "PATCH")
|
|
11221
11502
|
);
|
|
11222
11503
|
}
|
|
11223
11504
|
deleteField(schema, field) {
|
|
11224
11505
|
return this.client.requestJson(
|
|
11225
|
-
`/api/v2/schemas/${
|
|
11506
|
+
`/api/v2/schemas/${selectorValue10(schema)}/fields/${selectorValue10(field)}`,
|
|
11226
11507
|
{ method: "DELETE" }
|
|
11227
11508
|
);
|
|
11228
11509
|
}
|
|
11229
11510
|
};
|
|
11230
11511
|
|
|
11231
11512
|
// src/commands/records.ts
|
|
11232
|
-
function
|
|
11513
|
+
function getCommandIo11(stdout) {
|
|
11233
11514
|
return stdout ?? process.stdout;
|
|
11234
11515
|
}
|
|
11235
|
-
function
|
|
11516
|
+
function writeLine11(stdout, value) {
|
|
11236
11517
|
stdout.write(`${value}
|
|
11237
11518
|
`);
|
|
11238
11519
|
}
|
|
11239
|
-
function
|
|
11520
|
+
function getGlobalOptions11(command) {
|
|
11240
11521
|
return command.optsWithGlobals();
|
|
11241
11522
|
}
|
|
11242
11523
|
function emitJson10(stdout, commandName, data, configPath, meta = {}) {
|
|
11243
|
-
|
|
11524
|
+
writeLine11(
|
|
11244
11525
|
stdout,
|
|
11245
11526
|
JSON.stringify(buildJsonSuccess(data, { command: commandName, configPath, ...meta }))
|
|
11246
11527
|
);
|
|
11247
11528
|
}
|
|
11248
|
-
function
|
|
11529
|
+
function toConfigurationError10(filePath, error) {
|
|
11249
11530
|
if (error instanceof CliError) {
|
|
11250
11531
|
throw error;
|
|
11251
11532
|
}
|
|
@@ -11260,7 +11541,7 @@ function toConfigurationError9(filePath, error) {
|
|
|
11260
11541
|
function createRecordsApi(command, filePath) {
|
|
11261
11542
|
try {
|
|
11262
11543
|
const config = readRuntimeConfig(filePath);
|
|
11263
|
-
const runtime = resolveRuntimeContext(config,
|
|
11544
|
+
const runtime = resolveRuntimeContext(config, getGlobalOptions11(command));
|
|
11264
11545
|
if (!runtime.baseUrl) {
|
|
11265
11546
|
throw new CliError(
|
|
11266
11547
|
"configuration_error",
|
|
@@ -11279,10 +11560,10 @@ function createRecordsApi(command, filePath) {
|
|
|
11279
11560
|
readOnly: runtime.readOnly
|
|
11280
11561
|
};
|
|
11281
11562
|
} catch (error) {
|
|
11282
|
-
|
|
11563
|
+
toConfigurationError10(filePath, error);
|
|
11283
11564
|
}
|
|
11284
11565
|
}
|
|
11285
|
-
function
|
|
11566
|
+
function ensureWritable8(commandName, readOnly, commandMode) {
|
|
11286
11567
|
if (readOnly) {
|
|
11287
11568
|
throw new CliError(
|
|
11288
11569
|
"command_not_allowed_in_read_only_mode",
|
|
@@ -11294,24 +11575,24 @@ function ensureWritable7(commandName, readOnly, commandMode) {
|
|
|
11294
11575
|
);
|
|
11295
11576
|
}
|
|
11296
11577
|
}
|
|
11297
|
-
function
|
|
11578
|
+
function parseUuidOrSlugSelector9(input) {
|
|
11298
11579
|
try {
|
|
11299
11580
|
return normalizeUuidOrSlug(input);
|
|
11300
11581
|
} catch (error) {
|
|
11301
11582
|
const message = error instanceof Error ? error.message : "Invalid selector.";
|
|
11302
|
-
throw new
|
|
11583
|
+
throw new InvalidArgumentError9(message);
|
|
11303
11584
|
}
|
|
11304
11585
|
}
|
|
11305
11586
|
function parseNonNegativeInteger2(input) {
|
|
11306
11587
|
if (!/^\d+$/.test(input.trim())) {
|
|
11307
|
-
throw new
|
|
11588
|
+
throw new InvalidArgumentError9(`Expected a non-negative integer, received "${input}".`);
|
|
11308
11589
|
}
|
|
11309
11590
|
return Number(input);
|
|
11310
11591
|
}
|
|
11311
11592
|
function parseCommaSeparatedValues(input, label) {
|
|
11312
11593
|
const values = input.split(",").map((value) => value.trim()).filter(Boolean);
|
|
11313
11594
|
if (values.length === 0) {
|
|
11314
|
-
throw new
|
|
11595
|
+
throw new InvalidArgumentError9(`Expected ${label} to contain at least one value.`);
|
|
11315
11596
|
}
|
|
11316
11597
|
return values;
|
|
11317
11598
|
}
|
|
@@ -11320,7 +11601,7 @@ function parseExpressionValue(input) {
|
|
|
11320
11601
|
return parseExpression(input);
|
|
11321
11602
|
} catch (error) {
|
|
11322
11603
|
const message = error instanceof Error ? error.message : "Invalid expression.";
|
|
11323
|
-
throw new
|
|
11604
|
+
throw new InvalidArgumentError9(message);
|
|
11324
11605
|
}
|
|
11325
11606
|
}
|
|
11326
11607
|
function parseKeyValueAssignment(input) {
|
|
@@ -11328,7 +11609,7 @@ function parseKeyValueAssignment(input) {
|
|
|
11328
11609
|
return parseKeyValue(input);
|
|
11329
11610
|
} catch (error) {
|
|
11330
11611
|
const message = error instanceof Error ? error.message : "Invalid assignment.";
|
|
11331
|
-
throw new
|
|
11612
|
+
throw new InvalidArgumentError9(message);
|
|
11332
11613
|
}
|
|
11333
11614
|
}
|
|
11334
11615
|
function parseJsonKeyValueAssignment(input) {
|
|
@@ -11336,7 +11617,7 @@ function parseJsonKeyValueAssignment(input) {
|
|
|
11336
11617
|
return parseJsonAssignment(input);
|
|
11337
11618
|
} catch (error) {
|
|
11338
11619
|
const message = error instanceof Error ? error.message : "Invalid JSON assignment.";
|
|
11339
|
-
throw new
|
|
11620
|
+
throw new InvalidArgumentError9(message);
|
|
11340
11621
|
}
|
|
11341
11622
|
}
|
|
11342
11623
|
function dedupeStrings(values) {
|
|
@@ -11353,7 +11634,7 @@ function toRecordUuid(value) {
|
|
|
11353
11634
|
function collectRecordIds(value, previous = []) {
|
|
11354
11635
|
const uuid = toRecordUuid(value.trim());
|
|
11355
11636
|
if (!uuid) {
|
|
11356
|
-
throw new
|
|
11637
|
+
throw new InvalidArgumentError9(`Expected a record UUID, received "${value}".`);
|
|
11357
11638
|
}
|
|
11358
11639
|
return [...previous, uuid];
|
|
11359
11640
|
}
|
|
@@ -11640,9 +11921,9 @@ async function resolveSchemaSelector(api, selector) {
|
|
|
11640
11921
|
}
|
|
11641
11922
|
function registerRecordsCommands(program, options = {}) {
|
|
11642
11923
|
const filePath = options.configPath ?? defaultConfigPath;
|
|
11643
|
-
const stdout =
|
|
11924
|
+
const stdout = getCommandIo11(options.stdout);
|
|
11644
11925
|
const records = program.command("records").description("Manage schema records");
|
|
11645
|
-
records.command("list").description("List records for a schema with simple pagination").argument("<schema>", "schema uuid or slug",
|
|
11926
|
+
records.command("list").description("List records for a schema with simple pagination").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector9).option("--limit <number>", "limit results", parseNonNegativeInteger2).option("--offset <number>", "offset results", parseNonNegativeInteger2).action(async function action(schema, commandOptions) {
|
|
11646
11927
|
const { api, schemasApi, json } = createRecordsApi(this, filePath);
|
|
11647
11928
|
const resolvedSchema = await resolveSchemaSelector(schemasApi, schema);
|
|
11648
11929
|
const data = await api.listRecords(
|
|
@@ -11662,7 +11943,7 @@ function registerRecordsCommands(program, options = {}) {
|
|
|
11662
11943
|
}
|
|
11663
11944
|
emitTable4(stdout, recordsData);
|
|
11664
11945
|
});
|
|
11665
|
-
records.command("query").description("Query records for a schema").argument("<schema>", "schema uuid or slug",
|
|
11946
|
+
records.command("query").description("Query records for a schema").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector9).option("--select <fields>", "field selection (comma-separated, repeatable)", collectSelectValues, []).option("--where <expression>", "where expression", collectWhereExpressions, []).option(
|
|
11666
11947
|
"--search <term>",
|
|
11667
11948
|
"free-text search term (matched across the schema's searchable fields)"
|
|
11668
11949
|
).option("--sort <field:direction>", "sort field(s)", collectSortValues, []).option("--limit <number>", "limit results", parseNonNegativeInteger2).option("--offset <number>", "offset results", parseNonNegativeInteger2).option("--raw <json>", "raw JSON object payload").option("--raw-file <path>", "path to a raw JSON object payload").action(async function action(schema, commandOptions) {
|
|
@@ -11685,7 +11966,7 @@ function registerRecordsCommands(program, options = {}) {
|
|
|
11685
11966
|
}
|
|
11686
11967
|
emitTable4(stdout, recordsData);
|
|
11687
11968
|
});
|
|
11688
|
-
records.command("get").description("Get a record by UUID or slug").argument("<schema>", "schema uuid or slug",
|
|
11969
|
+
records.command("get").description("Get a record by UUID or slug").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector9).argument("<record>", "record uuid or slug", parseUuidOrSlugSelector9).action(async function action(schema, record) {
|
|
11689
11970
|
const { api, schemasApi, json } = createRecordsApi(this, filePath);
|
|
11690
11971
|
const resolvedSchema = await resolveSchemaSelector(schemasApi, schema);
|
|
11691
11972
|
const data = await api.getRecord(resolvedSchema, record);
|
|
@@ -11695,7 +11976,7 @@ function registerRecordsCommands(program, options = {}) {
|
|
|
11695
11976
|
}
|
|
11696
11977
|
emitTable4(stdout, data);
|
|
11697
11978
|
});
|
|
11698
|
-
records.command("create").description("Create one or more records").argument("<schema>", "schema uuid or slug",
|
|
11979
|
+
records.command("create").description("Create one or more records").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector9).option(
|
|
11699
11980
|
"--set <field=value>",
|
|
11700
11981
|
"set a string field (reference fields: a record id, 'recordId::label', or an exact display value)",
|
|
11701
11982
|
collectKeyValueAssignments,
|
|
@@ -11705,7 +11986,7 @@ function registerRecordsCommands(program, options = {}) {
|
|
|
11705
11986
|
"path to a JSON array of record objects (mutually exclusive with --set/--set-json/--raw/--raw-file)"
|
|
11706
11987
|
).action(async function action(schema, commandOptions) {
|
|
11707
11988
|
const { api, schemasApi, json, readOnly } = createRecordsApi(this, filePath);
|
|
11708
|
-
|
|
11989
|
+
ensureWritable8("records create", readOnly, "write");
|
|
11709
11990
|
const records2 = buildCreateRecords(commandOptions);
|
|
11710
11991
|
const resolvedSchema = await resolveSchemaSelector(schemasApi, schema);
|
|
11711
11992
|
const data = await api.createRecords(resolvedSchema, records2);
|
|
@@ -11713,22 +11994,22 @@ function registerRecordsCommands(program, options = {}) {
|
|
|
11713
11994
|
emitJson10(stdout, "records create", data, filePath);
|
|
11714
11995
|
return;
|
|
11715
11996
|
}
|
|
11716
|
-
|
|
11997
|
+
writeLine11(stdout, `Created ${data.created.length} record(s) in schema "${schema.value}".`);
|
|
11717
11998
|
if (data.errors.length > 0) {
|
|
11718
|
-
|
|
11999
|
+
writeLine11(stdout, `${data.errors.length} record(s) rejected:`);
|
|
11719
12000
|
for (const error of data.errors) {
|
|
11720
|
-
|
|
12001
|
+
writeLine11(stdout, ` - index ${error.index}: ${error.message}`);
|
|
11721
12002
|
}
|
|
11722
12003
|
}
|
|
11723
12004
|
});
|
|
11724
|
-
records.command("update").description("Update a record").argument("<schema>", "schema uuid or slug",
|
|
12005
|
+
records.command("update").description("Update a record").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector9).argument("<record>", "record uuid or slug", parseUuidOrSlugSelector9).option(
|
|
11725
12006
|
"--set <field=value>",
|
|
11726
12007
|
"set a string field (reference fields: a record id, 'recordId::label', or an exact display value)",
|
|
11727
12008
|
collectKeyValueAssignments,
|
|
11728
12009
|
[]
|
|
11729
12010
|
).option("--set-json <field=json>", "set a structured field", collectJsonAssignments, []).option("--unset <field>", "unset a field", collectStringValues, []).option("--raw <json>", "raw JSON object of fields to set").option("--raw-file <path>", "path to a JSON object of fields to set").action(async function action(schema, record, commandOptions) {
|
|
11730
12011
|
const { api, schemasApi, json, readOnly } = createRecordsApi(this, filePath);
|
|
11731
|
-
|
|
12012
|
+
ensureWritable8("records update", readOnly, "write");
|
|
11732
12013
|
const resolvedSchema = await resolveSchemaSelector(schemasApi, schema);
|
|
11733
12014
|
const data = await api.updateRecord(
|
|
11734
12015
|
resolvedSchema,
|
|
@@ -11739,14 +12020,14 @@ function registerRecordsCommands(program, options = {}) {
|
|
|
11739
12020
|
emitJson10(stdout, "records update", data, filePath);
|
|
11740
12021
|
return;
|
|
11741
12022
|
}
|
|
11742
|
-
|
|
12023
|
+
writeLine11(stdout, `Updated record "${getRecordIdentifier(data)}".`);
|
|
11743
12024
|
});
|
|
11744
|
-
records.command("delete").description("Delete one or more records").argument("<schema>", "schema uuid or slug",
|
|
12025
|
+
records.command("delete").description("Delete one or more records").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector9).option("--record <uuid>", "record uuid to delete (repeatable)", collectRecordIds, []).option(
|
|
11745
12026
|
"--records-file <path>",
|
|
11746
12027
|
"path to a file with one record uuid per line (merged with --record)"
|
|
11747
12028
|
).action(async function action(schema, commandOptions) {
|
|
11748
12029
|
const { api, schemasApi, json, readOnly } = createRecordsApi(this, filePath);
|
|
11749
|
-
|
|
12030
|
+
ensureWritable8("records delete", readOnly, "destructive");
|
|
11750
12031
|
const recordIds = resolveDeleteRecordIds(commandOptions);
|
|
11751
12032
|
const resolvedSchema = await resolveSchemaSelector(schemasApi, schema);
|
|
11752
12033
|
const data = await api.deleteRecords(resolvedSchema, recordIds);
|
|
@@ -11754,27 +12035,27 @@ function registerRecordsCommands(program, options = {}) {
|
|
|
11754
12035
|
emitJson10(stdout, "records delete", data, filePath);
|
|
11755
12036
|
return;
|
|
11756
12037
|
}
|
|
11757
|
-
|
|
12038
|
+
writeLine11(
|
|
11758
12039
|
stdout,
|
|
11759
12040
|
`Deleted ${recordIds.length} record(s) from schema "${schema.value}".`
|
|
11760
12041
|
);
|
|
11761
12042
|
});
|
|
11762
|
-
records.command("clear").description("Delete all records from a schema's table").argument("<schema>", "schema uuid or slug",
|
|
12043
|
+
records.command("clear").description("Delete all records from a schema's table").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector9).action(async function action(schema) {
|
|
11763
12044
|
const { api, schemasApi, json, readOnly } = createRecordsApi(this, filePath);
|
|
11764
|
-
|
|
12045
|
+
ensureWritable8("records clear", readOnly, "destructive");
|
|
11765
12046
|
const resolvedSchema = await resolveSchemaSelector(schemasApi, schema);
|
|
11766
12047
|
const data = await api.clearRecords(resolvedSchema);
|
|
11767
12048
|
if (json) {
|
|
11768
12049
|
emitJson10(stdout, "records clear", data, filePath);
|
|
11769
12050
|
return;
|
|
11770
12051
|
}
|
|
11771
|
-
|
|
12052
|
+
writeLine11(stdout, `Cleared all records from schema "${schema.value}".`);
|
|
11772
12053
|
});
|
|
11773
12054
|
}
|
|
11774
12055
|
|
|
11775
12056
|
// src/commands/schemas.ts
|
|
11776
12057
|
import { readFileSync as readFileSync9 } from "fs";
|
|
11777
|
-
import { InvalidArgumentError as
|
|
12058
|
+
import { InvalidArgumentError as InvalidArgumentError10 } from "commander";
|
|
11778
12059
|
var HIGHLIGHTED_FIELD_HELP = `
|
|
11779
12060
|
Highlighted field:
|
|
11780
12061
|
The schema's "main" field. The frontend uses its value as each record's
|
|
@@ -11784,23 +12065,23 @@ Highlighted field:
|
|
|
11784
12065
|
- Detail view: the record's name in the left-hand record list you
|
|
11785
12066
|
browse to open each record's form.
|
|
11786
12067
|
`;
|
|
11787
|
-
function
|
|
12068
|
+
function getCommandIo12(stdout) {
|
|
11788
12069
|
return stdout ?? process.stdout;
|
|
11789
12070
|
}
|
|
11790
|
-
function
|
|
12071
|
+
function writeLine12(stdout, value) {
|
|
11791
12072
|
stdout.write(`${value}
|
|
11792
12073
|
`);
|
|
11793
12074
|
}
|
|
11794
|
-
function
|
|
12075
|
+
function getGlobalOptions12(command) {
|
|
11795
12076
|
return command.optsWithGlobals();
|
|
11796
12077
|
}
|
|
11797
12078
|
function emitJson11(stdout, commandName, data, configPath) {
|
|
11798
|
-
|
|
12079
|
+
writeLine12(
|
|
11799
12080
|
stdout,
|
|
11800
12081
|
JSON.stringify(buildJsonSuccess(data, { command: commandName, configPath }))
|
|
11801
12082
|
);
|
|
11802
12083
|
}
|
|
11803
|
-
function
|
|
12084
|
+
function toConfigurationError11(filePath, error) {
|
|
11804
12085
|
if (error instanceof CliError) {
|
|
11805
12086
|
throw error;
|
|
11806
12087
|
}
|
|
@@ -11815,7 +12096,7 @@ function toConfigurationError10(filePath, error) {
|
|
|
11815
12096
|
function createSchemasApi(command, filePath) {
|
|
11816
12097
|
try {
|
|
11817
12098
|
const config = readRuntimeConfig(filePath);
|
|
11818
|
-
const runtime = resolveRuntimeContext(config,
|
|
12099
|
+
const runtime = resolveRuntimeContext(config, getGlobalOptions12(command));
|
|
11819
12100
|
if (!runtime.baseUrl) {
|
|
11820
12101
|
throw new CliError(
|
|
11821
12102
|
"configuration_error",
|
|
@@ -11834,10 +12115,10 @@ function createSchemasApi(command, filePath) {
|
|
|
11834
12115
|
readOnly: runtime.readOnly
|
|
11835
12116
|
};
|
|
11836
12117
|
} catch (error) {
|
|
11837
|
-
|
|
12118
|
+
toConfigurationError11(filePath, error);
|
|
11838
12119
|
}
|
|
11839
12120
|
}
|
|
11840
|
-
function
|
|
12121
|
+
function ensureWritable9(commandName, readOnly, commandMode) {
|
|
11841
12122
|
if (readOnly) {
|
|
11842
12123
|
throw new CliError(
|
|
11843
12124
|
"command_not_allowed_in_read_only_mode",
|
|
@@ -11849,16 +12130,16 @@ function ensureWritable8(commandName, readOnly, commandMode) {
|
|
|
11849
12130
|
);
|
|
11850
12131
|
}
|
|
11851
12132
|
}
|
|
11852
|
-
function
|
|
12133
|
+
function parseUuidOrSlugSelector10(input) {
|
|
11853
12134
|
try {
|
|
11854
12135
|
return normalizeUuidOrSlug(input);
|
|
11855
12136
|
} catch (error) {
|
|
11856
12137
|
const message = error instanceof Error ? error.message : "Invalid selector.";
|
|
11857
|
-
throw new
|
|
12138
|
+
throw new InvalidArgumentError10(message);
|
|
11858
12139
|
}
|
|
11859
12140
|
}
|
|
11860
12141
|
function collectFieldSelectors(value, previous = []) {
|
|
11861
|
-
return [...previous,
|
|
12142
|
+
return [...previous, parseUuidOrSlugSelector10(value)];
|
|
11862
12143
|
}
|
|
11863
12144
|
function parseBooleanFlag(input) {
|
|
11864
12145
|
const normalized = input.trim().toLowerCase();
|
|
@@ -11868,7 +12149,7 @@ function parseBooleanFlag(input) {
|
|
|
11868
12149
|
if (["false", "0", "no", "n", "off"].includes(normalized)) {
|
|
11869
12150
|
return false;
|
|
11870
12151
|
}
|
|
11871
|
-
throw new
|
|
12152
|
+
throw new InvalidArgumentError10(`Expected a boolean value, received "${input}".`);
|
|
11872
12153
|
}
|
|
11873
12154
|
function isJsonObject7(value) {
|
|
11874
12155
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -12083,7 +12364,7 @@ function isEmptyObject6(value) {
|
|
|
12083
12364
|
}
|
|
12084
12365
|
function registerSchemasCommands(program, options = {}) {
|
|
12085
12366
|
const filePath = options.configPath ?? defaultConfigPath;
|
|
12086
|
-
const stdout =
|
|
12367
|
+
const stdout = getCommandIo12(options.stdout);
|
|
12087
12368
|
const schemas = program.command("schemas").description("Manage schemas and schema fields");
|
|
12088
12369
|
schemas.command("list").description("List schemas").action(async function action() {
|
|
12089
12370
|
const { api, json } = createSchemasApi(this, filePath);
|
|
@@ -12094,7 +12375,7 @@ function registerSchemasCommands(program, options = {}) {
|
|
|
12094
12375
|
}
|
|
12095
12376
|
emitSchemasTable(stdout, data);
|
|
12096
12377
|
});
|
|
12097
|
-
schemas.command("get").description("Get a schema by UUID or slug").argument("<schema>", "schema uuid or slug",
|
|
12378
|
+
schemas.command("get").description("Get a schema by UUID or slug").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector10).action(async function action(schema) {
|
|
12098
12379
|
const { api, json } = createSchemasApi(this, filePath);
|
|
12099
12380
|
const resolvedSchema = await resolveSchemaSelector2(api, schema);
|
|
12100
12381
|
const data = await api.getSchema(resolvedSchema);
|
|
@@ -12106,7 +12387,7 @@ function registerSchemasCommands(program, options = {}) {
|
|
|
12106
12387
|
});
|
|
12107
12388
|
schemas.command("create").description("Create a schema").requiredOption("--name <name>", "schema name").requiredOption("--slug <slug>", "schema slug").option("--auditable", "mark schema as auditable").option("--commentable", "mark schema as commentable").action(async function action(commandOptions) {
|
|
12108
12389
|
const { api, json, readOnly } = createSchemasApi(this, filePath);
|
|
12109
|
-
|
|
12390
|
+
ensureWritable9("schemas create", readOnly, "write");
|
|
12110
12391
|
const input = {
|
|
12111
12392
|
name: commandOptions.name,
|
|
12112
12393
|
slug: commandOptions.slug,
|
|
@@ -12118,15 +12399,15 @@ function registerSchemasCommands(program, options = {}) {
|
|
|
12118
12399
|
emitJson11(stdout, "schemas create", data, filePath);
|
|
12119
12400
|
return;
|
|
12120
12401
|
}
|
|
12121
|
-
|
|
12402
|
+
writeLine12(stdout, `Created schema "${data.slug ?? commandOptions.slug}".`);
|
|
12122
12403
|
});
|
|
12123
|
-
schemas.command("update").description("Update a schema").argument("<schema>", "schema uuid or slug",
|
|
12404
|
+
schemas.command("update").description("Update a schema").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector10).option("--name <name>", "schema name").option("--slug <slug>", "schema slug").option("--auditable <bool>", "auditable flag", parseBooleanFlag).option("--commentable <bool>", "commentable flag", parseBooleanFlag).option(
|
|
12124
12405
|
"--highlighted-field <field>",
|
|
12125
12406
|
"its value is used as each record's display name in the UI (field uuid or slug)",
|
|
12126
|
-
|
|
12407
|
+
parseUuidOrSlugSelector10
|
|
12127
12408
|
).action(async function action(schema, commandOptions) {
|
|
12128
12409
|
const { api, json, readOnly } = createSchemasApi(this, filePath);
|
|
12129
|
-
|
|
12410
|
+
ensureWritable9("schemas update", readOnly, "write");
|
|
12130
12411
|
const resolvedSchema = await resolveSchemaSelector2(api, schema);
|
|
12131
12412
|
const input = buildSchemaUpdateInput(commandOptions);
|
|
12132
12413
|
if (commandOptions.highlightedField !== void 0) {
|
|
@@ -12148,16 +12429,16 @@ function registerSchemasCommands(program, options = {}) {
|
|
|
12148
12429
|
emitJson11(stdout, "schemas update", data, filePath);
|
|
12149
12430
|
return;
|
|
12150
12431
|
}
|
|
12151
|
-
|
|
12432
|
+
writeLine12(stdout, `Updated schema "${data.slug ?? schema.value}".`);
|
|
12152
12433
|
}).addHelpText("after", HIGHLIGHTED_FIELD_HELP);
|
|
12153
|
-
schemas.command("set-unique-fields").description("Set or clear the composite unique-field constraint on a schema").argument("<schema>", "schema uuid or slug",
|
|
12434
|
+
schemas.command("set-unique-fields").description("Set or clear the composite unique-field constraint on a schema").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector10).option(
|
|
12154
12435
|
"--field <field>",
|
|
12155
12436
|
"field uuid or slug to include in the unique constraint (repeatable)",
|
|
12156
12437
|
collectFieldSelectors,
|
|
12157
12438
|
[]
|
|
12158
12439
|
).option("--clear", "clear the unique constraint (sends an empty field list)").action(async function action(schema, commandOptions) {
|
|
12159
12440
|
const { api, json, readOnly } = createSchemasApi(this, filePath);
|
|
12160
|
-
|
|
12441
|
+
ensureWritable9("schemas set-unique-fields", readOnly, "write");
|
|
12161
12442
|
const selectors = commandOptions.field ?? [];
|
|
12162
12443
|
if (commandOptions.clear && selectors.length > 0) {
|
|
12163
12444
|
throw new CliError(
|
|
@@ -12184,18 +12465,18 @@ function registerSchemasCommands(program, options = {}) {
|
|
|
12184
12465
|
return;
|
|
12185
12466
|
}
|
|
12186
12467
|
if (input.fieldIds.length === 0) {
|
|
12187
|
-
|
|
12468
|
+
writeLine12(stdout, `Cleared unique fields on schema "${schema.value}".`);
|
|
12188
12469
|
return;
|
|
12189
12470
|
}
|
|
12190
12471
|
const count = input.fieldIds.length;
|
|
12191
|
-
|
|
12472
|
+
writeLine12(
|
|
12192
12473
|
stdout,
|
|
12193
12474
|
`Set unique fields on schema "${schema.value}" (${count} field${count === 1 ? "" : "s"}).`
|
|
12194
12475
|
);
|
|
12195
12476
|
});
|
|
12196
|
-
schemas.command("delete").description("Delete a schema").argument("<schema>", "schema uuid or slug",
|
|
12477
|
+
schemas.command("delete").description("Delete a schema").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector10).action(async function action(schema) {
|
|
12197
12478
|
const { api, json, readOnly } = createSchemasApi(this, filePath);
|
|
12198
|
-
|
|
12479
|
+
ensureWritable9("schemas delete", readOnly, "destructive");
|
|
12199
12480
|
const resolvedSchema = await resolveSchemaSelector2(api, schema);
|
|
12200
12481
|
await api.deleteSchema(resolvedSchema);
|
|
12201
12482
|
const data = {
|
|
@@ -12206,10 +12487,10 @@ function registerSchemasCommands(program, options = {}) {
|
|
|
12206
12487
|
emitJson11(stdout, "schemas delete", data, filePath);
|
|
12207
12488
|
return;
|
|
12208
12489
|
}
|
|
12209
|
-
|
|
12490
|
+
writeLine12(stdout, `Deleted schema "${schema.value}".`);
|
|
12210
12491
|
});
|
|
12211
12492
|
const fields = schemas.command("fields").description("Manage schema fields");
|
|
12212
|
-
fields.command("list").description("List fields for a schema").argument("<schema>", "schema uuid or slug",
|
|
12493
|
+
fields.command("list").description("List fields for a schema").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector10).action(async function action(schema) {
|
|
12213
12494
|
const { api, json } = createSchemasApi(this, filePath);
|
|
12214
12495
|
const resolvedSchema = await resolveSchemaSelector2(api, schema);
|
|
12215
12496
|
const data = await api.listFields(resolvedSchema);
|
|
@@ -12219,7 +12500,7 @@ function registerSchemasCommands(program, options = {}) {
|
|
|
12219
12500
|
}
|
|
12220
12501
|
emitFieldsTable(stdout, data);
|
|
12221
12502
|
});
|
|
12222
|
-
fields.command("get").description("Get a field by UUID or slug").argument("<schema>", "schema uuid or slug",
|
|
12503
|
+
fields.command("get").description("Get a field by UUID or slug").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector10).argument("<field>", "field uuid or slug", parseUuidOrSlugSelector10).action(async function action(schema, field) {
|
|
12223
12504
|
const { api, json } = createSchemasApi(this, filePath);
|
|
12224
12505
|
const resolvedSchema = await resolveSchemaSelector2(api, schema);
|
|
12225
12506
|
const resolvedField = await resolveFieldSelector(api, resolvedSchema, field);
|
|
@@ -12230,9 +12511,9 @@ function registerSchemasCommands(program, options = {}) {
|
|
|
12230
12511
|
}
|
|
12231
12512
|
emitFieldsTable(stdout, [data]);
|
|
12232
12513
|
});
|
|
12233
|
-
fields.command("create").description(`Create a field in a schema.${buildSchemaFieldCreateHelpText()}`).argument("<schema>", "schema uuid or slug",
|
|
12514
|
+
fields.command("create").description(`Create a field in a schema.${buildSchemaFieldCreateHelpText()}`).argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector10).option("--type <type>", `field type (${formatSchemaFieldTypes()})`).option("--slug <slug>", "field slug").option("--label <label>", "field label").option("--required <bool>", "required flag", parseBooleanFlag).option("--default <value>", "default field value").option("--raw <json>", "raw JSON object payload (see type-specific shapes in --help)").option("--raw-file <path>", "path to a raw JSON object payload").action(async function action(schema, commandOptions) {
|
|
12234
12515
|
const { api, json, readOnly } = createSchemasApi(this, filePath);
|
|
12235
|
-
|
|
12516
|
+
ensureWritable9("schemas fields create", readOnly, "write");
|
|
12236
12517
|
const input = buildFieldCreateInput(commandOptions);
|
|
12237
12518
|
const resolvedSchema = await resolveSchemaSelector2(api, schema);
|
|
12238
12519
|
let data;
|
|
@@ -12245,11 +12526,11 @@ function registerSchemasCommands(program, options = {}) {
|
|
|
12245
12526
|
emitJson11(stdout, "schemas fields create", data, filePath);
|
|
12246
12527
|
return;
|
|
12247
12528
|
}
|
|
12248
|
-
|
|
12529
|
+
writeLine12(stdout, `Created field "${data.slug ?? commandOptions.slug}".`);
|
|
12249
12530
|
});
|
|
12250
|
-
fields.command("update").description("Update a field in a schema").argument("<schema>", "schema uuid or slug",
|
|
12531
|
+
fields.command("update").description("Update a field in a schema").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector10).argument("<field>", "field uuid or slug", parseUuidOrSlugSelector10).option("--label <label>", "field label").option("--required <bool>", "required flag", parseBooleanFlag).option("--default <value>", "default field value").option("--raw <json>", "raw JSON object payload").option("--raw-file <path>", "path to a raw JSON object payload").action(async function action(schema, field, commandOptions) {
|
|
12251
12532
|
const { api, json, readOnly } = createSchemasApi(this, filePath);
|
|
12252
|
-
|
|
12533
|
+
ensureWritable9("schemas fields update", readOnly, "write");
|
|
12253
12534
|
const resolvedSchema = await resolveSchemaSelector2(api, schema);
|
|
12254
12535
|
const resolvedField = await resolveFieldSelector(api, resolvedSchema, field);
|
|
12255
12536
|
const currentField = await api.getField(resolvedSchema, resolvedField);
|
|
@@ -12269,11 +12550,11 @@ function registerSchemasCommands(program, options = {}) {
|
|
|
12269
12550
|
emitJson11(stdout, "schemas fields update", data, filePath);
|
|
12270
12551
|
return;
|
|
12271
12552
|
}
|
|
12272
|
-
|
|
12553
|
+
writeLine12(stdout, `Updated field "${data.slug ?? field.value}".`);
|
|
12273
12554
|
});
|
|
12274
|
-
fields.command("delete").description("Delete a field from a schema").argument("<schema>", "schema uuid or slug",
|
|
12555
|
+
fields.command("delete").description("Delete a field from a schema").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector10).argument("<field>", "field uuid or slug", parseUuidOrSlugSelector10).action(async function action(schema, field) {
|
|
12275
12556
|
const { api, json, readOnly } = createSchemasApi(this, filePath);
|
|
12276
|
-
|
|
12557
|
+
ensureWritable9("schemas fields delete", readOnly, "destructive");
|
|
12277
12558
|
const resolvedSchema = await resolveSchemaSelector2(api, schema);
|
|
12278
12559
|
const resolvedField = await resolveFieldSelector(api, resolvedSchema, field);
|
|
12279
12560
|
await api.deleteField(resolvedSchema, resolvedField);
|
|
@@ -12286,13 +12567,13 @@ function registerSchemasCommands(program, options = {}) {
|
|
|
12286
12567
|
emitJson11(stdout, "schemas fields delete", data, filePath);
|
|
12287
12568
|
return;
|
|
12288
12569
|
}
|
|
12289
|
-
|
|
12570
|
+
writeLine12(stdout, `Deleted field "${field.value}" from schema "${schema.value}".`);
|
|
12290
12571
|
});
|
|
12291
12572
|
}
|
|
12292
12573
|
|
|
12293
12574
|
// src/commands/teamspace.ts
|
|
12294
12575
|
import { readFileSync as readFileSync10 } from "fs";
|
|
12295
|
-
import { InvalidArgumentError as
|
|
12576
|
+
import { InvalidArgumentError as InvalidArgumentError11 } from "commander";
|
|
12296
12577
|
|
|
12297
12578
|
// src/api/teamspace.ts
|
|
12298
12579
|
function jsonOptions8(body, method) {
|
|
@@ -12304,7 +12585,7 @@ function jsonOptions8(body, method) {
|
|
|
12304
12585
|
body: JSON.stringify(body)
|
|
12305
12586
|
};
|
|
12306
12587
|
}
|
|
12307
|
-
function
|
|
12588
|
+
function selectorValue11(selector) {
|
|
12308
12589
|
return selector.value;
|
|
12309
12590
|
}
|
|
12310
12591
|
var TeamspaceApi = class {
|
|
@@ -12330,13 +12611,13 @@ var TeamspaceApi = class {
|
|
|
12330
12611
|
}
|
|
12331
12612
|
updateFolder(folder, input) {
|
|
12332
12613
|
return this.client.requestJson(
|
|
12333
|
-
`/api/v2/teamspaces/folders/${
|
|
12614
|
+
`/api/v2/teamspaces/folders/${selectorValue11(folder)}`,
|
|
12334
12615
|
jsonOptions8(input, "PATCH")
|
|
12335
12616
|
);
|
|
12336
12617
|
}
|
|
12337
12618
|
deleteFolder(folder) {
|
|
12338
12619
|
return this.client.requestJson(
|
|
12339
|
-
`/api/v2/teamspaces/folders/${
|
|
12620
|
+
`/api/v2/teamspaces/folders/${selectorValue11(folder)}`,
|
|
12340
12621
|
{ method: "DELETE" }
|
|
12341
12622
|
);
|
|
12342
12623
|
}
|
|
@@ -12355,23 +12636,23 @@ var TeamspaceApi = class {
|
|
|
12355
12636
|
};
|
|
12356
12637
|
|
|
12357
12638
|
// src/commands/teamspace.ts
|
|
12358
|
-
function
|
|
12639
|
+
function getCommandIo13(stdout) {
|
|
12359
12640
|
return stdout ?? process.stdout;
|
|
12360
12641
|
}
|
|
12361
|
-
function
|
|
12642
|
+
function writeLine13(stdout, value) {
|
|
12362
12643
|
stdout.write(`${value}
|
|
12363
12644
|
`);
|
|
12364
12645
|
}
|
|
12365
|
-
function
|
|
12646
|
+
function getGlobalOptions13(command) {
|
|
12366
12647
|
return command.optsWithGlobals();
|
|
12367
12648
|
}
|
|
12368
12649
|
function emitJson12(stdout, commandName, data, configPath) {
|
|
12369
|
-
|
|
12650
|
+
writeLine13(
|
|
12370
12651
|
stdout,
|
|
12371
12652
|
JSON.stringify(buildJsonSuccess(data, { command: commandName, configPath }))
|
|
12372
12653
|
);
|
|
12373
12654
|
}
|
|
12374
|
-
function
|
|
12655
|
+
function toConfigurationError12(filePath, error) {
|
|
12375
12656
|
if (error instanceof CliError) {
|
|
12376
12657
|
throw error;
|
|
12377
12658
|
}
|
|
@@ -12386,7 +12667,7 @@ function toConfigurationError11(filePath, error) {
|
|
|
12386
12667
|
function createTeamspaceApi(command, filePath) {
|
|
12387
12668
|
try {
|
|
12388
12669
|
const config = readRuntimeConfig(filePath);
|
|
12389
|
-
const runtime = resolveRuntimeContext(config,
|
|
12670
|
+
const runtime = resolveRuntimeContext(config, getGlobalOptions13(command));
|
|
12390
12671
|
if (!runtime.baseUrl) {
|
|
12391
12672
|
throw new CliError(
|
|
12392
12673
|
"configuration_error",
|
|
@@ -12404,10 +12685,10 @@ function createTeamspaceApi(command, filePath) {
|
|
|
12404
12685
|
readOnly: runtime.readOnly
|
|
12405
12686
|
};
|
|
12406
12687
|
} catch (error) {
|
|
12407
|
-
|
|
12688
|
+
toConfigurationError12(filePath, error);
|
|
12408
12689
|
}
|
|
12409
12690
|
}
|
|
12410
|
-
function
|
|
12691
|
+
function ensureWritable10(commandName, readOnly, commandMode) {
|
|
12411
12692
|
if (readOnly) {
|
|
12412
12693
|
throw new CliError(
|
|
12413
12694
|
"command_not_allowed_in_read_only_mode",
|
|
@@ -12419,17 +12700,17 @@ function ensureWritable9(commandName, readOnly, commandMode) {
|
|
|
12419
12700
|
);
|
|
12420
12701
|
}
|
|
12421
12702
|
}
|
|
12422
|
-
function
|
|
12703
|
+
function parseUuidOrSlugSelector11(input) {
|
|
12423
12704
|
try {
|
|
12424
12705
|
return normalizeUuidOrSlug(input);
|
|
12425
12706
|
} catch (error) {
|
|
12426
12707
|
const message = error instanceof Error ? error.message : "Invalid selector.";
|
|
12427
|
-
throw new
|
|
12708
|
+
throw new InvalidArgumentError11(message);
|
|
12428
12709
|
}
|
|
12429
12710
|
}
|
|
12430
12711
|
function parseNonNegativeInteger3(input) {
|
|
12431
12712
|
if (!/^\d+$/.test(input.trim())) {
|
|
12432
|
-
throw new
|
|
12713
|
+
throw new InvalidArgumentError11(`Expected a non-negative integer, received "${input}".`);
|
|
12433
12714
|
}
|
|
12434
12715
|
return Number(input);
|
|
12435
12716
|
}
|
|
@@ -12585,7 +12866,7 @@ async function resolveFolderSelector2(api, selector) {
|
|
|
12585
12866
|
}
|
|
12586
12867
|
function registerTeamspaceCommands(program, options = {}) {
|
|
12587
12868
|
const filePath = options.configPath ?? defaultConfigPath;
|
|
12588
|
-
const stdout =
|
|
12869
|
+
const stdout = getCommandIo13(options.stdout);
|
|
12589
12870
|
const teamspace = program.command("teamspace").description("Manage teamspace folders and resources");
|
|
12590
12871
|
const folders = teamspace.command("folders").description("Manage teamspace folders");
|
|
12591
12872
|
folders.command("list").description("List teamspace folders").option("--include-resources", "include the published resources inside each folder").action(async function action(commandOptions) {
|
|
@@ -12597,7 +12878,7 @@ function registerTeamspaceCommands(program, options = {}) {
|
|
|
12597
12878
|
}
|
|
12598
12879
|
emitTable5(stdout, data);
|
|
12599
12880
|
});
|
|
12600
|
-
folders.command("get").description("Get a teamspace folder by exact name or UUID").argument("<folder>", "folder UUID or exact name",
|
|
12881
|
+
folders.command("get").description("Get a teamspace folder by exact name or UUID").argument("<folder>", "folder UUID or exact name", parseUuidOrSlugSelector11).option("--include-resources", "include the published resources inside each folder").action(async function action(folder, commandOptions) {
|
|
12601
12882
|
const { api, json } = createTeamspaceApi(this, filePath);
|
|
12602
12883
|
const resolvedFolder = await resolveFolderSelector2(api, folder);
|
|
12603
12884
|
const allFolders = await api.listFolders(Boolean(commandOptions.includeResources));
|
|
@@ -12610,46 +12891,46 @@ function registerTeamspaceCommands(program, options = {}) {
|
|
|
12610
12891
|
});
|
|
12611
12892
|
folders.command("create").description("Create a teamspace folder").requiredOption("--name <name>", "folder name").option("--order <n>", "display order (lower values appear first)", parseNonNegativeInteger3).option("--props <json>", 'additionalProperties JSON: free-form client metadata, e.g. {"icon":"folder-users","color":"gold"}').option("--props-file <path>", "path to a file with the additionalProperties JSON").action(async function action(commandOptions) {
|
|
12612
12893
|
const { api, json, readOnly } = createTeamspaceApi(this, filePath);
|
|
12613
|
-
|
|
12894
|
+
ensureWritable10("teamspace folders create", readOnly, "write");
|
|
12614
12895
|
const data = await api.createFolder(buildFolderCreateInput(commandOptions));
|
|
12615
12896
|
if (json) {
|
|
12616
12897
|
emitJson12(stdout, "teamspace folders create", data, filePath);
|
|
12617
12898
|
return;
|
|
12618
12899
|
}
|
|
12619
|
-
|
|
12900
|
+
writeLine13(stdout, `Created folder "${getFolderIdentifier(data)}".`);
|
|
12620
12901
|
});
|
|
12621
|
-
folders.command("update").description("Update a teamspace folder").argument("<folder>", "folder UUID or exact name",
|
|
12902
|
+
folders.command("update").description("Update a teamspace folder").argument("<folder>", "folder UUID or exact name", parseUuidOrSlugSelector11).option("--name <name>", "folder name").option("--order <n>", "display order (lower values appear first)", parseNonNegativeInteger3).option("--props <json>", 'additionalProperties JSON: free-form client metadata, e.g. {"icon":"folder-users","color":"gold"}').option("--props-file <path>", "path to a file with the additionalProperties JSON").action(async function action(folder, commandOptions) {
|
|
12622
12903
|
const { api, json, readOnly } = createTeamspaceApi(this, filePath);
|
|
12623
|
-
|
|
12904
|
+
ensureWritable10("teamspace folders update", readOnly, "write");
|
|
12624
12905
|
const resolvedFolder = await resolveFolderSelector2(api, folder);
|
|
12625
12906
|
const data = await api.updateFolder(resolvedFolder, buildFolderUpdateInput(commandOptions));
|
|
12626
12907
|
if (json) {
|
|
12627
12908
|
emitJson12(stdout, "teamspace folders update", data, filePath);
|
|
12628
12909
|
return;
|
|
12629
12910
|
}
|
|
12630
|
-
|
|
12911
|
+
writeLine13(stdout, `Updated folder "${getFolderIdentifier(data)}".`);
|
|
12631
12912
|
});
|
|
12632
|
-
folders.command("delete").description("Delete a teamspace folder").argument("<folder>", "folder UUID or exact name",
|
|
12913
|
+
folders.command("delete").description("Delete a teamspace folder").argument("<folder>", "folder UUID or exact name", parseUuidOrSlugSelector11).action(async function action(folder) {
|
|
12633
12914
|
const { api, json, readOnly } = createTeamspaceApi(this, filePath);
|
|
12634
|
-
|
|
12915
|
+
ensureWritable10("teamspace folders delete", readOnly, "destructive");
|
|
12635
12916
|
const resolvedFolder = await resolveFolderSelector2(api, folder);
|
|
12636
12917
|
const data = await api.deleteFolder(resolvedFolder);
|
|
12637
12918
|
if (json) {
|
|
12638
12919
|
emitJson12(stdout, "teamspace folders delete", data, filePath);
|
|
12639
12920
|
return;
|
|
12640
12921
|
}
|
|
12641
|
-
|
|
12922
|
+
writeLine13(stdout, `Deleted folder "${resolvedFolder.value}".`);
|
|
12642
12923
|
});
|
|
12643
12924
|
const resources = teamspace.command("resources").description("Manage teamspace resources");
|
|
12644
12925
|
resources.command("publish").description(
|
|
12645
12926
|
"Publish a resource to a teamspace folder. Publishing an already-published resource moves it to the new folder."
|
|
12646
|
-
).argument("<resource>", "schema UUID, schema slug, or display UUID",
|
|
12927
|
+
).argument("<resource>", "schema UUID, schema slug, or display UUID", parseUuidOrSlugSelector11).requiredOption(
|
|
12647
12928
|
"--to <folder>",
|
|
12648
12929
|
"target folder UUID or exact name (root folder UUID is 00000000-0000-0000-0000-000000000000)",
|
|
12649
|
-
|
|
12930
|
+
parseUuidOrSlugSelector11
|
|
12650
12931
|
).action(async function action(resource, commandOptions) {
|
|
12651
12932
|
const { api, json, readOnly } = createTeamspaceApi(this, filePath);
|
|
12652
|
-
|
|
12933
|
+
ensureWritable10("teamspace resources publish", readOnly, "write");
|
|
12653
12934
|
const folder = await resolveFolderSelector2(api, commandOptions.to);
|
|
12654
12935
|
const data = await api.publishResource({
|
|
12655
12936
|
resourceId: resource.value,
|
|
@@ -12659,17 +12940,17 @@ function registerTeamspaceCommands(program, options = {}) {
|
|
|
12659
12940
|
emitJson12(stdout, "teamspace resources publish", data, filePath);
|
|
12660
12941
|
return;
|
|
12661
12942
|
}
|
|
12662
|
-
|
|
12943
|
+
writeLine13(stdout, `Published resource "${resource.value}" to folder "${folder.value}".`);
|
|
12663
12944
|
});
|
|
12664
|
-
resources.command("unpublish").description("Unpublish a resource from teamspace (removes it from its shared folder)").argument("<resource>", "schema UUID, schema slug, or display UUID",
|
|
12945
|
+
resources.command("unpublish").description("Unpublish a resource from teamspace (removes it from its shared folder)").argument("<resource>", "schema UUID, schema slug, or display UUID", parseUuidOrSlugSelector11).action(async function action(resource) {
|
|
12665
12946
|
const { api, json, readOnly } = createTeamspaceApi(this, filePath);
|
|
12666
|
-
|
|
12947
|
+
ensureWritable10("teamspace resources unpublish", readOnly, "write");
|
|
12667
12948
|
const data = await api.unpublishResource(resource.value);
|
|
12668
12949
|
if (json) {
|
|
12669
12950
|
emitJson12(stdout, "teamspace resources unpublish", data, filePath);
|
|
12670
12951
|
return;
|
|
12671
12952
|
}
|
|
12672
|
-
|
|
12953
|
+
writeLine13(stdout, `Unpublished resource "${resource.value}".`);
|
|
12673
12954
|
});
|
|
12674
12955
|
}
|
|
12675
12956
|
|
|
@@ -12677,7 +12958,7 @@ function registerTeamspaceCommands(program, options = {}) {
|
|
|
12677
12958
|
var require2 = createRequire(import.meta.url);
|
|
12678
12959
|
var { version } = require2("../package.json");
|
|
12679
12960
|
function buildProgram(options = {}) {
|
|
12680
|
-
const program = new
|
|
12961
|
+
const program = new Command12();
|
|
12681
12962
|
program.name("zinkee").description("CLI for Zinkee API v2").version(version).enablePositionalOptions().showHelpAfterError().option("--profile <name>", "select a profile from config").option("--base-url <url>", "override the configured base URL").option("--api-key <token>", "override the configured API key").option("--read-only", "run in read-only mode").option("--example", "show examples for a command").option("--json", "emit JSON output").option("--install-completion [shell]", "install shell completion (bash, zsh, fish, powershell)").option("--show-completion [shell]", "print shell completion script for the current shell");
|
|
12682
12963
|
registerProfilesCommands(program, options);
|
|
12683
12964
|
registerAutomationsCommands(program, options);
|
|
@@ -12685,6 +12966,7 @@ function buildProgram(options = {}) {
|
|
|
12685
12966
|
registerDisplaysCommands(program, options);
|
|
12686
12967
|
registerDocumentTemplatesCommands(program, options);
|
|
12687
12968
|
registerFilesCommands(program, options);
|
|
12969
|
+
registerFormulasCommands(program, options);
|
|
12688
12970
|
registerNavigationCommands(program, options);
|
|
12689
12971
|
registerSchemasCommands(program, options);
|
|
12690
12972
|
registerRecordsCommands(program, options);
|