@atscript/db-client 0.1.83 → 0.1.85
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/index.cjs +16 -0
- package/dist/index.d.cts +24 -1
- package/dist/index.d.mts +24 -1
- package/dist/index.mjs +16 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -40,6 +40,20 @@ var ActionDisabledError = class extends ClientError {
|
|
|
40
40
|
return this.body.ids;
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
|
+
/**
|
|
44
|
+
* Typed marker thrown by `Client._send` when the server response body's
|
|
45
|
+
* `kind === 'version_mismatch'`. The transport / status / base body are
|
|
46
|
+
* identical to a generic `ClientError`; this subclass adds a typed
|
|
47
|
+
* `currentVersion` accessor so consumers can write
|
|
48
|
+
* `catch (e) { if (e instanceof VersionMismatchError) … }` without casting.
|
|
49
|
+
*/
|
|
50
|
+
var VersionMismatchError = class extends ClientError {
|
|
51
|
+
name = "VersionMismatchError";
|
|
52
|
+
/** Row's current server-side version — clients refresh + retry against it. */
|
|
53
|
+
get currentVersion() {
|
|
54
|
+
return this.body.currentVersion;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
43
57
|
/** Thrown by `Client.action()` when the action name is not present in `/meta`. */
|
|
44
58
|
var ActionNotFoundError = class extends Error {
|
|
45
59
|
name = "ActionNotFoundError";
|
|
@@ -381,6 +395,7 @@ var Client = class {
|
|
|
381
395
|
};
|
|
382
396
|
}
|
|
383
397
|
if (errorBody.name === "ActionDisabledError") throw new ActionDisabledError(res.status, errorBody);
|
|
398
|
+
if (errorBody.kind === "version_mismatch") throw new VersionMismatchError(res.status, errorBody);
|
|
384
399
|
throw new ClientError(res.status, errorBody);
|
|
385
400
|
}
|
|
386
401
|
if (!allowEmpty) return res.json();
|
|
@@ -433,6 +448,7 @@ exports.ActionNotFoundError = ActionNotFoundError;
|
|
|
433
448
|
exports.ActionUnsupportedError = ActionUnsupportedError;
|
|
434
449
|
exports.Client = Client;
|
|
435
450
|
exports.ClientError = ClientError;
|
|
451
|
+
exports.VersionMismatchError = VersionMismatchError;
|
|
436
452
|
exports.encodeNavigateId = encodeNavigateId;
|
|
437
453
|
exports.formatIdentifier = formatIdentifier;
|
|
438
454
|
exports.formatIdentifierField = formatIdentifierField;
|
package/dist/index.d.cts
CHANGED
|
@@ -245,6 +245,29 @@ declare class ActionDisabledError extends ClientError {
|
|
|
245
245
|
/** Present only for `'rows'`-level rejections (full list of failing IDs). */
|
|
246
246
|
get ids(): Record<string, unknown>[] | undefined;
|
|
247
247
|
}
|
|
248
|
+
/**
|
|
249
|
+
* Wire-body shape for 409 OCC `version_mismatch` responses. Extends the base
|
|
250
|
+
* `ServerError` envelope with a `kind` discriminator and the row's current
|
|
251
|
+
* server-side version. The bridge between `@atscript/moost-db`'s server-side
|
|
252
|
+
* `_disambiguateMismatch` and this typed client-side subclass is the wire
|
|
253
|
+
* JSON body — neither package depends on the other.
|
|
254
|
+
*/
|
|
255
|
+
interface VersionMismatchErrorBody extends ServerError {
|
|
256
|
+
kind: "version_mismatch";
|
|
257
|
+
currentVersion: number;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Typed marker thrown by `Client._send` when the server response body's
|
|
261
|
+
* `kind === 'version_mismatch'`. The transport / status / base body are
|
|
262
|
+
* identical to a generic `ClientError`; this subclass adds a typed
|
|
263
|
+
* `currentVersion` accessor so consumers can write
|
|
264
|
+
* `catch (e) { if (e instanceof VersionMismatchError) … }` without casting.
|
|
265
|
+
*/
|
|
266
|
+
declare class VersionMismatchError extends ClientError {
|
|
267
|
+
name: string;
|
|
268
|
+
/** Row's current server-side version — clients refresh + retry against it. */
|
|
269
|
+
get currentVersion(): number;
|
|
270
|
+
}
|
|
248
271
|
/** Thrown by `Client.action()` when the action name is not present in `/meta`. */
|
|
249
272
|
declare class ActionNotFoundError extends Error {
|
|
250
273
|
readonly action: string;
|
|
@@ -264,4 +287,4 @@ declare class ActionUnsupportedError extends Error {
|
|
|
264
287
|
constructor(action: string, processor: string, message: string);
|
|
265
288
|
}
|
|
266
289
|
//#endregion
|
|
267
|
-
export { ActionDisabledError, type ActionDisabledErrorBody, ActionNotFoundError, ActionUnsupportedError, type AggregateQuery, type AggregateResult, type AtscriptClientShape, Client, ClientError, type ClientOptions, type ClientResponse, type ClientValidationError, type ClientValidator, type DataOf, type FieldMeta, type FilterExpr, type IdOf, type MetaResponse, type NavOf, type OwnOf, type PageResult, type RelationInfo, type SearchIndexInfo, type ServerError, type TCrudOp, type TCrudPermissions, type TDbActionInfo, type TDbActionIntent, type TDbActionLevel, type TDbActionProcessor, type TDbDeleteResult, type TDbInsertManyResult, type TDbInsertResult, type TDbUpdateResult, type TSerializedAnnotatedType, type TypedWithRelation, type Uniquery, type UniqueryControls, type ValidatorMode, encodeNavigateId, formatIdentifier, formatIdentifierField };
|
|
290
|
+
export { ActionDisabledError, type ActionDisabledErrorBody, ActionNotFoundError, ActionUnsupportedError, type AggregateQuery, type AggregateResult, type AtscriptClientShape, Client, ClientError, type ClientOptions, type ClientResponse, type ClientValidationError, type ClientValidator, type DataOf, type FieldMeta, type FilterExpr, type IdOf, type MetaResponse, type NavOf, type OwnOf, type PageResult, type RelationInfo, type SearchIndexInfo, type ServerError, type TCrudOp, type TCrudPermissions, type TDbActionInfo, type TDbActionIntent, type TDbActionLevel, type TDbActionProcessor, type TDbDeleteResult, type TDbInsertManyResult, type TDbInsertResult, type TDbUpdateResult, type TSerializedAnnotatedType, type TypedWithRelation, type Uniquery, type UniqueryControls, type ValidatorMode, VersionMismatchError, type VersionMismatchErrorBody, encodeNavigateId, formatIdentifier, formatIdentifierField };
|
package/dist/index.d.mts
CHANGED
|
@@ -245,6 +245,29 @@ declare class ActionDisabledError extends ClientError {
|
|
|
245
245
|
/** Present only for `'rows'`-level rejections (full list of failing IDs). */
|
|
246
246
|
get ids(): Record<string, unknown>[] | undefined;
|
|
247
247
|
}
|
|
248
|
+
/**
|
|
249
|
+
* Wire-body shape for 409 OCC `version_mismatch` responses. Extends the base
|
|
250
|
+
* `ServerError` envelope with a `kind` discriminator and the row's current
|
|
251
|
+
* server-side version. The bridge between `@atscript/moost-db`'s server-side
|
|
252
|
+
* `_disambiguateMismatch` and this typed client-side subclass is the wire
|
|
253
|
+
* JSON body — neither package depends on the other.
|
|
254
|
+
*/
|
|
255
|
+
interface VersionMismatchErrorBody extends ServerError {
|
|
256
|
+
kind: "version_mismatch";
|
|
257
|
+
currentVersion: number;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Typed marker thrown by `Client._send` when the server response body's
|
|
261
|
+
* `kind === 'version_mismatch'`. The transport / status / base body are
|
|
262
|
+
* identical to a generic `ClientError`; this subclass adds a typed
|
|
263
|
+
* `currentVersion` accessor so consumers can write
|
|
264
|
+
* `catch (e) { if (e instanceof VersionMismatchError) … }` without casting.
|
|
265
|
+
*/
|
|
266
|
+
declare class VersionMismatchError extends ClientError {
|
|
267
|
+
name: string;
|
|
268
|
+
/** Row's current server-side version — clients refresh + retry against it. */
|
|
269
|
+
get currentVersion(): number;
|
|
270
|
+
}
|
|
248
271
|
/** Thrown by `Client.action()` when the action name is not present in `/meta`. */
|
|
249
272
|
declare class ActionNotFoundError extends Error {
|
|
250
273
|
readonly action: string;
|
|
@@ -264,4 +287,4 @@ declare class ActionUnsupportedError extends Error {
|
|
|
264
287
|
constructor(action: string, processor: string, message: string);
|
|
265
288
|
}
|
|
266
289
|
//#endregion
|
|
267
|
-
export { ActionDisabledError, type ActionDisabledErrorBody, ActionNotFoundError, ActionUnsupportedError, type AggregateQuery, type AggregateResult, type AtscriptClientShape, Client, ClientError, type ClientOptions, type ClientResponse, type ClientValidationError, type ClientValidator, type DataOf, type FieldMeta, type FilterExpr, type IdOf, type MetaResponse, type NavOf, type OwnOf, type PageResult, type RelationInfo, type SearchIndexInfo, type ServerError, type TCrudOp, type TCrudPermissions, type TDbActionInfo, type TDbActionIntent, type TDbActionLevel, type TDbActionProcessor, type TDbDeleteResult, type TDbInsertManyResult, type TDbInsertResult, type TDbUpdateResult, type TSerializedAnnotatedType, type TypedWithRelation, type Uniquery, type UniqueryControls, type ValidatorMode, encodeNavigateId, formatIdentifier, formatIdentifierField };
|
|
290
|
+
export { ActionDisabledError, type ActionDisabledErrorBody, ActionNotFoundError, ActionUnsupportedError, type AggregateQuery, type AggregateResult, type AtscriptClientShape, Client, ClientError, type ClientOptions, type ClientResponse, type ClientValidationError, type ClientValidator, type DataOf, type FieldMeta, type FilterExpr, type IdOf, type MetaResponse, type NavOf, type OwnOf, type PageResult, type RelationInfo, type SearchIndexInfo, type ServerError, type TCrudOp, type TCrudPermissions, type TDbActionInfo, type TDbActionIntent, type TDbActionLevel, type TDbActionProcessor, type TDbDeleteResult, type TDbInsertManyResult, type TDbInsertResult, type TDbUpdateResult, type TSerializedAnnotatedType, type TypedWithRelation, type Uniquery, type UniqueryControls, type ValidatorMode, VersionMismatchError, type VersionMismatchErrorBody, encodeNavigateId, formatIdentifier, formatIdentifierField };
|
package/dist/index.mjs
CHANGED
|
@@ -39,6 +39,20 @@ var ActionDisabledError = class extends ClientError {
|
|
|
39
39
|
return this.body.ids;
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
|
+
/**
|
|
43
|
+
* Typed marker thrown by `Client._send` when the server response body's
|
|
44
|
+
* `kind === 'version_mismatch'`. The transport / status / base body are
|
|
45
|
+
* identical to a generic `ClientError`; this subclass adds a typed
|
|
46
|
+
* `currentVersion` accessor so consumers can write
|
|
47
|
+
* `catch (e) { if (e instanceof VersionMismatchError) … }` without casting.
|
|
48
|
+
*/
|
|
49
|
+
var VersionMismatchError = class extends ClientError {
|
|
50
|
+
name = "VersionMismatchError";
|
|
51
|
+
/** Row's current server-side version — clients refresh + retry against it. */
|
|
52
|
+
get currentVersion() {
|
|
53
|
+
return this.body.currentVersion;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
42
56
|
/** Thrown by `Client.action()` when the action name is not present in `/meta`. */
|
|
43
57
|
var ActionNotFoundError = class extends Error {
|
|
44
58
|
name = "ActionNotFoundError";
|
|
@@ -380,6 +394,7 @@ var Client = class {
|
|
|
380
394
|
};
|
|
381
395
|
}
|
|
382
396
|
if (errorBody.name === "ActionDisabledError") throw new ActionDisabledError(res.status, errorBody);
|
|
397
|
+
if (errorBody.kind === "version_mismatch") throw new VersionMismatchError(res.status, errorBody);
|
|
383
398
|
throw new ClientError(res.status, errorBody);
|
|
384
399
|
}
|
|
385
400
|
if (!allowEmpty) return res.json();
|
|
@@ -427,4 +442,4 @@ function describeShape(value) {
|
|
|
427
442
|
return typeof value;
|
|
428
443
|
}
|
|
429
444
|
//#endregion
|
|
430
|
-
export { ActionDisabledError, ActionNotFoundError, ActionUnsupportedError, Client, ClientError, encodeNavigateId, formatIdentifier, formatIdentifierField };
|
|
445
|
+
export { ActionDisabledError, ActionNotFoundError, ActionUnsupportedError, Client, ClientError, VersionMismatchError, encodeNavigateId, formatIdentifier, formatIdentifierField };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atscript/db-client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.85",
|
|
4
4
|
"description": "Browser-compatible HTTP client for @atscript/moost-db REST endpoints.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"atscript",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@atscript/typescript": "^0.1.59",
|
|
51
51
|
"@uniqu/core": "^0.1.6",
|
|
52
52
|
"unplugin-atscript": "^0.1.59",
|
|
53
|
-
"@atscript/db": "0.1.
|
|
53
|
+
"@atscript/db": "0.1.85"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"@atscript/db": "^0.1.44",
|