@atscript/db-client 0.1.167 → 0.1.169

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
@@ -1,7 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_client_error = require("./client-error-C9Q5xCuW.cjs");
3
3
  let _uniqu_url_builder = require("@uniqu/url/builder");
4
- let _atscript_typescript_utils = require("@atscript/typescript/utils");
5
4
  let _uniqu_core = require("@uniqu/core");
6
5
  //#region src/meta-store.ts
7
6
  /** ETags remembered per store key (most recent first). */
@@ -222,6 +221,16 @@ var Client = class {
222
221
  * numeric entries or numeric `$groupBy` fields (`number | null`). `first` / `last`
223
222
  * read a representative row ordered by `$rowOrder`. The URL forms are `expr(a/b):x`,
224
223
  * `sum(a*b):x`, `first(f):x` and `$rowOrder=f,-id`.
224
+ *
225
+ * Since 0.1.168 (server: `/meta` `distinctFieldLists`, `conditionalAggregates`,
226
+ * `nestedAggregates`):
227
+ * - `{ $fn: 'countDistinct', $field: ['a', 'b'] }` counts distinct combinations (a row
228
+ * with any NULL field is not counted); URL `countDistinct(a,b)`;
229
+ * - `{ $fn, $field, $where, $as }` aggregates only the rows matching `$where` (a typed
230
+ * filter); URL `sum(amount|status=paid):paid`;
231
+ * - a query with `controls.$from` is a two-level aggregate: `$from` groups the filtered
232
+ * rows, the root controls aggregate its rows and name its columns (its `$groupBy`
233
+ * keys and aliases) — typed by `ValidNested`, rows by `NestedAggregateResult`.
225
234
  */
226
235
  async aggregate(query, opts) {
227
236
  return this._get("query", query, opts?.signal);
@@ -286,7 +295,11 @@ var Client = class {
286
295
  }
287
296
  async insert(data, opts) {
288
297
  const query = opts?.onConflict === "ignore" ? "?$onConflict=ignore" : "";
289
- return this._request("POST", query, await this._prepareWrite(data, "insert"), opts);
298
+ const headers = opts?.returning ? { Prefer: "return=representation" } : void 0;
299
+ return this._request("POST", query, await this._prepareWrite(data, "insert"), {
300
+ signal: opts?.signal,
301
+ headers
302
+ });
290
303
  }
291
304
  /**
292
305
  * `PATCH /` — partial update one or many records by primary key.
@@ -520,7 +533,7 @@ var Client = class {
520
533
  _loadActionForm(url) {
521
534
  let p = this._formCache.get(url);
522
535
  if (!p) {
523
- const loading = this._requestUrl("GET", url).then((schema) => (0, _atscript_typescript_utils.deserializeAnnotatedType)(schema)).catch((err) => {
536
+ const loading = Promise.all([this._requestUrl("GET", url), import("@atscript/typescript/utils")]).then(([schema, { deserializeAnnotatedType }]) => deserializeAnnotatedType(schema)).catch((err) => {
524
537
  if (this._formCache.get(url) === loading) this._formCache.delete(url);
525
538
  throw err;
526
539
  });
@@ -717,7 +730,10 @@ var Client = class {
717
730
  }
718
731
  /** Sends one request to an absolute URL with the client's headers and a JSON body. */
719
732
  async _requestUrl(method, url, body, opts) {
720
- const headers = { ...await this._resolveHeaders() };
733
+ const headers = {
734
+ ...await this._resolveHeaders(),
735
+ ...opts?.headers
736
+ };
721
737
  const init = {
722
738
  method,
723
739
  headers
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
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
- 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";
1
+ import { $ as TDbInsertManyResult, A as DecoratedControls, B as OwnOf, C as CalendarBucketLabel, D as DbInsert, E as DataOf, F as InsertOf, G as RowOf, H as PatchOf, I as MetaResponse, J as StageRow, K as SearchIndexInfo, L as NavOf, M as FieldMeta, N as FilterExpr, O as DbPatch, P as IdOf, Q as TDbInsertManyIgnoreResult, R as NestedAggregateQuery, S as BucketUnit, T as ClientResponse, U as RelationInfo, V as PageResult, W as ResponseDataOf, X as TDbDeleteResult, Y as TClientCallOptions, Z as TDbInsertIgnoreResult, _ as AggregateQuery, at as UniqueryControls, b as AtscriptClientShape, c as ActionNotFoundError, ct as WeekStart, d as ActionUnsupportedError, dt as clearMetaStore, et as TDbInsertResult, f as ClientError, ft as defaultMetaStore, g as VersionMismatchErrorBody, h as VersionMismatchError, i as ValidatorMode, it as Uniquery, j as DecoratedQuery, k as DbRow, l as ActionTargetError, lt as MetaStore, m as TransportError, n as ClientValidatorOptions, nt as TDbUpdateResult, o as ActionDisabledError, ot as ValidGroupBy, p as ClientValidationError, q as ServerError, rt as TypedWithRelation, s as ActionDisabledErrorBody, st as ValidNested, t as ClientValidator, tt as TDbQueryTarget, u as ActionTargetErrorBody, ut as MetaStoreOptions, v as AggregateResult, w as ClientOptions, x as BucketExpr, y as AggregateStage, z as NestedAggregateResult } from "./validator-BfGRI3X9.cjs";
2
+ import { AggregateQuery as AggregateQuery$1, AggregateResult as AggregateResult$1, BucketSeriesOptions, ComputedExpr, NestedAggregateQuery as NestedAggregateQuery$1, NestedAggregateResult as NestedAggregateResult$1, NextBucketOptions, Uniquery as Uniquery$1, ValidGroupBy as ValidGroupBy$1, ValidNested as ValidNested$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";
5
5
 
@@ -10,6 +10,25 @@ type Id<T> = IdOf<T>;
10
10
  type Response<T, Q> = ClientResponse<T, Q>;
11
11
  /** A read row: the response over the own fields plus the declared decorations `D`, each optional. */
12
12
  type DecoratedRow<T, Q, D> = Response<T, Q> & Partial<D>;
13
+ /**
14
+ * One insert row for `returning`: an untyped client's row is any `object`,
15
+ * which an array would match too — there it is any non-array object.
16
+ */
17
+ type SingleInsertOf<T> = [keyof InsertOf<T>] extends [never] ? Record<string, any> & {
18
+ readonly [Symbol.iterator]?: never;
19
+ } : InsertOf<T>;
20
+ /** The stored row `insert(row, { returning: true })` answers: the `one()` row shape. */
21
+ type InsertedRow<T, D> = DecoratedRow<T, Record<never, never>, D>;
22
+ /** A two-level aggregate query: one with `controls.$from`. */
23
+ type NestedShape = {
24
+ controls: {
25
+ $from: object;
26
+ };
27
+ };
28
+ /** The compile-time check an aggregate query must pass: two-level or flat. */
29
+ type AggregateCheck<T, Q> = Q extends NestedShape ? ValidNested$1<T, Q> : ValidGroupBy$1<T, Q>;
30
+ /** The rows `aggregate()` answers for query `Q`. */
31
+ type AggregateRows<T, Q extends AggregateQuery$1<T> | NestedAggregateQuery$1<T>> = Q extends NestedShape ? NestedAggregateResult$1<T, Q>[] : Q["controls"]["$select"] extends readonly (string | ComputedExpr)[] ? AggregateResult$1<T, Q["controls"]["$select"]>[] : Record<string, unknown>[];
13
32
  /**
14
33
  * HTTP client for moost-db REST endpoints.
15
34
  *
@@ -87,8 +106,18 @@ declare class Client<T extends AtscriptClientShape = AtscriptClientShape, D exte
87
106
  * numeric entries or numeric `$groupBy` fields (`number | null`). `first` / `last`
88
107
  * read a representative row ordered by `$rowOrder`. The URL forms are `expr(a/b):x`,
89
108
  * `sum(a*b):x`, `first(f):x` and `$rowOrder=f,-id`.
109
+ *
110
+ * Since 0.1.168 (server: `/meta` `distinctFieldLists`, `conditionalAggregates`,
111
+ * `nestedAggregates`):
112
+ * - `{ $fn: 'countDistinct', $field: ['a', 'b'] }` counts distinct combinations (a row
113
+ * with any NULL field is not counted); URL `countDistinct(a,b)`;
114
+ * - `{ $fn, $field, $where, $as }` aggregates only the rows matching `$where` (a typed
115
+ * filter); URL `sum(amount|status=paid):paid`;
116
+ * - a query with `controls.$from` is a two-level aggregate: `$from` groups the filtered
117
+ * rows, the root controls aggregate its rows and name its columns (its `$groupBy`
118
+ * keys and aliases) — typed by `ValidNested`, rows by `NestedAggregateResult`.
90
119
  */
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>[]>;
120
+ aggregate<const Q extends AggregateQuery$1<Own<T>> | NestedAggregateQuery$1<Own<T>>>(query: Q & AggregateCheck<Own<T>, Q>, opts?: TClientCallOptions): Promise<AggregateRows<Own<T>, Q>>;
92
121
  /**
93
122
  * `GET /pages` — paginated query with typed filter and relations.
94
123
  *
@@ -126,28 +155,50 @@ declare class Client<T extends AtscriptClientShape = AtscriptClientShape, D exte
126
155
  controls?: DecoratedControls<T, D>;
127
156
  }>(id: Id<T>, query?: Q, opts?: TClientCallOptions): Promise<DecoratedRow<T, Q, D> | null>;
128
157
  /**
129
- * `POST /` — insert one record. The version column (if any) is optional —
130
- * the server initialises it; `$cas` is rejected (no meaning on insert).
158
+ * `POST /` — insert many records.
131
159
  */
132
- insert(data: PatchOf<T>, opts?: TClientCallOptions): Promise<TDbInsertResult$1>;
160
+ insert(data: InsertOf<T>[], opts?: TClientCallOptions): Promise<TDbInsertManyResult$1>;
133
161
  /**
134
- * `POST /` — insert many records.
162
+ * `POST /?$onConflict=ignore` — insert many records, skipping the ones that
163
+ * collide; the result reports inserted and skipped input indices (since 0.1.148).
135
164
  */
136
- insert(data: PatchOf<T>[], opts?: TClientCallOptions): Promise<TDbInsertManyResult$1>;
165
+ insert(data: InsertOf<T>[], opts: TClientCallOptions & {
166
+ onConflict: "ignore";
167
+ }): Promise<TDbInsertManyIgnoreResult$1>;
137
168
  /**
138
- * `POST /?$onConflict=ignore` — insert one record, skipping it when it
139
- * collides on the primary key or a unique index (since 0.1.148).
169
+ * `POST /` with `Prefer: return=representation` — insert one record and
170
+ * get the stored row back as `row` (since 0.1.168): server defaults and
171
+ * stamps included, shaped as `one()` would answer it. `row` is absent when
172
+ * the server could not apply the preference (the caller may not read the
173
+ * row, or a skipped conflict).
174
+ */
175
+ insert(data: SingleInsertOf<T>, opts: TClientCallOptions & {
176
+ returning: true;
177
+ }): Promise<TDbInsertResult$1 & {
178
+ row?: InsertedRow<T, D>;
179
+ }>;
180
+ /**
181
+ * `POST /?$onConflict=ignore` with `Prefer: return=representation` — as
182
+ * above; a skipped row answers `{ conflict: true }` without `row`.
140
183
  */
141
- insert(data: PatchOf<T>, opts: TClientCallOptions & {
184
+ insert(data: SingleInsertOf<T>, opts: TClientCallOptions & {
185
+ returning: true;
142
186
  onConflict: "ignore";
143
- }): Promise<TDbInsertIgnoreResult$1>;
187
+ }): Promise<TDbInsertIgnoreResult$1 & {
188
+ row?: InsertedRow<T, D>;
189
+ }>;
144
190
  /**
145
- * `POST /?$onConflict=ignore` — insert many records, skipping the ones that
146
- * collide; the result reports inserted and skipped input indices (since 0.1.148).
191
+ * `POST /` — insert one record. The version column (if any) is optional —
192
+ * the server initialises it; `$cas` is rejected (no meaning on insert).
147
193
  */
148
- insert(data: PatchOf<T>[], opts: TClientCallOptions & {
194
+ insert(data: InsertOf<T>, opts?: TClientCallOptions): Promise<TDbInsertResult$1>;
195
+ /**
196
+ * `POST /?$onConflict=ignore` — insert one record, skipping it when it
197
+ * collides on the primary key or a unique index (since 0.1.148).
198
+ */
199
+ insert(data: InsertOf<T>, opts: TClientCallOptions & {
149
200
  onConflict: "ignore";
150
- }): Promise<TDbInsertManyIgnoreResult$1>;
201
+ }): Promise<TDbInsertIgnoreResult$1>;
151
202
  /**
152
203
  * `PATCH /` — partial update one or many records by primary key.
153
204
  *
@@ -390,4 +441,4 @@ declare function formatIdentifier(id: Record<string, unknown> | undefined, prefe
390
441
  */
391
442
  declare function encodeNavigateId(id: Record<string, unknown>, preferredId: readonly string[]): string;
392
443
  //#endregion
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 };
444
+ export { ActionDisabledError, type ActionDisabledErrorBody, ActionNotFoundError, ActionTargetError, type ActionTargetErrorBody, ActionUnsupportedError, type AggregateQuery, type AggregateResult, type AggregateStage, type AtscriptClientShape, type BucketExpr, type BucketSeriesOptions, type BucketUnit, type CalendarBucketLabel, Client, ClientError, type ClientOptions, type ClientResponse, ClientValidationError, type ClientValidator, type ClientValidatorOptions, type DataOf, type DbInsert, type DbPatch, type DbRow, type FieldMeta, type FilterExpr, type IdOf, type InsertOf, type MetaResponse, MetaStore, type MetaStoreOptions, type NavOf, type NestedAggregateQuery, type NestedAggregateResult, type NextBucketOptions, type OwnOf, type PageResult, type PatchOf, type RelationInfo, type ResponseDataOf, type RowOf, type SearchIndexInfo, type ServerError, type StageRow, 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 ValidNested, type ValidatorMode, VersionMismatchError, type VersionMismatchErrorBody, type WeekStart, actionIdentifier, bucketSeries, bucketStartInstant, clearMetaStore, defaultMetaStore, encodeNavigateId, formatIdentifier, formatIdentifierField, nextBucketLabel };
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
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";
1
+ import { $ as TDbInsertManyResult, A as DecoratedControls, B as OwnOf, C as CalendarBucketLabel, D as DbInsert, E as DataOf, F as InsertOf, G as RowOf, H as PatchOf, I as MetaResponse, J as StageRow, K as SearchIndexInfo, L as NavOf, M as FieldMeta, N as FilterExpr, O as DbPatch, P as IdOf, Q as TDbInsertManyIgnoreResult, R as NestedAggregateQuery, S as BucketUnit, T as ClientResponse, U as RelationInfo, V as PageResult, W as ResponseDataOf, X as TDbDeleteResult, Y as TClientCallOptions, Z as TDbInsertIgnoreResult, _ as AggregateQuery, at as UniqueryControls, b as AtscriptClientShape, c as ActionNotFoundError, ct as WeekStart, d as ActionUnsupportedError, dt as clearMetaStore, et as TDbInsertResult, f as ClientError, ft as defaultMetaStore, g as VersionMismatchErrorBody, h as VersionMismatchError, i as ValidatorMode, it as Uniquery, j as DecoratedQuery, k as DbRow, l as ActionTargetError, lt as MetaStore, m as TransportError, n as ClientValidatorOptions, nt as TDbUpdateResult, o as ActionDisabledError, ot as ValidGroupBy, p as ClientValidationError, q as ServerError, rt as TypedWithRelation, s as ActionDisabledErrorBody, st as ValidNested, t as ClientValidator, tt as TDbQueryTarget, u as ActionTargetErrorBody, ut as MetaStoreOptions, v as AggregateResult, w as ClientOptions, x as BucketExpr, y as AggregateStage, z as NestedAggregateResult } from "./validator-DrRph1BQ.mjs";
2
+ import { AggregateQuery as AggregateQuery$1, AggregateResult as AggregateResult$1, BucketSeriesOptions, ComputedExpr, NestedAggregateQuery as NestedAggregateQuery$1, NestedAggregateResult as NestedAggregateResult$1, NextBucketOptions, Uniquery as Uniquery$1, ValidGroupBy as ValidGroupBy$1, ValidNested as ValidNested$1, bucketSeries, bucketStartInstant, nextBucketLabel } from "@uniqu/core";
2
3
  import { TAtscriptAnnotatedType, TSerializedAnnotatedType } from "@atscript/typescript/utils";
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";
5
5
 
6
6
  //#region src/client.d.ts
@@ -10,6 +10,25 @@ type Id<T> = IdOf<T>;
10
10
  type Response<T, Q> = ClientResponse<T, Q>;
11
11
  /** A read row: the response over the own fields plus the declared decorations `D`, each optional. */
12
12
  type DecoratedRow<T, Q, D> = Response<T, Q> & Partial<D>;
13
+ /**
14
+ * One insert row for `returning`: an untyped client's row is any `object`,
15
+ * which an array would match too — there it is any non-array object.
16
+ */
17
+ type SingleInsertOf<T> = [keyof InsertOf<T>] extends [never] ? Record<string, any> & {
18
+ readonly [Symbol.iterator]?: never;
19
+ } : InsertOf<T>;
20
+ /** The stored row `insert(row, { returning: true })` answers: the `one()` row shape. */
21
+ type InsertedRow<T, D> = DecoratedRow<T, Record<never, never>, D>;
22
+ /** A two-level aggregate query: one with `controls.$from`. */
23
+ type NestedShape = {
24
+ controls: {
25
+ $from: object;
26
+ };
27
+ };
28
+ /** The compile-time check an aggregate query must pass: two-level or flat. */
29
+ type AggregateCheck<T, Q> = Q extends NestedShape ? ValidNested$1<T, Q> : ValidGroupBy$1<T, Q>;
30
+ /** The rows `aggregate()` answers for query `Q`. */
31
+ type AggregateRows<T, Q extends AggregateQuery$1<T> | NestedAggregateQuery$1<T>> = Q extends NestedShape ? NestedAggregateResult$1<T, Q>[] : Q["controls"]["$select"] extends readonly (string | ComputedExpr)[] ? AggregateResult$1<T, Q["controls"]["$select"]>[] : Record<string, unknown>[];
13
32
  /**
14
33
  * HTTP client for moost-db REST endpoints.
15
34
  *
@@ -87,8 +106,18 @@ declare class Client<T extends AtscriptClientShape = AtscriptClientShape, D exte
87
106
  * numeric entries or numeric `$groupBy` fields (`number | null`). `first` / `last`
88
107
  * read a representative row ordered by `$rowOrder`. The URL forms are `expr(a/b):x`,
89
108
  * `sum(a*b):x`, `first(f):x` and `$rowOrder=f,-id`.
109
+ *
110
+ * Since 0.1.168 (server: `/meta` `distinctFieldLists`, `conditionalAggregates`,
111
+ * `nestedAggregates`):
112
+ * - `{ $fn: 'countDistinct', $field: ['a', 'b'] }` counts distinct combinations (a row
113
+ * with any NULL field is not counted); URL `countDistinct(a,b)`;
114
+ * - `{ $fn, $field, $where, $as }` aggregates only the rows matching `$where` (a typed
115
+ * filter); URL `sum(amount|status=paid):paid`;
116
+ * - a query with `controls.$from` is a two-level aggregate: `$from` groups the filtered
117
+ * rows, the root controls aggregate its rows and name its columns (its `$groupBy`
118
+ * keys and aliases) — typed by `ValidNested`, rows by `NestedAggregateResult`.
90
119
  */
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>[]>;
120
+ aggregate<const Q extends AggregateQuery$1<Own<T>> | NestedAggregateQuery$1<Own<T>>>(query: Q & AggregateCheck<Own<T>, Q>, opts?: TClientCallOptions): Promise<AggregateRows<Own<T>, Q>>;
92
121
  /**
93
122
  * `GET /pages` — paginated query with typed filter and relations.
94
123
  *
@@ -126,28 +155,50 @@ declare class Client<T extends AtscriptClientShape = AtscriptClientShape, D exte
126
155
  controls?: DecoratedControls<T, D>;
127
156
  }>(id: Id<T>, query?: Q, opts?: TClientCallOptions): Promise<DecoratedRow<T, Q, D> | null>;
128
157
  /**
129
- * `POST /` — insert one record. The version column (if any) is optional —
130
- * the server initialises it; `$cas` is rejected (no meaning on insert).
158
+ * `POST /` — insert many records.
131
159
  */
132
- insert(data: PatchOf<T>, opts?: TClientCallOptions): Promise<TDbInsertResult$1>;
160
+ insert(data: InsertOf<T>[], opts?: TClientCallOptions): Promise<TDbInsertManyResult$1>;
133
161
  /**
134
- * `POST /` — insert many records.
162
+ * `POST /?$onConflict=ignore` — insert many records, skipping the ones that
163
+ * collide; the result reports inserted and skipped input indices (since 0.1.148).
135
164
  */
136
- insert(data: PatchOf<T>[], opts?: TClientCallOptions): Promise<TDbInsertManyResult$1>;
165
+ insert(data: InsertOf<T>[], opts: TClientCallOptions & {
166
+ onConflict: "ignore";
167
+ }): Promise<TDbInsertManyIgnoreResult$1>;
137
168
  /**
138
- * `POST /?$onConflict=ignore` — insert one record, skipping it when it
139
- * collides on the primary key or a unique index (since 0.1.148).
169
+ * `POST /` with `Prefer: return=representation` — insert one record and
170
+ * get the stored row back as `row` (since 0.1.168): server defaults and
171
+ * stamps included, shaped as `one()` would answer it. `row` is absent when
172
+ * the server could not apply the preference (the caller may not read the
173
+ * row, or a skipped conflict).
174
+ */
175
+ insert(data: SingleInsertOf<T>, opts: TClientCallOptions & {
176
+ returning: true;
177
+ }): Promise<TDbInsertResult$1 & {
178
+ row?: InsertedRow<T, D>;
179
+ }>;
180
+ /**
181
+ * `POST /?$onConflict=ignore` with `Prefer: return=representation` — as
182
+ * above; a skipped row answers `{ conflict: true }` without `row`.
140
183
  */
141
- insert(data: PatchOf<T>, opts: TClientCallOptions & {
184
+ insert(data: SingleInsertOf<T>, opts: TClientCallOptions & {
185
+ returning: true;
142
186
  onConflict: "ignore";
143
- }): Promise<TDbInsertIgnoreResult$1>;
187
+ }): Promise<TDbInsertIgnoreResult$1 & {
188
+ row?: InsertedRow<T, D>;
189
+ }>;
144
190
  /**
145
- * `POST /?$onConflict=ignore` — insert many records, skipping the ones that
146
- * collide; the result reports inserted and skipped input indices (since 0.1.148).
191
+ * `POST /` — insert one record. The version column (if any) is optional —
192
+ * the server initialises it; `$cas` is rejected (no meaning on insert).
147
193
  */
148
- insert(data: PatchOf<T>[], opts: TClientCallOptions & {
194
+ insert(data: InsertOf<T>, opts?: TClientCallOptions): Promise<TDbInsertResult$1>;
195
+ /**
196
+ * `POST /?$onConflict=ignore` — insert one record, skipping it when it
197
+ * collides on the primary key or a unique index (since 0.1.148).
198
+ */
199
+ insert(data: InsertOf<T>, opts: TClientCallOptions & {
149
200
  onConflict: "ignore";
150
- }): Promise<TDbInsertManyIgnoreResult$1>;
201
+ }): Promise<TDbInsertIgnoreResult$1>;
151
202
  /**
152
203
  * `PATCH /` — partial update one or many records by primary key.
153
204
  *
@@ -390,4 +441,4 @@ declare function formatIdentifier(id: Record<string, unknown> | undefined, prefe
390
441
  */
391
442
  declare function encodeNavigateId(id: Record<string, unknown>, preferredId: readonly string[]): string;
392
443
  //#endregion
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 };
444
+ export { ActionDisabledError, type ActionDisabledErrorBody, ActionNotFoundError, ActionTargetError, type ActionTargetErrorBody, ActionUnsupportedError, type AggregateQuery, type AggregateResult, type AggregateStage, type AtscriptClientShape, type BucketExpr, type BucketSeriesOptions, type BucketUnit, type CalendarBucketLabel, Client, ClientError, type ClientOptions, type ClientResponse, ClientValidationError, type ClientValidator, type ClientValidatorOptions, type DataOf, type DbInsert, type DbPatch, type DbRow, type FieldMeta, type FilterExpr, type IdOf, type InsertOf, type MetaResponse, MetaStore, type MetaStoreOptions, type NavOf, type NestedAggregateQuery, type NestedAggregateResult, type NextBucketOptions, type OwnOf, type PageResult, type PatchOf, type RelationInfo, type ResponseDataOf, type RowOf, type SearchIndexInfo, type ServerError, type StageRow, 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 ValidNested, type ValidatorMode, VersionMismatchError, type VersionMismatchErrorBody, type WeekStart, actionIdentifier, bucketSeries, bucketStartInstant, clearMetaStore, defaultMetaStore, encodeNavigateId, formatIdentifier, formatIdentifierField, nextBucketLabel };
package/dist/index.mjs CHANGED
@@ -1,6 +1,5 @@
1
1
  import { a as ClientError, c as VersionMismatchError, i as ActionUnsupportedError, n as ActionNotFoundError, o as ClientValidationError, r as ActionTargetError, s as TransportError, t as ActionDisabledError } from "./client-error-Dn4WeNft.mjs";
2
2
  import { buildUrl } from "@uniqu/url/builder";
3
- import { deserializeAnnotatedType } from "@atscript/typescript/utils";
4
3
  import { bucketSeries, bucketStartInstant, nextBucketLabel } from "@uniqu/core";
5
4
  //#region src/meta-store.ts
6
5
  /** ETags remembered per store key (most recent first). */
@@ -221,6 +220,16 @@ var Client = class {
221
220
  * numeric entries or numeric `$groupBy` fields (`number | null`). `first` / `last`
222
221
  * read a representative row ordered by `$rowOrder`. The URL forms are `expr(a/b):x`,
223
222
  * `sum(a*b):x`, `first(f):x` and `$rowOrder=f,-id`.
223
+ *
224
+ * Since 0.1.168 (server: `/meta` `distinctFieldLists`, `conditionalAggregates`,
225
+ * `nestedAggregates`):
226
+ * - `{ $fn: 'countDistinct', $field: ['a', 'b'] }` counts distinct combinations (a row
227
+ * with any NULL field is not counted); URL `countDistinct(a,b)`;
228
+ * - `{ $fn, $field, $where, $as }` aggregates only the rows matching `$where` (a typed
229
+ * filter); URL `sum(amount|status=paid):paid`;
230
+ * - a query with `controls.$from` is a two-level aggregate: `$from` groups the filtered
231
+ * rows, the root controls aggregate its rows and name its columns (its `$groupBy`
232
+ * keys and aliases) — typed by `ValidNested`, rows by `NestedAggregateResult`.
224
233
  */
225
234
  async aggregate(query, opts) {
226
235
  return this._get("query", query, opts?.signal);
@@ -285,7 +294,11 @@ var Client = class {
285
294
  }
286
295
  async insert(data, opts) {
287
296
  const query = opts?.onConflict === "ignore" ? "?$onConflict=ignore" : "";
288
- return this._request("POST", query, await this._prepareWrite(data, "insert"), opts);
297
+ const headers = opts?.returning ? { Prefer: "return=representation" } : void 0;
298
+ return this._request("POST", query, await this._prepareWrite(data, "insert"), {
299
+ signal: opts?.signal,
300
+ headers
301
+ });
289
302
  }
290
303
  /**
291
304
  * `PATCH /` — partial update one or many records by primary key.
@@ -519,7 +532,7 @@ var Client = class {
519
532
  _loadActionForm(url) {
520
533
  let p = this._formCache.get(url);
521
534
  if (!p) {
522
- const loading = this._requestUrl("GET", url).then((schema) => deserializeAnnotatedType(schema)).catch((err) => {
535
+ const loading = Promise.all([this._requestUrl("GET", url), import("@atscript/typescript/utils")]).then(([schema, { deserializeAnnotatedType }]) => deserializeAnnotatedType(schema)).catch((err) => {
523
536
  if (this._formCache.get(url) === loading) this._formCache.delete(url);
524
537
  throw err;
525
538
  });
@@ -716,7 +729,10 @@ var Client = class {
716
729
  }
717
730
  /** Sends one request to an absolute URL with the client's headers and a JSON body. */
718
731
  async _requestUrl(method, url, body, opts) {
719
- const headers = { ...await this._resolveHeaders() };
732
+ const headers = {
733
+ ...await this._resolveHeaders(),
734
+ ...opts?.headers
735
+ };
720
736
  const init = {
721
737
  method,
722
738
  headers
@@ -1,6 +1,6 @@
1
- import { AggregateQuery as AggregateQuery$1, AggregateResult as AggregateResult$1, BucketExpr as BucketExpr$1, BucketUnit, CalendarBucketLabel, FilterExpr, SelectExpr, TypedWithRelation, Uniquery as Uniquery$1, UniqueryControls, ValidGroupBy as ValidGroupBy$1, WeekStart } from "@uniqu/core";
1
+ import { AggregateQuery as AggregateQuery$1, AggregateResult as AggregateResult$1, AggregateStage, BucketExpr, BucketUnit, CalendarBucketLabel, FilterExpr, NestedAggregateQuery as NestedAggregateQuery$1, NestedAggregateResult as NestedAggregateResult$1, SelectExpr, StageRow, TypedWithRelation, Uniquery as Uniquery$1, UniqueryControls, ValidGroupBy as ValidGroupBy$1, ValidNested as ValidNested$1, WeekStart } from "@uniqu/core";
2
2
  import { TAtscriptAnnotatedType, TAtscriptTypeObject } from "@atscript/typescript/utils";
3
- import { DbPatch, DbResponse, DbRow, TDbDeleteResult as TDbDeleteResult$1, TDbInsertIgnoreResult as TDbInsertIgnoreResult$1, TDbInsertManyIgnoreResult as TDbInsertManyIgnoreResult$1, TDbInsertManyResult as TDbInsertManyResult$1, TDbInsertResult as TDbInsertResult$1, TDbUpdateResult as TDbUpdateResult$1, TFieldMeta, TMetaResponse, TRelationInfo, TSearchIndexInfo } from "@atscript/db";
3
+ import { DbInsert, DbPatch, DbResponse, DbRow, TDbDeleteResult as TDbDeleteResult$1, TDbInsertIgnoreResult as TDbInsertIgnoreResult$1, TDbInsertManyIgnoreResult as TDbInsertManyIgnoreResult$1, TDbInsertManyResult as TDbInsertManyResult$1, TDbInsertResult as TDbInsertResult$1, TDbUpdateResult as TDbUpdateResult$1, TFieldMeta, TMetaResponse, TRelationInfo, TSearchIndexInfo } from "@atscript/db";
4
4
  import { DbValidationContext, ValidatorMode, ValidatorMode as ValidatorMode$1 } from "@atscript/db/validator";
5
5
 
6
6
  //#region src/meta-store.d.ts
@@ -95,13 +95,25 @@ declare function clearMetaStore(): void;
95
95
  //#endregion
96
96
  //#region src/types.d.ts
97
97
  /**
98
- * Write payload for `insert()` / `update()`: every key optional, optional
99
- * columns additionally accept `null` (explicit NULL). `$cas` is accepted on
100
- * `update()` / `replace()` through the open index signature.
98
+ * Write payload for `insert()` (since 0.1.168): every key optional, optional
99
+ * columns additionally accept `null` (explicit NULL). A value of the model's
100
+ * interface type fits; on an untyped client any object does.
101
101
  */
102
- type PatchOf<T> = DbPatch<DataOf<T>>;
103
- /** Write payload for `replace()`: full row; optional columns additionally accept `null`. */
104
- type RowOf<T> = DbRow<DataOf<T>>;
102
+ type InsertOf<T> = DbInsert<ResponseDataOf<T>>;
103
+ /**
104
+ * Write payload for `update()`: every key optional, optional columns
105
+ * additionally accept `null` (explicit NULL). Number fields also take
106
+ * `{ $inc | $dec | $mul: n }`, top-level arrays the array operators
107
+ * (`$insert`, `$remove`, …) and the payload a `$cas` version check (since
108
+ * 0.1.168). A value of the model's interface type fits; on an untyped client
109
+ * any object does.
110
+ */
111
+ type PatchOf<T> = DbPatch<ResponseDataOf<T>>;
112
+ /**
113
+ * Write payload for `replace()`: full row; optional columns additionally
114
+ * accept `null`, `$cas` checks the version. On an untyped client any object fits.
115
+ */
116
+ type RowOf<T> = DbRow<ResponseDataOf<T>>;
105
117
  /** Options for creating a Client instance. */
106
118
  interface ClientOptions {
107
119
  /**
@@ -568,4 +580,4 @@ declare class ClientValidator {
568
580
  */
569
581
  declare function createClientValidator(meta: MetaResponse, opts?: ClientValidatorOptions): ClientValidator;
570
582
  //#endregion
571
- export { UniqueryControls as $, FieldMeta as A, RowOf as B, ClientOptions as C, DbRow as D, DbPatch as E, OwnOf as F, TDbInsertIgnoreResult$1 as G, ServerError as H, PageResult as I, TDbInsertResult$1 as J, TDbInsertManyIgnoreResult$1 as K, PatchOf as L, IdOf as M, MetaResponse as N, DecoratedControls as O, NavOf as P, Uniquery$1 as Q, RelationInfo as R, CalendarBucketLabel as S, DataOf as T, TClientCallOptions as U, SearchIndexInfo as V, TDbDeleteResult$1 as W, TDbUpdateResult$1 as X, TDbQueryTarget as Y, TypedWithRelation as Z, AggregateQuery$1 as _, createClientValidator as a, defaultMetaStore as at, BucketExpr$1 as b, ActionNotFoundError as c, ActionUnsupportedError as d, ValidGroupBy$1 as et, ClientError as f, VersionMismatchErrorBody as g, VersionMismatchError as h, ValidatorMode$1 as i, clearMetaStore as it, FilterExpr as j, DecoratedQuery as k, ActionTargetError as l, TransportError as m, ClientValidatorOptions as n, MetaStore as nt, ActionDisabledError as o, ClientValidationError as p, TDbInsertManyResult$1 as q, DbValidationContext as r, MetaStoreOptions as rt, ActionDisabledErrorBody as s, ClientValidator as t, WeekStart as tt, ActionTargetErrorBody as u, AggregateResult$1 as v, ClientResponse as w, BucketUnit as x, AtscriptClientShape as y, ResponseDataOf as z };
583
+ export { TDbInsertManyResult$1 as $, DecoratedControls as A, OwnOf as B, CalendarBucketLabel as C, DbInsert as D, DataOf as E, InsertOf as F, RowOf as G, PatchOf as H, MetaResponse as I, StageRow as J, SearchIndexInfo as K, NavOf as L, FieldMeta as M, FilterExpr as N, DbPatch as O, IdOf as P, TDbInsertManyIgnoreResult$1 as Q, NestedAggregateQuery$1 as R, BucketUnit as S, ClientResponse as T, RelationInfo as U, PageResult as V, ResponseDataOf as W, TDbDeleteResult$1 as X, TClientCallOptions as Y, TDbInsertIgnoreResult$1 as Z, AggregateQuery$1 as _, createClientValidator as a, UniqueryControls as at, AtscriptClientShape as b, ActionNotFoundError as c, WeekStart as ct, ActionUnsupportedError as d, clearMetaStore as dt, TDbInsertResult$1 as et, ClientError as f, defaultMetaStore as ft, VersionMismatchErrorBody as g, VersionMismatchError as h, ValidatorMode$1 as i, Uniquery$1 as it, DecoratedQuery as j, DbRow as k, ActionTargetError as l, MetaStore as lt, TransportError as m, ClientValidatorOptions as n, TDbUpdateResult$1 as nt, ActionDisabledError as o, ValidGroupBy$1 as ot, ClientValidationError as p, ServerError as q, DbValidationContext as r, TypedWithRelation as rt, ActionDisabledErrorBody as s, ValidNested$1 as st, ClientValidator as t, TDbQueryTarget as tt, ActionTargetErrorBody as u, MetaStoreOptions as ut, AggregateResult$1 as v, ClientOptions as w, BucketExpr as x, AggregateStage as y, NestedAggregateResult$1 as z };
@@ -1,7 +1,7 @@
1
+ import { AggregateQuery as AggregateQuery$1, AggregateResult as AggregateResult$1, AggregateStage, BucketExpr, BucketUnit, CalendarBucketLabel, FilterExpr, NestedAggregateQuery as NestedAggregateQuery$1, NestedAggregateResult as NestedAggregateResult$1, SelectExpr, StageRow, TypedWithRelation, Uniquery as Uniquery$1, UniqueryControls, ValidGroupBy as ValidGroupBy$1, ValidNested as ValidNested$1, WeekStart } from "@uniqu/core";
1
2
  import { TAtscriptAnnotatedType, TAtscriptTypeObject } from "@atscript/typescript/utils";
2
- import { AggregateQuery as AggregateQuery$1, AggregateResult as AggregateResult$1, BucketExpr as BucketExpr$1, BucketUnit, CalendarBucketLabel, FilterExpr, SelectExpr, TypedWithRelation, Uniquery as Uniquery$1, UniqueryControls, ValidGroupBy as ValidGroupBy$1, WeekStart } from "@uniqu/core";
3
3
  import { DbValidationContext, ValidatorMode, ValidatorMode as ValidatorMode$1 } from "@atscript/db/validator";
4
- import { DbPatch, DbResponse, DbRow, TDbDeleteResult as TDbDeleteResult$1, TDbInsertIgnoreResult as TDbInsertIgnoreResult$1, TDbInsertManyIgnoreResult as TDbInsertManyIgnoreResult$1, TDbInsertManyResult as TDbInsertManyResult$1, TDbInsertResult as TDbInsertResult$1, TDbUpdateResult as TDbUpdateResult$1, TFieldMeta, TMetaResponse, TRelationInfo, TSearchIndexInfo } from "@atscript/db";
4
+ import { DbInsert, DbPatch, DbResponse, DbRow, TDbDeleteResult as TDbDeleteResult$1, TDbInsertIgnoreResult as TDbInsertIgnoreResult$1, TDbInsertManyIgnoreResult as TDbInsertManyIgnoreResult$1, TDbInsertManyResult as TDbInsertManyResult$1, TDbInsertResult as TDbInsertResult$1, TDbUpdateResult as TDbUpdateResult$1, TFieldMeta, TMetaResponse, TRelationInfo, TSearchIndexInfo } from "@atscript/db";
5
5
 
6
6
  //#region src/meta-store.d.ts
7
7
  /** Options for {@link MetaStore}. */
@@ -95,13 +95,25 @@ declare function clearMetaStore(): void;
95
95
  //#endregion
96
96
  //#region src/types.d.ts
97
97
  /**
98
- * Write payload for `insert()` / `update()`: every key optional, optional
99
- * columns additionally accept `null` (explicit NULL). `$cas` is accepted on
100
- * `update()` / `replace()` through the open index signature.
98
+ * Write payload for `insert()` (since 0.1.168): every key optional, optional
99
+ * columns additionally accept `null` (explicit NULL). A value of the model's
100
+ * interface type fits; on an untyped client any object does.
101
101
  */
102
- type PatchOf<T> = DbPatch<DataOf<T>>;
103
- /** Write payload for `replace()`: full row; optional columns additionally accept `null`. */
104
- type RowOf<T> = DbRow<DataOf<T>>;
102
+ type InsertOf<T> = DbInsert<ResponseDataOf<T>>;
103
+ /**
104
+ * Write payload for `update()`: every key optional, optional columns
105
+ * additionally accept `null` (explicit NULL). Number fields also take
106
+ * `{ $inc | $dec | $mul: n }`, top-level arrays the array operators
107
+ * (`$insert`, `$remove`, …) and the payload a `$cas` version check (since
108
+ * 0.1.168). A value of the model's interface type fits; on an untyped client
109
+ * any object does.
110
+ */
111
+ type PatchOf<T> = DbPatch<ResponseDataOf<T>>;
112
+ /**
113
+ * Write payload for `replace()`: full row; optional columns additionally
114
+ * accept `null`, `$cas` checks the version. On an untyped client any object fits.
115
+ */
116
+ type RowOf<T> = DbRow<ResponseDataOf<T>>;
105
117
  /** Options for creating a Client instance. */
106
118
  interface ClientOptions {
107
119
  /**
@@ -568,4 +580,4 @@ declare class ClientValidator {
568
580
  */
569
581
  declare function createClientValidator(meta: MetaResponse, opts?: ClientValidatorOptions): ClientValidator;
570
582
  //#endregion
571
- export { UniqueryControls as $, FieldMeta as A, RowOf as B, ClientOptions as C, DbRow as D, DbPatch as E, OwnOf as F, TDbInsertIgnoreResult$1 as G, ServerError as H, PageResult as I, TDbInsertResult$1 as J, TDbInsertManyIgnoreResult$1 as K, PatchOf as L, IdOf as M, MetaResponse as N, DecoratedControls as O, NavOf as P, Uniquery$1 as Q, RelationInfo as R, CalendarBucketLabel as S, DataOf as T, TClientCallOptions as U, SearchIndexInfo as V, TDbDeleteResult$1 as W, TDbUpdateResult$1 as X, TDbQueryTarget as Y, TypedWithRelation as Z, AggregateQuery$1 as _, createClientValidator as a, defaultMetaStore as at, BucketExpr$1 as b, ActionNotFoundError as c, ActionUnsupportedError as d, ValidGroupBy$1 as et, ClientError as f, VersionMismatchErrorBody as g, VersionMismatchError as h, ValidatorMode$1 as i, clearMetaStore as it, FilterExpr as j, DecoratedQuery as k, ActionTargetError as l, TransportError as m, ClientValidatorOptions as n, MetaStore as nt, ActionDisabledError as o, ClientValidationError as p, TDbInsertManyResult$1 as q, DbValidationContext as r, MetaStoreOptions as rt, ActionDisabledErrorBody as s, ClientValidator as t, WeekStart as tt, ActionTargetErrorBody as u, AggregateResult$1 as v, ClientResponse as w, BucketUnit as x, AtscriptClientShape as y, ResponseDataOf as z };
583
+ export { TDbInsertManyResult$1 as $, DecoratedControls as A, OwnOf as B, CalendarBucketLabel as C, DbInsert as D, DataOf as E, InsertOf as F, RowOf as G, PatchOf as H, MetaResponse as I, StageRow as J, SearchIndexInfo as K, NavOf as L, FieldMeta as M, FilterExpr as N, DbPatch as O, IdOf as P, TDbInsertManyIgnoreResult$1 as Q, NestedAggregateQuery$1 as R, BucketUnit as S, ClientResponse as T, RelationInfo as U, PageResult as V, ResponseDataOf as W, TDbDeleteResult$1 as X, TClientCallOptions as Y, TDbInsertIgnoreResult$1 as Z, AggregateQuery$1 as _, createClientValidator as a, UniqueryControls as at, AtscriptClientShape as b, ActionNotFoundError as c, WeekStart as ct, ActionUnsupportedError as d, clearMetaStore as dt, TDbInsertResult$1 as et, ClientError as f, defaultMetaStore as ft, VersionMismatchErrorBody as g, VersionMismatchError as h, ValidatorMode$1 as i, Uniquery$1 as it, DecoratedQuery as j, DbRow as k, ActionTargetError as l, MetaStore as lt, TransportError as m, ClientValidatorOptions as n, TDbUpdateResult$1 as nt, ActionDisabledError as o, ValidGroupBy$1 as ot, ClientValidationError as p, ServerError as q, DbValidationContext as r, TypedWithRelation as rt, ActionDisabledErrorBody as s, ValidNested$1 as st, ClientValidator as t, TDbQueryTarget as tt, ActionTargetErrorBody as u, MetaStoreOptions as ut, AggregateResult$1 as v, ClientOptions as w, BucketExpr as x, AggregateStage as y, NestedAggregateResult$1 as z };
@@ -1,2 +1,2 @@
1
- import { a as createClientValidator, i as ValidatorMode, n as ClientValidatorOptions, p as ClientValidationError, r as DbValidationContext, t as ClientValidator } from "./validator-DrJYT-pz.cjs";
1
+ import { a as createClientValidator, i as ValidatorMode, n as ClientValidatorOptions, p as ClientValidationError, r as DbValidationContext, t as ClientValidator } from "./validator-BfGRI3X9.cjs";
2
2
  export { ClientValidationError, ClientValidator, ClientValidatorOptions, type DbValidationContext, type ValidatorMode, createClientValidator };
@@ -1,2 +1,2 @@
1
- import { a as createClientValidator, i as ValidatorMode, n as ClientValidatorOptions, p as ClientValidationError, r as DbValidationContext, t as ClientValidator } from "./validator-tvR4Sl3l.mjs";
1
+ import { a as createClientValidator, i as ValidatorMode, n as ClientValidatorOptions, p as ClientValidationError, r as DbValidationContext, t as ClientValidator } from "./validator-DrRph1BQ.mjs";
2
2
  export { ClientValidationError, ClientValidator, ClientValidatorOptions, type DbValidationContext, type ValidatorMode, createClientValidator };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atscript/db-client",
3
- "version": "0.1.167",
3
+ "version": "0.1.169",
4
4
  "description": "Browser-compatible HTTP client for @atscript/moost-db REST endpoints.",
5
5
  "keywords": [
6
6
  "atscript",
@@ -43,18 +43,18 @@
43
43
  "access": "public"
44
44
  },
45
45
  "dependencies": {
46
- "@uniqu/core": "^0.1.15",
47
- "@uniqu/url": "^0.1.15"
46
+ "@uniqu/core": "^0.2.0",
47
+ "@uniqu/url": "^0.2.0"
48
48
  },
49
49
  "devDependencies": {
50
- "@atscript/core": "^0.2.3",
51
- "@atscript/typescript": "^0.2.3",
52
- "unplugin-atscript": "^0.2.3",
53
- "@atscript/db": "0.1.167"
50
+ "@atscript/core": "^0.2.4",
51
+ "@atscript/typescript": "^0.2.4",
52
+ "unplugin-atscript": "^0.2.4",
53
+ "@atscript/db": "0.1.169"
54
54
  },
55
55
  "peerDependencies": {
56
- "@atscript/typescript": "^0.2.3",
57
- "@atscript/db": "^0.1.167"
56
+ "@atscript/typescript": "^0.2.4",
57
+ "@atscript/db": "^0.1.169"
58
58
  },
59
59
  "scripts": {
60
60
  "build": "vp pack",