@gonovus-ai/spec-flow-cli 0.6.3 → 1.0.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 +58 -7
- package/dist/authentication-command-topology.js.map +1 -1
- package/dist/bin.js.map +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +864 -287
- package/dist/cli.js.map +1 -1
- package/dist/client-identity.d.ts +1 -1
- package/dist/client-identity.js +3 -1
- package/dist/client-identity.js.map +1 -1
- package/dist/commands/client-compatibility.d.ts +3 -0
- package/dist/commands/client-compatibility.js +191 -0
- package/dist/commands/client-compatibility.js.map +1 -0
- package/dist/commands/guide.d.ts +2 -0
- package/dist/commands/guide.js +35 -0
- package/dist/commands/guide.js.map +1 -0
- package/dist/commands/work-item-output.d.ts +15 -5
- package/dist/commands/work-item-output.js +47 -9
- package/dist/commands/work-item-output.js.map +1 -1
- package/dist/credential-store.js +6 -7
- package/dist/credential-store.js.map +1 -1
- package/dist/custom-field-color-commands.js +13 -3
- package/dist/custom-field-color-commands.js.map +1 -1
- package/dist/default-api-origin.js.map +1 -1
- package/dist/github-account-commands.js +116 -20
- package/dist/github-account-commands.js.map +1 -1
- package/dist/github-connection-commands.js +284 -36
- package/dist/github-connection-commands.js.map +1 -1
- package/dist/github-import-commands.js +41 -11
- package/dist/github-import-commands.js.map +1 -1
- package/dist/http-origin.js +1 -1
- package/dist/http-origin.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +125 -35
- package/dist/index.js.map +1 -1
- package/dist/input/text-source.js +8 -2
- package/dist/input/text-source.js.map +1 -1
- package/dist/node-version.js.map +1 -1
- package/dist/product-map-commands.js +220 -37
- package/dist/product-map-commands.js.map +1 -1
- package/dist/program.js +9 -3
- package/dist/program.js.map +1 -1
- package/dist/project-administration-commands.js +36 -8
- package/dist/project-administration-commands.js.map +1 -1
- package/dist/runtime/client-compatibility.d.ts +13 -0
- package/dist/runtime/client-compatibility.js +79 -0
- package/dist/runtime/client-compatibility.js.map +1 -0
- package/dist/runtime/errors.js +21 -3
- package/dist/runtime/errors.js.map +1 -1
- package/dist/runtime/execute.js +16 -2
- package/dist/runtime/execute.js.map +1 -1
- package/dist/runtime/identity.d.ts +8 -80
- package/dist/runtime/identity.js +21 -4
- package/dist/runtime/identity.js.map +1 -1
- package/dist/runtime/npm-upgrade.d.ts +32 -0
- package/dist/runtime/npm-upgrade.js +132 -0
- package/dist/runtime/npm-upgrade.js.map +1 -0
- package/dist/runtime/output.js +6 -1
- package/dist/runtime/output.js.map +1 -1
- package/dist/runtime/session.js +44 -11
- package/dist/runtime/session.js.map +1 -1
- package/dist/screen-image-commands.js +66 -14
- package/dist/screen-image-commands.js.map +1 -1
- package/dist/spec-discussion-commands.js +87 -24
- package/dist/spec-discussion-commands.js.map +1 -1
- package/dist/spec-owner-commands.js +22 -7
- package/dist/spec-owner-commands.js.map +1 -1
- package/dist/user-api-key-commands.js +92 -20
- package/dist/user-api-key-commands.js.map +1 -1
- package/dist/work-item-asset-commands.js +23 -6
- package/dist/work-item-asset-commands.js.map +1 -1
- package/dist/work-item-delivery-commands.js +97 -31
- package/dist/work-item-delivery-commands.js.map +1 -1
- package/dist/work-item-exchange-file.js +22 -8
- package/dist/work-item-exchange-file.js.map +1 -1
- package/dist/work-item-query-commands.js +403 -35
- package/dist/work-item-query-commands.js.map +1 -1
- package/dist/work-item-resource-link-commands.js +105 -28
- package/dist/work-item-resource-link-commands.js.map +1 -1
- package/dist/work-item-thread-commands.d.ts +3 -0
- package/dist/work-item-thread-commands.js +101 -0
- package/dist/work-item-thread-commands.js.map +1 -0
- package/dist/work-item-watcher-commands.d.ts +20 -0
- package/dist/work-item-watcher-commands.js +93 -0
- package/dist/work-item-watcher-commands.js.map +1 -0
- package/guides/authoring.md +178 -0
- package/guides/delivery.md +60 -0
- package/guides/discussions-audit.md +32 -0
- package/guides/errors.md +41 -0
- package/guides/glossary.md +40 -0
- package/guides/map-and-screens.md +31 -0
- package/guides/search.md +9 -0
- package/guides/work-items.md +195 -0
- package/guides/workspace-admin.md +130 -0
- package/package.json +8 -3
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import { open } from "node:fs/promises";
|
|
2
2
|
import { basename } from "node:path";
|
|
3
|
-
import { readBoundedFile, reservationSchema, validateUploadReservation } from "./work-item-asset-commands.js";
|
|
3
|
+
import { readBoundedFile, reservationSchema, validateUploadReservation, } from "./work-item-asset-commands.js";
|
|
4
4
|
const maximumBytes = 10 * 1024 * 1024;
|
|
5
|
-
const invalid = (message) => ({
|
|
5
|
+
const invalid = (message) => ({
|
|
6
|
+
response: new Response(null, { status: 400 }),
|
|
7
|
+
error: { code: "INVALID_IMAGE_INPUT", message },
|
|
8
|
+
});
|
|
6
9
|
export function registerScreenImageCommands(screen, runtime) {
|
|
7
|
-
screen
|
|
8
|
-
.
|
|
9
|
-
.
|
|
10
|
+
screen
|
|
11
|
+
.command("image-upload")
|
|
12
|
+
.description("Reserve, PUT local bytes, then finalize a private Screen image")
|
|
13
|
+
.requiredOption("--workspace-id <id>")
|
|
14
|
+
.requiredOption("--screen-id <id>")
|
|
15
|
+
.requiredOption("--file <path>")
|
|
16
|
+
.requiredOption("--content-type <type>")
|
|
17
|
+
.requiredOption("--expected-version <version>", "Observed Screen version", runtime.parseOpaqueVersion)
|
|
10
18
|
.requiredOption("--idempotency-key <key>", "Reservation identity; reuse with identical inputs")
|
|
11
19
|
.requiredOption("--finalize-key <key>", "Separate finalization identity; reuse with identical inputs")
|
|
12
20
|
.action(async (o) => {
|
|
@@ -22,14 +30,36 @@ export function registerScreenImageCommands(screen, runtime) {
|
|
|
22
30
|
catch {
|
|
23
31
|
return invalid("Image input must be a readable nonempty regular file of at most 10 MiB");
|
|
24
32
|
}
|
|
25
|
-
const params = {
|
|
26
|
-
|
|
33
|
+
const params = {
|
|
34
|
+
path: { workspaceId: o.workspaceId, screenId: o.screenId },
|
|
35
|
+
header: { "if-match": o.expectedVersion, "idempotency-key": o.idempotencyKey },
|
|
36
|
+
};
|
|
37
|
+
const reserved = await c.POST("/v1/workspaces/{workspaceId}/screens/{screenId}/image/uploads", {
|
|
38
|
+
params,
|
|
39
|
+
body: {
|
|
40
|
+
filename: basename(o.file),
|
|
41
|
+
contentType: o.contentType,
|
|
42
|
+
size: bytes.byteLength,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
27
45
|
if (reserved.data === undefined)
|
|
28
46
|
return reserved;
|
|
29
47
|
let request;
|
|
30
48
|
try {
|
|
31
49
|
const reservation = reservationSchema.parse(reserved.data);
|
|
32
|
-
request = new Request(validateUploadReservation(reservation), {
|
|
50
|
+
request = new Request(validateUploadReservation(reservation), {
|
|
51
|
+
method: "PUT",
|
|
52
|
+
headers: {
|
|
53
|
+
"Content-Type": reservation.headers["Content-Type"],
|
|
54
|
+
...(reservation.headers["x-ms-blob-type"] === undefined
|
|
55
|
+
? {}
|
|
56
|
+
: { "x-ms-blob-type": reservation.headers["x-ms-blob-type"] }),
|
|
57
|
+
},
|
|
58
|
+
body: new Uint8Array(bytes),
|
|
59
|
+
redirect: "error",
|
|
60
|
+
credentials: "omit",
|
|
61
|
+
signal: AbortSignal.timeout(60_000),
|
|
62
|
+
});
|
|
33
63
|
}
|
|
34
64
|
catch {
|
|
35
65
|
return invalid("Server upload reservation is invalid or expired; no bytes were sent");
|
|
@@ -44,15 +74,34 @@ export function registerScreenImageCommands(screen, runtime) {
|
|
|
44
74
|
}
|
|
45
75
|
await response.body?.cancel();
|
|
46
76
|
if (!response.ok)
|
|
47
|
-
return {
|
|
48
|
-
|
|
77
|
+
return {
|
|
78
|
+
response,
|
|
79
|
+
error: {
|
|
80
|
+
code: "SCREEN_IMAGE_UPLOAD_FAILED",
|
|
81
|
+
message: "Upload failed; retain the original inputs and keys",
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
return c.POST("/v1/workspaces/{workspaceId}/screens/{screenId}/image/finalize", {
|
|
85
|
+
params: { ...params, header: { ...params.header, "idempotency-key": o.finalizeKey } },
|
|
86
|
+
body: { uploadId: reserved.data.uploadId },
|
|
87
|
+
});
|
|
49
88
|
}));
|
|
50
89
|
});
|
|
51
|
-
screen
|
|
52
|
-
.
|
|
90
|
+
screen
|
|
91
|
+
.command("image-download")
|
|
92
|
+
.description("Download an authorized asset identity into a new owner-only file")
|
|
93
|
+
.requiredOption("--workspace-id <id>")
|
|
94
|
+
.requiredOption("--screen-id <id>")
|
|
95
|
+
.requiredOption("--asset-id <id>")
|
|
96
|
+
.requiredOption("--output-file <path>")
|
|
53
97
|
.action(async (o) => {
|
|
54
98
|
runtime.setExitCode(await runtime.run(async (c) => {
|
|
55
|
-
const result = await c.GET("/v1/workspaces/{workspaceId}/screens/{screenId}/image/assets/{assetId}", {
|
|
99
|
+
const result = await c.GET("/v1/workspaces/{workspaceId}/screens/{screenId}/image/assets/{assetId}", {
|
|
100
|
+
params: {
|
|
101
|
+
path: { workspaceId: o.workspaceId, screenId: o.screenId, assetId: o.assetId },
|
|
102
|
+
},
|
|
103
|
+
parseAs: "arrayBuffer",
|
|
104
|
+
});
|
|
56
105
|
if (result.data === undefined)
|
|
57
106
|
return result;
|
|
58
107
|
if (result.data.byteLength > maximumBytes)
|
|
@@ -70,7 +119,10 @@ export function registerScreenImageCommands(screen, runtime) {
|
|
|
70
119
|
finally {
|
|
71
120
|
await file.close();
|
|
72
121
|
}
|
|
73
|
-
return {
|
|
122
|
+
return {
|
|
123
|
+
response: result.response,
|
|
124
|
+
data: { assetId: o.assetId, size: result.data.byteLength, outputFile: o.outputFile },
|
|
125
|
+
};
|
|
74
126
|
}));
|
|
75
127
|
});
|
|
76
128
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screen-image-commands.js","sourceRoot":"","sources":["../src/screen-image-commands.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAIrC,OAAO,
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,EAAE,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,UAAU,EAAE,CAAC,CAAC,UAAU,EAAE;aACrF,CAAC;QACJ,CAAC,CAAC,CACH,CAAC;IACJ,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -8,48 +8,111 @@ const parse = (schema, message) => (value) => {
|
|
|
8
8
|
};
|
|
9
9
|
const uuid = parse(z.uuid(), "Thread, comment and command identities must be UUIDs");
|
|
10
10
|
const scenario = parse(z.string().regex(/^[A-Z]{2,10}-S[1-9][0-9]*-[1-9][0-9]*$/u), "Use an allocated stable Scenario identity");
|
|
11
|
-
const content = parse(z
|
|
11
|
+
const content = parse(z
|
|
12
|
+
.string()
|
|
13
|
+
.trim()
|
|
14
|
+
.min(1)
|
|
15
|
+
.max(10000)
|
|
16
|
+
.regex(/^[^\0]*$/u), "Comment must contain 1 to 10000 characters without NUL");
|
|
12
17
|
const contextHash = parse(z.string().regex(/^[a-f0-9]{64}$/u), "Use the observed server context hash");
|
|
13
18
|
export function registerSpecDiscussionCommands(spec, runtime) {
|
|
14
|
-
const discussion = spec
|
|
15
|
-
|
|
19
|
+
const discussion = spec
|
|
20
|
+
.command("discussion")
|
|
21
|
+
.description("Discuss stable Scenarios in explicit Published or WorkingDraft context");
|
|
22
|
+
const scoped = (command) => command
|
|
23
|
+
.requiredOption("--workspace-id <id>")
|
|
24
|
+
.requiredOption("--spec-id <id>")
|
|
16
25
|
.option("--context-kind <kind>", "Content view: Published or WorkingDraft", parse(z.enum(["Published", "WorkingDraft"]), "Choose Published or WorkingDraft"), "Published")
|
|
17
26
|
.option("--json", "Emit structured JSON (the default)");
|
|
18
27
|
const thread = (command) => scoped(command).requiredOption("--thread-id <id>", "Thread UUID", uuid);
|
|
19
28
|
const comment = (command) => thread(command).requiredOption("--comment-id <id>", "Comment UUID", uuid);
|
|
20
|
-
const paged = (command) => command
|
|
29
|
+
const paged = (command) => command
|
|
30
|
+
.option("--limit <limit>", "Maximum entries, 1 through 100", runtime.parseLimit, 30)
|
|
31
|
+
.option("--cursor <cursor>", "Opaque nextCursor from this view");
|
|
21
32
|
const write = (command) => command.requiredOption("--idempotency-key <key>", "Retain this UUID for the same intent", uuid);
|
|
22
33
|
const observed = (command, resource) => write(command).requiredOption("--expected-version <version>", `Observed ${resource} version`, runtime.parseOpaqueVersion);
|
|
23
34
|
const path = (options) => ({ workspaceId: options.workspaceId, specId: options.specId });
|
|
24
35
|
const threadPath = (options) => ({ ...path(options), threadId: options.threadId });
|
|
25
|
-
const commentPath = (options) => ({
|
|
26
|
-
|
|
27
|
-
|
|
36
|
+
const commentPath = (options) => ({
|
|
37
|
+
...threadPath(options),
|
|
38
|
+
commentId: options.commentId,
|
|
39
|
+
});
|
|
40
|
+
const headers = (options) => ({
|
|
41
|
+
"if-match": options.expectedVersion,
|
|
42
|
+
"idempotency-key": options.idempotencyKey,
|
|
43
|
+
});
|
|
44
|
+
const page = (options) => ({
|
|
45
|
+
contextKind: options.contextKind,
|
|
46
|
+
limit: options.limit,
|
|
47
|
+
...(options.cursor === undefined ? {} : { cursor: options.cursor }),
|
|
48
|
+
});
|
|
28
49
|
const run = async (request, mutation = false) => {
|
|
29
50
|
runtime.setExitCode(await runtime.run(request, { rejectWorkspaceReadToken: true, retryTransportOnce: mutation }));
|
|
30
51
|
};
|
|
31
|
-
scoped(discussion.command("targets")).action(async (options) => run(client => client.GET("/v1/workspaces/{workspaceId}/specs/{specId}/discussion-targets", {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
.
|
|
36
|
-
.action(async (options) => run(client => client.
|
|
37
|
-
params: {
|
|
52
|
+
scoped(discussion.command("targets")).action(async (options) => run((client) => client.GET("/v1/workspaces/{workspaceId}/specs/{specId}/discussion-targets", {
|
|
53
|
+
params: { path: path(options), query: { contextKind: options.contextKind } },
|
|
54
|
+
})));
|
|
55
|
+
paged(scoped(discussion.command("list")))
|
|
56
|
+
.option("--scenario-id <id>", "Filter by allocated Scenario", scenario)
|
|
57
|
+
.action(async (options) => run((client) => client.GET("/v1/workspaces/{workspaceId}/specs/{specId}/discussions", {
|
|
58
|
+
params: {
|
|
59
|
+
path: path(options),
|
|
60
|
+
query: {
|
|
61
|
+
...page(options),
|
|
62
|
+
...(options.scenarioId === undefined ? {} : { scenarioId: options.scenarioId }),
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
})));
|
|
66
|
+
paged(thread(discussion.command("comments"))).action(async (options) => run((client) => client.GET("/v1/workspaces/{workspaceId}/specs/{specId}/discussions/{threadId}/comments", {
|
|
67
|
+
params: { path: threadPath(options), query: page(options) },
|
|
68
|
+
})));
|
|
69
|
+
write(scoped(discussion.command("start")))
|
|
70
|
+
.requiredOption("--scenario-id <id>", "Allocated Scenario from targets", scenario)
|
|
71
|
+
.requiredOption("--context-hash <hash>", "Hash from targets in the selected view", contextHash)
|
|
72
|
+
.requiredOption("--content <markdown>", "Comment text", content)
|
|
73
|
+
.action(async (options) => run((client) => client.POST("/v1/workspaces/{workspaceId}/specs/{specId}/discussions", {
|
|
74
|
+
params: { path: path(options), header: { "idempotency-key": options.idempotencyKey } },
|
|
75
|
+
body: {
|
|
76
|
+
contextKind: options.contextKind,
|
|
77
|
+
contextHash: options.contextHash,
|
|
78
|
+
scenarioId: options.scenarioId,
|
|
79
|
+
content: options.content,
|
|
80
|
+
},
|
|
38
81
|
}), true));
|
|
39
|
-
write(thread(discussion.command("reply")))
|
|
40
|
-
.
|
|
41
|
-
|
|
82
|
+
write(thread(discussion.command("reply")))
|
|
83
|
+
.requiredOption("--context-hash <hash>", "Hash from targets in the selected view", contextHash)
|
|
84
|
+
.requiredOption("--content <markdown>", "Comment text", content)
|
|
85
|
+
.action(async (options) => run((client) => client.POST("/v1/workspaces/{workspaceId}/specs/{specId}/discussions/{threadId}/comments", {
|
|
86
|
+
params: {
|
|
87
|
+
path: threadPath(options),
|
|
88
|
+
header: { "idempotency-key": options.idempotencyKey },
|
|
89
|
+
},
|
|
90
|
+
body: {
|
|
91
|
+
contextKind: options.contextKind,
|
|
92
|
+
contextHash: options.contextHash,
|
|
93
|
+
content: options.content,
|
|
94
|
+
},
|
|
42
95
|
}), true));
|
|
43
|
-
observed(comment(discussion.command("edit-comment")), "comment")
|
|
44
|
-
.
|
|
45
|
-
|
|
96
|
+
observed(comment(discussion.command("edit-comment")), "comment")
|
|
97
|
+
.requiredOption("--content <markdown>", "Replacement for your own comment", content)
|
|
98
|
+
.action(async (options) => run((client) => client.PATCH("/v1/workspaces/{workspaceId}/specs/{specId}/discussions/{threadId}/comments/{commentId}", {
|
|
99
|
+
params: { path: commentPath(options), header: headers(options) },
|
|
100
|
+
body: { contextKind: options.contextKind, content: options.content },
|
|
46
101
|
}), true));
|
|
47
|
-
observed(comment(discussion.command("delete-comment")), "comment").action(async (options) => run(client => client.DELETE("/v1/workspaces/{workspaceId}/specs/{specId}/discussions/{threadId}/comments/{commentId}", {
|
|
48
|
-
params: {
|
|
102
|
+
observed(comment(discussion.command("delete-comment")), "comment").action(async (options) => run((client) => client.DELETE("/v1/workspaces/{workspaceId}/specs/{specId}/discussions/{threadId}/comments/{commentId}", {
|
|
103
|
+
params: {
|
|
104
|
+
path: commentPath(options),
|
|
105
|
+
header: headers(options),
|
|
106
|
+
query: { contextKind: options.contextKind },
|
|
107
|
+
},
|
|
49
108
|
}), true));
|
|
50
109
|
for (const operation of ["resolve", "reopen"]) {
|
|
51
|
-
observed(thread(discussion.command(operation)), "thread").action(async (options) => run(client => client.PATCH("/v1/workspaces/{workspaceId}/specs/{specId}/discussions/{threadId}/status", {
|
|
52
|
-
params: { path: threadPath(options), header: headers(options) },
|
|
110
|
+
observed(thread(discussion.command(operation)), "thread").action(async (options) => run((client) => client.PATCH("/v1/workspaces/{workspaceId}/specs/{specId}/discussions/{threadId}/status", {
|
|
111
|
+
params: { path: threadPath(options), header: headers(options) },
|
|
112
|
+
body: {
|
|
113
|
+
contextKind: options.contextKind,
|
|
114
|
+
status: operation === "resolve" ? "Resolved" : "Open",
|
|
115
|
+
},
|
|
53
116
|
}), true));
|
|
54
117
|
}
|
|
55
118
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spec-discussion-commands.js","sourceRoot":"","sources":["../src/spec-discussion-commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAgB,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"spec-discussion-commands.js","sourceRoot":"","sources":["../src/spec-discussion-commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAgB,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAiCxB,MAAM,KAAK,GACT,CAAI,MAAoB,EAAE,OAAe,EAAE,EAAE,CAC7C,CAAC,KAAa,EAAK,EAAE;IACnB,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACvC,IAAI,CAAC,MAAM,CAAC,OAAO;QAAE,MAAM,IAAI,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAC7D,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC,CAAC;AACJ,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,sDAAsD,CAAC,CAAC;AACrF,MAAM,QAAQ,GAAG,KAAK,CACpB,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,yCAAyC,CAAC,EAC3D,2CAA2C,CAC5C,CAAC;AACF,MAAM,OAAO,GAAG,KAAK,CACnB,CAAC;KACE,MAAM,EAAE;KACR,IAAI,EAAE;KACN,GAAG,CAAC,CAAC,CAAC;KACN,GAAG,CAAC,KAAK,CAAC;KACV,KAAK,CAAC,WAAW,CAAC,EACrB,wDAAwD,CACzD,CAAC;AACF,MAAM,WAAW,GAAG,KAAK,CACvB,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC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,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,MAAM,CAC9D,KAAK,EAAE,OAA0B,EAAE,EAAE,CACnC,GAAG,CACD,CAAC,MAAM,EAAE,EAAE,CACT,MAAM,CAAC,KAAK,CACV,2EAA2E,EAC3E;YACE,MAAM,EAAE,EAAE,IAAI,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE;YAC/D,IAAI,EAAE;gBACJ,WAAW,EAAE,OAAO,CAAC,WAAW;gBAChC,MAAM,EAAE,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM;aACtD;SACF,CACF,EACH,IAAI,CACL,CACJ,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -12,13 +12,22 @@ const commandKey = (value) => {
|
|
|
12
12
|
return value;
|
|
13
13
|
};
|
|
14
14
|
export function registerSpecOwnerCommands(spec, runtime) {
|
|
15
|
-
const owner = spec
|
|
16
|
-
|
|
15
|
+
const owner = spec
|
|
16
|
+
.command("owner")
|
|
17
|
+
.description("Read and assign Spec responsibility without granting access");
|
|
18
|
+
const scoped = (command) => command
|
|
19
|
+
.requiredOption("--workspace-id <id>")
|
|
20
|
+
.requiredOption("--spec-id <id>")
|
|
21
|
+
.option("--json", "Emit structured JSON (the default)");
|
|
17
22
|
scoped(owner.command("read")).action(async (options) => {
|
|
18
|
-
runtime.setExitCode(await runtime.run(client => client.GET("/v1/workspaces/{workspaceId}/specs/{specId}/owner", {
|
|
23
|
+
runtime.setExitCode(await runtime.run((client) => client.GET("/v1/workspaces/{workspaceId}/specs/{specId}/owner", {
|
|
24
|
+
params: { path: options },
|
|
25
|
+
}), { rejectWorkspaceReadToken: true }));
|
|
19
26
|
});
|
|
20
27
|
scoped(owner.command("candidates")).action(async (options) => {
|
|
21
|
-
runtime.setExitCode(await runtime.run(client => client.GET("/v1/workspaces/{workspaceId}/specs/{specId}/owner/candidates", {
|
|
28
|
+
runtime.setExitCode(await runtime.run((client) => client.GET("/v1/workspaces/{workspaceId}/specs/{specId}/owner/candidates", {
|
|
29
|
+
params: { path: options },
|
|
30
|
+
}), { rejectWorkspaceReadToken: true }));
|
|
22
31
|
});
|
|
23
32
|
for (const operation of ["assign", "clear"]) {
|
|
24
33
|
const command = scoped(owner.command(operation))
|
|
@@ -27,9 +36,15 @@ export function registerSpecOwnerCommands(spec, runtime) {
|
|
|
27
36
|
if (operation === "assign")
|
|
28
37
|
command.requiredOption("--user-id <id>", "Eligible Workspace member", userIdentity);
|
|
29
38
|
command.action(async (options) => {
|
|
30
|
-
runtime.setExitCode(await runtime.run(client => client.PUT("/v1/workspaces/{workspaceId}/specs/{specId}/owner", {
|
|
31
|
-
params: {
|
|
32
|
-
|
|
39
|
+
runtime.setExitCode(await runtime.run((client) => client.PUT("/v1/workspaces/{workspaceId}/specs/{specId}/owner", {
|
|
40
|
+
params: {
|
|
41
|
+
path: { workspaceId: options.workspaceId, specId: options.specId },
|
|
42
|
+
header: {
|
|
43
|
+
"if-match": options.expectedVersion,
|
|
44
|
+
"idempotency-key": options.idempotencyKey,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
body: { userId: operation === "clear" ? null : (options.userId ?? "") },
|
|
33
48
|
}), { rejectWorkspaceReadToken: true, retryTransportOnce: true }));
|
|
34
49
|
});
|
|
35
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spec-owner-commands.js","sourceRoot":"","sources":["../src/spec-owner-commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAgB,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"spec-owner-commands.js","sourceRoot":"","sources":["../src/spec-owner-commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAgB,MAAM,WAAW,CAAC;AAC/D,OAA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iBAAiB,EAAE,OAAO,CAAC,cAAc;qBAC1C;iBACF;gBACD,IAAI,EAAE,EAAE,MAAM,EAAE,SAAS,KAAK,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,EAAE;aACxE,CAAC,EACJ,EAAE,wBAAwB,EAAE,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAC7D,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
|
|
@@ -20,24 +20,58 @@ const version = (value) => {
|
|
|
20
20
|
};
|
|
21
21
|
const grants = (value) => {
|
|
22
22
|
try {
|
|
23
|
-
return z
|
|
23
|
+
return z
|
|
24
|
+
.array(z
|
|
25
|
+
.object({
|
|
26
|
+
scope: z.enum(["WorkspaceKnowledge", "ProjectTasks"]),
|
|
27
|
+
resourceId: z.string().min(1).max(200),
|
|
28
|
+
statements: z.record(z.string(), z.array(z.string()).min(1)),
|
|
29
|
+
})
|
|
30
|
+
.strict())
|
|
31
|
+
.min(1)
|
|
32
|
+
.max(100)
|
|
33
|
+
.parse(JSON.parse(value));
|
|
24
34
|
}
|
|
25
35
|
catch {
|
|
26
36
|
throw new InvalidArgumentError("Grants must be an explicit WorkspaceKnowledge/ProjectTasks JSON array");
|
|
27
37
|
}
|
|
28
38
|
};
|
|
29
39
|
const keyMetadata = z.object({
|
|
30
|
-
id: z.uuid(),
|
|
31
|
-
|
|
40
|
+
id: z.uuid(),
|
|
41
|
+
name: z.string(),
|
|
42
|
+
prefix: z.string().max(12),
|
|
43
|
+
grants: z.array(z.object({
|
|
44
|
+
scope: z.enum(["WorkspaceKnowledge", "ProjectTasks"]),
|
|
45
|
+
resourceId: z.string(),
|
|
46
|
+
statements: z.record(z.string(), z.array(z.string())),
|
|
47
|
+
})),
|
|
48
|
+
version: z.string().regex(/^"[1-9]\d*"$/u),
|
|
49
|
+
createdAt: z.iso.datetime(),
|
|
50
|
+
expiresAt: z.iso.datetime().nullable(),
|
|
51
|
+
revokedAt: z.iso.datetime().nullable(),
|
|
52
|
+
});
|
|
53
|
+
const issued = z.object({
|
|
54
|
+
key: keyMetadata,
|
|
55
|
+
credential: z
|
|
56
|
+
.string()
|
|
57
|
+
.regex(/^sfk_[A-Za-z0-9_-]{43}$/u)
|
|
58
|
+
.nullable(),
|
|
59
|
+
replayed: z.boolean(),
|
|
32
60
|
});
|
|
33
|
-
const issued = z.object({ key: keyMetadata, credential: z.string().regex(/^sfk_[A-Za-z0-9_-]{43}$/u).nullable(), replayed: z.boolean() });
|
|
34
61
|
const revoked = z.object({ key: keyMetadata, replayed: z.boolean() });
|
|
35
62
|
const listed = z.object({ keys: z.array(keyMetadata), nextCursor: z.string().nullable() });
|
|
36
|
-
const failure = (message) => ({
|
|
63
|
+
const failure = (message) => ({
|
|
64
|
+
message,
|
|
65
|
+
reason: "Temporary Failure",
|
|
66
|
+
retryable: false,
|
|
67
|
+
});
|
|
37
68
|
/** Consume one-time secrets before the shared command runner can print data. */
|
|
38
69
|
export function registerUserApiKeyCommands(program, runtime) {
|
|
39
|
-
const manager = program
|
|
40
|
-
|
|
70
|
+
const manager = program
|
|
71
|
+
.command("api-key")
|
|
72
|
+
.description("Manage User API Keys using an authenticated User Session");
|
|
73
|
+
manager
|
|
74
|
+
.command("list")
|
|
41
75
|
.option("--limit <limit>", "Maximum results, 1 through 100", runtime.parseLimit, 50)
|
|
42
76
|
.option("--cursor <cursor>", "Cursor from the previous page")
|
|
43
77
|
.action(async (options) => {
|
|
@@ -46,7 +80,8 @@ export function registerUserApiKeyCommands(program, runtime) {
|
|
|
46
80
|
return result.response.ok ? { ...result, data: listed.parse(result.data) } : result;
|
|
47
81
|
}, { requireUserSession: true }));
|
|
48
82
|
});
|
|
49
|
-
manager
|
|
83
|
+
manager
|
|
84
|
+
.command("create")
|
|
50
85
|
.requiredOption("--name <name>", "Key display name")
|
|
51
86
|
.requiredOption("--grants <json>", "Explicit Workspace knowledge and Project task grants", grants)
|
|
52
87
|
.requiredOption("--expires-at <timestamp>", "UTC ISO expiry or never", expiresAt)
|
|
@@ -56,23 +91,36 @@ export function registerUserApiKeyCommands(program, runtime) {
|
|
|
56
91
|
runtime.setExitCode(await runtime.run(async (client) => {
|
|
57
92
|
if (runtime.dependencies.credentialStore.writeApiKey === undefined) {
|
|
58
93
|
storageFailure = failure("API Key storage is unavailable; no key was issued");
|
|
59
|
-
return {
|
|
94
|
+
return {
|
|
95
|
+
response: new Response(null, { status: 200 }),
|
|
96
|
+
data: { credentialStored: false },
|
|
97
|
+
};
|
|
60
98
|
}
|
|
61
99
|
const result = await client.POST("/v1/user-api-keys", {
|
|
62
100
|
params: { header: { "idempotency-key": options.idempotencyKey } },
|
|
63
|
-
body: {
|
|
101
|
+
body: {
|
|
102
|
+
name: options.name,
|
|
103
|
+
grants: options.grants,
|
|
104
|
+
expiresAt: options.expiresAt === "never" ? null : options.expiresAt,
|
|
105
|
+
},
|
|
64
106
|
});
|
|
65
107
|
if (!result.response.ok)
|
|
66
108
|
return result;
|
|
67
109
|
const receipt = issued.parse(result.data);
|
|
68
110
|
const id = receipt.key.id;
|
|
69
|
-
const metadata = {
|
|
111
|
+
const metadata = {
|
|
112
|
+
key: receipt.key,
|
|
113
|
+
replayed: receipt.replayed,
|
|
114
|
+
credentialStored: false,
|
|
115
|
+
};
|
|
70
116
|
if (receipt.credential === null) {
|
|
71
117
|
let existing = null;
|
|
72
118
|
try {
|
|
73
|
-
existing = await runtime.dependencies.credentialStore.readApiKey?.(id) ?? null;
|
|
119
|
+
existing = (await runtime.dependencies.credentialStore.readApiKey?.(id)) ?? null;
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
/* Never echo a credential-store exception. */
|
|
74
123
|
}
|
|
75
|
-
catch { /* Never echo a credential-store exception. */ }
|
|
76
124
|
if (existing !== null && /^sfk_[A-Za-z0-9_-]{43}$/u.test(existing))
|
|
77
125
|
return { ...result, data: { ...metadata, credentialStored: true } };
|
|
78
126
|
storageFailure = failure(`Key ${id} was issued, but its secret cannot be recovered; revoke it before deliberately creating another`);
|
|
@@ -87,30 +135,54 @@ export function registerUserApiKeyCommands(program, runtime) {
|
|
|
87
135
|
// A changed version or uncertain response never triggers a fresh issue.
|
|
88
136
|
let compensated = false;
|
|
89
137
|
try {
|
|
90
|
-
const compensation = await client.DELETE("/v1/user-api-keys/{keyId}", {
|
|
138
|
+
const compensation = await client.DELETE("/v1/user-api-keys/{keyId}", {
|
|
139
|
+
params: {
|
|
140
|
+
path: { keyId: id },
|
|
141
|
+
header: { "if-match": receipt.key.version, "idempotency-key": randomUUID() },
|
|
142
|
+
},
|
|
143
|
+
});
|
|
91
144
|
const parsed = revoked.safeParse(compensation.data);
|
|
92
|
-
compensated =
|
|
145
|
+
compensated =
|
|
146
|
+
compensation.response.ok &&
|
|
147
|
+
parsed.success &&
|
|
148
|
+
parsed.data.key.id === id &&
|
|
149
|
+
parsed.data.key.revokedAt !== null;
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
/* An unknown revoke outcome must be reported conservatively. */
|
|
93
153
|
}
|
|
94
|
-
catch { /* An unknown revoke outcome must be reported conservatively. */ }
|
|
95
154
|
if (compensated) {
|
|
96
155
|
try {
|
|
97
156
|
await runtime.dependencies.credentialStore.deleteApiKey?.(id);
|
|
98
157
|
}
|
|
99
|
-
catch {
|
|
158
|
+
catch {
|
|
159
|
+
/* Server revocation already makes this credential unusable. */
|
|
160
|
+
}
|
|
100
161
|
}
|
|
101
|
-
storageFailure = failure(compensated
|
|
162
|
+
storageFailure = failure(compensated
|
|
163
|
+
? `Key ${id} could not be saved and was revoked; fix credential storage before creating another`
|
|
164
|
+
: `Key ${id} could not be saved; revocation is unconfirmed. List and revoke this key before creating another`);
|
|
102
165
|
return { ...result, data: metadata };
|
|
103
166
|
}
|
|
104
167
|
}, { requireUserSession: true, validateSuccess: () => storageFailure }));
|
|
105
168
|
});
|
|
106
|
-
manager
|
|
169
|
+
manager
|
|
170
|
+
.command("revoke")
|
|
107
171
|
.requiredOption("--key-id <id>", "Key identity returned by list", uuid)
|
|
108
172
|
.requiredOption("--expected-version <version>", "Quoted version returned by list", version)
|
|
109
173
|
.requiredOption("--idempotency-key <id>", "Reuse the same command ID and expected version when retrying", uuid)
|
|
110
174
|
.action(async (options) => {
|
|
111
175
|
let deletionFailure = null;
|
|
112
176
|
runtime.setExitCode(await runtime.run(async (client) => {
|
|
113
|
-
const result = await client.DELETE("/v1/user-api-keys/{keyId}", {
|
|
177
|
+
const result = await client.DELETE("/v1/user-api-keys/{keyId}", {
|
|
178
|
+
params: {
|
|
179
|
+
path: { keyId: options.keyId },
|
|
180
|
+
header: {
|
|
181
|
+
"if-match": options.expectedVersion,
|
|
182
|
+
"idempotency-key": options.idempotencyKey,
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
});
|
|
114
186
|
if (!result.response.ok)
|
|
115
187
|
return result;
|
|
116
188
|
const receipt = revoked.parse(result.data);
|