@interop/was-client 0.26.0 → 0.27.2
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/dist/Collection.d.ts.map +1 -1
- package/dist/Collection.js +27 -66
- package/dist/Collection.js.map +1 -1
- package/dist/Resource.d.ts.map +1 -1
- package/dist/Resource.js +28 -6
- package/dist/Resource.js.map +1 -1
- package/dist/Space.d.ts.map +1 -1
- package/dist/Space.js +10 -25
- package/dist/Space.js.map +1 -1
- package/dist/WasClient.d.ts.map +1 -1
- package/dist/WasClient.js +9 -19
- package/dist/WasClient.js.map +1 -1
- package/dist/codec.d.ts +31 -5
- package/dist/codec.d.ts.map +1 -1
- package/dist/edv/EdvCodec.d.ts +9 -14
- package/dist/edv/EdvCodec.d.ts.map +1 -1
- package/dist/edv/EdvCodec.js +147 -71
- package/dist/edv/EdvCodec.js.map +1 -1
- package/dist/edv/WasTransport.d.ts +1 -2
- package/dist/edv/WasTransport.d.ts.map +1 -1
- package/dist/edv/WasTransport.js +19 -28
- package/dist/edv/WasTransport.js.map +1 -1
- package/dist/edv/constants.d.ts +11 -0
- package/dist/edv/constants.d.ts.map +1 -1
- package/dist/edv/constants.js +16 -4
- package/dist/edv/constants.js.map +1 -1
- package/dist/edv/docCipher.d.ts +10 -26
- package/dist/edv/docCipher.d.ts.map +1 -1
- package/dist/edv/docCipher.js +62 -135
- package/dist/edv/docCipher.js.map +1 -1
- package/dist/edv/epochCrypto.d.ts +0 -4
- package/dist/edv/epochCrypto.d.ts.map +1 -1
- package/dist/edv/epochCrypto.js +4 -4
- package/dist/edv/epochCrypto.js.map +1 -1
- package/dist/edv/epochKeys.d.ts.map +1 -1
- package/dist/edv/epochKeys.js +2 -4
- package/dist/edv/epochKeys.js.map +1 -1
- package/dist/edv/epochMac.d.ts +24 -1
- package/dist/edv/epochMac.d.ts.map +1 -1
- package/dist/edv/epochMac.js +43 -13
- package/dist/edv/epochMac.js.map +1 -1
- package/dist/edv/index.d.ts +6 -4
- package/dist/edv/index.d.ts.map +1 -1
- package/dist/edv/index.js +4 -3
- package/dist/edv/index.js.map +1 -1
- package/dist/edv/recipients.d.ts +29 -17
- package/dist/edv/recipients.d.ts.map +1 -1
- package/dist/edv/recipients.js +177 -112
- package/dist/edv/recipients.js.map +1 -1
- package/dist/errors.d.ts +29 -12
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +37 -65
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/internal/codec.d.ts +15 -12
- package/dist/internal/codec.d.ts.map +1 -1
- package/dist/internal/codec.js +4 -6
- package/dist/internal/codec.js.map +1 -1
- package/dist/internal/conditional.d.ts +9 -4
- package/dist/internal/conditional.d.ts.map +1 -1
- package/dist/internal/conditional.js +9 -2
- package/dist/internal/conditional.js.map +1 -1
- package/dist/internal/content.d.ts +28 -24
- package/dist/internal/content.d.ts.map +1 -1
- package/dist/internal/content.js +28 -13
- package/dist/internal/content.js.map +1 -1
- package/dist/internal/describe.d.ts +15 -2
- package/dist/internal/describe.d.ts.map +1 -1
- package/dist/internal/describe.js +17 -0
- package/dist/internal/describe.js.map +1 -1
- package/dist/internal/pagination.d.ts +20 -1
- package/dist/internal/pagination.d.ts.map +1 -1
- package/dist/internal/pagination.js +22 -0
- package/dist/internal/pagination.js.map +1 -1
- package/dist/internal/paths.d.ts +0 -11
- package/dist/internal/paths.d.ts.map +1 -1
- package/dist/internal/paths.js +20 -33
- package/dist/internal/paths.js.map +1 -1
- package/dist/internal/policy.d.ts.map +1 -1
- package/dist/internal/policy.js +2 -9
- package/dist/internal/policy.js.map +1 -1
- package/dist/internal/write.d.ts +50 -4
- package/dist/internal/write.d.ts.map +1 -1
- package/dist/internal/write.js +45 -0
- package/dist/internal/write.js.map +1 -1
- package/dist/sync/cid.d.ts.map +1 -1
- package/dist/sync/cid.js +8 -2
- package/dist/sync/cid.js.map +1 -1
- package/dist/sync/port.d.ts +9 -8
- package/dist/sync/port.d.ts.map +1 -1
- package/dist/sync/port.js +74 -70
- package/dist/sync/port.js.map +1 -1
- package/dist/sync/provisioning.d.ts +4 -1
- package/dist/sync/provisioning.d.ts.map +1 -1
- package/dist/sync/provisioning.js +11 -2
- package/dist/sync/provisioning.js.map +1 -1
- package/dist/sync/types.d.ts +7 -10
- package/dist/sync/types.d.ts.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +14 -14
package/dist/errors.js
CHANGED
|
@@ -34,19 +34,13 @@ export class WasError extends Error {
|
|
|
34
34
|
* means "not visible to you" rather than strictly "does not exist".
|
|
35
35
|
*/
|
|
36
36
|
export class NotFoundError extends WasError {
|
|
37
|
-
|
|
38
|
-
super(message, options);
|
|
39
|
-
this.name = 'NotFoundError';
|
|
40
|
-
}
|
|
37
|
+
name = 'NotFoundError';
|
|
41
38
|
}
|
|
42
39
|
/**
|
|
43
40
|
* The request was malformed or rejected as invalid (HTTP 400).
|
|
44
41
|
*/
|
|
45
42
|
export class ValidationError extends WasError {
|
|
46
|
-
|
|
47
|
-
super(message, options);
|
|
48
|
-
this.name = 'ValidationError';
|
|
49
|
-
}
|
|
43
|
+
name = 'ValidationError';
|
|
50
44
|
}
|
|
51
45
|
/**
|
|
52
46
|
* Authorization headers were missing or could not be verified (HTTP 401), or
|
|
@@ -54,20 +48,14 @@ export class ValidationError extends WasError {
|
|
|
54
48
|
* 403).
|
|
55
49
|
*/
|
|
56
50
|
export class AuthRequiredError extends WasError {
|
|
57
|
-
|
|
58
|
-
super(message, options);
|
|
59
|
-
this.name = 'AuthRequiredError';
|
|
60
|
-
}
|
|
51
|
+
name = 'AuthRequiredError';
|
|
61
52
|
}
|
|
62
53
|
/**
|
|
63
54
|
* The endpoint exists in the spec but is not yet implemented by the server
|
|
64
55
|
* (HTTP 501).
|
|
65
56
|
*/
|
|
66
57
|
export class NotImplementedError extends WasError {
|
|
67
|
-
|
|
68
|
-
super(message, options);
|
|
69
|
-
this.name = 'NotImplementedError';
|
|
70
|
-
}
|
|
58
|
+
name = 'NotImplementedError';
|
|
71
59
|
}
|
|
72
60
|
/**
|
|
73
61
|
* A client-supplied id or backend conflicts with existing state (HTTP 409):
|
|
@@ -76,10 +64,7 @@ export class NotImplementedError extends WasError {
|
|
|
76
64
|
* the space's available list). The specific kind is on the `type` URI.
|
|
77
65
|
*/
|
|
78
66
|
export class ConflictError extends WasError {
|
|
79
|
-
|
|
80
|
-
super(message, options);
|
|
81
|
-
this.name = 'ConflictError';
|
|
82
|
-
}
|
|
67
|
+
name = 'ConflictError';
|
|
83
68
|
}
|
|
84
69
|
/**
|
|
85
70
|
* A conditional write's precondition evaluated false (HTTP 412): an `ifMatch`
|
|
@@ -90,10 +75,7 @@ export class ConflictError extends WasError {
|
|
|
90
75
|
* conflict family.
|
|
91
76
|
*/
|
|
92
77
|
export class PreconditionFailedError extends WasError {
|
|
93
|
-
|
|
94
|
-
super(message, options);
|
|
95
|
-
this.name = 'PreconditionFailedError';
|
|
96
|
-
}
|
|
78
|
+
name = 'PreconditionFailedError';
|
|
97
79
|
}
|
|
98
80
|
/**
|
|
99
81
|
* A single upload exceeded the target backend's `maxUploadBytes` constraint
|
|
@@ -101,10 +83,7 @@ export class PreconditionFailedError extends WasError {
|
|
|
101
83
|
* upload may still succeed.
|
|
102
84
|
*/
|
|
103
85
|
export class PayloadTooLargeError extends WasError {
|
|
104
|
-
|
|
105
|
-
super(message, options);
|
|
106
|
-
this.name = 'PayloadTooLargeError';
|
|
107
|
-
}
|
|
86
|
+
name = 'PayloadTooLargeError';
|
|
108
87
|
}
|
|
109
88
|
/**
|
|
110
89
|
* A write was rejected because the target backend's storage quota is exhausted
|
|
@@ -112,10 +91,7 @@ export class PayloadTooLargeError extends WasError {
|
|
|
112
91
|
* fault.
|
|
113
92
|
*/
|
|
114
93
|
export class QuotaExceededError extends WasError {
|
|
115
|
-
|
|
116
|
-
super(message, options);
|
|
117
|
-
this.name = 'QuotaExceededError';
|
|
118
|
-
}
|
|
94
|
+
name = 'QuotaExceededError';
|
|
119
95
|
}
|
|
120
96
|
/**
|
|
121
97
|
* A client-side, fail-closed encryption error: a collection is declared
|
|
@@ -127,10 +103,7 @@ export class QuotaExceededError extends WasError {
|
|
|
127
103
|
* per-handle `encryption` override). Never silently downgrades to plaintext.
|
|
128
104
|
*/
|
|
129
105
|
export class EncryptionError extends WasError {
|
|
130
|
-
|
|
131
|
-
super(message, options);
|
|
132
|
-
this.name = 'EncryptionError';
|
|
133
|
-
}
|
|
106
|
+
name = 'EncryptionError';
|
|
134
107
|
}
|
|
135
108
|
/**
|
|
136
109
|
* A fail-closed key-epoch error: a reader could not unwrap any epoch key it
|
|
@@ -147,10 +120,7 @@ export class EncryptionError extends WasError {
|
|
|
147
120
|
* already decrypt.
|
|
148
121
|
*/
|
|
149
122
|
export class KeyUnwrapError extends EncryptionError {
|
|
150
|
-
|
|
151
|
-
super(message, options);
|
|
152
|
-
this.name = 'KeyUnwrapError';
|
|
153
|
-
}
|
|
123
|
+
name = 'KeyUnwrapError';
|
|
154
124
|
}
|
|
155
125
|
/**
|
|
156
126
|
* A fail-closed integrity error: a stored EDV envelope this reader DOES hold a
|
|
@@ -164,10 +134,7 @@ export class KeyUnwrapError extends EncryptionError {
|
|
|
164
134
|
* problem. Raised client-side before/independent of any HTTP status.
|
|
165
135
|
*/
|
|
166
136
|
export class IntegrityError extends EncryptionError {
|
|
167
|
-
|
|
168
|
-
super(message, options);
|
|
169
|
-
this.name = 'IntegrityError';
|
|
170
|
-
}
|
|
137
|
+
name = 'IntegrityError';
|
|
171
138
|
}
|
|
172
139
|
/**
|
|
173
140
|
* The replication-port signal for a rejected conditional write (HTTP 412): an
|
|
@@ -201,9 +168,27 @@ export class WasSyncNotFoundError extends NotFoundError {
|
|
|
201
168
|
* The server encountered an internal fault (HTTP 5xx).
|
|
202
169
|
*/
|
|
203
170
|
export class WasServerError extends WasError {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
171
|
+
name = 'WasServerError';
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Thrown on decrypt when a stored envelope names JWE recipient (`kid`) ids
|
|
175
|
+
* that match none of this reader's candidate keys: neither the key-agreement
|
|
176
|
+
* key (single-key collection) nor any key epoch resolved from the Collection
|
|
177
|
+
* Description. It signals that the caller's cached descriptor may be stale and
|
|
178
|
+
* should be re-read before retrying: an epoch rotation emits no change-feed
|
|
179
|
+
* entry, so a codec built from a pre-rotation descriptor meets envelopes
|
|
180
|
+
* stamped with a newer epoch it has never seen. It also fires on a single-key
|
|
181
|
+
* codec that meets an envelope encrypted to a different key-agreement key
|
|
182
|
+
* entirely.
|
|
183
|
+
*/
|
|
184
|
+
export class UnknownEpochError extends Error {
|
|
185
|
+
constructor({ collectionId, kids }) {
|
|
186
|
+
super(`Cannot decrypt a resource in collection "${collectionId}": its ` +
|
|
187
|
+
`envelope names recipient key id(s) [${kids.join(', ')}] that match ` +
|
|
188
|
+
'neither the key-agreement key nor any known key epoch. The cached ' +
|
|
189
|
+
'Collection Description may be stale (an epoch rotation emits no ' +
|
|
190
|
+
'change-feed entry); re-read it and rebuild the cipher.');
|
|
191
|
+
this.name = 'UnknownEpochError';
|
|
207
192
|
}
|
|
208
193
|
}
|
|
209
194
|
/**
|
|
@@ -241,21 +226,6 @@ const ERROR_CLASS_BY_KIND = {
|
|
|
241
226
|
[problemFragment(ProblemTypes.STORAGE_ERROR)]: WasServerError,
|
|
242
227
|
[problemFragment(ProblemTypes.INTERNAL_ERROR)]: WasServerError
|
|
243
228
|
};
|
|
244
|
-
/**
|
|
245
|
-
* Constructs a `WasError` subclass from a problem-kind anchor (the fragment of
|
|
246
|
-
* the `type` URI, e.g. `quota-exceeded`). Returns `null` for an unrecognized or
|
|
247
|
-
* absent kind so the caller can fall back to status-based dispatch.
|
|
248
|
-
*
|
|
249
|
-
* @param options {object}
|
|
250
|
-
* @param [options.kind] {string} the `type` URI fragment
|
|
251
|
-
* @param options.message {string}
|
|
252
|
-
* @param options.options {WasErrorOptions}
|
|
253
|
-
* @returns {WasError | null}
|
|
254
|
-
*/
|
|
255
|
-
function errorForKind({ kind, message, options }) {
|
|
256
|
-
const ErrorClass = kind === undefined ? undefined : ERROR_CLASS_BY_KIND[kind];
|
|
257
|
-
return ErrorClass ? new ErrorClass(message, options) : null;
|
|
258
|
-
}
|
|
259
229
|
/**
|
|
260
230
|
* Reads the HTTP status from a raw ky/ezcap error, checking both the flat
|
|
261
231
|
* `status` and the nested `response.status` shapes.
|
|
@@ -298,10 +268,12 @@ export function mapError(err) {
|
|
|
298
268
|
const requestUrl = httpError.requestUrl;
|
|
299
269
|
const message = title ?? httpError.message ?? 'WAS request failed';
|
|
300
270
|
const options = { status, type, title, details, requestUrl, cause: err };
|
|
271
|
+
// Dispatch on the problem-kind anchor when the server sent one, falling
|
|
272
|
+
// through to the status-based switch for an unrecognized or absent kind.
|
|
301
273
|
const kind = typeof type === 'string' ? problemFragment(type) : undefined;
|
|
302
|
-
const
|
|
303
|
-
if (
|
|
304
|
-
return
|
|
274
|
+
const ErrorClass = kind === undefined ? undefined : ERROR_CLASS_BY_KIND[kind];
|
|
275
|
+
if (ErrorClass) {
|
|
276
|
+
return new ErrorClass(message, options);
|
|
305
277
|
}
|
|
306
278
|
switch (status) {
|
|
307
279
|
case 400:
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;GAKG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAmBpD;;GAEG;AACH,MAAM,OAAO,QAAS,SAAQ,KAAK;IACjC,MAAM,CAAS;IACf,IAAI,CAAS;IACb,KAAK,CAAS;IACd,OAAO,CAAW;IAClB,UAAU,CAAS;IAEnB,YAAY,OAAe,EAAE,UAA2B,EAAE;QACxD,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,K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AAC,CAAA;IAC7E,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,IAAI,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IACzC,CAAC;IAED,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,GAAG;YACN,OAAO,IAAI,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QAC9C,KAAK,GAAG,CAAC;QACT,KAAK,GAAG;YACN,OAAO,IAAI,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QAChD,KAAK,GAAG;YACN,OAAO,IAAI,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QAC5C,KAAK,GAAG;YACN,OAAO,IAAI,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QAC9C,KAAK,GAAG;YACN,OAAO,IAAI,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QAC5C,KAAK,GAAG;YACN,OAAO,IAAI,uBAAuB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QACtD,KAAK,GAAG;YACN,OAAO,IAAI,oBAAoB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QACnD,KAAK,GAAG;YACN,OAAO,IAAI,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QAClD,KAAK,GAAG;YACN,OAAO,IAAI,kBAAkB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IACnD,CAAC;IAED,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,IAAI,GAAG,EAAE,CAAC;QAChD,OAAO,IAAI,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IAC7C,CAAC;IAED,OAAO,IAAI,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AACvC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -14,6 +14,6 @@ export type { ParsedSpacePath } from './internal/paths.js';
|
|
|
14
14
|
export { readEtag, writeHeaders } from './internal/conditional.js';
|
|
15
15
|
export type { WritePrecondition } from './internal/conditional.js';
|
|
16
16
|
export { WasError, NotFoundError, ValidationError, AuthRequiredError, NotImplementedError, ConflictError, PreconditionFailedError, PayloadTooLargeError, QuotaExceededError, EncryptionError, KeyUnwrapError, IntegrityError, WasSyncConflictError, WasSyncNotFoundError, WasServerError, mapError } from './errors.js';
|
|
17
|
-
export type { ResourceCodec, EncryptionProvider, EncodedWrite } from './codec.js';
|
|
18
|
-
export type { Json, JsonPrimitive, JsonObject, JsonArray, ResourceData, Action, ActionInput, SpaceDescription, CollectionDescription, CollectionWritableFields, CollectionEncryption, CollectionEncryptionEpoch, CollectionEncryptionRecipient, CollectionSummary, CollectionsList, SpaceSummary, SpaceListing, ResourceSummary, CollectionResourcesList, ResourceMetadata, ResourceMetadataCustom, AddResult, ImportStats, PolicyDocument, LinkSet, LinkSetEntry, HandleOptions, EncryptionOverride, BackendReference, BackendDescriptor, BackendRegistration, BackendConnectionInput, BackendConnectionPublic, StorageLimit, CollectionUsage, BackendUsage, SpaceQuotaReport, GrantOptions, RequestInput, IZcap, IDelegatedZcap, ISigner } from './types.js';
|
|
17
|
+
export type { ResourceCodec, EncryptionProvider, EncodedWrite, ResponseLike } from './codec.js';
|
|
18
|
+
export type { Json, JsonPrimitive, JsonObject, JsonArray, ResourceData, Action, ActionInput, SpaceDescription, CollectionDescription, CollectionWritableFields, CollectionEncryption, CollectionEncryptionEpoch, CollectionEncryptionEpochsSig, CollectionEncryptionRecipient, CollectionSummary, CollectionsList, SpaceSummary, SpaceListing, ResourceSummary, CollectionResourcesList, ResourceMetadata, ResourceMetadataCustom, AddResult, ImportStats, PolicyDocument, LinkSet, LinkSetEntry, HandleOptions, EncryptionOverride, BackendReference, BackendDescriptor, BackendRegistration, BackendConnectionInput, BackendConnectionPublic, StorageLimit, CollectionUsage, BackendUsage, SpaceQuotaReport, GrantOptions, RequestInput, IZcap, IDelegatedZcap, ISigner } from './types.js';
|
|
19
19
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;GAGG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACtD,YAAY,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAClE,YAAY,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAElE,OAAO,EACL,QAAQ,EACR,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,aAAa,EACb,uBAAuB,EACvB,oBAAoB,EACpB,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACpB,cAAc,EACd,QAAQ,EACT,MAAM,aAAa,CAAA;AAEpB,YAAY,EACV,aAAa,EACb,kBAAkB,EAClB,YAAY,EACb,MAAM,YAAY,CAAA;AAEnB,YAAY,EACV,IAAI,EACJ,aAAa,EACb,UAAU,EACV,SAAS,EACT,YAAY,EACZ,MAAM,EACN,WAAW,EACX,gBAAgB,EAChB,qBAAqB,EACrB,wBAAwB,EACxB,oBAAoB,EACpB,yBAAyB,EACzB,6BAA6B,EAC7B,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,uBAAuB,EACvB,gBAAgB,EAChB,sBAAsB,EACtB,SAAS,EACT,WAAW,EACX,cAAc,EACd,OAAO,EACP,YAAY,EACZ,aAAa,EACb,kBAAkB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AA6B,EAC7B,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,uBAAuB,EACvB,gBAAgB,EAChB,sBAAsB,EACtB,SAAS,EACT,WAAW,EACX,cAAc,EACd,OAAO,EACP,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,EACvB,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,KAAK,EACL,cAAc,EACd,OAAO,EACR,MAAM,YAAY,CAAA"}
|
package/dist/internal/codec.d.ts
CHANGED
|
@@ -28,6 +28,18 @@ export declare class CodecHolder {
|
|
|
28
28
|
*/
|
|
29
29
|
reset(): void;
|
|
30
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* The collection a codec is being resolved for, plus the per-handle inputs that
|
|
33
|
+
* decide it: the encryption override and the handle's bound capability. Shared
|
|
34
|
+
* by {@link collectionCodecHolder} and {@link resolveCodec}, which forwards it
|
|
35
|
+
* through unchanged.
|
|
36
|
+
*/
|
|
37
|
+
interface CodecTarget {
|
|
38
|
+
spaceId: string;
|
|
39
|
+
collectionId: string;
|
|
40
|
+
override?: EncryptionOverride;
|
|
41
|
+
capability?: IZcap;
|
|
42
|
+
}
|
|
31
43
|
/**
|
|
32
44
|
* Builds the per-handle {@link CodecHolder} for a collection's codec -- the
|
|
33
45
|
* one resolver wiring shared by the `Collection` and standalone `Resource`
|
|
@@ -41,12 +53,7 @@ export declare class CodecHolder {
|
|
|
41
53
|
* @param [options.capability] {IZcap} the handle's bound capability
|
|
42
54
|
* @returns {CodecHolder}
|
|
43
55
|
*/
|
|
44
|
-
export declare function collectionCodecHolder(context: ClientContext, options:
|
|
45
|
-
spaceId: string;
|
|
46
|
-
collectionId: string;
|
|
47
|
-
override?: EncryptionOverride;
|
|
48
|
-
capability?: IZcap;
|
|
49
|
-
}): CodecHolder;
|
|
56
|
+
export declare function collectionCodecHolder(context: ClientContext, options: CodecTarget): CodecHolder;
|
|
50
57
|
/**
|
|
51
58
|
* The default codec: passes plaintext through unchanged. `encode` echoes the
|
|
52
59
|
* caller's `id` (so `put(id, ...)` is a `PUT` and `add(...)`, with no id, stays
|
|
@@ -74,10 +81,6 @@ export declare const identityCodec: ResourceCodec;
|
|
|
74
81
|
* override and the client has a keystore)
|
|
75
82
|
* @returns {Promise<ResourceCodec>}
|
|
76
83
|
*/
|
|
77
|
-
export declare function resolveCodec(context: ClientContext, { spaceId, collectionId, override, capability }:
|
|
78
|
-
|
|
79
|
-
collectionId: string;
|
|
80
|
-
override?: EncryptionOverride;
|
|
81
|
-
capability?: IZcap;
|
|
82
|
-
}): Promise<ResourceCodec>;
|
|
84
|
+
export declare function resolveCodec(context: ClientContext, { spaceId, collectionId, override, capability }: CodecTarget): Promise<ResourceCodec>;
|
|
85
|
+
export {};
|
|
83
86
|
//# sourceMappingURL=codec.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../src/internal/codec.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAgB,aAAa,EAAE,MAAM,aAAa,CAAA;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAIjD,OAAO,KAAK,EAEV,kBAAkB,EAClB,KAAK,EAIN,MAAM,aAAa,CAAA;AAEpB;;;;;;GAMG;AACH,qBAAa,WAAW;;IAItB;;;OAGG;gBACS,OAAO,EAAE,MAAM,OAAO,CAAC,aAAa,CAAC;IAIjD;;;;OAIG;IACH,GAAG,IAAI,OAAO,CAAC,aAAa,CAAC;IAiB7B;;;;OAIG;IACH,KAAK,IAAI,IAAI;CAGd;AAED
|
|
1
|
+
{"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../src/internal/codec.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAgB,aAAa,EAAE,MAAM,aAAa,CAAA;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAIjD,OAAO,KAAK,EAEV,kBAAkB,EAClB,KAAK,EAIN,MAAM,aAAa,CAAA;AAEpB;;;;;;GAMG;AACH,qBAAa,WAAW;;IAItB;;;OAGG;gBACS,OAAO,EAAE,MAAM,OAAO,CAAC,aAAa,CAAC;IAIjD;;;;OAIG;IACH,GAAG,IAAI,OAAO,CAAC,aAAa,CAAC;IAiB7B;;;;OAIG;IACH,KAAK,IAAI,IAAI;CAGd;AAED;;;;;GAKG;AACH,UAAU,WAAW;IACnB,OAAO,EAAE,MAAM,CAAA;IACf,YAAY,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,kBAAkB,CAAA;IAC7B,UAAU,CAAC,EAAE,KAAK,CAAA;CACnB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,WAAW,GACnB,WAAW,CAEb;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,EAAE,aAkC3B,CAAA;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,YAAY,CAChC,OAAO,EAAE,aAAa,EACtB,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,WAAW,GAC3D,OAAO,CAAC,aAAa,CAAC,CA2DxB"}
|
package/dist/internal/codec.js
CHANGED
|
@@ -75,13 +75,11 @@ export function collectionCodecHolder(context, options) {
|
|
|
75
75
|
export const identityCodec = {
|
|
76
76
|
async encode({ id, data, contentType }) {
|
|
77
77
|
const prepared = prepareBody(data, { contentType, filename: id });
|
|
78
|
-
return {
|
|
79
|
-
id,
|
|
80
|
-
json: prepared.json,
|
|
81
|
-
body: prepared.body,
|
|
82
|
-
contentType: prepared.contentType
|
|
83
|
-
};
|
|
78
|
+
return { id, ...prepared };
|
|
84
79
|
},
|
|
80
|
+
// Deliberately narrower than the seam's `ResponseLike`: a byte-exact
|
|
81
|
+
// pass-through needs the full response stream surface (blob, content-type),
|
|
82
|
+
// and core's read path only ever hands it a real HttpResponse.
|
|
85
83
|
async decode(response) {
|
|
86
84
|
return (await parseResource(response));
|
|
87
85
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codec.js","sourceRoot":"","sources":["../../src/internal/codec.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AACzD,OAAO,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAA;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAU9C;;;;;;GAMG;AACH,MAAM,OAAO,WAAW;IACtB,QAAQ,CAAyB;IACxB,QAAQ,CAA8B;IAE/C;;;OAGG;IACH,YAAY,OAAqC;QAC/C,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAA;IACzB,CAAC;IAED;;;;OAIG;IACH,GAAG;QACD,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,OAAO,IAAI,CAAC,QAAQ,CAAA;QACtB,CAAC;QACD,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAA;QAC/B,4EAA4E;QAC5E,uEAAuE;QACvE,2EAA2E;QAC3E,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAA;QACvB,OAAO,CAAC,KAAK,CAAC,GAAS,EAAE;YACvB,IAAI,IAAI,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;gBAC9B,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAA;YAC3B,CAAC;QACH,CAAC,CAAC,CAAA;QACF,OAAO,OAAO,CAAA;IAChB,CAAC;IAED;;;;OAIG;IACH,KAAK;QACH,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAA;IAC3B,CAAC;CACF;
|
|
1
|
+
{"version":3,"file":"codec.js","sourceRoot":"","sources":["../../src/internal/codec.ts"],"names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AAE,CAAC;QACX,MAAM,IAAI,eAAe,CACvB,cAAc,KAAK,0BAA0B,MAAM,qBAAqB;YACtE,wEAAwE;YACxE,kEAAkE,CACrE,CAAA;IACH,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC"}
|
|
@@ -7,8 +7,13 @@
|
|
|
7
7
|
* `If-Match` / `If-None-Match: *` preconditions, and reading the `ETag` a write
|
|
8
8
|
* response returns.
|
|
9
9
|
*/
|
|
10
|
-
import type {
|
|
11
|
-
|
|
10
|
+
import type { EncodedWrite, ResponseLike } from '../codec.js';
|
|
11
|
+
/**
|
|
12
|
+
* The request header the server reads a content write's key-epoch id from,
|
|
13
|
+
* stamping it onto the Resource's metadata (an absent header clears any prior
|
|
14
|
+
* stamp). HTTP header names are case-insensitive; the wire form is `WAS-Key-Epoch`.
|
|
15
|
+
*/
|
|
16
|
+
export declare const WAS_KEY_EPOCH_HEADER = "WAS-Key-Epoch";
|
|
12
17
|
/**
|
|
13
18
|
* A conditional-write precondition: `ifMatch` is the quoted ETag an
|
|
14
19
|
* update-if-unchanged write must match; `ifNoneMatch` requests a create-if-absent
|
|
@@ -54,8 +59,8 @@ export declare function writeHeaders({ contentType, precondition, epoch }: {
|
|
|
54
59
|
* `undefined` when the backend sent none (it does not advertise the
|
|
55
60
|
* `conditional-writes` feature).
|
|
56
61
|
*
|
|
57
|
-
* @param response {
|
|
62
|
+
* @param response {ResponseLike | null}
|
|
58
63
|
* @returns {string | undefined}
|
|
59
64
|
*/
|
|
60
|
-
export declare function readEtag(response:
|
|
65
|
+
export declare function readEtag(response: ResponseLike | null): string | undefined;
|
|
61
66
|
//# sourceMappingURL=conditional.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conditional.d.ts","sourceRoot":"","sources":["../../src/internal/conditional.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;GAKG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"conditional.d.ts","sourceRoot":"","sources":["../../src/internal/conditional.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;GAKG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE7D;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,kBAAkB,CAAA;AAEnD;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,YAAY,GAAG,iBAAiB,CAE5E;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,EAC3B,WAAW,EACX,YAAiB,EACjB,KAAK,EACN,EAAE;IACD,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,YAAY,CAAC,EAAE,iBAAiB,CAAA;IAChC,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAgBrC;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI,GAAG,MAAM,GAAG,SAAS,CAE1E"}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The request header the server reads a content write's key-epoch id from,
|
|
3
|
+
* stamping it onto the Resource's metadata (an absent header clears any prior
|
|
4
|
+
* stamp). HTTP header names are case-insensitive; the wire form is `WAS-Key-Epoch`.
|
|
5
|
+
*/
|
|
6
|
+
export const WAS_KEY_EPOCH_HEADER = 'WAS-Key-Epoch';
|
|
1
7
|
/**
|
|
2
8
|
* Extracts the conditional-write precondition a codec attached to its encoded
|
|
3
9
|
* write (`EncodedWrite.ifMatch` / `ifNoneMatch`). The one mapping shared by
|
|
@@ -38,7 +44,8 @@ export function writeHeaders({ contentType, precondition = {}, epoch }) {
|
|
|
38
44
|
headers['if-none-match'] = '*';
|
|
39
45
|
}
|
|
40
46
|
if (epoch !== undefined) {
|
|
41
|
-
|
|
47
|
+
// This record keys every header in lower case; the name is case-insensitive.
|
|
48
|
+
headers[WAS_KEY_EPOCH_HEADER.toLowerCase()] = epoch;
|
|
42
49
|
}
|
|
43
50
|
return Object.keys(headers).length > 0 ? headers : undefined;
|
|
44
51
|
}
|
|
@@ -47,7 +54,7 @@ export function writeHeaders({ contentType, precondition = {}, epoch }) {
|
|
|
47
54
|
* `undefined` when the backend sent none (it does not advertise the
|
|
48
55
|
* `conditional-writes` feature).
|
|
49
56
|
*
|
|
50
|
-
* @param response {
|
|
57
|
+
* @param response {ResponseLike | null}
|
|
51
58
|
* @returns {string | undefined}
|
|
52
59
|
*/
|
|
53
60
|
export function readEtag(response) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conditional.js","sourceRoot":"","sources":["../../src/internal/conditional.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"conditional.js","sourceRoot":"","sources":["../../src/internal/conditional.ts"],"names":[],"mappings":"AAWA;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,eAAe,CAAA;AAYnD;;;;;;;;GAQG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAqB;IACvD,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,CAAA;AACvE,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,YAAY,CAAC,EAC3B,WAAW,EACX,YAAY,GAAG,EAAE,EACjB,KAAK,EAKN;IACC,MAAM,OAAO,GAA2B,EAAE,CAAA;IAC1C,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,CAAC,cAAc,CAAC,GAAG,WAAW,CAAA;IACvC,CAAC;IACD,IAAI,YAAY,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QACvC,OAAO,CAAC,UAAU,CAAC,GAAG,YAAY,CAAC,OAAO,CAAA;IAC5C,CAAC;IACD,IAAI,YAAY,CAAC,WAAW,EAAE,CAAC;QAC7B,OAAO,CAAC,eAAe,CAAC,GAAG,GAAG,CAAA;IAChC,CAAC;IACD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,6EAA6E;QAC7E,OAAO,CAAC,oBAAoB,CAAC,WAAW,EAAE,CAAC,GAAG,KAAK,CAAA;IACrD,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAA;AAC9D,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CAAC,QAA6B;IACpD,OAAO,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,SAAS,CAAA;AACnD,CAAC"}
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* `application/octet-stream`.
|
|
11
11
|
*/
|
|
12
12
|
import type { HttpResponse } from '@interop/http-client';
|
|
13
|
+
import type { ResponseLike } from '../codec.js';
|
|
13
14
|
import type { Json, ResourceData } from '../types.js';
|
|
14
15
|
/**
|
|
15
16
|
* The shared `TextEncoder` (stateless, so one instance serves the whole
|
|
@@ -18,20 +19,6 @@ import type { Json, ResourceData } from '../types.js';
|
|
|
18
19
|
* EDV envelope bytes (re-exported by `edv/constants.ts`).
|
|
19
20
|
*/
|
|
20
21
|
export declare const ENCODER: TextEncoder;
|
|
21
|
-
/**
|
|
22
|
-
* Whether a content-type denotes JSON -- `application/json` or any
|
|
23
|
-
* `application/<prefix>+json` structured-suffix variant (e.g.
|
|
24
|
-
* `application/ld+json`, `application/jose+json`), each optionally followed by
|
|
25
|
-
* parameters (`; charset=utf-8`). The `json` token is anchored to the end of the
|
|
26
|
-
* media type, so a non-JSON type that merely contains the substring `json` --
|
|
27
|
-
* `application/jsonl`, `application/json-seq`, `application/json5` -- is NOT
|
|
28
|
-
* treated as JSON and is read back as binary (a `Blob`) instead of being
|
|
29
|
-
* JSON-parsed.
|
|
30
|
-
*
|
|
31
|
-
* @param contentType {string}
|
|
32
|
-
* @returns {boolean}
|
|
33
|
-
*/
|
|
34
|
-
export declare function isJsonContentType(contentType: string): boolean;
|
|
35
22
|
/**
|
|
36
23
|
* Whether a content type denotes UTF-8-safe text that should be stored inline as
|
|
37
24
|
* a plain string (legible, no ~33% base64 inflation) rather than as opaque
|
|
@@ -61,7 +48,7 @@ export declare function guessContentTypeFromId(id: string): string | undefined;
|
|
|
61
48
|
* A write body resolved into either a JSON payload (passed to ezcap as `json`)
|
|
62
49
|
* or a binary payload with its content-type (passed as `body` + header).
|
|
63
50
|
*/
|
|
64
|
-
|
|
51
|
+
interface PreparedBody {
|
|
65
52
|
json?: object;
|
|
66
53
|
body?: Uint8Array | Blob;
|
|
67
54
|
contentType?: string;
|
|
@@ -87,7 +74,7 @@ export declare function toPlainBytes(bytes: Uint8Array): Uint8Array;
|
|
|
87
74
|
* with its resolved content-type), JSON (a plain object/array), or invalid (a
|
|
88
75
|
* bare primitive -- the caller throws its own error message).
|
|
89
76
|
*/
|
|
90
|
-
|
|
77
|
+
type ResolvedPayload = {
|
|
91
78
|
kind: 'binary';
|
|
92
79
|
data: Blob | Uint8Array;
|
|
93
80
|
contentType: string;
|
|
@@ -137,12 +124,28 @@ export declare function prepareBody(data: ResourceData, options?: {
|
|
|
137
124
|
filename?: string;
|
|
138
125
|
}): PreparedBody;
|
|
139
126
|
/**
|
|
140
|
-
* Extracts the id of a just-created resource from a create response
|
|
141
|
-
* the
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
* surface as a raw
|
|
127
|
+
* Extracts the id of a just-created resource from a create response, together
|
|
128
|
+
* with the raw `Location` header it carried (if any). Prefers the response
|
|
129
|
+
* body's `id`; for a body-less 2xx falls back to the last path segment of the
|
|
130
|
+
* `Location` header (decoded, since the server emits a percent-encoded path).
|
|
131
|
+
* Throws a `WasServerError` when the response carries neither -- a malformed
|
|
132
|
+
* create response -- rather than letting an absent body surface as a raw
|
|
133
|
+
* `TypeError` on `data.id`.
|
|
134
|
+
*
|
|
135
|
+
* The header is read once and returned verbatim so a caller that also needs
|
|
136
|
+
* the created resource's URL (`Collection.add`, which resolves it against the
|
|
137
|
+
* items URL) does not re-read and re-parse it.
|
|
138
|
+
*
|
|
139
|
+
* @param response {HttpResponse | null}
|
|
140
|
+
* @returns {{ id: string; location?: string }}
|
|
141
|
+
*/
|
|
142
|
+
export declare function createdResource(response: HttpResponse | null): {
|
|
143
|
+
id: string;
|
|
144
|
+
location?: string;
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* The id of a just-created resource -- {@link createdResource} for callers that
|
|
148
|
+
* need only the id.
|
|
146
149
|
*
|
|
147
150
|
* @param response {HttpResponse | null}
|
|
148
151
|
* @returns {string}
|
|
@@ -168,10 +171,10 @@ export declare function dataOrNull<T>(response: HttpResponse | null): T | null;
|
|
|
168
171
|
* Test for `undefined` rather than using `??`; otherwise the nullish fallback
|
|
169
172
|
* would re-invoke `.json()` on the already-consumed stream and throw.
|
|
170
173
|
*
|
|
171
|
-
* @param response {
|
|
174
|
+
* @param response {ResponseLike}
|
|
172
175
|
* @returns {Promise<unknown>}
|
|
173
176
|
*/
|
|
174
|
-
export declare function readJsonData(response:
|
|
177
|
+
export declare function readJsonData(response: ResponseLike): Promise<unknown>;
|
|
175
178
|
/**
|
|
176
179
|
* Parses a resource GET response: returns the parsed object when the stored
|
|
177
180
|
* content-type is JSON, otherwise a `Blob` whose `.type` carries the
|
|
@@ -181,4 +184,5 @@ export declare function readJsonData(response: HttpResponse): Promise<unknown>;
|
|
|
181
184
|
* @returns {Promise<Json | Blob | null>}
|
|
182
185
|
*/
|
|
183
186
|
export declare function parseResource(response: HttpResponse | null): Promise<Json | Blob | null>;
|
|
187
|
+
export {};
|
|
184
188
|
//# sourceMappingURL=content.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../src/internal/content.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../src/internal/content.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,OAAO,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAIrD;;;;;GAKG;AACH,eAAO,MAAM,OAAO,aAAoB,CAAA;AAmBxC;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAO9D;AA6BD;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAOrE;AAED;;;GAGG;AACH,UAAU,YAAY;IACpB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,UAAU,GAAG,IAAI,CAAA;IACxB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,IAAI,CAEpD;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,CAK1D;AAED;;;;GAIG;AACH,KAAK,eAAe,GAChB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,IAAI,GAAG,UAAU,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GAChE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,CAAA;AAEvB;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,cAAc,CAAC,EAC7B,IAAI,EACJ,WAAW,EACX,EAAE,EACH,EAAE;IACD,IAAI,EAAE,YAAY,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,EAAE,CAAC,EAAE,MAAM,CAAA;CACZ,GAAG,eAAe,CAwBlB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,YAAY,EAClB,OAAO,GAAE;IAAE,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAO,GACxD,YAAY,CAiCd;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI,GAAG;IAC9D,EAAE,EAAE,MAAM,CAAA;IACV,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CA4BA;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI,GAAG,MAAM,CAE/D;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,QAAQ,EAAE,YAAY,GAAG,IAAI,GAAG,CAAC,GAAG,IAAI,CAIrE;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,YAAY,CAAC,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,CAE3E;AAED;;;;;;;GAOG;AACH,wBAAsB,aAAa,CACjC,QAAQ,EAAE,YAAY,GAAG,IAAI,GAC5B,OAAO,CAAC,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,CAS7B"}
|
package/dist/internal/content.js
CHANGED
|
@@ -20,7 +20,7 @@ export const ENCODER = new TextEncoder();
|
|
|
20
20
|
* @param contentType {string}
|
|
21
21
|
* @returns {boolean}
|
|
22
22
|
*/
|
|
23
|
-
|
|
23
|
+
function isJsonContentType(contentType) {
|
|
24
24
|
return /^application\/([^+\s;]+\+)?json\s*(;.*)?$/i.test(contentType);
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
@@ -194,24 +194,29 @@ export function prepareBody(data, options = {}) {
|
|
|
194
194
|
'Blob/Uint8Array (binary).');
|
|
195
195
|
}
|
|
196
196
|
/**
|
|
197
|
-
* Extracts the id of a just-created resource from a create response
|
|
198
|
-
* the
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
* surface as a raw
|
|
197
|
+
* Extracts the id of a just-created resource from a create response, together
|
|
198
|
+
* with the raw `Location` header it carried (if any). Prefers the response
|
|
199
|
+
* body's `id`; for a body-less 2xx falls back to the last path segment of the
|
|
200
|
+
* `Location` header (decoded, since the server emits a percent-encoded path).
|
|
201
|
+
* Throws a `WasServerError` when the response carries neither -- a malformed
|
|
202
|
+
* create response -- rather than letting an absent body surface as a raw
|
|
203
|
+
* `TypeError` on `data.id`.
|
|
204
|
+
*
|
|
205
|
+
* The header is read once and returned verbatim so a caller that also needs
|
|
206
|
+
* the created resource's URL (`Collection.add`, which resolves it against the
|
|
207
|
+
* items URL) does not re-read and re-parse it.
|
|
203
208
|
*
|
|
204
209
|
* @param response {HttpResponse | null}
|
|
205
|
-
* @returns {string}
|
|
210
|
+
* @returns {{ id: string; location?: string }}
|
|
206
211
|
*/
|
|
207
|
-
export function
|
|
212
|
+
export function createdResource(response) {
|
|
213
|
+
const location = response?.headers.get('location') ?? undefined;
|
|
208
214
|
const data = response?.data;
|
|
209
215
|
if (data !== null &&
|
|
210
216
|
typeof data === 'object' &&
|
|
211
217
|
typeof data.id === 'string') {
|
|
212
|
-
return data.id;
|
|
218
|
+
return { id: data.id, location };
|
|
213
219
|
}
|
|
214
|
-
const location = response?.headers.get('location');
|
|
215
220
|
// Parse the `Location` as a URL (relative to the response URL) so a query
|
|
216
221
|
// string or fragment on the create response -- e.g.
|
|
217
222
|
// `/space/s/c/newid?token=abc` -- is dropped before the last path segment is
|
|
@@ -223,11 +228,21 @@ export function createdId(response) {
|
|
|
223
228
|
.pop()
|
|
224
229
|
: undefined;
|
|
225
230
|
if (segment) {
|
|
226
|
-
return decodeURIComponent(segment);
|
|
231
|
+
return { id: decodeURIComponent(segment), location };
|
|
227
232
|
}
|
|
228
233
|
throw new WasServerError('Create response carried no resource id: the body has no `id` and there ' +
|
|
229
234
|
'is no `Location` header.');
|
|
230
235
|
}
|
|
236
|
+
/**
|
|
237
|
+
* The id of a just-created resource -- {@link createdResource} for callers that
|
|
238
|
+
* need only the id.
|
|
239
|
+
*
|
|
240
|
+
* @param response {HttpResponse | null}
|
|
241
|
+
* @returns {string}
|
|
242
|
+
*/
|
|
243
|
+
export function createdId(response) {
|
|
244
|
+
return createdResource(response).id;
|
|
245
|
+
}
|
|
231
246
|
/**
|
|
232
247
|
* Unwraps a read response's pre-parsed JSON `data` as `T`, mapping a `null`
|
|
233
248
|
* response (a 404 that a `read` request resolved to `null`) to `null`. The
|
|
@@ -252,7 +267,7 @@ export function dataOrNull(response) {
|
|
|
252
267
|
* Test for `undefined` rather than using `??`; otherwise the nullish fallback
|
|
253
268
|
* would re-invoke `.json()` on the already-consumed stream and throw.
|
|
254
269
|
*
|
|
255
|
-
* @param response {
|
|
270
|
+
* @param response {ResponseLike}
|
|
256
271
|
* @returns {Promise<unknown>}
|
|
257
272
|
*/
|
|
258
273
|
export async function readJsonData(response) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content.js","sourceRoot":"","sources":["../../src/internal/content.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"content.js","sourceRoot":"","sources":["../../src/internal/content.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAG9D,MAAM,YAAY,GAAG,0BAA0B,CAAA;AAE/C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,IA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