@aws-amplify/data-schema 0.13.12 → 0.13.13
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.
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { type __modelMeta__ } from '@aws-amplify/data-schema-types';
|
|
2
2
|
import type { ModelSchema } from './ModelSchema';
|
|
3
3
|
import type { ResolveSchema, SchemaTypes } from './MappedTypes/ResolveSchema';
|
|
4
|
-
import type { ResolveFieldProperties } from './MappedTypes/ResolveFieldProperties';
|
|
4
|
+
import type { CreateImplicitModelsFromRelations, ResolveFieldProperties } from './MappedTypes/ResolveFieldProperties';
|
|
5
5
|
import type { ModelIdentifier, ModelSecondaryIndexes, RelationalMetadata } from './MappedTypes/ModelMetadata';
|
|
6
6
|
import type { ExtractNonModelTypes, NonModelTypesShape } from './MappedTypes/ExtractNonModelTypes';
|
|
7
|
-
import { ResolveCustomOperations } from './MappedTypes/CustomOperations';
|
|
7
|
+
import type { ResolveCustomOperations } from './MappedTypes/CustomOperations';
|
|
8
8
|
export type ClientSchema<Schema extends ModelSchema<any, any>> = InternalClientSchema<Schema>;
|
|
9
9
|
/**
|
|
10
10
|
* Types for unwrapping generic type args into client-consumable types
|
|
@@ -24,7 +24,11 @@ export type ClientSchema<Schema extends ModelSchema<any, any>> = InternalClientS
|
|
|
24
24
|
* used by `API.generateClient` to craft strongly typed mutation inputs; hidden from customer-facing types behind __modelMeta__ symbol
|
|
25
25
|
*
|
|
26
26
|
*/
|
|
27
|
-
type InternalClientSchema<Schema extends ModelSchema<any, any>, NonModelTypes extends NonModelTypesShape = ExtractNonModelTypes<Schema>, ResolvedSchema = ResolveSchema<Schema>,
|
|
28
|
-
[
|
|
27
|
+
type InternalClientSchema<Schema extends ModelSchema<any, any>, NonModelTypes extends NonModelTypesShape = ExtractNonModelTypes<Schema>, ResolvedSchema = ResolveSchema<Schema>, ImplicitModels = CreateImplicitModelsFromRelations<ResolvedSchema>, ImplicitModelsIdentifierMeta = {
|
|
28
|
+
[ImplicitModel in keyof ImplicitModels]: {
|
|
29
|
+
identifier: 'id';
|
|
30
|
+
};
|
|
31
|
+
}, ResolvedFields extends Record<string, unknown> = ResolveFieldProperties<Schema, NonModelTypes, ImplicitModels>, IdentifierMeta extends Record<string, any> = ModelIdentifier<SchemaTypes<Schema>>, SecondaryIndexes extends Record<string, any> = ModelSecondaryIndexes<SchemaTypes<Schema>>> = ResolvedFields & {
|
|
32
|
+
[__modelMeta__]: IdentifierMeta & ImplicitModelsIdentifierMeta & SecondaryIndexes & RelationalMetadata<ResolvedSchema, ResolvedFields, IdentifierMeta> & NonModelTypes & ResolveCustomOperations<Schema, ResolvedFields, NonModelTypes>;
|
|
29
33
|
};
|
|
30
34
|
export {};
|
|
@@ -3,7 +3,7 @@ import type { Authorization, ImpliedAuthFields } from '../Authorization';
|
|
|
3
3
|
import type { ModelField } from '../ModelField';
|
|
4
4
|
import type { ModelType, ModelTypeParamShape } from '../ModelType';
|
|
5
5
|
import type { ModelSchema } from '../ModelSchema';
|
|
6
|
-
import type { ModelRelationalField, ModelRelationalFieldParamShape, ModelRelationalTypeArgFactory } from '../ModelRelationalField';
|
|
6
|
+
import type { ModelRelationalField, ModelRelationalFieldParamShape, ModelRelationalTypeArgFactory, ModelRelationshipTypes } from '../ModelRelationalField';
|
|
7
7
|
import type { AllImpliedFKs } from './ForeignKeys';
|
|
8
8
|
import type { ResolveSchema, SchemaTypes } from './ResolveSchema';
|
|
9
9
|
import type { InjectImplicitModelFields } from './ImplicitFieldInjector';
|
|
@@ -13,17 +13,14 @@ import type { NonModelTypesShape } from './ExtractNonModelTypes';
|
|
|
13
13
|
import type { CustomType, CustomTypeParamShape } from '../CustomType';
|
|
14
14
|
import type { EnumType, EnumTypeParamShape } from '../EnumType';
|
|
15
15
|
import type { CustomOperation, CustomOperationParamShape } from '../CustomOperation';
|
|
16
|
-
export type ResolveFieldProperties<Schema extends ModelSchema<any, any>, NonModelTypes extends NonModelTypesShape, ResolvedSchema = ResolveSchema<Schema>, IdentifierMeta extends Record<string, {
|
|
16
|
+
export type ResolveFieldProperties<Schema extends ModelSchema<any, any>, NonModelTypes extends NonModelTypesShape, ImplicitModelsSchema, ResolvedSchema = ResolveSchema<Schema>, IdentifierMeta extends Record<string, {
|
|
17
17
|
identifier: string;
|
|
18
|
-
}> = ModelIdentifier<SchemaTypes<Schema>>,
|
|
19
|
-
type
|
|
18
|
+
}> = ModelIdentifier<SchemaTypes<Schema>>, FieldsWithInjectedImplicitFields = InjectImplicitModelFields<ResolvedSchema & ImplicitModelsSchema, IdentifierMeta>, FieldsWithRelationships = ResolveRelationships<FieldsWithInjectedImplicitFields, NonModelTypes>> = Intersection<FilterFieldTypes<MarkModelsNonNullableFieldsRequired<FieldsWithRelationships>>, FilterFieldTypes<MarkModelsNullableFieldsOptional<FieldsWithRelationships>>, FilterFieldTypes<ModelImpliedAuthFields<Schema>>, AllImpliedFKs<ResolvedSchema, IdentifierMeta>>;
|
|
19
|
+
export type CreateImplicitModelsFromRelations<Schema> = UnionToIntersection<ExcludeEmpty<{
|
|
20
20
|
[ModelProp in keyof Schema]: {
|
|
21
|
-
[FieldProp in keyof Schema[ModelProp] as Schema[ModelProp][FieldProp] extends ModelRelationalFieldParamShape ? Schema[ModelProp][FieldProp]['relationName'] extends string ? Schema[ModelProp][FieldProp]['relationName'] extends keyof Schema ? never : Schema[ModelProp][FieldProp]['relationName'] : never : never]: {
|
|
22
|
-
id?: string;
|
|
23
|
-
} & Record<`${Lowercase<ModelProp & string>}`, ModelRelationalTypeArgFactory<ModelProp & string, 'hasMany', false>>;
|
|
21
|
+
[FieldProp in keyof Schema[ModelProp] as Schema[ModelProp][FieldProp] extends ModelRelationalFieldParamShape ? Schema[ModelProp][FieldProp]['relationName'] extends string ? Schema[ModelProp][FieldProp]['relationName'] extends keyof Schema ? never : Schema[ModelProp][FieldProp]['relationName'] : never : never]: Record<`${Lowercase<ModelProp & string>}`, ModelRelationalTypeArgFactory<ModelProp & string, ModelRelationshipTypes.hasMany, false>>;
|
|
24
22
|
};
|
|
25
23
|
}[keyof Schema]>>;
|
|
26
|
-
type InjectImplicitModels<Schema> = Schema & ExtractImplicitModelNames<Schema>;
|
|
27
24
|
type GetRelationshipRef<T, RM extends keyof T, TypeArg extends ModelRelationalFieldParamShape, Flat extends boolean, ResolvedModel = ResolveRelationalFieldsForModel<T, RM, Flat>, Model = TypeArg['valueRequired'] extends true ? ResolvedModel : ResolvedModel | null | undefined> = LazyLoader<Model, TypeArg['array']>;
|
|
28
25
|
type ResolveRelationalFieldsForModel<Schema, ModelName extends keyof Schema, Flat extends boolean> = {
|
|
29
26
|
[FieldName in keyof Schema[ModelName]]: Schema[ModelName][FieldName] extends ModelRelationalFieldParamShape ? Schema[ModelName][FieldName]['relatedModel'] extends keyof Schema ? GetRelationshipRef<Schema, Schema[ModelName][FieldName]['relatedModel'], Schema[ModelName][FieldName], Flat> : never : Schema[ModelName][FieldName];
|