@atscript/db-client 0.1.57 → 0.1.58

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 CHANGED
@@ -17,6 +17,28 @@ var ClientError = class extends Error {
17
17
  return this.body.errors ?? [];
18
18
  }
19
19
  };
20
+ /**
21
+ * Typed marker thrown by `Client._send` when the server response body's
22
+ * `name === 'ActionDisabledError'`. The transport / status / base body are
23
+ * identical to a generic `ClientError`; this subclass adds typed accessors
24
+ * so consumers can write `catch (e) { if (e instanceof ActionDisabledError) … }`
25
+ * to access `action` / `pk` / `pks` without indexing into `body`.
26
+ */
27
+ var ActionDisabledError = class extends ClientError {
28
+ name = "ActionDisabledError";
29
+ /** The `@DbAction` name that rejected the request. */
30
+ get action() {
31
+ return this.body.action;
32
+ }
33
+ /** Present only for `'row'`-level rejections. */
34
+ get pk() {
35
+ return this.body.pk;
36
+ }
37
+ /** Present only for `'rows'`-level rejections (full list of failing PKs). */
38
+ get pks() {
39
+ return this.body.pks;
40
+ }
41
+ };
20
42
  /** Thrown by `Client.action()` when the action name is not present in `/meta`. */
21
43
  var ActionNotFoundError = class extends Error {
22
44
  name = "ActionNotFoundError";
@@ -291,6 +313,7 @@ var Client = class {
291
313
  statusCode: res.status
292
314
  };
293
315
  }
316
+ if (errorBody.name === "ActionDisabledError") throw new ActionDisabledError(res.status, errorBody);
294
317
  throw new ClientError(res.status, errorBody);
295
318
  }
296
319
  if (!allowEmpty) return res.json();
@@ -313,6 +336,7 @@ function encodeNavigatePk(pk) {
313
336
  return (typeof pk === "object" ? Object.values(pk) : [pk]).map((v) => encodeURIComponent(String(v))).join("/");
314
337
  }
315
338
  //#endregion
339
+ exports.ActionDisabledError = ActionDisabledError;
316
340
  exports.ActionNotFoundError = ActionNotFoundError;
317
341
  exports.ActionUnsupportedError = ActionUnsupportedError;
318
342
  exports.Client = Client;
package/dist/index.d.cts CHANGED
@@ -156,6 +156,35 @@ declare class ClientError extends Error {
156
156
  details?: unknown[];
157
157
  }[];
158
158
  }
159
+ /**
160
+ * Wire-body shape for `ActionDisabledError` responses (HTTP 409). Extends
161
+ * the base `ServerError` envelope with a `name` discriminator, the action
162
+ * name, and the offending PK(s). The bridge between `@atscript/moost-db`'s
163
+ * server-side error and this typed client-side subclass is the wire JSON
164
+ * body — neither package depends on the other.
165
+ */
166
+ interface ActionDisabledErrorBody extends ServerError {
167
+ name: "ActionDisabledError";
168
+ action: string;
169
+ pk?: unknown;
170
+ pks?: unknown[];
171
+ }
172
+ /**
173
+ * Typed marker thrown by `Client._send` when the server response body's
174
+ * `name === 'ActionDisabledError'`. The transport / status / base body are
175
+ * identical to a generic `ClientError`; this subclass adds typed accessors
176
+ * so consumers can write `catch (e) { if (e instanceof ActionDisabledError) … }`
177
+ * to access `action` / `pk` / `pks` without indexing into `body`.
178
+ */
179
+ declare class ActionDisabledError extends ClientError {
180
+ name: string;
181
+ /** The `@DbAction` name that rejected the request. */
182
+ get action(): string;
183
+ /** Present only for `'row'`-level rejections. */
184
+ get pk(): unknown;
185
+ /** Present only for `'rows'`-level rejections (full list of failing PKs). */
186
+ get pks(): unknown[] | undefined;
187
+ }
159
188
  /** Thrown by `Client.action()` when the action name is not present in `/meta`. */
160
189
  declare class ActionNotFoundError extends Error {
161
190
  readonly action: string;
@@ -175,4 +204,4 @@ declare class ActionUnsupportedError extends Error {
175
204
  constructor(action: string, processor: string, message: string);
176
205
  }
177
206
  //#endregion
178
- export { ActionNotFoundError, ActionUnsupportedError, type AggregateQuery, type AggregateResult, Client, ClientError, type ClientOptions, 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 };
207
+ export { ActionDisabledError, type ActionDisabledErrorBody, ActionNotFoundError, ActionUnsupportedError, type AggregateQuery, type AggregateResult, Client, ClientError, type ClientOptions, 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 };
package/dist/index.d.mts CHANGED
@@ -156,6 +156,35 @@ declare class ClientError extends Error {
156
156
  details?: unknown[];
157
157
  }[];
158
158
  }
