@aws-amplify/data-schema 0.16.1 → 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/package.json
CHANGED
|
@@ -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
|
>;
|