@artis-lab/cli 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -11
- package/package.json +5 -3
- package/src/bin.js +7 -6
- package/src/index.js +17 -8
- package/src/lib/{chunk-WQDTNA6L.js → chunk-H32QAUSA.js} +1 -1
- package/src/lib/{chunk-Q4UVVKZI.js → chunk-KY47KP5E.js} +4 -4
- package/src/lib/{chunk-MX2ASLZR.js → chunk-OBEJTKCR.js} +13 -9
- package/src/lib/chunk-QDQQASRY.js +117 -0
- package/src/lib/chunk-YAZGW7Y4.js +10781 -0
- package/src/lib/{chunk-AEVC3USN.js → chunk-YXGHBN47.js} +854 -139
- package/src/lib/cli.d.ts +46 -3
- package/src/lib/cli.js +17 -8
- package/src/lib/exit-codes.js +1 -1
- package/src/lib/files.d.ts +19 -0
- package/src/lib/files.js +13 -0
- package/src/lib/revision-bases.d.ts +2 -3
- package/src/lib/revision-bases.js +1 -1
- package/src/lib/skill-install.d.ts +1 -1
- package/src/lib/skill-install.js +1 -1
- package/src/lib/verify.d.ts +83 -4
- package/src/lib/verify.js +15 -1
- package/src/lib/chunk-IKP5TJZP.js +0 -362
|
@@ -1,21 +1,35 @@
|
|
|
1
|
+
import {
|
|
2
|
+
installSkillFromCli
|
|
3
|
+
} from "./chunk-OBEJTKCR.js";
|
|
1
4
|
import {
|
|
2
5
|
VerifyUnavailableError,
|
|
6
|
+
composeSlidesFiles,
|
|
3
7
|
formatVerifyReport,
|
|
4
|
-
verifyHtml
|
|
5
|
-
|
|
8
|
+
verifyHtml,
|
|
9
|
+
verifyTypes
|
|
10
|
+
} from "./chunk-YAZGW7Y4.js";
|
|
6
11
|
import {
|
|
7
12
|
artisCliVersion
|
|
8
13
|
} from "./chunk-IZYFOV2K.js";
|
|
14
|
+
import {
|
|
15
|
+
hasFlag,
|
|
16
|
+
parseFlagValue
|
|
17
|
+
} from "./chunk-U3ZF6SRR.js";
|
|
18
|
+
import {
|
|
19
|
+
changedFiles,
|
|
20
|
+
readFilesDir,
|
|
21
|
+
writeFilesDir
|
|
22
|
+
} from "./chunk-QDQQASRY.js";
|
|
9
23
|
import {
|
|
10
24
|
CliError,
|
|
11
25
|
exitCodeForResponse,
|
|
12
26
|
exitCodes,
|
|
13
27
|
usageError
|
|
14
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-H32QAUSA.js";
|
|
15
29
|
import {
|
|
16
30
|
getRememberedBase,
|
|
17
31
|
rememberBase
|
|
18
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-KY47KP5E.js";
|
|
19
33
|
import {
|
|
20
34
|
ARTIS_DEFAULT_HOST,
|
|
21
35
|
findProfileForHost,
|
|
@@ -24,14 +38,6 @@ import {
|
|
|
24
38
|
readCliConfig,
|
|
25
39
|
saveDefaultProfile
|
|
26
40
|
} from "./chunk-QNS7GLAA.js";
|
|
27
|
-
import {
|
|
28
|
-
installSkillFromCli
|
|
29
|
-
} from "./chunk-MX2ASLZR.js";
|
|
30
|
-
import {
|
|
31
|
-
collectFlagValues,
|
|
32
|
-
hasFlag,
|
|
33
|
-
parseFlagValue
|
|
34
|
-
} from "./chunk-U3ZF6SRR.js";
|
|
35
41
|
|
|
36
42
|
// packages/cli/src/lib/cli.ts
|
|
37
43
|
import { spawn } from "node:child_process";
|
|
@@ -155,6 +161,11 @@ function annotationIdFromIri(iri) {
|
|
|
155
161
|
return iri.replace(/\/+$/, "").split("/").pop() ?? iri;
|
|
156
162
|
}
|
|
157
163
|
|
|
164
|
+
// packages/sdk/src/lib/agent-handoff.ts
|
|
165
|
+
function isReviewClosed(status) {
|
|
166
|
+
return status === "resolved";
|
|
167
|
+
}
|
|
168
|
+
|
|
158
169
|
// packages/sdk/src/lib/sdk.ts
|
|
159
170
|
var artifactShareRoles = [
|
|
160
171
|
"viewer",
|
|
@@ -163,16 +174,6 @@ var artifactShareRoles = [
|
|
|
163
174
|
"editor"
|
|
164
175
|
];
|
|
165
176
|
var artifactListLimits = { default: 50, max: 100 };
|
|
166
|
-
var artifactKinds = [
|
|
167
|
-
"incident-timeline",
|
|
168
|
-
"migration-plan",
|
|
169
|
-
"generated-dashboard",
|
|
170
|
-
"architecture-explainer",
|
|
171
|
-
"animated-report",
|
|
172
|
-
"ui-prototype",
|
|
173
|
-
"pr-review",
|
|
174
|
-
"custom-html"
|
|
175
|
-
];
|
|
176
177
|
function formatRevisionConflictMessage(message, details) {
|
|
177
178
|
if (!details?.currentRevisionId) {
|
|
178
179
|
return message;
|
|
@@ -188,9 +189,112 @@ function revisionSummaryLines(summary) {
|
|
|
188
189
|
return summary.split(/\r?\n/).map((line) => line.replace(/^\s*(?:[-*•]\s+)?/, "").trim()).filter(Boolean);
|
|
189
190
|
}
|
|
190
191
|
|
|
191
|
-
// packages/sdk/src/lib/
|
|
192
|
-
var
|
|
193
|
-
|
|
192
|
+
// packages/sdk/src/lib/page-storage.ts
|
|
193
|
+
var storageLimits = {
|
|
194
|
+
/** One document, serialized as UTF-8 JSON. */
|
|
195
|
+
maxDocBytes: 256 * 1024,
|
|
196
|
+
/** A document on a `{viewer}` path, unless its rule raises `maxBytes`. */
|
|
197
|
+
maxViewerDocBytes: 16 * 1024,
|
|
198
|
+
maxDepth: 32,
|
|
199
|
+
maxPathBytes: 512,
|
|
200
|
+
maxSegments: 16,
|
|
201
|
+
maxSegmentBytes: 128,
|
|
202
|
+
maxArtifactDocuments: 25e3,
|
|
203
|
+
maxArtifactBytes: 16 * 1024 * 1024,
|
|
204
|
+
maxOwnerBytes: 256 * 1024 * 1024,
|
|
205
|
+
maxRules: 64,
|
|
206
|
+
maxBatchOps: 50,
|
|
207
|
+
/** Sum of the serialized values and patches in one batch. */
|
|
208
|
+
maxBatchBytes: 1024 * 1024,
|
|
209
|
+
maxListLimit: 1e3,
|
|
210
|
+
idempotencyTtlMs: 24 * 60 * 60 * 1e3
|
|
211
|
+
};
|
|
212
|
+
var encoder = new TextEncoder();
|
|
213
|
+
var storageOnlyCodes = /* @__PURE__ */ new Set([
|
|
214
|
+
"version_conflict",
|
|
215
|
+
"storage_not_declared",
|
|
216
|
+
"rules_changed",
|
|
217
|
+
"revision_stale",
|
|
218
|
+
"quota_exceeded",
|
|
219
|
+
"too_large",
|
|
220
|
+
"invalid_path",
|
|
221
|
+
"invalid_value",
|
|
222
|
+
"idempotency_in_progress",
|
|
223
|
+
"idempotency_key_used",
|
|
224
|
+
"idempotency_key_reused"
|
|
225
|
+
]);
|
|
226
|
+
function formatStorageErrorMessage(message, body) {
|
|
227
|
+
if (!body) return message;
|
|
228
|
+
const storageCode = typeof body["code"] === "string" && storageOnlyCodes.has(body["code"]);
|
|
229
|
+
const details = [];
|
|
230
|
+
if (typeof body["code"] === "string") details.push(`code ${body["code"]}`);
|
|
231
|
+
if (typeof body["index"] === "number")
|
|
232
|
+
details.push(`write #${body["index"]}`);
|
|
233
|
+
if (typeof body["path"] === "string") details.push(`path ${body["path"]}`);
|
|
234
|
+
if (body["current"]) {
|
|
235
|
+
details.push(`current ${JSON.stringify(body["current"])}`);
|
|
236
|
+
}
|
|
237
|
+
if (body["quota"]) details.push(`quota ${JSON.stringify(body["quota"])}`);
|
|
238
|
+
return storageCode || details.length > 1 ? `${message} (${details.join("; ")})` : message;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// packages/sdk/src/lib/ids.ts
|
|
242
|
+
var UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
243
|
+
function isUuid(value) {
|
|
244
|
+
return typeof value === "string" && UUID_PATTERN.test(value);
|
|
245
|
+
}
|
|
246
|
+
var BASE62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
247
|
+
var SHORT_ID_LENGTH = 22;
|
|
248
|
+
function artifactShortId(id) {
|
|
249
|
+
if (!isUuid(id)) throw new Error(`Not a uuid: ${id}`);
|
|
250
|
+
const hex = id.replace(/-/g, "");
|
|
251
|
+
const bytes = [];
|
|
252
|
+
for (let i = 0; i < 32; i += 2) bytes.push(parseInt(hex.slice(i, i + 2), 16));
|
|
253
|
+
let out = "";
|
|
254
|
+
for (let digit = 0; digit < SHORT_ID_LENGTH; digit += 1) {
|
|
255
|
+
let remainder = 0;
|
|
256
|
+
for (let i = 0; i < bytes.length; i += 1) {
|
|
257
|
+
const value = remainder * 256 + bytes[i];
|
|
258
|
+
bytes[i] = Math.floor(value / 62);
|
|
259
|
+
remainder = value % 62;
|
|
260
|
+
}
|
|
261
|
+
out = BASE62[remainder] + out;
|
|
262
|
+
}
|
|
263
|
+
return out;
|
|
264
|
+
}
|
|
265
|
+
function artifactIdFromShortId(value) {
|
|
266
|
+
if (value.length !== SHORT_ID_LENGTH) return void 0;
|
|
267
|
+
const bytes = new Array(16).fill(0);
|
|
268
|
+
for (const char of value) {
|
|
269
|
+
const digit = BASE62.indexOf(char);
|
|
270
|
+
if (digit < 0) return void 0;
|
|
271
|
+
let carry = digit;
|
|
272
|
+
for (let i = 15; i >= 0; i -= 1) {
|
|
273
|
+
const next = bytes[i] * 62 + carry;
|
|
274
|
+
bytes[i] = next % 256;
|
|
275
|
+
carry = Math.floor(next / 256);
|
|
276
|
+
}
|
|
277
|
+
if (carry !== 0) return void 0;
|
|
278
|
+
}
|
|
279
|
+
const hex = bytes.map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
280
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
281
|
+
}
|
|
282
|
+
function artifactIdFromReference(reference) {
|
|
283
|
+
const value = reference.trim();
|
|
284
|
+
if (isUuid(value)) return value;
|
|
285
|
+
const short = artifactIdFromShortId(value);
|
|
286
|
+
if (short) return short;
|
|
287
|
+
let url;
|
|
288
|
+
try {
|
|
289
|
+
url = new URL(value);
|
|
290
|
+
} catch {
|
|
291
|
+
return void 0;
|
|
292
|
+
}
|
|
293
|
+
const page = /^\/a\/([0-9A-Za-z]+)\/?$/.exec(url.pathname);
|
|
294
|
+
if (page) return artifactIdFromShortId(page[1]);
|
|
295
|
+
const label = url.hostname.split(".")[0];
|
|
296
|
+
return isUuid(label) ? label : void 0;
|
|
297
|
+
}
|
|
194
298
|
|
|
195
299
|
// packages/cli/src/lib/cli.ts
|
|
196
300
|
function isRootAnnotation(annotation) {
|
|
@@ -207,6 +311,7 @@ var commands = [
|
|
|
207
311
|
"annotate",
|
|
208
312
|
"annotation",
|
|
209
313
|
"artifact",
|
|
314
|
+
"data",
|
|
210
315
|
"guidelines",
|
|
211
316
|
"help",
|
|
212
317
|
"install-skill",
|
|
@@ -215,18 +320,24 @@ var commands = [
|
|
|
215
320
|
"reply",
|
|
216
321
|
"revise",
|
|
217
322
|
"share",
|
|
323
|
+
"types",
|
|
218
324
|
"version",
|
|
219
325
|
"watch",
|
|
220
326
|
"whoami"
|
|
221
327
|
];
|
|
222
328
|
var cliVisibilityOptions = ["public", "unlisted", "private"];
|
|
223
|
-
var cliAnnotationStatusOptions = [
|
|
224
|
-
"open",
|
|
225
|
-
"needs-revision",
|
|
226
|
-
"resolved"
|
|
227
|
-
];
|
|
329
|
+
var cliAnnotationStatusOptions = ["open", "resolved"];
|
|
228
330
|
var valueFlags = /* @__PURE__ */ new Set([
|
|
331
|
+
"--after",
|
|
229
332
|
"--api-key",
|
|
333
|
+
"--as-role",
|
|
334
|
+
"--depth",
|
|
335
|
+
"--idempotency-key",
|
|
336
|
+
"--if-match",
|
|
337
|
+
"--ops",
|
|
338
|
+
"--order",
|
|
339
|
+
"--patch",
|
|
340
|
+
"--value",
|
|
230
341
|
"--author",
|
|
231
342
|
"--comment",
|
|
232
343
|
"--css",
|
|
@@ -236,6 +347,8 @@ var valueFlags = /* @__PURE__ */ new Set([
|
|
|
236
347
|
"--email",
|
|
237
348
|
"--harness",
|
|
238
349
|
"--host",
|
|
350
|
+
// Removed (ADR 0015); still a value flag so its value is not read as a
|
|
351
|
+
// positional before rejectRemovedKindFlag() refuses it.
|
|
239
352
|
"--kind",
|
|
240
353
|
"--limit",
|
|
241
354
|
"--output",
|
|
@@ -246,9 +359,12 @@ var valueFlags = /* @__PURE__ */ new Set([
|
|
|
246
359
|
"--query",
|
|
247
360
|
"--rect",
|
|
248
361
|
"--requested-change",
|
|
362
|
+
// Removed; still a value flag so its value is not read as a positional
|
|
363
|
+
// before rejectRemovedResolveFlag() refuses it.
|
|
249
364
|
"--resolve",
|
|
250
365
|
"--revision",
|
|
251
366
|
"--role",
|
|
367
|
+
"--root",
|
|
252
368
|
"--since",
|
|
253
369
|
"--status",
|
|
254
370
|
"--base",
|
|
@@ -260,6 +376,7 @@ var valueFlags = /* @__PURE__ */ new Set([
|
|
|
260
376
|
"--text-start",
|
|
261
377
|
"--timeout",
|
|
262
378
|
"--title",
|
|
379
|
+
"--type",
|
|
263
380
|
"--types",
|
|
264
381
|
"--url",
|
|
265
382
|
"--visibility"
|
|
@@ -332,13 +449,17 @@ function parseContractFlag(value) {
|
|
|
332
449
|
`Invalid --contract "${value}". Expected a version number or latest.`
|
|
333
450
|
);
|
|
334
451
|
}
|
|
335
|
-
function
|
|
336
|
-
if (
|
|
337
|
-
return
|
|
452
|
+
function parseTypeFlag(value) {
|
|
453
|
+
if (value === void 0) {
|
|
454
|
+
return void 0;
|
|
338
455
|
}
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
456
|
+
if (!value.trim()) {
|
|
457
|
+
throw usageError("--type must name a type, e.g. slides.");
|
|
458
|
+
}
|
|
459
|
+
return value.trim();
|
|
460
|
+
}
|
|
461
|
+
function describeType(declaration) {
|
|
462
|
+
return declaration.type && declaration.type !== "html" ? `${declaration.type} (format ${declaration.typeFormat})` : void 0;
|
|
342
463
|
}
|
|
343
464
|
function parseAnnotationStatus(value) {
|
|
344
465
|
if (cliAnnotationStatusOptions.includes(value)) {
|
|
@@ -467,10 +588,31 @@ async function guidelinesFromCli(args) {
|
|
|
467
588
|
process.stdout.write(text.endsWith("\n") ? text : `${text}
|
|
468
589
|
`);
|
|
469
590
|
}
|
|
591
|
+
function rejectRemovedKindFlag(args) {
|
|
592
|
+
if (args.includes("--kind")) {
|
|
593
|
+
throw usageError(
|
|
594
|
+
"--kind was removed: artifacts no longer have a kind. Use --type for the type an artifact is written in (html by default), or tags to group artifacts."
|
|
595
|
+
);
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
function rejectRemovedResolveFlag(args) {
|
|
599
|
+
if (args.includes("--resolve")) {
|
|
600
|
+
throw usageError(
|
|
601
|
+
'--resolve was removed: a revision no longer changes review status. Reply in each thread you addressed with "artis reply"; the reviewers resolve it.'
|
|
602
|
+
);
|
|
603
|
+
}
|
|
604
|
+
}
|
|
470
605
|
async function parsePublishOptions(args) {
|
|
606
|
+
rejectRemovedKindFlag(args);
|
|
471
607
|
const [filePath] = getPositionals(args);
|
|
472
|
-
|
|
473
|
-
|
|
608
|
+
const root = parseFlagValue(args, "--root");
|
|
609
|
+
if (!filePath && !root) {
|
|
610
|
+
throw usageError(
|
|
611
|
+
"Missing artifact HTML file path (or --root <dir> for a typed artifact made of files)."
|
|
612
|
+
);
|
|
613
|
+
}
|
|
614
|
+
if (filePath && root) {
|
|
615
|
+
throw usageError("Pass an HTML file or --root <dir>, not both.");
|
|
474
616
|
}
|
|
475
617
|
const credentials = await resolveCredentials(args);
|
|
476
618
|
const visibility = parseVisibility(
|
|
@@ -478,17 +620,18 @@ async function parsePublishOptions(args) {
|
|
|
478
620
|
);
|
|
479
621
|
return {
|
|
480
622
|
filePath,
|
|
623
|
+
root,
|
|
481
624
|
apiKey: credentials.apiKey,
|
|
482
625
|
baseUrl: credentials.baseUrl,
|
|
483
626
|
title: parseFlagValue(args, "--title"),
|
|
484
627
|
description: parseFlagValue(args, "--description") ?? "Published from Artis CLI.",
|
|
485
628
|
visibility,
|
|
486
629
|
authorName: parseFlagValue(args, "--author") ?? "Artis CLI",
|
|
487
|
-
kind: parseKind(parseFlagValue(args, "--kind") ?? "custom-html"),
|
|
488
630
|
capabilities: await parseCapabilitiesFlag(
|
|
489
631
|
parseFlagValue(args, "--capabilities")
|
|
490
632
|
),
|
|
491
633
|
contract: parseContractFlag(parseFlagValue(args, "--contract")),
|
|
634
|
+
type: parseTypeFlag(parseFlagValue(args, "--type")),
|
|
492
635
|
json: hasFlag(args, "--json")
|
|
493
636
|
};
|
|
494
637
|
}
|
|
@@ -496,7 +639,10 @@ function cliErrorOf(error) {
|
|
|
496
639
|
if (!(error instanceof ApiError)) {
|
|
497
640
|
return error;
|
|
498
641
|
}
|
|
499
|
-
let message =
|
|
642
|
+
let message = formatStorageErrorMessage(
|
|
643
|
+
formatRevisionConflictMessage(error.message, error.body),
|
|
644
|
+
error.body
|
|
645
|
+
);
|
|
500
646
|
if (error.status === 429 && error.retryAfter) {
|
|
501
647
|
message += ` Retry after ${error.retryAfter} s.`;
|
|
502
648
|
}
|
|
@@ -592,22 +738,34 @@ Usage:
|
|
|
592
738
|
artis login [--host <url>]
|
|
593
739
|
artis whoami [--host <url>]
|
|
594
740
|
artis guidelines [section] [--contract <n|latest>] [--host <url>]
|
|
741
|
+
artis types [name [reference]] [--json] [--host <url>]
|
|
595
742
|
artis install-skill [--harness <id>]... [--yes] [--dir <path>] [--force] [--list] [--json]
|
|
596
743
|
artis publish artifact.html [options]
|
|
597
|
-
artis
|
|
598
|
-
artis artifact
|
|
599
|
-
artis artifact
|
|
600
|
-
artis artifact
|
|
601
|
-
artis artifact
|
|
602
|
-
artis artifact
|
|
603
|
-
artis
|
|
604
|
-
artis
|
|
605
|
-
artis
|
|
606
|
-
artis
|
|
744
|
+
artis publish --root <dir> --type <type> [options]
|
|
745
|
+
artis artifact get <artifact> [--json]
|
|
746
|
+
artis artifact html <artifact> [--output <path>] [--revision <revision-id>] [--json]
|
|
747
|
+
artis artifact files <artifact> [path] [--output <dir>] [--revision <revision-id>] [--json]
|
|
748
|
+
artis artifact feedback <artifact> [--json] [--revision <revision-id>]
|
|
749
|
+
artis artifact list [--query <text>] [--tag <tag>] [--type <type>] [--limit <n>] [--cursor <cursor>] [--json]
|
|
750
|
+
artis artifact visibility <artifact> <public|unlisted|private> [--json]
|
|
751
|
+
artis artifact delete <artifact> --yes
|
|
752
|
+
artis verify <artifact.html | artifact> [--type slides] [--revision <revision-id>] [--json]
|
|
753
|
+
artis verify --root <dir> --type slides [--json]
|
|
754
|
+
artis share <artifact> [--email <email> --role <viewer|commenter|contributor|editor>] [--remove]
|
|
755
|
+
artis revise <artifact> (artifact.html | --root <dir>) --summary <text> [--base <revision-id>] [--capabilities <json|file>] [--contract <n|latest>] [--type <type>]
|
|
756
|
+
artis annotate <artifact> --comment <text> [anchor options]
|
|
607
757
|
artis reply <annotation-id> --comment <text>
|
|
608
758
|
artis annotation edit <annotation-id> [--comment <text>] [--title <text>] [--requested-change <text>]
|
|
609
759
|
artis annotation retract <annotation-id>
|
|
610
|
-
artis watch <artifact
|
|
760
|
+
artis watch <artifact> [--since <cursor>] [--once] [--timeout <duration>] [--include-self] [--types <families>]
|
|
761
|
+
artis data get <artifact> <path> [--as-role <role>]
|
|
762
|
+
artis data list <artifact> [prefix] [--depth children|all] [--order path|created] [--limit <n>] [--after <next>] [--as-role <role>]
|
|
763
|
+
artis data set <artifact> <path> --value <json|file|-> [--if-match <id>@<version> | --if-absent] [--idempotency-key <key>]
|
|
764
|
+
artis data update <artifact> <path> --patch <json|file|-> [--if-match <id>@<version> | --if-absent] [--idempotency-key <key>]
|
|
765
|
+
artis data delete <artifact> <path> [--if-match <id>@<version>] [--idempotency-key <key>]
|
|
766
|
+
artis data batch <artifact> --ops <json|file|-> [--idempotency-key <key>]
|
|
767
|
+
artis data export <artifact> [--output <path>] [--as-role <role>]
|
|
768
|
+
artis data usage <artifact>
|
|
611
769
|
|
|
612
770
|
Options:
|
|
613
771
|
--api-key <key> API key. Defaults to ARTIS_API_KEY or ~/.artis/config.json. Run "artis login" to obtain one.
|
|
@@ -615,16 +773,15 @@ Options:
|
|
|
615
773
|
--title <title> Artifact title. Defaults to the file name.
|
|
616
774
|
--description <text> Artifact description.
|
|
617
775
|
--visibility <value> public, unlisted, or private. Defaults to unlisted.
|
|
618
|
-
--
|
|
776
|
+
--type <type> The type the artifact is created with, e.g. slides (publish, revise, verify; artifact list keeps your artifacts of that type). It is fixed at publish: revise keeps it, and may only repeat it. Verify of a published artifact reads it from the revision.
|
|
619
777
|
--author <name> Artifact author/agent name. Defaults to Artis CLI.
|
|
620
778
|
--summary <text> Revision summary. Write one change per line; they render as a list.
|
|
621
779
|
--base <revision-id> Revision the file was edited from. Defaults to the revision this machine last published, read (artifact html), or revised. Refuses the revise if someone revised since.
|
|
622
|
-
--resolve <annotation-id> Mark an annotation resolved when revising. Repeatable.
|
|
623
780
|
--capabilities <json|file> Page capabilities as a JSON object or JSON file (publish, revise). Revise keeps the previous set without it; '{}' clears it.
|
|
624
781
|
--contract <n|latest> Page contract version (publish, revise, guidelines). Publish defaults to latest; revise keeps the pinned version.
|
|
625
782
|
--comment <text> Annotation or reply comment text (annotate, reply).
|
|
626
783
|
--requested-change <text> Structured change request for the artifact author (annotate).
|
|
627
|
-
--status <value> Annotation status: open
|
|
784
|
+
--status <value> Annotation status: open or resolved. Defaults to open.
|
|
628
785
|
--quote <text> Exact artifact text to anchor to (annotate, TextQuoteSelector).
|
|
629
786
|
--quote-prefix <text> Text just before --quote, to disambiguate repeats.
|
|
630
787
|
--quote-suffix <text> Text just after --quote, to disambiguate repeats.
|
|
@@ -633,10 +790,11 @@ Options:
|
|
|
633
790
|
--text-end <n> Document offset where the quote ends (annotate, TextPositionSelector).
|
|
634
791
|
--rect <x,y,w,h> Canvas point/rect as percentages (annotate, FragmentSelector). w,h default to 0.
|
|
635
792
|
--pin-label <text> Short label shown on the artifact canvas pin (annotate).
|
|
636
|
-
--output <path> Write the artifact HTML to this file (artifact html). Without it, the document goes to stdout.
|
|
793
|
+
--output <path> Write the artifact HTML to this file (artifact html), or every file of a files revision under this directory (artifact files). Without it, the document goes to stdout.
|
|
794
|
+
--root <dir> A typed artifact made of files (ADR 0015): publish every file under the directory, or revise with the ones that differ from the base revision (removed files are removed); verify composes a slides deck from it. Dotfiles are skipped.
|
|
637
795
|
--revision <revision-id> Revision to read (artifact html, artifact feedback). Defaults to the current revision.
|
|
638
796
|
--query <text> Text to find in your artifacts' titles and descriptions (artifact list).
|
|
639
|
-
--tag <tag> Only your artifacts carrying this tag (artifact list).
|
|
797
|
+
--tag <tag> Only your artifacts carrying this tag (artifact list).
|
|
640
798
|
--limit <n> Artifacts per page, 1-100 (artifact list). Defaults to 50.
|
|
641
799
|
--cursor <cursor> Continue after the page that printed it (artifact list).
|
|
642
800
|
--email <email> Email address for artis share.
|
|
@@ -652,61 +810,85 @@ Options:
|
|
|
652
810
|
--timeout <duration> Give up after this long, e.g. 30s, 10m (watch). Exits 6 if nothing happened.
|
|
653
811
|
--include-self Also report events caused by this API key (watch).
|
|
654
812
|
--types <families> Only these event families, comma-separated: annotation, revision (watch). Defaults to all.
|
|
813
|
+
--value <json|file|-> The whole document, a JSON object: inline, a file, or - for stdin (data set).
|
|
814
|
+
--patch <json|file|-> A JSON object deep-merged into the document (data update).
|
|
815
|
+
--ops <json|file|-> Writes for data batch: [{"op":"set","path":"...","value":{...}}, ...] or {"ops":[...]}.
|
|
816
|
+
--if-match <id>@<version> Write only if this document is still at this version (data set, update, delete).
|
|
817
|
+
--if-absent Write only if nothing is at the path, a claim (data set, update).
|
|
818
|
+
--idempotency-key <key> Make a data write safe to retry: the same key and body within 24 h replays the first result.
|
|
819
|
+
--as-role <role> Read data as a lower role (viewer, commenter, contributor) to check your path rules.
|
|
820
|
+
--depth <children|all> data list: direct children only, or the whole subtree (default).
|
|
821
|
+
--order <path|created> data list order. Defaults to path.
|
|
822
|
+
--after <next> data list: continue after the page that printed this next.
|
|
655
823
|
--json Print machine-readable JSON for supported commands.
|
|
656
824
|
|
|
657
825
|
Exit codes:
|
|
658
|
-
0 success, 1 error, 2 usage, 3 auth, 4 not found, 5 revision
|
|
826
|
+
0 success, 1 error, 2 usage, 3 auth, 4 not found (data get: no document at the path), 5 conflict (a revision, or a data document's version: re-read, reapply, retry), 6 watch timeout, 7 rate limited, 8 verify found problems.
|
|
659
827
|
|
|
660
828
|
Examples (--host is optional; without it commands target https://artis.xiispace.eu.org):
|
|
661
829
|
artis publish report.html
|
|
662
830
|
artis login
|
|
663
831
|
artis publish report.html --host https://artis.example.com --visibility private
|
|
664
|
-
artis share
|
|
665
|
-
artis artifact get
|
|
666
|
-
artis artifact html
|
|
832
|
+
artis share 4kq9Zt2LmX8vRbP3nWc7Hy --host https://artis.example.com --email reviewer@example.com --role commenter
|
|
833
|
+
artis artifact get 4kq9Zt2LmX8vRbP3nWc7Hy --host https://artis.example.com --json
|
|
834
|
+
artis artifact html 4kq9Zt2LmX8vRbP3nWc7Hy --output report.html
|
|
667
835
|
artis verify report.html
|
|
668
|
-
artis
|
|
669
|
-
artis
|
|
836
|
+
artis verify deck.html --type slides
|
|
837
|
+
artis artifact feedback 4kq9Zt2LmX8vRbP3nWc7Hy --host https://artis.example.com --json
|
|
838
|
+
artis annotate 4kq9Zt2LmX8vRbP3nWc7Hy --host https://artis.example.com --comment "Tighten this heading" --quote "Checkout latency" --requested-change "Add the affected checkout count"
|
|
670
839
|
artis reply annotation-123 --host https://artis.example.com --comment "Addressed in the latest revision"
|
|
671
840
|
artis annotation edit annotation-123 --host https://artis.example.com --comment "Corrected: the latency spike is on checkout, not search"
|
|
672
841
|
artis annotation retract annotation-123 --host https://artis.example.com
|
|
673
|
-
artis watch
|
|
842
|
+
artis watch 4kq9Zt2LmX8vRbP3nWc7Hy --since 42
|
|
674
843
|
artis guidelines authoring
|
|
844
|
+
artis types slides
|
|
675
845
|
artis install-skill --yes
|
|
676
|
-
artis revise
|
|
846
|
+
artis revise 4kq9Zt2LmX8vRbP3nWc7Hy report.html --host https://artis.example.com --summary "Addressed open feedback" --base <revision-id>`;
|
|
677
847
|
}
|
|
678
848
|
async function publishArtifactFromCli(args) {
|
|
679
849
|
const options = await parsePublishOptions(args);
|
|
680
|
-
const
|
|
681
|
-
const
|
|
682
|
-
const
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
850
|
+
const credentials = { apiKey: options.apiKey, baseUrl: options.baseUrl };
|
|
851
|
+
const source = options.root ?? options.filePath ?? "";
|
|
852
|
+
const title = options.title ?? inferTitleFromPath(source);
|
|
853
|
+
const query = {
|
|
854
|
+
title,
|
|
855
|
+
description: options.description,
|
|
856
|
+
visibility: options.visibility,
|
|
857
|
+
authorName: options.authorName,
|
|
858
|
+
source: "cli",
|
|
859
|
+
capabilities: options.capabilities,
|
|
860
|
+
contract: options.contract,
|
|
861
|
+
type: options.type
|
|
862
|
+
};
|
|
863
|
+
let result;
|
|
864
|
+
if (options.root) {
|
|
865
|
+
if (!options.type || options.type === "html") {
|
|
866
|
+
throw usageError(
|
|
867
|
+
"--root publishes an artifact made of files: pass the type it is written in, e.g. --type slides. An html artifact is one HTML file."
|
|
868
|
+
);
|
|
697
869
|
}
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
870
|
+
const files = await readFilesDir(options.root);
|
|
871
|
+
({ result } = await apiCall(credentials, "POST /api/artifacts/files", {
|
|
872
|
+
query,
|
|
873
|
+
body: { files }
|
|
874
|
+
}));
|
|
875
|
+
} else {
|
|
876
|
+
const html = await readHtmlUpload(source, "Artifact file");
|
|
877
|
+
({ result } = await apiCall(credentials, "POST /api/artifacts", {
|
|
878
|
+
query,
|
|
879
|
+
body: html
|
|
880
|
+
}));
|
|
881
|
+
}
|
|
882
|
+
await rememberBase(options.baseUrl, [result.artifactId], result.revisionId);
|
|
704
883
|
return {
|
|
705
884
|
artifactId: result.artifactId,
|
|
706
885
|
revisionId: result.revisionId,
|
|
707
886
|
title,
|
|
708
887
|
url: buildArtifactUrl(options.baseUrl, result.url),
|
|
709
|
-
visibility: options.visibility
|
|
888
|
+
visibility: options.visibility,
|
|
889
|
+
// Absent from a server that predates types.
|
|
890
|
+
type: result.type ?? null,
|
|
891
|
+
typeFormat: result.typeFormat ?? null
|
|
710
892
|
};
|
|
711
893
|
}
|
|
712
894
|
async function loginFromCli(args) {
|
|
@@ -751,6 +933,70 @@ async function loginFromCli(args) {
|
|
|
751
933
|
}
|
|
752
934
|
throw new Error("Login expired. Run artis login again.");
|
|
753
935
|
}
|
|
936
|
+
async function typesFromCli(args) {
|
|
937
|
+
const [name, file] = getPositionals(args);
|
|
938
|
+
const config = await readCliConfig();
|
|
939
|
+
const baseUrl = resolveBaseUrl(args, config);
|
|
940
|
+
const json = hasFlag(args, "--json");
|
|
941
|
+
const call = async (key, ...input) => {
|
|
942
|
+
try {
|
|
943
|
+
return await apiClient({ baseUrl }).call(key, ...input);
|
|
944
|
+
} catch (error) {
|
|
945
|
+
throw cliErrorOf(error);
|
|
946
|
+
}
|
|
947
|
+
};
|
|
948
|
+
if (!name) {
|
|
949
|
+
const { types } = await call("GET /api/types");
|
|
950
|
+
if (json) {
|
|
951
|
+
console.log(JSON.stringify(types, null, 2));
|
|
952
|
+
return;
|
|
953
|
+
}
|
|
954
|
+
if (!types.length) {
|
|
955
|
+
console.log("No types are installed on this server.");
|
|
956
|
+
return;
|
|
957
|
+
}
|
|
958
|
+
for (const type2 of types) {
|
|
959
|
+
console.log(
|
|
960
|
+
`${type2.name} format ${type2.format} ${type2.release} ${type2.description}`
|
|
961
|
+
);
|
|
962
|
+
}
|
|
963
|
+
return;
|
|
964
|
+
}
|
|
965
|
+
if (file) {
|
|
966
|
+
const result = await call("GET /api/types/{name}/files/{path}", {
|
|
967
|
+
params: { name, path: file }
|
|
968
|
+
});
|
|
969
|
+
if (json) {
|
|
970
|
+
console.log(JSON.stringify(result, null, 2));
|
|
971
|
+
return;
|
|
972
|
+
}
|
|
973
|
+
process.stdout.write(
|
|
974
|
+
result.content.endsWith("\n") ? result.content : `${result.content}
|
|
975
|
+
`
|
|
976
|
+
);
|
|
977
|
+
return;
|
|
978
|
+
}
|
|
979
|
+
const { type } = await call("GET /api/types/{name}", { params: { name } });
|
|
980
|
+
if (json) {
|
|
981
|
+
console.log(JSON.stringify(type, null, 2));
|
|
982
|
+
return;
|
|
983
|
+
}
|
|
984
|
+
if (type.guidance) {
|
|
985
|
+
process.stdout.write(
|
|
986
|
+
type.guidance.endsWith("\n") ? type.guidance : `${type.guidance}
|
|
987
|
+
`
|
|
988
|
+
);
|
|
989
|
+
} else {
|
|
990
|
+
console.log(`${type.title}: ${type.description}`);
|
|
991
|
+
}
|
|
992
|
+
if (type.references.length) {
|
|
993
|
+
console.log(
|
|
994
|
+
`
|
|
995
|
+
References (artis types ${type.name} <path>):
|
|
996
|
+
${type.references.map((reference) => ` ${reference}`).join("\n")}`
|
|
997
|
+
);
|
|
998
|
+
}
|
|
999
|
+
}
|
|
754
1000
|
async function whoamiFromCli(args) {
|
|
755
1001
|
const credentials = await resolveCredentials(args);
|
|
756
1002
|
const result = await apiCall(credentials, "GET /api/me");
|
|
@@ -759,10 +1005,14 @@ async function whoamiFromCli(args) {
|
|
|
759
1005
|
);
|
|
760
1006
|
console.log(`Principal: ${result.principal.kind}`);
|
|
761
1007
|
}
|
|
1008
|
+
function artifactIdArg(value) {
|
|
1009
|
+
return artifactIdFromReference(value) ?? value;
|
|
1010
|
+
}
|
|
762
1011
|
async function getArtifactFromCli(args) {
|
|
763
|
-
const [
|
|
1012
|
+
const [artifactRef] = getPositionals(args);
|
|
1013
|
+
const artifactId = artifactRef && artifactIdArg(artifactRef);
|
|
764
1014
|
if (!artifactId) {
|
|
765
|
-
throw usageError("Missing artifact id or
|
|
1015
|
+
throw usageError("Missing artifact id or link.");
|
|
766
1016
|
}
|
|
767
1017
|
const target = await resolveOptionalTarget(args);
|
|
768
1018
|
const result = await apiCallOptional(
|
|
@@ -777,15 +1027,87 @@ async function getArtifactFromCli(args) {
|
|
|
777
1027
|
console.log(`${result.artifact.metadata.title}`);
|
|
778
1028
|
console.log(`Artifact: ${result.artifact.id}`);
|
|
779
1029
|
console.log(`Revision: ${result.artifact.currentRevisionId}`);
|
|
1030
|
+
const current = result.artifact.revisions.find(
|
|
1031
|
+
(revision) => revision.id === result.artifact.currentRevisionId
|
|
1032
|
+
);
|
|
1033
|
+
const currentType = current && describeType(current);
|
|
1034
|
+
if (currentType) {
|
|
1035
|
+
console.log(`Type: ${currentType}`);
|
|
1036
|
+
}
|
|
780
1037
|
console.log(
|
|
781
|
-
`Open annotations: ${result.annotations.filter((annotation) => isRootAnnotation(annotation) && annotation["artis:status"]
|
|
1038
|
+
`Open annotations: ${result.annotations.filter((annotation) => isRootAnnotation(annotation) && !isReviewClosed(annotation["artis:status"])).length}`
|
|
1039
|
+
);
|
|
1040
|
+
}
|
|
1041
|
+
async function getArtifactFilesFromCli(args) {
|
|
1042
|
+
const [artifactRef, filePath] = getPositionals(args);
|
|
1043
|
+
const artifactId = artifactRef && artifactIdArg(artifactRef);
|
|
1044
|
+
if (!artifactId) {
|
|
1045
|
+
throw usageError(
|
|
1046
|
+
"Usage: artis artifact files <artifact> [path] [--output <dir>] [--revision <revision-id>] [--json]"
|
|
1047
|
+
);
|
|
1048
|
+
}
|
|
1049
|
+
const target = await resolveOptionalTarget(args);
|
|
1050
|
+
const revisionId = parseFlagValue(args, "--revision");
|
|
1051
|
+
const json = hasFlag(args, "--json");
|
|
1052
|
+
if (filePath) {
|
|
1053
|
+
const file = await apiCallOptional(
|
|
1054
|
+
target,
|
|
1055
|
+
"GET /api/artifacts/{artifactId}/files/{path}",
|
|
1056
|
+
{ params: { artifactId, path: filePath }, query: { revisionId } }
|
|
1057
|
+
);
|
|
1058
|
+
if (json) {
|
|
1059
|
+
console.log(JSON.stringify(file, null, 2));
|
|
1060
|
+
return;
|
|
1061
|
+
}
|
|
1062
|
+
process.stdout.write(
|
|
1063
|
+
file.content.endsWith("\n") ? file.content : `${file.content}
|
|
1064
|
+
`
|
|
1065
|
+
);
|
|
1066
|
+
return;
|
|
1067
|
+
}
|
|
1068
|
+
const listed = await apiCallOptional(
|
|
1069
|
+
target,
|
|
1070
|
+
"GET /api/artifacts/{artifactId}/files",
|
|
1071
|
+
{ params: { artifactId }, query: { revisionId } }
|
|
1072
|
+
);
|
|
1073
|
+
const output = parseFlagValue(args, "--output");
|
|
1074
|
+
if (output) {
|
|
1075
|
+
const files = [];
|
|
1076
|
+
for (const file of listed.files) {
|
|
1077
|
+
const read = await apiCallOptional(
|
|
1078
|
+
target,
|
|
1079
|
+
"GET /api/artifacts/{artifactId}/files/{path}",
|
|
1080
|
+
{
|
|
1081
|
+
params: { artifactId, path: file.path },
|
|
1082
|
+
query: { revisionId: listed.revisionId }
|
|
1083
|
+
}
|
|
1084
|
+
);
|
|
1085
|
+
files.push({ path: file.path, content: read.content });
|
|
1086
|
+
}
|
|
1087
|
+
await writeFilesDir(output, files);
|
|
1088
|
+
await rememberBase(
|
|
1089
|
+
target.baseUrl,
|
|
1090
|
+
[artifactId, listed.artifactId],
|
|
1091
|
+
listed.revisionId
|
|
1092
|
+
);
|
|
1093
|
+
}
|
|
1094
|
+
if (json) {
|
|
1095
|
+
console.log(JSON.stringify(listed, null, 2));
|
|
1096
|
+
return;
|
|
1097
|
+
}
|
|
1098
|
+
for (const file of listed.files) {
|
|
1099
|
+
console.log(`${file.path} ${file.size}`);
|
|
1100
|
+
}
|
|
1101
|
+
console.log(
|
|
1102
|
+
output ? `Wrote ${listed.files.length} files of revision ${listed.revisionId} (v${listed.version}) to ${output}.` : `Revision ${listed.revisionId} (v${listed.version})${listed.isLatest ? "" : ", not the latest"}.`
|
|
782
1103
|
);
|
|
783
1104
|
}
|
|
784
1105
|
async function getArtifactHtmlFromCli(args) {
|
|
785
|
-
const [
|
|
1106
|
+
const [artifactRef] = getPositionals(args);
|
|
1107
|
+
const artifactId = artifactRef && artifactIdArg(artifactRef);
|
|
786
1108
|
if (!artifactId) {
|
|
787
1109
|
throw usageError(
|
|
788
|
-
"Usage: artis artifact html <artifact
|
|
1110
|
+
"Usage: artis artifact html <artifact> [--output <path>] [--revision <revision-id>]"
|
|
789
1111
|
);
|
|
790
1112
|
}
|
|
791
1113
|
const target = await resolveOptionalTarget(args);
|
|
@@ -824,16 +1146,34 @@ async function getArtifactHtmlFromCli(args) {
|
|
|
824
1146
|
console.log(`Revision: ${result.revisionId}`);
|
|
825
1147
|
console.log(`Version: ${result.version}`);
|
|
826
1148
|
}
|
|
1149
|
+
function parseVerifyType(value) {
|
|
1150
|
+
const type = parseTypeFlag(value);
|
|
1151
|
+
if (type === void 0 || type === "html") {
|
|
1152
|
+
return void 0;
|
|
1153
|
+
}
|
|
1154
|
+
if (!verifyTypes.includes(type)) {
|
|
1155
|
+
throw usageError(
|
|
1156
|
+
`Unknown type "${type}". Expected one of: ${verifyTypes.join(", ")}.`
|
|
1157
|
+
);
|
|
1158
|
+
}
|
|
1159
|
+
return type;
|
|
1160
|
+
}
|
|
827
1161
|
async function verifyFromCli(args) {
|
|
828
1162
|
const [target] = getPositionals(args);
|
|
829
|
-
|
|
1163
|
+
const root = parseFlagValue(args, "--root");
|
|
1164
|
+
if (!target && !root) {
|
|
830
1165
|
throw usageError(
|
|
831
|
-
"Usage: artis verify <artifact.html | artifact
|
|
1166
|
+
"Usage: artis verify <artifact.html | artifact> [--type slides] [--revision <revision-id>] [--json]\n artis verify --root <dir> --type slides [--json]"
|
|
832
1167
|
);
|
|
833
1168
|
}
|
|
1169
|
+
if (root) {
|
|
1170
|
+
return verifyFilesDirFromCli(args, root, target);
|
|
1171
|
+
}
|
|
1172
|
+
let type = parseVerifyType(parseFlagValue(args, "--type"));
|
|
834
1173
|
let html;
|
|
835
1174
|
let label;
|
|
836
|
-
const
|
|
1175
|
+
const referenced = artifactIdFromReference(target);
|
|
1176
|
+
const looksLikePath = !referenced && (/[\\/]/.test(target) || /\.html?$/i.test(target));
|
|
837
1177
|
const local = await readFile(target, "utf8").catch(
|
|
838
1178
|
(error) => error
|
|
839
1179
|
);
|
|
@@ -854,26 +1194,77 @@ async function verifyFromCli(args) {
|
|
|
854
1194
|
remote,
|
|
855
1195
|
"GET /api/artifacts/{artifactId}/html",
|
|
856
1196
|
{
|
|
857
|
-
params: { artifactId: target },
|
|
1197
|
+
params: { artifactId: referenced ?? target },
|
|
858
1198
|
query: { revisionId: parseFlagValue(args, "--revision") }
|
|
859
1199
|
}
|
|
860
1200
|
);
|
|
861
1201
|
html = result.html;
|
|
862
1202
|
label = `${target} v${result.version}`;
|
|
1203
|
+
if (type === void 0) {
|
|
1204
|
+
const { artifact } = await apiCallOptional(
|
|
1205
|
+
remote,
|
|
1206
|
+
"GET /api/artifacts/{artifactId}",
|
|
1207
|
+
{ params: { artifactId: referenced ?? target } }
|
|
1208
|
+
);
|
|
1209
|
+
const declared = artifact.revisions.find(
|
|
1210
|
+
(revision) => revision.id === result.revisionId
|
|
1211
|
+
)?.type;
|
|
1212
|
+
if (declared && declared !== "html") {
|
|
1213
|
+
if (!verifyTypes.includes(declared)) {
|
|
1214
|
+
throw new CliError(
|
|
1215
|
+
`${label} is of type ${declared}, which this CLI cannot verify. Update the CLI.`,
|
|
1216
|
+
exitCodes.error
|
|
1217
|
+
);
|
|
1218
|
+
}
|
|
1219
|
+
type = declared;
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
await runVerify(args, html, label, type);
|
|
1224
|
+
}
|
|
1225
|
+
async function verifyFilesDirFromCli(args, root, target) {
|
|
1226
|
+
if (target) {
|
|
1227
|
+
throw usageError("--root takes no file or artifact argument.");
|
|
863
1228
|
}
|
|
1229
|
+
if (parseFlagValue(args, "--revision")) {
|
|
1230
|
+
throw usageError("--revision applies to a published artifact.");
|
|
1231
|
+
}
|
|
1232
|
+
const type = parseVerifyType(parseFlagValue(args, "--type"));
|
|
1233
|
+
if (type !== "slides") {
|
|
1234
|
+
throw usageError("--root needs --type slides: a deck as files.");
|
|
1235
|
+
}
|
|
1236
|
+
const composed = composeSlidesFiles(await readFilesDir(root));
|
|
1237
|
+
if (!composed.ok) {
|
|
1238
|
+
console.error(composed.error);
|
|
1239
|
+
throw new CliError("", exitCodes.verifyFailed);
|
|
1240
|
+
}
|
|
1241
|
+
await runVerify(args, composed.value, root, type);
|
|
1242
|
+
}
|
|
1243
|
+
async function runVerify(args, html, label, type) {
|
|
1244
|
+
const json = hasFlag(args, "--json");
|
|
1245
|
+
const title = `Verified ${label}${type ? ` (type ${type})` : ""}`;
|
|
864
1246
|
let report;
|
|
865
1247
|
try {
|
|
866
|
-
report = await verifyHtml(html);
|
|
1248
|
+
report = await verifyHtml(html, { type });
|
|
867
1249
|
} catch (error) {
|
|
868
1250
|
if (error instanceof VerifyUnavailableError) {
|
|
869
|
-
|
|
1251
|
+
if (error.partial && !json) {
|
|
1252
|
+
console.log(title);
|
|
1253
|
+
for (const line of formatVerifyReport(error.partial)) {
|
|
1254
|
+
console.log(line);
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
throw new CliError(
|
|
1258
|
+
error.partial ? `Rendering checks did not run: ${error.message}` : error.message,
|
|
1259
|
+
exitCodes.error
|
|
1260
|
+
);
|
|
870
1261
|
}
|
|
871
1262
|
throw error;
|
|
872
1263
|
}
|
|
873
|
-
if (
|
|
1264
|
+
if (json) {
|
|
874
1265
|
console.log(JSON.stringify(report, null, 2));
|
|
875
1266
|
} else {
|
|
876
|
-
console.log(
|
|
1267
|
+
console.log(title);
|
|
877
1268
|
for (const line of formatVerifyReport(report)) {
|
|
878
1269
|
console.log(line);
|
|
879
1270
|
}
|
|
@@ -883,10 +1274,11 @@ async function verifyFromCli(args) {
|
|
|
883
1274
|
}
|
|
884
1275
|
}
|
|
885
1276
|
async function listArtifactsFromCli(args) {
|
|
1277
|
+
rejectRemovedKindFlag(args);
|
|
886
1278
|
const credentials = await resolveCredentials(args);
|
|
887
1279
|
const query = parseFlagValue(args, "--query");
|
|
888
|
-
const kind = parseFlagValue(args, "--kind");
|
|
889
1280
|
const tag = parseFlagValue(args, "--tag");
|
|
1281
|
+
const type = parseTypeFlag(parseFlagValue(args, "--type"));
|
|
890
1282
|
const limit = parseFlagValue(args, "--limit");
|
|
891
1283
|
const cursor = parseFlagValue(args, "--cursor");
|
|
892
1284
|
if (limit !== void 0 && (!/^\d+$/.test(limit) || Number(limit) < 1 || Number(limit) > artifactListLimits.max)) {
|
|
@@ -898,8 +1290,8 @@ async function listArtifactsFromCli(args) {
|
|
|
898
1290
|
query: {
|
|
899
1291
|
owner: "me",
|
|
900
1292
|
q: query || void 0,
|
|
901
|
-
kind: kind ? parseKind(kind) : void 0,
|
|
902
1293
|
tag: tag || void 0,
|
|
1294
|
+
type,
|
|
903
1295
|
limit: limit ? Number(limit) : void 0,
|
|
904
1296
|
cursor: cursor || void 0
|
|
905
1297
|
}
|
|
@@ -911,14 +1303,14 @@ async function listArtifactsFromCli(args) {
|
|
|
911
1303
|
const { artifacts } = result;
|
|
912
1304
|
if (!artifacts.length) {
|
|
913
1305
|
console.log(
|
|
914
|
-
cursor ? "No more artifacts." : query ||
|
|
1306
|
+
cursor ? "No more artifacts." : query || tag ? "No artifacts match." : "You have no artifacts yet."
|
|
915
1307
|
);
|
|
916
1308
|
return;
|
|
917
1309
|
}
|
|
918
1310
|
for (const artifact of artifacts) {
|
|
919
1311
|
const tags = artifact.metadata.tags?.length ? ` #${artifact.metadata.tags.join(" #")}` : "";
|
|
920
1312
|
console.log(
|
|
921
|
-
`${artifact.
|
|
1313
|
+
`${artifactShortId(artifact.id)} ${artifact.metadata.visibility} ${artifact.metadata.title}${tags}`
|
|
922
1314
|
);
|
|
923
1315
|
}
|
|
924
1316
|
if (result.nextCursor) {
|
|
@@ -928,9 +1320,10 @@ async function listArtifactsFromCli(args) {
|
|
|
928
1320
|
}
|
|
929
1321
|
}
|
|
930
1322
|
async function getArtifactFeedbackFromCli(args) {
|
|
931
|
-
const [
|
|
1323
|
+
const [artifactRef] = getPositionals(args);
|
|
1324
|
+
const artifactId = artifactRef && artifactIdArg(artifactRef);
|
|
932
1325
|
if (!artifactId) {
|
|
933
|
-
throw usageError("Missing artifact id or
|
|
1326
|
+
throw usageError("Missing artifact id or link.");
|
|
934
1327
|
}
|
|
935
1328
|
const target = await resolveOptionalTarget(args);
|
|
936
1329
|
const result = await apiCallOptional(
|
|
@@ -952,10 +1345,11 @@ Feedback cursor: ${result.cursor} (artis watch ${artifactId} --since ${result.cu
|
|
|
952
1345
|
);
|
|
953
1346
|
}
|
|
954
1347
|
async function shareArtifactFromCli(args) {
|
|
955
|
-
const [
|
|
1348
|
+
const [artifactRef] = getPositionals(args);
|
|
1349
|
+
const artifactId = artifactRef && artifactIdArg(artifactRef);
|
|
956
1350
|
if (!artifactId) {
|
|
957
1351
|
throw usageError(
|
|
958
|
-
"Usage: artis share <artifact
|
|
1352
|
+
"Usage: artis share <artifact> [--email <email> --role <viewer|commenter|contributor|editor>] [--remove]"
|
|
959
1353
|
);
|
|
960
1354
|
}
|
|
961
1355
|
const email = parseFlagValue(args, "--email")?.trim().toLowerCase();
|
|
@@ -1002,10 +1396,11 @@ async function shareArtifactFromCli(args) {
|
|
|
1002
1396
|
console.log(`Shared with ${result.share.email} as ${result.share.role}`);
|
|
1003
1397
|
}
|
|
1004
1398
|
async function setArtifactVisibilityFromCli(args) {
|
|
1005
|
-
const [
|
|
1399
|
+
const [artifactRef, value] = getPositionals(args);
|
|
1400
|
+
const artifactId = artifactRef && artifactIdArg(artifactRef);
|
|
1006
1401
|
if (!artifactId || !value) {
|
|
1007
1402
|
throw usageError(
|
|
1008
|
-
`Usage: artis artifact visibility <artifact
|
|
1403
|
+
`Usage: artis artifact visibility <artifact> <${cliVisibilityOptions.join("|")}>`
|
|
1009
1404
|
);
|
|
1010
1405
|
}
|
|
1011
1406
|
const visibility = parseVisibility(value);
|
|
@@ -1022,11 +1417,10 @@ async function setArtifactVisibilityFromCli(args) {
|
|
|
1022
1417
|
console.log(`Visibility: ${result.artifact.metadata.visibility}`);
|
|
1023
1418
|
}
|
|
1024
1419
|
async function deleteArtifactFromCli(args) {
|
|
1025
|
-
const [
|
|
1420
|
+
const [artifactRef] = getPositionals(args);
|
|
1421
|
+
const artifactId = artifactRef && artifactIdArg(artifactRef);
|
|
1026
1422
|
if (!artifactId) {
|
|
1027
|
-
throw usageError(
|
|
1028
|
-
"Usage: artis artifact delete <artifact-id-or-slug> --yes"
|
|
1029
|
-
);
|
|
1423
|
+
throw usageError("Usage: artis artifact delete <artifact> --yes");
|
|
1030
1424
|
}
|
|
1031
1425
|
if (!hasFlag(args, "--yes")) {
|
|
1032
1426
|
throw usageError(
|
|
@@ -1040,11 +1434,14 @@ async function deleteArtifactFromCli(args) {
|
|
|
1040
1434
|
console.log(`Deleted ${artifactId}`);
|
|
1041
1435
|
}
|
|
1042
1436
|
async function reviseArtifactFromCli(args) {
|
|
1043
|
-
|
|
1437
|
+
rejectRemovedResolveFlag(args);
|
|
1438
|
+
const [artifactRef, filePath] = getPositionals(args);
|
|
1439
|
+
const artifactId = artifactRef && artifactIdArg(artifactRef);
|
|
1044
1440
|
const summary = parseFlagValue(args, "--summary");
|
|
1045
|
-
|
|
1441
|
+
const root = parseFlagValue(args, "--root");
|
|
1442
|
+
if (!artifactId || !filePath && !root || filePath && root) {
|
|
1046
1443
|
throw usageError(
|
|
1047
|
-
"Usage: artis revise <artifact
|
|
1444
|
+
"Usage: artis revise <artifact> (artifact.html | --root <dir>) --summary <text> [--base <revision-id>]"
|
|
1048
1445
|
);
|
|
1049
1446
|
}
|
|
1050
1447
|
if (!summary) {
|
|
@@ -1054,27 +1451,55 @@ async function reviseArtifactFromCli(args) {
|
|
|
1054
1451
|
parseFlagValue(args, "--capabilities")
|
|
1055
1452
|
);
|
|
1056
1453
|
const contract = parseContractFlag(parseFlagValue(args, "--contract"));
|
|
1454
|
+
const type = parseTypeFlag(parseFlagValue(args, "--type"));
|
|
1057
1455
|
const credentials = await resolveCredentials(args);
|
|
1058
|
-
const html = await readHtmlUpload(filePath, "Revision file");
|
|
1059
1456
|
const explicitBase = parseFlagValue(args, "--base");
|
|
1060
1457
|
const baseRevisionId = explicitBase ?? await getRememberedBase(credentials.baseUrl, artifactId);
|
|
1061
|
-
const
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1458
|
+
const query = {
|
|
1459
|
+
authorName: parseFlagValue(args, "--author") ?? "Artis CLI",
|
|
1460
|
+
baseRevisionId,
|
|
1461
|
+
source: "cli",
|
|
1462
|
+
summary,
|
|
1463
|
+
capabilities,
|
|
1464
|
+
contract,
|
|
1465
|
+
type
|
|
1466
|
+
};
|
|
1467
|
+
let result;
|
|
1468
|
+
if (root) {
|
|
1469
|
+
const local = await readFilesDir(root);
|
|
1470
|
+
const remote = await apiCall(
|
|
1471
|
+
credentials,
|
|
1472
|
+
"GET /api/artifacts/{artifactId}/files",
|
|
1473
|
+
{ params: { artifactId }, query: { revisionId: baseRevisionId } }
|
|
1474
|
+
);
|
|
1475
|
+
const files = changedFiles(local, remote.files);
|
|
1476
|
+
if (Object.keys(files).length === 0) {
|
|
1477
|
+
console.log(
|
|
1478
|
+
`No files differ from revision ${remote.revisionId}; nothing to revise.`
|
|
1479
|
+
);
|
|
1480
|
+
return;
|
|
1076
1481
|
}
|
|
1077
|
-
|
|
1482
|
+
result = await apiCall(
|
|
1483
|
+
credentials,
|
|
1484
|
+
"POST /api/artifacts/{artifactId}/revisions/files",
|
|
1485
|
+
{ params: { artifactId }, query, body: { files } }
|
|
1486
|
+
);
|
|
1487
|
+
if (!hasFlag(args, "--json")) {
|
|
1488
|
+
const removed = Object.values(files).filter(
|
|
1489
|
+
(content) => content === null
|
|
1490
|
+
);
|
|
1491
|
+
console.log(
|
|
1492
|
+
`Sent ${Object.keys(files).length - removed.length} changed and ${removed.length} removed of ${Object.keys(local).length} files.`
|
|
1493
|
+
);
|
|
1494
|
+
}
|
|
1495
|
+
} else {
|
|
1496
|
+
const html = await readHtmlUpload(filePath ?? "", "Revision file");
|
|
1497
|
+
result = await apiCall(
|
|
1498
|
+
credentials,
|
|
1499
|
+
"POST /api/artifacts/{artifactId}/revisions",
|
|
1500
|
+
{ params: { artifactId }, query, body: html }
|
|
1501
|
+
);
|
|
1502
|
+
}
|
|
1078
1503
|
await rememberBase(
|
|
1079
1504
|
credentials.baseUrl,
|
|
1080
1505
|
[artifactId],
|
|
@@ -1087,6 +1512,10 @@ async function reviseArtifactFromCli(args) {
|
|
|
1087
1512
|
}
|
|
1088
1513
|
console.log(`Revision ${result.revision.id}`);
|
|
1089
1514
|
console.log(`Version ${result.revision.version}`);
|
|
1515
|
+
const revisionType = describeType(result.revision);
|
|
1516
|
+
if (revisionType) {
|
|
1517
|
+
console.log(`Type ${revisionType}`);
|
|
1518
|
+
}
|
|
1090
1519
|
if (baseRevisionId && !explicitBase) {
|
|
1091
1520
|
console.log(`Base ${baseRevisionId} (remembered from this machine)`);
|
|
1092
1521
|
} else if (!baseRevisionId) {
|
|
@@ -1096,11 +1525,12 @@ async function reviseArtifactFromCli(args) {
|
|
|
1096
1525
|
}
|
|
1097
1526
|
}
|
|
1098
1527
|
async function createAnnotationFromCli(args) {
|
|
1099
|
-
const [
|
|
1528
|
+
const [artifactRef] = getPositionals(args);
|
|
1529
|
+
const artifactId = artifactRef && artifactIdArg(artifactRef);
|
|
1100
1530
|
const comment = parseFlagValue(args, "--comment");
|
|
1101
1531
|
if (!artifactId || !comment) {
|
|
1102
1532
|
throw usageError(
|
|
1103
|
-
"Usage: artis annotate <artifact
|
|
1533
|
+
"Usage: artis annotate <artifact> --comment <text> [--title <text>] [--quote <text>] [--css <selector>] [--text-start <n> --text-end <n>] [--rect <x,y,w,h>] [--pin-label <text>] [--requested-change <text>] [--status <open|resolved>]"
|
|
1104
1534
|
);
|
|
1105
1535
|
}
|
|
1106
1536
|
const selectors = buildAnnotationSelectors(args);
|
|
@@ -1195,10 +1625,11 @@ function parseDuration(value) {
|
|
|
1195
1625
|
return Number(match[1]) * unitMs;
|
|
1196
1626
|
}
|
|
1197
1627
|
async function watchArtifactFromCli(args) {
|
|
1198
|
-
const [
|
|
1628
|
+
const [artifactRef] = getPositionals(args);
|
|
1629
|
+
const artifactId = artifactRef && artifactIdArg(artifactRef);
|
|
1199
1630
|
if (!artifactId) {
|
|
1200
1631
|
throw usageError(
|
|
1201
|
-
"Usage: artis watch <artifact
|
|
1632
|
+
"Usage: artis watch <artifact> [--since <cursor>] [--once] [--timeout <duration>] [--include-self] [--types <families>]"
|
|
1202
1633
|
);
|
|
1203
1634
|
}
|
|
1204
1635
|
const typesFlag = parseFlagValue(args, "--types");
|
|
@@ -1287,6 +1718,270 @@ async function watchArtifactFromCli(args) {
|
|
|
1287
1718
|
delivered = true;
|
|
1288
1719
|
}
|
|
1289
1720
|
}
|
|
1721
|
+
var dataActions = [
|
|
1722
|
+
"get",
|
|
1723
|
+
"list",
|
|
1724
|
+
"set",
|
|
1725
|
+
"update",
|
|
1726
|
+
"delete",
|
|
1727
|
+
"batch",
|
|
1728
|
+
"export",
|
|
1729
|
+
"usage"
|
|
1730
|
+
];
|
|
1731
|
+
var dataAsRoles = ["viewer", "commenter", "contributor"];
|
|
1732
|
+
var dataUsage = "Usage: artis data <get|list|set|update|delete|batch|export|usage> <artifact> [path] [options]. Run artis help.";
|
|
1733
|
+
function parseIfMatchFlag(value) {
|
|
1734
|
+
if (value === void 0) return void 0;
|
|
1735
|
+
const match = /^([^@\s]+)@([1-9]\d*)$/.exec(value);
|
|
1736
|
+
if (!match?.[1] || !match[2]) {
|
|
1737
|
+
throw usageError(
|
|
1738
|
+
`Invalid --if-match "${value}". Expected <id>@<version>, e.g. doc-abc@3.`
|
|
1739
|
+
);
|
|
1740
|
+
}
|
|
1741
|
+
return { id: match[1], version: Number(match[2]) };
|
|
1742
|
+
}
|
|
1743
|
+
function parseDataCommand(args) {
|
|
1744
|
+
const [action, artifactRef, path, extra] = getPositionals(args);
|
|
1745
|
+
const artifactId = artifactRef && artifactIdArg(artifactRef);
|
|
1746
|
+
if (!dataActions.includes(action) || !artifactId) {
|
|
1747
|
+
throw usageError(dataUsage);
|
|
1748
|
+
}
|
|
1749
|
+
const command = { action, artifactId };
|
|
1750
|
+
const is = (...actions) => actions.includes(command.action);
|
|
1751
|
+
if (is("get", "set", "update", "delete") && !path) {
|
|
1752
|
+
throw usageError(`Usage: artis data ${command.action} <artifact> <path>`);
|
|
1753
|
+
}
|
|
1754
|
+
if (extra !== void 0 || path !== void 0 && is("batch", "export", "usage")) {
|
|
1755
|
+
throw usageError(dataUsage);
|
|
1756
|
+
}
|
|
1757
|
+
if (path !== void 0) command.path = path;
|
|
1758
|
+
const asRole = parseFlagValue(args, "--as-role");
|
|
1759
|
+
if (asRole !== void 0) {
|
|
1760
|
+
if (!is("get", "list", "export")) {
|
|
1761
|
+
throw usageError("--as-role applies to data get, list and export.");
|
|
1762
|
+
}
|
|
1763
|
+
if (!dataAsRoles.includes(asRole)) {
|
|
1764
|
+
throw usageError(
|
|
1765
|
+
`Invalid --as-role "${asRole}". Expected one of: ${dataAsRoles.join(", ")}.`
|
|
1766
|
+
);
|
|
1767
|
+
}
|
|
1768
|
+
command.asRole = asRole;
|
|
1769
|
+
}
|
|
1770
|
+
const ifMatch = parseIfMatchFlag(parseFlagValue(args, "--if-match"));
|
|
1771
|
+
const ifAbsent = hasFlag(args, "--if-absent");
|
|
1772
|
+
if (ifMatch && ifAbsent) {
|
|
1773
|
+
throw usageError("Pass --if-match or --if-absent, not both.");
|
|
1774
|
+
}
|
|
1775
|
+
if (ifMatch) {
|
|
1776
|
+
if (!is("set", "update", "delete")) {
|
|
1777
|
+
throw usageError("--if-match applies to data set, update and delete.");
|
|
1778
|
+
}
|
|
1779
|
+
command.ifMatch = ifMatch;
|
|
1780
|
+
}
|
|
1781
|
+
if (ifAbsent) {
|
|
1782
|
+
if (!is("set", "update")) {
|
|
1783
|
+
throw usageError("--if-absent applies to data set and update.");
|
|
1784
|
+
}
|
|
1785
|
+
command.ifAbsent = true;
|
|
1786
|
+
}
|
|
1787
|
+
const key = parseFlagValue(args, "--idempotency-key");
|
|
1788
|
+
if (key !== void 0) {
|
|
1789
|
+
if (!is("set", "update", "delete", "batch")) {
|
|
1790
|
+
throw usageError("--idempotency-key applies to data writes.");
|
|
1791
|
+
}
|
|
1792
|
+
if (!/^[\x21-\x7e]{1,255}$/.test(key)) {
|
|
1793
|
+
throw usageError(
|
|
1794
|
+
"--idempotency-key must be 1-255 printable characters without spaces."
|
|
1795
|
+
);
|
|
1796
|
+
}
|
|
1797
|
+
command.idempotencyKey = key;
|
|
1798
|
+
}
|
|
1799
|
+
return command;
|
|
1800
|
+
}
|
|
1801
|
+
async function readStdin() {
|
|
1802
|
+
const chunks = [];
|
|
1803
|
+
for await (const chunk of process.stdin) chunks.push(chunk);
|
|
1804
|
+
return Buffer.concat(chunks).toString("utf8");
|
|
1805
|
+
}
|
|
1806
|
+
async function readJsonFlag(args, flag) {
|
|
1807
|
+
const value = parseFlagValue(args, flag);
|
|
1808
|
+
if (value === void 0) {
|
|
1809
|
+
throw usageError(`Missing ${flag} <json|file|->.`);
|
|
1810
|
+
}
|
|
1811
|
+
let source = value;
|
|
1812
|
+
if (value === "-") {
|
|
1813
|
+
source = await readStdin();
|
|
1814
|
+
} else if (!/^\s*[[{]/.test(value)) {
|
|
1815
|
+
try {
|
|
1816
|
+
source = await readFile(value, "utf8");
|
|
1817
|
+
} catch {
|
|
1818
|
+
throw usageError(
|
|
1819
|
+
`${flag} must be JSON, a path to a JSON file, or - for stdin; could not read "${value}".`
|
|
1820
|
+
);
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1823
|
+
try {
|
|
1824
|
+
return JSON.parse(source);
|
|
1825
|
+
} catch {
|
|
1826
|
+
throw usageError(`${flag} is not valid JSON.`);
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
async function readJsonObjectFlag(args, flag) {
|
|
1830
|
+
const value = await readJsonFlag(args, flag);
|
|
1831
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
1832
|
+
throw usageError(`${flag} must be a JSON object.`);
|
|
1833
|
+
}
|
|
1834
|
+
return value;
|
|
1835
|
+
}
|
|
1836
|
+
function printJson(value) {
|
|
1837
|
+
console.log(JSON.stringify(value, null, 2));
|
|
1838
|
+
}
|
|
1839
|
+
async function dataFromCli(args) {
|
|
1840
|
+
const command = parseDataCommand(args);
|
|
1841
|
+
const credentials = await resolveCredentials(args);
|
|
1842
|
+
const { artifactId } = command;
|
|
1843
|
+
const path = command.path ?? "";
|
|
1844
|
+
const headers = command.idempotencyKey ? { "idempotency-key": command.idempotencyKey } : void 0;
|
|
1845
|
+
const condition = {
|
|
1846
|
+
...command.ifMatch ? { ifMatch: command.ifMatch } : {},
|
|
1847
|
+
...command.ifAbsent ? { ifAbsent: true } : {}
|
|
1848
|
+
};
|
|
1849
|
+
switch (command.action) {
|
|
1850
|
+
case "get": {
|
|
1851
|
+
const { document } = await apiCall(
|
|
1852
|
+
credentials,
|
|
1853
|
+
"GET /api/artifacts/{artifactId}/data/docs/{path}",
|
|
1854
|
+
{ params: { artifactId, path }, query: { asRole: command.asRole } }
|
|
1855
|
+
);
|
|
1856
|
+
printJson(document);
|
|
1857
|
+
if (!document) {
|
|
1858
|
+
throw new CliError(`No document at "${path}".`, exitCodes.notFound);
|
|
1859
|
+
}
|
|
1860
|
+
return;
|
|
1861
|
+
}
|
|
1862
|
+
case "list": {
|
|
1863
|
+
const limit = parseFlagValue(args, "--limit");
|
|
1864
|
+
if (limit !== void 0 && (!/^\d+$/.test(limit) || Number(limit) < 1 || Number(limit) > 1e3)) {
|
|
1865
|
+
throw usageError(
|
|
1866
|
+
`Invalid --limit "${limit}". Pass a whole number from 1 to 1000.`
|
|
1867
|
+
);
|
|
1868
|
+
}
|
|
1869
|
+
const depth = parseFlagValue(args, "--depth");
|
|
1870
|
+
if (depth !== void 0 && depth !== "children" && depth !== "all") {
|
|
1871
|
+
throw usageError("--depth must be children or all.");
|
|
1872
|
+
}
|
|
1873
|
+
const order = parseFlagValue(args, "--order");
|
|
1874
|
+
if (order !== void 0 && order !== "path" && order !== "created") {
|
|
1875
|
+
throw usageError("--order must be path or created.");
|
|
1876
|
+
}
|
|
1877
|
+
printJson(
|
|
1878
|
+
await apiCall(credentials, "GET /api/artifacts/{artifactId}/data", {
|
|
1879
|
+
params: { artifactId },
|
|
1880
|
+
query: {
|
|
1881
|
+
prefix: command.path,
|
|
1882
|
+
depth,
|
|
1883
|
+
order,
|
|
1884
|
+
limit: limit ? Number(limit) : void 0,
|
|
1885
|
+
after: parseFlagValue(args, "--after"),
|
|
1886
|
+
asRole: command.asRole
|
|
1887
|
+
}
|
|
1888
|
+
})
|
|
1889
|
+
);
|
|
1890
|
+
return;
|
|
1891
|
+
}
|
|
1892
|
+
case "set": {
|
|
1893
|
+
const value = await readJsonObjectFlag(args, "--value");
|
|
1894
|
+
const { document } = await apiCall(
|
|
1895
|
+
credentials,
|
|
1896
|
+
"PUT /api/artifacts/{artifactId}/data/docs/{path}",
|
|
1897
|
+
{
|
|
1898
|
+
params: { artifactId, path },
|
|
1899
|
+
body: { value, ...condition },
|
|
1900
|
+
headers
|
|
1901
|
+
}
|
|
1902
|
+
);
|
|
1903
|
+
printJson(document);
|
|
1904
|
+
return;
|
|
1905
|
+
}
|
|
1906
|
+
case "update": {
|
|
1907
|
+
const patch = await readJsonObjectFlag(args, "--patch");
|
|
1908
|
+
const { document } = await apiCall(
|
|
1909
|
+
credentials,
|
|
1910
|
+
"PATCH /api/artifacts/{artifactId}/data/docs/{path}",
|
|
1911
|
+
{
|
|
1912
|
+
params: { artifactId, path },
|
|
1913
|
+
body: { patch, ...condition },
|
|
1914
|
+
headers
|
|
1915
|
+
}
|
|
1916
|
+
);
|
|
1917
|
+
printJson(document);
|
|
1918
|
+
return;
|
|
1919
|
+
}
|
|
1920
|
+
case "delete": {
|
|
1921
|
+
const ifMatch = command.ifMatch ? `${command.ifMatch.id}@${command.ifMatch.version}` : void 0;
|
|
1922
|
+
printJson(
|
|
1923
|
+
await apiCall(
|
|
1924
|
+
credentials,
|
|
1925
|
+
"DELETE /api/artifacts/{artifactId}/data/docs/{path}",
|
|
1926
|
+
{ params: { artifactId, path }, query: { ifMatch }, headers }
|
|
1927
|
+
)
|
|
1928
|
+
);
|
|
1929
|
+
return;
|
|
1930
|
+
}
|
|
1931
|
+
case "batch": {
|
|
1932
|
+
const raw = await readJsonFlag(args, "--ops");
|
|
1933
|
+
const ops = Array.isArray(raw) ? raw : raw?.ops;
|
|
1934
|
+
if (!Array.isArray(ops)) {
|
|
1935
|
+
throw usageError(
|
|
1936
|
+
'--ops must be a JSON array of writes, or {"ops": [...]}.'
|
|
1937
|
+
);
|
|
1938
|
+
}
|
|
1939
|
+
printJson(
|
|
1940
|
+
await apiCall(
|
|
1941
|
+
credentials,
|
|
1942
|
+
"POST /api/artifacts/{artifactId}/data/batch",
|
|
1943
|
+
// The server checks each write.
|
|
1944
|
+
{ params: { artifactId }, body: { ops }, headers }
|
|
1945
|
+
)
|
|
1946
|
+
);
|
|
1947
|
+
return;
|
|
1948
|
+
}
|
|
1949
|
+
case "export": {
|
|
1950
|
+
let exported;
|
|
1951
|
+
try {
|
|
1952
|
+
exported = await apiClient(credentials).send(
|
|
1953
|
+
"GET /api/artifacts/{artifactId}/data/export",
|
|
1954
|
+
{ params: { artifactId }, query: { asRole: command.asRole } }
|
|
1955
|
+
);
|
|
1956
|
+
} catch (error) {
|
|
1957
|
+
throw cliErrorOf(error);
|
|
1958
|
+
}
|
|
1959
|
+
const text = typeof exported.body === "string" ? exported.body : "";
|
|
1960
|
+
const output = parseFlagValue(args, "--output");
|
|
1961
|
+
if (output) {
|
|
1962
|
+
await writeFile(output, text);
|
|
1963
|
+
} else {
|
|
1964
|
+
process.stdout.write(text);
|
|
1965
|
+
}
|
|
1966
|
+
const count = text.split("\n").filter((line) => line.trim()).length;
|
|
1967
|
+
const left = exported.headers.get("artis-private-documents");
|
|
1968
|
+
console.error(
|
|
1969
|
+
`Exported ${count} document${count === 1 ? "" : "s"}${output ? ` to ${output}` : ""}${left === null ? "" : `; ${left} in private subtrees left out`}.`
|
|
1970
|
+
);
|
|
1971
|
+
return;
|
|
1972
|
+
}
|
|
1973
|
+
case "usage": {
|
|
1974
|
+
printJson(
|
|
1975
|
+
await apiCall(
|
|
1976
|
+
credentials,
|
|
1977
|
+
"GET /api/artifacts/{artifactId}/data/usage",
|
|
1978
|
+
{ params: { artifactId } }
|
|
1979
|
+
)
|
|
1980
|
+
);
|
|
1981
|
+
return;
|
|
1982
|
+
}
|
|
1983
|
+
}
|
|
1984
|
+
}
|
|
1290
1985
|
async function runArtisCli(args = process.argv.slice(2)) {
|
|
1291
1986
|
const [command, ...rest] = args;
|
|
1292
1987
|
if (command === "version" || command === "--version" || command === "-v") {
|
|
@@ -1313,6 +2008,10 @@ async function runArtisCli(args = process.argv.slice(2)) {
|
|
|
1313
2008
|
await guidelinesFromCli(rest);
|
|
1314
2009
|
return;
|
|
1315
2010
|
}
|
|
2011
|
+
if (command === "types") {
|
|
2012
|
+
await typesFromCli(rest);
|
|
2013
|
+
return;
|
|
2014
|
+
}
|
|
1316
2015
|
if (command === "publish") {
|
|
1317
2016
|
const published = await publishArtifactFromCli(rest);
|
|
1318
2017
|
if (hasFlag(rest, "--json")) {
|
|
@@ -1323,6 +2022,10 @@ async function runArtisCli(args = process.argv.slice(2)) {
|
|
|
1323
2022
|
console.log(`Artifact: ${published.artifactId}`);
|
|
1324
2023
|
console.log(`Revision: ${published.revisionId}`);
|
|
1325
2024
|
console.log(`Visibility: ${published.visibility}`);
|
|
2025
|
+
const publishedType = describeType(published);
|
|
2026
|
+
if (publishedType) {
|
|
2027
|
+
console.log(`Type: ${publishedType}`);
|
|
2028
|
+
}
|
|
1326
2029
|
console.log(published.url);
|
|
1327
2030
|
return;
|
|
1328
2031
|
}
|
|
@@ -1334,6 +2037,10 @@ async function runArtisCli(args = process.argv.slice(2)) {
|
|
|
1334
2037
|
await getArtifactHtmlFromCli(rest.slice(1));
|
|
1335
2038
|
return;
|
|
1336
2039
|
}
|
|
2040
|
+
if (command === "artifact" && rest[0] === "files") {
|
|
2041
|
+
await getArtifactFilesFromCli(rest.slice(1));
|
|
2042
|
+
return;
|
|
2043
|
+
}
|
|
1337
2044
|
if (command === "verify") {
|
|
1338
2045
|
await verifyFromCli(rest);
|
|
1339
2046
|
return;
|
|
@@ -1382,6 +2089,10 @@ async function runArtisCli(args = process.argv.slice(2)) {
|
|
|
1382
2089
|
await retractAnnotationFromCli(rest.slice(1));
|
|
1383
2090
|
return;
|
|
1384
2091
|
}
|
|
2092
|
+
if (command === "data") {
|
|
2093
|
+
await dataFromCli(rest);
|
|
2094
|
+
return;
|
|
2095
|
+
}
|
|
1385
2096
|
throw usageError(`Unknown command "${args.join(" ")}". Run artis help.`);
|
|
1386
2097
|
}
|
|
1387
2098
|
|
|
@@ -1392,8 +2103,10 @@ export {
|
|
|
1392
2103
|
getCliHelp,
|
|
1393
2104
|
publishArtifactFromCli,
|
|
1394
2105
|
loginFromCli,
|
|
2106
|
+
typesFromCli,
|
|
1395
2107
|
whoamiFromCli,
|
|
1396
2108
|
getArtifactFromCli,
|
|
2109
|
+
getArtifactFilesFromCli,
|
|
1397
2110
|
getArtifactHtmlFromCli,
|
|
1398
2111
|
verifyFromCli,
|
|
1399
2112
|
listArtifactsFromCli,
|
|
@@ -1407,5 +2120,7 @@ export {
|
|
|
1407
2120
|
editAnnotationFromCli,
|
|
1408
2121
|
retractAnnotationFromCli,
|
|
1409
2122
|
watchArtifactFromCli,
|
|
2123
|
+
parseDataCommand,
|
|
2124
|
+
dataFromCli,
|
|
1410
2125
|
runArtisCli
|
|
1411
2126
|
};
|