@aws-amplify/data-schema 1.2.8 → 1.3.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/dist/cjs/ClientSchema/Core/ClientCustomOperations.js +4 -0
- package/dist/cjs/ClientSchema/Core/ClientCustomOperations.js.map +1 -0
- package/dist/cjs/{MappedTypes/CustomOperations.js → ClientSchema/Core/ClientCustomType.js} +1 -1
- package/dist/cjs/ClientSchema/Core/ClientCustomType.js.map +1 -0
- package/dist/cjs/{ClientSchema.js → ClientSchema/Core/ClientEnum.js} +1 -1
- package/dist/cjs/ClientSchema/Core/ClientEnum.js.map +1 -0
- package/dist/cjs/ClientSchema/Core/ClientModel.js +4 -0
- package/dist/cjs/ClientSchema/Core/ClientModel.js.map +1 -0
- package/dist/cjs/ClientSchema/Core/ClientSchemaProperty.js +4 -0
- package/dist/cjs/ClientSchema/Core/ClientSchemaProperty.js.map +1 -0
- package/dist/cjs/ClientSchema/Core/index.js +4 -0
- package/dist/cjs/ClientSchema/Core/index.js.map +1 -0
- package/dist/cjs/ClientSchema/index.js +4 -0
- package/dist/cjs/ClientSchema/index.js.map +1 -0
- package/dist/cjs/ClientSchema/utilities/ExtractNestedTypes.js +4 -0
- package/dist/cjs/ClientSchema/utilities/ExtractNestedTypes.js.map +1 -0
- package/dist/cjs/ClientSchema/utilities/ResolveField.js +4 -0
- package/dist/cjs/ClientSchema/utilities/ResolveField.js.map +1 -0
- package/dist/cjs/ClientSchema/utilities/ResolveRef.js +4 -0
- package/dist/cjs/ClientSchema/utilities/ResolveRef.js.map +1 -0
- package/dist/cjs/ClientSchema/utilities/SchemaMetadata.js +4 -0
- package/dist/cjs/ClientSchema/utilities/SchemaMetadata.js.map +1 -0
- package/dist/cjs/ClientSchema/utilities/index.js +9 -0
- package/dist/cjs/ClientSchema/utilities/index.js.map +1 -0
- package/dist/cjs/util/Filters.js +10 -0
- package/dist/cjs/util/Filters.js.map +1 -0
- package/dist/cjs/util/IndexShapes.js +4 -0
- package/dist/cjs/util/IndexShapes.js.map +1 -0
- package/dist/cjs/util/Select.js +4 -0
- package/dist/cjs/util/Select.js.map +1 -0
- package/dist/esm/Authorization.d.ts +3 -3
- package/dist/esm/ClientSchema/Core/ClientCustomOperations.d.ts +88 -0
- package/dist/esm/ClientSchema/Core/ClientCustomOperations.mjs +2 -0
- package/dist/esm/ClientSchema/Core/ClientCustomOperations.mjs.map +1 -0
- package/dist/esm/ClientSchema/Core/ClientCustomType.d.ts +7 -0
- package/dist/esm/ClientSchema/Core/ClientCustomType.mjs +2 -0
- package/dist/esm/ClientSchema/Core/ClientCustomType.mjs.map +1 -0
- package/dist/esm/ClientSchema/Core/ClientEnum.d.ts +5 -0
- package/dist/esm/ClientSchema/Core/ClientEnum.mjs +2 -0
- package/dist/esm/ClientSchema/Core/ClientEnum.mjs.map +1 -0
- package/dist/esm/ClientSchema/Core/ClientModel.d.ts +123 -0
- package/dist/esm/ClientSchema/Core/ClientModel.mjs +2 -0
- package/dist/esm/ClientSchema/Core/ClientModel.mjs.map +1 -0
- package/dist/esm/ClientSchema/Core/ClientSchemaProperty.d.ts +4 -0
- package/dist/esm/ClientSchema/Core/ClientSchemaProperty.mjs +2 -0
- package/dist/esm/ClientSchema/Core/ClientSchemaProperty.mjs.map +1 -0
- package/dist/esm/ClientSchema/Core/index.d.ts +5 -0
- package/dist/esm/ClientSchema/Core/index.mjs +2 -0
- package/dist/esm/ClientSchema/Core/index.mjs.map +1 -0
- package/dist/esm/ClientSchema/index.d.ts +59 -0
- package/dist/esm/ClientSchema/index.mjs +2 -0
- package/dist/esm/ClientSchema/index.mjs.map +1 -0
- package/dist/esm/ClientSchema/utilities/ExtractNestedTypes.d.ts +7 -0
- package/dist/esm/ClientSchema/utilities/ExtractNestedTypes.mjs +2 -0
- package/dist/esm/ClientSchema/utilities/ExtractNestedTypes.mjs.map +1 -0
- package/dist/esm/ClientSchema/utilities/ResolveField.d.ts +29 -0
- package/dist/esm/ClientSchema/utilities/ResolveField.mjs +2 -0
- package/dist/esm/ClientSchema/utilities/ResolveField.mjs.map +1 -0
- package/dist/esm/ClientSchema/utilities/ResolveRef.d.ts +18 -0
- package/dist/esm/ClientSchema/utilities/ResolveRef.mjs +2 -0
- package/dist/esm/ClientSchema/utilities/ResolveRef.mjs.map +1 -0
- package/dist/esm/ClientSchema/utilities/SchemaMetadata.d.ts +7 -0
- package/dist/esm/ClientSchema/utilities/SchemaMetadata.mjs +2 -0
- package/dist/esm/ClientSchema/utilities/SchemaMetadata.mjs.map +1 -0
- package/dist/esm/ClientSchema/utilities/index.d.ts +4 -0
- package/dist/esm/ClientSchema/utilities/index.mjs +2 -0
- package/dist/esm/ClientSchema/utilities/index.mjs.map +1 -0
- package/dist/esm/MappedTypes/ImplicitFieldInjector.d.ts +1 -1
- package/dist/esm/MappedTypes/ModelMetadata.d.ts +1 -1
- package/dist/esm/MappedTypes/ResolveFieldProperties.d.ts +1 -1
- package/dist/esm/ModelSchema.d.ts +11 -5
- package/dist/esm/ModelType.d.ts +9 -8
- package/dist/esm/ModelType.mjs.map +1 -1
- package/dist/esm/runtime/client/index.d.ts +77 -223
- package/dist/esm/runtime/internals/generateCustomOperationsProperty.d.ts +12 -5
- package/dist/esm/util/Filters.d.ts +94 -0
- package/dist/esm/util/Filters.mjs +2 -0
- package/dist/esm/util/Filters.mjs.map +1 -0
- package/dist/esm/util/IndexShapes.d.ts +13 -0
- package/dist/esm/util/IndexShapes.mjs +2 -0
- package/dist/esm/util/IndexShapes.mjs.map +1 -0
- package/dist/esm/util/Select.d.ts +3 -0
- package/dist/esm/util/Select.mjs +2 -0
- package/dist/esm/util/Select.mjs.map +1 -0
- package/dist/esm/util/index.d.ts +3 -0
- package/dist/meta/cjs.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/Authorization.ts +2 -2
- package/src/ClientSchema/Core/ClientCustomOperations.ts +152 -0
- package/src/ClientSchema/Core/ClientCustomType.ts +11 -0
- package/src/ClientSchema/Core/ClientEnum.ts +7 -0
- package/src/ClientSchema/Core/ClientModel.ts +299 -0
- package/src/ClientSchema/Core/ClientSchemaProperty.ts +10 -0
- package/src/ClientSchema/Core/index.ts +5 -0
- package/src/ClientSchema/index.ts +158 -0
- package/src/ClientSchema/utilities/ExtractNestedTypes.ts +15 -0
- package/src/ClientSchema/utilities/ResolveField.ts +79 -0
- package/src/ClientSchema/utilities/ResolveRef.ts +38 -0
- package/src/ClientSchema/utilities/SchemaMetadata.ts +11 -0
- package/src/ClientSchema/utilities/index.ts +4 -0
- package/src/MappedTypes/ImplicitFieldInjector.ts +1 -1
- package/src/MappedTypes/ModelMetadata.ts +2 -1
- package/src/MappedTypes/ResolveFieldProperties.ts +1 -1
- package/src/ModelSchema.ts +19 -4
- package/src/ModelType.ts +12 -3
- package/src/runtime/client/index.ts +175 -433
- package/src/runtime/internals/generateCustomOperationsProperty.ts +2 -2
- package/src/runtime/internals/utils/clientProperties/generateEnumsProperty.ts +1 -1
- package/src/util/Filters.ts +102 -0
- package/src/util/IndexShapes.ts +10 -0
- package/src/util/Select.ts +3 -0
- package/src/util/index.ts +3 -0
- package/dist/cjs/ClientSchema.js.map +0 -1
- package/dist/cjs/MappedTypes/CustomOperations.js.map +0 -1
- package/dist/esm/ClientSchema.d.ts +0 -51
- package/dist/esm/ClientSchema.mjs +0 -2
- package/dist/esm/ClientSchema.mjs.map +0 -1
- package/dist/esm/MappedTypes/CustomOperations.d.ts +0 -125
- package/dist/esm/MappedTypes/CustomOperations.mjs +0 -2
- package/dist/esm/MappedTypes/CustomOperations.mjs.map +0 -1
- package/src/ClientSchema.ts +0 -121
- package/src/MappedTypes/CustomOperations.ts +0 -254
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { DeepReadOnlyObject, UnwrapArray, UnionToIntersection, Prettify
|
|
1
|
+
import { type DeepReadOnlyObject, type UnwrapArray, type UnionToIntersection, type Prettify } from '@aws-amplify/data-schema-types';
|
|
2
2
|
import type { Observable } from 'rxjs';
|
|
3
|
-
import {
|
|
3
|
+
import type { ClientSchemaByEntityType, ClientSchemaByEntityTypeBaseShape } from '../../ClientSchema';
|
|
4
|
+
import type { ExtractNestedTypes } from '../../ClientSchema/utilities/';
|
|
5
|
+
import type { Select, StringFilter, NumericFilter, BooleanFilters } from '../../util';
|
|
4
6
|
export { __modelMeta__, ExtractModelMeta, } from '@aws-amplify/data-schema-types';
|
|
5
7
|
type Model = Record<string, any>;
|
|
6
8
|
/**
|
|
@@ -9,12 +11,15 @@ type Model = Record<string, any>;
|
|
|
9
11
|
type NonRelationalFields<M extends Model> = {
|
|
10
12
|
[Field in keyof M as UnwrapArray<M[Field]> extends Record<string, unknown> ? never : Field]: M[Field];
|
|
11
13
|
};
|
|
14
|
+
type WithOptionalsAsNullishOnly<T> = T extends Array<infer ArrayType> ? Array<WithOptionalsAsNullishOnly<ArrayType>> : T extends (...args: any) => any ? T : T extends object ? {
|
|
15
|
+
[K in keyof T]-?: WithOptionalsAsNullishOnly<T[K]>;
|
|
16
|
+
} : Exclude<T, undefined>;
|
|
12
17
|
/**
|
|
13
18
|
* Selection set-aware CRUDL operation return value type
|
|
14
19
|
*
|
|
15
|
-
* @returns model type
|
|
20
|
+
* @returns model type with default selection set; otherwise generates return type from custom sel. set. Optionality is removed from both return types.
|
|
16
21
|
*/
|
|
17
|
-
type ReturnValue<M extends
|
|
22
|
+
type ReturnValue<M extends ClientSchemaByEntityTypeBaseShape['models'][string], FlatModel extends Model, Paths extends ReadonlyArray<ModelPath<FlatModel>>> = Paths extends undefined | never[] ? WithOptionalsAsNullishOnly<M['type']> : WithOptionalsAsNullishOnly<CustomSelectionSetReturnValue<FlatModel, Paths[number]>>;
|
|
18
23
|
/**
|
|
19
24
|
* This mapped type traverses the SelectionSetReturnValue result and the original FlatModel, restoring array types
|
|
20
25
|
* that were flattened in DeepPickFromPath
|
|
@@ -154,34 +159,13 @@ RecursionLoop extends number[] = [-1, 0, 1, 2, 3, 4], Field = keyof FlatModel> =
|
|
|
154
159
|
*
|
|
155
160
|
* ```
|
|
156
161
|
*/
|
|
157
|
-
|
|
162
|
+
type ResolvedModel<Model extends Record<string, unknown>, Depth extends number = 7, RecursionLoop extends number[] = [-1, 0, 1, 2, 3, 4, 5, 6]> = {
|
|
158
163
|
done: NonRelationalFields<Model>;
|
|
159
164
|
recur: {
|
|
160
165
|
[Field in keyof Model]: Model[Field] extends (...args: any) => ListReturnValue<infer M> ? NonNullable<M> extends Record<string, any> ? ResolvedModel<NonNullable<M>, RecursionLoop[Depth]>[] : never : Model[Field] extends (...args: any) => SingularReturnValue<infer M> ? NonNullable<M> extends Record<string, any> ? ResolvedModel<NonNullable<M>, RecursionLoop[Depth]> : never : Model[Field];
|
|
161
166
|
};
|
|
162
167
|
}[Depth extends -1 ? 'done' : 'recur'];
|
|
163
|
-
export type SelectionSet<Model extends Record<string, unknown>, Path extends ReadonlyArray<ModelPath<FlatModel>>, FlatModel extends Record<string, unknown> = ResolvedModel<Model>> = CustomSelectionSetReturnValue<FlatModel, Path[number]
|
|
164
|
-
export type ModelIdentifier<ModelMeta extends ModelMetaShape> = ModelMeta['identifier']['pk'] & (ModelMeta['identifier']['sk'] extends never ? unknown : ModelMeta['identifier']['sk']);
|
|
165
|
-
type IfEquals<X, Y, A = X, B = never> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? A : B;
|
|
166
|
-
type WritableKeys<T> = {
|
|
167
|
-
[P in keyof T]-?: IfEquals<{
|
|
168
|
-
[Q in P]: T[P];
|
|
169
|
-
}, {
|
|
170
|
-
-readonly [Q in P]: T[P];
|
|
171
|
-
}, P>;
|
|
172
|
-
}[keyof T];
|
|
173
|
-
/**
|
|
174
|
-
* All required fields and relational fields, exclude readonly fields
|
|
175
|
-
*/
|
|
176
|
-
type MutationInput<Fields, WritableFields = Pick<Fields, WritableKeys<Fields>>> = {
|
|
177
|
-
[Prop in keyof WritableFields as WritableFields[Prop] extends (...args: any) => any ? never : Prop]: WritableFields[Prop];
|
|
178
|
-
};
|
|
179
|
-
/**
|
|
180
|
-
* All identifiers and fields used to create a model
|
|
181
|
-
*/
|
|
182
|
-
type CreateModelInput<Model extends Record<string, unknown>, ModelMeta extends ModelMetaShape> = Equal<ModelIdentifier<ModelMeta>, {
|
|
183
|
-
id: string;
|
|
184
|
-
}> extends true ? Partial<ModelIdentifier<ModelMeta>> & Omit<MutationInput<Model>, 'id'> : MutationInput<Model>;
|
|
168
|
+
export type SelectionSet<Model extends Record<string, unknown>, Path extends ReadonlyArray<ModelPath<FlatModel>>, FlatModel extends Record<string, unknown> = ResolvedModel<Model>> = WithOptionalsAsNullishOnly<CustomSelectionSetReturnValue<FlatModel, Path[number]>>;
|
|
185
169
|
/**
|
|
186
170
|
* See: https://spec.graphql.org/draft/#sec-Errors
|
|
187
171
|
*/
|
|
@@ -251,7 +235,7 @@ export type ObserveQueryReturnValue<T> = Observable<{
|
|
|
251
235
|
items: T[];
|
|
252
236
|
isSynced: boolean;
|
|
253
237
|
}>;
|
|
254
|
-
export type LazyLoader<
|
|
238
|
+
export type LazyLoader<T, IsArray extends boolean> = (options?: IsArray extends true ? {
|
|
255
239
|
authMode?: AuthMode;
|
|
256
240
|
authToken?: string;
|
|
257
241
|
limit?: number;
|
|
@@ -261,138 +245,59 @@ export type LazyLoader<Model, IsArray extends boolean> = (options?: IsArray exte
|
|
|
261
245
|
authMode?: AuthMode;
|
|
262
246
|
authToken?: string;
|
|
263
247
|
headers?: CustomHeaders;
|
|
264
|
-
}) => IsArray extends true ? ListReturnValue<Prettify<NonNullable<
|
|
248
|
+
}) => IsArray extends true ? ListReturnValue<Prettify<NonNullable<T>>> : SingularReturnValue<Prettify<T>>;
|
|
265
249
|
export type AuthMode = 'apiKey' | 'iam' | 'identityPool' | 'oidc' | 'userPool' | 'lambda' | 'none';
|
|
266
|
-
type LogicalFilters<Model extends
|
|
250
|
+
type LogicalFilters<Model extends ClientSchemaByEntityTypeBaseShape['models'][string]> = {
|
|
267
251
|
and?: ModelFilter<Model> | ModelFilter<Model>[];
|
|
268
252
|
or?: ModelFilter<Model> | ModelFilter<Model>[];
|
|
269
253
|
not?: ModelFilter<Model>;
|
|
270
254
|
};
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
*/
|
|
274
|
-
type SizeFilter = {
|
|
275
|
-
between?: [number, number];
|
|
276
|
-
eq?: number;
|
|
277
|
-
ge?: number;
|
|
278
|
-
gt?: number;
|
|
279
|
-
le?: number;
|
|
280
|
-
lt?: number;
|
|
281
|
-
ne?: number;
|
|
282
|
-
};
|
|
283
|
-
/**
|
|
284
|
-
* Not actually sure if/how customer can pass this through as variables yet.
|
|
285
|
-
* Leaving it out for now:
|
|
286
|
-
*
|
|
287
|
-
* attributeType: "binary" | "binarySet" | "bool" | "list" | "map" | "number" | "numberSet" | "string" | "stringSet" | "_null"
|
|
288
|
-
*/
|
|
289
|
-
/**
|
|
290
|
-
* Filters options that can be used on string-like fields.
|
|
291
|
-
*/
|
|
292
|
-
export type StringFilter<T extends string = string> = {
|
|
293
|
-
attributeExists?: boolean;
|
|
294
|
-
beginsWith?: string;
|
|
295
|
-
between?: [string, string];
|
|
296
|
-
contains?: string;
|
|
297
|
-
eq?: T;
|
|
298
|
-
ge?: string;
|
|
299
|
-
gt?: string;
|
|
300
|
-
le?: string;
|
|
301
|
-
lt?: string;
|
|
302
|
-
ne?: T;
|
|
303
|
-
notContains?: string;
|
|
304
|
-
size?: SizeFilter;
|
|
305
|
-
};
|
|
306
|
-
export type NumericFilter = {
|
|
307
|
-
attributeExists?: boolean;
|
|
308
|
-
between?: [number, number];
|
|
309
|
-
eq?: number;
|
|
310
|
-
ge?: number;
|
|
311
|
-
gt?: number;
|
|
312
|
-
le?: number;
|
|
313
|
-
lt?: number;
|
|
314
|
-
ne?: number;
|
|
315
|
-
};
|
|
316
|
-
type BooleanFilters = {
|
|
317
|
-
attributeExists?: boolean;
|
|
318
|
-
eq?: boolean;
|
|
319
|
-
ne?: boolean;
|
|
320
|
-
};
|
|
321
|
-
/**
|
|
322
|
-
* A composite SK (in an identifier or secondaryIndex) resolves to this type for
|
|
323
|
-
* list queries and index queries
|
|
324
|
-
*
|
|
325
|
-
* @example
|
|
326
|
-
* Given
|
|
327
|
-
* ```ts
|
|
328
|
-
* MyModel: a
|
|
329
|
-
.model({
|
|
330
|
-
pk: a.string().required(),
|
|
331
|
-
sk1: a.string().required(),
|
|
332
|
-
sk2: a.integer().required(),
|
|
333
|
-
})
|
|
334
|
-
.identifier(['pk', 'sk1', 'sk2']),
|
|
335
|
-
* ```
|
|
336
|
-
* Expected list options:
|
|
337
|
-
* ```ts
|
|
338
|
-
* {
|
|
339
|
-
* pk?: string
|
|
340
|
-
* sk1Sk2?: ModelPrimaryCompositeKeyConditionInput
|
|
341
|
-
* }
|
|
342
|
-
* ```
|
|
343
|
-
* Where ModelPrimaryCompositeKeyConditionInput resolves to:
|
|
344
|
-
* ```ts
|
|
345
|
-
* {
|
|
346
|
-
* eq: {sk1: string; sk2: number};
|
|
347
|
-
* le: {sk1: string; sk2: number};
|
|
348
|
-
* lt: {sk1: string; sk2: number};
|
|
349
|
-
* ge: {sk1: string; sk2: number};
|
|
350
|
-
* gt: {sk1: string; sk2: number};
|
|
351
|
-
* between: [ {sk1: string; sk2: number} ];
|
|
352
|
-
* beginsWith: {sk1: string; sk2: number};
|
|
353
|
-
* }
|
|
354
|
-
* ```
|
|
355
|
-
* */
|
|
356
|
-
export type ModelPrimaryCompositeKeyInput<SkIr extends Record<string, string | number>> = {
|
|
357
|
-
eq?: SkIr;
|
|
358
|
-
le?: SkIr;
|
|
359
|
-
lt?: SkIr;
|
|
360
|
-
ge?: SkIr;
|
|
361
|
-
gt?: SkIr;
|
|
362
|
-
between?: [SkIr];
|
|
363
|
-
beginsWith?: SkIr;
|
|
364
|
-
};
|
|
365
|
-
type ModelFilter<Model extends Record<any, any>> = LogicalFilters<Model> & {
|
|
366
|
-
[K in keyof Model as Model[K] extends LazyLoader<any, any> ? never : K]?: boolean extends Model[K] ? BooleanFilters : number extends Model[K] ? NumericFilter : StringFilter;
|
|
255
|
+
type ModelFilter<Model extends ClientSchemaByEntityTypeBaseShape['models'][string]> = LogicalFilters<Model> & {
|
|
256
|
+
[K in keyof Model['type'] as Model['type'][K] extends LazyLoader<any, any> ? never : K]?: boolean extends Model['type'][K] ? BooleanFilters : number extends Model['type'][K] ? NumericFilter : StringFilter;
|
|
367
257
|
};
|
|
368
258
|
export type ModelSortDirection = 'ASC' | 'DESC';
|
|
369
|
-
type
|
|
370
|
-
|
|
371
|
-
identifier: PrimaryIndexIrShape;
|
|
259
|
+
type ListCpkOptions<Model extends ClientSchemaByEntityTypeBaseShape['models'][string]> = unknown extends Model['__meta']['listOptionsPkParams'] ? unknown : Model['__meta']['listOptionsPkParams'] & {
|
|
260
|
+
sortDirection?: ModelSortDirection;
|
|
372
261
|
};
|
|
373
|
-
|
|
374
|
-
|
|
262
|
+
interface ClientSecondaryIndexField {
|
|
263
|
+
input: object;
|
|
264
|
+
}
|
|
265
|
+
type IndexQueryMethods<Model extends ClientSchemaByEntityTypeBaseShape['models'][string]> = {
|
|
266
|
+
[K in keyof Select<Model['secondaryIndexes'], ClientSecondaryIndexField>]: IndexQueryMethod<Model, Select<Model['secondaryIndexes'], ClientSecondaryIndexField>[K]>;
|
|
267
|
+
};
|
|
268
|
+
type IndexQueryMethod<Model extends ClientSchemaByEntityTypeBaseShape['models'][string], Method extends ClientSecondaryIndexField, FlatModel extends Record<string, unknown> = ResolvedModel<Model['type']>> = <SelectionSet extends ReadonlyArray<ModelPath<FlatModel>> = never[]>(input: Method['input'], options?: {
|
|
269
|
+
filter?: ModelFilter<Model>;
|
|
270
|
+
sortDirection?: ModelSortDirection;
|
|
271
|
+
limit?: number;
|
|
272
|
+
nextToken?: string | null;
|
|
273
|
+
selectionSet?: SelectionSet;
|
|
274
|
+
authMode?: AuthMode;
|
|
275
|
+
authToken?: string;
|
|
276
|
+
headers?: CustomHeaders;
|
|
277
|
+
}) => ListReturnValue<Prettify<ReturnValue<Model, FlatModel, SelectionSet>>>;
|
|
278
|
+
type ModelTypesClient<Model extends ClientSchemaByEntityTypeBaseShape['models'][string], FlatModel extends Record<string, unknown> = ResolvedModel<Model['type']>> = IndexQueryMethods<Model> & {
|
|
279
|
+
create: (model: Model['createType'], options?: {
|
|
375
280
|
authMode?: AuthMode;
|
|
376
281
|
authToken?: string;
|
|
377
282
|
headers?: CustomHeaders;
|
|
378
|
-
}) => SingularReturnValue<Model>;
|
|
379
|
-
update: (model:
|
|
283
|
+
}) => SingularReturnValue<Model['type']>;
|
|
284
|
+
update: (model: Model['updateType'], options?: {
|
|
380
285
|
authMode?: AuthMode;
|
|
381
286
|
authToken?: string;
|
|
382
287
|
headers?: CustomHeaders;
|
|
383
|
-
}) => SingularReturnValue<Model>;
|
|
384
|
-
delete: (identifier:
|
|
288
|
+
}) => SingularReturnValue<Model['type']>;
|
|
289
|
+
delete: (identifier: Model['deleteType'], options?: {
|
|
385
290
|
authMode?: AuthMode;
|
|
386
291
|
authToken?: string;
|
|
387
292
|
headers?: CustomHeaders;
|
|
388
|
-
}) => SingularReturnValue<Model>;
|
|
389
|
-
get<SelectionSet extends ReadonlyArray<ModelPath<FlatModel>> = never[]>(identifier:
|
|
293
|
+
}) => SingularReturnValue<Model['type']>;
|
|
294
|
+
get<SelectionSet extends ReadonlyArray<ModelPath<FlatModel>> = never[]>(identifier: Model['identifier'], options?: {
|
|
390
295
|
selectionSet?: SelectionSet;
|
|
391
296
|
authMode?: AuthMode;
|
|
392
297
|
authToken?: string;
|
|
393
298
|
headers?: CustomHeaders;
|
|
394
299
|
}): SingularReturnValue<Prettify<ReturnValue<Model, FlatModel, SelectionSet>>>;
|
|
395
|
-
list<SelectionSet extends ReadonlyArray<ModelPath<FlatModel>> = never[]>(options?:
|
|
300
|
+
list<SelectionSet extends ReadonlyArray<ModelPath<FlatModel>> = never[]>(options?: ListCpkOptions<Model> & {
|
|
396
301
|
filter?: ModelFilter<Model>;
|
|
397
302
|
limit?: number;
|
|
398
303
|
nextToken?: string | null;
|
|
@@ -429,29 +334,29 @@ export type ModelTypesClient<ModelName extends string, Model extends Record<stri
|
|
|
429
334
|
authToken?: string;
|
|
430
335
|
}): ObserveQueryReturnValue<Prettify<ReturnValue<Model, FlatModel, SelectionSet>>>;
|
|
431
336
|
};
|
|
432
|
-
type ModelTypesSSRCookies<
|
|
433
|
-
create: (model:
|
|
337
|
+
type ModelTypesSSRCookies<Model extends ClientSchemaByEntityTypeBaseShape['models'][string], FlatModel extends Record<string, unknown> = ResolvedModel<Model['type']>> = IndexQueryMethods<Model> & {
|
|
338
|
+
create: (model: Model['createType'], options?: {
|
|
434
339
|
authMode?: AuthMode;
|
|
435
340
|
authToken?: string;
|
|
436
341
|
headers?: CustomHeaders;
|
|
437
342
|
}) => SingularReturnValue<Model>;
|
|
438
|
-
update: (model:
|
|
343
|
+
update: (model: Model['updateType'], options?: {
|
|
439
344
|
authMode?: AuthMode;
|
|
440
345
|
authToken?: string;
|
|
441
346
|
headers?: CustomHeaders;
|
|
442
347
|
}) => SingularReturnValue<Model>;
|
|
443
|
-
delete: (identifier:
|
|
348
|
+
delete: (identifier: Model['deleteType'], options?: {
|
|
444
349
|
authMode?: AuthMode;
|
|
445
350
|
authToken?: string;
|
|
446
351
|
headers?: CustomHeaders;
|
|
447
352
|
}) => SingularReturnValue<Model>;
|
|
448
|
-
get<SelectionSet extends ReadonlyArray<ModelPath<FlatModel>> = never[]>(identifier:
|
|
353
|
+
get<SelectionSet extends ReadonlyArray<ModelPath<FlatModel>> = never[]>(identifier: Model['identifier'], options?: {
|
|
449
354
|
selectionSet?: SelectionSet;
|
|
450
355
|
authMode?: AuthMode;
|
|
451
356
|
authToken?: string;
|
|
452
357
|
headers?: CustomHeaders;
|
|
453
358
|
}): SingularReturnValue<Prettify<ReturnValue<Model, FlatModel, SelectionSet>>>;
|
|
454
|
-
list<SelectionSet extends ReadonlyArray<ModelPath<FlatModel>> = never[]>(options?:
|
|
359
|
+
list<SelectionSet extends ReadonlyArray<ModelPath<FlatModel>> = never[]>(options?: ListCpkOptions<Model> & {
|
|
455
360
|
filter?: ModelFilter<Model>;
|
|
456
361
|
sortDirection?: ModelSortDirection;
|
|
457
362
|
limit?: number;
|
|
@@ -462,29 +367,29 @@ type ModelTypesSSRCookies<ModelName extends string, Model extends Record<string,
|
|
|
462
367
|
headers?: CustomHeaders;
|
|
463
368
|
}): ListReturnValue<Prettify<ReturnValue<Model, FlatModel, SelectionSet>>>;
|
|
464
369
|
};
|
|
465
|
-
type ModelTypesSSRRequest<
|
|
466
|
-
create: (contextSpec: any, model:
|
|
370
|
+
type ModelTypesSSRRequest<Model extends ClientSchemaByEntityTypeBaseShape['models'][string], FlatModel extends Record<string, unknown> = ResolvedModel<Model['type']>> = IndexQueryMethods<Model> & {
|
|
371
|
+
create: (contextSpec: any, model: Model['createType'], options?: {
|
|
467
372
|
authMode?: AuthMode;
|
|
468
373
|
authToken?: string;
|
|
469
374
|
headers?: CustomHeaders;
|
|
470
375
|
}) => SingularReturnValue<Model>;
|
|
471
|
-
update: (contextSpec: any, model:
|
|
376
|
+
update: (contextSpec: any, model: Model['updateType'], options?: {
|
|
472
377
|
authMode?: AuthMode;
|
|
473
378
|
authToken?: string;
|
|
474
379
|
headers?: CustomHeaders;
|
|
475
380
|
}) => SingularReturnValue<Model>;
|
|
476
|
-
delete: (contextSpec: any, identifier:
|
|
381
|
+
delete: (contextSpec: any, identifier: Model['deleteType'], options?: {
|
|
477
382
|
authMode?: AuthMode;
|
|
478
383
|
authToken?: string;
|
|
479
384
|
headers?: CustomHeaders;
|
|
480
385
|
}) => SingularReturnValue<Model>;
|
|
481
|
-
get<SelectionSet extends ReadonlyArray<ModelPath<FlatModel>> = never[]>(contextSpec: any, identifier:
|
|
386
|
+
get<SelectionSet extends ReadonlyArray<ModelPath<FlatModel>> = never[]>(contextSpec: any, identifier: Model['identifier'], options?: {
|
|
482
387
|
selectionSet?: SelectionSet;
|
|
483
388
|
authMode?: AuthMode;
|
|
484
389
|
authToken?: string;
|
|
485
390
|
headers?: CustomHeaders;
|
|
486
391
|
}): SingularReturnValue<Prettify<ReturnValue<Model, FlatModel, SelectionSet>>>;
|
|
487
|
-
list<SelectionSet extends ReadonlyArray<ModelPath<FlatModel>> = never[]>(contextSpec: any, options?:
|
|
392
|
+
list<SelectionSet extends ReadonlyArray<ModelPath<FlatModel>> = never[]>(contextSpec: any, options?: ListCpkOptions<Model> & {
|
|
488
393
|
filter?: ModelFilter<Model>;
|
|
489
394
|
sortDirection?: ModelSortDirection;
|
|
490
395
|
limit?: number;
|
|
@@ -496,12 +401,12 @@ type ModelTypesSSRRequest<ModelName extends string, Model extends Record<string,
|
|
|
496
401
|
}): ListReturnValue<Prettify<ReturnValue<Model, FlatModel, SelectionSet>>>;
|
|
497
402
|
};
|
|
498
403
|
type ContextType = 'CLIENT' | 'COOKIES' | 'REQUEST';
|
|
499
|
-
export type ModelTypes<
|
|
500
|
-
[ModelName in
|
|
404
|
+
export type ModelTypes<T extends Record<any, any>, Context extends ContextType = 'CLIENT', Schema extends ClientSchemaByEntityType<T> = ClientSchemaByEntityType<T>> = {
|
|
405
|
+
[ModelName in keyof Schema['models']]: Context extends 'CLIENT' ? ModelTypesClient<Schema['models'][ModelName]> : Context extends 'COOKIES' ? ModelTypesSSRCookies<Schema['models'][ModelName]> : Context extends 'REQUEST' ? ModelTypesSSRRequest<Schema['models'][ModelName]> : never;
|
|
501
406
|
};
|
|
502
|
-
export type CustomQueries<
|
|
503
|
-
export type CustomMutations<
|
|
504
|
-
export type CustomSubscriptions<
|
|
407
|
+
export type CustomQueries<T extends Record<any, any>, Context extends ContextType = 'CLIENT', Schema extends ClientSchemaByEntityType<T> = ClientSchemaByEntityType<T>> = CustomOperations<Schema['queries'], Context>;
|
|
408
|
+
export type CustomMutations<T extends Record<any, any>, Context extends ContextType = 'CLIENT', Schema extends ClientSchemaByEntityType<T> = ClientSchemaByEntityType<T>> = CustomOperations<Schema['mutations'], Context>;
|
|
409
|
+
export type CustomSubscriptions<T extends Record<any, any>, Context extends ContextType = 'CLIENT', Schema extends ClientSchemaByEntityType<T> = ClientSchemaByEntityType<T>> = CustomOperations<Schema['subscriptions'], Context>;
|
|
505
410
|
type CustomOperationMethodOptions = {
|
|
506
411
|
authMode?: AuthMode;
|
|
507
412
|
authToken?: string;
|
|
@@ -513,11 +418,11 @@ type CustomOperationMethodOptions = {
|
|
|
513
418
|
type CustomOperationFnParams<Args extends Record<string, unknown> | never> = [
|
|
514
419
|
Args
|
|
515
420
|
] extends [never] ? [CustomOperationMethodOptions?] : [Args, CustomOperationMethodOptions?];
|
|
516
|
-
export type CustomOperations<
|
|
517
|
-
[OpName in keyof
|
|
518
|
-
CLIENT: (...params: CustomOperationFnParams<
|
|
519
|
-
COOKIES: (...params: CustomOperationFnParams<
|
|
520
|
-
REQUEST: (contextSpec: any, ...params: CustomOperationFnParams<
|
|
421
|
+
export type CustomOperations<OperationDefs extends ClientSchemaByEntityTypeBaseShape['queries' | 'mutations' | 'subscriptions'], Context extends ContextType = 'CLIENT'> = {
|
|
422
|
+
[OpName in keyof OperationDefs]: {
|
|
423
|
+
CLIENT: (...params: CustomOperationFnParams<OperationDefs[OpName]['args']>) => OperationDefs[OpName]['operationType'] extends 'Subscription' ? ObservedReturnValue<OperationDefs[OpName]['type']> : SingularReturnValue<OperationDefs[OpName]['type']>;
|
|
424
|
+
COOKIES: (...params: CustomOperationFnParams<OperationDefs[OpName]['args']>) => SingularReturnValue<OperationDefs[OpName]['type']>;
|
|
425
|
+
REQUEST: (contextSpec: any, ...params: CustomOperationFnParams<OperationDefs[OpName]['args']>) => SingularReturnValue<OperationDefs[OpName]['type']>;
|
|
521
426
|
}[Context];
|
|
522
427
|
};
|
|
523
428
|
/**
|
|
@@ -537,11 +442,14 @@ export type CustomOperations<Schema extends Record<any, any>, OperationType exte
|
|
|
537
442
|
* }
|
|
538
443
|
* }
|
|
539
444
|
*/
|
|
540
|
-
export type EnumTypes<
|
|
541
|
-
[EnumName in keyof
|
|
542
|
-
values: () => Array<
|
|
445
|
+
export type EnumTypes<T extends Record<any, any>> = {
|
|
446
|
+
[EnumName in keyof AllEnumTypesRecursively<T>]: {
|
|
447
|
+
values: () => Array<AllEnumTypesRecursively<T>[EnumName]['type']>;
|
|
543
448
|
};
|
|
544
449
|
};
|
|
450
|
+
type AllEnumTypesRecursively<T extends Record<any, any>> = ClientSchemaByEntityType<T>['enums'] & Select<ExtractNestedTypes<ClientSchemaByEntityType<T>>, {
|
|
451
|
+
__entityType: 'enum';
|
|
452
|
+
}>;
|
|
545
453
|
/**
|
|
546
454
|
* Request options that are passed to custom header functions.
|
|
547
455
|
* `method` and `headers` are not included in custom header functions passed to
|
|
@@ -558,76 +466,22 @@ export type RequestOptions = {
|
|
|
558
466
|
* promise.
|
|
559
467
|
*/
|
|
560
468
|
export type CustomHeaders = Record<string, string> | ((requestOptions?: RequestOptions) => Promise<Record<string, string>>);
|
|
561
|
-
|
|
562
|
-
* PrimaryIndex field types and query methods
|
|
563
|
-
*/
|
|
564
|
-
export interface PrimaryIndexIrShape {
|
|
565
|
-
pk: {
|
|
566
|
-
[key: string]: string | number;
|
|
567
|
-
};
|
|
568
|
-
sk: {
|
|
569
|
-
[key: string]: string | number;
|
|
570
|
-
} | never;
|
|
571
|
-
compositeSk: never | string;
|
|
572
|
-
}
|
|
573
|
-
/**
|
|
574
|
-
* SecondaryIndex field types and query methods
|
|
575
|
-
*/
|
|
576
|
-
export interface SecondaryIndexIrShape extends PrimaryIndexIrShape {
|
|
577
|
-
defaultQueryFieldSuffix: string;
|
|
578
|
-
queryField: string;
|
|
579
|
-
}
|
|
580
|
-
export type IndexQueryMethodsFromIR<SecondaryIdxTuple extends SecondaryIndexIrShape[], ModelName extends string, Model extends Record<string, unknown>, Enums extends Record<string, string>, Res = unknown> = SecondaryIdxTuple extends [
|
|
581
|
-
infer A extends SecondaryIndexIrShape,
|
|
582
|
-
...infer B extends SecondaryIndexIrShape[]
|
|
583
|
-
] ? IndexQueryMethodsFromIR<B, ModelName, Model, Enums, IndexQueryMethodSignature<A, ModelName, Model, Enums> & Res> : Res;
|
|
584
|
-
export type ListPkOptions<ModelMeta extends ModelMetaShape, Enums extends Record<string, string>> = ModelMeta['identifier']['sk'] extends never ? unknown : Prettify<Partial<IndexQueryInput<ModelMeta['identifier'], Enums>> & {
|
|
585
|
-
sortDirection?: ModelSortDirection;
|
|
586
|
-
}>;
|
|
587
|
-
/**
|
|
588
|
-
* Accepts a PrimaryIndexIr or SecondaryIndexIr and returns resolved parameters
|
|
589
|
-
*/
|
|
590
|
-
export type IndexQueryInput<Idx extends PrimaryIndexIrShape, Enums extends Record<string, string>> = {
|
|
591
|
-
[PKField in keyof Idx['pk']]: Idx['pk'][PKField] extends `${deferredRefResolvingPrefix}${infer R}` ? Enums[R] : Idx['pk'][PKField];
|
|
592
|
-
} & (Idx['compositeSk'] extends never ? {
|
|
593
|
-
[SKField in keyof Idx['sk']]+?: number extends Idx['sk'][SKField] ? NumericFilter : Idx['sk'][SKField] extends `${deferredRefResolvingPrefix}${infer R}` ? StringFilter<Enums[R]> : StringFilter<Idx['sk'][SKField] & string>;
|
|
594
|
-
} : {
|
|
595
|
-
[CompositeSk in Idx['compositeSk']]+?: ModelPrimaryCompositeKeyInput<{
|
|
596
|
-
[SKField in keyof Idx['sk']]: Idx['sk'][SKField] extends `${deferredRefResolvingPrefix}${infer _R}` ? string : Idx['sk'][SKField];
|
|
597
|
-
}>;
|
|
598
|
-
});
|
|
599
|
-
type IndexQueryMethodSignature<Idx extends SecondaryIndexIrShape, ModelName extends string, Model extends Record<string, unknown>, Enums extends Record<string, string>> = Record<IsEmptyStringOrNever<Idx['queryField']> extends false ? Idx['queryField'] : `list${ModelName}By${Idx['defaultQueryFieldSuffix']}`, <FlatModel extends Record<string, unknown> = ResolvedModel<Model>, SelectionSet extends ReadonlyArray<ModelPath<FlatModel>> = never[]>(input: IndexQueryInput<Idx, Enums>, options?: {
|
|
600
|
-
filter?: ModelFilter<Model>;
|
|
601
|
-
sortDirection?: ModelSortDirection;
|
|
602
|
-
limit?: number;
|
|
603
|
-
nextToken?: string | null;
|
|
604
|
-
selectionSet?: SelectionSet;
|
|
605
|
-
authMode?: AuthMode;
|
|
606
|
-
authToken?: string;
|
|
607
|
-
headers?: CustomHeaders;
|
|
608
|
-
}) => ListReturnValue<Prettify<ReturnValue<Model, FlatModel, SelectionSet>>>>;
|
|
609
|
-
type FilteredKeys<T> = {
|
|
610
|
-
[P in keyof T]: T[P] extends never ? never : P;
|
|
611
|
-
}[keyof T];
|
|
612
|
-
type ExcludeNeverFields<O> = {
|
|
613
|
-
[K in FilteredKeys<O>]: O[K];
|
|
614
|
-
};
|
|
615
|
-
export type ClientExtensions<T extends Record<any, any> = never> = ExcludeNeverFields<{
|
|
469
|
+
export type ClientExtensions<T extends Record<any, any> = never> = {
|
|
616
470
|
models: ModelTypes<T, 'CLIENT'>;
|
|
617
471
|
enums: EnumTypes<T>;
|
|
618
472
|
queries: CustomQueries<T, 'CLIENT'>;
|
|
619
473
|
mutations: CustomMutations<T, 'CLIENT'>;
|
|
620
474
|
subscriptions: CustomSubscriptions<T, 'CLIENT'>;
|
|
621
|
-
}
|
|
622
|
-
export type ClientExtensionsSSRRequest<T extends Record<any, any> = never> =
|
|
475
|
+
};
|
|
476
|
+
export type ClientExtensionsSSRRequest<T extends Record<any, any> = never> = {
|
|
623
477
|
models: ModelTypes<T, 'REQUEST'>;
|
|
624
478
|
enums: EnumTypes<T>;
|
|
625
479
|
queries: CustomQueries<T, 'REQUEST'>;
|
|
626
480
|
mutations: CustomMutations<T, 'REQUEST'>;
|
|
627
|
-
}
|
|
628
|
-
export type ClientExtensionsSSRCookies<T extends Record<any, any> = never> =
|
|
481
|
+
};
|
|
482
|
+
export type ClientExtensionsSSRCookies<T extends Record<any, any> = never> = {
|
|
629
483
|
models: ModelTypes<T, 'COOKIES'>;
|
|
630
484
|
enums: EnumTypes<T>;
|
|
631
485
|
queries: CustomQueries<T, 'COOKIES'>;
|
|
632
486
|
mutations: CustomMutations<T, 'COOKIES'>;
|
|
633
|
-
}
|
|
487
|
+
};
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
import { CustomMutations, CustomQueries } from '../client';
|
|
1
|
+
import { CustomMutations, CustomQueries, CustomSubscriptions } from '../client';
|
|
2
2
|
import { BaseClient, ClientInternalsGetter, GraphQLProviderConfig } from '../bridge-types';
|
|
3
3
|
type OpTypes = 'queries' | 'mutations' | 'subscriptions';
|
|
4
|
-
|
|
5
|
-
export declare function
|
|
6
|
-
export declare function
|
|
7
|
-
|
|
4
|
+
type CustomOpsProperty<T extends Record<any, any>, OpType extends OpTypes> = OpType extends 'queries' ? CustomQueries<T> : OpType extends 'mutations' ? CustomMutations<T> : OpType extends 'subscriptions' ? CustomSubscriptions<T> : never;
|
|
5
|
+
export declare function generateCustomOperationsProperty<T extends Record<any, any>, OpType extends OpTypes>(client: BaseClient, config: GraphQLProviderConfig['GraphQL'], operationsType: OpType, getInternals: ClientInternalsGetter): CustomOpsProperty<T, OpType>;
|
|
6
|
+
export declare function generateCustomMutationsProperty<T extends Record<any, any>>(client: BaseClient, config: GraphQLProviderConfig['GraphQL'], getInternals: ClientInternalsGetter): import("../client").CustomOperations<import("../../util").Select<T, {
|
|
7
|
+
__entityType: "customMutation";
|
|
8
|
+
}>, "CLIENT">;
|
|
9
|
+
export declare function generateCustomQueriesProperty<T extends Record<any, any>>(client: BaseClient, config: GraphQLProviderConfig['GraphQL'], getInternals: ClientInternalsGetter): import("../client").CustomOperations<import("../../util").Select<T, {
|
|
10
|
+
__entityType: "customQuery";
|
|
11
|
+
}>, "CLIENT">;
|
|
12
|
+
export declare function generateCustomSubscriptionsProperty<T extends Record<any, any>>(client: BaseClient, config: GraphQLProviderConfig['GraphQL'], getInternals: ClientInternalsGetter): import("../client").CustomOperations<import("../../util").Select<T, {
|
|
13
|
+
__entityType: "customSubscription";
|
|
14
|
+
}>, "CLIENT">;
|
|
8
15
|
export {};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Not actually sure if/how customer can pass this through as variables yet.
|
|
3
|
+
* Leaving it out for now:
|
|
4
|
+
*
|
|
5
|
+
* attributeType: "binary" | "binarySet" | "bool" | "list" | "map" | "number" | "numberSet" | "string" | "stringSet" | "_null"
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Filters options that can be used on string-like fields.
|
|
9
|
+
*/
|
|
10
|
+
export type StringFilter<T extends string = string> = {
|
|
11
|
+
attributeExists?: boolean;
|
|
12
|
+
beginsWith?: string;
|
|
13
|
+
between?: [string, string];
|
|
14
|
+
contains?: string;
|
|
15
|
+
eq?: T;
|
|
16
|
+
ge?: string;
|
|
17
|
+
gt?: string;
|
|
18
|
+
le?: string;
|
|
19
|
+
lt?: string;
|
|
20
|
+
ne?: T;
|
|
21
|
+
notContains?: string;
|
|
22
|
+
size?: SizeFilter;
|
|
23
|
+
};
|
|
24
|
+
export type NumericFilter = {
|
|
25
|
+
attributeExists?: boolean;
|
|
26
|
+
between?: [number, number];
|
|
27
|
+
eq?: number;
|
|
28
|
+
ge?: number;
|
|
29
|
+
gt?: number;
|
|
30
|
+
le?: number;
|
|
31
|
+
lt?: number;
|
|
32
|
+
ne?: number;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Filter options that can be used on fields where size checks are supported.
|
|
36
|
+
*/
|
|
37
|
+
export type SizeFilter = {
|
|
38
|
+
between?: [number, number];
|
|
39
|
+
eq?: number;
|
|
40
|
+
ge?: number;
|
|
41
|
+
gt?: number;
|
|
42
|
+
le?: number;
|
|
43
|
+
lt?: number;
|
|
44
|
+
ne?: number;
|
|
45
|
+
};
|
|
46
|
+
export type BooleanFilters = {
|
|
47
|
+
attributeExists?: boolean;
|
|
48
|
+
eq?: boolean;
|
|
49
|
+
ne?: boolean;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* A composite SK (in an identifier or secondaryIndex) resolves to this type for
|
|
53
|
+
* list queries and index queries
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* Given
|
|
57
|
+
* ```ts
|
|
58
|
+
* MyModel: a
|
|
59
|
+
.model({
|
|
60
|
+
pk: a.string().required(),
|
|
61
|
+
sk1: a.string().required(),
|
|
62
|
+
sk2: a.integer().required(),
|
|
63
|
+
})
|
|
64
|
+
.identifier(['pk', 'sk1', 'sk2']),
|
|
65
|
+
* ```
|
|
66
|
+
* Expected list options:
|
|
67
|
+
* ```ts
|
|
68
|
+
* {
|
|
69
|
+
* pk?: string
|
|
70
|
+
* sk1Sk2?: ModelPrimaryCompositeKeyConditionInput
|
|
71
|
+
* }
|
|
72
|
+
* ```
|
|
73
|
+
* Where ModelPrimaryCompositeKeyConditionInput resolves to:
|
|
74
|
+
* ```ts
|
|
75
|
+
* {
|
|
76
|
+
* eq: {sk1: string; sk2: number};
|
|
77
|
+
* le: {sk1: string; sk2: number};
|
|
78
|
+
* lt: {sk1: string; sk2: number};
|
|
79
|
+
* ge: {sk1: string; sk2: number};
|
|
80
|
+
* gt: {sk1: string; sk2: number};
|
|
81
|
+
* between: [ {sk1: string; sk2: number} ];
|
|
82
|
+
* beginsWith: {sk1: string; sk2: number};
|
|
83
|
+
* }
|
|
84
|
+
* ```
|
|
85
|
+
* */
|
|
86
|
+
export type ModelPrimaryCompositeKeyInput<SkIr extends Record<string, string | number>> = {
|
|
87
|
+
eq?: SkIr;
|
|
88
|
+
le?: SkIr;
|
|
89
|
+
lt?: SkIr;
|
|
90
|
+
ge?: SkIr;
|
|
91
|
+
gt?: SkIr;
|
|
92
|
+
between?: [SkIr];
|
|
93
|
+
beginsWith?: SkIr;
|
|
94
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Filters.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface PrimaryIndexIrShape {
|
|
2
|
+
pk: {
|
|
3
|
+
[key: string]: string | number;
|
|
4
|
+
};
|
|
5
|
+
sk: {
|
|
6
|
+
[key: string]: string | number;
|
|
7
|
+
} | never;
|
|
8
|
+
compositeSk: never | string;
|
|
9
|
+
}
|
|
10
|
+
export interface SecondaryIndexIrShape extends PrimaryIndexIrShape {
|
|
11
|
+
defaultQueryFieldSuffix: string;
|
|
12
|
+
queryField: string;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IndexShapes.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Select.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/esm/util/index.d.ts
CHANGED