@atscript/db-client 0.1.163 → 0.1.165

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.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as SearchIndexInfo, B as Uniquery, C as MetaResponse, D as PatchOf, E as PageResult, F as TDbInsertManyResult, G as MetaStoreOptions, H as ValidGroupBy, I as TDbInsertResult, K as clearMetaStore, L as TDbQueryTarget, M as TDbDeleteResult, N as TDbInsertIgnoreResult, O as RelationInfo, P as TDbInsertManyIgnoreResult, R as TDbUpdateResult, S as IdOf, T as OwnOf, U as WeekStart, V as UniqueryControls, W as MetaStore, _ as DbRow, a as ValidatorMode, b as FieldMeta, c as AggregateResult, d as BucketUnit, f as CalendarBucketLabel, g as DbPatch, h as DataOf, j as ServerError, k as RowOf, l as AtscriptClientShape, m as ClientResponse, n as ClientValidator, p as ClientOptions, q as defaultMetaStore, r as ClientValidatorOptions, s as AggregateQuery, t as ClientValidationError, u as BucketExpr, v as DecoratedControls, w as NavOf, x as FilterExpr, y as DecoratedQuery, z as TypedWithRelation } from "./validator-CI8qxCps.cjs";
1
+ import { $ as UniqueryControls, A as FieldMeta, B as RowOf, C as ClientOptions, D as DbRow, E as DbPatch, F as OwnOf, G as TDbInsertIgnoreResult, H as ServerError, I as PageResult, J as TDbInsertResult, K as TDbInsertManyIgnoreResult, L as PatchOf, M as IdOf, N as MetaResponse, O as DecoratedControls, P as NavOf, Q as Uniquery, R as RelationInfo, S as CalendarBucketLabel, T as DataOf, U as TClientCallOptions, V as SearchIndexInfo, W as TDbDeleteResult, X as TDbUpdateResult, Y as TDbQueryTarget, Z as TypedWithRelation, _ as AggregateQuery, at as defaultMetaStore, b as BucketExpr, c as ActionNotFoundError, d as ActionUnsupportedError, et as ValidGroupBy, f as ClientError, g as VersionMismatchErrorBody, h as VersionMismatchError, i as ValidatorMode, it as clearMetaStore, j as FilterExpr, k as DecoratedQuery, l as ActionTargetError, m as TransportError, n as ClientValidatorOptions, nt as MetaStore, o as ActionDisabledError, p as ClientValidationError, q as TDbInsertManyResult, rt as MetaStoreOptions, s as ActionDisabledErrorBody, t as ClientValidator, tt as WeekStart, u as ActionTargetErrorBody, v as AggregateResult, w as ClientResponse, x as BucketUnit, y as AtscriptClientShape, z as ResponseDataOf } from "./validator-DrJYT-pz.cjs";
2
2
  import { AggregateExpr, AggregateOfExpr, AggregateQuery as AggregateQuery$1, AggregateResult as AggregateResult$1, BucketExpr as BucketExpr$1, BucketSeriesOptions, NextBucketOptions, SelectArithExpr, Uniquery as Uniquery$1, ValidGroupBy as ValidGroupBy$1, bucketSeries, bucketStartInstant, nextBucketLabel } from "@uniqu/core";
3
3
  import { TAtscriptAnnotatedType, TSerializedAnnotatedType } from "@atscript/typescript/utils";
4
4
  import { TCrudOp, TCrudPermissions, TDbActionInfo, TDbActionInfo as TDbActionInfo$1, TDbActionIntent, TDbActionLevel, TDbActionProcessor, TDbActionTargetSummary, TDbActionTargetSummary as TDbActionTargetSummary$1, TDbAvailableActions, TDbAvailableActions as TDbAvailableActions$1, TDbDeleteResult as TDbDeleteResult$1, TDbInsertIgnoreResult as TDbInsertIgnoreResult$1, TDbInsertManyIgnoreResult as TDbInsertManyIgnoreResult$1, TDbInsertManyResult as TDbInsertManyResult$1, TDbInsertResult as TDbInsertResult$1, TDbUpdateResult as TDbUpdateResult$1 } from "@atscript/db";
@@ -64,13 +64,13 @@ declare class Client<T extends AtscriptClientShape = AtscriptClientShape, D exte
64
64
  * The response type narrows by the literal `$with` array in `query` —
65
65
  * relations not listed in `$with` are stripped from the row type.
66
66
  */
67
- query<Q extends DecoratedQuery<T, D> = DecoratedQuery<T, D>>(query?: Q): Promise<DecoratedRow<T, Q, D>[]>;
67
+ query<const Q extends DecoratedQuery<T, D> = DecoratedQuery<T, D>>(query?: Q, opts?: TClientCallOptions): Promise<DecoratedRow<T, Q, D>[]>;
68
68
  /**
69
69
  * `GET /query` with `$count: true` — returns record count.
70
70
  */
71
71
  count(query?: {
72
72
  filter?: Uniquery$1<Own<T>, Nav<T>>["filter"];
73
- }): Promise<number>;
73
+ }, opts?: TClientCallOptions): Promise<number>;
74
74
  /**
75
75
  * `GET /query` with `$groupBy` — aggregate query with typed dimension/measure fields.
76
76
  * `$groupBy: []` is the ungrouped aggregate: one row over the filtered set (served
@@ -88,14 +88,14 @@ declare class Client<T extends AtscriptClientShape = AtscriptClientShape, D exte
88
88
  * read a representative row ordered by `$rowOrder`. The URL forms are `expr(a/b):x`,
89
89
  * `sum(a*b):x`, `first(f):x` and `$rowOrder=f,-id`.
90
90
  */