159
+ /**
160
+ * Wire-body shape for `ActionDisabledError` responses (HTTP 409). Extends
161
+ * the base `ServerError` envelope with a `name` discriminator, the action
162
+ * name, and the offending PK(s). The bridge between `@atscript/moost-db`'s
163
+ * server-side error and this typed client-side subclass is the wire JSON
164
+ * body — neither package depends on the other.
165
+ */
166
+ interface ActionDisabledErrorBody extends ServerError {
167
+ name: "ActionDisabledError";
168
+ action: string;
169
+ pk?: unknown;
170
+ pks?: unknown[];
171
+ }
172
+ /**
173
+ * Typed marker thrown by `Client._send` when the server response body's
174
+ * `name === 'ActionDisabledError'`. The transport / status / base body are
175
+ * identical to a generic `ClientError`; this subclass adds typed accessors
176
+ * so consumers can write `catch (e) { if (e instanceof ActionDisabledError) … }`
177
+ * to access `action` / `pk` / `pks` without indexing into `body`.
178
+ */
179
+ declare class ActionDisabledError extends ClientError {
180
+ name: string;
181
+ /** The `@DbAction` name that rejected the request. */
182
+ get action(): string;
183
+ /** Present only for `'row'`-level rejections. */
184
+ get pk(): unknown;
185
+ /** Present only for `'rows'`-level rejections (full list of failing PKs). */
186
+ get pks(): unknown[] | undefined;
187
+ }
159
188
  /** Thrown by `Client.action()` when the action name is not present in `/meta`. */
160
189
  declare class ActionNotFoundError extends Error {
161
190
  readonly action: string;
@@ -175,4 +204,4 @@ declare class ActionUnsupportedError extends Error {
175
204
  constructor(action: string, processor: string, message: string);
176
205
  }
177
206
  //#endregion
178
- export { ActionNotFoundError, ActionUnsupportedError, type AggregateQuery, type AggregateResult, Client, ClientError, type ClientOptions, 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 };
207
+ export { ActionDisabledError, type ActionDisabledErrorBody, ActionNotFoundError, ActionUnsupportedError, type AggregateQuery, type AggregateResult, Client, ClientError, type ClientOptions, 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 };
package/dist/index.mjs CHANGED
@@ -16,6 +16,28 @@ var ClientError = class extends Error {
16
16
  return this.body.errors ?? [];
17
17
  }
18
18
  };
19
+ /**
20
+ * Typed marker thrown by `Client._send` when the server response body's
21
+ * `name === 'ActionDisabledError'`. The transport / status / base body are
22
+ * identical to a generic `ClientError`; this subclass adds typed accessors
23
+ * so consumers can write `catch (e) { if (e instanceof ActionDisabledError) … }`
24
+ * to access `action` / `pk` / `pks` without indexing into `body`.
25
+ */
26
+ var ActionDisabledError = class extends ClientError {
27
+ name = "ActionDisabledError";
28
+ /** The `@DbAction` name that rejected the request. */
29
+ get action() {
30
+ return this.body.action;
31
+ }
32
+ /** Present only for `'row'`-level rejections. */
33
+ get pk() {
34
+ return this.body.pk;
35
+ }
36
+ /** Present only for `'rows'`-level rejections (full list of failing PKs). */
37
+ get pks() {
38
+ return this.body.pks;
39
+ }
40
+ };
19
41
  /** Thrown by `Client.action()` when the action name is not present in `/meta`. */
20
42
  var ActionNotFoundError = class extends Error {
21
43
  name = "ActionNotFoundError";
@@ -290,6 +312,7 @@ var Client = class {
290
312
  statusCode: res.status
291
313
  };
292
314
  }
315
+ if (errorBody.name === "ActionDisabledError") throw new ActionDisabledError(res.status, errorBody);
293
316
  throw new ClientError(res.status, errorBody);
294
317
  }
295
318
  if (!allowEmpty) return res.json();
@@ -312,4 +335,4 @@ function encodeNavigatePk(pk) {
312
335
  return (typeof pk === "object" ? Object.values(pk) : [pk]).map((v) => encodeURIComponent(String(v))).join("/");
313
336
  }
314
337
  //#endregion
315
- export { ActionNotFoundError, ActionUnsupportedError, Client, ClientError };
338
+ export { ActionDisabledError, ActionNotFoundError, ActionUnsupportedError, Client, ClientError };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atscript/db-client",
3
- "version": "0.1.57",
3
+ "version": "0.1.58",
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.50",
51
51
  "@uniqu/core": "^0.1.5",
52
52
  "unplugin-atscript": "^0.1.50",
53
- "@atscript/db": "0.1.57"
53
+ "@atscript/db": "0.1.58"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "@atscript/db": "^0.1.44",