@aws-amplify/data-schema
Advanced tools
Comparing version 0.0.0-allow-customtypes-ref-in-arguments-20250115042921 to 0.0.0-allow-customtypes-ref-in-arguments-20250115045024
@@ -378,2 +378,4 @@ import type { UnionToIntersection, DefineFunction } from '@aws-amplify/data-schema-types'; | ||
export type AllowModifierForConversations = typeof allowForConversations; | ||
export type BaseAllowModifier = Omit<AllowModifier, 'resource'>; | ||
export type AnyAuthorization = Authorization<any, any, any>; | ||
export {}; |
@@ -5,3 +5,3 @@ import type { SetTypeSubArg } from '@aws-amplify/data-schema-types'; | ||
import type { ModelRelationshipField, InternalRelationshipField, ModelRelationshipFieldParamShape } from './ModelRelationshipField'; | ||
import { type AllowModifier, type Authorization } from './Authorization'; | ||
import { type Authorization, type BaseAllowModifier, type AnyAuthorization } from './Authorization'; | ||
import type { RefType, RefTypeParamShape } from './RefType'; | ||
@@ -69,6 +69,55 @@ import type { EnumType } from './EnumType'; | ||
[brandSymbol]: typeof brandName; | ||
/** | ||
* Defines single-field or composite identifiers, the fields must be marked required | ||
* | ||
* @param identifier A list of field names used as identifiers for the data model | ||
* @returns A ModelType instance with updated identifiers | ||
* | ||
* @example | ||
* a.model({ | ||
* name: a.string().required(), | ||
* email: a.string().required(), | ||
* age: a.integer(), | ||
* }).identifier(['name', 'email']) | ||
*/ | ||
identifier<PrimaryIndexFields = ExtractSecondaryIndexIRFields<T>, PrimaryIndexPool extends string = keyof PrimaryIndexFields & string, const ID extends ReadonlyArray<PrimaryIndexPool> = readonly [], const PrimaryIndexIR extends PrimaryIndexIrShape = PrimaryIndexFieldsToIR<ID, PrimaryIndexFields>>(identifier: ID): ModelType<SetTypeSubArg<T, 'identifier', PrimaryIndexIR>, UsedMethod | 'identifier'>; | ||
/** | ||
* Adds secondary index for a model, secondary index consists of a "hash key" and optionally, a "sort key" | ||
* | ||
* @param callback A function that specifies "hash key" and "sort key" | ||
* @returns A ModelType instance with updated secondary index | ||
* | ||
* @example | ||
* a.model().secondaryIndexes((index) => [index('type').sortKeys(['sort'])]) | ||
* | ||
* @see [Amplify documentation for secondary indexes](https://docs.amplify.aws/react/build-a-backend/data/data-modeling/secondary-index/) | ||
* @see [Amazon DynamoDB documentation for secondary indexes](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/SecondaryIndexes.html) | ||
*/ | ||
secondaryIndexes<const SecondaryIndexFields = ExtractSecondaryIndexIRFields<T>, const SecondaryIndexPKPool extends string = keyof SecondaryIndexFields & string, const Indexes extends readonly ModelIndexType<string, string, unknown, readonly [], any>[] = readonly [], const IndexesIR extends readonly any[] = SecondaryIndexToIR<Indexes, SecondaryIndexFields>>(callback: (index: <PK extends SecondaryIndexPKPool>(pk: PK) => ModelIndexType<SecondaryIndexPKPool, PK, ReadonlyArray<Exclude<SecondaryIndexPKPool, PK>>>) => Indexes): ModelType<SetTypeSubArg<T, 'secondaryIndexes', IndexesIR>, UsedMethod | 'secondaryIndexes'>; | ||
/** | ||
* Disables the specified operations for the model | ||
* | ||
* @param ops A list of operations to be disabled | ||
* @returns A ModelType instance with updated disabled operations | ||
* | ||
* @example | ||
* a.model().disableOperations(['delete', 'update', 'queries', 'subscriptions']) | ||
* | ||
* @see [Amplify Data documentation for supported operations](https://docs.amplify.aws/react/build-a-backend/data/) | ||
*/ | ||
disableOperations<const Ops extends ReadonlyArray<DisableOperationsOptions>>(ops: Ops): ModelType<SetTypeSubArg<T, 'disabledOperations', Ops>, UsedMethod | 'disableOperations'>; | ||
authorization<AuthRuleType extends Authorization<any, any, any>>(callback: (allow: Omit<AllowModifier, 'resource'>) => AuthRuleType | AuthRuleType[]): ModelType<SetTypeSubArg<T, 'authorization', AuthRuleType[]>, UsedMethod | 'authorization'>; | ||
/** | ||
* Configures authorization rules for public, signed-in user, per user, and per user group data access | ||
* | ||
* @param callback A function that receives an allow modifier to define authorization rules | ||
* @returns A ModelType instance with updated authorization rules | ||
* | ||
* @example | ||
* a.model().authorization((allow) => [ | ||
* allow.guest(), | ||
* allow.publicApiKey(), | ||
* allow.authenticated(), | ||
* ]) | ||
*/ | ||
authorization<AuthRuleType extends AnyAuthorization>(callback: (allow: BaseAllowModifier) => AuthRuleType | AuthRuleType[]): ModelType<SetTypeSubArg<T, 'authorization', AuthRuleType[]>, UsedMethod | 'authorization'>; | ||
}, UsedMethod>; | ||
@@ -75,0 +124,0 @@ /** |
{ | ||
"name": "@aws-amplify/data-schema", | ||
"version": "0.0.0-allow-customtypes-ref-in-arguments-20250115042921", | ||
"version": "0.0.0-allow-customtypes-ref-in-arguments-20250115045024", | ||
"license": "Apache-2.0", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -710,2 +710,5 @@ import type { | ||
export type AllowModifierForCustomOperation = typeof allowForCustomOperations; | ||
export type AllowModifierForConversations = typeof allowForConversations; | ||
export type AllowModifierForConversations = typeof allowForConversations; | ||
export type BaseAllowModifier = Omit<AllowModifier, 'resource'>; | ||
export type AnyAuthorization = Authorization<any, any, any>; |
@@ -13,3 +13,8 @@ import type { SetTypeSubArg } from '@aws-amplify/data-schema-types'; | ||
} from './ModelRelationshipField'; | ||
import { type AllowModifier, type Authorization, allow } from './Authorization'; | ||
import { | ||
type Authorization, | ||
type BaseAllowModifier, | ||
type AnyAuthorization, | ||
allow, | ||
} from './Authorization'; | ||
import type { RefType, RefTypeParamShape } from './RefType'; | ||
@@ -228,2 +233,16 @@ import type { EnumType } from './EnumType'; | ||
[brandSymbol]: typeof brandName; | ||
/** | ||
* Defines single-field or composite identifiers, the fields must be marked required | ||
* | ||
* @param identifier A list of field names used as identifiers for the data model | ||
* @returns A ModelType instance with updated identifiers | ||
* | ||
* @example | ||
* a.model({ | ||
* name: a.string().required(), | ||
* email: a.string().required(), | ||
* age: a.integer(), | ||
* }).identifier(['name', 'email']) | ||
*/ | ||
identifier< | ||
@@ -243,2 +262,15 @@ PrimaryIndexFields = ExtractSecondaryIndexIRFields<T>, | ||
>; | ||
/** | ||
* Adds secondary index for a model, secondary index consists of a "hash key" and optionally, a "sort key" | ||
* | ||
* @param callback A function that specifies "hash key" and "sort key" | ||
* @returns A ModelType instance with updated secondary index | ||
* | ||
* @example | ||
* a.model().secondaryIndexes((index) => [index('type').sortKeys(['sort'])]) | ||
* | ||
* @see [Amplify documentation for secondary indexes](https://docs.amplify.aws/react/build-a-backend/data/data-modeling/secondary-index/) | ||
* @see [Amazon DynamoDB documentation for secondary indexes](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/SecondaryIndexes.html) | ||
*/ | ||
secondaryIndexes< | ||
@@ -273,2 +305,14 @@ const SecondaryIndexFields = ExtractSecondaryIndexIRFields<T>, | ||
>; | ||
/** | ||
* Disables the specified operations for the model | ||
* | ||
* @param ops A list of operations to be disabled | ||
* @returns A ModelType instance with updated disabled operations | ||
* | ||
* @example | ||
* a.model().disableOperations(['delete', 'update', 'queries', 'subscriptions']) | ||
* | ||
* @see [Amplify Data documentation for supported operations](https://docs.amplify.aws/react/build-a-backend/data/) | ||
*/ | ||
disableOperations< | ||
@@ -282,5 +326,19 @@ const Ops extends ReadonlyArray<DisableOperationsOptions>, | ||
>; | ||
authorization<AuthRuleType extends Authorization<any, any, any>>( | ||
/** | ||
* Configures authorization rules for public, signed-in user, per user, and per user group data access | ||
* | ||
* @param callback A function that receives an allow modifier to define authorization rules | ||
* @returns A ModelType instance with updated authorization rules | ||
* | ||
* @example | ||
* a.model().authorization((allow) => [ | ||
* allow.guest(), | ||
* allow.publicApiKey(), | ||
* allow.authenticated(), | ||
* ]) | ||
*/ | ||
authorization<AuthRuleType extends AnyAuthorization>( | ||
callback: ( | ||
allow: Omit<AllowModifier, 'resource'>, | ||
allow: BaseAllowModifier, | ||
) => AuthRuleType | AuthRuleType[], | ||
@@ -287,0 +345,0 @@ ): ModelType< |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
2358124
32017