@atscript/db-client 0.1.198 → 0.1.200
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/{client-Byw4P7DT.d.cts → client-CM--7NfJ.d.mts} +33 -19
- package/dist/{client-CFr71FpF.d.mts → client-CVcoc72F.d.cts} +33 -19
- package/dist/index.cjs +9 -3
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +9 -3
- package/dist/validator.d.cts +1 -1
- package/dist/validator.d.mts +1 -1
- package/package.json +7 -7
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AggregateQuery, AggregateQuery as AggregateQuery$1, AggregateResult, AggregateResult as AggregateResult$1, AggregateStage, BucketExpr, BucketUnit, CalendarBucketLabel, ComputedExpr, FilterExpr, NestedAggregateQuery, NestedAggregateQuery as NestedAggregateQuery$1, NestedAggregateResult, NestedAggregateResult as NestedAggregateResult$1, SelectExpr, StageRow, TypedWithRelation, Uniquery, Uniquery as Uniquery$1, UniqueryControls, ValidGroupBy, ValidGroupBy as ValidGroupBy$1, ValidNested, ValidNested as ValidNested$1, WeekStart } from "@uniqu/core";
|
|
2
2
|
import { TAtscriptAnnotatedType, TAtscriptTypeObject } from "@atscript/typescript/utils";
|
|
3
|
-
import { DbInsert, DbPatch, DbResponse, DbRow, TDbActionInfo, TDbActionTargetSummary, TDbAvailableActions, TDbDeleteResult, TDbDeleteResult as TDbDeleteResult$1, TDbInsertIgnoreResult, TDbInsertIgnoreResult as TDbInsertIgnoreResult$1, TDbInsertManyIgnoreResult, TDbInsertManyIgnoreResult as TDbInsertManyIgnoreResult$1, TDbInsertManyResult, TDbInsertManyResult as TDbInsertManyResult$1, TDbInsertResult, TDbInsertResult as TDbInsertResult$1, TDbUpdateResult, TDbUpdateResult as TDbUpdateResult$1, TDbVersion, TFieldMeta, TMetaResponse, TRelationInfo, TSearchIndexInfo } from "@atscript/db";
|
|
4
3
|
import { DbValidationContext, ValidatorMode, ValidatorMode as ValidatorMode$1 } from "@atscript/db/validator";
|
|
4
|
+
import { DbInsert, DbPatch, DbResponse, DbRow, TDbActionInfo, TDbActionTargetSummary, TDbAvailableActions, TDbDeleteResult, TDbDeleteResult as TDbDeleteResult$1, TDbInsertIgnoreResult, TDbInsertIgnoreResult as TDbInsertIgnoreResult$1, TDbInsertManyIgnoreResult, TDbInsertManyIgnoreResult as TDbInsertManyIgnoreResult$1, TDbInsertManyResult, TDbInsertManyResult as TDbInsertManyResult$1, TDbInsertResult, TDbInsertResult as TDbInsertResult$1, TDbUpdateResult, TDbUpdateResult as TDbUpdateResult$1, TDbVersion, TFieldMeta, TMetaResponse, TRelationInfo, TSearchIndexInfo } from "@atscript/db";
|
|
5
5
|
|
|
6
6
|
//#region src/meta-store.d.ts
|
|
7
7
|
/** Options for {@link MetaStore}. */
|
|
@@ -200,6 +200,8 @@ interface PageResult<T> {
|
|
|
200
200
|
}
|
|
201
201
|
/**
|
|
202
202
|
* Per-call options of the `Client` read / write methods (since 0.1.165).
|
|
203
|
+
* A `ClientLike` implementation with options of its own extends this
|
|
204
|
+
* interface and passes it as the third type parameter (since 0.1.199).
|
|
203
205
|
*/
|
|
204
206
|
interface TClientCallOptions {
|
|
205
207
|
/**
|
|
@@ -354,9 +356,15 @@ interface TDbQueryTarget<T = AtscriptClientShape> {
|
|
|
354
356
|
* (`createClientValidator(await this.meta())`), `invalidateMeta`, `metaEtag` (may return
|
|
355
357
|
* `undefined`) and `metaStore` (may be `undefined`); answers "none" from `availableActions`,
|
|
356
358
|
* `getActionForm` (`null`) and `getActionFormTexts` (`undefined`); and rejects the rest.
|
|
359
|
+
*
|
|
360
|
+
* `O` (since 0.1.199) is the per-call options the read / write methods take: an implementation
|
|
361
|
+
* with options of its own declares them as `O`, an interface extending {@link TClientCallOptions}
|
|
362
|
+
* (`ClientLike<T, D, MyCallOptions>`), instead of augmenting `TClientCallOptions` — which would
|
|
363
|
+
* let a plain `Client` accept them too and ignore them. `Client` itself reads only `signal`
|
|
364
|
+
* (and `insert`'s `onConflict` / `returning`).
|
|
357
365
|
* @since 0.1.196
|
|
358
366
|
*/
|
|
359
|
-
type ClientLike<T extends AtscriptClientShape = AtscriptClientShape, D extends object = Record<never, never
|
|
367
|
+
type ClientLike<T extends AtscriptClientShape = AtscriptClientShape, D extends object = Record<never, never>, O extends TClientCallOptions = TClientCallOptions> = Pick<Client<T, D, O>, keyof Client<T, D, O>>;
|
|
360
368
|
//#endregion
|
|
361
369
|
//#region src/client-error.d.ts
|
|
362
370
|
/**
|
|
@@ -716,8 +724,14 @@ type AggregateRows<T, Q extends AggregateQuery<T> | NestedAggregateQuery<T>> = Q
|
|
|
716
724
|
* const rows = await tickets.query({ controls: { $select: ['title', 'ownerName'] } })
|
|
717
725
|
* rows[0].ownerName // string | undefined
|
|
718
726
|
* ```
|
|
727
|
+
*
|
|
728
|
+
* `O` (since 0.1.199) types the per-call options the read / write methods
|
|
729
|
+
* take (an interface extending {@link TClientCallOptions}). An implementation
|
|
730
|
+
* of `ClientLike` that has per-call options of its own declares them as `O`;
|
|
731
|
+
* `Client` itself reads only `signal` (and `insert`'s `onConflict` /
|
|
732
|
+
* `returning`).
|
|
719
733
|
*/
|
|
720
|
-
declare class Client<T extends AtscriptClientShape = AtscriptClientShape, D extends object = Record<never, never
|
|
734
|
+
declare class Client<T extends AtscriptClientShape = AtscriptClientShape, D extends object = Record<never, never>, O extends TClientCallOptions = TClientCallOptions> {
|
|
721
735
|
private readonly _path;
|
|
722
736
|
private readonly _baseUrl;
|
|
723
737
|
private readonly _fetch;
|
|
@@ -743,13 +757,13 @@ declare class Client<T extends AtscriptClientShape = AtscriptClientShape, D exte
|
|
|
743
757
|
* relations not listed in `$with` are stripped from the row type. A vector
|
|
744
758
|
* read (`controls: { $search, $vector }`) types `$score` on every row.
|
|
745
759
|
*/
|
|
746
|
-
query<const Q extends DecoratedQuery<T, D> = DecoratedQuery<T, D>>(query?: Q, opts?:
|
|
760
|
+
query<const Q extends DecoratedQuery<T, D> = DecoratedQuery<T, D>>(query?: Q, opts?: O): Promise<ReadRow<T, Q, D>[]>;
|
|
747
761
|
/**
|
|
748
762
|
* `GET /query` with `$count: true` — returns record count.
|
|
749
763
|
*/
|
|
750
764
|
count(query?: {
|
|
751
765
|
filter?: Uniquery<Own<T>, Nav<T>>["filter"];
|
|
752
|
-
}, opts?:
|
|
766
|
+
}, opts?: O): Promise<number>;
|
|
753
767
|
/**
|
|
754
768
|
* `GET /query` with `$groupBy` — aggregate query with typed dimension/measure fields.
|
|
755
769
|
* `$groupBy: []` is the ungrouped aggregate: one row over the filtered set (served
|
|
@@ -777,14 +791,14 @@ declare class Client<T extends AtscriptClientShape = AtscriptClientShape, D exte
|
|
|
777
791
|
* rows, the root controls aggregate its rows and name its columns (its `$groupBy`
|
|
778
792
|
* keys and aliases) — typed by `ValidNested`, rows by `NestedAggregateResult`.
|
|
779
793
|
*/
|
|
780
|
-
aggregate<const Q extends AggregateQuery<Own<T>> | NestedAggregateQuery<Own<T>>>(query: Q & AggregateCheck<Own<T>, Q>, opts?:
|
|
794
|
+
aggregate<const Q extends AggregateQuery<Own<T>> | NestedAggregateQuery<Own<T>>>(query: Q & AggregateCheck<Own<T>, Q>, opts?: O): Promise<AggregateRows<Own<T>, Q>>;
|
|
781
795
|
/**
|
|
782
796
|
* `GET /pages` — paginated query with typed filter and relations.
|
|
783
797
|
*
|
|
784
798
|
* Response rows narrow by the literal `$with` array — same algebra as
|
|
785
799
|
* {@link query}, `$score` on a vector read included.
|
|
786
800
|
*/
|
|
787
|
-
pages<const Q extends DecoratedQuery<T, D> = DecoratedQuery<T, D>>(query?: Q, page?: number, size?: number, opts?:
|
|
801
|
+
pages<const Q extends DecoratedQuery<T, D> = DecoratedQuery<T, D>>(query?: Q, page?: number, size?: number, opts?: O): Promise<PageResult<ReadRow<T, Q, D>>>;
|
|
788
802
|
/**
|
|
789
803
|
* `GET /geo` — distance-ranked geospatial search (tables with `@db.index.geo`).
|
|
790
804
|
*
|
|
@@ -794,13 +808,13 @@ declare class Client<T extends AtscriptClientShape = AtscriptClientShape, D exte
|
|
|
794
808
|
* in `query.controls`; filter / `$select` / `$with` / `$skip` / `$limit`
|
|
795
809
|
* compose as usual.
|
|
796
810
|
*/
|
|
797
|
-
geoSearch<const Q extends DecoratedQuery<T, D> = DecoratedQuery<T, D>>(point: [number, number], query?: Q, opts?:
|
|
811
|
+
geoSearch<const Q extends DecoratedQuery<T, D> = DecoratedQuery<T, D>>(point: [number, number], query?: Q, opts?: O): Promise<Array<DecoratedRow<T, Q, D> & {
|
|
798
812
|
$distance: number;
|
|
799
813
|
}>>;
|
|
800
814
|
/**
|
|
801
815
|
* `GET /geo` with `$page` / `$size` — paginated distance-ranked search.
|
|
802
816
|
*/
|
|
803
|
-
geoPages<const Q extends DecoratedQuery<T, D> = DecoratedQuery<T, D>>(point: [number, number], query?: Q, page?: number, size?: number, opts?:
|
|
817
|
+
geoPages<const Q extends DecoratedQuery<T, D> = DecoratedQuery<T, D>>(point: [number, number], query?: Q, page?: number, size?: number, opts?: O): Promise<PageResult<DecoratedRow<T, Q, D> & {
|
|
804
818
|
$distance: number;
|
|
805
819
|
}>>;
|
|
806
820
|
/**
|
|
@@ -813,16 +827,16 @@ declare class Client<T extends AtscriptClientShape = AtscriptClientShape, D exte
|
|
|
813
827
|
controls?: DecoratedControls<T, D>;
|
|
814
828
|
} = {
|
|
815
829
|
controls?: DecoratedControls<T, D>;
|
|
816
|
-
}>(id: Id<T>, query?: Q, opts?:
|
|
830
|
+
}>(id: Id<T>, query?: Q, opts?: O): Promise<DecoratedRow<T, Q, D> | null>;
|
|
817
831
|
/**
|
|
818
832
|
* `POST /` — insert many records.
|
|
819
833
|
*/
|
|
820
|
-
insert(data: InsertOf<T>[], opts?:
|
|
834
|
+
insert(data: InsertOf<T>[], opts?: O): Promise<TDbInsertManyResult>;
|
|
821
835
|
/**
|
|
822
836
|
* `POST /?$onConflict=ignore` — insert many records, skipping the ones that
|
|
823
837
|
* collide; the result reports inserted and skipped input indices (since 0.1.148).
|
|
824
838
|
*/
|
|
825
|
-
insert(data: InsertOf<T>[], opts:
|
|
839
|
+
insert(data: InsertOf<T>[], opts: O & {
|
|
826
840
|
onConflict: "ignore";
|
|
827
841
|
}): Promise<TDbInsertManyIgnoreResult>;
|
|
828
842
|
/**
|
|
@@ -832,7 +846,7 @@ declare class Client<T extends AtscriptClientShape = AtscriptClientShape, D exte
|
|
|
832
846
|
* the server could not apply the preference (the caller may not read the
|
|
833
847
|
* row, or a skipped conflict).
|
|
834
848
|
*/
|
|
835
|
-
insert(data: SingleInsertOf<T>, opts:
|
|
849
|
+
insert(data: SingleInsertOf<T>, opts: O & {
|
|
836
850
|
returning: true;
|
|
837
851
|
}): Promise<TDbInsertResult & {
|
|
838
852
|
row?: InsertedRow<T, D>;
|
|
@@ -841,7 +855,7 @@ declare class Client<T extends AtscriptClientShape = AtscriptClientShape, D exte
|
|
|
841
855
|
* `POST /?$onConflict=ignore` with `Prefer: return=representation` — as
|
|
842
856
|
* above; a skipped row answers `{ conflict: true }` without `row`.
|
|
843
857
|
*/
|
|
844
|
-
insert(data: SingleInsertOf<T>, opts:
|
|
858
|
+
insert(data: SingleInsertOf<T>, opts: O & {
|
|
845
859
|
returning: true;
|
|
846
860
|
onConflict: "ignore";
|
|
847
861
|
}): Promise<TDbInsertIgnoreResult & {
|
|
@@ -851,12 +865,12 @@ declare class Client<T extends AtscriptClientShape = AtscriptClientShape, D exte
|
|
|
851
865
|
* `POST /` — insert one record. The version column (if any) is optional —
|
|
852
866
|
* the server initialises it; `$cas` is rejected (no meaning on insert).
|
|
853
867
|
*/
|
|
854
|
-
insert(data: InsertOf<T>, opts?:
|
|
868
|
+
insert(data: InsertOf<T>, opts?: O): Promise<TDbInsertResult>;
|
|
855
869
|
/**
|
|
856
870
|
* `POST /?$onConflict=ignore` — insert one record, skipping it when it
|
|
857
871
|
* collides on the primary key or a unique index (since 0.1.148).
|
|
858
872
|
*/
|
|
859
|
-
insert(data: InsertOf<T>, opts:
|
|
873
|
+
insert(data: InsertOf<T>, opts: O & {
|
|
860
874
|
onConflict: "ignore";
|
|
861
875
|
}): Promise<TDbInsertIgnoreResult>;
|
|
862
876
|
/**
|
|
@@ -868,16 +882,16 @@ declare class Client<T extends AtscriptClientShape = AtscriptClientShape, D exte
|
|
|
868
882
|
* {@link VersionMismatchError}; a PK-only body with a version is a real
|
|
869
883
|
* write (the server bumps the version).
|
|
870
884
|
*/
|
|
871
|
-
update(data: PatchOf<T> | PatchOf<T>[], opts?:
|
|
885
|
+
update(data: PatchOf<T> | PatchOf<T>[], opts?: O): Promise<TDbUpdateResult>;
|
|
872
886
|
/**
|
|
873
887
|
* `PUT /` — full replace one or many records by primary key. Same OCC
|
|
874
888
|
* shapes as {@link update}; the version column itself is optional.
|
|
875
889
|
*/
|
|
876
|
-
replace(data: RowOf<T> | RowOf<T>[], opts?:
|
|
890
|
+
replace(data: RowOf<T> | RowOf<T>[], opts?: O): Promise<TDbUpdateResult>;
|
|
877
891
|
/**
|
|
878
892
|
* `DELETE /:id` or `DELETE /?k1=v1&k2=v2` — remove a record by primary key.
|
|
879
893
|
*/
|
|
880
|
-
remove(id: Id<T>, opts?:
|
|
894
|
+
remove(id: Id<T>, opts?: O): Promise<TDbDeleteResult>;
|
|
881
895
|
/**
|
|
882
896
|
* `GET /meta` — table/view metadata (cached after first call).
|
|
883
897
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AggregateQuery, AggregateQuery as AggregateQuery$1, AggregateResult, AggregateResult as AggregateResult$1, AggregateStage, BucketExpr, BucketUnit, CalendarBucketLabel, ComputedExpr, FilterExpr, NestedAggregateQuery, NestedAggregateQuery as NestedAggregateQuery$1, NestedAggregateResult, NestedAggregateResult as NestedAggregateResult$1, SelectExpr, StageRow, TypedWithRelation, Uniquery, Uniquery as Uniquery$1, UniqueryControls, ValidGroupBy, ValidGroupBy as ValidGroupBy$1, ValidNested, ValidNested as ValidNested$1, WeekStart } from "@uniqu/core";
|
|
2
2
|
import { TAtscriptAnnotatedType, TAtscriptTypeObject } from "@atscript/typescript/utils";
|
|
3
|
-
import { DbValidationContext, ValidatorMode, ValidatorMode as ValidatorMode$1 } from "@atscript/db/validator";
|
|
4
3
|
import { DbInsert, DbPatch, DbResponse, DbRow, TDbActionInfo, TDbActionTargetSummary, TDbAvailableActions, TDbDeleteResult, TDbDeleteResult as TDbDeleteResult$1, TDbInsertIgnoreResult, TDbInsertIgnoreResult as TDbInsertIgnoreResult$1, TDbInsertManyIgnoreResult, TDbInsertManyIgnoreResult as TDbInsertManyIgnoreResult$1, TDbInsertManyResult, TDbInsertManyResult as TDbInsertManyResult$1, TDbInsertResult, TDbInsertResult as TDbInsertResult$1, TDbUpdateResult, TDbUpdateResult as TDbUpdateResult$1, TDbVersion, TFieldMeta, TMetaResponse, TRelationInfo, TSearchIndexInfo } from "@atscript/db";
|
|
4
|
+
import { DbValidationContext, ValidatorMode, ValidatorMode as ValidatorMode$1 } from "@atscript/db/validator";
|
|
5
5
|
|
|
6
6
|
//#region src/meta-store.d.ts
|
|
7
7
|
/** Options for {@link MetaStore}. */
|
|
@@ -200,6 +200,8 @@ interface PageResult<T> {
|
|
|
200
200
|
}
|
|
201
201
|
/**
|
|
202
202
|
* Per-call options of the `Client` read / write methods (since 0.1.165).
|
|
203
|
+
* A `ClientLike` implementation with options of its own extends this
|
|
204
|
+
* interface and passes it as the third type parameter (since 0.1.199).
|
|
203
205
|
*/
|
|
204
206
|
interface TClientCallOptions {
|
|
205
207
|
/**
|
|
@@ -354,9 +356,15 @@ interface TDbQueryTarget<T = AtscriptClientShape> {
|
|
|
354
356
|
* (`createClientValidator(await this.meta())`), `invalidateMeta`, `metaEtag` (may return
|
|
355
357
|
* `undefined`) and `metaStore` (may be `undefined`); answers "none" from `availableActions`,
|
|
356
358
|
* `getActionForm` (`null`) and `getActionFormTexts` (`undefined`); and rejects the rest.
|
|
359
|
+
*
|
|
360
|
+
* `O` (since 0.1.199) is the per-call options the read / write methods take: an implementation
|
|
361
|
+
* with options of its own declares them as `O`, an interface extending {@link TClientCallOptions}
|
|
362
|
+
* (`ClientLike<T, D, MyCallOptions>`), instead of augmenting `TClientCallOptions` — which would
|
|
363
|
+
* let a plain `Client` accept them too and ignore them. `Client` itself reads only `signal`
|
|
364
|
+
* (and `insert`'s `onConflict` / `returning`).
|
|
357
365
|
* @since 0.1.196
|
|
358
366
|
*/
|
|
359
|
-
type ClientLike<T extends AtscriptClientShape = AtscriptClientShape, D extends object = Record<never, never
|
|
367
|
+
type ClientLike<T extends AtscriptClientShape = AtscriptClientShape, D extends object = Record<never, never>, O extends TClientCallOptions = TClientCallOptions> = Pick<Client<T, D, O>, keyof Client<T, D, O>>;
|
|
360
368
|
//#endregion
|
|
361
369
|
//#region src/client-error.d.ts
|
|
362
370
|
/**
|
|
@@ -716,8 +724,14 @@ type AggregateRows<T, Q extends AggregateQuery<T> | NestedAggregateQuery<T>> = Q
|
|
|
716
724
|
* const rows = await tickets.query({ controls: { $select: ['title', 'ownerName'] } })
|
|
717
725
|
* rows[0].ownerName // string | undefined
|
|
718
726
|
* ```
|
|
727
|
+
*
|
|
728
|
+
* `O` (since 0.1.199) types the per-call options the read / write methods
|
|
729
|
+
* take (an interface extending {@link TClientCallOptions}). An implementation
|
|
730
|
+
* of `ClientLike` that has per-call options of its own declares them as `O`;
|
|
731
|
+
* `Client` itself reads only `signal` (and `insert`'s `onConflict` /
|
|
732
|
+
* `returning`).
|
|
719
733
|
*/
|
|
720
|
-
declare class Client<T extends AtscriptClientShape = AtscriptClientShape, D extends object = Record<never, never
|
|
734
|
+
declare class Client<T extends AtscriptClientShape = AtscriptClientShape, D extends object = Record<never, never>, O extends TClientCallOptions = TClientCallOptions> {
|
|
721
735
|
private readonly _path;
|
|
722
736
|
private readonly _baseUrl;
|
|
723
737
|
private readonly _fetch;
|
|
@@ -743,13 +757,13 @@ declare class Client<T extends AtscriptClientShape = AtscriptClientShape, D exte
|
|
|
743
757
|
* relations not listed in `$with` are stripped from the row type. A vector
|
|
744
758
|
* read (`controls: { $search, $vector }`) types `$score` on every row.
|
|
745
759
|
*/
|
|
746
|
-
query<const Q extends DecoratedQuery<T, D> = DecoratedQuery<T, D>>(query?: Q, opts?:
|
|
760
|
+
query<const Q extends DecoratedQuery<T, D> = DecoratedQuery<T, D>>(query?: Q, opts?: O): Promise<ReadRow<T, Q, D>[]>;
|
|
747
761
|
/**
|
|
748
762
|
* `GET /query` with `$count: true` — returns record count.
|
|
749
763
|
*/
|
|
750
764
|
count(query?: {
|
|
751
765
|
filter?: Uniquery<Own<T>, Nav<T>>["filter"];
|
|
752
|
-
}, opts?:
|
|
766
|
+
}, opts?: O): Promise<number>;
|
|
753
767
|
/**
|
|
754
768
|
* `GET /query` with `$groupBy` — aggregate query with typed dimension/measure fields.
|
|
755
769
|
* `$groupBy: []` is the ungrouped aggregate: one row over the filtered set (served
|
|
@@ -777,14 +791,14 @@ declare class Client<T extends AtscriptClientShape = AtscriptClientShape, D exte
|
|
|
777
791
|
* rows, the root controls aggregate its rows and name its columns (its `$groupBy`
|
|
778
792
|
* keys and aliases) — typed by `ValidNested`, rows by `NestedAggregateResult`.
|
|
779
793
|
*/
|
|
780
|
-
aggregate<const Q extends AggregateQuery<Own<T>> | NestedAggregateQuery<Own<T>>>(query: Q & AggregateCheck<Own<T>, Q>, opts?:
|
|
794
|
+
aggregate<const Q extends AggregateQuery<Own<T>> | NestedAggregateQuery<Own<T>>>(query: Q & AggregateCheck<Own<T>, Q>, opts?: O): Promise<AggregateRows<Own<T>, Q>>;
|
|
781
795
|
/**
|
|
782
796
|
* `GET /pages` — paginated query with typed filter and relations.
|
|
783
797
|
*
|
|
784
798
|
* Response rows narrow by the literal `$with` array — same algebra as
|
|
785
799
|
* {@link query}, `$score` on a vector read included.
|
|
786
800
|
*/
|
|
787
|
-
pages<const Q extends DecoratedQuery<T, D> = DecoratedQuery<T, D>>(query?: Q, page?: number, size?: number, opts?:
|
|
801
|
+
pages<const Q extends DecoratedQuery<T, D> = DecoratedQuery<T, D>>(query?: Q, page?: number, size?: number, opts?: O): Promise<PageResult<ReadRow<T, Q, D>>>;
|
|
788
802
|
/**
|
|
789
803
|
* `GET /geo` — distance-ranked geospatial search (tables with `@db.index.geo`).
|
|
790
804
|
*
|
|
@@ -794,13 +808,13 @@ declare class Client<T extends AtscriptClientShape = AtscriptClientShape, D exte
|
|
|
794
808
|
* in `query.controls`; filter / `$select` / `$with` / `$skip` / `$limit`
|
|
795
809
|
* compose as usual.
|
|
796
810
|
*/
|
|
797
|
-
geoSearch<const Q extends DecoratedQuery<T, D> = DecoratedQuery<T, D>>(point: [number, number], query?: Q, opts?:
|
|
811
|
+
geoSearch<const Q extends DecoratedQuery<T, D> = DecoratedQuery<T, D>>(point: [number, number], query?: Q, opts?: O): Promise<Array<DecoratedRow<T, Q, D> & {
|
|
798
812
|
$distance: number;
|
|
799
813
|
}>>;
|
|
800
814
|
/**
|
|
801
815
|
* `GET /geo` with `$page` / `$size` — paginated distance-ranked search.
|
|
802
816
|
*/
|
|
803
|
-
geoPages<const Q extends DecoratedQuery<T, D> = DecoratedQuery<T, D>>(point: [number, number], query?: Q, page?: number, size?: number, opts?:
|
|
817
|
+
geoPages<const Q extends DecoratedQuery<T, D> = DecoratedQuery<T, D>>(point: [number, number], query?: Q, page?: number, size?: number, opts?: O): Promise<PageResult<DecoratedRow<T, Q, D> & {
|
|
804
818
|
$distance: number;
|
|
805
819
|
}>>;
|
|
806
820
|
/**
|
|
@@ -813,16 +827,16 @@ declare class Client<T extends AtscriptClientShape = AtscriptClientShape, D exte
|
|
|
813
827
|
controls?: DecoratedControls<T, D>;
|
|
814
828
|
} = {
|
|
815
829
|
controls?: DecoratedControls<T, D>;
|
|
816
|
-
}>(id: Id<T>, query?: Q, opts?:
|
|
830
|
+
}>(id: Id<T>, query?: Q, opts?: O): Promise<DecoratedRow<T, Q, D> | null>;
|
|
817
831
|
/**
|
|
818
832
|
* `POST /` — insert many records.
|
|
819
833
|
*/
|
|
820
|
-
insert(data: InsertOf<T>[], opts?:
|
|
834
|
+
insert(data: InsertOf<T>[], opts?: O): Promise<TDbInsertManyResult>;
|
|
821
835
|
/**
|
|
822
836
|
* `POST /?$onConflict=ignore` — insert many records, skipping the ones that
|
|
823
837
|
* collide; the result reports inserted and skipped input indices (since 0.1.148).
|
|
824
838
|
*/
|
|
825
|
-
insert(data: InsertOf<T>[], opts:
|
|
839
|
+
insert(data: InsertOf<T>[], opts: O & {
|
|
826
840
|
onConflict: "ignore";
|
|
827
841
|
}): Promise<TDbInsertManyIgnoreResult>;
|
|
828
842
|
/**
|
|
@@ -832,7 +846,7 @@ declare class Client<T extends AtscriptClientShape = AtscriptClientShape, D exte
|
|
|
832
846
|
* the server could not apply the preference (the caller may not read the
|
|
833
847
|
* row, or a skipped conflict).
|
|
834
848
|
*/
|
|
835
|
-
insert(data: SingleInsertOf<T>, opts:
|
|
849
|
+
insert(data: SingleInsertOf<T>, opts: O & {
|
|
836
850
|
returning: true;
|
|
837
851
|
}): Promise<TDbInsertResult & {
|
|
838
852
|
row?: InsertedRow<T, D>;
|
|
@@ -841,7 +855,7 @@ declare class Client<T extends AtscriptClientShape = AtscriptClientShape, D exte
|
|
|
841
855
|
* `POST /?$onConflict=ignore` with `Prefer: return=representation` — as
|
|
842
856
|
* above; a skipped row answers `{ conflict: true }` without `row`.
|
|
843
857
|
*/
|
|
844
|
-
insert(data: SingleInsertOf<T>, opts:
|
|
858
|
+
insert(data: SingleInsertOf<T>, opts: O & {
|
|
845
859
|
returning: true;
|
|
846
860
|
onConflict: "ignore";
|
|
847
861
|
}): Promise<TDbInsertIgnoreResult & {
|
|
@@ -851,12 +865,12 @@ declare class Client<T extends AtscriptClientShape = AtscriptClientShape, D exte
|
|
|
851
865
|
* `POST /` — insert one record. The version column (if any) is optional —
|
|
852
866
|
* the server initialises it; `$cas` is rejected (no meaning on insert).
|
|
853
867
|
*/
|
|
854
|
-
insert(data: InsertOf<T>, opts?:
|
|
868
|
+
insert(data: InsertOf<T>, opts?: O): Promise<TDbInsertResult>;
|
|
855
869
|
/**
|
|
856
870
|
* `POST /?$onConflict=ignore` — insert one record, skipping it when it
|
|
857
871
|
* collides on the primary key or a unique index (since 0.1.148).
|
|
858
872
|
*/
|
|
859
|
-
insert(data: InsertOf<T>, opts:
|
|
873
|
+
insert(data: InsertOf<T>, opts: O & {
|
|
860
874
|
onConflict: "ignore";
|
|
861
875
|
}): Promise<TDbInsertIgnoreResult>;
|
|
862
876
|
/**
|
|
@@ -868,16 +882,16 @@ declare class Client<T extends AtscriptClientShape = AtscriptClientShape, D exte
|
|
|
868
882
|
* {@link VersionMismatchError}; a PK-only body with a version is a real
|
|
869
883
|
* write (the server bumps the version).
|
|
870
884
|
*/
|
|
871
|
-
update(data: PatchOf<T> | PatchOf<T>[], opts?:
|
|
885
|
+
update(data: PatchOf<T> | PatchOf<T>[], opts?: O): Promise<TDbUpdateResult>;
|
|
872
886
|
/**
|
|
873
887
|
* `PUT /` — full replace one or many records by primary key. Same OCC
|
|
874
888
|
* shapes as {@link update}; the version column itself is optional.
|
|
875
889
|
*/
|
|
876
|
-
replace(data: RowOf<T> | RowOf<T>[], opts?:
|
|
890
|
+
replace(data: RowOf<T> | RowOf<T>[], opts?: O): Promise<TDbUpdateResult>;
|
|
877
891
|
/**
|
|
878
892
|
* `DELETE /:id` or `DELETE /?k1=v1&k2=v2` — remove a record by primary key.
|
|
879
893
|
*/
|
|
880
|
-
remove(id: Id<T>, opts?:
|
|
894
|
+
remove(id: Id<T>, opts?: O): Promise<TDbDeleteResult>;
|
|
881
895
|
/**
|
|
882
896
|
* `GET /meta` — table/view metadata (cached after first call).
|
|
883
897
|
*
|
package/dist/index.cjs
CHANGED
|
@@ -161,6 +161,12 @@ function clearMetaStore() {
|
|
|
161
161
|
* const rows = await tickets.query({ controls: { $select: ['title', 'ownerName'] } })
|
|
162
162
|
* rows[0].ownerName // string | undefined
|
|
163
163
|
* ```
|
|
164
|
+
*
|
|
165
|
+
* `O` (since 0.1.199) types the per-call options the read / write methods
|
|
166
|
+
* take (an interface extending {@link TClientCallOptions}). An implementation
|
|
167
|
+
* of `ClientLike` that has per-call options of its own declares them as `O`;
|
|
168
|
+
* `Client` itself reads only `signal` (and `insert`'s `onConflict` /
|
|
169
|
+
* `returning`).
|
|
164
170
|
*/
|
|
165
171
|
var Client = class {
|
|
166
172
|
_path;
|
|
@@ -316,20 +322,20 @@ var Client = class {
|
|
|
316
322
|
* write (the server bumps the version).
|
|
317
323
|
*/
|
|
318
324
|
async update(data, opts) {
|
|
319
|
-
return this._request("PATCH", "", await this._prepareWrite(data, "patch"), opts);
|
|
325
|
+
return this._request("PATCH", "", await this._prepareWrite(data, "patch"), { signal: opts?.signal });
|
|
320
326
|
}
|
|
321
327
|
/**
|
|
322
328
|
* `PUT /` — full replace one or many records by primary key. Same OCC
|
|
323
329
|
* shapes as {@link update}; the version column itself is optional.
|
|
324
330
|
*/
|
|
325
331
|
async replace(data, opts) {
|
|
326
|
-
return this._request("PUT", "", await this._prepareWrite(data, "replace"), opts);
|
|
332
|
+
return this._request("PUT", "", await this._prepareWrite(data, "replace"), { signal: opts?.signal });
|
|
327
333
|
}
|
|
328
334
|
/**
|
|
329
335
|
* `DELETE /:id` or `DELETE /?k1=v1&k2=v2` — remove a record by primary key.
|
|
330
336
|
*/
|
|
331
337
|
async remove(id, opts) {
|
|
332
|
-
return this._request("DELETE", this._idUrl("", id), void 0, opts);
|
|
338
|
+
return this._request("DELETE", this._idUrl("", id), void 0, { signal: opts?.signal });
|
|
333
339
|
}
|
|
334
340
|
/**
|
|
335
341
|
* `GET /meta` — table/view metadata (cached after first call).
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as RelationInfo, A as AggregateStage, B as DbPatch, C as ClientError, D as VersionMismatchErrorBody, E as VersionMismatchError, F as ClientLike, G as InsertOf, H as FieldMeta, I as ClientOptions, J as NestedAggregateQuery, K as MetaResponse, L as ClientResponse, M as BucketExpr, N as BucketUnit, O as AggregateQuery, P as CalendarBucketLabel, Q as PatchOf, R as DataOf, S as ActionUnsupportedError, St as defaultMetaStore, T as TransportError, U as FilterExpr, V as DbRow, W as IdOf, X as OwnOf, Y as NestedAggregateResult, Z as PageResult, _ as ActionDisabledError, _t as ValidNested, a as InsertedRow, at as TClientCallOptions, b as ActionTargetError, bt as MetaStoreOptions, c as actionIdentifier, ct as TDbInsertManyIgnoreResult, d as formatIdentifierField, dt as TDbQueryTarget, et as ResponseDataOf, f as ClientValidator, ft as TDbUpdateResult, gt as ValidGroupBy, h as ValidatorMode, ht as UniqueryControls, i as DecoratedRow, it as StageRow, j as AtscriptClientShape, k as AggregateResult, l as encodeNavigateId, lt as TDbInsertManyResult, mt as Uniquery, n as AggregateRows, nt as SearchIndexInfo, o as ReadRow, ot as TDbDeleteResult, p as ClientValidatorOptions, pt as TypedWithRelation, q as NavOf, r as Client, rt as ServerError, s as SingleInsertOf, st as TDbInsertIgnoreResult, t as AggregateCheck, tt as RowOf, u as formatIdentifier, ut as TDbInsertResult, v as ActionDisabledErrorBody, vt as WeekStart, w as ClientValidationError, x as ActionTargetErrorBody, xt as clearMetaStore, y as ActionNotFoundError, yt as MetaStore, z as DbInsert } from "./client-
|
|
1
|
+
import { $ as RelationInfo, A as AggregateStage, B as DbPatch, C as ClientError, D as VersionMismatchErrorBody, E as VersionMismatchError, F as ClientLike, G as InsertOf, H as FieldMeta, I as ClientOptions, J as NestedAggregateQuery, K as MetaResponse, L as ClientResponse, M as BucketExpr, N as BucketUnit, O as AggregateQuery, P as CalendarBucketLabel, Q as PatchOf, R as DataOf, S as ActionUnsupportedError, St as defaultMetaStore, T as TransportError, U as FilterExpr, V as DbRow, W as IdOf, X as OwnOf, Y as NestedAggregateResult, Z as PageResult, _ as ActionDisabledError, _t as ValidNested, a as InsertedRow, at as TClientCallOptions, b as ActionTargetError, bt as MetaStoreOptions, c as actionIdentifier, ct as TDbInsertManyIgnoreResult, d as formatIdentifierField, dt as TDbQueryTarget, et as ResponseDataOf, f as ClientValidator, ft as TDbUpdateResult, gt as ValidGroupBy, h as ValidatorMode, ht as UniqueryControls, i as DecoratedRow, it as StageRow, j as AtscriptClientShape, k as AggregateResult, l as encodeNavigateId, lt as TDbInsertManyResult, mt as Uniquery, n as AggregateRows, nt as SearchIndexInfo, o as ReadRow, ot as TDbDeleteResult, p as ClientValidatorOptions, pt as TypedWithRelation, q as NavOf, r as Client, rt as ServerError, s as SingleInsertOf, st as TDbInsertIgnoreResult, t as AggregateCheck, tt as RowOf, u as formatIdentifier, ut as TDbInsertResult, v as ActionDisabledErrorBody, vt as WeekStart, w as ClientValidationError, x as ActionTargetErrorBody, xt as clearMetaStore, y as ActionNotFoundError, yt as MetaStore, z as DbInsert } from "./client-CVcoc72F.cjs";
|
|
2
2
|
import { BucketSeriesOptions, NextBucketOptions, bucketSeries, bucketStartInstant, nextBucketLabel } from "@uniqu/core";
|
|
3
3
|
import { TSerializedAnnotatedType } from "@atscript/typescript/utils";
|
|
4
4
|
import { TCrudOp, TCrudPermissions, TDbActionInfo, TDbActionIntent, TDbActionLevel, TDbActionProcessor, TDbActionTargetSummary, TDbAvailableActions } from "@atscript/db";
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as RelationInfo, A as AggregateStage, B as DbPatch, C as ClientError, D as VersionMismatchErrorBody, E as VersionMismatchError, F as ClientLike, G as InsertOf, H as FieldMeta, I as ClientOptions, J as NestedAggregateQuery, K as MetaResponse, L as ClientResponse, M as BucketExpr, N as BucketUnit, O as AggregateQuery, P as CalendarBucketLabel, Q as PatchOf, R as DataOf, S as ActionUnsupportedError, St as defaultMetaStore, T as TransportError, U as FilterExpr, V as DbRow, W as IdOf, X as OwnOf, Y as NestedAggregateResult, Z as PageResult, _ as ActionDisabledError, _t as ValidNested, a as InsertedRow, at as TClientCallOptions, b as ActionTargetError, bt as MetaStoreOptions, c as actionIdentifier, ct as TDbInsertManyIgnoreResult, d as formatIdentifierField, dt as TDbQueryTarget, et as ResponseDataOf, f as ClientValidator, ft as TDbUpdateResult, gt as ValidGroupBy, h as ValidatorMode, ht as UniqueryControls, i as DecoratedRow, it as StageRow, j as AtscriptClientShape, k as AggregateResult, l as encodeNavigateId, lt as TDbInsertManyResult, mt as Uniquery, n as AggregateRows, nt as SearchIndexInfo, o as ReadRow, ot as TDbDeleteResult, p as ClientValidatorOptions, pt as TypedWithRelation, q as NavOf, r as Client, rt as ServerError, s as SingleInsertOf, st as TDbInsertIgnoreResult, t as AggregateCheck, tt as RowOf, u as formatIdentifier, ut as TDbInsertResult, v as ActionDisabledErrorBody, vt as WeekStart, w as ClientValidationError, x as ActionTargetErrorBody, xt as clearMetaStore, y as ActionNotFoundError, yt as MetaStore, z as DbInsert } from "./client-
|
|
1
|
+
import { $ as RelationInfo, A as AggregateStage, B as DbPatch, C as ClientError, D as VersionMismatchErrorBody, E as VersionMismatchError, F as ClientLike, G as InsertOf, H as FieldMeta, I as ClientOptions, J as NestedAggregateQuery, K as MetaResponse, L as ClientResponse, M as BucketExpr, N as BucketUnit, O as AggregateQuery, P as CalendarBucketLabel, Q as PatchOf, R as DataOf, S as ActionUnsupportedError, St as defaultMetaStore, T as TransportError, U as FilterExpr, V as DbRow, W as IdOf, X as OwnOf, Y as NestedAggregateResult, Z as PageResult, _ as ActionDisabledError, _t as ValidNested, a as InsertedRow, at as TClientCallOptions, b as ActionTargetError, bt as MetaStoreOptions, c as actionIdentifier, ct as TDbInsertManyIgnoreResult, d as formatIdentifierField, dt as TDbQueryTarget, et as ResponseDataOf, f as ClientValidator, ft as TDbUpdateResult, gt as ValidGroupBy, h as ValidatorMode, ht as UniqueryControls, i as DecoratedRow, it as StageRow, j as AtscriptClientShape, k as AggregateResult, l as encodeNavigateId, lt as TDbInsertManyResult, mt as Uniquery, n as AggregateRows, nt as SearchIndexInfo, o as ReadRow, ot as TDbDeleteResult, p as ClientValidatorOptions, pt as TypedWithRelation, q as NavOf, r as Client, rt as ServerError, s as SingleInsertOf, st as TDbInsertIgnoreResult, t as AggregateCheck, tt as RowOf, u as formatIdentifier, ut as TDbInsertResult, v as ActionDisabledErrorBody, vt as WeekStart, w as ClientValidationError, x as ActionTargetErrorBody, xt as clearMetaStore, y as ActionNotFoundError, yt as MetaStore, z as DbInsert } from "./client-CM--7NfJ.mjs";
|
|
2
2
|
import { BucketSeriesOptions, NextBucketOptions, bucketSeries, bucketStartInstant, nextBucketLabel } from "@uniqu/core";
|
|
3
3
|
import { TSerializedAnnotatedType } from "@atscript/typescript/utils";
|
|
4
4
|
import { TCrudOp, TCrudPermissions, TDbActionInfo, TDbActionIntent, TDbActionLevel, TDbActionProcessor, TDbActionTargetSummary, TDbAvailableActions } from "@atscript/db";
|
package/dist/index.mjs
CHANGED
|
@@ -160,6 +160,12 @@ function clearMetaStore() {
|
|
|
160
160
|
* const rows = await tickets.query({ controls: { $select: ['title', 'ownerName'] } })
|
|
161
161
|
* rows[0].ownerName // string | undefined
|
|
162
162
|
* ```
|
|
163
|
+
*
|
|
164
|
+
* `O` (since 0.1.199) types the per-call options the read / write methods
|
|
165
|
+
* take (an interface extending {@link TClientCallOptions}). An implementation
|
|
166
|
+
* of `ClientLike` that has per-call options of its own declares them as `O`;
|
|
167
|
+
* `Client` itself reads only `signal` (and `insert`'s `onConflict` /
|
|
168
|
+
* `returning`).
|
|
163
169
|
*/
|
|
164
170
|
var Client = class {
|
|
165
171
|
_path;
|
|
@@ -315,20 +321,20 @@ var Client = class {
|
|
|
315
321
|
* write (the server bumps the version).
|
|
316
322
|
*/
|
|
317
323
|
async update(data, opts) {
|
|
318
|
-
return this._request("PATCH", "", await this._prepareWrite(data, "patch"), opts);
|
|
324
|
+
return this._request("PATCH", "", await this._prepareWrite(data, "patch"), { signal: opts?.signal });
|
|
319
325
|
}
|
|
320
326
|
/**
|
|
321
327
|
* `PUT /` — full replace one or many records by primary key. Same OCC
|
|
322
328
|
* shapes as {@link update}; the version column itself is optional.
|
|
323
329
|
*/
|
|
324
330
|
async replace(data, opts) {
|
|
325
|
-
return this._request("PUT", "", await this._prepareWrite(data, "replace"), opts);
|
|
331
|
+
return this._request("PUT", "", await this._prepareWrite(data, "replace"), { signal: opts?.signal });
|
|
326
332
|
}
|
|
327
333
|
/**
|
|
328
334
|
* `DELETE /:id` or `DELETE /?k1=v1&k2=v2` — remove a record by primary key.
|
|
329
335
|
*/
|
|
330
336
|
async remove(id, opts) {
|
|
331
|
-
return this._request("DELETE", this._idUrl("", id), void 0, opts);
|
|
337
|
+
return this._request("DELETE", this._idUrl("", id), void 0, { signal: opts?.signal });
|
|
332
338
|
}
|
|
333
339
|
/**
|
|
334
340
|
* `GET /meta` — table/view metadata (cached after first call).
|
package/dist/validator.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { f as ClientValidator, g as createClientValidator, h as ValidatorMode, m as DbValidationContext, p as ClientValidatorOptions, w as ClientValidationError } from "./client-
|
|
1
|
+
import { f as ClientValidator, g as createClientValidator, h as ValidatorMode, m as DbValidationContext, p as ClientValidatorOptions, w as ClientValidationError } from "./client-CVcoc72F.cjs";
|
|
2
2
|
export { ClientValidationError, ClientValidator, ClientValidatorOptions, type DbValidationContext, type ValidatorMode, createClientValidator };
|
package/dist/validator.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { f as ClientValidator, g as createClientValidator, h as ValidatorMode, m as DbValidationContext, p as ClientValidatorOptions, w as ClientValidationError } from "./client-
|
|
1
|
+
import { f as ClientValidator, g as createClientValidator, h as ValidatorMode, m as DbValidationContext, p as ClientValidatorOptions, w as ClientValidationError } from "./client-CM--7NfJ.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.
|
|
3
|
+
"version": "0.1.200",
|
|
4
4
|
"description": "Browser-compatible HTTP client for @atscript/moost-db REST endpoints.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"atscript",
|
|
@@ -47,14 +47,14 @@
|
|
|
47
47
|
"@uniqu/url": "^0.2.2"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@atscript/core": "^0.2.
|
|
51
|
-
"@atscript/typescript": "^0.2.
|
|
52
|
-
"unplugin-atscript": "^0.2.
|
|
53
|
-
"@atscript/db": "0.1.
|
|
50
|
+
"@atscript/core": "^0.2.25",
|
|
51
|
+
"@atscript/typescript": "^0.2.25",
|
|
52
|
+
"unplugin-atscript": "^0.2.25",
|
|
53
|
+
"@atscript/db": "0.1.200"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@atscript/typescript": "^0.2.
|
|
57
|
-
"@atscript/db": "^0.1.
|
|
56
|
+
"@atscript/typescript": "^0.2.25",
|
|
57
|
+
"@atscript/db": "^0.1.200"
|
|
58
58
|
},
|
|
59
59
|
"scripts": {
|
|
60
60
|
"build": "vp pack",
|