@aws-amplify/data-schema 0.16.0 → 0.16.2
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/runtime/index.v3.js +0 -5
- package/dist/cjs/runtime/index.v3.js.map +1 -1
- package/dist/esm/MappedTypes/CustomOperations.d.ts +4 -4
- package/dist/esm/MappedTypes/ResolveFieldProperties.d.ts +2 -2
- package/dist/esm/runtime/bridge-types.d.ts +1 -1
- package/dist/esm/runtime/client/index.v3.d.ts +40 -0
- package/dist/esm/runtime/index.v3.d.ts +2 -3
- package/dist/esm/runtime/index.v3.mjs +0 -2
- package/dist/esm/runtime/index.v3.mjs.map +1 -1
- package/dist/meta/cjs.tsbuildinfo +1 -1
- package/package.json +2 -1
- package/runtime/package.json +14 -2
- package/src/MappedTypes/CustomOperations.ts +23 -22
- package/src/MappedTypes/ResolveFieldProperties.ts +2 -2
- package/src/runtime/bridge-types.ts +1 -1
- package/src/runtime/client/index.v3.ts +46 -0
- package/src/runtime/index.v3.ts +8 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-amplify/data-schema",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.2",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"./runtime": {
|
|
36
36
|
"types": "./dist/esm/runtime/index.d.ts",
|
|
37
|
+
"types@<5": "./dist/esm/runtime/index.v3.d.ts",
|
|
37
38
|
"import": "./dist/esm/runtime/index.mjs",
|
|
38
39
|
"require": "./dist/cjs/runtime/index.js",
|
|
39
40
|
"node": "./dist/esm/index.mjs"
|
package/runtime/package.json
CHANGED
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-amplify/data-schema/runtime",
|
|
3
3
|
"main": "../dist/cjs/runtime/index.js",
|
|
4
|
+
"typings": "./defer-to-types-versions",
|
|
4
5
|
"module": "../dist/esm/runtime/index.mjs",
|
|
5
|
-
"types": "../dist/esm/runtime/index.d.ts",
|
|
6
6
|
"react-native": "../src/runtime/index.ts",
|
|
7
|
-
"sideEffects": false
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"typesVersions": {
|
|
9
|
+
"<5": {
|
|
10
|
+
"defer-to-types-versions": [
|
|
11
|
+
"../dist/esm/runtime/index.v3.d.ts"
|
|
12
|
+
]
|
|
13
|
+
},
|
|
14
|
+
">=5": {
|
|
15
|
+
"defer-to-types-versions": [
|
|
16
|
+
"../dist/esm/runtime/index.d.ts"
|
|
17
|
+
]
|
|
18
|
+
}
|
|
19
|
+
}
|
|
8
20
|
}
|
|
@@ -7,7 +7,7 @@ import type {
|
|
|
7
7
|
import type { ModelField } from '../ModelField';
|
|
8
8
|
import type { RefType, RefTypeParamShape } from '../RefType';
|
|
9
9
|
import type {
|
|
10
|
-
|
|
10
|
+
ResolveFieldRequirements,
|
|
11
11
|
ResolveRefsOfCustomType,
|
|
12
12
|
ResolveRefValueArrayTraits,
|
|
13
13
|
} from './ResolveFieldProperties';
|
|
@@ -66,7 +66,7 @@ export type CustomOpShapes<Schema extends GenericModelSchema<any>> = {
|
|
|
66
66
|
export type CustomOpArguments<Shape extends CustomOperationParamShape> =
|
|
67
67
|
Shape['arguments'] extends null
|
|
68
68
|
? never
|
|
69
|
-
: {
|
|
69
|
+
: ResolveFieldRequirements<{
|
|
70
70
|
[FieldName in keyof Shape['arguments']]: Shape['arguments'][FieldName] extends ModelField<
|
|
71
71
|
infer R,
|
|
72
72
|
any,
|
|
@@ -74,7 +74,7 @@ export type CustomOpArguments<Shape extends CustomOperationParamShape> =
|
|
|
74
74
|
>
|
|
75
75
|
? R
|
|
76
76
|
: never;
|
|
77
|
-
}
|
|
77
|
+
}>;
|
|
78
78
|
|
|
79
79
|
/**
|
|
80
80
|
* Computes the return type from the `returnType` of a custom operation shape.
|
|
@@ -106,12 +106,12 @@ export type CustomOpReturnType<
|
|
|
106
106
|
? R
|
|
107
107
|
: Shape['returnType'] extends CustomType<infer R>
|
|
108
108
|
?
|
|
109
|
-
|
|
|
109
|
+
| ResolveFieldRequirements<
|
|
110
110
|
FieldTypesOfCustomType<{
|
|
111
111
|
thisCustomType: R['fields'];
|
|
112
112
|
}>['thisCustomType']
|
|
113
113
|
> // The inline `.customType()` with a custom operation doesn't have
|
|
114
|
-
|
|
114
|
+
// `.required()` modifier, hence it's nullable
|
|
115
115
|
| null
|
|
116
116
|
: never;
|
|
117
117
|
|
|
@@ -237,20 +237,21 @@ export type CustomOperationHandlerTypes<
|
|
|
237
237
|
*
|
|
238
238
|
* (Custom handlers should not return lazy loaded fields -- they're *lazy loaded*.)
|
|
239
239
|
*/
|
|
240
|
-
type LambdaReturnType<T> =
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
T,
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
240
|
+
type LambdaReturnType<T> =
|
|
241
|
+
T extends Record<string, any>
|
|
242
|
+
? {
|
|
243
|
+
// Return type can include `null | undefined`, which we can't meaningfully
|
|
244
|
+
// map over.
|
|
245
|
+
[K in keyof Exclude<T, null | undefined> as Exclude<
|
|
246
|
+
T,
|
|
247
|
+
null | undefined
|
|
248
|
+
>[K] extends (...args: any) => any
|
|
249
|
+
? never
|
|
250
|
+
: K]: Exclude<T, null | undefined>[K];
|
|
251
|
+
}
|
|
252
|
+
:
|
|
253
|
+
| T
|
|
254
|
+
// If the original return type allowed null | undefined, mix them back into
|
|
255
|
+
// the final return type
|
|
256
|
+
| (null extends T ? null : never)
|
|
257
|
+
| (undefined extends T ? undefined : never);
|
|
@@ -138,10 +138,10 @@ export type ResolveRefsOfCustomType<
|
|
|
138
138
|
? ResolveRef<NonModelTypes, R>
|
|
139
139
|
: T[Prop];
|
|
140
140
|
} extends infer Resolved
|
|
141
|
-
?
|
|
141
|
+
? ResolveFieldRequirements<Resolved>
|
|
142
142
|
: never;
|
|
143
143
|
|
|
144
|
-
export type
|
|
144
|
+
export type ResolveFieldRequirements<Resolved> = Intersection<
|
|
145
145
|
ExtractNullableFieldsToOptionalFields<Resolved>,
|
|
146
146
|
ExtractNonNullableFieldsToRequiredFields<Resolved>
|
|
147
147
|
>;
|
|
@@ -355,7 +355,7 @@ export type ClientInternals = {
|
|
|
355
355
|
headers: CustomHeaders | undefined;
|
|
356
356
|
};
|
|
357
357
|
|
|
358
|
-
export type ClientInternalsGetter = (client:
|
|
358
|
+
export type ClientInternalsGetter = (client: BaseClient) => ClientInternals;
|
|
359
359
|
|
|
360
360
|
export type BaseClient = BaseBrowserClient | BaseSSRClient;
|
|
361
361
|
|
|
@@ -31,6 +31,17 @@ export type CustomHeaders =
|
|
|
31
31
|
| Record<string, string>
|
|
32
32
|
| (() => Promise<Record<string, string>>);
|
|
33
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Request options that are passed to custom header functions.
|
|
36
|
+
* `method` and `headers` are not included in custom header functions passed to
|
|
37
|
+
* subscriptions.
|
|
38
|
+
*/
|
|
39
|
+
export type RequestOptions = {
|
|
40
|
+
url: string;
|
|
41
|
+
queryString: string;
|
|
42
|
+
method?: string;
|
|
43
|
+
};
|
|
44
|
+
|
|
34
45
|
export type CustomQueries<
|
|
35
46
|
Schema extends Record<any, any>,
|
|
36
47
|
_Context extends string = 'CLIENT',
|
|
@@ -50,3 +61,38 @@ export type CustomSubscriptions<
|
|
|
50
61
|
> = any;
|
|
51
62
|
|
|
52
63
|
export type ModelSortDirection = 'ASC' | 'DESC';
|
|
64
|
+
|
|
65
|
+
export type ClientExtensions<T extends Record<any, any> = never> = {
|
|
66
|
+
models: ModelTypes<T>;
|
|
67
|
+
enums: EnumTypes<T>;
|
|
68
|
+
queries: CustomQueries<T, 'CLIENT'>;
|
|
69
|
+
mutations: CustomMutations<T, 'CLIENT'>;
|
|
70
|
+
subscriptions: CustomSubscriptions<T, 'CLIENT'>;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export type ClientExtensionsSSRRequest<T extends Record<any, any> = never> = {
|
|
74
|
+
models: ModelTypes<T, 'REQUEST'>;
|
|
75
|
+
enums: EnumTypes<T>;
|
|
76
|
+
queries: CustomQueries<T, 'REQUEST'>;
|
|
77
|
+
mutations: CustomMutations<T, 'REQUEST'>;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export type ClientExtensionsSSRCookies<T extends Record<any, any> = never> = {
|
|
81
|
+
models: ModelTypes<T, 'COOKIES'>;
|
|
82
|
+
enums: EnumTypes<T>;
|
|
83
|
+
queries: CustomQueries<T, 'COOKIES'>;
|
|
84
|
+
mutations: CustomMutations<T, 'COOKIES'>;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export type ClientInternals = {
|
|
88
|
+
amplify: any;
|
|
89
|
+
authMode: any;
|
|
90
|
+
authToken: string | undefined;
|
|
91
|
+
headers: CustomHeaders | undefined;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export type BaseClient = {
|
|
95
|
+
graphql(...args: any): Promise<Record<string, any>>;
|
|
96
|
+
cancel(promise: Promise<any>, message?: string): boolean;
|
|
97
|
+
isCancelError(error: any): boolean;
|
|
98
|
+
};
|
package/src/runtime/index.v3.ts
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
export * from './client/index.v3';
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
export declare function addSchemaToClient<_T extends Record<any, any> = never>(
|
|
6
|
+
client: any,
|
|
7
|
+
apiGraphqlConfig: any,
|
|
8
|
+
getInternals: any,
|
|
9
|
+
): any;
|
|
10
|
+
export declare function addSchemaToClientWithInstance<
|
|
11
|
+
_T extends Record<any, any>,
|
|
12
|
+
>(client: any, params: any, getInternals: any): any;
|