@aws-amplify/data-schema
Advanced tools
Comparing version 0.14.10 to 0.14.11
@@ -22,5 +22,3 @@ import type { DerivedApiDefinition, SetTypeSubArg, SchemaConfiguration, DataSourceConfiguration, DatasourceEngine, UnionToIntersection } from '@aws-amplify/data-schema-types'; | ||
}; | ||
export type RDSModelSchemaParamShape = ModelSchemaParamShape & { | ||
sqlStatementFolderPath?: CustomPathData; | ||
}; | ||
export type RDSModelSchemaParamShape = ModelSchemaParamShape; | ||
export type InternalSchema = { | ||
@@ -36,3 +34,3 @@ data: { | ||
models: { | ||
[TypeKey in keyof T['types']]: T['types'][TypeKey] extends ModelType<ModelTypeParamShape> ? SchemaModelType<T['types'][TypeKey], TypeKey & string, IsRDS> : never; | ||
[TypeKey in keyof T['types']]: T['types'][TypeKey] extends ModelType<ModelTypeParamShape, never | 'identifier'> ? SchemaModelType<T['types'][TypeKey], TypeKey & string, IsRDS> : never; | ||
}; | ||
@@ -45,3 +43,3 @@ transform: () => DerivedApiDefinition; | ||
}, UsedMethods> & BaseSchema<T> & DDBSchemaBrand; | ||
type RDSModelSchemaFunctions = 'addQueries' | 'addMutations' | 'addSubscriptions' | 'authorization' | 'relationships'; | ||
type RDSModelSchemaFunctions = 'addQueries' | 'addMutations' | 'addSubscriptions' | 'authorization' | 'relationships' | 'setAuthorization'; | ||
export type RDSModelSchema<T extends RDSModelSchemaParamShape, UsedMethods extends RDSModelSchemaFunctions = never, RelationshipTemplate extends Record<string, ModelRelationalField<ModelRelationalFieldParamShape, string, any, any>> = Record<string, ModelRelationalField<ModelRelationalFieldParamShape, string, any, any>>> = Omit<{ | ||
@@ -52,2 +50,3 @@ addQueries: <Queries extends Record<string, QueryCustomOperation>>(types: Queries) => RDSModelSchema<SetTypeSubArg<T, 'types', T['types'] & Queries>, UsedMethods | 'addQueries'>; | ||
authorization: <AuthRules extends SchemaAuthorization<any, any, any>>(auth: AuthRules[]) => RDSModelSchema<SetTypeSubArg<T, 'authorization', AuthRules[]>, UsedMethods | 'authorization'>; | ||
setAuthorization: (callback: (models: BaseSchema<T, true>['models'], schema: RDSModelSchema<T>) => void) => RDSModelSchema<T>; | ||
relationships: <Relationships extends ReadonlyArray<Partial<Record<keyof T['types'], RelationshipTemplate>>>>(callback: (models: BaseSchema<T, true>['models']) => Relationships) => RDSModelSchema<UnionToIntersection<Relationships[number]> extends infer RelationshipsDefs ? RelationshipsDefs extends Record<string, RelationshipTemplate> ? SetTypeSubArg<T, 'types', { | ||
@@ -54,0 +53,0 @@ [ModelName in keyof T['types']]: ModelName extends keyof RelationshipsDefs ? AddRelationshipFieldsToModelTypeFields<T['types'][ModelName], RelationshipsDefs[ModelName]> : T['types'][ModelName]; |
@@ -71,2 +71,7 @@ "use strict"; | ||
}, | ||
setAuthorization(callback) { | ||
callback(models, this); | ||
const { setAuthorization: _, ...rest } = this; | ||
return rest; | ||
}, | ||
relationships(callback) { | ||
@@ -73,0 +78,0 @@ const { relationships: _, ...rest } = this; |
@@ -54,4 +54,5 @@ import type { SetTypeSubArg, SecondaryIndexIrShape } from '@aws-amplify/data-schema-types'; | ||
*/ | ||
export type SchemaModelType<T extends ModelType<ModelTypeParamShape> = ModelType<ModelTypeParamShape>, ModelName extends string = string, IsRDS extends boolean = false> = IsRDS extends true ? T & { | ||
export type SchemaModelType<T extends ModelType<ModelTypeParamShape, never | 'identifier'> = ModelType<ModelTypeParamShape, never | 'identifier'>, ModelName extends string = string, IsRDS extends boolean = false> = IsRDS extends true ? T & { | ||
addRelationships<Param extends Record<string, ModelRelationalField<any, string, any, any>> = Record<never, never>>(relationships: Param): Record<ModelName, Param>; | ||
fields: T extends ModelType<infer R extends ModelTypeParamShape, any> ? R['fields'] : never; | ||
} : T; | ||
@@ -70,3 +71,3 @@ /** | ||
*/ | ||
export declare const isSchemaModelType: (modelType: any | SchemaModelType) => modelType is ModelType<ModelTypeParamShape, never>; | ||
export declare const isSchemaModelType: (modelType: any | SchemaModelType) => modelType is ModelType<ModelTypeParamShape, "identifier">; | ||
/** | ||
@@ -73,0 +74,0 @@ * A data model that creates a matching Amazon DynamoDB table and provides create, read (list and get), update, |
@@ -35,2 +35,3 @@ "use strict"; | ||
}, | ||
fields: data.fields, | ||
}; | ||
@@ -65,3 +66,1 @@ } | ||
exports.model = model; | ||
// TODO: rename and extract into separate file; | ||
// Will breaking apart SecondaryIndexToIR optimize it? |
{ | ||
"name": "@aws-amplify/data-schema", | ||
"version": "0.14.10", | ||
"version": "0.14.11", | ||
"license": "Apache-2.0", | ||
@@ -5,0 +5,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
728394
4124