@aws-amplify/data-schema 0.17.1 → 0.18.1
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/SchemaProcessor.js +3 -0
- package/dist/cjs/SchemaProcessor.js.map +1 -1
- package/dist/esm/ClientSchema.d.ts +5 -1
- package/dist/esm/CustomOperation.d.ts +2 -2
- package/dist/esm/MappedTypes/CustomOperations.d.ts +2 -2
- package/dist/esm/SchemaProcessor.mjs +3 -0
- package/dist/esm/SchemaProcessor.mjs.map +1 -1
- package/dist/esm/runtime/client/index.d.ts +1 -1
- package/dist/meta/cjs.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/ClientSchema.ts +10 -7
- package/src/CustomOperation.ts +2 -2
- package/src/MappedTypes/CustomOperations.ts +2 -2
- package/src/SchemaProcessor.ts +6 -0
- package/src/runtime/client/index.ts +7 -3
package/package.json
CHANGED
package/src/ClientSchema.ts
CHANGED
|
@@ -74,14 +74,17 @@ type InternalClientSchema<
|
|
|
74
74
|
ResolvedFields,
|
|
75
75
|
NonModelTypes
|
|
76
76
|
>['customOperations']
|
|
77
|
-
> &
|
|
78
|
-
ResolvedFields
|
|
79
|
-
[
|
|
80
|
-
SecondaryIndexes &
|
|
81
|
-
RelationalMetadata<ResolvedSchema, ResolvedFields, IdentifierMeta> &
|
|
82
|
-
NonModelTypes &
|
|
83
|
-
ResolveCustomOperations<Schema, ResolvedFields, NonModelTypes>;
|
|
77
|
+
> & {
|
|
78
|
+
[K in keyof ResolvedFields]: {
|
|
79
|
+
type: ResolvedFields[K];
|
|
84
80
|
};
|
|
81
|
+
} & {
|
|
82
|
+
[__modelMeta__]: IdentifierMeta &
|
|
83
|
+
SecondaryIndexes &
|
|
84
|
+
RelationalMetadata<ResolvedSchema, ResolvedFields, IdentifierMeta> &
|
|
85
|
+
NonModelTypes &
|
|
86
|
+
ResolveCustomOperations<Schema, ResolvedFields, NonModelTypes>;
|
|
87
|
+
};
|
|
85
88
|
|
|
86
89
|
type GetInternalClientSchema<Schema> =
|
|
87
90
|
Schema extends GenericModelSchema<any> ? InternalClientSchema<Schema> : never;
|
package/src/CustomOperation.ts
CHANGED
|
@@ -237,7 +237,7 @@ export function query(): CustomOperation<
|
|
|
237
237
|
typeName: 'Query';
|
|
238
238
|
handlers: null;
|
|
239
239
|
},
|
|
240
|
-
|
|
240
|
+
'for',
|
|
241
241
|
typeof queryBrand
|
|
242
242
|
> {
|
|
243
243
|
return _custom('Query', queryBrand);
|
|
@@ -258,7 +258,7 @@ export function mutation(): CustomOperation<
|
|
|
258
258
|
typeName: 'Mutation';
|
|
259
259
|
handlers: null;
|
|
260
260
|
},
|
|
261
|
-
|
|
261
|
+
'for',
|
|
262
262
|
typeof mutationBrand
|
|
263
263
|
> {
|
|
264
264
|
return _custom('Mutation', mutationBrand);
|
|
@@ -200,7 +200,7 @@ type IndividualCustomHandlerTypes<Op extends CustomOperationMinimalDef> = {
|
|
|
200
200
|
* }
|
|
201
201
|
* ```
|
|
202
202
|
*/
|
|
203
|
-
|
|
203
|
+
args: Op['arguments'];
|
|
204
204
|
|
|
205
205
|
/**
|
|
206
206
|
* The return type expected by a lambda function handler.
|
|
@@ -217,7 +217,7 @@ type IndividualCustomHandlerTypes<Op extends CustomOperationMinimalDef> = {
|
|
|
217
217
|
* }
|
|
218
218
|
* ```
|
|
219
219
|
*/
|
|
220
|
-
|
|
220
|
+
returnType: LambdaReturnType<Op['returnType']>;
|
|
221
221
|
};
|
|
222
222
|
|
|
223
223
|
/**
|
package/src/SchemaProcessor.ts
CHANGED
|
@@ -1270,6 +1270,12 @@ function validateCustomOperations(
|
|
|
1270
1270
|
}
|
|
1271
1271
|
}
|
|
1272
1272
|
|
|
1273
|
+
if (opType !== 'Subscription' && subscriptionSource.length > 0) {
|
|
1274
|
+
throw new Error(
|
|
1275
|
+
`The .for() modifier function can only be used with a custom subscription. ${typeName} is not a custom subscription.`,
|
|
1276
|
+
);
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1273
1279
|
if (opType === 'Subscription') {
|
|
1274
1280
|
if (subscriptionSource.length < 1) {
|
|
1275
1281
|
throw new Error(
|
|
@@ -720,17 +720,21 @@ export type ModelTypes<
|
|
|
720
720
|
>]: ModelName extends string
|
|
721
721
|
? Schema[ModelName] extends Record<string, unknown>
|
|
722
722
|
? Context extends 'CLIENT'
|
|
723
|
-
? ModelTypesClient<
|
|
723
|
+
? ModelTypesClient<
|
|
724
|
+
ModelName,
|
|
725
|
+
Schema[ModelName]['type'],
|
|
726
|
+
ModelMeta[ModelName]
|
|
727
|
+
>
|
|
724
728
|
: Context extends 'COOKIES'
|
|
725
729
|
? ModelTypesSSRCookies<
|
|
726
730
|
ModelName,
|
|
727
|
-
Schema[ModelName],
|
|
731
|
+
Schema[ModelName]['type'],
|
|
728
732
|
ModelMeta[ModelName]
|
|
729
733
|
>
|
|
730
734
|
: Context extends 'REQUEST'
|
|
731
735
|
? ModelTypesSSRRequest<
|
|
732
736
|
ModelName,
|
|
733
|
-
Schema[ModelName],
|
|
737
|
+
Schema[ModelName]['type'],
|
|
734
738
|
ModelMeta[ModelName]
|
|
735
739
|
>
|
|
736
740
|
: never
|