@aws-amplify/data-schema
Advanced tools
Comparing version 0.13.2 to 0.13.3
@@ -1,2 +0,2 @@ | ||
import { type Prettify, __modelMeta__ } from '@aws-amplify/data-schema-types'; | ||
import { type __modelMeta__ } from '@aws-amplify/data-schema-types'; | ||
import type { ModelSchema } from './ModelSchema'; | ||
@@ -16,5 +16,7 @@ import type { ResolveSchema, SchemaTypes } from './MappedTypes/ResolveSchema'; | ||
* | ||
* @internal @typeParam NonModelTypes - Custom Types, Enums, and Custom Operations | ||
* @internal @typeParam ResolvedSchema - Schema/Models/Fields structure with generic type args extracted | ||
* @internal @typeParam IdentifierMeta - Stores model identifier | ||
* @internal @typeParam ResolvedFields - optionality enforced on nullable types (+?); These are the client-facing types used for CRUDL response shapes | ||
* @internal @typeParam ResolvedFields - Resovled client-facing types used for CRUDL response shapes | ||
* @internal @typeParam IdentifierMeta - Map of model primary index metadata | ||
* @internal @typeParam SecondaryIndexes - Map of model secondary index metadata | ||
* | ||
@@ -25,5 +27,5 @@ * @internal @typeParam Meta - Stores schema metadata: identifier, relationship metadata; | ||
*/ | ||
type InternalClientSchema<Schema extends ModelSchema<any, any>, NonModelTypes extends NonModelTypesShape = ExtractNonModelTypes<Schema>, ResolvedSchema = ResolveSchema<Schema>, IdentifierMeta extends Record<string, any> = ModelIdentifier<SchemaTypes<Schema>>, SecondaryIndexes extends Record<string, any> = ModelSecondaryIndexes<SchemaTypes<Schema>>, ResolvedFields extends Record<string, unknown> = ResolveFieldProperties<Schema, NonModelTypes>, RelationshipMeta = RelationalMetadata<ResolvedSchema, ResolvedFields, IdentifierMeta>, Meta = IdentifierMeta & SecondaryIndexes & RelationshipMeta & NonModelTypes> = Prettify<ResolvedFields & { | ||
[__modelMeta__]: Meta; | ||
}>; | ||
type InternalClientSchema<Schema extends ModelSchema<any, any>, NonModelTypes extends NonModelTypesShape = ExtractNonModelTypes<Schema>, ResolvedSchema = ResolveSchema<Schema>, ResolvedFields extends Record<string, unknown> = ResolveFieldProperties<Schema, NonModelTypes>, IdentifierMeta extends Record<string, any> = ModelIdentifier<SchemaTypes<Schema>>, SecondaryIndexes extends Record<string, any> = ModelSecondaryIndexes<SchemaTypes<Schema>>> = ResolvedFields & { | ||
[__modelMeta__]: IdentifierMeta & SecondaryIndexes & RelationalMetadata<ResolvedSchema, ResolvedFields, IdentifierMeta> & NonModelTypes; | ||
}; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const data_schema_types_1 = require("@aws-amplify/data-schema-types"); |
@@ -32,12 +32,12 @@ import type { UnionToIntersection } from '@aws-amplify/data-schema-types'; | ||
}; | ||
type ResolveNonModelFields<T extends NonModelTypesShape, CustomTypes = T['customTypes'], CustomOps = T['customOperations']> = { | ||
type ResolveNonModelFields<T extends NonModelTypesShape> = { | ||
enums: T['enums']; | ||
customTypes: { | ||
[CustomType in keyof CustomTypes]: { | ||
[FieldProp in keyof CustomTypes[CustomType]]: CustomTypes[CustomType][FieldProp] extends ModelField<infer R, any, any> ? R : never; | ||
[CustomType in keyof T['customTypes']]: { | ||
[FieldProp in keyof T['customTypes'][CustomType]]: T['customTypes'][CustomType][FieldProp] extends ModelField<infer R, any, any> ? R : never; | ||
}; | ||
}; | ||
customOperations: { | ||
[Op in keyof CustomOps]: { | ||
[FieldProp in keyof CustomOps[Op]]: CustomOps[Op][FieldProp] extends ModelField<infer R, any, any> ? R : never; | ||
[Op in keyof T['customOperations']]: { | ||
[FieldProp in keyof T['customOperations'][Op]]: T['customOperations'][Op][FieldProp] extends ModelField<infer R, any, any> ? R : never; | ||
}; | ||
@@ -44,0 +44,0 @@ }; |
import { ResolveSchema } from './ResolveSchema'; | ||
import { Prettify, UnionToIntersection } from '@aws-amplify/data-schema-types'; | ||
import { UnionToIntersection } from '@aws-amplify/data-schema-types'; | ||
import { ModelRelationalFieldParamShape, ModelRelationshipTypes } from '../ModelRelationalField'; | ||
@@ -13,3 +13,3 @@ export type AllImpliedFKs<ResolvedSchema, Identifiers extends Record<string, { | ||
[ModelName in keyof Schema]: { | ||
[FieldName in keyof Schema[ModelName]]: Prettify<{ | ||
[FieldName in keyof Schema[ModelName]]: { | ||
model: ModelName; | ||
@@ -19,3 +19,3 @@ identifier: IdentifierFields<Identifiers, ModelName>; | ||
type: Schema[ModelName][FieldName]; | ||
} & RelatedModelFields<Schema[ModelName][FieldName], Identifiers>>; | ||
} & RelatedModelFields<Schema[ModelName][FieldName], Identifiers>; | ||
}[keyof Schema[ModelName]]; | ||
@@ -37,3 +37,3 @@ }[keyof Schema]; | ||
relationshipType: ModelRelationshipTypes.manyToMany; | ||
}>, InferredFields = HasMany_Model_Keys<Schema, HasMany_Model> | HasOne_Model_Keys<Schema, HasOne_Model> | Model_BelongsTo_Keys<Schema, Model_BelongsTo> | ManyToManyKeys<Schema, ManyToManys>> = unknown extends UnionToIntersection<InferredFields> ? never : Prettify<UnionToIntersection<InferredFields>>; | ||
}>, InferredFields = HasMany_Model_Keys<Schema, HasMany_Model> | HasOne_Model_Keys<Schema, HasOne_Model> | Model_BelongsTo_Keys<Schema, Model_BelongsTo> | ManyToManyKeys<Schema, ManyToManys>> = unknown extends UnionToIntersection<InferredFields> ? never : UnionToIntersection<InferredFields>; | ||
type IdentifierFields<Identifiers extends Record<string, { | ||
@@ -40,0 +40,0 @@ identifier: string; |
@@ -5,3 +5,3 @@ import { type UnionToIntersection, type ExcludeEmpty } from '@aws-amplify/data-schema-types'; | ||
export type ModelIdentifier<T> = { | ||
[Property in keyof T]: T[Property] extends ModelType<infer R, any, any> ? R['identifier'] extends any[] ? { | ||
[Property in keyof T]: T[Property] extends ModelType<infer R, any> ? R['identifier'] extends any[] ? { | ||
identifier: R['identifier'][number]; | ||
@@ -11,3 +11,3 @@ } : never : never; | ||
export type ModelSecondaryIndexes<T> = { | ||
[Property in keyof T]: T[Property] extends ModelType<infer R, any, any> ? R['secondaryIndexes'] extends any[] ? { | ||
[Property in keyof T]: T[Property] extends ModelType<infer R, any> ? R['secondaryIndexes'] extends any[] ? { | ||
secondaryIndexes: R['secondaryIndexes']; | ||
@@ -14,0 +14,0 @@ } : never : never; |
@@ -56,3 +56,3 @@ import type { UnionToIntersection, LazyLoader, ExcludeEmpty } from '@aws-amplify/data-schema-types'; | ||
export type ModelImpliedAuthFields<Schema extends ModelSchema<any, any>> = { | ||
[ModelKey in keyof Schema['data']['types'] as Schema['data']['types'][ModelKey] extends EnumType<EnumTypeParamShape> ? never : Schema['data']['types'][ModelKey] extends CustomType<CustomTypeParamShape> ? never : Schema['data']['types'][ModelKey] extends CustomOperation<CustomOperationParamShape, any> ? never : ModelKey]: Schema['data']['types'][ModelKey] extends ModelType<infer Model, any, any> ? AllAuthFieldsForModel<Schema, Model> : object; | ||
[ModelKey in keyof Schema['data']['types'] as Schema['data']['types'][ModelKey] extends EnumType<EnumTypeParamShape> ? never : Schema['data']['types'][ModelKey] extends CustomType<CustomTypeParamShape> ? never : Schema['data']['types'][ModelKey] extends CustomOperation<CustomOperationParamShape, any> ? never : ModelKey]: Schema['data']['types'][ModelKey] extends ModelType<infer Model, any> ? AllAuthFieldsForModel<Schema, Model> : object; | ||
}; | ||
@@ -59,0 +59,0 @@ type AllAuthFieldsForModel<Schema extends ModelSchema<any, any>, Model extends Schema['data']['types'][keyof Schema['data']['types']]> = (Model['authorization'][number] extends never ? Schema['data']['authorization'][number] extends never ? object : ImpliedAuthFields<Schema['data']['authorization'][number]> : ImpliedAuthFields<Model['authorization'][number]>) & ImpliedAuthFieldsFromFields<Model>; |
@@ -19,3 +19,3 @@ import type { ModelType } from '../ModelType'; | ||
export type ModelTypes<Schema> = { | ||
[Model in keyof Schema as Schema[Model] extends EnumType<EnumTypeParamShape> | CustomType<CustomTypeParamShape> | CustomOperation<CustomOperationParamShape, any> ? never : Model]: Schema[Model] extends ModelType<infer R, any, any> ? R['fields'] : never; | ||
[Model in keyof Schema as Schema[Model] extends EnumType<EnumTypeParamShape> | CustomType<CustomTypeParamShape> | CustomOperation<CustomOperationParamShape, any> ? never : Model]: Schema[Model] extends ModelType<infer R, any> ? R['fields'] : never; | ||
}; | ||
@@ -22,0 +22,0 @@ /** |
@@ -8,3 +8,3 @@ import type { DerivedApiDefinition, SetTypeSubArg } from '@aws-amplify/data-schema-types'; | ||
import { Authorization } from './Authorization'; | ||
type SchemaContent = ModelType<ModelTypeParamShape, any, any> | CustomType<CustomTypeParamShape> | EnumType<EnumTypeParamShape> | CustomOperation<CustomOperationParamShape, any>; | ||
type SchemaContent = ModelType<ModelTypeParamShape, any> | CustomType<CustomTypeParamShape> | EnumType<EnumTypeParamShape> | CustomOperation<CustomOperationParamShape, any>; | ||
type ModelSchemaContents = Record<string, SchemaContent>; | ||
@@ -11,0 +11,0 @@ type InternalSchemaModels = Record<string, InternalModel | EnumType<any> | CustomType<any> | InternalCustom>; |
@@ -43,6 +43,6 @@ import type { Brand, SetTypeSubArg, SecondaryIndexIrShape } from '@aws-amplify/data-schema-types'; | ||
type IdentifierType<T extends ModelTypeParamShape, Fields extends string = IdentifierFields<T>> = Array<Fields>; | ||
export type ModelType<T extends ModelTypeParamShape, K extends keyof ModelType<T> = never, ResolvedModelFields extends Record<string, unknown> = ExtractType<T>, IndexFieldKeys extends string = SecondaryIndexFields<ResolvedModelFields>> = Omit<{ | ||
identifier<ID extends IdentifierType<T> = []>(identifier: ID): ModelType<SetTypeSubArg<T, 'identifier', ID>, K | 'identifier', ResolvedModelFields>; | ||
secondaryIndexes<const Indexes extends readonly ModelIndexType<IndexFieldKeys, IndexFieldKeys, unknown, never, any>[] = readonly [], const IndexesIR extends readonly any[] = SecondaryIndexToIR<Indexes, ResolvedModelFields>>(indexes: Indexes): ModelType<SetTypeSubArg<T, 'secondaryIndexes', IndexesIR>, K | 'secondaryIndexes', ResolvedModelFields>; | ||
authorization<AuthRuleType extends Authorization<any, any, any>>(rules: AuthRuleType[]): ModelType<SetTypeSubArg<T, 'authorization', AuthRuleType[]>, K | 'authorization', ResolvedModelFields>; | ||
export type ModelType<T extends ModelTypeParamShape, K extends keyof ModelType<T> = never> = Omit<{ | ||
identifier<ID extends IdentifierType<T> = []>(identifier: ID): ModelType<SetTypeSubArg<T, 'identifier', ID>, K | 'identifier'>; | ||
secondaryIndexes<const Indexes extends readonly ModelIndexType<SecondaryIndexFields<ExtractType<T>>, SecondaryIndexFields<ExtractType<T>>, unknown, never, any>[] = readonly [], const IndexesIR extends readonly any[] = SecondaryIndexToIR<Indexes, ExtractType<T>>>(indexes: Indexes): ModelType<SetTypeSubArg<T, 'secondaryIndexes', IndexesIR>, K | 'secondaryIndexes'>; | ||
authorization<AuthRuleType extends Authorization<any, any, any>>(rules: AuthRuleType[]): ModelType<SetTypeSubArg<T, 'authorization', AuthRuleType[]>, K | 'authorization'>; | ||
}, K> & Brand<object, typeof brand>; | ||
@@ -68,3 +68,3 @@ /** | ||
*/ | ||
export declare const isSchemaModelType: (modelType: any | SchemaModelType) => modelType is SchemaModelType<ModelType<ModelTypeParamShape, never, ExtractType<ModelTypeParamShape>, never>>; | ||
export declare const isSchemaModelType: (modelType: any | SchemaModelType) => modelType is SchemaModelType<ModelType<ModelTypeParamShape, never>>; | ||
/** | ||
@@ -71,0 +71,0 @@ * A data model that creates a matching Amazon DynamoDB table and provides create, read (list and get), update, |
{ | ||
"name": "@aws-amplify/data-schema", | ||
"version": "0.13.2", | ||
"version": "0.13.3", | ||
"license": "Apache-2.0", | ||
@@ -5,0 +5,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
215988