@interop/did-cli 0.13.0 → 0.15.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.
Files changed (102) hide show
  1. package/CHANGELOG.md +166 -6
  2. package/README.md +172 -26
  3. package/dist/commands/did/create.d.ts +22 -0
  4. package/dist/commands/did/create.d.ts.map +1 -1
  5. package/dist/commands/did/create.js +6 -27
  6. package/dist/commands/did/create.js.map +1 -1
  7. package/dist/commands/did/service.d.ts +19 -4
  8. package/dist/commands/did/service.d.ts.map +1 -1
  9. package/dist/commands/did/service.js +46 -45
  10. package/dist/commands/did/service.js.map +1 -1
  11. package/dist/commands/did/webvh-update.d.ts +72 -9
  12. package/dist/commands/did/webvh-update.d.ts.map +1 -1
  13. package/dist/commands/did/webvh-update.js +177 -61
  14. package/dist/commands/did/webvh-update.js.map +1 -1
  15. package/dist/commands/did.d.ts.map +1 -1
  16. package/dist/commands/did.js +10 -1
  17. package/dist/commands/did.js.map +1 -1
  18. package/dist/commands/key.d.ts.map +1 -1
  19. package/dist/commands/key.js +5 -8
  20. package/dist/commands/key.js.map +1 -1
  21. package/dist/commands/was/request-grant.d.ts +39 -0
  22. package/dist/commands/was/request-grant.d.ts.map +1 -0
  23. package/dist/commands/was/request-grant.js +250 -0
  24. package/dist/commands/was/request-grant.js.map +1 -0
  25. package/dist/commands/was/resource.d.ts +21 -7
  26. package/dist/commands/was/resource.d.ts.map +1 -1
  27. package/dist/commands/was/resource.js +40 -15
  28. package/dist/commands/was/resource.js.map +1 -1
  29. package/dist/commands/was/shared.d.ts +43 -3
  30. package/dist/commands/was/shared.d.ts.map +1 -1
  31. package/dist/commands/was/shared.js +82 -4
  32. package/dist/commands/was/shared.js.map +1 -1
  33. package/dist/commands/was/shell/completer.d.ts +24 -0
  34. package/dist/commands/was/shell/completer.d.ts.map +1 -0
  35. package/dist/commands/was/shell/completer.js +99 -0
  36. package/dist/commands/was/shell/completer.js.map +1 -0
  37. package/dist/commands/was/shell/dispatcher.d.ts +27 -0
  38. package/dist/commands/was/shell/dispatcher.d.ts.map +1 -0
  39. package/dist/commands/was/shell/dispatcher.js +227 -0
  40. package/dist/commands/was/shell/dispatcher.js.map +1 -0
  41. package/dist/commands/was/shell/session.d.ts +37 -0
  42. package/dist/commands/was/shell/session.d.ts.map +1 -0
  43. package/dist/commands/was/shell/session.js +67 -0
  44. package/dist/commands/was/shell/session.js.map +1 -0
  45. package/dist/commands/was/shell/tokenize.d.ts +19 -0
  46. package/dist/commands/was/shell/tokenize.d.ts.map +1 -0
  47. package/dist/commands/was/shell/tokenize.js +77 -0
  48. package/dist/commands/was/shell/tokenize.js.map +1 -0
  49. package/dist/commands/was/shell.d.ts +30 -0
  50. package/dist/commands/was/shell.d.ts.map +1 -0
  51. package/dist/commands/was/shell.js +170 -0
  52. package/dist/commands/was/shell.js.map +1 -0
  53. package/dist/commands/was/tree.d.ts +6 -1
  54. package/dist/commands/was/tree.d.ts.map +1 -1
  55. package/dist/commands/was/tree.js +12 -5
  56. package/dist/commands/was/tree.js.map +1 -1
  57. package/dist/commands/was.d.ts.map +1 -1
  58. package/dist/commands/was.js +34 -1
  59. package/dist/commands/was.js.map +1 -1
  60. package/dist/commands/zcap.d.ts +22 -2
  61. package/dist/commands/zcap.d.ts.map +1 -1
  62. package/dist/commands/zcap.js +75 -4
  63. package/dist/commands/zcap.js.map +1 -1
  64. package/dist/keys/seed.d.ts +21 -0
  65. package/dist/keys/seed.d.ts.map +1 -0
  66. package/dist/keys/seed.js +41 -0
  67. package/dist/keys/seed.js.map +1 -0
  68. package/dist/keys/webvh-signer.d.ts +18 -13
  69. package/dist/keys/webvh-signer.d.ts.map +1 -1
  70. package/dist/keys/webvh-signer.js +5 -20
  71. package/dist/keys/webvh-signer.js.map +1 -1
  72. package/dist/storage.d.ts.map +1 -1
  73. package/dist/storage.js +57 -10
  74. package/dist/storage.js.map +1 -1
  75. package/dist/was/address.d.ts +24 -0
  76. package/dist/was/address.d.ts.map +1 -1
  77. package/dist/was/address.js +49 -3
  78. package/dist/was/address.js.map +1 -1
  79. package/dist/was/capability.d.ts.map +1 -1
  80. package/dist/was/capability.js +4 -1
  81. package/dist/was/capability.js.map +1 -1
  82. package/dist/was/client.d.ts +10 -3
  83. package/dist/was/client.d.ts.map +1 -1
  84. package/dist/was/client.js +27 -6
  85. package/dist/was/client.js.map +1 -1
  86. package/dist/was/request-grant.d.ts +147 -0
  87. package/dist/was/request-grant.d.ts.map +1 -0
  88. package/dist/was/request-grant.js +256 -0
  89. package/dist/was/request-grant.js.map +1 -0
  90. package/dist/zcap/create.d.ts +1 -1
  91. package/dist/zcap/create.js +1 -1
  92. package/dist/zcap/delegate.d.ts +1 -1
  93. package/dist/zcap/delegate.js +1 -1
  94. package/dist/zcap/encoding.d.ts +17 -5
  95. package/dist/zcap/encoding.d.ts.map +1 -1
  96. package/dist/zcap/encoding.js +31 -17
  97. package/dist/zcap/encoding.js.map +1 -1
  98. package/dist/zcap/resolve.d.ts +17 -4
  99. package/dist/zcap/resolve.d.ts.map +1 -1
  100. package/dist/zcap/resolve.js +25 -8
  101. package/dist/zcap/resolve.js.map +1 -1
  102. package/package.json +22 -20
