@interop/was-client 0.60.0 → 0.62.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 +124 -48
- package/dist/Collection.d.ts +135 -94
- package/dist/Collection.d.ts.map +1 -1
- package/dist/Collection.js +612 -194
- package/dist/Collection.js.map +1 -1
- package/dist/Resource.d.ts +1 -1
- package/dist/Resource.d.ts.map +1 -1
- package/dist/Resource.js +0 -3
- package/dist/Resource.js.map +1 -1
- package/dist/Space.d.ts +17 -16
- package/dist/Space.d.ts.map +1 -1
- package/dist/Space.js +41 -24
- package/dist/Space.js.map +1 -1
- package/dist/WasClient.d.ts +51 -6
- package/dist/WasClient.d.ts.map +1 -1
- package/dist/WasClient.js +84 -14
- package/dist/WasClient.js.map +1 -1
- package/dist/codec.d.ts +3 -3
- package/dist/edv/EdvCodec.js +1 -1
- package/dist/edv/descriptorStore.d.ts +16 -14
- package/dist/edv/descriptorStore.d.ts.map +1 -1
- package/dist/edv/descriptorStore.js +17 -14
- package/dist/edv/descriptorStore.js.map +1 -1
- package/dist/edv/index.d.ts +1 -1
- package/dist/edv/index.js +1 -1
- package/dist/edv/logGovernedDescriptorStore.d.ts +2 -2
- package/dist/edv/logGovernedDescriptorStore.d.ts.map +1 -1
- package/dist/edv/logGovernedDescriptorStore.js +10 -9
- package/dist/edv/logGovernedDescriptorStore.js.map +1 -1
- package/dist/edv/recipients.d.ts +1 -1
- package/dist/edv/recipients.js +2 -2
- package/dist/edv/recipients.js.map +1 -1
- package/dist/edv/refresh.d.ts +1 -1
- package/dist/edv/refresh.js +1 -1
- package/dist/errors.d.ts +14 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +16 -3
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/codec.d.ts +22 -1
- package/dist/internal/codec.d.ts.map +1 -1
- package/dist/internal/codec.js +117 -46
- package/dist/internal/codec.js.map +1 -1
- package/dist/internal/describe.d.ts +98 -24
- package/dist/internal/describe.d.ts.map +1 -1
- package/dist/internal/describe.js +125 -18
- package/dist/internal/describe.js.map +1 -1
- package/dist/internal/meta.d.ts +32 -17
- package/dist/internal/meta.d.ts.map +1 -1
- package/dist/internal/meta.js +64 -35
- package/dist/internal/meta.js.map +1 -1
- package/dist/internal/paths.d.ts +33 -21
- package/dist/internal/paths.d.ts.map +1 -1
- package/dist/internal/paths.js +93 -46
- package/dist/internal/paths.js.map +1 -1
- package/dist/internal/request.d.ts +22 -6
- package/dist/internal/request.d.ts.map +1 -1
- package/dist/internal/request.js +31 -13
- package/dist/internal/request.js.map +1 -1
- package/dist/internal/reserved.d.ts +14 -0
- package/dist/internal/reserved.d.ts.map +1 -1
- package/dist/internal/reserved.js +23 -4
- package/dist/internal/reserved.js.map +1 -1
- package/dist/internal/service.d.ts +61 -0
- package/dist/internal/service.d.ts.map +1 -0
- package/dist/internal/service.js +259 -0
- package/dist/internal/service.js.map +1 -0
- package/dist/paths.d.ts +8 -5
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +8 -5
- package/dist/paths.js.map +1 -1
- package/dist/sync/provisioning.d.ts +5 -5
- package/dist/sync/provisioning.d.ts.map +1 -1
- package/dist/sync/provisioning.js +2 -2
- package/dist/sync/provisioning.js.map +1 -1
- package/dist/types.d.ts +43 -10
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/internal/meta.d.ts
CHANGED
|
@@ -16,47 +16,51 @@ import type { IZcap, ResourceMetadataCustom, ResourceMetadataCustomInput } from
|
|
|
16
16
|
* @param options.slot {MetaReadSlot} the `/meta` slot being read, for an
|
|
17
17
|
* encrypting codec's envelope-binding check
|
|
18
18
|
* @param [options.capability] {IZcap}
|
|
19
|
+
* @param [options.onStored] {function} receives the document as served, with
|
|
20
|
+
* its validator and its `custom` still undecoded, before the decode -- so a
|
|
21
|
+
* caller whose next step is a full-replacement write of the same document
|
|
22
|
+
* can compose that write against the read it just paid for
|
|
19
23
|
* @returns {Promise<(Metadata & { etag?: string }) | null>}
|
|
20
24
|
*/
|
|
21
25
|
export declare function readMeta<Metadata extends {
|
|
22
26
|
custom?: ResourceMetadataCustom;
|
|
23
|
-
}>(context: ClientContext, { metaPath, codec: codecPromise, subject, slot, capability }: {
|
|
27
|
+
}>(context: ClientContext, { metaPath, codec: codecPromise, subject, slot, capability, onStored }: {
|
|
24
28
|
metaPath: string;
|
|
25
29
|
codec: Promise<ResourceCodec>;
|
|
26
30
|
subject: string;
|
|
27
31
|
slot: MetaReadSlot;
|
|
28
32
|
capability?: IZcap;
|
|
33
|
+
onStored?: (read: {
|
|
34
|
+
metadata: Record<string, unknown>;
|
|
35
|
+
etag?: string;
|
|
36
|
+
}) => void;
|
|
29
37
|
}): Promise<(Metadata & {
|
|
30
38
|
etag?: string;
|
|
31
39
|
}) | null>;
|
|
32
40
|
/**
|
|
33
|
-
* Replaces a metadata document's user-writable `custom`, encoding it
|
|
34
|
-
* the codec first (which seals it into an opaque envelope on an
|
|
35
|
-
* collection).
|
|
41
|
+
* Replaces a Resource metadata document's user-writable `custom`, encoding it
|
|
42
|
+
* through the codec first (which seals it into an opaque envelope on an
|
|
43
|
+
* encrypted collection). A key epoch the codec surfaces is deliberately
|
|
44
|
+
* dropped: a Resource's epoch stamps its *content* write through the
|
|
45
|
+
* `Key-Epoch` header, not its metadata.
|
|
36
46
|
*
|
|
37
47
|
* @param context {ClientContext}
|
|
38
48
|
* @param options {object}
|
|
39
|
-
* @param options.metaPath {string} the
|
|
49
|
+
* @param options.metaPath {string} the `meta` sub-resource path
|
|
40
50
|
* @param options.codec {Promise<ResourceCodec>} the resolving codec
|
|
41
51
|
* @param options.custom {ResourceMetadataCustomInput} the user-writable
|
|
42
52
|
* properties, as a full replacement
|
|
43
|
-
* @param options.
|
|
44
|
-
* a top-level member of this PUT body. True at Collection level, where the
|
|
45
|
-
* stamp describes the `custom` envelope itself; false at Resource level,
|
|
46
|
-
* where a Resource's epoch instead stamps its content write via the
|
|
47
|
-
* `Key-Epoch` header, so an epoch surfaced here is deliberately dropped.
|
|
48
|
-
* @param options.slot {MetaWriteSlot} the `/meta` slot being written, which
|
|
53
|
+
* @param options.slot {MetaWriteSlot} the `meta` slot being written, which
|
|
49
54
|
* an encrypting codec binds into the envelope
|
|
50
|
-
* @param [options.ifMatch] {string} update only if the
|
|
55
|
+
* @param [options.ifMatch] {string} update only if the `meta` ETag matches
|
|
51
56
|
* @param [options.ifNoneMatch] {boolean} write only if no metadata is set
|
|
52
57
|
* @param [options.capability] {IZcap}
|
|
53
58
|
* @returns {Promise<{ etag?: string }>} the metadata's new ETag
|
|
54
59
|
*/
|
|
55
|
-
export declare function writeMeta(context: ClientContext, { metaPath, codec: codecPromise, custom,
|
|
60
|
+
export declare function writeMeta(context: ClientContext, { metaPath, codec: codecPromise, custom, slot, ifMatch, ifNoneMatch, capability }: {
|
|
56
61
|
metaPath: string;
|
|
57
62
|
codec: Promise<ResourceCodec>;
|
|
58
63
|
custom: ResourceMetadataCustomInput;
|
|
59
|
-
sendEpoch: boolean;
|
|
60
64
|
slot: MetaWriteSlot;
|
|
61
65
|
ifMatch?: string;
|
|
62
66
|
ifNoneMatch?: boolean;
|
|
@@ -68,12 +72,23 @@ export declare function writeMeta(context: ClientContext, { metaPath, codec: cod
|
|
|
68
72
|
* The shared read-then-CAS body of the handles' `setName` / `setTags`: reads
|
|
69
73
|
* the current metadata, merges `patch` over its `custom`, and writes it back
|
|
70
74
|
* pinned to the read's `etag` (when the backend supports `conditional-writes`),
|
|
71
|
-
* so a concurrent metadata write
|
|
72
|
-
*
|
|
75
|
+
* so a concurrent metadata write is rebased on rather than silently erased by
|
|
76
|
+
* the full-replacement write.
|
|
77
|
+
*
|
|
78
|
+
* A lost race (`412`) re-reads and re-applies the patch, up to the shared
|
|
79
|
+
* compare-and-swap attempt limit. A handle whose metadata cannot be read at
|
|
80
|
+
* all patches nothing onto an empty object: the write it drives is the one
|
|
81
|
+
* that refuses (`Collection.setMeta` throws `NotFoundError`), so a masked 404
|
|
82
|
+
* cannot turn a rename into a create. At Collection level that is not a rare event:
|
|
83
|
+
* one `metaVersion` covers the configuration members and the annotations
|
|
84
|
+
* alike, so a concurrent `configure` -- or an epoch rotation -- legitimately
|
|
85
|
+
* invalidates an in-flight annotation write.
|
|
73
86
|
*
|
|
74
87
|
* @param handle {object} the Collection or Resource handle to patch
|
|
75
88
|
* @param patch {ResourceMetadataCustom} the properties to merge over the
|
|
76
89
|
* current `custom`
|
|
90
|
+
* @param operation {string} what the caller is doing, for the exhaustion
|
|
91
|
+
* error (e.g. `Metadata update`)
|
|
77
92
|
* @returns {Promise<void>}
|
|
78
93
|
*/
|
|
79
94
|
export declare function patchCustom(handle: {
|
|
@@ -88,5 +103,5 @@ export declare function patchCustom(handle: {
|
|
|
88
103
|
}): Promise<{
|
|
89
104
|
etag?: string;
|
|
90
105
|
}>;
|
|
91
|
-
}, patch: ResourceMetadataCustom): Promise<void>;
|
|
106
|
+
}, patch: ResourceMetadataCustom, operation?: string): Promise<void>;
|
|
92
107
|
//# sourceMappingURL=meta.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../src/internal/meta.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../src/internal/meta.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC7E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAIjD,OAAO,KAAK,EACV,KAAK,EACL,sBAAsB,EACtB,2BAA2B,EAC5B,MAAM,aAAa,CAAA;AAEpB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,QAAQ,CAC5B,QAAQ,SAAS;IAAE,MAAM,CAAC,EAAE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AAC,EAAE,sBAAsB,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC,CAAA;IAC1E,OAAO,CACL,IAAI,EAAE;QAAE,MAAM,CAAC,EAAE,sBAAsB,CAAA;KAAE,EACzC,OAAO,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAC5B,OAAO,CAAC;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAC9B,EACD,KAAK,EAAE,sBAAsB,EAC7B,SAAS,SAAoB,GAC5B,OAAO,CAAC,IAAI,CAAC,CAiBf"}
|
package/dist/internal/meta.js
CHANGED
|
@@ -2,13 +2,18 @@
|
|
|
2
2
|
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
|
-
* Shared
|
|
6
|
-
*
|
|
7
|
-
* the
|
|
8
|
-
*
|
|
9
|
-
*
|
|
5
|
+
* Shared `meta` I/O for the Collection and Resource handles. `readMeta` serves
|
|
6
|
+
* both: the two read the same metadata document shape and differ only in the
|
|
7
|
+
* metadata type and the slot the `custom` envelope is bound to.
|
|
8
|
+
*
|
|
9
|
+
* `writeMeta` is the Resource side alone. A Collection's `meta` write is a full
|
|
10
|
+
* replacement of the merged Collection Metadata object -- configuration
|
|
11
|
+
* members included -- so it is composed against a fresh read of that object in
|
|
12
|
+
* `Collection`, and `patchCustom` below drives both handles' read-modify-write
|
|
13
|
+
* helpers through a bounded compare-and-swap.
|
|
10
14
|
*/
|
|
11
15
|
import { WasServerError } from '../errors.js';
|
|
16
|
+
import { compareAndSwap } from './cas.js';
|
|
12
17
|
import { send } from './request.js';
|
|
13
18
|
import { readEtag, writeHeaders } from './conditional.js';
|
|
14
19
|
import { withCodec } from './withCodec.js';
|
|
@@ -27,9 +32,13 @@ import { withCodec } from './withCodec.js';
|
|
|
27
32
|
* @param options.slot {MetaReadSlot} the `/meta` slot being read, for an
|
|
28
33
|
* encrypting codec's envelope-binding check
|
|
29
34
|
* @param [options.capability] {IZcap}
|
|
35
|
+
* @param [options.onStored] {function} receives the document as served, with
|
|
36
|
+
* its validator and its `custom` still undecoded, before the decode -- so a
|
|
37
|
+
* caller whose next step is a full-replacement write of the same document
|
|
38
|
+
* can compose that write against the read it just paid for
|
|
30
39
|
* @returns {Promise<(Metadata & { etag?: string }) | null>}
|
|
31
40
|
*/
|
|
32
|
-
export async function readMeta(context, { metaPath, codec: codecPromise, subject, slot, capability }) {
|
|
41
|
+
export async function readMeta(context, { metaPath, codec: codecPromise, subject, slot, capability, onStored }) {
|
|
33
42
|
// The metadata GET does not depend on the codec (only its `custom` decode
|
|
34
43
|
// below does), so the two overlap.
|
|
35
44
|
const [codec, response] = await withCodec(codecPromise, send(context, {
|
|
@@ -54,54 +63,49 @@ export async function readMeta(context, { metaPath, codec: codecPromise, subject
|
|
|
54
63
|
`"${response.headers.get('content-type') ?? 'unknown'}").`);
|
|
55
64
|
}
|
|
56
65
|
const metadata = response.data;
|
|
66
|
+
const etagBeforeDecode = readEtag(response);
|
|
67
|
+
onStored?.({
|
|
68
|
+
metadata: metadata,
|
|
69
|
+
...(etagBeforeDecode !== undefined && { etag: etagBeforeDecode })
|
|
70
|
+
});
|
|
57
71
|
// Decode the user-writable `custom` (decrypting it on an encrypted
|
|
58
72
|
// collection) so callers uniformly see plaintext `{ name, tags }`. The
|
|
59
73
|
// stated slot drives the encrypting codec's binding check: in the
|
|
60
74
|
// Collection slot it refuses a resource-bound envelope served there.
|
|
61
75
|
const custom = await codec.decodeMeta({ custom: metadata.custom }, slot);
|
|
62
76
|
const decoded = { ...metadata, custom };
|
|
63
|
-
|
|
64
|
-
|
|
77
|
+
return etagBeforeDecode !== undefined
|
|
78
|
+
? { ...decoded, etag: etagBeforeDecode }
|
|
79
|
+
: decoded;
|
|
65
80
|
}
|
|
66
81
|
/**
|
|
67
|
-
* Replaces a metadata document's user-writable `custom`, encoding it
|
|
68
|
-
* the codec first (which seals it into an opaque envelope on an
|
|
69
|
-
* collection).
|
|
82
|
+
* Replaces a Resource metadata document's user-writable `custom`, encoding it
|
|
83
|
+
* through the codec first (which seals it into an opaque envelope on an
|
|
84
|
+
* encrypted collection). A key epoch the codec surfaces is deliberately
|
|
85
|
+
* dropped: a Resource's epoch stamps its *content* write through the
|
|
86
|
+
* `Key-Epoch` header, not its metadata.
|
|
70
87
|
*
|
|
71
88
|
* @param context {ClientContext}
|
|
72
89
|
* @param options {object}
|
|
73
|
-
* @param options.metaPath {string} the
|
|
90
|
+
* @param options.metaPath {string} the `meta` sub-resource path
|
|
74
91
|
* @param options.codec {Promise<ResourceCodec>} the resolving codec
|
|
75
92
|
* @param options.custom {ResourceMetadataCustomInput} the user-writable
|
|
76
93
|
* properties, as a full replacement
|
|
77
|
-
* @param options.
|
|
78
|
-
* a top-level member of this PUT body. True at Collection level, where the
|
|
79
|
-
* stamp describes the `custom` envelope itself; false at Resource level,
|
|
80
|
-
* where a Resource's epoch instead stamps its content write via the
|
|
81
|
-
* `Key-Epoch` header, so an epoch surfaced here is deliberately dropped.
|
|
82
|
-
* @param options.slot {MetaWriteSlot} the `/meta` slot being written, which
|
|
94
|
+
* @param options.slot {MetaWriteSlot} the `meta` slot being written, which
|
|
83
95
|
* an encrypting codec binds into the envelope
|
|
84
|
-
* @param [options.ifMatch] {string} update only if the
|
|
96
|
+
* @param [options.ifMatch] {string} update only if the `meta` ETag matches
|
|
85
97
|
* @param [options.ifNoneMatch] {boolean} write only if no metadata is set
|
|
86
98
|
* @param [options.capability] {IZcap}
|
|
87
99
|
* @returns {Promise<{ etag?: string }>} the metadata's new ETag
|
|
88
100
|
*/
|
|
89
|
-
export async function writeMeta(context, { metaPath, codec: codecPromise, custom,
|
|
101
|
+
export async function writeMeta(context, { metaPath, codec: codecPromise, custom, slot, ifMatch, ifNoneMatch, capability }) {
|
|
90
102
|
const codec = await codecPromise;
|
|
91
|
-
const { custom: encoded
|
|
103
|
+
const { custom: encoded } = await codec.encodeMeta({ custom, slot });
|
|
92
104
|
const response = await send(context, {
|
|
93
105
|
path: metaPath,
|
|
94
106
|
method: 'PUT',
|
|
95
107
|
capability,
|
|
96
|
-
|
|
97
|
-
// the header channel stamps a Resource's *content* write, while the
|
|
98
|
-
// Collection metadata stamp describes the `custom` envelope itself and is
|
|
99
|
-
// a top-level member of this PUT body. The server clears the stored stamp
|
|
100
|
-
// when the member is omitted -- which is exactly right on a plaintext
|
|
101
|
-
// collection, whose codec surfaces no epoch.
|
|
102
|
-
json: sendEpoch && epoch !== undefined
|
|
103
|
-
? { custom: encoded, epoch }
|
|
104
|
-
: { custom: encoded },
|
|
108
|
+
json: { custom: encoded },
|
|
105
109
|
headers: writeHeaders({ precondition: { ifMatch, ifNoneMatch } })
|
|
106
110
|
});
|
|
107
111
|
return { etag: readEtag(response) };
|
|
@@ -110,16 +114,41 @@ export async function writeMeta(context, { metaPath, codec: codecPromise, custom
|
|
|
110
114
|
* The shared read-then-CAS body of the handles' `setName` / `setTags`: reads
|
|
111
115
|
* the current metadata, merges `patch` over its `custom`, and writes it back
|
|
112
116
|
* pinned to the read's `etag` (when the backend supports `conditional-writes`),
|
|
113
|
-
* so a concurrent metadata write
|
|
114
|
-
*
|
|
117
|
+
* so a concurrent metadata write is rebased on rather than silently erased by
|
|
118
|
+
* the full-replacement write.
|
|
119
|
+
*
|
|
120
|
+
* A lost race (`412`) re-reads and re-applies the patch, up to the shared
|
|
121
|
+
* compare-and-swap attempt limit. A handle whose metadata cannot be read at
|
|
122
|
+
* all patches nothing onto an empty object: the write it drives is the one
|
|
123
|
+
* that refuses (`Collection.setMeta` throws `NotFoundError`), so a masked 404
|
|
124
|
+
* cannot turn a rename into a create. At Collection level that is not a rare event:
|
|
125
|
+
* one `metaVersion` covers the configuration members and the annotations
|
|
126
|
+
* alike, so a concurrent `configure` -- or an epoch rotation -- legitimately
|
|
127
|
+
* invalidates an in-flight annotation write.
|
|
115
128
|
*
|
|
116
129
|
* @param handle {object} the Collection or Resource handle to patch
|
|
117
130
|
* @param patch {ResourceMetadataCustom} the properties to merge over the
|
|
118
131
|
* current `custom`
|
|
132
|
+
* @param operation {string} what the caller is doing, for the exhaustion
|
|
133
|
+
* error (e.g. `Metadata update`)
|
|
119
134
|
* @returns {Promise<void>}
|
|
120
135
|
*/
|
|
121
|
-
export async function patchCustom(handle, patch) {
|
|
122
|
-
|
|
123
|
-
|
|
136
|
+
export async function patchCustom(handle, patch, operation = 'Metadata update') {
|
|
137
|
+
await compareAndSwap({
|
|
138
|
+
store: {
|
|
139
|
+
read: async () => {
|
|
140
|
+
const current = await handle.meta();
|
|
141
|
+
return {
|
|
142
|
+
value: current?.custom ?? {},
|
|
143
|
+
...(current?.etag !== undefined && { etag: current.etag })
|
|
144
|
+
};
|
|
145
|
+
},
|
|
146
|
+
replace: async (custom, { ifMatch }) => {
|
|
147
|
+
await handle.setMeta({ custom }, { ifMatch });
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
operation,
|
|
151
|
+
mutate: custom => ({ ...custom, ...patch })
|
|
152
|
+
});
|
|
124
153
|
}
|
|
125
154
|
//# sourceMappingURL=meta.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta.js","sourceRoot":"","sources":["../../src/internal/meta.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
1
|
+
{"version":3,"file":"meta.js","sourceRoot":"","sources":["../../src/internal/meta.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;GAUG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAGzC,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAO1C;;;;;;;;;;;;;;;;;;;;GAoBG;A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C5B,GAAG,CAAC,OAAO,EAAE,IAAI,KAAK,SAAS,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC;iBAC3D,CAAA;YACH,CAAC;YACD,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;gBACrC,MAAM,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,CAAA;YAC/C,CAAC;SACF;QACD,SAAS;QACT,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,GAAG,KAAK,EAAE,CAAC;KAC5C,CAAC,CAAA;AACJ,CAAC"}
|
package/dist/internal/paths.d.ts
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `/
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*
|
|
2
|
+
* `/space/:spaceId/` -- the Space container in canonical form: the target a
|
|
3
|
+
* Space root capability names, the URL whose `GET` lists the Space's
|
|
4
|
+
* Collections, whose `POST` creates one, and whose `DELETE` removes the Space.
|
|
5
|
+
* The Space is an ordinary container, so its members are listed and created at
|
|
6
|
+
* the container itself -- there is no second builder for that.
|
|
7
|
+
*
|
|
8
|
+
* @param spaceId {string}
|
|
9
|
+
* @returns {string}
|
|
7
10
|
*/
|
|
8
11
|
export declare function spacePath(spaceId: string): string;
|
|
9
12
|
/**
|
|
10
|
-
* `/space/:spaceId
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*
|
|
13
|
+
* `/space/:spaceId/meta` -- the Space Metadata object: the Space's description
|
|
14
|
+
* (`name`, `controller`, `type`), read with `GET` and replaced with `PUT`.
|
|
15
|
+
*
|
|
16
|
+
* @param spaceId {string}
|
|
17
|
+
* @returns {string}
|
|
15
18
|
*/
|
|
16
|
-
export declare function
|
|
19
|
+
export declare function spaceMeta(spaceId: string): string;
|
|
17
20
|
/**
|
|
18
21
|
* `/space/:spaceId/export` -- export a space as a tar archive.
|
|
19
22
|
*/
|
|
@@ -54,15 +57,16 @@ export declare function spaceLinkset(spaceId: string): string;
|
|
|
54
57
|
*/
|
|
55
58
|
export declare function spaceRevocation(spaceId: string, capabilityId: string): string;
|
|
56
59
|
/**
|
|
57
|
-
* `/space/:spaceId/:collectionId
|
|
58
|
-
*
|
|
60
|
+
* `/space/:spaceId/:collectionId/` -- the Collection container in canonical
|
|
61
|
+
* form: the target a "share this collection" capability names, the URL whose
|
|
62
|
+
* `GET` lists its Resources, whose `POST` adds one, and whose `DELETE` removes
|
|
63
|
+
* the Collection.
|
|
64
|
+
*
|
|
65
|
+
* @param spaceId {string}
|
|
66
|
+
* @param collectionId {string}
|
|
67
|
+
* @returns {string}
|
|
59
68
|
*/
|
|
60
69
|
export declare function collectionPath(spaceId: string, collectionId: string): string;
|
|
61
|
-
/**
|
|
62
|
-
* `/space/:spaceId/:collectionId/` -- list items / add a resource
|
|
63
|
-
* (trailing slash).
|
|
64
|
-
*/
|
|
65
|
-
export declare function collectionItems(spaceId: string, collectionId: string): string;
|
|
66
70
|
/**
|
|
67
71
|
* `/space/:spaceId/:collectionId/policy` -- the collection-level access-control
|
|
68
72
|
* policy resource.
|
|
@@ -84,9 +88,10 @@ export declare function collectionBackend(spaceId: string, collectionId: string)
|
|
|
84
88
|
*/
|
|
85
89
|
export declare function collectionQuota(spaceId: string, collectionId: string): string;
|
|
86
90
|
/**
|
|
87
|
-
* `/space/:spaceId/:collectionId/meta` -- the Collection
|
|
88
|
-
*
|
|
89
|
-
*
|
|
91
|
+
* `/space/:spaceId/:collectionId/meta` -- the Collection Metadata object: the
|
|
92
|
+
* Collection's configuration (`name`, `backend`, `encryption`, `generator`)
|
|
93
|
+
* together with the server-managed timestamps / `createdBy` and the
|
|
94
|
+
* user-writable `custom` and `epoch`, as one object under one validator.
|
|
90
95
|
*/
|
|
91
96
|
export declare function collectionMeta(spaceId: string, collectionId: string): string;
|
|
92
97
|
/**
|
|
@@ -209,6 +214,13 @@ export declare function parseSpaceTarget({ serverUrl, target }: {
|
|
|
209
214
|
* or any 5-segment target like `/space/s/c/r/meta` -- is classified
|
|
210
215
|
* `sub-resource`, never silently truncated to the nearest handle.
|
|
211
216
|
*
|
|
217
|
+
* Empty segments are dropped, so a container addressed in either form
|
|
218
|
+
* classifies the same: `/space/s` and `/space/s/` are both the Space, and
|
|
219
|
+
* `/space/s/c` and `/space/s/c/` both the Collection. That is deliberate. The
|
|
220
|
+
* builders emit only the canonical trailing-slash form, but the targets parsed
|
|
221
|
+
* here come from capabilities minted elsewhere, and a client that reads only
|
|
222
|
+
* one spelling would refuse valid ones.
|
|
223
|
+
*
|
|
212
224
|
* @param pathname {string} a URL pathname (e.g. from `new URL(...).pathname`)
|
|
213
225
|
* @returns {ParsedSpacePath | null}
|
|
214
226
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/internal/paths.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/internal/paths.ts"],"names":[],"mappings":"AA8GA;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAErD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAE5E;AAED;;GAEG;A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