91
- aggregate<const Q extends AggregateQuery$1<Own<T>>>(query: Q & ValidGroupBy$1<Own<T>, Q>): Promise<Q["controls"]["$select"] extends readonly (string | AggregateExpr | BucketExpr$1 | AggregateOfExpr | SelectArithExpr)[] ? AggregateResult$1<Own<T>, Q["controls"]["$select"]>[] : Record<string, unknown>[]>;
91
+ aggregate<const Q extends AggregateQuery$1<Own<T>>>(query: Q & ValidGroupBy$1<Own<T>, Q>, opts?: TClientCallOptions): Promise<Q["controls"]["$select"] extends readonly (string | AggregateExpr | BucketExpr$1 | AggregateOfExpr | SelectArithExpr)[] ? AggregateResult$1<Own<T>, Q["controls"]["$select"]>[] : Record<string, unknown>[]>;
92
92
  /**
93
93
  * `GET /pages` — paginated query with typed filter and relations.
94
94
  *
95
95
  * Response rows narrow by the literal `$with` array — same algebra as
96
96
  * {@link query}.
97
97
  */
98
- pages<Q extends DecoratedQuery<T, D> = DecoratedQuery<T, D>>(query?: Q, page?: number, size?: number): Promise<PageResult<DecoratedRow<T, Q, D>>>;
98
+ pages<const Q extends DecoratedQuery<T, D> = DecoratedQuery<T, D>>(query?: Q, page?: number, size?: number, opts?: TClientCallOptions): Promise<PageResult<DecoratedRow<T, Q, D>>>;
99
99
  /**
100
100
  * `GET /geo` — distance-ranked geospatial search (tables with `@db.index.geo`).
101
101
  *
@@ -105,13 +105,13 @@ declare class Client<T extends AtscriptClientShape = AtscriptClientShape, D exte
105
105
  * in `query.controls`; filter / `$select` / `$with` / `$skip` / `$limit`
106
106
  * compose as usual.
107
107
  */
