@aws-amplify/data-schema 1.2.9 → 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 +6 -3
- 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 +8 -2
- 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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClientCustomOperations.js","sources":["../../../../src/ClientSchema/Core/ClientCustomOperations.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClientCustomType.js","sources":["../../../../src/ClientSchema/Core/ClientCustomType.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClientEnum.js","sources":["../../../../src/ClientSchema/Core/ClientEnum.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClientModel.js","sources":["../../../../src/ClientSchema/Core/ClientModel.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClientSchemaProperty.js","sources":["../../../../src/ClientSchema/Core/ClientSchemaProperty.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/ClientSchema/Core/index.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/ClientSchema/index.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExtractNestedTypes.js","sources":["../../../../src/ClientSchema/utilities/ExtractNestedTypes.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResolveField.js","sources":["../../../../src/ClientSchema/utilities/ResolveField.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResolveRef.js","sources":["../../../../src/ClientSchema/utilities/ResolveRef.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchemaMetadata.js","sources":["../../../../src/ClientSchema/utilities/SchemaMetadata.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
tslib_1.__exportStar(require("./ExtractNestedTypes"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./ResolveField"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./ResolveRef"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./SchemaMetadata"), exports);
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/ClientSchema/utilities/index.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nconst tslib_1 = require(\"tslib\");\ntslib_1.__exportStar(require(\"./ExtractNestedTypes\"), exports);\ntslib_1.__exportStar(require(\"./ResolveField\"), exports);\ntslib_1.__exportStar(require(\"./ResolveRef\"), exports);\ntslib_1.__exportStar(require(\"./SchemaMetadata\"), exports);\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AACjC,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,sBAAsB,CAAC,EAAE,OAAO,CAAC,CAAC;AAC/D,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC,CAAC;AACzD,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC,CAAC;AACvD,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAAE,OAAO,CAAC;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Not actually sure if/how customer can pass this through as variables yet.
|
|
5
|
+
* Leaving it out for now:
|
|
6
|
+
*
|
|
7
|
+
* attributeType: "binary" | "binarySet" | "bool" | "list" | "map" | "number" | "numberSet" | "string" | "stringSet" | "_null"
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
//# sourceMappingURL=Filters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Filters.js","sources":["../../../src/util/Filters.ts"],"sourcesContent":["\"use strict\";\n/**\n * Not actually sure if/how customer can pass this through as variables yet.\n * Leaving it out for now:\n *\n * attributeType: \"binary\" | \"binarySet\" | \"bool\" | \"list\" | \"map\" | \"number\" | \"numberSet\" | \"string\" | \"stringSet\" | \"_null\"\n */\nObject.defineProperty(exports, \"__esModule\", { value: true });\n"],"names":[],"mappings":";;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IndexShapes.js","sources":["../../../src/util/IndexShapes.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Select.js","sources":["../../../src/util/Select.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;;"}
|
|
@@ -319,9 +319,9 @@ declare function resourceTo<SELF extends ResourceAuthorization>(this: SELF, oper
|
|
|
319
319
|
* ```
|
|
320
320
|
*/
|
|
321
321
|
export type ImpliedAuthField<T extends Authorization<any, any, any>> = T extends Authorization<infer _Strat, infer Field, infer isMulti> ? Field extends undefined ? never : Field extends string ? isMulti extends true ? {
|
|
322
|
-
[K in Field]?: string[];
|
|
322
|
+
[K in Field]?: string[] | null | undefined;
|
|
323
323
|
} : {
|
|
324
|
-
[K in Field]?: string;
|
|
324
|
+
[K in Field]?: string | null | undefined;
|
|
325
325
|
} : never : never;
|
|
326
326
|
/**
|
|
327
327
|
* Turns the type from a list of `Authorization` rules like this:
|
|
@@ -348,7 +348,7 @@ export type ImpliedAuthFields<T extends Authorization<any, any, any>> = ImpliedA
|
|
|
348
348
|
export declare const accessData: <T extends Authorization<any, any, any>>(authorization: T) => {
|
|
349
349
|
strategy?: any;
|
|
350
350
|
provider?: "function" | "userPools" | "oidc" | "identityPool" | "apiKey" | undefined;
|
|
351
|
-
operations?: ("
|
|
351
|
+
operations?: ("search" | "create" | "update" | "delete" | "read" | "get" | "list" | "sync" | "listen")[] | undefined;
|
|
352
352
|
groupOrOwnerField?: any;
|
|
353
353
|
groups?: string[] | undefined;
|
|
354
354
|
multiOwner: any;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { CustomOperationParamShape } from '../../CustomOperation';
|
|
2
|
+
import type { BaseModelField } from '../../ModelField';
|
|
3
|
+
import type { RefType } from '../../RefType';
|
|
4
|
+
import type { ResolveFieldRequirements } from '../../MappedTypes/ResolveFieldProperties';
|
|
5
|
+
import type { AppSyncResolverHandler } from 'aws-lambda';
|
|
6
|
+
import type { CustomType } from '../../CustomType';
|
|
7
|
+
import type { FieldTypesOfCustomType } from '../../MappedTypes/ResolveSchema';
|
|
8
|
+
import type { ResolveRef } from '../utilities/ResolveRef';
|
|
9
|
+
import { ClientSchemaProperty } from './ClientSchemaProperty';
|
|
10
|
+
type CustomOperationSubType<Op extends CustomOperationParamShape> = `custom${Op['typeName']}`;
|
|
11
|
+
/**
|
|
12
|
+
* Derives the signature and types for a lambda handler for a particular
|
|
13
|
+
* custom Query or Mutation from a Schema.
|
|
14
|
+
*/
|
|
15
|
+
export interface ClientCustomOperation<RefBag extends Record<any, any>, Op extends CustomOperationParamShape> extends ClientSchemaProperty {
|
|
16
|
+
__entityType: CustomOperationSubType<Op>;
|
|
17
|
+
operationType: Op['typeName'];
|
|
18
|
+
/**
|
|
19
|
+
* Handler type for lambda function implementations. E.g.,
|
|
20
|
+
*
|
|
21
|
+
* ```typescript
|
|
22
|
+
* import type { Schema } from './resource';
|
|
23
|
+
*
|
|
24
|
+
* export const handler: Schema['echo']['functionHandler'] = async (event, context) => {
|
|
25
|
+
* // event and context will be fully typed inside here.
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
functionHandler: AppSyncResolverHandler<CustomOpArguments<Op>, LambdaReturnType<CustomOpReturnType<Op, RefBag>>>;
|
|
30
|
+
/**
|
|
31
|
+
* The `context.arguments` type for lambda function implementations.
|
|
32
|
+
*
|
|
33
|
+
* ```typescript
|
|
34
|
+
* import type { Schema } from './resource';
|
|
35
|
+
*
|
|
36
|
+
* export const handler: Schema['echo']['functionHandler'] = async (event, context) => {
|
|
37
|
+
* // Provides this type, if needed:
|
|
38
|
+
* const args: Schema['echo']['functionHandlerArguments'] = event.arguments;
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
args: CustomOpArguments<Op>;
|
|
43
|
+
/**
|
|
44
|
+
* The return type expected by a lambda function handler.
|
|
45
|
+
*
|
|
46
|
+
* ```typescript
|
|
47
|
+
* import type { Schema } from './resource';
|
|
48
|
+
*
|
|
49
|
+
* export const handler: Schema['echo']['functionHandler'] = async (event, context) => {
|
|
50
|
+
* // Result type enforced here:
|
|
51
|
+
* const result: Schema['echo']['functionHandlerResult'] = buildResult(...);
|
|
52
|
+
*
|
|
53
|
+
* // `Result` type matches expected function return type here:
|
|
54
|
+
* return result;
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
returnType: LambdaReturnType<CustomOpReturnType<Op, RefBag>>;
|
|
59
|
+
type: CustomOpReturnType<Op, RefBag>;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Digs out custom operation arguments, mapped to the intended graphql types.
|
|
63
|
+
*/
|
|
64
|
+
type CustomOpArguments<Shape extends CustomOperationParamShape> = Shape['arguments'] extends null ? never : ResolveFieldRequirements<{
|
|
65
|
+
[FieldName in keyof Shape['arguments']]: Shape['arguments'][FieldName] extends BaseModelField<infer R> ? R : never;
|
|
66
|
+
}>;
|
|
67
|
+
/**
|
|
68
|
+
* Removes `null | undefined` from the return type if the operation is a subscription,
|
|
69
|
+
* since subs don't fire on empty/non-existent values.
|
|
70
|
+
*/
|
|
71
|
+
type Normalize<Shape extends CustomOperationParamShape, RT> = Shape['typeName'] extends 'Subscription' ? Exclude<RT, null | undefined> : RT;
|
|
72
|
+
/**
|
|
73
|
+
* Computes the return type from the `returnType` of a custom operation shape.
|
|
74
|
+
*
|
|
75
|
+
* This entails dereferencing refs and inferring graphql types from field-type defs.
|
|
76
|
+
*/
|
|
77
|
+
type CustomOpReturnType<Shape extends CustomOperationParamShape, RefBag extends Record<string, any>> = Normalize<Shape, Shape['returnType'] extends RefType<infer RefShape, any, any> ? RefShape['link'] extends keyof RefBag ? ResolveRef<RefShape, RefBag> : never : Shape['returnType'] extends BaseModelField<infer R> ? R : Shape['returnType'] extends CustomType<infer R> ? ResolveFieldRequirements<FieldTypesOfCustomType<{
|
|
78
|
+
thisCustomType: R['fields'];
|
|
79
|
+
}>['thisCustomType']> | null : never>;
|
|
80
|
+
/**
|
|
81
|
+
* Returns a return type with lazy loaders removed.
|
|
82
|
+
*
|
|
83
|
+
* (Custom handlers should not return lazy loaded fields -- they're *lazy loaded*.)
|
|
84
|
+
*/
|
|
85
|
+
type LambdaReturnType<T> = T extends Array<infer RT> ? Array<LambdaReturnType<RT>> : T extends Record<string, any> ? {
|
|
86
|
+
[K in keyof Exclude<T, null | undefined> as Exclude<T, null | undefined>[K] extends (...args: any) => any ? never : K]: Exclude<T, null | undefined>[K];
|
|
87
|
+
} : T | (null extends T ? null : never) | (undefined extends T ? undefined : never);
|
|
88
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClientCustomOperations.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CustomTypeParamShape } from '../../CustomType';
|
|
2
|
+
import { ClientSchemaProperty } from './ClientSchemaProperty';
|
|
3
|
+
import { ResolveFields } from '../utilities/ResolveField';
|
|
4
|
+
export interface ClientCustomType<Bag extends Record<string, unknown>, T extends CustomTypeParamShape> extends ClientSchemaProperty {
|
|
5
|
+
__entityType: 'customType';
|
|
6
|
+
type: ResolveFields<Bag, T['fields']>;
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClientCustomType.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClientEnum.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import type { deferredRefResolvingPrefix, ModelTypeParamShape, ModelDefaultIdentifier } from '../../ModelType';
|
|
2
|
+
import type { ClientSchemaProperty } from './ClientSchemaProperty';
|
|
3
|
+
import type { Authorization, ImpliedAuthFields } from '../../Authorization';
|
|
4
|
+
import type { SchemaMetadata, ResolveFields } from '../utilities';
|
|
5
|
+
import type { IsEmptyStringOrNever, UnionToIntersection, Equal, Prettify } from '@aws-amplify/data-schema-types';
|
|
6
|
+
import type { ModelField } from '../../ModelField';
|
|
7
|
+
import type { ModelRelationalField } from '../../ModelRelationalField';
|
|
8
|
+
import type { EnumType } from '../../EnumType';
|
|
9
|
+
import type { CustomType, CustomTypeParamShape } from '../../CustomType';
|
|
10
|
+
import type { RefType } from '../../RefType';
|
|
11
|
+
import type { StringFilter, NumericFilter, ModelPrimaryCompositeKeyInput, PrimaryIndexIrShape, SecondaryIndexIrShape } from '../../util';
|
|
12
|
+
export interface ClientModel<Bag extends Record<string, unknown>, Metadata extends SchemaMetadata<any>, IsRDS extends boolean, T extends ModelTypeParamShape, K extends keyof Bag & string> extends ClientSchemaProperty {
|
|
13
|
+
__entityType: 'model';
|
|
14
|
+
type: ShallowPretty<ClientFields<Bag, Metadata, IsRDS, T>>;
|
|
15
|
+
createType: Prettify<CreateModelInput<ClientModel<Bag, Metadata, IsRDS, T, K>>>;
|
|
16
|
+
updateType: Prettify<UpdateModelInput<ClientModel<Bag, Metadata, IsRDS, T, K>>>;
|
|
17
|
+
deleteType: Prettify<ModelIdentifier<Bag, T>>;
|
|
18
|
+
identifier: ShallowPretty<ModelIdentifier<Bag, T>>;
|
|
19
|
+
nestedTypes: NestedTypes<ClientFields<Bag, Metadata, IsRDS, T>, T>;
|
|
20
|
+
secondaryIndexes: IndexQueryMethodsFromIR<Bag, T['secondaryIndexes'], K>;
|
|
21
|
+
__meta: {
|
|
22
|
+
listOptionsPkParams: ListOptionsPkParams<Bag, T>;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
type ShallowPretty<T> = {
|
|
26
|
+
[K in keyof T]: T[K];
|
|
27
|
+
};
|
|
28
|
+
type ClientFields<Bag extends Record<string, unknown>, Metadata extends SchemaMetadata<any>, IsRDS extends boolean, T extends ModelTypeParamShape> = ResolveFields<Bag, T['fields']> & If<Not<IsRDS>, ImplicitIdentifier<T>> & AuthFields<Metadata, T> & Omit<SystemFields<IsRDS>, keyof ResolveFields<Bag, T['fields']>>;
|
|
29
|
+
type SystemFields<IsRDS extends boolean> = IsRDS extends false ? {
|
|
30
|
+
readonly createdAt: string;
|
|
31
|
+
readonly updatedAt: string;
|
|
32
|
+
} : object;
|
|
33
|
+
type ModelIdentifier<Bag extends Record<string, unknown>, T extends ModelTypeParamShape> = ResolveIdentifierFields<ResolveFields<Bag, T['fields']>, T['identifier']['pk'] & (T['identifier']['sk'] extends never ? unknown : T['identifier']['sk'])>;
|
|
34
|
+
/**
|
|
35
|
+
* Separate util for *injecting* the default implicit identifier for performance
|
|
36
|
+
* reasons. The full ModelIdentifer util needs to extract types from the fields
|
|
37
|
+
* matching the explicitly defined field types. Contrast that to **injecting** PK
|
|
38
|
+
* fields into the model, which is only done specifically when the default of
|
|
39
|
+
* `readonly id: string` is being injected IF AND ONLY IF another `id` field is
|
|
40
|
+
* not already present on the model.
|
|
41
|
+
*/
|
|
42
|
+
type ImplicitIdentifier<T extends ModelTypeParamShape> = T['identifier']['pk'] extends ModelDefaultIdentifier['pk'] ? 'id' extends keyof T['fields'] ? unknown : ModelDefaultIdentifier['pk'] : unknown;
|
|
43
|
+
type ResolveIdentifierFields<Model, IdentifierFields> = {
|
|
44
|
+
[K in keyof IdentifierFields]: K extends keyof Model ? Model[K] : string;
|
|
45
|
+
};
|
|
46
|
+
type If<ConditionResult extends boolean, IfTrueValue, IfFalseValue = unknown> = ConditionResult extends true ? IfTrueValue : IfFalseValue;
|
|
47
|
+
type Not<T extends boolean> = T extends true ? false : true;
|
|
48
|
+
/**
|
|
49
|
+
* Models with composite PKs defined are expected to contain the model's pk, sk, and sortDirection properties in the `options` param
|
|
50
|
+
*
|
|
51
|
+
* @returns an object containing additional `options` properties for models with a composite primary index
|
|
52
|
+
*
|
|
53
|
+
*/
|
|
54
|
+
export type ListOptionsPkParams<Bag extends Record<string, unknown>, T extends ModelTypeParamShape> = T['identifier']['sk'] extends never ? unknown : Prettify<Partial<IndexQueryInput<Bag, T['identifier']>>>;
|
|
55
|
+
type AuthFields<SchemaMeta extends SchemaMetadata<any>, Model extends ModelTypeParamShape> = (Model['authorization'][number] extends never ? SchemaMeta['authFields'] extends never ? object : SchemaMeta['authFields'] : ImpliedAuthFields<Model['authorization'][number]> extends never ? object : ImpliedAuthFields<Model['authorization'][number]>) & ImpliedAuthFieldsFromFields<Model>;
|
|
56
|
+
type ImpliedAuthFieldsFromFields<T> = UnionToIntersection<T extends ModelTypeParamShape ? T['fields'][keyof T['fields']] extends ModelField<any, any, infer Auth> | ModelRelationalField<any, any, any, infer Auth> | RefType<any, any, infer Auth> ? Auth extends Authorization<any, any, any> ? ImpliedAuthFields<Auth> : object : object : object>;
|
|
57
|
+
type NestedTypes<Bag extends Record<string, unknown>, T extends ModelTypeParamShape> = {
|
|
58
|
+
[K in keyof T['fields'] as T['fields'][K] extends EnumType | CustomType<CustomTypeParamShape> ? K : never]: K extends keyof Bag ? {
|
|
59
|
+
__entityType: T['fields'][K] extends EnumType ? 'enum' : 'customType';
|
|
60
|
+
type: Exclude<Bag[K], null | undefined>;
|
|
61
|
+
} : never;
|
|
62
|
+
};
|
|
63
|
+
type IndexQueryMethodsFromIR<Bag extends Record<string, unknown>, Indexes, ModelName extends string, Res = unknown> = Indexes extends [
|
|
64
|
+
infer A extends SecondaryIndexIrShape,
|
|
65
|
+
...infer B extends SecondaryIndexIrShape[]
|
|
66
|
+
] ? IndexQueryMethodsFromIR<Bag, B, ModelName, IndexQueryMethodSignature<Bag, A, ModelName> & Res> : Res;
|
|
67
|
+
type IndexQueryMethodSignature<Bag extends Record<string, unknown>, Idx extends SecondaryIndexIrShape, ModelName extends string> = Record<IsEmptyStringOrNever<Idx['queryField']> extends false ? Idx['queryField'] : `list${ModelName}By${Idx['defaultQueryFieldSuffix']}`, {
|
|
68
|
+
input: IndexQueryInput<Bag, Idx>;
|
|
69
|
+
}>;
|
|
70
|
+
/**
|
|
71
|
+
* Accepts a PrimaryIndexIr or SecondaryIndexIr and returns resolved parameters
|
|
72
|
+
*
|
|
73
|
+
* TODO: Get rid of the `deferredRefResolvingPrefix` reference hack.
|
|
74
|
+
* Instead, just dereference refs as usual?
|
|
75
|
+
*/
|
|
76
|
+
export type IndexQueryInput<Bag extends Record<string, unknown>, Idx extends PrimaryIndexIrShape> = {
|
|
77
|
+
[PKField in keyof Idx['pk']]: Idx['pk'][PKField] extends `${deferredRefResolvingPrefix}${infer R}` ? 'type' extends keyof Bag[R] ? Bag[R]['type'] : never : Idx['pk'][PKField];
|
|
78
|
+
} & (Idx['compositeSk'] extends never ? {
|
|
79
|
+
[SKField in keyof Idx['sk']]+?: number extends Idx['sk'][SKField] ? NumericFilter : Idx['sk'][SKField] extends `${deferredRefResolvingPrefix}${infer R}` ? 'type' extends keyof Bag[R] ? Bag[R]['type'] extends string ? StringFilter<Bag[R]['type']> : never : never : StringFilter<Idx['sk'][SKField] & string>;
|
|
80
|
+
} : {
|
|
81
|
+
[CompositeSk in Idx['compositeSk']]+?: ModelPrimaryCompositeKeyInput<{
|
|
82
|
+
[SKField in keyof Idx['sk']]: Idx['sk'][SKField] extends `${deferredRefResolvingPrefix}${infer _R}` ? string : Idx['sk'][SKField];
|
|
83
|
+
}>;
|
|
84
|
+
});
|
|
85
|
+
/**
|
|
86
|
+
*
|
|
87
|
+
* TEMP
|
|
88
|
+
* ---++---
|
|
89
|
+
* ||
|
|
90
|
+
* ||
|
|
91
|
+
* \^^/
|
|
92
|
+
* \/
|
|
93
|
+
*/
|
|
94
|
+
/**
|
|
95
|
+
* All required fields and relational fields, exclude readonly fields
|
|
96
|
+
*/
|
|
97
|
+
type MutationInput<Model extends ClientModel<any, any, any, any, any>, WritableFields = Pick<Model['type'], WritableKeys<Model['type']>>> = WithNullablesAsOptionalRecursively<{
|
|
98
|
+
[Prop in keyof WritableFields as WritableFields[Prop] extends (...args: any) => any ? never : Prop]: WritableFields[Prop];
|
|
99
|
+
}>;
|
|
100
|
+
type IfEquals<X, Y, A = X, B = never> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? A : B;
|
|
101
|
+
type WritableKeys<T> = {
|
|
102
|
+
[P in keyof T]-?: IfEquals<{
|
|
103
|
+
[Q in P]: T[P];
|
|
104
|
+
}, {
|
|
105
|
+
-readonly [Q in P]: T[P];
|
|
106
|
+
}, P>;
|
|
107
|
+
}[keyof T];
|
|
108
|
+
type MinusReadonly<T> = {
|
|
109
|
+
-readonly [K in keyof T]: T[K];
|
|
110
|
+
};
|
|
111
|
+
type WithNullablesAsOptionalRecursively<T> = T extends Array<any> | ((...args: any) => any) ? T : T extends object ? {
|
|
112
|
+
[K in keyof T as null extends T[K] ? K : never]+?: WithNullablesAsOptionalRecursively<T[K]>;
|
|
113
|
+
} & {
|
|
114
|
+
[K in keyof T as null extends T[K] ? never : K]: WithNullablesAsOptionalRecursively<T[K]>;
|
|
115
|
+
} : T;
|
|
116
|
+
/**
|
|
117
|
+
* All identifiers and fields used to create a model
|
|
118
|
+
*/
|
|
119
|
+
type CreateModelInput<Model extends ClientModel<any, any, any, any, any>> = Equal<MinusReadonly<Model['identifier']>, {
|
|
120
|
+
id: string;
|
|
121
|
+
}> extends true ? Partial<MinusReadonly<Model['identifier']>> & Omit<MutationInput<Model>, 'id'> : MutationInput<Model>;
|
|
122
|
+
type UpdateModelInput<Model extends ClientModel<any, any, any, any, any>> = MinusReadonly<Model['identifier']> & Partial<MutationInput<Model>>;
|
|
123
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClientModel.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClientSchemaProperty.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { ClientCustomOperation } from './ClientCustomOperations';
|
|
2
|
+
export { ClientEnum } from './ClientEnum';
|
|
3
|
+
export { ClientCustomType } from './ClientCustomType';
|
|
4
|
+
export { ClientModel } from './ClientModel';
|
|
5
|
+
export { ClientSchemaProperty } from './ClientSchemaProperty';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { __modelMeta__ } from '../runtime/client';
|
|
2
|
+
import type { BaseSchema, CustomOperation, CustomType, EnumType, GenericModelSchema, ModelSchemaContents, ModelType } from '../ModelSchema';
|
|
3
|
+
import type { ClientCustomOperation, ClientCustomType, ClientEnum, ClientModel } from './Core';
|
|
4
|
+
import type { CombinedModelSchema, CombinedSchemaIndexesUnion } from '../CombineSchema';
|
|
5
|
+
import type { SchemaMetadata } from './utilities/SchemaMetadata';
|
|
6
|
+
import type { Brand, Select, SpreadTuple } from '../util';
|
|
7
|
+
export type ClientSchema<Schema extends GenericModelSchema<any> | CombinedModelSchema<any>> = Schema extends GenericModelSchema<any> ? InternalClientSchema<Schema> : Schema extends CombinedModelSchema<any> ? InternalCombinedSchema<Schema> : never;
|
|
8
|
+
type InternalClientSchema<CustomerSchema extends ModelSchemaContents | BaseSchema<any, any>, Metadata extends SchemaMetadata<any> = never, IsRDS extends boolean = never> = CustomerSchema extends ModelSchemaContents ? {
|
|
9
|
+
[K in keyof CustomerSchema as K extends string ? K : never]: K extends string ? ClientSchemaProperty<CustomerSchema, Metadata, IsRDS, K> : never;
|
|
10
|
+
} : CustomerSchema extends BaseSchema<any, any> ? InternalClientSchema<CustomerSchema['data']['types'], SchemaMetadata<CustomerSchema>, CustomerSchema extends Brand<'RDSSchema'> ? true : false> : never;
|
|
11
|
+
type ClientSchemaProperty<T extends ModelSchemaContents, Metadata extends SchemaMetadata<any>, IsRDS extends boolean, K extends keyof T & string> = T[K] extends Brand<'enum'> ? RemapEnum<T, T[K]> : T[K] extends Brand<'customType'> ? RemapCustomType<T, Metadata, IsRDS, T[K]> : T[K] extends Brand<'queryCustomOperation' | 'mutationCustomOperation' | 'subscriptionCustomOperation'> ? RemapCustomOperation<T, Metadata, IsRDS, T[K]> : T[K] extends Brand<'modelType'> ? RemapModel<T, Metadata, IsRDS, T[K], K> : never;
|
|
12
|
+
type RemapEnum<_T extends ModelSchemaContents, E> = E extends EnumType<infer values> ? ClientEnum<values> : never;
|
|
13
|
+
type RemapCustomType<T extends ModelSchemaContents, Metadata extends SchemaMetadata<any>, IsRDS extends boolean, E> = E extends CustomType<infer CT> ? ClientCustomType<InternalClientSchema<T, Metadata, IsRDS>, CT> : never;
|
|
14
|
+
type RemapCustomOperation<T extends ModelSchemaContents, Metadata extends SchemaMetadata<any>, IsRDS extends boolean, E> = E extends CustomOperation<infer CO, any> ? ClientCustomOperation<InternalClientSchema<T, Metadata, IsRDS>, CO> : never;
|
|
15
|
+
type RemapModel<T extends ModelSchemaContents, Metadata extends SchemaMetadata<any>, IsRDS extends boolean, E, K extends keyof T & string> = E extends ModelType<infer MT, any> ? ClientModel<InternalClientSchema<T, Metadata, IsRDS>, Metadata, IsRDS, MT, K> : never;
|
|
16
|
+
type GetInternalClientSchema<Schema> = Schema extends GenericModelSchema<any> ? InternalClientSchema<Schema> : never;
|
|
17
|
+
type CombinedClientSchemas<Schemas extends CombinedModelSchema<any>['schemas']> = {
|
|
18
|
+
[Index in keyof Schemas]: Index extends CombinedSchemaIndexesUnion ? GetInternalClientSchema<Schemas[Index]> : never;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Types for unwrapping and combining generic type args into client-consumable types
|
|
22
|
+
* for multiple schemas
|
|
23
|
+
*
|
|
24
|
+
* @typeParam Combined - A container of multiple schemas
|
|
25
|
+
*
|
|
26
|
+
* @internal @typeParam ClientSchemas - The tuple of client schemas to combine
|
|
27
|
+
*/
|
|
28
|
+
type InternalCombinedSchema<Combined extends CombinedModelSchema<any>, ClientSchemas extends [...any] = CombinedClientSchemas<Combined['schemas']>> = SpreadTuple<{
|
|
29
|
+
[I in keyof ClientSchemas]: I extends CombinedSchemaIndexesUnion ? Omit<ClientSchemas[I], typeof __modelMeta__> : never;
|
|
30
|
+
}>;
|
|
31
|
+
export type ClientSchemaByEntityTypeBaseShape = {
|
|
32
|
+
enums: Record<string, ClientEnum<any>>;
|
|
33
|
+
customTypes: Record<string, ClientCustomType<any, any>>;
|
|
34
|
+
models: Record<string, ClientModel<any, any, any, any, any>>;
|
|
35
|
+
queries: Record<string, ClientCustomOperation<any, any>>;
|
|
36
|
+
mutations: Record<string, ClientCustomOperation<any, any>>;
|
|
37
|
+
subscriptions: Record<string, ClientCustomOperation<any, any>>;
|
|
38
|
+
};
|
|
39
|
+
export type ClientSchemaByEntityType<T> = {
|
|
40
|
+
enums: Select<T, {
|
|
41
|
+
__entityType: 'enum';
|
|
42
|
+
}>;
|
|
43
|
+
customTypes: Select<T, {
|
|
44
|
+
__entityType: 'customType';
|
|
45
|
+
}>;
|
|
46
|
+
models: Select<T, {
|
|
47
|
+
__entityType: 'model';
|
|
48
|
+
}>;
|
|
49
|
+
queries: Select<T, {
|
|
50
|
+
__entityType: 'customQuery';
|
|
51
|
+
}>;
|
|
52
|
+
mutations: Select<T, {
|
|
53
|
+
__entityType: 'customMutation';
|
|
54
|
+
}>;
|
|
55
|
+
subscriptions: Select<T, {
|
|
56
|
+
__entityType: 'customSubscription';
|
|
57
|
+
}>;
|
|
58
|
+
};
|
|
59
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ClientSchemaByEntityTypeBaseShape } from '..';
|
|
2
|
+
import { UnionToIntersection } from '@aws-amplify/data-schema-types';
|
|
3
|
+
export type ExtractNestedTypes<T extends ClientSchemaByEntityTypeBaseShape> = UnionToIntersection<{
|
|
4
|
+
[ModelName in keyof T['models']]: ModelName extends string ? {
|
|
5
|
+
[TypeName in keyof T['models'][ModelName]['nestedTypes'] as TypeName extends string ? `${ModelName}${Capitalize<TypeName>}` : never]: T['models'][ModelName]['nestedTypes'][TypeName];
|
|
6
|
+
} : never;
|
|
7
|
+
}[keyof T['models']]>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExtractNestedTypes.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { BaseModelField } from '../../ModelField';
|
|
2
|
+
import { ModelRelationalField, ModelRelationalFieldParamShape } from '../../ModelRelationalField';
|
|
3
|
+
import { EnumType } from '../../EnumType';
|
|
4
|
+
import { CustomType } from '../../CustomType';
|
|
5
|
+
import { RefType, RefTypeParamShape } from '../../RefType';
|
|
6
|
+
import { ResolveRef } from './ResolveRef';
|
|
7
|
+
import { LazyLoader } from '../../runtime';
|
|
8
|
+
/**
|
|
9
|
+
* Takes a `ReturnType<typeof a.model()>` and turns it into a client-consumable type. Fields
|
|
10
|
+
* definitions (e.g., `a.string()`) are turned into the client facing types (e.g., `string`),
|
|
11
|
+
* `a.ref()` fields will be resolved, and relationships (e.g., `a.belongsTo()`) will be
|
|
12
|
+
* turned into `LazyLoader` fields (e.g., `post.comments({...})`).
|
|
13
|
+
*
|
|
14
|
+
* The first type parameter (`Bag`) should always just be the top-level `ClientSchema` that
|
|
15
|
+
* references and related model definitions can be resolved against.
|
|
16
|
+
*/
|
|
17
|
+
export type ResolveFields<Bag extends Record<string, any>, T> = ShallowPretty<{
|
|
18
|
+
[K in keyof T as IsRequired<T[K]> extends true ? K : never]: ResolveIndividualField<Bag, T[K]>;
|
|
19
|
+
} & {
|
|
20
|
+
[K in keyof T as IsRequired<T[K]> extends true ? never : K]+?: ResolveIndividualField<Bag, T[K]>;
|
|
21
|
+
}>;
|
|
22
|
+
type ShallowPretty<T> = {
|
|
23
|
+
[K in keyof T]: T[K];
|
|
24
|
+
};
|
|
25
|
+
export type ResolveIndividualField<Bag extends Record<string, any>, T> = T extends BaseModelField<infer FieldShape> ? FieldShape : T extends RefType<infer RefShape, any, any> ? ResolveRef<RefShape, Bag> : T extends ModelRelationalField<infer RelationshipShape, any, any, any> ? ResolveRelationship<Bag, RelationshipShape> : T extends CustomType<infer CT> ? ResolveFields<Bag, CT['fields']> | null : T extends EnumType<infer values> ? values[number] | null : never;
|
|
26
|
+
type ResolveRelationship<Bag extends Record<string, any>, RelationshipShape extends ModelRelationalFieldParamShape> = LazyLoader<RelationshipShape['valueRequired'] extends true ? Bag[RelationshipShape['relatedModel']]['type'] : Bag[RelationshipShape['relatedModel']]['type'] | null, RelationshipShape['array']>;
|
|
27
|
+
type IsRequired<T> = T extends BaseModelField<infer FieldShape> ? null extends FieldShape ? false : true : T extends RefType<infer RefShape, any, any> ? IsRefRequired<RefShape> : T extends ModelRelationalField<any, any, any, any> ? true : T extends CustomType<any> | EnumType<any> ? false : never;
|
|
28
|
+
type IsRefRequired<T extends RefTypeParamShape> = T['array'] extends true ? T['arrayRequired'] : T['valueRequired'];
|
|
29
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResolveField.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|