@@ -1,9 +1,27 @@
1
1
  import { Option } from 'commander';
2
2
  import { type Collection, type CollectionsList, type Resource, type CollectionResourcesList, type Space } from '@interop/was-client';
3
+ import type { ResolvedCapabilityTarget } from '../../was/capability.js';
3
4
  import { type ResolvedWasTarget } from '../../was/client.js';
5
+ /**
6
+ * Installs (or clears) the exit reporter used by `runAndExit`. With a reporter
7
+ * set, `runAndExit` never touches `process.exit`; call with no argument to
8
+ * restore the default process-exiting behavior.
9
+ *
10
+ * @param [reporter] {(code: number) => void}
11
+ * @returns {void}
12
+ */
13
+ export declare function setRunAndExitReporter(reporter?: (code: number) => void): void;
4
14
  /**
5
15
  * Awaits a command's run function and exits the process with its code when
6
- * non-zero -- the shared tail of every `was` command action.
16
+ * non-zero -- the shared tail of every `was` command action. When an exit
17
+ * reporter is installed (the interactive shell), the code is handed to the
18
+ * reporter instead, so a command failure returns control to the REPL loop
19
+ * rather than exiting the process.
20
+ *
21
+ * A run function normally reports its own errors and returns a code; an
22
+ * error that escapes anyway is caught here and reported as a one-line
23
+ * message with exit code 1, instead of surfacing as an unhandled rejection
24
+ * with a raw stack trace (which would also bypass the shell's reporter).
7
25
  *
8
26
  * @param run {Promise<number>}
9
27
  * @returns {Promise<void>}
@@ -20,20 +38,42 @@ export declare function runAndExit(run: Promise<number>): Promise<void>;
20
38
  export declare function serverOption(): Option;
21
39
  export declare function didOption(): Option;
22
40
  export declare function capabilityOption(): Option;
41
+ export declare function resourceIdOption(): Option;
23
42
  export declare function contentTypeOption(): Option;
24
43
  /**
25
44
  * Guards a run function against receiving both path- and capability-based
26
- * addressing (or neither).
45
+ * addressing (or neither). `--resource <id>` is part of capability
46
+ * addressing -- it names a resource beneath a collection capability -- so it
47
+ * is rejected first when no capability anchors it, whether or not a path was
48
+ * also given.
27
49
  *
28
50
  * @param options {object}
29
51
  * @param [options.address] {string}
30
52
  * @param [options.capability] {string}
53
+ * @param [options.resource] {string} The `--resource` value.
31
54
  * @returns {void}
32
55
  */