108
- geoSearch<Q extends DecoratedQuery<T, D> = DecoratedQuery<T, D>>(point: [number, number], query?: Q): Promise<Array<DecoratedRow<T, Q, D> & {
108
+ geoSearch<const Q extends DecoratedQuery<T, D> = DecoratedQuery<T, D>>(point: [number, number], query?: Q, opts?: TClientCallOptions): Promise<Array<DecoratedRow<T, Q, D> & {
109
109
  $distance: number;
110
110
  }>>;
111
111
  /**
112
112
  * `GET /geo` with `$page` / `$size` — paginated distance-ranked search.
113
113
  */
114
- geoPages<Q extends DecoratedQuery<T, D> = DecoratedQuery<T, D>>(point: [number, number], query?: Q, page?: number, size?: number): Promise<PageResult<DecoratedRow<T, Q, D> & {
114
+ geoPages<const Q extends DecoratedQuery<T, D> = DecoratedQuery<T, D>>(point: [number, number], query?: Q, page?: number, size?: number, opts?: TClientCallOptions): Promise<PageResult<DecoratedRow<T, Q, D> & {
115
115
  $distance: number;
116
116
  }>>;
117
117
  /**
@@ -120,32 +120,32 @@ declare class Client<T extends AtscriptClientShape = AtscriptClientShape, D exte
120
120
  * Returns `null` on 404. Response narrows by the literal `$with` array in
121
121
  * `query.controls` — same algebra as {@link query}.
122
122
  */
123
- one<Q extends {
123
+ one<const Q extends {
124
124
  controls?: DecoratedControls<T, D>;
125
125
  } = {
126
126
  controls?: DecoratedControls<T, D>;
127
- }>(id: Id<T>, query?: Q): Promise<DecoratedRow<T, Q, D> | null>;
127
+ }>(id: Id<T>, query?: Q, opts?: TClientCallOptions): Promise<DecoratedRow<T, Q, D> | null>;
128
128
  /**
129
129
  * `POST /` — insert one record. The version column (if any) is optional —
130
130
  * the server initialises it; `$cas` is rejected (no meaning on insert).
131
131
  */
132
- insert(data: PatchOf<T>): Promise<TDbInsertResult$1>;
132
+ insert(data: PatchOf<T>, opts?: TClientCallOptions): Promise<TDbInsertResult$1>;
133
133
  /**
134
134
  * `POST /` — insert many records.
135
135
  */
136
- insert(data: PatchOf<T>[]): Promise<TDbInsertManyResult$1>;
136
+ insert(data: PatchOf<T>[], opts?: TClientCallOptions): Promise<TDbInsertManyResult$1>;
137
137
  /**
138
138
  * `POST /?$onConflict=ignore` — insert one record, skipping it when it
139
139
  * collides on the primary key or a unique index (since 0.1.148).
140
140
  */
141
- insert(data: PatchOf<T>, opts: {
141
+ insert(data: PatchOf<T>, opts: TClientCallOptions & {
142
142
  onConflict: "ignore";
143
143
  }): Promise<TDbInsertIgnoreResult$1>;
144
144
  /**
145
145
  * `POST /?$onConflict=ignore` — insert many records, skipping the ones that
146
146
  * collide; the result reports inserted and skipped input indices (since 0.1.148).
147
147
  */
148
- insert(data: PatchOf<T>[], opts: {
148
+ insert(data: PatchOf<T>[], opts: TClientCallOptions & {
149
149
  onConflict: "ignore";
150
150
  }): Promise<TDbInsertManyIgnoreResult$1>;
151
151
  /**
@@ -157,16 +157,16 @@ declare class Client<T extends AtscriptClientShape = AtscriptClientShape, D exte
157
157
  * {@link VersionMismatchError}; a PK-only body with a version is a real
158
158
  * write (the server bumps the version).
159
159
  */
160
- update(data: PatchOf<T> | PatchOf<T>[]): Promise<TDbUpdateResult$1>;
160
+ update(data: PatchOf<T> | PatchOf<T>[], opts?: TClientCallOptions): Promise<TDbUpdateResult$1>;
161
161
  /**
162
162
  * `PUT /` — full replace one or many records by primary key. Same OCC
163
163
  * shapes as {@link update}; the version column itself is optional.
164
164
  */
165
- replace(data: RowOf<T> | RowOf<T>[]): Promise<TDbUpdateResult$1>;
165
+ replace(data: RowOf<T> | RowOf<T>[], opts?: TClientCallOptions): Promise<TDbUpdateResult$1>;
166
166
  /**
167
167
  * `DELETE /:id` or `DELETE /?k1=v1&k2=v2` — remove a record by primary key.
168
168
  */
169
- remove(id: Id<T>): Promise<TDbDeleteResult$1>;
169
+ remove(id: Id<T>, opts?: TClientCallOptions): Promise<TDbDeleteResult$1>;
170
170
  /**
171
171
  * `GET /meta` — table/view metadata (cached after first call).
172
172
  *
@@ -390,169 +390,4 @@ declare function formatIdentifier(id: Record<string, unknown> | undefined, prefe
390
390
  */
391
391
  declare function encodeNavigateId(id: Record<string, unknown>, preferredId: readonly string[]): string;
392
392
  //#endregion
393
- //#region src/client-error.d.ts
394
- /**
395
- * Error thrown by `Client` when the server responds with a non-2xx status code.
396
- * Captures the HTTP status and the structured error body from moost-db.
397
- */
398
- declare class ClientError extends Error {
399
- /** HTTP status code (e.g. 400, 404, 409, 500). */
400
- readonly status: number;
401
- /** Structured error response from the server. */
402
- readonly body: ServerError;
403
- name: string;
404
- constructor(/** HTTP status code (e.g. 400, 404, 409, 500). */
405
-
406
- status: number, /** Structured error response from the server. */
407
-
408
- body: ServerError);
409
- /** Shortcut to structured validation/DB errors from the server. */
410
- get errors(): {
411
- path: string;
412
- message: string;
413
- details?: unknown[];
414
- }[];
415
- }
416
- /**
417
- * Wire-body shape for `ActionDisabledError` responses (HTTP 409). Extends
418
- * the base `ServerError` envelope with a `name` discriminator, the action
419
- * name, and the offending identifier(s). The bridge between `@atscript/moost-db`'s
420
- * server-side error and this typed client-side subclass is the wire JSON
421
- * body — neither package depends on the other.
422
- */
423
- interface ActionDisabledErrorBody extends ServerError {
424
- name: "ActionDisabledError";
425
- action: string;
426
- id?: Record<string, unknown>;
427
- ids?: Record<string, unknown>[];
428
- /** Reason shared by every rejected row, when the server's predicate gave one. @since 0.1.141 */
429
- reason?: string;
430
- /** `'rows'` level: index-aligned with `ids`, `null` = no reason for that row. @since 0.1.141 */
431
- reasons?: (string | null)[];
432
- }
433
- /**
434
- * Typed marker thrown by `Client._send` when the server response body's
435
- * `name === 'ActionDisabledError'`. The transport / status / base body are
436
- * identical to a generic `ClientError`; this subclass adds typed accessors
437
- * so consumers can write `catch (e) { if (e instanceof ActionDisabledError) … }`
438
- * to access `action` / `id` / `ids` / `reason` / `reasons` without indexing
439
- * into `body`.
440
- */
441
- declare class ActionDisabledError extends ClientError {
442
- name: string;
443
- /** The `@DbAction` name that rejected the request. */
444
- get action(): string;
445
- /** Present only for `'row'`-level rejections. */
446
- get id(): Record<string, unknown> | undefined;
447
- /** Present only for `'rows'`-level rejections (full list of failing IDs). */
448
- get ids(): Record<string, unknown>[] | undefined;
449
- /**
450
- * Human-readable reason shared by every rejected row — present only when
451
- * the server's `disabled` predicate returned one. `message` already
452
- * carries it.
453
- *
454
- * @since 0.1.141
455
- */
456
- get reason(): string | undefined;
457
- /**
458
- * `'rows'`-level only: per-row reasons index-aligned with {@link ids}
459
- * (`null` where that row has none). Present only when at least one
460
- * rejected row carries a reason.
461
- *
462
- * @since 0.1.141
463
- */
464
- get reasons(): (string | null)[] | undefined;
465
- }
466
- /**
467
- * Wire-body shape for `ActionTargetError` responses (since 0.1.147): a
468
- * query target the server refused — `code` says why.
469
- */
470
- interface ActionTargetErrorBody extends ServerError {
471
- name: "ActionTargetError";
472
- code: "TARGET_INVALID" | "TARGET_TOO_LARGE" | "TARGET_CHANGED";
473
- action: string;
474
- /** `TARGET_CHANGED`: the current match count. */
475
- matched?: number;
476
- /** `TARGET_TOO_LARGE`: the most rows one request may target. */
477
- cap?: number;
478
- }
479
- /**
480
- * Typed marker thrown by `Client` when a query-targeted action request is
481
- * refused (body `name === 'ActionTargetError'`): `TARGET_INVALID` (400),
482
- * `TARGET_TOO_LARGE` (400, `cap`) or `TARGET_CHANGED` (409, `matched` — the
483
- * rows the query matches now; re-confirm and retry with that count).
484
- *
485
- * @since 0.1.147
486
- */
487
- declare class ActionTargetError extends ClientError {
488
- name: string;
489
- get code(): ActionTargetErrorBody["code"];
490
- get action(): string;
491
- get matched(): number | undefined;
492
- get cap(): number | undefined;
493
- }
494
- /**
495
- * Wire-body shape for 409 OCC `version_mismatch` responses. Extends the base
496
- * `ServerError` envelope with a `kind` discriminator and the row's current
497
- * server-side version. The bridge between `@atscript/moost-db`'s server-side
498
- * `_disambiguateMismatch` and this typed client-side subclass is the wire
499
- * JSON body — neither package depends on the other.
500
- */
501
- interface VersionMismatchErrorBody extends ServerError {
502
- kind: "version_mismatch";
503
- currentVersion: number;
504
- }
505
- /**
506
- * Typed marker thrown by `Client._send` when the server response body's
507
- * `kind === 'version_mismatch'`. The transport / status / base body are
508
- * identical to a generic `ClientError`; this subclass adds a typed
509
- * `currentVersion` accessor so consumers can write
510
- * `catch (e) { if (e instanceof VersionMismatchError) … }` without casting.
511
- */
512
- declare class VersionMismatchError extends ClientError {
513
- name: string;
514
- /** Row's current server-side version — clients refresh + retry against it. */
515
- get currentVersion(): number;
516
- }
517
- /**
518
- * Thrown by `Client` when NO server verdict was obtained: `fetch` itself
519
- * rejected (network down, DNS, CORS, `AbortError`, …) or a 2xx response
520
- * carried a body that is not JSON. Unlike {@link ClientError} — where the
521
- * server answered and rejected — the request's outcome is unknown: a write
522
- * may have committed. Reload before retrying a non-idempotent write.
523
- * The underlying error is the standard `cause`.
524
- */
525
- declare class TransportError extends Error {
526
- /** HTTP method of the failed request. */
527
- readonly method: string;
528
- /** Full request URL. */
529
- readonly url: string;
530
- name: string;
531
- constructor(/** HTTP method of the failed request. */
532
-
533
- method: string, /** Full request URL. */
534
-
535
- url: string, /** What went wrong; the message is `<method> <url>: <detail>`. */
536
-
537
- detail: string, cause?: unknown);
538
- }
539
- /** Thrown by `Client.action()` when the action name is not present in `/meta`. */
540
- declare class ActionNotFoundError extends Error {
541
- readonly action: string;
542
- name: string;
543
- constructor(action: string);
544
- }
545
- /**
546
- * Thrown by `Client.action()` for actions that cannot be invoked through
547
- * the client — currently `processor: 'custom'` (UI-dispatched events,
548
- * which the application is responsible for handling) and `processor: 'navigate'`
549
- * when no browser environment and no `navigate` option are configured.
550
- */
551
- declare class ActionUnsupportedError extends Error {
552
- readonly action: string;
553
- readonly processor: string;
554
- name: string;
555
- constructor(action: string, processor: string, message: string);
556
- }
557
- //#endregion
558
- export { ActionDisabledError, type ActionDisabledErrorBody, ActionNotFoundError, ActionTargetError, type ActionTargetErrorBody, ActionUnsupportedError, type AggregateQuery, type AggregateResult, type AtscriptClientShape, type BucketExpr, type BucketSeriesOptions, type BucketUnit, type CalendarBucketLabel, Client, ClientError, type ClientOptions, type ClientResponse, type ClientValidationError, type ClientValidator, type ClientValidatorOptions, type DataOf, type DbPatch, type DbRow, type FieldMeta, type FilterExpr, type IdOf, type MetaResponse, MetaStore, type MetaStoreOptions, type NavOf, type NextBucketOptions, type OwnOf, type PageResult, type PatchOf, type RelationInfo, type RowOf, type SearchIndexInfo, type ServerError, type TCrudOp, type TCrudPermissions, type TDbActionInfo, type TDbActionIntent, type TDbActionLevel, type TDbActionProcessor, type TDbActionTargetSummary, type TDbAvailableActions, type TDbDeleteResult, type TDbInsertIgnoreResult, type TDbInsertManyIgnoreResult, type TDbInsertManyResult, type TDbInsertResult, type TDbQueryTarget, type TDbUpdateResult, type TSerializedAnnotatedType, TransportError, type TypedWithRelation, type Uniquery, type UniqueryControls, type ValidGroupBy, type ValidatorMode, VersionMismatchError, type VersionMismatchErrorBody, type WeekStart, actionIdentifier, bucketSeries, bucketStartInstant, clearMetaStore, defaultMetaStore, encodeNavigateId, formatIdentifier, formatIdentifierField, nextBucketLabel };
393
+ export { ActionDisabledError, type ActionDisabledErrorBody, ActionNotFoundError, ActionTargetError, type ActionTargetErrorBody, ActionUnsupportedError, type AggregateQuery, type AggregateResult, type AtscriptClientShape, type BucketExpr, type BucketSeriesOptions, type BucketUnit, type CalendarBucketLabel, Client, ClientError, type ClientOptions, type ClientResponse, ClientValidationError, type ClientValidator, type ClientValidatorOptions, type DataOf, type DbPatch, type DbRow, type FieldMeta, type FilterExpr, type IdOf, type MetaResponse, MetaStore, type MetaStoreOptions, type NavOf, type NextBucketOptions, type OwnOf, type PageResult, type PatchOf, type RelationInfo, type ResponseDataOf, type RowOf, type SearchIndexInfo, type ServerError, type TClientCallOptions, type TCrudOp, type TCrudPermissions, type TDbActionInfo, type TDbActionIntent, type TDbActionLevel, type TDbActionProcessor, type TDbActionTargetSummary, type TDbAvailableActions, type TDbDeleteResult, type TDbInsertIgnoreResult, type TDbInsertManyIgnoreResult, type TDbInsertManyResult, type TDbInsertResult, type TDbQueryTarget, type TDbUpdateResult, type TSerializedAnnotatedType, TransportError, type TypedWithRelation, type Uniquery, type UniqueryControls, type ValidGroupBy, type ValidatorMode, VersionMismatchError, type VersionMismatchErrorBody, type WeekStart, actionIdentifier, bucketSeries, bucketStartInstant, clearMetaStore, defaultMetaStore, encodeNavigateId, formatIdentifier, formatIdentifierField, nextBucketLabel };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as SearchIndexInfo, B as Uniquery, C as MetaResponse, D as PatchOf, E as PageResult, F as TDbInsertManyResult, G as MetaStoreOptions, H as ValidGroupBy, I as TDbInsertResult, K as clearMetaStore, L as TDbQueryTarget, M as TDbDeleteResult, N as TDbInsertIgnoreResult, O as RelationInfo, P as TDbInsertManyIgnoreResult, R as TDbUpdateResult, S as IdOf, T as OwnOf, U as WeekStart, V as UniqueryControls, W as MetaStore, _ as DbRow, a as ValidatorMode, b as FieldMeta, c as AggregateResult, d as BucketUnit, f as CalendarBucketLabel, g as DbPatch, h as DataOf, j as ServerError, k as RowOf, l as AtscriptClientShape, m as ClientResponse, n as ClientValidator, p as ClientOptions, q as defaultMetaStore, r as ClientValidatorOptions, s as AggregateQuery, t as ClientValidationError, u as BucketExpr, v as DecoratedControls, w as NavOf, x as FilterExpr, y as DecoratedQuery, z as TypedWithRelation } from "./validator-zwjB-484.mjs";
1
+ import { $ as UniqueryControls, A as FieldMeta, B as RowOf, C as ClientOptions, D as DbRow, E as DbPatch, F as OwnOf, G as TDbInsertIgnoreResult, H as ServerError, I as PageResult, J as TDbInsertResult, K as TDbInsertManyIgnoreResult, L as PatchOf, M as IdOf, N as MetaResponse, O as DecoratedControls, P as NavOf, Q as Uniquery, R as RelationInfo, S as CalendarBucketLabel, T as DataOf, U as TClientCallOptions, V as SearchIndexInfo, W as TDbDeleteResult, X as TDbUpdateResult, Y as TDbQueryTarget, Z as TypedWithRelation, _ as AggregateQuery, at as defaultMetaStore, b as BucketExpr, c as ActionNotFoundError, d as ActionUnsupportedError, et as ValidGroupBy, f as ClientError, g as VersionMismatchErrorBody, h as VersionMismatchError, i as ValidatorMode, it as clearMetaStore, j as FilterExpr, k as DecoratedQuery, l as ActionTargetError, m as TransportError, n as ClientValidatorOptions, nt as MetaStore, o as ActionDisabledError, p as ClientValidationError, q as TDbInsertManyResult, rt as MetaStoreOptions, s as ActionDisabledErrorBody, t as ClientValidator, tt as WeekStart, u as ActionTargetErrorBody, v as AggregateResult, w as ClientResponse, x as BucketUnit, y as AtscriptClientShape, z as ResponseDataOf } from "./validator-tvR4Sl3l.mjs";
2
2
  import { TAtscriptAnnotatedType, TSerializedAnnotatedType } from "@atscript/typescript/utils";
3
3
  import { AggregateExpr, AggregateOfExpr, AggregateQuery as AggregateQuery$1, AggregateResult as AggregateResult$1, BucketExpr as BucketExpr$1, BucketSeriesOptions, NextBucketOptions, SelectArithExpr, Uniquery as Uniquery$1, ValidGroupBy as ValidGroupBy$1, bucketSeries, bucketStartInstant, nextBucketLabel } from "@uniqu/core";
4
4
  import { TCrudOp, TCrudPermissions, TDbActionInfo, TDbActionInfo as TDbActionInfo$1, TDbActionIntent, TDbActionLevel, TDbActionProcessor, TDbActionTargetSummary, TDbActionTargetSummary as TDbActionTargetSummary$1, TDbAvailableActions, TDbAvailableActions as TDbAvailableActions$1, TDbDeleteResult as TDbDeleteResult$1, TDbInsertIgnoreResult as TDbInsertIgnoreResult$1, TDbInsertManyIgnoreResult as TDbInsertManyIgnoreResult$1, TDbInsertManyResult as TDbInsertManyResult$1, TDbInsertResult as TDbInsertResult$1, TDbUpdateResult as TDbUpdateResult$1 } from "@atscript/db";
@@ -64,13 +64,13 @@ declare class Client<T extends AtscriptClientShape = AtscriptClientShape, D exte
64
64
  * The response type narrows by the literal `$with` array in `query` —
65
65
  * relations not listed in `$with` are stripped from the row type.
66
66
  */
67
- query<Q extends DecoratedQuery<T, D> = DecoratedQuery<T, D>>(query?: Q): Promise<DecoratedRow<T, Q, D>[]>;
67
+ query<const Q extends DecoratedQuery<T, D> = DecoratedQuery<T, D>>(query?: Q, opts?: TClientCallOptions): Promise<DecoratedRow<T, Q, D>[]>;
68
68
  /**
69
69
  * `GET /query` with `$count: true` — returns record count.
70
70
  */
71
71
  count(query?: {
72
72
  filter?: Uniquery$1<Own<T>, Nav<T>>["filter"];
73
- }): Promise<number>;
73
+ }, opts?: TClientCallOptions): Promise<number>;
74
74
  /**
75
75
  * `GET /query` with `$groupBy` — aggregate query with typed dimension/measure fields.
76
76
  * `$groupBy: []` is the ungrouped aggregate: one row over the filtered set (served
@@ -88,14 +88,14 @@ declare class Client<T extends AtscriptClientShape = AtscriptClientShape, D exte
88
88
  * read a representative row ordered by `$rowOrder`. The URL forms are `expr(a/b):x`,
89
89
  * `sum(a*b):x`, `first(f):x` and `$rowOrder=f,-id`.
90
90
  */
91
- aggregate<const Q extends AggregateQuery$1<Own<T>>>(query: Q & ValidGroupBy$1<Own<T>, Q>): Promise<Q["controls"]["$select"] extends readonly (string | AggregateExpr | BucketExpr$1 | AggregateOfExpr | SelectArithExpr)[] ? AggregateResult$1<Own<T>, Q["controls"]["$select"]>[] : Record<string, unknown>[]>;
91
+ aggregate<const Q extends AggregateQuery$1<Own<T>>>(query: Q & ValidGroupBy$1<Own<T>, Q>, opts?: TClientCallOptions): Promise<Q["controls"]["$select"] extends readonly (string | AggregateExpr | BucketExpr$1 | AggregateOfExpr | SelectArithExpr)[] ? AggregateResult$1<Own<T>, Q["controls"]["$select"]>[] : Record<string, unknown>[]>;
92
92
  /**
93
93
  * `GET /pages` — paginated query with typed filter and relations.
94
94
  *
95
95
  * Response rows narrow by the literal `$with` array — same algebra as
96
96
  * {@link query}.
97
97
  */
98
- pages<Q extends DecoratedQuery<T, D> = DecoratedQuery<T, D>>(query?: Q, page?: number, size?: number): Promise<PageResult<DecoratedRow<T, Q, D>>>;
98
+ pages<const Q extends DecoratedQuery<T, D> = DecoratedQuery<T, D>>(query?: Q, page?: number, size?: number, opts?: TClientCallOptions): Promise<PageResult<DecoratedRow<T, Q, D>>>;
99
99
  /**
100
100
  * `GET /geo` — distance-ranked geospatial search (tables with `@db.index.geo`).
101
101
  *
@@ -105,13 +105,13 @@ declare class Client<T extends AtscriptClientShape = AtscriptClientShape, D exte
105
105
  * in `query.controls`; filter / `$select` / `$with` / `$skip` / `$limit`
106
106
  * compose as usual.
107
107
  */
108
- geoSearch<Q extends DecoratedQuery<T, D> = DecoratedQuery<T, D>>(point: [number, number], query?: Q): Promise<Array<DecoratedRow<T, Q, D> & {
108
+ geoSearch<const Q extends DecoratedQuery<T, D> = DecoratedQuery<T, D>>(point: [number, number], query?: Q, opts?: TClientCallOptions): Promise<Array<DecoratedRow<T, Q, D> & {
109
109
  $distance: number;
110
110
  }>>;
111
111
  /**
112
112
  * `GET /geo` with `$page` / `$size` — paginated distance-ranked search.
113
113
  */
114
- geoPages<Q extends DecoratedQuery<T, D> = DecoratedQuery<T, D>>(point: [number, number], query?: Q, page?: number, size?: number): Promise<PageResult<DecoratedRow<T, Q, D> & {
114
+ geoPages<const Q extends DecoratedQuery<T, D> = DecoratedQuery<T, D>>(point: [number, number], query?: Q, page?: number, size?: number, opts?: TClientCallOptions): Promise<PageResult<DecoratedRow<T, Q, D> & {
115
115
  $distance: number;
116
116
  }>>;
117
117
  /**
@@ -120,32 +120,32 @@ declare class Client<T extends AtscriptClientShape = AtscriptClientShape, D exte
120
120
  * Returns `null` on 404. Response narrows by the literal `$with` array in
121
121
  * `query.controls` — same algebra as {@link query}.
122
122
  */
123
- one<Q extends {
123
+ one<const Q extends {
124
124
  controls?: DecoratedControls<T, D>;
125
125
  } = {
126
126
  controls?: DecoratedControls<T, D>;
127
- }>(id: Id<T>, query?: Q): Promise<DecoratedRow<T, Q, D> | null>;
127
+ }>(id: Id<T>, query?: Q, opts?: TClientCallOptions): Promise<DecoratedRow<T, Q, D> | null>;
128
128
  /**
129
129
  * `POST /` — insert one record. The version column (if any) is optional —
130
130
  * the server initialises it; `$cas` is rejected (no meaning on insert).
131
131
  */
132
- insert(data: PatchOf<T>): Promise<TDbInsertResult$1>;
132
+ insert(data: PatchOf<T>, opts?: TClientCallOptions): Promise<TDbInsertResult$1>;
133
133
  /**
134
134
  * `POST /` — insert many records.
135
135
  */
136
- insert(data: PatchOf<T>[]): Promise<TDbInsertManyResult$1>;
136
+ insert(data: PatchOf<T>[], opts?: TClientCallOptions): Promise<TDbInsertManyResult$1>;
137
137
  /**
138
138
  * `POST /?$onConflict=ignore` — insert one record, skipping it when it
139
139
  * collides on the primary key or a unique index (since 0.1.148).
140
140
  */
141
- insert(data: PatchOf<T>, opts: {
141
+ insert(data: PatchOf<T>, opts: TClientCallOptions & {
142
142
  onConflict: "ignore";
143
143
  }): Promise<TDbInsertIgnoreResult$1>;
144
144
  /**
145
145
  * `POST /?$onConflict=ignore` — insert many records, skipping the ones that
146
146
  * collide; the result reports inserted and skipped input indices (since 0.1.148).
147
147
  */
148
- insert(data: PatchOf<T>[], opts: {
148
+ insert(data: PatchOf<T>[], opts: TClientCallOptions & {
149
149
  onConflict: "ignore";
150
150
  }): Promise<TDbInsertManyIgnoreResult$1>;
151
151
  /**
@@ -157,16 +157,16 @@ declare class Client<T extends AtscriptClientShape = AtscriptClientShape, D exte
157
157
  * {@link VersionMismatchError}; a PK-only body with a version is a real
158
158
  * write (the server bumps the version).
159
159
  */
160
- update(data: PatchOf<T> | PatchOf<T>[]): Promise<TDbUpdateResult$1>;
160
+ update(data: PatchOf<T> | PatchOf<T>[], opts?: TClientCallOptions): Promise<TDbUpdateResult$1>;
161
161
  /**
162
162
  * `PUT /` — full replace one or many records by primary key. Same OCC
163
163
  * shapes as {@link update}; the version column itself is optional.
164
164
  */
165
- replace(data: RowOf<T> | RowOf<T>[]): Promise<TDbUpdateResult$1>;
165
+ replace(data: RowOf<T> | RowOf<T>[], opts?: TClientCallOptions): Promise<TDbUpdateResult$1>;
166
166
  /**
167
167
  * `DELETE /:id` or `DELETE /?k1=v1&k2=v2` — remove a record by primary key.
168
168
  */
169
- remove(id: Id<T>): Promise<TDbDeleteResult$1>;
169
+ remove(id: Id<T>, opts?: TClientCallOptions): Promise<TDbDeleteResult$1>;
170
170
  /**
171
171
  * `GET /meta` — table/view metadata (cached after first call).
172
172
  *
@@ -390,169 +390,4 @@ declare function formatIdentifier(id: Record<string, unknown> | undefined, prefe
390
390
  */
391
391
  declare function encodeNavigateId(id: Record<string, unknown>, preferredId: readonly string[]): string;
392
392
  //#endregion
393
- //#region src/client-error.d.ts
394
- /**
395
- * Error thrown by `Client` when the server responds with a non-2xx status code.
396
- * Captures the HTTP status and the structured error body from moost-db.
397
- */
398
- declare class ClientError extends Error {
399
- /** HTTP status code (e.g. 400, 404, 409, 500). */
400
- readonly status: number;
401
- /** Structured error response from the server. */
402
- readonly body: ServerError;
403
- name: string;
404
- constructor(/** HTTP status code (e.g. 400, 404, 409, 500). */
405
-
406
- status: number, /** Structured error response from the server. */
407
-
408
- body: ServerError);
409
- /** Shortcut to structured validation/DB errors from the server. */
410
- get errors(): {
411
- path: string;
412
- message: string;
413
- details?: unknown[];
414
- }[];
415
- }
416
- /**
417
- * Wire-body shape for `ActionDisabledError` responses (HTTP 409). Extends
418
- * the base `ServerError` envelope with a `name` discriminator, the action
419
- * name, and the offending identifier(s). The bridge between `@atscript/moost-db`'s
420
- * server-side error and this typed client-side subclass is the wire JSON
421
- * body — neither package depends on the other.
422
- */
423
- interface ActionDisabledErrorBody extends ServerError {
424
- name: "ActionDisabledError";
425
- action: string;
426
- id?: Record<string, unknown>;
427
- ids?: Record<string, unknown>[];
428
- /** Reason shared by every rejected row, when the server's predicate gave one. @since 0.1.141 */
429
- reason?: string;
430
- /** `'rows'` level: index-aligned with `ids`, `null` = no reason for that row. @since 0.1.141 */
431
- reasons?: (string | null)[];
432
- }
433
- /**
434
- * Typed marker thrown by `Client._send` when the server response body's
435
- * `name === 'ActionDisabledError'`. The transport / status / base body are
436
- * identical to a generic `ClientError`; this subclass adds typed accessors
437
- * so consumers can write `catch (e) { if (e instanceof ActionDisabledError) … }`
438
- * to access `action` / `id` / `ids` / `reason` / `reasons` without indexing
439
- * into `body`.
440
- */
441
- declare class ActionDisabledError extends ClientError {
442
- name: string;
443
- /** The `@DbAction` name that rejected the request. */
444
- get action(): string;
445
- /** Present only for `'row'`-level rejections. */
446
- get id(): Record<string, unknown> | undefined;
447
- /** Present only for `'rows'`-level rejections (full list of failing IDs). */
448
- get ids(): Record<string, unknown>[] | undefined;
449
- /**
450
- * Human-readable reason shared by every rejected row — present only when
451
- * the server's `disabled` predicate returned one. `message` already
452
- * carries it.
453
- *
454
- * @since 0.1.141
455
- */
456
- get reason(): string | undefined;
457
- /**
458
- * `'rows'`-level only: per-row reasons index-aligned with {@link ids}
459
- * (`null` where that row has none). Present only when at least one
460
- * rejected row carries a reason.
461
- *
462
- * @since 0.1.141
463
- */
464
- get reasons(): (string | null)[] | undefined;
465
- }
466
- /**
467
- * Wire-body shape for `ActionTargetError` responses (since 0.1.147): a
468
- * query target the server refused — `code` says why.
469
- */
470
- interface ActionTargetErrorBody extends ServerError {
471
- name: "ActionTargetError";
472
- code: "TARGET_INVALID" | "TARGET_TOO_LARGE" | "TARGET_CHANGED";
473
- action: string;
474
- /** `TARGET_CHANGED`: the current match count. */
475
- matched?: number;
476
- /** `TARGET_TOO_LARGE`: the most rows one request may target. */
477
- cap?: number;
478
- }
479
- /**
480
- * Typed marker thrown by `Client` when a query-targeted action request is
481
- * refused (body `name === 'ActionTargetError'`): `TARGET_INVALID` (400),
482
- * `TARGET_TOO_LARGE` (400, `cap`) or `TARGET_CHANGED` (409, `matched` — the
483
- * rows the query matches now; re-confirm and retry with that count).
484
- *
485
- * @since 0.1.147
486
- */
487
- declare class ActionTargetError extends ClientError {
488
- name: string;
489
- get code(): ActionTargetErrorBody["code"];
490
- get action(): string;
491
- get matched(): number | undefined;
492
- get cap(): number | undefined;
493
- }
494
- /**
495
- * Wire-body shape for 409 OCC `version_mismatch` responses. Extends the base
496
- * `ServerError` envelope with a `kind` discriminator and the row's current
497
- * server-side version. The bridge between `@atscript/moost-db`'s server-side
498
- * `_disambiguateMismatch` and this typed client-side subclass is the wire
499
- * JSON body — neither package depends on the other.
500
- */
501
- interface VersionMismatchErrorBody extends ServerError {
502
- kind: "version_mismatch";
503
- currentVersion: number;
504
- }
505
- /**
506
- * Typed marker thrown by `Client._send` when the server response body's
507
- * `kind === 'version_mismatch'`. The transport / status / base body are
508
- * identical to a generic `ClientError`; this subclass adds a typed
509
- * `currentVersion` accessor so consumers can write
510
- * `catch (e) { if (e instanceof VersionMismatchError) … }` without casting.
511
- */
512
- declare class VersionMismatchError extends ClientError {
513
- name: string;
514
- /** Row's current server-side version — clients refresh + retry against it. */
515
- get currentVersion(): number;
516
- }
517
- /**
518
- * Thrown by `Client` when NO server verdict was obtained: `fetch` itself
519
- * rejected (network down, DNS, CORS, `AbortError`, …) or a 2xx response
520
- * carried a body that is not JSON. Unlike {@link ClientError} — where the
521
- * server answered and rejected — the request's outcome is unknown: a write
522
- * may have committed. Reload before retrying a non-idempotent write.
523
- * The underlying error is the standard `cause`.
524
- */
525
- declare class TransportError extends Error {
526
- /** HTTP method of the failed request. */
527
- readonly method: string;
528
- /** Full request URL. */
529
- readonly url: string;
530
- name: string;
531
- constructor(/** HTTP method of the failed request. */
532
-
533
- method: string, /** Full request URL. */
534
-
535
- url: string, /** What went wrong; the message is `<method> <url>: <detail>`. */
536
-
537
- detail: string, cause?: unknown);
538
- }
539
- /** Thrown by `Client.action()` when the action name is not present in `/meta`. */
540
- declare class ActionNotFoundError extends Error {
541
- readonly action: string;
542
- name: string;
543
- constructor(action: string);
544
- }
545
- /**
546
- * Thrown by `Client.action()` for actions that cannot be invoked through
547
- * the client — currently `processor: 'custom'` (UI-dispatched events,
548
- * which the application is responsible for handling) and `processor: 'navigate'`
549
- * when no browser environment and no `navigate` option are configured.
550
- */
551
- declare class ActionUnsupportedError extends Error {
552
- readonly action: string;
553
- readonly processor: string;
554
- name: string;
555
- constructor(action: string, processor: string, message: string);
556
- }
557
- //#endregion
558
- export { ActionDisabledError, type ActionDisabledErrorBody, ActionNotFoundError, ActionTargetError, type ActionTargetErrorBody, ActionUnsupportedError, type AggregateQuery, type AggregateResult, type AtscriptClientShape, type BucketExpr, type BucketSeriesOptions, type BucketUnit, type CalendarBucketLabel, Client, ClientError, type ClientOptions, type ClientResponse, type ClientValidationError, type ClientValidator, type ClientValidatorOptions, type DataOf, type DbPatch, type DbRow, type FieldMeta, type FilterExpr, type IdOf, type MetaResponse, MetaStore, type MetaStoreOptions, type NavOf, type NextBucketOptions, type OwnOf, type PageResult, type PatchOf, type RelationInfo, type RowOf, type SearchIndexInfo, type ServerError, type TCrudOp, type TCrudPermissions, type TDbActionInfo, type TDbActionIntent, type TDbActionLevel, type TDbActionProcessor, type TDbActionTargetSummary, type TDbAvailableActions, type TDbDeleteResult, type TDbInsertIgnoreResult, type TDbInsertManyIgnoreResult, type TDbInsertManyResult, type TDbInsertResult, type TDbQueryTarget, type TDbUpdateResult, type TSerializedAnnotatedType, TransportError, type TypedWithRelation, type Uniquery, type UniqueryControls, type ValidGroupBy, type ValidatorMode, VersionMismatchError, type VersionMismatchErrorBody, type WeekStart, actionIdentifier, bucketSeries, bucketStartInstant, clearMetaStore, defaultMetaStore, encodeNavigateId, formatIdentifier, formatIdentifierField, nextBucketLabel };
393
+ export { ActionDisabledError, type ActionDisabledErrorBody, ActionNotFoundError, ActionTargetError, type ActionTargetErrorBody, ActionUnsupportedError, type AggregateQuery, type AggregateResult, type AtscriptClientShape, type BucketExpr, type BucketSeriesOptions, type BucketUnit, type CalendarBucketLabel, Client, ClientError, type ClientOptions, type ClientResponse, ClientValidationError, type ClientValidator, type ClientValidatorOptions, type DataOf, type DbPatch, type DbRow, type FieldMeta, type FilterExpr, type IdOf, type MetaResponse, MetaStore, type MetaStoreOptions, type NavOf, type NextBucketOptions, type OwnOf, type PageResult, type PatchOf, type RelationInfo, type ResponseDataOf, type RowOf, type SearchIndexInfo, type ServerError, type TClientCallOptions, type TCrudOp, type TCrudPermissions, type TDbActionInfo, type TDbActionIntent, type TDbActionLevel, type TDbActionProcessor, type TDbActionTargetSummary, type TDbAvailableActions, type TDbDeleteResult, type TDbInsertIgnoreResult, type TDbInsertManyIgnoreResult, type TDbInsertManyResult, type TDbInsertResult, type TDbQueryTarget, type TDbUpdateResult, type TSerializedAnnotatedType, TransportError, type TypedWithRelation, type Uniquery, type UniqueryControls, type ValidGroupBy, type ValidatorMode, VersionMismatchError, type VersionMismatchErrorBody, type WeekStart, actionIdentifier, bucketSeries, bucketStartInstant, clearMetaStore, defaultMetaStore, encodeNavigateId, formatIdentifier, formatIdentifierField, nextBucketLabel };