@wix/wix-data-items-sdk 1.0.543 → 1.0.544
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.
|
@@ -23,15 +23,22 @@ type NoInfer<T> = [T][T extends any ? 0 : never];
|
|
|
23
23
|
* }
|
|
24
24
|
* ```
|
|
25
25
|
*
|
|
26
|
-
* `item` and `insert` are required. `
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* `
|
|
26
|
+
* `item` and `insert` are required. `item` is both the read shape and the
|
|
27
|
+
* authoritative field list: it drives `distinct`'s `fieldName` parameter — the
|
|
28
|
+
* one place a field name is checked strictly, dotted paths included — and the
|
|
29
|
+
* type of the values it returns. Reference fields belong on it too, typed as
|
|
30
|
+
* either an id or the resolved item (`owner?: string | OwnerItem` when single),
|
|
31
|
+
* and `refs` is what tells `distinct` they are references: it reports their
|
|
32
|
+
* `_id`s, so their value type is `string` rather than that union.
|
|
33
|
+
*
|
|
34
|
+
* `refs` is OPTIONAL: it maps each reference and multi-reference field to the id
|
|
35
|
+
* of the collection that field points at (the schema's `referencedCollection`),
|
|
36
|
+
* and drives the reference APIs — `queryReferencedItems` returns that
|
|
37
|
+
* collection's item type, and the mutation methods type their `referencedItem`
|
|
38
|
+
* argument with it. Codegen omits `refs` for collections with no reference
|
|
39
|
+
* fields, and entries written before `refs` existed keep working unchanged. A
|
|
40
|
+
* `refs` target need not itself be registered (`'service-manuals'` above isn't)
|
|
41
|
+
* — those resolve to the open `WixDataItem`.
|
|
35
42
|
*
|
|
36
43
|
* `refs` has no runtime counterpart. Nothing validates it against the live
|
|
37
44
|
* schema, so a stale hand-written entry silently yields a wrong item type.
|
|
@@ -88,6 +95,99 @@ export type ReferenceFieldOf<C> = Extract<keyof RefsOf<C>, string>;
|
|
|
88
95
|
* string is still allowed. Same shape and rationale as `CollectionId`.
|
|
89
96
|
*/
|
|
90
97
|
type ReferenceFieldName<C> = [ReferenceFieldOf<C>] extends [never] ? string : ReferenceFieldOf<C> | (string & {});
|
|
98
|
+
/** Element type of an array field; every other field type is left alone. */
|
|
99
|
+
type ElementOf<T> = T extends readonly (infer E)[] ? NonNullable<E> : T;
|
|
100
|
+
/**
|
|
101
|
+
* What one path segment resolves to: array fields collapse to their element
|
|
102
|
+
* type and `null`/`undefined` are stripped, so `tags?: string[]` reads as
|
|
103
|
+
* `string`.
|
|
104
|
+
*
|
|
105
|
+
* ASSUMPTION: the service returns the *elements* of an array field rather than
|
|
106
|
+
* the arrays themselves, and never a null distinct value. Neither is expressed
|
|
107
|
+
* anywhere in this repo — the wire type is `distinctValues?: any[]`.
|
|
108
|
+
*/
|
|
109
|
+
type FieldType<T> = ElementOf<NonNullable<T>>;
|
|
110
|
+
/**
|
|
111
|
+
* Whether a dot-path may descend into `T`. Objects yes, with three exceptions
|
|
112
|
+
* that would otherwise expose their methods as field paths: arrays (already
|
|
113
|
+
* unwrapped one level by `FieldType`, so this only rejects nested arrays),
|
|
114
|
+
* `Date`, and functions.
|
|
115
|
+
*/
|
|
116
|
+
type Descendable<T> = T extends readonly any[] ? false : T extends Date ? false : T extends (...args: any[]) => any ? false : T extends object ? true : false;
|
|
117
|
+
/**
|
|
118
|
+
* Nesting budget for `FieldPath`: one element per level beyond the first, so
|
|
119
|
+
* this admits up to four segments (`owner.address.geo.lat`).
|
|
120
|
+
*
|
|
121
|
+
* Named rather than inlined so the constraint reads as
|
|
122
|
+
* `FieldPath<MotoFleetItem, PathDepth>` in the compiler's error message for a
|
|
123
|
+
* rejected field name, instead of a bare tuple of `unknown`s.
|
|
124
|
+
*/
|
|
125
|
+
type PathDepth = [unknown, unknown, unknown];
|
|
126
|
+
/**
|
|
127
|
+
* Field names of `T` plus every dotted path into it that the shape allows.
|
|
128
|
+
*
|
|
129
|
+
* `NoDescend` names fields that are valid on their own but may not be descended
|
|
130
|
+
* into. Only the top level passes anything here — the reference fields, since
|
|
131
|
+
* `distinct` does not support nesting through them. Nested objects aren't
|
|
132
|
+
* collections, so they have no reference fields of their own.
|
|
133
|
+
*
|
|
134
|
+
* The `Depth` bound keeps deeply or circularly nested plain objects from
|
|
135
|
+
* recursing forever.
|
|
136
|
+
*/
|
|
137
|
+
type FieldPath<T, NoDescend extends string = never, Depth extends readonly unknown[] = PathDepth> = Extract<keyof T, string> | (Depth extends readonly [unknown, ...infer Rest] ? {
|
|
138
|
+
[K in Exclude<Extract<keyof T, string>, NoDescend>]: Descendable<FieldType<T[K]>> extends true ? `${K}.${FieldPath<FieldType<T[K]>, never, Rest>}` : never;
|
|
139
|
+
}[Exclude<Extract<keyof T, string>, NoDescend>] : never);
|
|
140
|
+
/**
|
|
141
|
+
* Field names — and dotted paths — accepted for a collection.
|
|
142
|
+
*
|
|
143
|
+
* STRICT, unlike `CollectionId` and `ReferenceFieldName`: there is no
|
|
144
|
+
* `| (string & {})` alternative, so a name the registered `item` type doesn't
|
|
145
|
+
* have is a compile error, and so is a widened `string` variable. Dot-paths are
|
|
146
|
+
* allowed where the shape permits descending — `'address.city'` resolves, while
|
|
147
|
+
* `'category.foo'` (a string field) and `'_createdDate.getTime'` (a `Date`) do
|
|
148
|
+
* not — with one carve-out: reference and multi-reference fields are valid on
|
|
149
|
+
* their own but cannot be nested through, because `distinct` doesn't support it.
|
|
150
|
+
* A registry left stale by a schema change therefore breaks the build instead of
|
|
151
|
+
* silently yielding a wrong type; pass an explicit `<any>` type argument to opt
|
|
152
|
+
* out.
|
|
153
|
+
*
|
|
154
|
+
* `string` for an unregistered collection, and for every collection while the
|
|
155
|
+
* registry is empty, so untyped projects keep passing arbitrary field names.
|
|
156
|
+
*
|
|
157
|
+
* An `item` type carrying an index signature degrades to plain `string` rather
|
|
158
|
+
* than erroring — such collections keep their pre-registry behavior.
|
|
159
|
+
*
|
|
160
|
+
* Being a *conditional* type is also what keeps literal inference alive at the
|
|
161
|
+
* call site: the checker unwraps a conditional constraint into the union of its
|
|
162
|
+
* branches, sees `string`, and therefore does not widen `'category'` to
|
|
163
|
+
* `string` — exactly how `F extends ReferenceFieldName<C>` behaves below.
|
|
164
|
+
*/
|
|
165
|
+
export type FieldOf<C> = [C] extends [never] ? string : C extends RegisteredCollections ? FieldPath<WixDataCollectionRegistry[C]['item'], ReferenceFieldOf<C>> : string;
|
|
166
|
+
/**
|
|
167
|
+
* Value type at field — or dotted path — `F` of collection `C`, as `distinct`
|
|
168
|
+
* reports it.
|
|
169
|
+
*
|
|
170
|
+
* A reference or multi-reference field always yields `string`: the service
|
|
171
|
+
* returns the `_id`s of the referenced items, never the items themselves. That
|
|
172
|
+
* is why `refs` is consulted here rather than the `item` field type — codegen
|
|
173
|
+
* types a single reference as `string | Item` (either an id or a resolved item),
|
|
174
|
+
* which is the read shape, not what `distinct` hands back.
|
|
175
|
+
*
|
|
176
|
+
* `any` in every "don't know" case: unregistered collection, unknown field, a
|
|
177
|
+
* path that runs past the end of the shape, or an `item` type with an index
|
|
178
|
+
* signature.
|
|
179
|
+
*
|
|
180
|
+
* A collection whose registry entry omits the optional `refs` key falls through
|
|
181
|
+
* to the `item` field type, so its reference fields resolve to the wider
|
|
182
|
+
* `string | Item` instead of `string`. Nothing else can distinguish a reference
|
|
183
|
+
* field from a union-typed plain one.
|
|
184
|
+
*
|
|
185
|
+
* Unlike `RefsOf`, this is safe to export: `NonNullable<string>` resolves to
|
|
186
|
+
* plain `string`, so the `& {}` artifact described above never appears here —
|
|
187
|
+
* that only sticks on deferred indexed accesses.
|
|
188
|
+
*/
|
|
189
|
+
export type FieldValueOf<C, F> = C extends RegisteredCollections ? F extends ReferenceFieldOf<C> ? string : ValueAtPath<WixDataCollectionRegistry[C]['item'], F> : any;
|
|
190
|
+
type ValueAtPath<T, P> = P extends `${infer Head}.${infer Rest}` ? Head extends keyof T ? ValueAtPath<FieldType<T[Head]>, Rest> : any : P extends keyof T ? FieldType<T[P]> : any;
|
|
91
191
|
/**
|
|
92
192
|
* Id of the collection that field `F` of collection `C` points at, or `never`
|
|
93
193
|
* when the registry doesn't say.
|
|
@@ -131,6 +231,8 @@ type ResultOf<C, Explicit> = [Explicit] extends [never] ? ItemOf<C> : Explicit &
|
|
|
131
231
|
* `WixDataQueryReferencedItemsResponse<Product>`, and that stays true.
|
|
132
232
|
*/
|
|
133
233
|
type ReferencedResultOf<C, F, Explicit> = [Explicit] extends [never] ? ReferencedItemOf<C, F> : Explicit;
|
|
234
|
+
/** Same `Explicit`-wins rule as `ResultOf`, over a field value instead of an item. */
|
|
235
|
+
type DistinctValueOf<C, F, Explicit> = [Explicit] extends [never] ? FieldValueOf<C, F> : Explicit;
|
|
134
236
|
/**
|
|
135
237
|
* Item shapes accepted by the reference APIs. Strict for a registered
|
|
136
238
|
* collection, and otherwise `WithId` — which is exactly the constraint these
|
|
@@ -222,6 +324,8 @@ type AggregateGeneric = {
|
|
|
222
324
|
(dataCollectionId: string): WixDataAggregate;
|
|
223
325
|
<Result = Record<string, any>>(dataCollectionId: string, pipeline: AggregationPipeline, options?: WixDataAggregateOptions): Promise<WixDataAggregateResponse<Result>>;
|
|
224
326
|
};
|
|
327
|
+
type DistinctSignature = <Value = never, C extends CollectionId = CollectionId, F extends FieldOf<C> = FieldOf<C>>(dataCollectionId: C, fieldName: F, options?: WixDataDistinctOptions) => Promise<WixDataDistinctResponse<DistinctValueOf<C, F, Value>>>;
|
|
328
|
+
type DistinctGeneric = DistinctSignature & ((httpClient: HttpClient) => DistinctSignature);
|
|
225
329
|
type PatchResultOf<C, Explicit> = ([Explicit] extends [never] ? ItemOf<C> : Explicit) | null;
|
|
226
330
|
type PatchRequestSignature = <Item = never, C extends CollectionId = CollectionId>(dataCollectionId: C, itemId: string, fieldModifications: FieldModification[], options?: WixDataPatchOptions) => Promise<PatchResultOf<C, Item>>;
|
|
227
331
|
type PatchBuilderSignature = (dataCollectionId: string, itemId: string) => WixDataPatch;
|
|
@@ -269,10 +373,6 @@ export declare const asyncRemoveByFilter: MaybeContext<BuildRESTFunction<typeof
|
|
|
269
373
|
export declare const getAsyncJobStatus: MaybeContext<BuildRESTFunction<typeof publicGetAsyncJobStatus> & GetAsyncJobStatusGeneric>;
|
|
270
374
|
export declare const aggregate: MaybeContext<BuildRESTFunction<typeof publicAggregate> & AggregateGeneric>;
|
|
271
375
|
export declare const aggregatePipeline: MaybeContext<BuildRESTFunction<typeof publicAggregatePipeline> & typeof publicAggregatePipeline>;
|
|
272
|
-
type DistinctGeneric = {
|
|
273
|
-
(httpClient: HttpClient): (dataCollectionId: string, fieldName: string, options?: WixDataDistinctOptions) => Promise<WixDataDistinctResponse>;
|
|
274
|
-
(dataCollectionId: string, fieldName: string, options?: WixDataDistinctOptions): Promise<WixDataDistinctResponse>;
|
|
275
|
-
};
|
|
276
376
|
export declare const distinct: MaybeContext<BuildRESTFunction<typeof publicDistinct> & DistinctGeneric>;
|
|
277
377
|
export declare const count: MaybeContext<BuildRESTFunction<typeof publicCount> & typeof publicCount>;
|
|
278
378
|
export declare const queryReferenced: MaybeContext<BuildRESTFunction<typeof publicQueryReferenced> & typeof publicQueryReferenced>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-v2-data-item-items.context.js","sourceRoot":"","sources":["../../../src/data-v2-data-item-items.context.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,qFAiCyC;AAEzC,gEAAgE;AAChE,wFAA6E;
|
|
1
|
+
{"version":3,"file":"data-v2-data-item-items.context.js","sourceRoot":"","sources":["../../../src/data-v2-data-item-items.context.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,qFAiCyC;AAEzC,gEAAgE;AAChE,wFAA6E;AAwsBhE,QAAA,MAAM,GAED,IAAA,+BAAgB,EAAC,uCAAY,CAE9C,CAAA;AAEY,QAAA,MAAM,GAED,IAAA,+BAAgB,EAAC,uCAAY,CAE9C,CAAA;AAEY,QAAA,IAAI,GAEC,IAAA,+BAAgB,EAAC,qCAAU,CAE5C,CAAA;A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B,+IAAA,0BAA0B,OAAA;AAC1B,yIAAA,oBAAoB,OAAA;AACpB,yIAAA,oBAAoB,OAAA;AACpB,6IAAA,wBAAwB,OAAA;AACxB,6IAAA,wBAAwB,OAAA;AACxB,wIAAA,mBAAmB,OAAA;AACnB,4IAAA,uBAAuB,OAAA;AACvB,6IAAA,wBAAwB,OAAA;AACxB,yIAAA,oBAAoB,OAAA;AACpB,sJAAA,iCAAiC,OAAA;AACjC,qJAAA,gCAAgC,OAAA;AAChC,2HAAA,MAAM,OAAA;AACN,yHAAA,IAAI,OAAA;AAEJ,kIAAA,aAAa,OAAA;AACb,iIAAA,YAAY,OAAA;AAyBd,kEAA+C"}
|
|
@@ -23,15 +23,22 @@ type NoInfer<T> = [T][T extends any ? 0 : never];
|
|
|
23
23
|
* }
|
|
24
24
|
* ```
|
|
25
25
|
*
|
|
26
|
-
* `item` and `insert` are required. `
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* `
|
|
26
|
+
* `item` and `insert` are required. `item` is both the read shape and the
|
|
27
|
+
* authoritative field list: it drives `distinct`'s `fieldName` parameter — the
|
|
28
|
+
* one place a field name is checked strictly, dotted paths included — and the
|
|
29
|
+
* type of the values it returns. Reference fields belong on it too, typed as
|
|
30
|
+
* either an id or the resolved item (`owner?: string | OwnerItem` when single),
|
|
31
|
+
* and `refs` is what tells `distinct` they are references: it reports their
|
|
32
|
+
* `_id`s, so their value type is `string` rather than that union.
|
|
33
|
+
*
|
|
34
|
+
* `refs` is OPTIONAL: it maps each reference and multi-reference field to the id
|
|
35
|
+
* of the collection that field points at (the schema's `referencedCollection`),
|
|
36
|
+
* and drives the reference APIs — `queryReferencedItems` returns that
|
|
37
|
+
* collection's item type, and the mutation methods type their `referencedItem`
|
|
38
|
+
* argument with it. Codegen omits `refs` for collections with no reference
|
|
39
|
+
* fields, and entries written before `refs` existed keep working unchanged. A
|
|
40
|
+
* `refs` target need not itself be registered (`'service-manuals'` above isn't)
|
|
41
|
+
* — those resolve to the open `WixDataItem`.
|
|
35
42
|
*
|
|
36
43
|
* `refs` has no runtime counterpart. Nothing validates it against the live
|
|
37
44
|
* schema, so a stale hand-written entry silently yields a wrong item type.
|
|
@@ -88,6 +95,99 @@ export type ReferenceFieldOf<C> = Extract<keyof RefsOf<C>, string>;
|
|
|
88
95
|
* string is still allowed. Same shape and rationale as `CollectionId`.
|
|
89
96
|
*/
|
|
90
97
|
type ReferenceFieldName<C> = [ReferenceFieldOf<C>] extends [never] ? string : ReferenceFieldOf<C> | (string & {});
|
|
98
|
+
/** Element type of an array field; every other field type is left alone. */
|
|
99
|
+
type ElementOf<T> = T extends readonly (infer E)[] ? NonNullable<E> : T;
|
|
100
|
+
/**
|
|
101
|
+
* What one path segment resolves to: array fields collapse to their element
|
|
102
|
+
* type and `null`/`undefined` are stripped, so `tags?: string[]` reads as
|
|
103
|
+
* `string`.
|
|
104
|
+
*
|
|
105
|
+
* ASSUMPTION: the service returns the *elements* of an array field rather than
|
|
106
|
+
* the arrays themselves, and never a null distinct value. Neither is expressed
|
|
107
|
+
* anywhere in this repo — the wire type is `distinctValues?: any[]`.
|
|
108
|
+
*/
|
|
109
|
+
type FieldType<T> = ElementOf<NonNullable<T>>;
|
|
110
|
+
/**
|
|
111
|
+
* Whether a dot-path may descend into `T`. Objects yes, with three exceptions
|
|
112
|
+
* that would otherwise expose their methods as field paths: arrays (already
|
|
113
|
+
* unwrapped one level by `FieldType`, so this only rejects nested arrays),
|
|
114
|
+
* `Date`, and functions.
|
|
115
|
+
*/
|
|
116
|
+
type Descendable<T> = T extends readonly any[] ? false : T extends Date ? false : T extends (...args: any[]) => any ? false : T extends object ? true : false;
|
|
117
|
+
/**
|
|
118
|
+
* Nesting budget for `FieldPath`: one element per level beyond the first, so
|
|
119
|
+
* this admits up to four segments (`owner.address.geo.lat`).
|
|
120
|
+
*
|
|
121
|
+
* Named rather than inlined so the constraint reads as
|
|
122
|
+
* `FieldPath<MotoFleetItem, PathDepth>` in the compiler's error message for a
|
|
123
|
+
* rejected field name, instead of a bare tuple of `unknown`s.
|
|
124
|
+
*/
|
|
125
|
+
type PathDepth = [unknown, unknown, unknown];
|
|
126
|
+
/**
|
|
127
|
+
* Field names of `T` plus every dotted path into it that the shape allows.
|
|
128
|
+
*
|
|
129
|
+
* `NoDescend` names fields that are valid on their own but may not be descended
|
|
130
|
+
* into. Only the top level passes anything here — the reference fields, since
|
|
131
|
+
* `distinct` does not support nesting through them. Nested objects aren't
|
|
132
|
+
* collections, so they have no reference fields of their own.
|
|
133
|
+
*
|
|
134
|
+
* The `Depth` bound keeps deeply or circularly nested plain objects from
|
|
135
|
+
* recursing forever.
|
|
136
|
+
*/
|
|
137
|
+
type FieldPath<T, NoDescend extends string = never, Depth extends readonly unknown[] = PathDepth> = Extract<keyof T, string> | (Depth extends readonly [unknown, ...infer Rest] ? {
|
|
138
|
+
[K in Exclude<Extract<keyof T, string>, NoDescend>]: Descendable<FieldType<T[K]>> extends true ? `${K}.${FieldPath<FieldType<T[K]>, never, Rest>}` : never;
|
|
139
|
+
}[Exclude<Extract<keyof T, string>, NoDescend>] : never);
|
|
140
|
+
/**
|
|
141
|
+
* Field names — and dotted paths — accepted for a collection.
|
|
142
|
+
*
|
|
143
|
+
* STRICT, unlike `CollectionId` and `ReferenceFieldName`: there is no
|
|
144
|
+
* `| (string & {})` alternative, so a name the registered `item` type doesn't
|
|
145
|
+
* have is a compile error, and so is a widened `string` variable. Dot-paths are
|
|
146
|
+
* allowed where the shape permits descending — `'address.city'` resolves, while
|
|
147
|
+
* `'category.foo'` (a string field) and `'_createdDate.getTime'` (a `Date`) do
|
|
148
|
+
* not — with one carve-out: reference and multi-reference fields are valid on
|
|
149
|
+
* their own but cannot be nested through, because `distinct` doesn't support it.
|
|
150
|
+
* A registry left stale by a schema change therefore breaks the build instead of
|
|
151
|
+
* silently yielding a wrong type; pass an explicit `<any>` type argument to opt
|
|
152
|
+
* out.
|
|
153
|
+
*
|
|
154
|
+
* `string` for an unregistered collection, and for every collection while the
|
|
155
|
+
* registry is empty, so untyped projects keep passing arbitrary field names.
|
|
156
|
+
*
|
|
157
|
+
* An `item` type carrying an index signature degrades to plain `string` rather
|
|
158
|
+
* than erroring — such collections keep their pre-registry behavior.
|
|
159
|
+
*
|
|
160
|
+
* Being a *conditional* type is also what keeps literal inference alive at the
|
|
161
|
+
* call site: the checker unwraps a conditional constraint into the union of its
|
|
162
|
+
* branches, sees `string`, and therefore does not widen `'category'` to
|
|
163
|
+
* `string` — exactly how `F extends ReferenceFieldName<C>` behaves below.
|
|
164
|
+
*/
|
|
165
|
+
export type FieldOf<C> = [C] extends [never] ? string : C extends RegisteredCollections ? FieldPath<WixDataCollectionRegistry[C]['item'], ReferenceFieldOf<C>> : string;
|
|
166
|
+
/**
|
|
167
|
+
* Value type at field — or dotted path — `F` of collection `C`, as `distinct`
|
|
168
|
+
* reports it.
|
|
169
|
+
*
|
|
170
|
+
* A reference or multi-reference field always yields `string`: the service
|
|
171
|
+
* returns the `_id`s of the referenced items, never the items themselves. That
|
|
172
|
+
* is why `refs` is consulted here rather than the `item` field type — codegen
|
|
173
|
+
* types a single reference as `string | Item` (either an id or a resolved item),
|
|
174
|
+
* which is the read shape, not what `distinct` hands back.
|
|
175
|
+
*
|
|
176
|
+
* `any` in every "don't know" case: unregistered collection, unknown field, a
|
|
177
|
+
* path that runs past the end of the shape, or an `item` type with an index
|
|
178
|
+
* signature.
|
|
179
|
+
*
|
|
180
|
+
* A collection whose registry entry omits the optional `refs` key falls through
|
|
181
|
+
* to the `item` field type, so its reference fields resolve to the wider
|
|
182
|
+
* `string | Item` instead of `string`. Nothing else can distinguish a reference
|
|
183
|
+
* field from a union-typed plain one.
|
|
184
|
+
*
|
|
185
|
+
* Unlike `RefsOf`, this is safe to export: `NonNullable<string>` resolves to
|
|
186
|
+
* plain `string`, so the `& {}` artifact described above never appears here —
|
|
187
|
+
* that only sticks on deferred indexed accesses.
|
|
188
|
+
*/
|
|
189
|
+
export type FieldValueOf<C, F> = C extends RegisteredCollections ? F extends ReferenceFieldOf<C> ? string : ValueAtPath<WixDataCollectionRegistry[C]['item'], F> : any;
|
|
190
|
+
type ValueAtPath<T, P> = P extends `${infer Head}.${infer Rest}` ? Head extends keyof T ? ValueAtPath<FieldType<T[Head]>, Rest> : any : P extends keyof T ? FieldType<T[P]> : any;
|
|
91
191
|
/**
|
|
92
192
|
* Id of the collection that field `F` of collection `C` points at, or `never`
|
|
93
193
|
* when the registry doesn't say.
|
|
@@ -131,6 +231,8 @@ type ResultOf<C, Explicit> = [Explicit] extends [never] ? ItemOf<C> : Explicit &
|
|
|
131
231
|
* `WixDataQueryReferencedItemsResponse<Product>`, and that stays true.
|
|
132
232
|
*/
|
|
133
233
|
type ReferencedResultOf<C, F, Explicit> = [Explicit] extends [never] ? ReferencedItemOf<C, F> : Explicit;
|
|
234
|
+
/** Same `Explicit`-wins rule as `ResultOf`, over a field value instead of an item. */
|
|
235
|
+
type DistinctValueOf<C, F, Explicit> = [Explicit] extends [never] ? FieldValueOf<C, F> : Explicit;
|
|
134
236
|
/**
|
|
135
237
|
* Item shapes accepted by the reference APIs. Strict for a registered
|
|
136
238
|
* collection, and otherwise `WithId` — which is exactly the constraint these
|
|
@@ -222,6 +324,8 @@ type AggregateGeneric = {
|
|
|
222
324
|
(dataCollectionId: string): WixDataAggregate;
|
|
223
325
|
<Result = Record<string, any>>(dataCollectionId: string, pipeline: AggregationPipeline, options?: WixDataAggregateOptions): Promise<WixDataAggregateResponse<Result>>;
|
|
224
326
|
};
|
|
327
|
+
type DistinctSignature = <Value = never, C extends CollectionId = CollectionId, F extends FieldOf<C> = FieldOf<C>>(dataCollectionId: C, fieldName: F, options?: WixDataDistinctOptions) => Promise<WixDataDistinctResponse<DistinctValueOf<C, F, Value>>>;
|
|
328
|
+
type DistinctGeneric = DistinctSignature & ((httpClient: HttpClient) => DistinctSignature);
|
|
225
329
|
type PatchResultOf<C, Explicit> = ([Explicit] extends [never] ? ItemOf<C> : Explicit) | null;
|
|
226
330
|
type PatchRequestSignature = <Item = never, C extends CollectionId = CollectionId>(dataCollectionId: C, itemId: string, fieldModifications: FieldModification[], options?: WixDataPatchOptions) => Promise<PatchResultOf<C, Item>>;
|
|
227
331
|
type PatchBuilderSignature = (dataCollectionId: string, itemId: string) => WixDataPatch;
|
|
@@ -269,10 +373,6 @@ export declare const asyncRemoveByFilter: MaybeContext<BuildRESTFunction<typeof
|
|
|
269
373
|
export declare const getAsyncJobStatus: MaybeContext<BuildRESTFunction<typeof publicGetAsyncJobStatus> & GetAsyncJobStatusGeneric>;
|
|
270
374
|
export declare const aggregate: MaybeContext<BuildRESTFunction<typeof publicAggregate> & AggregateGeneric>;
|
|
271
375
|
export declare const aggregatePipeline: MaybeContext<BuildRESTFunction<typeof publicAggregatePipeline> & typeof publicAggregatePipeline>;
|
|
272
|
-
type DistinctGeneric = {
|
|
273
|
-
(httpClient: HttpClient): (dataCollectionId: string, fieldName: string, options?: WixDataDistinctOptions) => Promise<WixDataDistinctResponse>;
|
|
274
|
-
(dataCollectionId: string, fieldName: string, options?: WixDataDistinctOptions): Promise<WixDataDistinctResponse>;
|
|
275
|
-
};
|
|
276
376
|
export declare const distinct: MaybeContext<BuildRESTFunction<typeof publicDistinct> & DistinctGeneric>;
|
|
277
377
|
export declare const count: MaybeContext<BuildRESTFunction<typeof publicCount> & typeof publicCount>;
|
|
278
378
|
export declare const queryReferenced: MaybeContext<BuildRESTFunction<typeof publicQueryReferenced> & typeof publicQueryReferenced>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-v2-data-item-items.context.js","sourceRoot":"","sources":["../../../src/data-v2-data-item-items.context.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,IAAI,YAAY,EACtB,MAAM,IAAI,YAAY,EACtB,IAAI,IAAI,UAAU,EAClB,GAAG,IAAI,SAAS,EAChB,MAAM,IAAI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EACpB,oBAAoB,EACpB,wBAAwB,EACxB,wBAAwB,EACxB,mBAAmB,EACnB,uBAAuB,EACvB,wBAAwB,EACxB,oBAAoB,EACpB,iCAAiC,EACjC,gCAAgC,EAChC,MAAM,EACN,IAAI,EAEJ,aAAa,EACb,YAAY,GACb,MAAM,qCAAqC,CAAA;AAwB5C,cAAc,iCAAiC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/wix-data-items-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.544",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Rimvydas Gimbutas",
|
|
@@ -95,5 +95,5 @@
|
|
|
95
95
|
"wallaby": {
|
|
96
96
|
"autoDetect": true
|
|
97
97
|
},
|
|
98
|
-
"falconPackageHash": "
|
|
98
|
+
"falconPackageHash": "493f4d67bd9cf995f143dd67dc86f40785124f7225b64c2874a557e1"
|
|
99
99
|
}
|