import type { DerivedApiDefinition, SetTypeSubArg, SchemaConfiguration, DataSourceConfiguration, DatasourceEngine, UnionToIntersection } from '@aws-amplify/data-schema-types'; import { type InternalModel, SchemaModelType, AddRelationshipFieldsToModelTypeFields, type BaseModelType } from './ModelType'; import type { EnumType } from './EnumType'; import type { CustomType, CustomTypeParamShape } from './CustomType'; import type { CustomOperation, CustomOperationParamShape, InternalCustom, MutationCustomOperation, QueryCustomOperation, SubscriptionCustomOperation } from './CustomOperation'; import { AllowModifier, SchemaAuthorization } from './Authorization'; import { Brand, RenameUsingTuples } from './util'; import { ModelRelationshipField, ModelRelationshipFieldParamShape } from './ModelRelationshipField'; import { ConversationType } from './ai/ConversationType'; export { ModelType } from './ModelType'; export { EnumType } from './EnumType'; export { CustomType } from './CustomType'; export { CustomOperation } from './CustomOperation'; export { ConversationType } from './ai/ConversationType'; export declare const rdsSchemaBrandName = "RDSSchema"; export declare const rdsSchemaBrand: Brand<"RDSSchema">; export type RDSSchemaBrand = Brand; export declare const ddbSchemaBrandName = "DDBSchema"; export type DDBSchemaBrand = Brand; type SchemaContent = BaseModelType | CustomType | EnumType | CustomOperation | ConversationType; type AddToSchemaContent = Exclude; type AddToSchemaContents = Record; type NonEmpty = keyof T extends never ? never : T; export type ModelSchemaContents = Record; type InternalSchemaModels = Record | InternalCustom>; export type ModelSchemaParamShape = { types: ModelSchemaContents; authorization: SchemaAuthorization[]; configuration: SchemaConfiguration; }; export type RDSModelSchemaParamShape = ModelSchemaParamShape; export type InternalSchema = { data: { types: InternalSchemaModels; authorization: SchemaAuthorization[]; configuration: SchemaConfiguration; }; context?: { schemas: InternalSchema[]; }; }; export type BaseSchema = { data: T; models: { [TypeKey in keyof T['types']]: T['types'][TypeKey] extends BaseModelType ? SchemaModelType : never; }; transform: () => DerivedApiDefinition; context?: { schemas: GenericModelSchema[]; }; }; export type GenericModelSchema = BaseSchema & Brand; /** * Model schema definition interface * * @param T - The shape of the model schema * @param UsedMethods - The method keys already defined */ export type ModelSchema = Omit<{ authorization: >(callback: (allow: AllowModifier) => AuthRules | AuthRules[]) => ModelSchema, UsedMethods | 'authorization'>; }, UsedMethods> & BaseSchema & DDBSchemaBrand; type RDSModelSchemaFunctions = 'addToSchema' | 'addQueries' | 'addMutations' | 'addSubscriptions' | 'authorization' | 'setRelationships' | 'setAuthorization' | 'renameModelFields' | 'renameModels'; type OmitFromEach = { [ModelName in keyof Models]: Omit; }; type RelationshipTemplate = Record>; /** * RDSModel schema definition interface * * @param T - The shape of the RDS model schema * @param UsedMethods - The method keys already defined */ export type RDSModelSchema = Omit<{ addToSchema: (types: AddedTypes) => RDSModelSchema, UsedMethods | 'addToSchema'>; /** * @deprecated use `addToSchema()` to add operations to a SQL schema */ addQueries: >(types: Queries) => RDSModelSchema, UsedMethods | 'addQueries'>; /** * @deprecated use `addToSchema()` to add operations to a SQL schema */ addMutations: >(types: Mutations) => RDSModelSchema, UsedMethods | 'addMutations'>; /** * @deprecated use `addToSchema()` to add operations to a SQL schema */ addSubscriptions: >(types: Subscriptions) => RDSModelSchema, UsedMethods | 'addSubscriptions'>; authorization: >(callback: (allow: AllowModifier) => AuthRules | AuthRules[]) => RDSModelSchema, UsedMethods | 'authorization'>; setAuthorization: (callback: (models: OmitFromEach['models'], 'secondaryIndexes'>, schema: RDSModelSchema) => void) => RDSModelSchema; setRelationships: >>>(callback: (models: OmitFromEach['models'], 'authorization' | 'fields' | 'secondaryIndexes'>) => Relationships) => RDSModelSchema; }>, UsedMethods | 'setRelationships'>; renameModels: ['models'] & string, const ChangeLog extends readonly [CurName, NewName][] = []>(callback: () => ChangeLog) => RDSModelSchema>, UsedMethods | 'renameModels'>; }, UsedMethods> & BaseSchema & RDSSchemaBrand; /** * Amplify API Next Model Schema shape */ export type ModelSchemaType = ModelSchema; type ModelWithRelationships, Relationships extends ReadonlyArray>, ModelName extends keyof Types, RelationshipMap extends UnionToIntersection = UnionToIntersection> = ModelName extends keyof RelationshipMap ? RelationshipMap[ModelName] extends Record> ? AddRelationshipFieldsToModelTypeFields : Types[ModelName] : Types[ModelName]; /** * Model Schema type guard * @param schema - api-next ModelSchema or string * @returns true if the given value is a ModelSchema */ export declare const isModelSchema: (schema: string | ModelSchemaType) => schema is ModelSchemaType; type SchemaReturnType = DE extends 'dynamodb' ? ModelSchema<{ types: Types; authorization: []; configuration: any; }> : RDSModelSchema<{ types: Types; authorization: []; configuration: any; }>; /** * The API and data model definition for Amplify Data. Pass in `{ : a.model(...) }` to create a database table * and exposes CRUDL operations via an API. * @param types The API and data model definition * @returns An API and data model definition to be deployed with Amplify (Gen 2) experience (`processSchema(...)`) * or with the Amplify Data CDK construct (`@aws-amplify/data-construct`) */ export declare const schema: (types: NonEmpty) => ModelSchema<{ types: Types; authorization: []; configuration: any; }, never>; /** * Configure wraps schema definition with non-default config to allow usecases other than * the default DynamoDB use-case. * * @param config The SchemaConfig augments the schema with content like the database type * @returns */ export declare function configure(config: SchemaConfiguration>): { schema: (types: NonEmpty) => SchemaReturnType; }; export declare function isCustomPathData(obj: any): obj is CustomPathData; export type CustomPathData = { stack: string | undefined; entry: string; };