@interop/did-cli 0.6.0 → 0.8.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/CHANGELOG.md +64 -1
- package/README.md +144 -6
- package/dist/commands/did.d.ts.map +1 -1
- package/dist/commands/did.js +41 -12
- package/dist/commands/did.js.map +1 -1
- package/dist/commands/key.d.ts.map +1 -1
- package/dist/commands/key.js +46 -8
- package/dist/commands/key.js.map +1 -1
- package/dist/commands/was/collection.d.ts +121 -0
- package/dist/commands/was/collection.d.ts.map +1 -0
- package/dist/commands/was/collection.js +316 -0
- package/dist/commands/was/collection.js.map +1 -0
- package/dist/commands/was/policy.d.ts +50 -0
- package/dist/commands/was/policy.d.ts.map +1 -0
- package/dist/commands/was/policy.js +133 -0
- package/dist/commands/was/policy.js.map +1 -0
- package/dist/commands/was/publish.d.ts +67 -0
- package/dist/commands/was/publish.d.ts.map +1 -0
- package/dist/commands/was/publish.js +151 -0
- package/dist/commands/was/publish.js.map +1 -0
- package/dist/commands/was/resource.d.ts +148 -0
- package/dist/commands/was/resource.d.ts.map +1 -0
- package/dist/commands/was/resource.js +402 -0
- package/dist/commands/was/resource.js.map +1 -0
- package/dist/commands/was/shared.d.ts +156 -0
- package/dist/commands/was/shared.d.ts.map +1 -0
- package/dist/commands/was/shared.js +237 -0
- package/dist/commands/was/shared.js.map +1 -0
- package/dist/commands/was/space.d.ts +196 -0
- package/dist/commands/was/space.d.ts.map +1 -0
- package/dist/commands/was/space.js +516 -0
- package/dist/commands/was/space.js.map +1 -0
- package/dist/commands/was/tree.d.ts +44 -0
- package/dist/commands/was/tree.d.ts.map +1 -0
- package/dist/commands/was/tree.js +135 -0
- package/dist/commands/was/tree.js.map +1 -0
- package/dist/commands/was.d.ts +29 -496
- package/dist/commands/was.d.ts.map +1 -1
- package/dist/commands/was.js +84 -1473
- package/dist/commands/was.js.map +1 -1
- package/dist/commands/zcap.d.ts +22 -2
- package/dist/commands/zcap.d.ts.map +1 -1
- package/dist/commands/zcap.js +6 -20
- package/dist/commands/zcap.js.map +1 -1
- package/dist/meta.js +1 -1
- package/dist/meta.js.map +1 -1
- package/dist/was/capability.d.ts +10 -13
- package/dist/was/capability.d.ts.map +1 -1
- package/dist/was/capability.js +1 -59
- package/dist/was/capability.js.map +1 -1
- package/dist/zcap/delegate.d.ts +2 -2
- package/dist/zcap/delegate.js +2 -2
- package/dist/zcap/resolve.d.ts +15 -0
- package/dist/zcap/resolve.d.ts.map +1 -0
- package/dist/zcap/resolve.js +55 -0
- package/dist/zcap/resolve.js.map +1 -0
- package/package.json +29 -16
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `was resource` run functions: add (server-generated id), put (upsert at a
|
|
3
|
+
* known id), get (JSON or binary), list, delete, and the resource-metadata
|
|
4
|
+
* verbs `meta get` / `meta put`. Each addressing-capable verb accepts either
|
|
5
|
+
* a path or a `--capability` targeting the resource or its collection.
|
|
6
|
+
*/
|
|
7
|
+
import { readFile } from 'node:fs/promises';
|
|
8
|
+
import { resolveWasTarget } from '../../was/client.js';
|
|
9
|
+
import { resolveCapabilityTarget } from '../../was/capability.js';
|
|
10
|
+
import { readPayload, writeResourceOutput } from '../../was/io.js';
|
|
11
|
+
import { assertOneAddressing, printResourceListing, reportError, requireCollectionTarget, requireResourceTarget, wasUrl } from './shared.js';
|
|
12
|
+
/**
|
|
13
|
+
* Resolves a single resource handle and its URL from either a path address
|
|
14
|
+
* or a `--capability` targeting a resource -- the shared addressing logic of
|
|
15
|
+
* the resource verbs that operate on one resource (`put`, `get`, `meta`).
|
|
16
|
+
*
|
|
17
|
+
* @param options {object}
|
|
18
|
+
* @param [options.address] {string} The resource address.
|
|
19
|
+
* @param [options.capability] {string} A capability reference instead of
|
|
20
|
+
* a path.
|
|
21
|
+
* @param options.verb {string} The verb name, for the capability-depth
|
|
22
|
+
* error message.
|
|
23
|
+
* @param [options.server] {string} The server base URL.
|
|
24
|
+
* @param [options.did] {string} The signing DID or stored-DID handle.
|
|
25
|
+
* @returns {Promise<{resource: Resource, url: string}>}
|
|
26
|
+
*/
|
|
27
|
+
async function resolveResourceHandle({ address, capability, verb, server, did }) {
|
|
28
|
+
assertOneAddressing({ address, capability });
|
|
29
|
+
if (capability) {
|
|
30
|
+
const resolved = await resolveCapabilityTarget({ ref: capability, did });
|
|
31
|
+
if (resolved.depth !== 'resource') {
|
|
32
|
+
throw new Error(`The capability targets a ${resolved.depth}; ` +
|
|
33
|
+
`${verb} needs a resource capability.`);
|
|
34
|
+
}
|
|
35
|
+
return { resource: resolved.handle, url: resolved.url };
|
|
36
|
+
}
|
|
37
|
+
const target = requireResourceTarget({
|
|
38
|
+
target: await resolveWasTarget({
|
|
39
|
+
address: address,
|
|
40
|
+
server,
|
|
41
|
+
did
|
|
42
|
+
}),
|
|
43
|
+
address: address
|
|
44
|
+
});
|
|
45
|
+
const resource = target.client
|
|
46
|
+
.space(target.spaceId)
|
|
47
|
+
.collection(target.collectionId)
|
|
48
|
+
.resource(target.resourceId);
|
|
49
|
+
const url = wasUrl({
|
|
50
|
+
server: target.server,
|
|
51
|
+
spaceId: target.spaceId,
|
|
52
|
+
collectionId: target.collectionId,
|
|
53
|
+
resourceId: target.resourceId
|
|
54
|
+
});
|
|
55
|
+
return { resource, url };
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Adds a resource to a collection (server-generated id) and prints the
|
|
59
|
+
* `{ id, url, contentType }` add result. The collection comes from a path
|
|
60
|
+
* or a `--capability` targeting one.
|
|
61
|
+
*
|
|
62
|
+
* @param options {object}
|
|
63
|
+
* @param [options.address] {string} The collection address.
|
|
64
|
+
* @param [options.capability] {string} A capability reference instead of
|
|
65
|
+
* a path.
|
|
66
|
+
* @param [options.file] {string} The payload file; stdin when omitted.
|
|
67
|
+
* @param [options.contentType] {string} Explicit payload content type.
|
|
68
|
+
* @param [options.server] {string} The server base URL.
|
|
69
|
+
* @param [options.did] {string} The signing DID or stored-DID handle.
|
|
70
|
+
* @returns {Promise<number>} The process exit code.
|
|
71
|
+
*/
|
|
72
|
+
export async function runResourceAdd(options) {
|
|
73
|
+
try {
|
|
74
|
+
assertOneAddressing(options);
|
|
75
|
+
let collection;
|
|
76
|
+
if (options.capability) {
|
|
77
|
+
const resolved = await resolveCapabilityTarget({
|
|
78
|
+
ref: options.capability,
|
|
79
|
+
did: options.did
|
|
80
|
+
});
|
|
81
|
+
if (resolved.depth !== 'collection') {
|
|
82
|
+
throw new Error(`The capability targets a ${resolved.depth}; ` +
|
|
83
|
+
'add needs a collection capability.');
|
|
84
|
+
}
|
|
85
|
+
collection = resolved.handle;
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
const target = requireCollectionTarget({
|
|
89
|
+
target: await resolveWasTarget({
|
|
90
|
+
address: options.address,
|
|
91
|
+
server: options.server,
|
|
92
|
+
did: options.did
|
|
93
|
+
}),
|
|
94
|
+
address: options.address
|
|
95
|
+
});
|
|
96
|
+
collection = target.client
|
|
97
|
+
.space(target.spaceId)
|
|
98
|
+
.collection(target.collectionId);
|
|
99
|
+
}
|
|
100
|
+
const payload = await readPayload({
|
|
101
|
+
file: options.file,
|
|
102
|
+
contentType: options.contentType
|
|
103
|
+
});
|
|
104
|
+
const result = await collection.add(payload.data, {
|
|
105
|
+
...(payload.contentType !== undefined && {
|
|
106
|
+
contentType: payload.contentType
|
|
107
|
+
})
|
|
108
|
+
});
|
|
109
|
+
console.log(JSON.stringify(result, null, 2));
|
|
110
|
+
return 0;
|
|
111
|
+
}
|
|
112
|
+
catch (err) {
|
|
113
|
+
return reportError({ action: 'add the resource', err });
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Creates or replaces a resource at a known id (upsert) and prints
|
|
118
|
+
* `{ id, url }`. The resource comes from a path or a `--capability`
|
|
119
|
+
* targeting one.
|
|
120
|
+
*
|
|
121
|
+
* @param options {object}
|
|
122
|
+
* @param [options.address] {string} The resource address.
|
|
123
|
+
* @param [options.capability] {string} A capability reference instead of
|
|
124
|
+
* a path.
|
|
125
|
+
* @param [options.file] {string} The payload file; stdin when omitted.
|
|
126
|
+
* @param [options.contentType] {string} Explicit payload content type.
|
|
127
|
+
* @param [options.server] {string} The server base URL.
|
|
128
|
+
* @param [options.did] {string} The signing DID or stored-DID handle.
|
|
129
|
+
* @returns {Promise<number>} The process exit code.
|
|
130
|
+
*/
|
|
131
|
+
export async function runResourcePut(options) {
|
|
132
|
+
try {
|
|
133
|
+
const { resource, url } = await resolveResourceHandle({
|
|
134
|
+
...options,
|
|
135
|
+
verb: 'put'
|
|
136
|
+
});
|
|
137
|
+
const payload = await readPayload({
|
|
138
|
+
file: options.file,
|
|
139
|
+
contentType: options.contentType
|
|
140
|
+
});
|
|
141
|
+
await resource.put(payload.data, {
|
|
142
|
+
...(payload.contentType !== undefined && {
|
|
143
|
+
contentType: payload.contentType
|
|
144
|
+
})
|
|
145
|
+
});
|
|
146
|
+
console.log(JSON.stringify({ id: resource.id, url }, null, 2));
|
|
147
|
+
return 0;
|
|
148
|
+
}
|
|
149
|
+
catch (err) {
|
|
150
|
+
return reportError({ action: 'put the resource', err });
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Reads a resource: JSON pretty-printed to stdout, binary written raw
|
|
155
|
+
* (`--output` for files). The resource comes from a path or a
|
|
156
|
+
* `--capability` targeting one.
|
|
157
|
+
*
|
|
158
|
+
* @param options {object}
|
|
159
|
+
* @param [options.address] {string} The resource address.
|
|
160
|
+
* @param [options.capability] {string} A capability reference instead of
|
|
161
|
+
* a path.
|
|
162
|
+
* @param [options.output] {string} The output file path; stdout when
|
|
163
|
+
* omitted.
|
|
164
|
+
* @param [options.server] {string} The server base URL.
|
|
165
|
+
* @param [options.did] {string} The signing DID or stored-DID handle.
|
|
166
|
+
* @returns {Promise<number>} The process exit code.
|
|
167
|
+
*/
|
|
168
|
+
export async function runResourceGet(options) {
|
|
169
|
+
try {
|
|
170
|
+
const { resource, url } = await resolveResourceHandle({
|
|
171
|
+
...options,
|
|
172
|
+
verb: 'get'
|
|
173
|
+
});
|
|
174
|
+
const data = await resource.get();
|
|
175
|
+
if (data === null) {
|
|
176
|
+
console.error(`Not found (or not visible to you): ${url}`);
|
|
177
|
+
return 1;
|
|
178
|
+
}
|
|
179
|
+
await writeResourceOutput({ data, output: options.output });
|
|
180
|
+
return 0;
|
|
181
|
+
}
|
|
182
|
+
catch (err) {
|
|
183
|
+
return reportError({ action: 'get the resource', err });
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Reads a resource's metadata object (server-managed `contentType` / `size` /
|
|
188
|
+
* timestamps plus the user-writable `custom`) and pretty-prints it. The
|
|
189
|
+
* resource comes from a path or a `--capability` targeting one.
|
|
190
|
+
*
|
|
191
|
+
* @param options {object}
|
|
192
|
+
* @param [options.address] {string} The resource address.
|
|
193
|
+
* @param [options.capability] {string} A capability reference instead of
|
|
194
|
+
* a path.
|
|
195
|
+
* @param [options.server] {string} The server base URL.
|
|
196
|
+
* @param [options.did] {string} The signing DID or stored-DID handle.
|
|
197
|
+
* @returns {Promise<number>} The process exit code.
|
|
198
|
+
*/
|
|
199
|
+
export async function runResourceMetaGet(options) {
|
|
200
|
+
try {
|
|
201
|
+
const { resource, url } = await resolveResourceHandle({
|
|
202
|
+
...options,
|
|
203
|
+
verb: 'meta get'
|
|
204
|
+
});
|
|
205
|
+
const meta = await resource.meta();
|
|
206
|
+
if (meta === null) {
|
|
207
|
+
console.error(`Not found (or not visible to you): ${url}`);
|
|
208
|
+
return 1;
|
|
209
|
+
}
|
|
210
|
+
console.log(JSON.stringify(meta, null, 2));
|
|
211
|
+
return 0;
|
|
212
|
+
}
|
|
213
|
+
catch (err) {
|
|
214
|
+
return reportError({ action: 'get the resource metadata', err });
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Parses the repeatable `--tag key=value` flags into a tags record. Returns
|
|
219
|
+
* `undefined` when no `--tag` was given (so the caller can leave tags
|
|
220
|
+
* untouched).
|
|
221
|
+
*
|
|
222
|
+
* @param rawTags {string[]} The raw `key=value` strings, as collected.
|
|
223
|
+
* @returns {Record<string, string> | undefined}
|
|
224
|
+
*/
|
|
225
|
+
function parseTags(rawTags) {
|
|
226
|
+
if (rawTags.length === 0) {
|
|
227
|
+
return undefined;
|
|
228
|
+
}
|
|
229
|
+
const tags = {};
|
|
230
|
+
for (const entry of rawTags) {
|
|
231
|
+
const separator = entry.indexOf('=');
|
|
232
|
+
const key = separator === -1 ? entry : entry.slice(0, separator);
|
|
233
|
+
if (separator === -1 || key === '') {
|
|
234
|
+
throw new Error(`Invalid --tag "${entry}"; expected key=value.`);
|
|
235
|
+
}
|
|
236
|
+
tags[key] = entry.slice(separator + 1);
|
|
237
|
+
}
|
|
238
|
+
return tags;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Parses the `--json` escape hatch -- inline JSON, or a path to a JSON file
|
|
242
|
+
* when the value does not itself parse -- into a `custom` metadata object.
|
|
243
|
+
*
|
|
244
|
+
* @param input {string} Inline JSON or a JSON file path.
|
|
245
|
+
* @returns {Promise<ResourceMetadataCustom>}
|
|
246
|
+
*/
|
|
247
|
+
async function parseCustomJson(input) {
|
|
248
|
+
let parsed;
|
|
249
|
+
try {
|
|
250
|
+
parsed = JSON.parse(input);
|
|
251
|
+
}
|
|
252
|
+
catch {
|
|
253
|
+
let contents;
|
|
254
|
+
try {
|
|
255
|
+
contents = await readFile(input, 'utf8');
|
|
256
|
+
}
|
|
257
|
+
catch {
|
|
258
|
+
throw new Error(`--json is neither valid JSON nor a readable file: ${input}`);
|
|
259
|
+
}
|
|
260
|
+
parsed = JSON.parse(contents);
|
|
261
|
+
}
|
|
262
|
+
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
|
|
263
|
+
throw new Error('--json must be a JSON object (the custom metadata).');
|
|
264
|
+
}
|
|
265
|
+
return parsed;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Updates a resource's user-writable metadata and prints the resulting
|
|
269
|
+
* metadata. `--name`/`--tag` are read-modify-write sugar that preserve the
|
|
270
|
+
* other field; giving both, or `--json`, is a full `custom` replacement so
|
|
271
|
+
* any omitted property is cleared. The resource comes from a path or a
|
|
272
|
+
* `--capability` targeting one.
|
|
273
|
+
*
|
|
274
|
+
* @param options {object}
|
|
275
|
+
* @param [options.address] {string} The resource address.
|
|
276
|
+
* @param [options.capability] {string} A capability reference instead of
|
|
277
|
+
* a path.
|
|
278
|
+
* @param [options.name] {string} The resource's display name.
|
|
279
|
+
* @param options.tag {string[]} Repeatable `key=value` tag pairs.
|
|
280
|
+
* @param [options.json] {string} Full `custom` JSON (inline or a file
|
|
281
|
+
* path); mutually exclusive with `--name`/`--tag`.
|
|
282
|
+
* @param [options.server] {string} The server base URL.
|
|
283
|
+
* @param [options.did] {string} The signing DID or stored-DID handle.
|
|
284
|
+
* @returns {Promise<number>} The process exit code.
|
|
285
|
+
*/
|
|
286
|
+
export async function runResourceMetaPut(options) {
|
|
287
|
+
try {
|
|
288
|
+
const tags = parseTags(options.tag);
|
|
289
|
+
const hasName = options.name !== undefined;
|
|
290
|
+
const hasTags = tags !== undefined;
|
|
291
|
+
const hasJson = options.json !== undefined;
|
|
292
|
+
if (hasJson && (hasName || hasTags)) {
|
|
293
|
+
throw new Error('Provide either --json or --name/--tag, not both.');
|
|
294
|
+
}
|
|
295
|
+
if (!hasJson && !hasName && !hasTags) {
|
|
296
|
+
throw new Error('Provide --name, --tag <key=value>, or --json.');
|
|
297
|
+
}
|
|
298
|
+
const { resource, url } = await resolveResourceHandle({
|
|
299
|
+
...options,
|
|
300
|
+
verb: 'meta put'
|
|
301
|
+
});
|
|
302
|
+
if (hasJson) {
|
|
303
|
+
await resource.setMeta({ custom: await parseCustomJson(options.json) });
|
|
304
|
+
}
|
|
305
|
+
else if (hasName && hasTags) {
|
|
306
|
+
await resource.setMeta({ custom: { name: options.name, tags } });
|
|
307
|
+
}
|
|
308
|
+
else if (hasName) {
|
|
309
|
+
await resource.setName(options.name);
|
|
310
|
+
}
|
|
311
|
+
else {
|
|
312
|
+
await resource.setTags(tags);
|
|
313
|
+
}
|
|
314
|
+
console.error(`Updated metadata for ${url}`);
|
|
315
|
+
const meta = await resource.meta();
|
|
316
|
+
console.log(JSON.stringify(meta, null, 2));
|
|
317
|
+
return 0;
|
|
318
|
+
}
|
|
319
|
+
catch (err) {
|
|
320
|
+
return reportError({ action: 'update the resource metadata', err });
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Lists the resources in a collection.
|
|
325
|
+
*
|
|
326
|
+
* @param options {object}
|
|
327
|
+
* @param options.address {string} The collection address.
|
|
328
|
+
* @param [options.json] {boolean} Output the raw listing JSON.
|
|
329
|
+
* @param [options.plain] {boolean} Output one resource id per line.
|
|
330
|
+
* @param [options.server] {string} The server base URL.
|
|
331
|
+
* @param [options.did] {string} The signing DID or stored-DID handle.
|
|
332
|
+
* @returns {Promise<number>} The process exit code.
|
|
333
|
+
*/
|
|
334
|
+
export async function runResourceList(options) {
|
|
335
|
+
try {
|
|
336
|
+
const target = requireCollectionTarget({
|
|
337
|
+
target: await resolveWasTarget({
|
|
338
|
+
address: options.address,
|
|
339
|
+
server: options.server,
|
|
340
|
+
did: options.did
|
|
341
|
+
}),
|
|
342
|
+
address: options.address
|
|
343
|
+
});
|
|
344
|
+
const listing = await target.client
|
|
345
|
+
.space(target.spaceId)
|
|
346
|
+
.collection(target.collectionId)
|
|
347
|
+
.list();
|
|
348
|
+
if (listing === null) {
|
|
349
|
+
console.error('Not found (or not visible to you): ' +
|
|
350
|
+
wasUrl({
|
|
351
|
+
server: target.server,
|
|
352
|
+
spaceId: target.spaceId,
|
|
353
|
+
collectionId: target.collectionId
|
|
354
|
+
}));
|
|
355
|
+
return 1;
|
|
356
|
+
}
|
|
357
|
+
printResourceListing({ listing, json: options.json, plain: options.plain });
|
|
358
|
+
return 0;
|
|
359
|
+
}
|
|
360
|
+
catch (err) {
|
|
361
|
+
return reportError({ action: 'list resources', err });
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Deletes a resource on the server. Idempotent.
|
|
366
|
+
*
|
|
367
|
+
* @param options {object}
|
|
368
|
+
* @param options.address {string} The resource address.
|
|
369
|
+
* @param [options.server] {string} The server base URL.
|
|
370
|
+
* @param [options.did] {string} The signing DID or stored-DID handle.
|
|
371
|
+
* @returns {Promise<number>} The process exit code.
|
|
372
|
+
*/
|
|
373
|
+
export async function runResourceDelete(options) {
|
|
374
|
+
try {
|
|
375
|
+
const target = requireResourceTarget({
|
|
376
|
+
target: await resolveWasTarget({
|
|
377
|
+
address: options.address,
|
|
378
|
+
server: options.server,
|
|
379
|
+
did: options.did
|
|
380
|
+
}),
|
|
381
|
+
address: options.address
|
|
382
|
+
});
|
|
383
|
+
await target.client
|
|
384
|
+
.space(target.spaceId)
|
|
385
|
+
.collection(target.collectionId)
|
|
386
|
+
.resource(target.resourceId)
|
|
387
|
+
.delete();
|
|
388
|
+
console.error('Deleted ' +
|
|
389
|
+
wasUrl({
|
|
390
|
+
server: target.server,
|
|
391
|
+
spaceId: target.spaceId,
|
|
392
|
+
collectionId: target.collectionId,
|
|
393
|
+
resourceId: target.resourceId
|
|
394
|
+
}) +
|
|
395
|
+
' on the server.');
|
|
396
|
+
return 0;
|
|
397
|
+
}
|
|
398
|
+
catch (err) {
|
|
399
|
+
return reportError({ action: 'delete the resource', err });
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
//# sourceMappingURL=resource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource.js","sourceRoot":"","sources":["../../../src/commands/was/resource.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAM3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB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AAE,CAAA;QACX,OAAO,CAAC,KAAK,CACX,UAAU;YACR,MAAM,CAAC;gBACL,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,YAAY,EAAE,MAAM,CAAC,YAAY;gBACjC,UAAU,EAAE,MAAM,CAAC,UAAU;aAC9B,CAAC;YACF,iBAAiB,CACpB,CAAA;QACD,OAAO,CAAC,CAAA;IACV,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,WAAW,CAAC,EAAE,MAAM,EAAE,qBAAqB,EAAE,GAAG,EAAE,CAAC,CAAA;IAC5D,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared helpers for the `was` command group: option factories, address
|
|
3
|
+
* parsing/assertion, URL building, error reporting, listing renderers, and
|
|
4
|
+
* the run-and-exit wrapper. Commander `Option` instances are bound to the
|
|
5
|
+
* command they are added to, so the options are exposed as factories.
|
|
6
|
+
*/
|
|
7
|
+
import { Option } from 'commander';
|
|
8
|
+
import { type Collection, type CollectionsList, type Resource, type CollectionResourcesList, type Space } from '@interop/was-client';
|
|
9
|
+
import { type ResolvedWasTarget } from '../../was/client.js';
|
|
10
|
+
/**
|
|
11
|
+
* Awaits a command's run function and exits the process with its code when
|
|
12
|
+
* non-zero -- the shared tail of every `was` command action.
|
|
13
|
+
*
|
|
14
|
+
* @param run {Promise<number>}
|
|
15
|
+
* @returns {Promise<void>}
|
|
16
|
+
*/
|
|
17
|
+
export declare function runAndExit(run: Promise<number>): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* The shared command options, as factories (commander `Option` instances
|
|
20
|
+
* are bound to the command they are added to, so they cannot be shared).
|
|
21
|
+
* Centralizing them keeps the flag names and help text consistent across
|
|
22
|
+
* the whole command tree.
|
|
23
|
+
*
|
|
24
|
+
* @returns {Option}
|
|
25
|
+
*/
|
|
26
|
+
export declare function serverOption(): Option;
|
|
27
|
+
export declare function didOption(): Option;
|
|
28
|
+
export declare function capabilityOption(): Option;
|
|
29
|
+
export declare function contentTypeOption(): Option;
|
|
30
|
+
/**
|
|
31
|
+
* Guards a run function against receiving both path- and capability-based
|
|
32
|
+
* addressing (or neither).
|
|
33
|
+
*
|
|
34
|
+
* @param options {object}
|
|
35
|
+
* @param [options.address] {string}
|
|
36
|
+
* @param [options.capability] {string}
|
|
37
|
+
* @returns {void}
|
|
38
|
+
*/
|
|
39
|
+
export declare function assertOneAddressing({ address, capability }: {
|
|
40
|
+
address?: string;
|
|
41
|
+
capability?: string;
|
|
42
|
+
}): void;
|
|
43
|
+
/**
|
|
44
|
+
* Builds the canonical URL of a space, collection, or resource on its
|
|
45
|
+
* server, for messages and output.
|
|
46
|
+
*
|
|
47
|
+
* @param options {object}
|
|
48
|
+
* @param options.server {string}
|
|
49
|
+
* @param options.spaceId {string}
|
|
50
|
+
* @param [options.collectionId] {string}
|
|
51
|
+
* @param [options.resourceId] {string}
|
|
52
|
+
* @returns {string}
|
|
53
|
+
*/
|
|
54
|
+
export declare function wasUrl({ server, spaceId, collectionId, resourceId }: {
|
|
55
|
+
server: string;
|
|
56
|
+
spaceId: string;
|
|
57
|
+
collectionId?: string;
|
|
58
|
+
resourceId?: string;
|
|
59
|
+
}): string;
|
|
60
|
+
/**
|
|
61
|
+
* Prints a one-line error for a failed command and classifies its exit code:
|
|
62
|
+
* 1 for operation errors (typed WAS errors from the server exchange), 2 for
|
|
63
|
+
* input errors (bad addresses, unknown handles/DIDs, missing server URL).
|
|
64
|
+
*
|
|
65
|
+
* @param options {object}
|
|
66
|
+
* @param options.action {string} What failed, e.g. `create the space`.
|
|
67
|
+
* @param options.err {unknown}
|
|
68
|
+
* @returns {number} The process exit code.
|
|
69
|
+
*/
|
|
70
|
+
export declare function reportError({ action, err }: {
|
|
71
|
+
action: string;
|
|
72
|
+
err: unknown;
|
|
73
|
+
}): number;
|
|
74
|
+
/**
|
|
75
|
+
* Parses a WAS address and asserts it addresses a space only (no
|
|
76
|
+
* collection/resource segments), as the `space` subcommands require.
|
|
77
|
+
*
|
|
78
|
+
* @param address {string}
|
|
79
|
+
* @returns {{server?: string, spaceRef: string}}
|
|
80
|
+
*/
|
|
81
|
+
export declare function parseSpaceAddress(address: string): {
|
|
82
|
+
server?: string;
|
|
83
|
+
spaceRef: string;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Asserts a resolved target addresses a collection (`SPACE/COLLECTION`,
|
|
87
|
+
* no resource segment) and narrows its type accordingly.
|
|
88
|
+
*
|
|
89
|
+
* @param options {object}
|
|
90
|
+
* @param options.target {ResolvedWasTarget}
|
|
91
|
+
* @param options.address {string} The original address, for error messages.
|
|
92
|
+
* @returns {ResolvedWasTarget & {collectionId: string}}
|
|
93
|
+
*/
|
|
94
|
+
export declare function requireCollectionTarget({ target, address }: {
|
|
95
|
+
target: ResolvedWasTarget;
|
|
96
|
+
address: string;
|
|
97
|
+
}): ResolvedWasTarget & {
|
|
98
|
+
collectionId: string;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Asserts a resolved target addresses a resource
|
|
102
|
+
* (`SPACE/COLLECTION/RESOURCE`) and narrows its type accordingly.
|
|
103
|
+
*
|
|
104
|
+
* @param options {object}
|
|
105
|
+
* @param options.target {ResolvedWasTarget}
|
|
106
|
+
* @param options.address {string} The original address, for error messages.
|
|
107
|
+
* @returns {ResolvedWasTarget & {collectionId: string, resourceId: string}}
|
|
108
|
+
*/
|
|
109
|
+
export declare function requireResourceTarget({ target, address }: {
|
|
110
|
+
target: ResolvedWasTarget;
|
|
111
|
+
address: string;
|
|
112
|
+
}): ResolvedWasTarget & {
|
|
113
|
+
collectionId: string;
|
|
114
|
+
resourceId: string;
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Renders a collection listing as a table, raw JSON, or one id per line.
|
|
118
|
+
*
|
|
119
|
+
* @param options {object}
|
|
120
|
+
* @param options.listing {CollectionsList}
|
|
121
|
+
* @param [options.json] {boolean}
|
|
122
|
+
* @param [options.plain] {boolean}
|
|
123
|
+
* @returns {void}
|
|
124
|
+
*/
|
|
125
|
+
export declare function printCollectionListing({ listing, json, plain }: {
|
|
126
|
+
listing: CollectionsList;
|
|
127
|
+
json?: boolean;
|
|
128
|
+
plain?: boolean;
|
|
129
|
+
}): void;
|
|
130
|
+
/**
|
|
131
|
+
* Renders a resource listing as a table, raw JSON, or one id per line.
|
|
132
|
+
*
|
|
133
|
+
* @param options {object}
|
|
134
|
+
* @param options.listing {CollectionResourcesList}
|
|
135
|
+
* @param [options.json] {boolean}
|
|
136
|
+
* @param [options.plain] {boolean}
|
|
137
|
+
* @returns {void}
|
|
138
|
+
*/
|
|
139
|
+
export declare function printResourceListing({ listing, json, plain }: {
|
|
140
|
+
listing: CollectionResourcesList;
|
|
141
|
+
json?: boolean;
|
|
142
|
+
plain?: boolean;
|
|
143
|
+
}): void;
|
|
144
|
+
/**
|
|
145
|
+
* Builds the access handle (space, collection, or resource) a resolved
|
|
146
|
+
* target addresses, together with its URL. Policies and publishing work at
|
|
147
|
+
* every depth, so these commands dispatch through this helper.
|
|
148
|
+
*
|
|
149
|
+
* @param target {ResolvedWasTarget}
|
|
150
|
+
* @returns {{handle: Space | Collection | Resource, url: string}}
|
|
151
|
+
*/
|
|
152
|
+
export declare function handleForTarget(target: ResolvedWasTarget): {
|
|
153
|
+
handle: Space | Collection | Resource;
|
|
154
|
+
url: string;
|
|
155
|
+
};
|
|
156
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../src/commands/was/shared.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,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,MA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