content-query 0.3.0 → 0.5.0
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/README.md +46 -15
- package/dist/{build-CI4s0oFP.mjs → build-DWpB69_c.mjs} +826 -69
- package/dist/{build-jKnjDjQE.d.mts → build-DfoncKL8.d.mts} +17 -5
- package/dist/build.d.mts +1 -1
- package/dist/build.mjs +1 -1
- package/dist/cli.mjs +14 -8
- package/dist/{content-N1gYshjg.mjs → collection-Cb5eWGnv.mjs} +998 -344
- package/dist/collection-types-CsQtGw7_.d.mts +119 -0
- package/dist/computed.d.mts +2 -2
- package/dist/{types-FmUJ3cH1.d.mts → descriptor-bcPa6XLk.d.mts} +17 -1
- package/dist/{diagnostics-Cu94mZhl.mjs → diagnostics-DmUZtrJ6.mjs} +3 -1
- package/dist/{errors-C2iuBM0G.mjs → errors-Bfd0R4_P.mjs} +16 -1
- package/dist/file-DSOcdFj0.mjs +81 -0
- package/dist/{glob-Bv0dpvCQ.mjs → glob-BXJuwy_p.mjs} +94 -6
- package/dist/index.d.mts +76 -18
- package/dist/index.mjs +1 -1
- package/dist/internal.d.mts +54 -7
- package/dist/internal.mjs +424 -19
- package/dist/loaders.d.mts +1 -2
- package/dist/loaders.mjs +2 -81
- package/dist/next.d.mts +3 -2
- package/dist/next.mjs +67 -14
- package/dist/operators-D-w1-gDg.mjs +391 -0
- package/dist/query-style-C2FcT1f9.d.mts +23 -0
- package/dist/query.d.mts +25 -2
- package/dist/query.mjs +1 -1
- package/dist/{relational-types-B45zM34W.d.mts → relational-types-CTcalUNW.d.mts} +241 -50
- package/dist/revision-DBwU-aC9.d.mts +56 -0
- package/dist/runtime.d.mts +3 -2
- package/dist/runtime.mjs +1 -1
- package/dist/types-Dz1vTXa2.d.mts +214 -0
- package/dist/vite.d.mts +1 -1
- package/dist/vite.mjs +77 -35
- package/package.json +1 -1
- package/dist/content-lwPxE9Yu.d.mts +0 -109
- package/dist/descriptor-BUPT2J7X.d.mts +0 -18
- package/dist/operators-UqWUhKQJ.mjs +0 -173
- package/dist/types-BC8gVJ6u.d.mts +0 -69
- package/dist/validation-D_XdE1pF.mjs +0 -84
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { S as UnavailableRelationshipsOf, T as VariantOf, _ as Relationship, g as QueryData, h as PayloadsOf, i as CollectionRegistry, v as RelationshipsOf, x as UnavailableRelationship } from "./types-Dz1vTXa2.mjs";
|
|
2
2
|
//#region src/query/plan.d.ts
|
|
3
3
|
type PredicateOperator = "eq" | "ne" | "gt" | "gte" | "lt" | "lte" | "in-array" | "not-in-array" | "contains" | "starts-with" | "ends-with" | "like" | "ilike" | "array-contains" | "array-contains-any" | "array-contains-all" | "array-contained" | "is-null" | "is-undefined" | "is-missing";
|
|
4
4
|
type Expression = {
|
|
@@ -12,15 +12,20 @@ type Expression = {
|
|
|
12
12
|
field: string;
|
|
13
13
|
target: string;
|
|
14
14
|
expression: Expression;
|
|
15
|
+
} |
|
|
16
|
+
/** A fluent `has()` filter that query builders resolve into a `relation` expression. */
|
|
17
|
+
{
|
|
18
|
+
kind: "has";
|
|
19
|
+
field: string;
|
|
20
|
+
expression: Expression;
|
|
15
21
|
} | {
|
|
16
22
|
kind: "and" | "or" | "not";
|
|
17
23
|
expressions: readonly Expression[];
|
|
18
24
|
};
|
|
19
25
|
type QueryPlan = {
|
|
20
26
|
collection: string;
|
|
27
|
+
/** Explicitly selected fields; scopes never include unselected fields, including `id`. */
|
|
21
28
|
select?: readonly string[];
|
|
22
|
-
allFields?: boolean;
|
|
23
|
-
exclude?: readonly string[];
|
|
24
29
|
filters: readonly Expression[];
|
|
25
30
|
order: readonly {
|
|
26
31
|
field: string;
|
|
@@ -29,14 +34,45 @@ type QueryPlan = {
|
|
|
29
34
|
limit?: number;
|
|
30
35
|
offset?: number;
|
|
31
36
|
with: Readonly<Record<string, QueryPlan>>;
|
|
32
|
-
adjacent?:
|
|
37
|
+
adjacent?: AdjacentPlan;
|
|
33
38
|
/** Payloads to attach under `_payloads` after filtering, ordering, and pagination. */
|
|
34
39
|
payloads?: Readonly<Record<string, PlanPayload>>;
|
|
40
|
+
/** A root `paginate()` request; plans that carry it never set `limit` or `offset`. */
|
|
41
|
+
paginate?: PaginatePlan;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* A page-number or cursor page request. Cursor keys are already decoded into the sort values of the
|
|
45
|
+
* boundary entry, in effective-order position, so backends never parse cursor strings.
|
|
46
|
+
*/
|
|
47
|
+
type PaginatePlan = {
|
|
48
|
+
mode: "page";
|
|
49
|
+
page: number;
|
|
50
|
+
size: number;
|
|
51
|
+
} | {
|
|
52
|
+
mode: "cursor";
|
|
53
|
+
size: number;
|
|
54
|
+
/** `after` pages forward from `key`; `before` pages backward to it. */
|
|
55
|
+
direction: "after" | "before";
|
|
56
|
+
/** Sort values of the boundary entry; omitted to start at the first or last entry. */
|
|
57
|
+
key?: readonly unknown[];
|
|
58
|
+
/** Whether the result includes the filtered total. */
|
|
59
|
+
total: boolean;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Selects previous and next entries. `results` finds neighbors within the scope's own filtered and
|
|
63
|
+
* ordered entries, or a parent's related entries, and `plan` holds only their selection;
|
|
64
|
+
* `collection` finds neighbors in an independent sibling scope described by `plan`.
|
|
65
|
+
*/
|
|
66
|
+
type AdjacentPlan = {
|
|
67
|
+
scope: "results" | "collection";
|
|
68
|
+
plan: QueryPlan;
|
|
35
69
|
};
|
|
36
70
|
/** One requested payload; variant keys are empty for payloads without variants. */
|
|
37
71
|
type PlanPayload = {
|
|
38
72
|
variant: Readonly<Record<string, string>>;
|
|
39
73
|
};
|
|
74
|
+
/** How a plan returns its results; `paginate` requires the plan's `paginate` request. */
|
|
75
|
+
type QueryTerminal = "all" | "first" | "count" | "paginate";
|
|
40
76
|
/** Describes a payload that queries may request, without its resolver or schema. */
|
|
41
77
|
type PayloadDescriptor = {
|
|
42
78
|
variants: readonly string[];
|
|
@@ -45,16 +81,41 @@ type QueryRegistry = Record<string, {
|
|
|
45
81
|
relationships: Record<string, Relationship>;
|
|
46
82
|
/** Payload names available to queries; omitted when the collection has none. */
|
|
47
83
|
payloads?: Record<string, PayloadDescriptor>;
|
|
84
|
+
/**
|
|
85
|
+
* Declared relationships whose target collection this query scope has not loaded, by name, with
|
|
86
|
+
* the target collection. Queries that use one report which collection to pass to `using()`.
|
|
87
|
+
*/
|
|
88
|
+
unavailable?: Record<string, string>;
|
|
89
|
+
/** The declared `typeName`, which only generated declarations read. */
|
|
90
|
+
typeName?: string;
|
|
48
91
|
}>;
|
|
92
|
+
/** Explains the explicit-selection rule wherever a scope returns rows without selecting data. */
|
|
93
|
+
declare const NO_SELECTION_MESSAGE: "Select fields, relationships, payloads, or adjacent entries before running this query.";
|
|
94
|
+
/** Explains why `paginate()` is unavailable once a query sets its own limit or offset. */
|
|
95
|
+
declare const PAGINATE_AFTER_LIMIT_MESSAGE: "paginate() sets the limit and offset itself; remove limit and offset from this query.";
|
|
49
96
|
//#endregion
|
|
50
97
|
//#region src/query/types.d.ts
|
|
51
98
|
declare const queryType: unique symbol;
|
|
99
|
+
/** Running an unselected query reports the explicit-selection rule as its required `this` type. */
|
|
100
|
+
type UnselectedTerminal = (this: typeof NO_SELECTION_MESSAGE, ...arguments_: readonly unknown[]) => never;
|
|
101
|
+
/** A `then` that cannot resolve a value, so awaiting an unselected query fails to compile. */
|
|
102
|
+
type UnselectedThen = (selectBeforeAwaiting: typeof NO_SELECTION_MESSAGE) => never;
|
|
52
103
|
declare const fieldType: unique symbol;
|
|
53
104
|
type Field$1<Value> = {
|
|
54
105
|
readonly name: string;
|
|
55
106
|
readonly [fieldType]: Value;
|
|
56
107
|
};
|
|
57
108
|
type Fields<Data> = { readonly [Name in keyof Data]-?: Field$1<Data[Name]>; };
|
|
109
|
+
declare const relationTarget: unique symbol;
|
|
110
|
+
/** A relationship in a fluent `where()` callback, filtered with `has()`. */
|
|
111
|
+
type RelationField<TargetFields> = {
|
|
112
|
+
readonly name: string;
|
|
113
|
+
readonly [relationTarget]: TargetFields;
|
|
114
|
+
};
|
|
115
|
+
/** Fields and relationships available to a fluent `where()` callback. */
|
|
116
|
+
type QueryFields<Registry extends CollectionRegistry, Name extends keyof Registry & string> = Fields<QueryData<Registry[Name]>> & { readonly [Key in keyof RelationshipsOf<Registry[Name]> & string]-?: RelationField<QueryFields<Registry, RelatedName$1<Registry, RelationOf<Registry, Name, Key>>>>; } & { readonly [
|
|
117
|
+
/** A relationship into a collection the query has not loaded reads as the type error. */
|
|
118
|
+
Key in keyof UnavailableRelationshipsOf<Registry[Name]> & string]-?: UnavailableRelationship<Registry[Name], Key>; };
|
|
58
119
|
type Scalar = string | number | bigint | boolean | Date | null | undefined;
|
|
59
120
|
type ScalarField<Value> = Field$1<Value> & ([Value] extends [Scalar] ? unknown : never);
|
|
60
121
|
type Ordered<Value> = NonNullable<Value> extends string ? unknown : NonNullable<Value> extends number ? unknown : NonNullable<Value> extends bigint ? unknown : NonNullable<Value> extends Date ? unknown : never;
|
|
@@ -80,39 +141,112 @@ type RelatedName$1<Registry extends CollectionRegistry, Relation extends Relatio
|
|
|
80
141
|
/** Applies declared relationship cardinality, optional reference fields, and filtering to a result. */
|
|
81
142
|
type RelationshipResult<Definition, Relation extends Relationship, Result, Filtered extends boolean = false> = Relation["type"] extends "many" ? Result[] : Result | (Filtered extends true ? null : Relation["referenceSide"] extends "from" ? Relation["from"] extends keyof QueryData<Definition> ? null extends QueryData<Definition>[Relation["from"]] ? null : undefined extends QueryData<Definition>[Relation["from"]] ? null : never : null : null);
|
|
82
143
|
type RelationValue<Definition, Relation extends Relationship, Configured> = RelationshipResult<Definition, Relation, ResultOf<Configured>, FilteredOf<Configured>>;
|
|
83
|
-
type Query<Registry extends CollectionRegistry, Name extends keyof Registry & string, Result = {}, Selected extends boolean = false, Many extends boolean = true, Root extends boolean = true, Filtered extends boolean = false, AllowAdjacent extends boolean = true, Pagination extends boolean = true> = QueryInfo<Result, Selected, Filtered> & {
|
|
84
|
-
select<const Keys extends readonly [keyof QueryData<Registry[Name]> & string, ...(keyof QueryData<Registry[Name]> & string)[]]>(...keys: Keys): Query<Registry, Name, { [Key in Exclude<keyof Result, keyof QueryData<Registry[Name]>> | Keys[number]]: Key extends Keys[number] ? QueryData<Registry[Name]>[Key & keyof QueryData<Registry[Name]>] : Key extends keyof Result ? Result[Key] : never; }, true, Many, Root, Filtered, AllowAdjacent, Pagination>;
|
|
85
|
-
where(configure: (fields:
|
|
86
|
-
with<Key extends keyof RelationshipsOf<Registry[Name]> & string, Configured extends QueryInfo<unknown, true>>(name: Key, configure: (query: Query<Registry, RelatedName$1<Registry, RelationOf<Registry, Name, Key>>, {}, false, RelationOf<Registry, Name, Key>["type"] extends "many" ? true : false, false, false, AllowAdjacent>) => Configured): Query<Registry, Name, Result & { [Property in Key]: RelationValue<Registry[Name], RelationOf<Registry, Name, Key>, Configured>; }, true, Many, Root, Filtered, AllowAdjacent, Pagination>;
|
|
144
|
+
type Query<Registry extends CollectionRegistry, Name extends keyof Registry & string, Result = {}, Selected extends boolean = false, Many extends boolean = true, Root extends boolean = true, Filtered extends boolean = false, AllowAdjacent extends boolean = true, Pagination extends boolean = true, Paged extends boolean = false> = QueryInfo<Result, Selected, Filtered> & {
|
|
145
|
+
select<const Keys extends readonly [keyof QueryData<Registry[Name]> & string, ...(keyof QueryData<Registry[Name]> & string)[]]>(...keys: Keys): Query<Registry, Name, { [Key in Exclude<keyof Result, keyof QueryData<Registry[Name]>> | Keys[number]]: Key extends Keys[number] ? QueryData<Registry[Name]>[Key & keyof QueryData<Registry[Name]>] : Key extends keyof Result ? Result[Key] : never; }, true, Many, Root, Filtered, AllowAdjacent, Pagination, Paged>;
|
|
146
|
+
where(configure: (fields: QueryFields<Registry, Name>) => Expression): Query<Registry, Name, Result, Selected, Many, Root, true, AllowAdjacent, Pagination, Paged>;
|
|
147
|
+
with<Key extends keyof RelationshipsOf<Registry[Name]> & string, Configured extends QueryInfo<unknown, true>>(name: Key, configure: (query: Query<Registry, RelatedName$1<Registry, RelationOf<Registry, Name, Key>>, {}, false, RelationOf<Registry, Name, Key>["type"] extends "many" ? true : false, false, false, AllowAdjacent>) => Configured): Query<Registry, Name, Result & { [Property in Key]: RelationValue<Registry[Name], RelationOf<Registry, Name, Key>, Configured>; }, true, Many, Root, Filtered, AllowAdjacent, Pagination, Paged>;
|
|
148
|
+
/** A relationship into a collection the query has not loaded reports which one to supply. */
|
|
149
|
+
with<Key extends keyof UnavailableRelationshipsOf<Registry[Name]> & string>(name: Key, configure: UnavailableRelationship<Registry[Name], Key>): never;
|
|
87
150
|
} & (Many extends true ? {
|
|
88
|
-
orderBy(field: SortKey<QueryData<Registry[Name]>>, direction?: "asc" | "desc"): Query<Registry, Name, Result, Selected, Many, Root, Filtered, AllowAdjacent, Pagination>;
|
|
151
|
+
orderBy(field: SortKey<QueryData<Registry[Name]>>, direction?: "asc" | "desc"): Query<Registry, Name, Result, Selected, Many, Root, Filtered, AllowAdjacent, Pagination, Paged>;
|
|
89
152
|
} : {}) & (Many extends true ? Pagination extends true ? {
|
|
90
|
-
limit(value: number): Query<Registry, Name, Result, Selected, Many, Root, Filtered, AllowAdjacent, Pagination>;
|
|
91
|
-
offset(value: number): Query<Registry, Name, Result, Selected, Many, Root, Filtered, AllowAdjacent, Pagination>;
|
|
153
|
+
limit(value: number): Query<Registry, Name, Result, Selected, Many, Root, Filtered, AllowAdjacent, Pagination, true>;
|
|
154
|
+
offset(value: number): Query<Registry, Name, Result, Selected, Many, Root, Filtered, AllowAdjacent, Pagination, true>;
|
|
92
155
|
} : {} : {}) & (AllowAdjacent extends true ? {
|
|
93
156
|
/** Attaches a payload under `_payloads` after filtering, ordering, and pagination. */
|
|
94
|
-
withPayload<Key extends keyof PayloadsOf<Registry[Name]> & string>(name: Key): Query<Registry, Name, WithPayload<Result, Key, PayloadsOf<Registry[Name]>[Key]>,
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}, true, Many, Root, Filtered, AllowAdjacent, Pagination>;
|
|
157
|
+
withPayload<Key extends keyof PayloadsOf<Registry[Name]> & string>(name: Key, ...variant: keyof VariantOf<Registry[Name], Key> extends never ? [] : [variant: Readonly<VariantOf<Registry[Name], Key>>]): Query<Registry, Name, WithPayload<Result, Key, PayloadsOf<Registry[Name]>[Key]>, true, Many, Root, Filtered, AllowAdjacent, Pagination, Paged>;
|
|
158
|
+
/** Selects neighbor fields within this scope's filtered and ordered results. */
|
|
159
|
+
selectAdjacent<const Keys extends readonly [keyof QueryData<Registry[Name]> & string, ...(keyof QueryData<Registry[Name]> & string)[]]>(...fields: Keys): Query<Registry, Name, Result & {
|
|
160
|
+
_adjacent: Adjacent<{ [Key in Keys[number]]: QueryData<Registry[Name]>[Key & keyof QueryData<Registry[Name]>]; }>;
|
|
161
|
+
}, true, Many, Root, Filtered, AllowAdjacent, Pagination, Paged>;
|
|
100
162
|
selectAdjacent<Configured extends QueryInfo<unknown, true>>(configure: (siblings: Query<Registry, Name, {}, false, true, false, false, false, false>) => Configured): Query<Registry, Name, Result & {
|
|
101
163
|
_adjacent: Adjacent<ResultOf<Configured>>;
|
|
102
|
-
}, true, Many, Root, Filtered, AllowAdjacent, Pagination>;
|
|
164
|
+
}, true, Many, Root, Filtered, AllowAdjacent, Pagination, Paged>;
|
|
103
165
|
selectAdjacent<const Options extends AdjacentOptions<Registry, Name>>(options: Options & CheckedOptions<Registry, Name, NoInfer<Options>, true, false, false>): Query<Registry, Name, Result & {
|
|
104
166
|
_adjacent: Adjacent<SelectionResult<Registry, Name, Options["select"]>>;
|
|
105
|
-
}, true, Many, Root, Filtered, AllowAdjacent, Pagination>;
|
|
167
|
+
}, true, Many, Root, Filtered, AllowAdjacent, Pagination, Paged>;
|
|
106
168
|
} : {}) & (Root extends true ? {
|
|
107
|
-
all: Selected extends true ? () => Promise<Simplify$1<Result>[]> :
|
|
108
|
-
execute: Selected extends true ? () => Promise<Simplify$1<Result>[]> :
|
|
109
|
-
then: Selected extends true ? Promise<Simplify$1<Result>[]>["then"] :
|
|
110
|
-
first: Selected extends true ? () => Promise<Simplify$1<Result> | undefined> :
|
|
111
|
-
/** Counts matching entries; unavailable once payloads are requested. */
|
|
169
|
+
all: Selected extends true ? () => Promise<Simplify$1<Result>[]> : UnselectedTerminal;
|
|
170
|
+
execute: Selected extends true ? () => Promise<Simplify$1<Result>[]> : UnselectedTerminal;
|
|
171
|
+
then: Selected extends true ? Promise<Simplify$1<Result>[]>["then"] : UnselectedThen;
|
|
172
|
+
first: Selected extends true ? () => Promise<Simplify$1<Result> | undefined> : UnselectedTerminal;
|
|
173
|
+
/** Counts matching entries without a selection; unavailable once payloads are requested. */
|
|
112
174
|
count: [Result] extends [never] ? () => Promise<number> : [Result] extends [{
|
|
113
175
|
_payloads: unknown;
|
|
114
176
|
}] ? never : () => Promise<number>;
|
|
177
|
+
/**
|
|
178
|
+
* Returns one page from one revision: `{ page, size }` for page numbers, or
|
|
179
|
+
* `{ size, after?, before?, total? }` for cursors. Unavailable after `limit()` or `offset()`.
|
|
180
|
+
*/
|
|
181
|
+
paginate: Selected extends true ? [Paged] extends [true] ? PaginateAfterLimit : Paginate<Simplify$1<Result>> : UnselectedTerminal;
|
|
115
182
|
} : {});
|
|
183
|
+
/** `paginate()` after `limit()` or `offset()` reports why as its required `this` type. */
|
|
184
|
+
type PaginateAfterLimit = (this: typeof PAGINATE_AFTER_LIMIT_MESSAGE, ...arguments_: readonly unknown[]) => never;
|
|
185
|
+
/** The `paginate()` overloads for one item type. */
|
|
186
|
+
type Paginate<Item> = {
|
|
187
|
+
(options: PageOptions): Promise<NumberedPage<Item>>;
|
|
188
|
+
(options: CursorOptions & {
|
|
189
|
+
total: true;
|
|
190
|
+
}): Promise<CursorPage<Item, true>>;
|
|
191
|
+
(options: CursorOptions): Promise<CursorPage<Item>>;
|
|
192
|
+
};
|
|
193
|
+
/** Page-number pagination: `page` starts at 1 and `size` is the number of entries per page. */
|
|
194
|
+
type PageOptions = {
|
|
195
|
+
page: number;
|
|
196
|
+
size: number;
|
|
197
|
+
after?: never;
|
|
198
|
+
before?: never;
|
|
199
|
+
total?: never;
|
|
200
|
+
};
|
|
201
|
+
/**
|
|
202
|
+
* Cursor pagination. `after` continues from an earlier page's `endCursor`; `before` returns the
|
|
203
|
+
* entries just before a `startCursor`. A `null` cursor starts at the first entry (`after`) or the
|
|
204
|
+
* last entry (`before`). `total: true` adds the matching total.
|
|
205
|
+
*/
|
|
206
|
+
type CursorOptions = {
|
|
207
|
+
size: number;
|
|
208
|
+
page?: never;
|
|
209
|
+
total?: boolean;
|
|
210
|
+
} & ({
|
|
211
|
+
after?: string | null;
|
|
212
|
+
before?: never;
|
|
213
|
+
} | {
|
|
214
|
+
before?: string | null;
|
|
215
|
+
after?: never;
|
|
216
|
+
});
|
|
217
|
+
/** Options accepted by `paginate()`. */
|
|
218
|
+
type PaginateOptions = PageOptions | CursorOptions;
|
|
219
|
+
/** Option names that `paginate()` reads alongside relational query options. */
|
|
220
|
+
type PaginateKey = keyof PageOptions;
|
|
221
|
+
/** One numbered page and where it sits among every matching entry. */
|
|
222
|
+
type NumberedPage<Item> = {
|
|
223
|
+
items: Item[];
|
|
224
|
+
/** Matching entries across every page. */
|
|
225
|
+
total: number;
|
|
226
|
+
page: number;
|
|
227
|
+
/** At least 1: the first page exists even when nothing matches. */
|
|
228
|
+
pageCount: number;
|
|
229
|
+
hasNextPage: boolean;
|
|
230
|
+
hasPreviousPage: boolean;
|
|
231
|
+
};
|
|
232
|
+
/** One cursor page. Both cursors are `null` when the page is empty. */
|
|
233
|
+
type CursorPage<Item, Total extends boolean = false> = {
|
|
234
|
+
items: Item[];
|
|
235
|
+
/** Pass as `before` for the previous page. */
|
|
236
|
+
startCursor: string | null;
|
|
237
|
+
/** Pass as `after` for the next page. */
|
|
238
|
+
endCursor: string | null;
|
|
239
|
+
hasNextPage: boolean;
|
|
240
|
+
hasPreviousPage: boolean;
|
|
241
|
+
} & (Total extends true ? {
|
|
242
|
+
total: number;
|
|
243
|
+
} : {});
|
|
244
|
+
/** The page type `paginate()` returns for the given options. */
|
|
245
|
+
type PaginateResult<Item, Options> = Options extends {
|
|
246
|
+
page: number;
|
|
247
|
+
} ? NumberedPage<Item> : CursorPage<Item, Options extends {
|
|
248
|
+
total: true;
|
|
249
|
+
} ? true : false>;
|
|
116
250
|
type Adjacent<Entry> = {
|
|
117
251
|
previous: Entry | null;
|
|
118
252
|
next: Entry | null;
|
|
@@ -149,7 +283,7 @@ type Where<Data> = { [Name in keyof Data]?: [Data[Name]] extends [Scalar] ? Data
|
|
|
149
283
|
};
|
|
150
284
|
type OrderBy<Data> = Partial<Record<SortKey<Data>, "asc" | "desc">>;
|
|
151
285
|
type ObjectScope<Registry extends CollectionRegistry, Name extends keyof Registry & string, Many extends boolean> = {
|
|
152
|
-
where?: Where<QueryData<Registry[Name]>> | ((fields:
|
|
286
|
+
where?: Where<QueryData<Registry[Name]>> | ((fields: QueryFields<Registry, Name>) => Expression);
|
|
153
287
|
} & (Many extends true ? {
|
|
154
288
|
orderBy?: OrderBy<QueryData<Registry[Name]>> | readonly OrderBy<QueryData<Registry[Name]>>[];
|
|
155
289
|
limit?: number;
|
|
@@ -160,20 +294,27 @@ type QueryOptions<Registry extends CollectionRegistry, Name extends keyof Regist
|
|
|
160
294
|
};
|
|
161
295
|
type AdjacentOptions<Registry extends CollectionRegistry, Name extends keyof Registry & string> = Omit<QueryOptions<Registry, Name, true, false>, "limit" | "offset">;
|
|
162
296
|
type Selection<Registry extends CollectionRegistry, Name extends keyof Registry & string, AllowAdjacent extends boolean = true> = { [Field in keyof QueryData<Registry[Name]>]?: boolean; } & { [Key in keyof RelationshipsOf<Registry[Name]>]?: QueryOptions<Registry, RelatedName$1<Registry, RelationOf<Registry, Name, Key>>, RelationOf<Registry, Name, Key>["type"] extends "many" ? true : false, AllowAdjacent> | false; } & (AllowAdjacent extends true ? {
|
|
163
|
-
_adjacent?:
|
|
297
|
+
_adjacent?: {
|
|
298
|
+
scope: "results";
|
|
299
|
+
select: Selection<Registry, Name, false>;
|
|
300
|
+
} | (AdjacentOptions<Registry, Name> & {
|
|
301
|
+
scope?: "collection";
|
|
302
|
+
});
|
|
164
303
|
} : {});
|
|
165
304
|
type ObjectRelationValue<Registry extends CollectionRegistry, Name extends keyof Registry & string, Key extends keyof RelationshipsOf<Registry[Name]>, Options> = Options extends {
|
|
166
305
|
select: infer Projection;
|
|
167
306
|
} ? RelationValue<Registry[Name], RelationOf<Registry, Name, Key>, QueryInfo<SelectionResult<Registry, RelatedName$1<Registry, RelationOf<Registry, Name, Key>>, Projection>, true, "where" extends keyof Options ? true : false>> : never;
|
|
168
|
-
type SelectionResult<Registry extends CollectionRegistry, Name extends keyof Registry & string, Projection> = { -readonly [Key in keyof Projection as Projection[Key] extends false | undefined ? never : Key]-?: Key extends "_adjacent" ? Projection[Key] extends
|
|
169
|
-
id: string;
|
|
170
|
-
}> : Projection[Key] extends {
|
|
307
|
+
type SelectionResult<Registry extends CollectionRegistry, Name extends keyof Registry & string, Projection> = { -readonly [Key in keyof Projection as Projection[Key] extends false | undefined ? never : Key]-?: Key extends "_adjacent" ? Projection[Key] extends {
|
|
171
308
|
select: infer Neighbors;
|
|
172
309
|
} ? Adjacent<SelectionResult<Registry, Name, Neighbors>> : never : Key extends keyof RelationshipsOf<Registry[Name]> ? ObjectRelationValue<Registry, Name, Key, Projection[Key]> : Key extends keyof QueryData<Registry[Name]> ? QueryData<Registry[Name]>[Key] : never; };
|
|
173
310
|
type CheckedField<Value, Filter> = Filter extends Scalar ? Filter : { [Operator in keyof Filter]: Operator extends keyof FieldFilter$1<Value> ? Operator extends "not" ? CheckedField<Value, Filter[Operator]> : Filter[Operator] : never; };
|
|
174
311
|
type CheckedWhereList$1<Data, Filters extends readonly unknown[]> = { [Index in keyof Filters]: CheckedWhere$1<Data, Filters[Index]>; };
|
|
175
312
|
type CheckedWhere$1<Data, Filter> = Filter extends ((...arguments_: never[]) => unknown) ? Filter : { [Key in keyof Filter]: Key extends "AND" | "OR" | "NOT" ? Filter[Key] extends readonly unknown[] ? CheckedWhereList$1<Data, Filter[Key]> : CheckedWhere$1<Data, Filter[Key]> : Key extends keyof Data ? CheckedField<Data[Key], Filter[Key]> : never; };
|
|
176
|
-
type CheckedSelection<Registry extends CollectionRegistry, Name extends keyof Registry & string, Projection, AllowAdjacent extends boolean> = { [Key in keyof Projection]: Key extends "_adjacent" ? AllowAdjacent extends true ? Projection[Key] extends
|
|
313
|
+
type CheckedSelection<Registry extends CollectionRegistry, Name extends keyof Registry & string, Projection, AllowAdjacent extends boolean> = { [Key in keyof Projection]: Key extends "_adjacent" ? AllowAdjacent extends true ? Projection[Key] extends {
|
|
314
|
+
scope: "results";
|
|
315
|
+
} ? { [Option in keyof Projection[Key]]: Option extends "scope" ? "results" : Option extends "select" ? CheckedSelection<Registry, Name, Projection[Key][Option], false> : never; } : CheckedOptions<Registry, Name, Omit<Projection[Key], "scope">, true, false, false> & {
|
|
316
|
+
scope?: "collection";
|
|
317
|
+
} : never : Key extends keyof RelationshipsOf<Registry[Name]> ? Projection[Key] extends false ? false : CheckedOptions<Registry, RelatedName$1<Registry, RelationOf<Registry, Name, Key>>, Projection[Key], RelationOf<Registry, Name, Key>["type"] extends "many" ? true : false, AllowAdjacent> : Key extends keyof QueryData<Registry[Name]> ? Projection[Key] : never; };
|
|
177
318
|
/** Rejects extra properties throughout inferred options, including recursive neighbor projections. */
|
|
178
319
|
type CheckedOptions<Registry extends CollectionRegistry, Name extends keyof Registry & string, Options, Many extends boolean = true, AllowAdjacent extends boolean = true, Pagination extends boolean = true> = { [Key in keyof Options]: Key extends "select" ? CheckedSelection<Registry, Name, Options[Key], AllowAdjacent> : Key extends "where" ? CheckedWhere$1<QueryData<Registry[Name]>, Options[Key]> : Key extends "limit" | "offset" ? Pagination extends true ? Many extends true ? Options[Key] : never : never : Key extends keyof ObjectScope<Registry, Name, Many> ? Options[Key] : never; };
|
|
179
320
|
//#endregion
|
|
@@ -221,36 +362,71 @@ type RelationalWhere<Registry extends CollectionRegistry, Name extends keyof Reg
|
|
|
221
362
|
NOT?: RelationalWhere<Registry, Name> | readonly RelationalWhere<Registry, Name>[];
|
|
222
363
|
RAW?: (fields: Fields<QueryData<Registry[Name]>>) => Expression;
|
|
223
364
|
};
|
|
365
|
+
/** Requests one payload: `true` without variants, or a record giving every variant key. */
|
|
366
|
+
type PayloadRequest<Variant> = keyof Variant extends never ? true : Readonly<Variant>;
|
|
224
367
|
/** Payloads to attach under `_payloads`; payloads set to false are omitted. */
|
|
225
|
-
type PayloadOptions<Registry extends CollectionRegistry, Name extends keyof Registry & string> = { [Key in keyof PayloadsOf<Registry[Name]>]?:
|
|
226
|
-
/**
|
|
368
|
+
type PayloadOptions<Registry extends CollectionRegistry, Name extends keyof Registry & string> = { [Key in keyof PayloadsOf<Registry[Name]>]?: false | PayloadRequest<VariantOf<Registry[Name], Key>>; };
|
|
369
|
+
/** Rejects variant keys a payload does not declare, including through inferred variables. */
|
|
370
|
+
type CheckedPayloadRequest<Request, Variant> = Request extends boolean ? Request : { [Key in keyof Request]: Key extends keyof Variant ? string : never; };
|
|
371
|
+
/**
|
|
372
|
+
* Collection-scoped metadata queries with Drizzle-style columns, relationships, and filters.
|
|
373
|
+
* Nothing is selected implicitly, not even `id`: list fields in `columns`, include relationships
|
|
374
|
+
* with nested options, request payloads, or select adjacency.
|
|
375
|
+
*/
|
|
227
376
|
type RelationalQueryOptions<Registry extends CollectionRegistry, Name extends keyof Registry & string, Many extends boolean = true, AllowAdjacent extends boolean = true, Pagination extends boolean = true> = {
|
|
228
|
-
|
|
377
|
+
/** Fields to include, each set to `true`. Omitted fields are never returned. */
|
|
378
|
+
columns?: Partial<Record<keyof QueryData<Registry[Name]>, true>>;
|
|
229
379
|
where?: RelationalWhere<Registry, Name>;
|
|
230
|
-
|
|
380
|
+
/** Related entries to include; each selects its own data. `false` omits a relationship. */
|
|
381
|
+
with?: { [Key in keyof RelationshipsOf<Registry[Name]>]?: false | RelationalQueryOptions<Registry, RelatedName<Registry, Name, Key>, IsMany<Registry, Name, Key>, AllowAdjacent>; };
|
|
231
382
|
} & (Many extends true ? {
|
|
232
383
|
orderBy?: OrderBy<QueryData<Registry[Name]>>;
|
|
233
384
|
} : {}) & (Many extends true ? (Pagination extends true ? {
|
|
234
385
|
limit?: number;
|
|
235
386
|
offset?: number;
|
|
236
387
|
} : {}) : {}) & (AllowAdjacent extends true ? {
|
|
237
|
-
|
|
388
|
+
/**
|
|
389
|
+
* Previous and next entries, which select their own data. `scope: "results"` finds
|
|
390
|
+
* neighbors within these results; other options describe an independent sibling scope.
|
|
391
|
+
*/
|
|
392
|
+
adjacent?: ({
|
|
393
|
+
scope: "results";
|
|
394
|
+
} & Pick<RelationalQueryOptions<Registry, Name, true, false, false>, "columns" | "with">) | ({
|
|
395
|
+
scope?: "collection";
|
|
396
|
+
} & RelationalQueryOptions<Registry, Name, true, false, false>);
|
|
238
397
|
payloads?: PayloadOptions<Registry, Name>;
|
|
239
398
|
} : {});
|
|
399
|
+
/** Options accepted by relational `paginate()`: query options without limit or offset, plus a page request. */
|
|
400
|
+
type RelationalPaginateOptions<Registry extends CollectionRegistry, Name extends keyof Registry & string> = RelationalQueryOptions<Registry, Name, true, true, false> & PaginateOptions;
|
|
240
401
|
/** Options accepted by the root count helper, whose result ignores sorting and pagination. */
|
|
241
402
|
type RelationalCountOptions<Registry extends CollectionRegistry, Name extends keyof Registry & string> = Pick<RelationalQueryOptions<Registry, Name>, "where" | "orderBy" | "offset" | "limit">;
|
|
242
403
|
type ColumnResult<Data, Options> = Options extends {
|
|
243
404
|
columns: infer Columns;
|
|
244
|
-
} ?
|
|
405
|
+
} ? { -readonly [Key in keyof Columns as Columns[Key] extends true ? Key : never]-?: Key extends keyof Data ? Data[Key] : never; } : {};
|
|
406
|
+
/** Keys whose option values request something, as opposed to `false` or `undefined`. */
|
|
407
|
+
type Requested<Map> = keyof { [Key in keyof Map as Map[Key] extends false | undefined ? never : Key]: unknown; };
|
|
408
|
+
/** Whether options select fields, include relationships, request payloads, or select adjacency. */
|
|
409
|
+
type SelectsData<Options> = (Options extends {
|
|
410
|
+
columns: infer Columns;
|
|
411
|
+
} ? Requested<Columns> : never) | (Options extends {
|
|
412
|
+
with: infer Related;
|
|
413
|
+
} ? Requested<Related> : never) | (Options extends {
|
|
414
|
+
payloads: infer Payloads;
|
|
415
|
+
} ? Requested<Payloads> : never) | (Options extends {
|
|
416
|
+
adjacent: infer Neighbors;
|
|
417
|
+
} ? Neighbors extends false | undefined ? never : "adjacent" : never) extends never ? false : true;
|
|
418
|
+
/**
|
|
419
|
+
* Requires a row-returning scope to request data. An unselected scope must supply an impossible
|
|
420
|
+
* property named after the rule, so the compiler error states it.
|
|
421
|
+
*/
|
|
422
|
+
type SelectionRequired<Options> = SelectsData<Options> extends true ? unknown : { [Rule in typeof NO_SELECTION_MESSAGE]: never; };
|
|
245
423
|
type IncludedResult<Registry extends CollectionRegistry, Name extends keyof Registry & string, Options> = Options extends {
|
|
246
424
|
with: infer Related;
|
|
247
|
-
} ? { -readonly [Key in keyof Related as Related[Key] extends false | undefined ? never : Key]-?: Key extends keyof RelationshipsOf<Registry[Name]> ? RelationshipResult<Registry[Name], RelationshipsOf<Registry[Name]>[Key] & Relationship, RelationalQueryResult<Registry, RelatedName<Registry, Name, Key>, Related[Key]
|
|
425
|
+
} ? { -readonly [Key in keyof Related as Related[Key] extends false | undefined ? never : Key]-?: Key extends keyof RelationshipsOf<Registry[Name]> ? RelationshipResult<Registry[Name], RelationshipsOf<Registry[Name]>[Key] & Relationship, RelationalQueryResult<Registry, RelatedName<Registry, Name, Key>, Related[Key]>, "where" extends keyof Related[Key] ? true : false> : never; } : {};
|
|
248
426
|
type AdjacentResult<Registry extends CollectionRegistry, Name extends keyof Registry & string, Options> = Options extends {
|
|
249
427
|
adjacent: infer Neighbors;
|
|
250
428
|
} ? {
|
|
251
|
-
_adjacent:
|
|
252
|
-
id: string;
|
|
253
|
-
}> : Adjacent<RelationalQueryResult<Registry, Name, Neighbors>>;
|
|
429
|
+
_adjacent: Adjacent<RelationalQueryResult<Registry, Name, Neighbors>>;
|
|
254
430
|
} : {};
|
|
255
431
|
type Simplify<Value> = { [Key in keyof Value]: Value[Key]; };
|
|
256
432
|
type RequestedPayloads<Payloads, Requested> = { -readonly [Key in keyof Requested as Requested[Key] extends false | undefined ? never : Key]-?: Key extends keyof Payloads ? Payloads[Key] : never; };
|
|
@@ -259,20 +435,35 @@ type PayloadResult<Registry extends CollectionRegistry, Name extends keyof Regis
|
|
|
259
435
|
} ? keyof RequestedPayloads<PayloadsOf<Registry[Name]>, Requested> extends never ? {} : {
|
|
260
436
|
_payloads: Simplify<RequestedPayloads<PayloadsOf<Registry[Name]>, Requested>>;
|
|
261
437
|
} : {};
|
|
262
|
-
/** Infers selected columns
|
|
438
|
+
/** Infers exactly the selected columns, relationships, adjacency, and payloads. */
|
|
263
439
|
type RelationalQueryResult<Registry extends CollectionRegistry, Name extends keyof Registry & string, Options> = Options extends unknown ? Simplify<ColumnResult<QueryData<Registry[Name]>, Options> & IncludedResult<Registry, Name, Options> & AdjacentResult<Registry, Name, Options> & PayloadResult<Registry, Name, Options>> : never;
|
|
264
440
|
type CheckedConditions<Value, Filters extends readonly unknown[]> = { [Index in keyof Filters]: CheckedCondition<Value, Filters[Index]>; };
|
|
265
441
|
type CheckedCondition<Value, Filter> = Filter extends Scalar ? Filter : { [Key in keyof Filter]: Key extends "AND" | "OR" ? Filter[Key] extends readonly unknown[] ? CheckedConditions<Value, Filter[Key]> : never : Key extends "NOT" ? CheckedCondition<Value, Filter[Key]> : Key extends keyof FieldFilter<Value> ? Filter[Key] : never; };
|
|
266
442
|
type CheckedWhereList<Registry extends CollectionRegistry, Name extends keyof Registry & string, Filters extends readonly unknown[]> = { [Index in keyof Filters]: CheckedWhere<Registry, Name, Filters[Index]>; };
|
|
267
|
-
type CheckedWhere<Registry extends CollectionRegistry, Name extends keyof Registry & string, Filter> = { [Key in keyof Filter]: Key extends "AND" | "OR" | "NOT" ? Filter[Key] extends readonly unknown[] ? CheckedWhereList<Registry, Name, Filter[Key]> : CheckedWhere<Registry, Name, Filter[Key]> : Key extends "RAW" ? Filter[Key] : Key extends keyof RelationshipsOf<Registry[Name]> ? Filter[Key] extends boolean ? Filter[Key] : CheckedWhere<Registry, RelatedName<Registry, Name, Key>, Filter[Key]> : Key extends keyof QueryData<Registry[Name]> ? CheckedCondition<QueryData<Registry[Name]>[Key], Filter[Key]> :
|
|
443
|
+
type CheckedWhere<Registry extends CollectionRegistry, Name extends keyof Registry & string, Filter> = { [Key in keyof Filter]: Key extends "AND" | "OR" | "NOT" ? Filter[Key] extends readonly unknown[] ? CheckedWhereList<Registry, Name, Filter[Key]> : CheckedWhere<Registry, Name, Filter[Key]> : Key extends "RAW" ? Filter[Key] : Key extends keyof RelationshipsOf<Registry[Name]> ? Filter[Key] extends boolean ? Filter[Key] : CheckedWhere<Registry, RelatedName<Registry, Name, Key>, Filter[Key]> : Key extends keyof QueryData<Registry[Name]> ? CheckedCondition<QueryData<Registry[Name]>[Key], Filter[Key]> : UnavailableRelationship<Registry[Name], Key>; };
|
|
268
444
|
/** Rejects unknown options recursively, including options supplied through inferred variables. */
|
|
269
|
-
type CheckedRelationalOptions<Registry extends CollectionRegistry, Name extends keyof Registry & string, Options, Many extends boolean = true, AllowAdjacent extends boolean = true, Pagination extends boolean = true> = { [Key in keyof Options]: Key extends "columns" ? { [Column in keyof Options[Key]]: Column extends keyof QueryData<Registry[Name]> ? Options[Key][Column] : never; } : Key extends "where" ? CheckedWhere<Registry, Name, Options[Key]> : Key extends "with" ? { [Related in keyof Options[Key]]: Related extends keyof RelationshipsOf<Registry[Name]> ? Options[Key][Related] extends
|
|
445
|
+
type CheckedRelationalOptions<Registry extends CollectionRegistry, Name extends keyof Registry & string, Options, Many extends boolean = true, AllowAdjacent extends boolean = true, Pagination extends boolean = true> = { [Key in keyof Options]: Key extends "columns" ? { [Column in keyof Options[Key]]: Column extends keyof QueryData<Registry[Name]> ? Options[Key][Column] : never; } : Key extends "where" ? CheckedWhere<Registry, Name, Options[Key]> : Key extends "with" ? { [Related in keyof Options[Key]]: Related extends keyof RelationshipsOf<Registry[Name]> ? Options[Key][Related] extends false | undefined ? Options[Key][Related] : CheckedRelationalOptions<Registry, RelatedName<Registry, Name, Related>, Options[Key][Related], IsMany<Registry, Name, Related>, AllowAdjacent> & SelectionRequired<Options[Key][Related]> : UnavailableRelationship<Registry[Name], Related>; } : Key extends "adjacent" ? AllowAdjacent extends true ? CheckedRelationalOptions<Registry, Name, Omit<Options[Key], "scope">, true, false, false> & SelectionRequired<Options[Key]> & (Options[Key] extends {
|
|
446
|
+
scope: "results";
|
|
447
|
+
} ? {
|
|
448
|
+
scope: "results";
|
|
449
|
+
where?: never;
|
|
450
|
+
orderBy?: never;
|
|
451
|
+
} : {
|
|
452
|
+
scope?: "collection";
|
|
453
|
+
}) : never : Key extends "payloads" ? AllowAdjacent extends true ? { [Payload in keyof Options[Key]]: Payload extends keyof PayloadsOf<Registry[Name]> ? CheckedPayloadRequest<Options[Key][Payload], VariantOf<Registry[Name], Payload>> : never; } : never : Key extends "orderBy" ? Key extends keyof RelationalQueryOptions<Registry, Name, Many, AllowAdjacent, Pagination> ? { [Field in keyof Options[Key]]: Field extends keyof OrderBy<QueryData<Registry[Name]>> ? Options[Key][Field] : never; } : never : Key extends keyof RelationalQueryOptions<Registry, Name, Many, AllowAdjacent, Pagination> ? Options[Key] : never; };
|
|
454
|
+
/** One collection's relational queries: `findMany`, `findFirst`, and `paginate`. */
|
|
455
|
+
type RelationalCollectionQueries<Registry extends CollectionRegistry, Name extends keyof Registry & string> = {
|
|
456
|
+
/** Returns matching rows with exactly the selected data. Options must select something. */
|
|
457
|
+
findMany<const Options extends RelationalQueryOptions<Registry, Name>>(options: Options & CheckedRelationalOptions<Registry, Name, NoInfer<Options>> & SelectionRequired<NoInfer<Options>>): Promise<RelationalQueryResult<Registry, Name, Options>[]>;
|
|
458
|
+
/** Returns the first matching row, or undefined when none matches. */
|
|
459
|
+
findFirst<const Options extends RelationalQueryOptions<Registry, Name>>(options: Options & CheckedRelationalOptions<Registry, Name, NoInfer<Options>> & SelectionRequired<NoInfer<Options>>): Promise<RelationalQueryResult<Registry, Name, Options> | undefined>;
|
|
460
|
+
/**
|
|
461
|
+
* Returns one page from one revision: `page` and `size` for page numbers, or `size` with
|
|
462
|
+
* `after`, `before`, or `total` for cursors. `limit` and `offset` are unavailable.
|
|
463
|
+
*/
|
|
464
|
+
paginate<const Options extends RelationalPaginateOptions<Registry, Name>>(options: Options & CheckedRelationalOptions<Registry, Name, NoInfer<Omit<Options, PaginateKey>>, true, true, false> & SelectionRequired<NoInfer<Options>>): Promise<PaginateResult<RelationalQueryResult<Registry, Name, Options>, Options>>;
|
|
465
|
+
};
|
|
270
466
|
/** Typed per-collection query entry points that never expose source configuration at runtime. */
|
|
271
|
-
type RelationalQueries<Registry extends CollectionRegistry> = string extends keyof Registry ? {} : { readonly [Name in keyof Registry & string]:
|
|
272
|
-
/** Returns matching metadata rows and requested relationships. */
|
|
273
|
-
findMany<const Options extends RelationalQueryOptions<Registry, Name> = {}>(options?: Options & CheckedRelationalOptions<Registry, Name, NoInfer<Options>>): Promise<RelationalQueryResult<Registry, Name, Options>[]>;
|
|
274
|
-
/** Returns the first matching entry, or undefined when none matches. */
|
|
275
|
-
findFirst<const Options extends RelationalQueryOptions<Registry, Name> = {}>(options?: Options & CheckedRelationalOptions<Registry, Name, NoInfer<Options>>): Promise<RelationalQueryResult<Registry, Name, Options> | undefined>;
|
|
276
|
-
}; };
|
|
467
|
+
type RelationalQueries<Registry extends CollectionRegistry> = string extends keyof Registry ? {} : { readonly [Name in keyof Registry & string]: RelationalCollectionQueries<Registry, Name>; };
|
|
277
468
|
//#endregion
|
|
278
|
-
export { QueryPlan as _,
|
|
469
|
+
export { Selection as C, QueryPlan as D, Expression as E, QueryRegistry as O, ScalarField as S, Where as T, PaginateResult as _, RelationalQueryOptions as a, RelationField as b, Adjacent as c, Field$1 as d, Fields as f, PaginateOptions as g, PageOptions as h, RelationalQueries as i, QueryTerminal as k, CursorOptions as l, Ordered as m, RelationalCountOptions as n, RelationalQueryResult as o, NumberedPage as p, RelationalPaginateOptions as r, RelationalWhere as s, RelationalCollectionQueries as t, CursorPage as u, Query as v, SelectionResult as w, Scalar as x, QueryFields as y };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { s as ContentError } from "./collection-types-CsQtGw7_.mjs";
|
|
2
|
+
import { n as ContentRenderResult } from "./types-Dh-Sydyw.mjs";
|
|
3
|
+
import { _ as Relationship } from "./types-Dz1vTXa2.mjs";
|
|
4
|
+
import { D as QueryPlan, O as QueryRegistry, k as QueryTerminal } from "./relational-types-CTcalUNW.mjs";
|
|
5
|
+
import { n as QueryStyle } from "./query-style-C2FcT1f9.mjs";
|
|
6
|
+
//#region src/runtime/revision.d.ts
|
|
7
|
+
type QueryRecord = Record<string, unknown> & {
|
|
8
|
+
id: string;
|
|
9
|
+
};
|
|
10
|
+
/** Custom payload loaders by payload name, entry ID, and canonical variant key. */
|
|
11
|
+
type CustomPayloadTable = ReadonlyMap<string, ReadonlyMap<string, ReadonlyMap<string, () => Promise<unknown>>>>;
|
|
12
|
+
/** The built-in side payload shared by an entry's `_body` and `_rendered` payloads. */
|
|
13
|
+
type BuiltinPayload = {
|
|
14
|
+
body?: string;
|
|
15
|
+
rendered?: ContentRenderResult;
|
|
16
|
+
markdown?: string;
|
|
17
|
+
};
|
|
18
|
+
type PreparedCollection = {
|
|
19
|
+
records: readonly QueryRecord[];
|
|
20
|
+
relationships: Record<string, Relationship>;
|
|
21
|
+
/** Lazy built-in payloads, present only for entries with a body or rendered output. */
|
|
22
|
+
builtins: ReadonlyMap<string, () => Promise<BuiltinPayload>>;
|
|
23
|
+
/**
|
|
24
|
+
* Lazy custom payloads by payload name, entry ID, and canonical variant key. A missing variant
|
|
25
|
+
* key means the entry has no such combination.
|
|
26
|
+
*/
|
|
27
|
+
payloads?: CustomPayloadTable;
|
|
28
|
+
sources?: ReadonlyMap<string, string | undefined>;
|
|
29
|
+
};
|
|
30
|
+
type PreparedRevision = {
|
|
31
|
+
registry: QueryRegistry;
|
|
32
|
+
collections: Record<string, PreparedCollection>;
|
|
33
|
+
relations: Map<string, Map<string, readonly QueryRecord[]>>;
|
|
34
|
+
active: number;
|
|
35
|
+
/** Built-in payloads keyed by collection and ID; custom payloads also by name and variant. */
|
|
36
|
+
payloadCache: Map<string, Promise<unknown>>;
|
|
37
|
+
renderCache: Map<string, Promise<ContentRenderResult>>;
|
|
38
|
+
renderMarkdown?: (body: string) => Promise<ContentRenderResult>;
|
|
39
|
+
/** The only query style this revision's configuration allows; absent allows both. */
|
|
40
|
+
queryStyle?: QueryStyle;
|
|
41
|
+
execute?: (plan: QueryPlan, terminal: QueryTerminal, requests: PayloadRequest[]) => Promise<unknown>;
|
|
42
|
+
};
|
|
43
|
+
/** A projected row awaiting the payloads its query scope requested. */
|
|
44
|
+
type PayloadRequest = {
|
|
45
|
+
target: Record<string, unknown>;
|
|
46
|
+
collection: string;
|
|
47
|
+
id: string;
|
|
48
|
+
payloads: NonNullable<QueryPlan["payloads"]>;
|
|
49
|
+
};
|
|
50
|
+
type ContentState = {
|
|
51
|
+
revision?: PreparedRevision;
|
|
52
|
+
registry?: QueryRegistry;
|
|
53
|
+
error?: ContentError;
|
|
54
|
+
};
|
|
55
|
+
//#endregion
|
|
56
|
+
export { PreparedRevision as n, ContentState as t };
|
package/dist/runtime.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as ContentErrorCode, i as LoadedRegistry, n as Collection, o as ContentDiagnostic, r as CollectionHandles, s as ContentError, t as AnyCollection } from "./collection-types-CsQtGw7_.mjs";
|
|
2
2
|
import { n as ContentRenderResult, t as ContentHeading } from "./types-Dh-Sydyw.mjs";
|
|
3
|
-
|
|
3
|
+
import { n as QueryStyle, r as QueryStyleDisabled } from "./query-style-C2FcT1f9.mjs";
|
|
4
|
+
export { type AnyCollection, type Collection, type CollectionHandles, type ContentDiagnostic, ContentError, type ContentErrorCode, type ContentHeading, type ContentRenderResult, type LoadedRegistry, type QueryStyle, type QueryStyleDisabled };
|
package/dist/runtime.mjs
CHANGED