33
- export declare function assertOneAddressing({ address, capability }: {
56
+ export declare function assertOneAddressing({ address, capability, resource }: {
34
57
  address?: string;
35
58
  capability?: string;
59
+ resource?: string;
36
60
  }): void;
61
+ /**
62
+ * Applies `--resource <id>` to a resolved capability target, returning the
63
+ * target unchanged when no id was given. The id names a resource beneath a
64
+ * collection capability, and the resource handle hangs off that capability's
65
+ * collection handle, so it inherits the bound capability and the request
66
+ * stays an invocation of the received grant.
67
+ *
68
+ * @param options {object}
69
+ * @param options.resolved {ResolvedCapabilityTarget}
70
+ * @param [options.resourceId] {string} The `--resource` value.
71
+ * @returns {ResolvedCapabilityTarget}
72
+ */
73
+ export declare function withResourceId({ resolved, resourceId }: {
74
+ resolved: ResolvedCapabilityTarget;
75
+ resourceId?: string;
76
+ }): ResolvedCapabilityTarget;
37
77
  /**
38
78
  * Builds the canonical URL of a space, collection, or resource on its
39
79
  * server, for messages and output.
@@ -1 +1 @@
1
- {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../src/commands/was/shared.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,QAAQ,EACb,KAAK,uBAAuB,EAC5B,KAAK,KAAK,EACX,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAoB,KAAK,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAG9E;;;;;;GAMG;AACH,wBAAsB,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAKpE;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAKrC;AAED,wBAAgB,SAAS,IAAI,MAAM,CAKlC;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAMzC;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAK1C;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,OAAO,EACP,UAAU,EACX,EAAE;IACD,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,GAAG,IAAI,CAOP;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,MAAM,CAAC,EACrB,MAAM,EACN,OAAO,EACP,YAAY,EACZ,UAAU,EACX,EAAE;IACD,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;IACf,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,GAAG,MAAM,CAKT;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,WAAW,CAAC,EAC1B,MAAM,EACN,GAAG,EACJ,EAAE;IACD,MAAM,EAAE,MAAM,CAAA;IACd,GAAG,EAAE,OA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AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,IAAI,CAO3D;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,iBAAiB,GAAG;IAC1D,MAAM,EAAE,KAAK,GAAG,UAAU,GAAG,QAAQ,CAAA;IACrC,GAAG,EAAE,MAAM,CAAA;CACZ,CAgBA"}
@@ -10,15 +10,52 @@ import { WasError } from '@interop/was-client';
10
10
  import { parseWasAddress } from '../../was/address.js';
11
11
  import { resolveWasTarget } from '../../was/client.js';
12
12
  import { renderTable } from '../../table.js';
13
+ /**
14
+ * The active exit reporter, if any. When set (by the interactive shell),
15
+ * `runAndExit` reports the exit code through it instead of calling
16
+ * `process.exit`, keeping the tree shell-safe (no `runXxx` ever calls
17
+ * `process.exit`). Mirrors the `setWasClientFactory` seam convention.
18
+ */
19
+ let exitReporter;
20
+ /**
21
+ * Installs (or clears) the exit reporter used by `runAndExit`. With a reporter
22
+ * set, `runAndExit` never touches `process.exit`; call with no argument to
23
+ * restore the default process-exiting behavior.
24
+ *
25
+ * @param [reporter] {(code: number) => void}
26
+ * @returns {void}
27
+ */
28
+ export function setRunAndExitReporter(reporter) {
29
+ exitReporter = reporter;
30
+ }
13
31
  /**
14
32
  * Awaits a command's run function and exits the process with its code when
15
- * non-zero -- the shared tail of every `was` command action.
33
+ * non-zero -- the shared tail of every `was` command action. When an exit
34
+ * reporter is installed (the interactive shell), the code is handed to the
35
+ * reporter instead, so a command failure returns control to the REPL loop
36
+ * rather than exiting the process.
37
+ *
38
+ * A run function normally reports its own errors and returns a code; an
39
+ * error that escapes anyway is caught here and reported as a one-line
40
+ * message with exit code 1, instead of surfacing as an unhandled rejection
41
+ * with a raw stack trace (which would also bypass the shell's reporter).
16
42
  *
17
43
  * @param run {Promise<number>}
18
44
  * @returns {Promise<void>}
19
45
  */
20
46
  export async function runAndExit(run) {
21
- const code = await run;
47
+ let code;
48
+ try {
49
+ code = await run;
50
+ }
51
+ catch (err) {
52
+ console.error(err instanceof Error ? err.message : String(err));
53
+ code = 1;
54
+ }
55
+ if (exitReporter) {
56
+ exitReporter(code);
57
+ return;
58
+ }
22
59
  if (code !== 0) {
23
60
  process.exit(code);
24
61
  }
@@ -41,19 +78,30 @@ export function capabilityOption() {
41
78
  return new Option('--capability <ref>', 'a received capability (encoded string, JSON file, or stored zcap ' +
42
79
  'id/handle) instead of a path');
43
80
  }
81
+ export function resourceIdOption() {
82
+ return new Option('--resource <id>', 'the resource id to operate on beneath a collection --capability');
83
+ }
44
84
  export function contentTypeOption() {
45
85
  return new Option('--content-type <type>', 'send the payload as-is with this content type (skips JSON detection)');
46
86
  }
47
87
  /**
48
88
  * Guards a run function against receiving both path- and capability-based
49
- * addressing (or neither).
89
+ * addressing (or neither). `--resource <id>` is part of capability
90
+ * addressing -- it names a resource beneath a collection capability -- so it
91
+ * is rejected first when no capability anchors it, whether or not a path was
92
+ * also given.
50
93
  *
51
94
  * @param options {object}
52
95
  * @param [options.address] {string}
53
96
  * @param [options.capability] {string}
97
+ * @param [options.resource] {string} The `--resource` value.
54
98
  * @returns {void}
55
99
  */
56
- export function assertOneAddressing({ address, capability }) {
100
+ export function assertOneAddressing({ address, capability, resource }) {
101
+ if (resource !== undefined && !capability) {
102
+ throw new Error('--resource names a resource beneath a collection --capability; ' +
103
+ 'a path already names one.');
104
+ }
57
105
  if (address && capability) {
58
106
  throw new Error('Provide either a path or --capability, not both.');
59
107
  }
@@ -61,6 +109,36 @@ export function assertOneAddressing({ address, capability }) {
61
109
  throw new Error('Provide a path or --capability.');
62
110
  }
63
111
  }
112
+ /**
113
+ * Applies `--resource <id>` to a resolved capability target, returning the
114
+ * target unchanged when no id was given. The id names a resource beneath a
115
+ * collection capability, and the resource handle hangs off that capability's
116
+ * collection handle, so it inherits the bound capability and the request
117
+ * stays an invocation of the received grant.
118
+ *
119
+ * @param options {object}
120
+ * @param options.resolved {ResolvedCapabilityTarget}
121
+ * @param [options.resourceId] {string} The `--resource` value.
122
+ * @returns {ResolvedCapabilityTarget}
123
+ */
124
+ export function withResourceId({ resolved, resourceId }) {
125
+ if (resourceId === undefined) {
126
+ return resolved;
127
+ }
128
+ if (resolved.depth === 'resource') {
129
+ throw new Error('The capability already targets a resource; drop --resource.');
130
+ }
131
+ if (resolved.depth !== 'collection') {
132
+ throw new Error('--resource names a resource beneath a collection capability; ' +
133
+ `this one targets a ${resolved.depth}.`);
134
+ }
135
+ return {
136
+ ...resolved,
137
+ depth: 'resource',
138
+ handle: resolved.handle.resource(resourceId),
139
+ url: `${resolved.url.replace(/\/$/, '')}/${encodeURIComponent(resourceId)}`
140
+ };
141
+ }
64
142
  /**
65
143
  * Builds the canonical URL of a space, collection, or resource on its
66
144
  * server, for messages and output.
@@ -1 +1 @@
1
- {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../src/commands/was/shared.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,EACL,QAAQ,EAMT,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,gBAAgB,EAA0B,MAAM,qBAAqB,CAAA;AAC9E,OAAO,EAAE,WAAW,EAAe,MAAM,gBAAgB,CAAA;AAEzD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,GAAoB;IACnD,MAAM,IAAI,GAAG,MAAM,GAAG,CAAA;IACtB,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACpB,CAAC;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY;IAC1B,OAAO,IAAI,MAAM,CACf,gBAAgB,EAChB,6CAA6C,CAC9C,CAAA;AACH,CAAC;AAED,MAAM,UAAU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rD,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAgB;IACnD,OAAO,CAAC,GAAG,CACT,WAAW,CAAC;QACV,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;QACnD,IAAI;KACL,CAAC,CACH,CAAA;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,MAAyB;IAIvD,MAAM,GAAG,GAAG,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,UAAU,EAAE,MAAM,CAAC,UAAU;KAC9B,CAAC,CAAA;IACF,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IACjD,IAAI,MAAM,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;QACtC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,CAAA;IAC/B,CAAC;IACD,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,YAAY,CAAC,CAAA;IACxD,IAAI,MAAM,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QACpC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,CAAA;IACpC,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,GAAG,EAAE,CAAA;AAChE,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Tab-completion for the interactive shell's readline interface. Completes the
3
+ * first word (builtins plus top-level subcommand names and aliases), the
4
+ * subcommand after a command group (`space`, `collection`, `resource`,
5
+ * `resource-meta`, `policy`), and -- at the root working directory -- the first
6
+ * path segment of a path verb from the local space registry (handles and ids).
7
+ * Network-backed completion (collection/resource listings) is deferred.
8
+ */
9
+ import type { Command } from 'commander';
10
+ import type { ShellSession } from './session.js';
11
+ /**
12
+ * Builds the readline completer function bound to the command tree and shell
13
+ * session.
14
+ *
15
+ * @param options {object}
16
+ * @param options.tree {Command} The `was` command tree.
17
+ * @param options.session {ShellSession}
18
+ * @returns {(line: string) => Promise<[string[], string]>}
19
+ */
20
+ export declare function makeShellCompleter({ tree, session }: {
21
+ tree: Command;
22
+ session: ShellSession;
23
+ }): (line: string) => Promise<[string[], string]>;
24
+ //# sourceMappingURL=completer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"completer.d.ts","sourceRoot":"","sources":["../../../../src/commands/was/shell/completer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAExC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAkFhD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,IAAI,EACJ,OAAO,EACR,EAAE;IACD,IAAI,EAAE,OAAO,CAAA;IACb,OAAO,EAAE,YAAY,CAAA;CACtB,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,MAAM,CAAC,CAAC,CA6BhD"}
@@ -0,0 +1,99 @@
1
+ import { listSpaceRecords } from '../../../was/registry.js';
2
+ /** The shell builtins, offered as first-word completions. */
3
+ const BUILTINS = ['cd', 'use', 'pwd', 'connect', 'did', 'help', 'exit', 'quit'];
4
+ /** Top-level verbs that take a WAS path as their first positional argument. */
5
+ const PATH_VERBS = new Set([
6
+ 'ls',
7
+ 'get',
8
+ 'put',
9
+ 'rm',
10
+ 'publish',
11
+ 'unpublish',
12
+ 'grant'
13
+ ]);
14
+ /**
15
+ * Collects a command's own name plus its aliases.
16
+ *
17
+ * @param command {Command}
18
+ * @returns {string[]}
19
+ */
20
+ function namesOf(command) {
21
+ return [command.name(), ...command.aliases()];
22
+ }
23
+ /**
24
+ * Finds a direct subcommand of a command by name or alias.
25
+ *
26
+ * @param options {object}
27
+ * @param options.parent {Command}
28
+ * @param options.name {string}
29
+ * @returns {Command | undefined}
30
+ */
31
+ function findSubcommand({ parent, name }) {
32
+ return parent.commands.find(command => namesOf(command).includes(name));
33
+ }
34
+ /**
35
+ * Narrows a candidate list to those starting with the word being edited,
36
+ * falling back to the full list when nothing matches (so a bare Tab lists
37
+ * everything).
38
+ *
39
+ * @param options {object}
40
+ * @param options.candidates {string[]}
41
+ * @param options.editing {string}
42
+ * @returns {string[]}
43
+ */
44
+ function filterHits({ candidates, editing }) {
45
+ const hits = candidates.filter(candidate => candidate.startsWith(editing));
46
+ return hits.length > 0 ? hits : candidates;
47
+ }
48
+ /**
49
+ * Lists the registry space completions (handles and space ids).
50
+ *
51
+ * @returns {Promise<string[]>}
52
+ */
53
+ async function spaceCompletions() {
54
+ const records = await listSpaceRecords();
55
+ const out = [];
56
+ for (const { record, meta } of records) {
57
+ if (meta?.handle) {
58
+ out.push(meta.handle);
59
+ }
60
+ out.push(record.id);
61
+ }
62
+ return out;
63
+ }
64
+ /**
65
+ * Builds the readline completer function bound to the command tree and shell
66
+ * session.
67
+ *
68
+ * @param options {object}
69
+ * @param options.tree {Command} The `was` command tree.
70
+ * @param options.session {ShellSession}
71
+ * @returns {(line: string) => Promise<[string[], string]>}
72
+ */
73
+ export function makeShellCompleter({ tree, session }) {
74
+ return async function completer(line) {
75
+ const words = line.split(/\s+/);
76
+ const editing = words[words.length - 1] ?? '';
77
+ if (words.length <= 1) {
78
+ const candidates = [...BUILTINS, ...tree.commands.flatMap(namesOf)].sort();
79
+ return [filterHits({ candidates, editing }), editing];
80
+ }
81
+ const first = words[0];
82
+ if (words.length === 2) {
83
+ const group = findSubcommand({ parent: tree, name: first });
84
+ if (group && group.commands.length > 0) {
85
+ const candidates = group.commands.flatMap(namesOf).sort();
86
+ return [filterHits({ candidates, editing }), editing];
87
+ }
88
+ if (session.cwd.length === 0 && PATH_VERBS.has(first)) {
89
+ const candidates = (await spaceCompletions()).sort();
90
+ return [
91
+ candidates.filter(candidate => candidate.startsWith(editing)),
92
+ editing
93
+ ];
94
+ }
95
+ }
96
+ return [[], editing];
97
+ };
98
+ }
99
+ //# sourceMappingURL=completer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"completer.js","sourceRoot":"","sources":["../../../../src/commands/was/shell/completer.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAG3D,6DAA6D;AAC7D,MAAM,QAAQ,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;AAE/E,+EAA+E;AAC/E,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC;IACzB,IAAI;IACJ,KAAK;IACL,KAAK;IACL,IAAI;IACJ,SAAS;IACT,WAAW;IACX,OAAO;CACR,CAAC,CAAA;AAEF;;;;;GAKG;AACH,SAAS,OAAO,CAAC,OAAgB;IAC/B,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAAA;AAC/C,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,cAAc,CAAC,EACtB,MAAM,EACN,IAAI,EAIL;IACC,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAA;AACzE,CAAC;AAED;;;;;;;;;GASG;AACH,SAAS,UAAU,CAAC,EAClB,UAAU,EACV,OAAO,EAIR;IACC,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC,OAAO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YACvB,MAAM,KAAK,GAAG,cAAc,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;YAC3D,IAAI,KAAK,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACvC,MAAM,UAAU,GAAG,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAA;gBACzD,OAAO,CAAC,UAAU,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,CAAC,CAAA;YACvD,CAAC;YACD,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC,IAAI,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;gBACtD,MAAM,UAAU,GAAG,CAAC,MAAM,gBAAgB,EAAE,CAAC,CAAC,IAAI,EAAE,CAAA;gBACpD,OAAO;oBACL,UAAU,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;oBAC7D,OAAO;iBACR,CAAA;YACH,CAAC;QACH,CAAC;QAED,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC,CAAA;IACtB,CAAC,CAAA;AACH,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * The interactive shell's per-line dispatcher: tokenizes a line, handles the
3
+ * builtins (`cd`/`use`, `pwd`, `connect`, `did`, `help`, `exit`/`quit`, blank
4
+ * and `#`-comment lines, and a rejected nested `shell`), guards stdin-payload
5
+ * commands that would fight readline for stdin, then hands the rest to the
6
+ * shared command tree via `parseAsync`. Command errors are reported by the
7
+ * commands themselves (and swallowed as `CommanderError`s here), so a bad line
8
+ * never stops the loop.
9
+ */
10
+ import { Command } from 'commander';
11
+ import { type ShellSession } from './session.js';
12
+ /**
13
+ * Builds the per-line dispatch function bound to the command tree. The
14
+ * returned function reports `'exit'` when the loop should stop.
15
+ *
16
+ * @param options {object}
17
+ * @param options.tree {Command}
18
+ * @returns {(options: {line: string, session: ShellSession, output: NodeJS.WritableStream}) => Promise<'exit' | void>}
19
+ */
20
+ export declare function makeWasShellDispatcher({ tree }: {
21
+ tree: Command;
22
+ }): (options: {
23
+ line: string;
24
+ session: ShellSession;
25
+ output: NodeJS.WritableStream;
26
+ }) => Promise<'exit' | void>;
27
+ //# sourceMappingURL=dispatcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispatcher.d.ts","sourceRoot":"","sources":["../../../../src/commands/was/shell/dispatcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,OAAO,EAAkB,MAAM,WAAW,CAAA;AAEnD,OAAO,EAA+B,KAAK,YAAY,EAAE,MAAM,cAAc,CAAA;AAuK7E;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,EACrC,IAAI,EACL,EAAE;IACD,IAAI,EAAE,OAAO,CAAA;CACd,GAAG,CAAC,OAAO,EAAE;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,YAAY,CAAA;IACrB,MAAM,EAAE,MAAM,CAAC,cAAc,CAAA;CAC9B,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAgF3B"}
@@ -0,0 +1,227 @@
1
+ /**
2
+ * The interactive shell's per-line dispatcher: tokenizes a line, handles the
3
+ * builtins (`cd`/`use`, `pwd`, `connect`, `did`, `help`, `exit`/`quit`, blank
4
+ * and `#`-comment lines, and a rejected nested `shell`), guards stdin-payload
5
+ * commands that would fight readline for stdin, then hands the rest to the
6
+ * shared command tree via `parseAsync`. Command errors are reported by the
7
+ * commands themselves (and swallowed as `CommanderError`s here), so a bad line
8
+ * never stops the loop.
9
+ */
10
+ import { CommanderError } from 'commander';
11
+ import { tokenizeShellLine } from './tokenize.js';
12
+ import { formatCwd, resolveCwdChange } from './session.js';
13
+ /**
14
+ * A summary of the shell builtins, printed by `help` before commander's own
15
+ * command help.
16
+ */
17
+ const BUILTINS_HELP = `Shell builtins:
18
+ cd / use <path> change the current directory (SPACE[/COLLECTION], .., /, or a full space URL)
19
+ pwd print the current directory and effective server/DID
20
+ connect <url> set the session WAS server URL (WAS_SERVER_URL)
21
+ did <ref> set the session signing DID (WAS_DID)
22
+ help show this summary and the command help
23
+ exit / quit leave the shell (Ctrl+D also works)
24
+
25
+ `;
26
+ /**
27
+ * Options on the stdin-reading verbs that take a following value; used to
28
+ * count positional arguments when guarding stdin payloads and bare `ls`.
29
+ */
30
+ const VALUE_FLAGS = new Set([
31
+ '--server',
32
+ '--did',
33
+ '--capability',
34
+ '--resource',
35
+ '--content-type',
36
+ '--output'
37
+ ]);
38
+ const STDIN_GUARD_MESSAGE = 'Provide a file argument inside the shell (the shell owns stdin).';
39
+ /**
40
+ * Splits a verb's argument tokens into positionals and notes whether
41
+ * `--capability` was given, skipping the values of value-taking flags. Handles
42
+ * the `--flag=value` form (no separate value token) as well.
43
+ *
44
+ * @param rest {string[]}
45
+ * @returns {{positionals: string[], hasCapability: boolean}}
46
+ */
47
+ function splitArgs(rest) {
48
+ const positionals = [];
49
+ let hasCapability = false;
50
+ for (let index = 0; index < rest.length; index++) {
51
+ const token = rest[index];
52
+ if (token.startsWith('-')) {
53
+ const name = token.split('=')[0];
54
+ if (name === '--capability') {
55
+ hasCapability = true;
56
+ }
57
+ if (!token.includes('=') && VALUE_FLAGS.has(name)) {
58
+ index++;
59
+ }
60
+ continue;
61
+ }
62
+ positionals.push(token);
63
+ }
64
+ return { positionals, hasCapability };
65
+ }
66
+ /**
67
+ * Returns a guard message when a line would run a stdin-reading verb (`put`,
68
+ * `add`, or `space import`) with no file argument -- which cannot work while
69
+ * readline owns stdin -- or undefined when the line is safe to dispatch.
70
+ *
71
+ * @param tokens {string[]}
72
+ * @returns {string | undefined}
73
+ */
74
+ function guardStdinPayload(tokens) {
75
+ const [head, ...tail] = tokens;
76
+ let group;
77
+ let verb = head;
78
+ let rest = tail;
79
+ if (head === 'resource' || head === 'res' || head === 'space') {
80
+ group = head;
81
+ verb = tail[0];
82
+ rest = tail.slice(1);
83
+ }
84
+ if (verb === 'put' || verb === 'add') {
85
+ const { positionals, hasCapability } = splitArgs(rest);
86
+ const fileProvided = hasCapability
87
+ ? positionals.length >= 1
88
+ : positionals.length >= 2;
89
+ if (!fileProvided) {
90
+ return STDIN_GUARD_MESSAGE;
91
+ }
92
+ }
93
+ if (group === 'space' && verb === 'import') {
94
+ const { positionals } = splitArgs(rest);
95
+ if (positionals.length < 2) {
96
+ return STDIN_GUARD_MESSAGE;
97
+ }
98
+ }
99
+ return undefined;
100
+ }
101
+ /**
102
+ * Appends `.` to a bare `ls` when a directory is selected, so it lists the
103
+ * current directory (the address base turns `.` into the cwd). At the root
104
+ * `ls` has nothing to list and is left alone.
105
+ *
106
+ * @param options {object}
107
+ * @param options.tokens {string[]}
108
+ * @param options.session {ShellSession}
109
+ * @returns {string[]}
110
+ */
111
+ function appendCwdForBareLs({ tokens, session }) {
112
+ if (tokens[0] !== 'ls' || session.cwd.length === 0) {
113
+ return tokens;
114
+ }
115
+ const { positionals } = splitArgs(tokens.slice(1));
116
+ return positionals.length > 0 ? tokens : [...tokens, '.'];
117
+ }
118
+ /**
119
+ * Handles `cd`/`use`: updates the session cwd, adopting a full space URL's
120
+ * origin as the server default.
121
+ */
122
+ function handleCd({ session, arg, output }) {
123
+ if (arg === undefined) {
124
+ session.cwd = [];
125
+ return;
126
+ }
127
+ try {
128
+ const { cwd, server } = resolveCwdChange({ cwd: session.cwd, arg });
129
+ session.cwd = cwd;
130
+ if (server) {
131
+ process.env.WAS_SERVER_URL = server;
132
+ }
133
+ }
134
+ catch (err) {
135
+ output.write(`${err.message}\n`);
136
+ }
137
+ }
138
+ /**
139
+ * Handles `pwd`: prints the current directory and the effective server/DID.
140
+ */
141
+ function handlePwd({ session, output }) {
142
+ output.write(`${formatCwd(session.cwd)}\n`);
143
+ output.write(`server: ${process.env.WAS_SERVER_URL ?? '(unset)'}\n`);
144
+ output.write(`did: ${process.env.WAS_DID ?? '(unset)'}\n`);
145
+ }
146
+ /**
147
+ * Builds the per-line dispatch function bound to the command tree. The
148
+ * returned function reports `'exit'` when the loop should stop.
149
+ *
150
+ * @param options {object}
151
+ * @param options.tree {Command}
152
+ * @returns {(options: {line: string, session: ShellSession, output: NodeJS.WritableStream}) => Promise<'exit' | void>}
153
+ */
154
+ export function makeWasShellDispatcher({ tree }) {
155
+ return async function dispatch({ line, session, output }) {
156
+ const trimmed = line.trim();
157
+ if (trimmed === '' || trimmed.startsWith('#')) {
158
+ return;
159
+ }
160
+ let tokens;
161
+ try {
162
+ tokens = tokenizeShellLine(trimmed);
163
+ }
164
+ catch (err) {
165
+ output.write(`${err.message}\n`);
166
+ return;
167
+ }
168
+ if (tokens.length === 0) {
169
+ return;
170
+ }
171
+ const [command, ...args] = tokens;
172
+ switch (command) {
173
+ case 'exit':
174
+ case 'quit':
175
+ return 'exit';
176
+ case 'cd':
177
+ case 'use':
178
+ handleCd({ session, arg: args[0], output });
179
+ return;
180
+ case 'pwd':
181
+ handlePwd({ session, output });
182
+ return;
183
+ case 'connect':
184
+ if (!args[0]) {
185
+ output.write('Usage: connect <url>\n');
186
+ return;
187
+ }
188
+ process.env.WAS_SERVER_URL = args[0];
189
+ output.write(`server: ${args[0]}\n`);
190
+ return;
191
+ case 'did':
192
+ if (!args[0]) {
193
+ output.write('Usage: did <ref>\n');
194
+ return;
195
+ }
196
+ process.env.WAS_DID = args[0];
197
+ output.write(`did: ${args[0]}\n`);
198
+ return;
199
+ case 'help':
200
+ output.write(BUILTINS_HELP);
201
+ tree.outputHelp();
202
+ return;
203
+ case 'shell':
204
+ output.write('Already inside a shell; nested shells are not supported.\n');
205
+ return;
206
+ }
207
+ const guardMessage = guardStdinPayload(tokens);
208
+ if (guardMessage) {
209
+ output.write(`${guardMessage}\n`);
210
+ return;
211
+ }
212
+ try {
213
+ await tree.parseAsync(appendCwdForBareLs({ tokens, session }), {
214
+ from: 'user'
215
+ });
216
+ }
217
+ catch (err) {
218
+ // exitOverride throws after commander has already written help or the
219
+ // usage/error message through the configured output; nothing more to do.
220
+ if (err instanceof CommanderError) {
221
+ return;
222
+ }
223
+ output.write(`${err.message}\n`);
224
+ }
225
+ };
226
+ }
227
+ //# sourceMappingURL=dispatcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispatcher.js","sourceRoot":"","sources":["../../../../src/commands/was/shell/dispatcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAW,cAAc,EAAE,MAAM,WAAW,CAAA;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAqB,MAAM,cAAc,CAAA;AAE7E;;;GAGG;AACH,MAAM,aAAa,GAAG;;;;;;;;CAQrB,CAAA;AAED;;;GAGG;AACH,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC;IAC1B,UAAU;IACV,OAAO;IACP,cAAc;IACd,YAAY;IACZ,gBAAgB;IAChB,UAAU;CACX,CAAC,CAAA;AAEF,MAAM,mBAAmB,GACvB,kEAAkE,CAAA;AAEpE;;;;;;;GAOG;AACH,SAAS,SAAS,CAAC,IAAc;IAI/B,MAAM,WAAW,GAAa,EAAE,CAAA;IAChC,IAAI,aAAa,GAAG,KAAK,CAAA;IACzB,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QACjD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAA;QACzB,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YAC1B,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;YAChC,IAAI,IAAI,KAAK,cAAc,EAAE,CAAC;gBAC5B,aAAa,GAAG,IAAI,CAAA;YACtB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