export type DocumentClientMethod = (parameters: any) => { promise: () => Promise; }; type TransactWriteItem = | { Put: { [param: string]: any } } | { Update: { [param: string]: any } } | { Delete: { [param: string]: any } } | { ConditionCheck: { [param: string]: any } }; type TransactWriteCommandInput = { TransactItems: TransactWriteItem[]; ClientRequestToken?: string; }; type TransactGetItem = { Get: { [param: string]: any } }; type TransactGetCommandInput = { TransactItems: TransactGetItem[]; }; export type DocumentClient = | { get: DocumentClientMethod; put: DocumentClientMethod; delete: DocumentClientMethod; update: DocumentClientMethod; batchWrite: DocumentClientMethod; batchGet: DocumentClientMethod; scan: DocumentClientMethod; transactGet: DocumentClientMethod; transactWrite: DocumentClientMethod; } | { send: (command: any) => Promise; }; export type AllCollectionNames< E extends { [name: string]: Entity }, > = { [Name in keyof E]: E[Name] extends Entity ? { [Collection in keyof EntityCollections]: Collection; }[keyof EntityCollections] : never; }[keyof E]; export type ClusteredCollectionNames< E extends { [name: string]: Entity }, > = { [Name in keyof E]: E[Name] extends Entity ? { [Collection in keyof ClusteredEntityCollections< A, F, C, S >]: Collection; }[keyof ClusteredEntityCollections] : never; }[keyof E]; export type IsolatedCollectionNames< E extends { [name: string]: Entity }, > = { [Name in keyof E]: E[Name] extends Entity ? { [Collection in keyof IsolatedEntityCollections]: Collection; }[keyof IsolatedEntityCollections] : never; }[keyof E]; export type IsolatedCollectionAssociations< E extends { [name: string]: Entity }, > = { [Collection in IsolatedCollectionNames]: { [Name in keyof E]: E[Name] extends Entity< infer A, infer F, infer C, infer S > ? Collection extends keyof IsolatedEntityCollections ? Name : never : never; }[keyof E]; }; export type AllEntityAttributeNames< E extends { [name: string]: Entity }, > = { [Name in keyof E]: { [A in keyof E[Name]["schema"]["attributes"]]: A; }[keyof E[Name]["schema"]["attributes"]]; }[keyof E]; export type AllEntityAttributes< E extends { [name: string]: Entity }, > = { [Attr in AllEntityAttributeNames]: { [Name in keyof E]: Attr extends keyof E[Name]["schema"]["attributes"] ? ItemAttribute : never; }[keyof E]; }; export type CollectionAssociations< E extends { [name: string]: Entity }, > = { [Collection in AllCollectionNames]: { [Name in keyof E]: E[Name] extends Entity< infer A, infer F, infer C, infer S > ? Collection extends keyof EntityCollections ? Name : never : never; }[keyof E]; }; export type ClusteredCollectionAssociations< E extends { [name: string]: Entity }, > = { [Collection in ClusteredCollectionNames]: { [Name in keyof E]: E[Name] extends Entity< infer A, infer F, infer C, infer S > ? Collection extends keyof ClusteredEntityCollections ? Name : never : never; }[keyof E]; }; export type CollectionAttributes< E extends { [name: string]: Entity }, Collections extends CollectionAssociations, > = { [Collection in keyof Collections]: { [EntityName in keyof E]: E[EntityName] extends Entity< infer A, infer F, infer C, infer S > ? EntityName extends Collections[Collection] ? keyof S["attributes"] : never : never; }[keyof E]; }; export type ClusteredCollectionAttributes< E extends { [name: string]: Entity }, Collections extends ClusteredCollectionAssociations, > = { [Collection in keyof Collections]: { [EntityName in keyof E]: E[EntityName] extends Entity< infer A, infer F, infer C, infer S > ? EntityName extends Collections[Collection] ? keyof S["attributes"] : never : never; }[keyof E]; }; export type IsolatedCollectionAttributes< E extends { [name: string]: Entity }, Collections extends IsolatedCollectionAssociations, > = { [Collection in keyof Collections]: { [EntityName in keyof E]: E[EntityName] extends Entity< infer A, infer F, infer C, infer S > ? EntityName extends Collections[Collection] ? keyof S["attributes"] : never : never; }[keyof E]; }; type DynamoDBAttributeType = | "S" | "SS" | "N" | "NS" | "B" | "BS" | "BOOL" | "NULL" | "L" | "M"; export interface CollectionWhereOperations { eq: >(attr: A, value: T) => string; ne: >(attr: A, value: T) => string; gt: >(attr: A, value: T) => string; lt: >(attr: A, value: T) => string; gte: >(attr: A, value: T) => string; lte: >(attr: A, value: T) => string; between: >( attr: A, value: T, value2: T, ) => string; begins: >(attr: A, value: T) => string; exists: >(attr: A) => string; notExists: >(attr: A) => string; contains: >( attr: A, value: A extends WhereAttributeSymbol ? V extends Array ? I : V : never, ) => string; notContains: >( attr: A, value: A extends WhereAttributeSymbol ? V extends Array ? I : V : never, ) => string; field: (name: string) => string; name: >(attr: A) => string; value: >(attr: A, value: T) => string; size: >(attr: A) => string; type: >( attr: A, type: DynamoDBAttributeType, ) => string; escape: ( value: T, ) => T extends string ? string : T extends number ? number : T extends boolean ? boolean : never; } export type CollectionWhereCallback< E extends { [name: string]: Entity }, I extends Partial>, > = }>( attributes: W, operations: CollectionWhereOperations, ) => string; export type CollectionWhereClause< E extends { [name: string]: Entity }, A extends string, F extends string, C extends string, S extends Schema, I extends Partial>, T, > = (where: CollectionWhereCallback) => T; export interface ServiceWhereRecordsActionOptions< E extends { [name: string]: Entity }, A extends string, F extends string, C extends string, S extends Schema, I extends Partial>, Items, IndexCompositeAttributes, > { go: ServiceQueryRecordsGo; params: ParamRecord; where: CollectionWhereClause< E, A, F, C, S, I, ServiceWhereRecordsActionOptions< E, A, F, C, S, I, Items, IndexCompositeAttributes > >; } export type CollectionIndexKeys< Entities extends { [name: string]: Entity }, Collections extends CollectionAssociations, > = { [Collection in keyof Collections]: { [EntityResultName in Collections[Collection]]: EntityResultName extends keyof Entities ? Entities[EntityResultName] extends Entity< infer A, infer F, infer C, infer S > ? keyof TableIndexCompositeAttributes : never : never; }[Collections[Collection]]; }; export type ClusteredCollectionIndexKeys< Entities extends { [name: string]: Entity }, Collections extends ClusteredCollectionAssociations, > = { [Collection in keyof Collections]: { [EntityResultName in Collections[Collection]]: EntityResultName extends keyof Entities ? Entities[EntityResultName] extends Entity< infer A, infer F, infer C, infer S > ? keyof TableIndexCompositeAttributes : never : never; }[Collections[Collection]]; }; export type IsolatedCollectionIndexKeys< Entities extends { [name: string]: Entity }, Collections extends IsolatedCollectionAssociations, > = { [Collection in keyof Collections]: { [EntityResultName in Collections[Collection]]: EntityResultName extends keyof Entities ? Entities[EntityResultName] extends Entity< infer A, infer F, infer C, infer S > ? keyof TableIndexCompositeAttributes : never : never; }[Collections[Collection]]; }; export type CollectionPageKeys< Entities extends { [name: string]: Entity }, Collections extends CollectionAssociations, > = { [Collection in keyof Collections]: { [EntityResultName in Collections[Collection]]: EntityResultName extends keyof Entities ? Entities[EntityResultName] extends Entity< infer A, infer F, infer C, infer S > ? keyof Parameters< Entities[EntityResultName]["query"][Collection extends keyof EntityCollections< A, F, C, S > ? EntityCollections[Collection] : never] >[0] : never : never; }[Collections[Collection]]; }; export type ClusteredCollectionPageKeys< Entities extends { [name: string]: Entity }, Collections extends ClusteredCollectionAssociations, > = { [Collection in keyof Collections]: { [EntityResultName in Collections[Collection]]: EntityResultName extends keyof Entities ? Entities[EntityResultName] extends Entity< infer A, infer F, infer C, infer S > ? keyof Parameters< Entities[EntityResultName]["query"][Collection extends keyof ClusteredEntityCollections< A, F, C, S > ? ClusteredEntityCollections[Collection] : never] >[0] : never : never; }[Collections[Collection]]; }; export type IsolatedCollectionPageKeys< Entities extends { [name: string]: Entity }, Collections extends IsolatedCollectionAssociations, > = { [Collection in keyof Collections]: { [EntityResultName in Collections[Collection]]: EntityResultName extends keyof Entities ? Entities[EntityResultName] extends Entity< infer A, infer F, infer C, infer S > ? keyof Parameters< Entities[EntityResultName]["query"][Collection extends keyof IsolatedEntityCollections< A, F, C, S > ? IsolatedEntityCollections[Collection] : never] >[0] : never : never; }[Collections[Collection]]; }; export type CollectionIndexAttributes< Entities extends { [name: string]: Entity }, Collections extends CollectionAssociations, > = { [Collection in keyof CollectionIndexKeys]: { [key in CollectionIndexKeys< Entities, Collections >[Collection]]: key extends keyof AllEntityAttributes ? AllEntityAttributes[key] : never; }; }; export type ClusteredCollectionIndexAttributes< Entities extends { [name: string]: Entity }, Collections extends ClusteredCollectionAssociations, > = { [Collection in keyof ClusteredCollectionIndexKeys]: { [Key in ClusteredCollectionIndexKeys< Entities, Collections >[Collection]]: Key extends keyof AllEntityAttributes ? AllEntityAttributes[Key] : never; }; }; export type IsolatedCollectionIndexAttributes< Entities extends { [name: string]: Entity }, Collections extends IsolatedCollectionAssociations, > = { [Collection in keyof IsolatedCollectionIndexKeys]: { [Key in IsolatedCollectionIndexKeys< Entities, Collections >[Collection]]: Key extends keyof AllEntityAttributes ? AllEntityAttributes[Key] : never; }; }; export type CollectionPageAttributes< Entities extends { [name: string]: Entity }, Collections extends CollectionAssociations, > = { [Collection in keyof CollectionPageKeys]: { [key in CollectionPageKeys< Entities, Collections >[Collection]]: key extends keyof AllEntityAttributes ? AllEntityAttributes[key] : never; }; }; export type ClusteredCollectionPageAttributes< Entities extends { [name: string]: Entity }, Collections extends ClusteredCollectionAssociations, > = { [Collection in keyof ClusteredCollectionPageKeys]: { [key in ClusteredCollectionPageKeys< Entities, Collections >[Collection]]: key extends keyof AllEntityAttributes ? AllEntityAttributes[key] : never; }; }; export type IsolatedCollectionPageAttributes< Entities extends { [name: string]: Entity }, Collections extends IsolatedCollectionAssociations, > = { [Collection in keyof IsolatedCollectionPageKeys]: { [key in IsolatedCollectionPageKeys< Entities, Collections >[Collection]]: key extends keyof AllEntityAttributes ? AllEntityAttributes[key] : never; }; }; export type OptionalPropertyNames = { [K in keyof T]: undefined extends T[K] ? K : never; }[keyof T]; // Common properties from L and R with undefined in R[K] replaced by type in L[K] export type SpreadProperties = { [P in K]: L[P] | Exclude; }; export type Id = { [K in keyof T]: T[K] }; // see note at bottom* // Type of { ...L, ...R } export type Spread = Id< // Properties in L that don't exist in R Pick> & // Properties in R with types that exclude undefined Pick>> & // Properties in R, with types that include undefined, that don't exist in L Pick, keyof L>> & // Properties in R, with types that include undefined, that exist in L SpreadProperties & keyof L> >; export type RequiredProperties = Pick< T, { [K in keyof T]-?: {} extends Pick ? never : K }[keyof T] >; export type CollectionQueries< E extends { [name: string]: Entity }, Collections extends CollectionAssociations, > = { [Collection in keyof Collections]: { [EntityName in keyof E]: EntityName extends Collections[Collection] ? ( params: RequiredProperties< Parameters< E[EntityName]["query"][E[EntityName] extends Entity< infer A, infer F, infer C, infer S > ? Collection extends keyof EntityCollections ? EntityCollections[Collection] : never : never] >[0] >, ) => { go: ServiceQueryRecordsGo<{ [EntityResultName in Collections[Collection]]: EntityResultName extends keyof E ? E[EntityResultName] extends Entity< infer A, infer F, infer C, infer S > ? ResponseItem[] : never : never; }>; params: ParamRecord; where: { [EntityResultName in Collections[Collection]]: EntityResultName extends keyof E ? E[EntityResultName] extends Entity< infer A, infer F, infer C, infer S > ? Pick< AllEntityAttributes, Extract< AllEntityAttributeNames, CollectionAttributes[Collection] > > extends Partial> ? CollectionWhereClause< E, A, F, C, S, Pick< AllEntityAttributes, Extract< AllEntityAttributeNames, CollectionAttributes[Collection] > >, ServiceWhereRecordsActionOptions< E, A, F, C, S, Pick< AllEntityAttributes, Extract< AllEntityAttributeNames, CollectionAttributes[Collection] > >, { [EntityResultName in Collections[Collection]]: EntityResultName extends keyof E ? E[EntityResultName] extends Entity< infer A, infer F, infer C, infer S > ? ResponseItem[] : never : never; }, Partial< Spread< Collection extends keyof CollectionPageAttributes< E, Collections > ? CollectionPageAttributes< E, Collections >[Collection] : {}, Collection extends keyof CollectionIndexAttributes< E, Collections > ? CollectionIndexAttributes< E, Collections >[Collection] : {} > > > > : never : never : never; }[Collections[Collection]]; } : never; }[keyof E]; }; type ClusteredCollectionOperations< E extends { [name: string]: Entity }, Collections extends ClusteredCollectionAssociations, Collection extends keyof Collections, EntityName extends keyof E, > = EntityName extends Collections[Collection] ? { go: ServiceQueryRecordsGo<{ [EntityResultName in Collections[Collection]]: EntityResultName extends keyof E ? E[EntityResultName] extends Entity< infer A, infer F, infer C, infer S > ? ResponseItem[] : never : never; }>; params: ParamRecord; where: { [EntityResultName in Collections[Collection]]: EntityResultName extends keyof E ? E[EntityResultName] extends Entity< infer A, infer F, infer C, infer S > ? Pick< AllEntityAttributes, Extract< AllEntityAttributeNames, ClusteredCollectionAttributes[Collection] > > extends Partial> ? CollectionWhereClause< E, A, F, C, S, Pick< AllEntityAttributes, Extract< AllEntityAttributeNames, ClusteredCollectionAttributes[Collection] > >, ServiceWhereRecordsActionOptions< E, A, F, C, S, Pick< AllEntityAttributes, Extract< AllEntityAttributeNames, ClusteredCollectionAttributes< E, Collections >[Collection] > >, { [EntityResultName in Collections[Collection]]: EntityResultName extends keyof E ? E[EntityResultName] extends Entity< infer A, infer F, infer C, infer S > ? ResponseItem[] : never : never; }, Partial< Spread< Collection extends keyof ClusteredCollectionPageAttributes< E, Collections > ? ClusteredCollectionPageAttributes< E, Collections >[Collection] : {}, Collection extends keyof ClusteredCollectionIndexAttributes< E, Collections > ? ClusteredCollectionIndexAttributes< E, Collections >[Collection] : {} > > > > : never : never : never; }[Collections[Collection]]; } : never; type ClusteredCompositeAttributes< E extends { [name: string]: Entity }, Collections extends ClusteredCollectionAssociations, Collection extends keyof Collections, EntityName extends keyof E, > = EntityName extends Collections[Collection] ? Parameters< E[EntityName]["query"][E[EntityName] extends Entity< infer A, infer F, infer C, infer S > ? Collection extends keyof ClusteredEntityCollections ? ClusteredEntityCollections[Collection] : never : never] >[0] : never; type ClusteredCollectionQueryOperations = { between( skCompositeAttributesStart: Param, skCompositeAttributesEnd: Param, ): Result; gt(skCompositeAttributes: Param): Result; gte(skCompositeAttributes: Param): Result; lt(skCompositeAttributes: Param): Result; lte(skCompositeAttributes: Param): Result; begins(skCompositeAttributes: Param): Result; }; type OptionalPropertyOf = Exclude< { [K in keyof T]: T extends Record ? never : K; }[keyof T], undefined >; type ClusteredCollectionQueryParams< E extends { [name: string]: Entity }, Collections extends ClusteredCollectionAssociations, > = { [Collection in keyof Collections as Collections[Collection] extends keyof E ? Collection : never]: { [EntityName in keyof E]: EntityName extends Collections[Collection] ? ClusteredCompositeAttributes : never; }[keyof E]; }; export type ClusteredCollectionQueries< E extends { [name: string]: Entity }, Collections extends ClusteredCollectionAssociations, > = { [Collection in keyof Collections as Collections[Collection] extends keyof E ? Collection : never]: { [EntityName in keyof E]: EntityName extends Collections[Collection] ? ( params: ClusteredCompositeAttributes< E, Collections, Collection, EntityName >, ) => ClusteredCollectionOperations< E, Collections, Collection, EntityName > & ClusteredCollectionQueryOperations< Pick< ClusteredCompositeAttributes< E, Collections, Collection, EntityName >, OptionalPropertyOf< ClusteredCompositeAttributes< E, Collections, Collection, EntityName > > >, ClusteredCollectionOperations< E, Collections, Collection, EntityName > > : never; }[keyof E]; }; export type IsolatedCollectionQueries< E extends { [name: string]: Entity }, Collections extends IsolatedCollectionAssociations, > = { [Collection in keyof Collections]: { [EntityName in keyof E]: EntityName extends Collections[Collection] ? ( params: RequiredProperties< Parameters< E[EntityName]["query"][E[EntityName] extends Entity< infer A, infer F, infer C, infer S > ? Collection extends keyof IsolatedEntityCollections ? IsolatedEntityCollections[Collection] : never : never] >[0] >, ) => { go: ServiceQueryRecordsGo<{ [EntityResultName in Collections[Collection]]: EntityResultName extends keyof E ? E[EntityResultName] extends Entity< infer A, infer F, infer C, infer S > ? ResponseItem[] : never : never; }>; params: ParamRecord; where: { [EntityResultName in Collections[Collection]]: EntityResultName extends keyof E ? E[EntityResultName] extends Entity< infer A, infer F, infer C, infer S > ? Pick< AllEntityAttributes, Extract< AllEntityAttributeNames, IsolatedCollectionAttributes[Collection] > > extends Partial> ? CollectionWhereClause< E, A, F, C, S, Pick< AllEntityAttributes, Extract< AllEntityAttributeNames, IsolatedCollectionAttributes< E, Collections >[Collection] > >, ServiceWhereRecordsActionOptions< E, A, F, C, S, Pick< AllEntityAttributes, Extract< AllEntityAttributeNames, IsolatedCollectionAttributes< E, Collections >[Collection] > >, { [EntityResultName in Collections[Collection]]: EntityResultName extends keyof E ? E[EntityResultName] extends Entity< infer A, infer F, infer C, infer S > ? ResponseItem[] : never : never; }, Partial< Spread< Collection extends keyof IsolatedCollectionPageAttributes< E, Collections > ? IsolatedCollectionPageAttributes< E, Collections >[Collection] : {}, Collection extends keyof IsolatedCollectionIndexAttributes< E, Collections > ? IsolatedCollectionIndexAttributes< E, Collections >[Collection] : {} > > > > : never : never : never; }[Collections[Collection]]; } : never; }[keyof E]; }; export type ElectroDBMethodTypes = | "put" | "get" | "query" | "scan" | "update" | "delete" | "remove" | "patch" | "create" | "batchGet" | "batchWrite"; export interface ElectroQueryEvent

{ type: "query"; method: ElectroDBMethodTypes; config: any; params: P; } export interface ElectroResultsEvent { type: "results"; method: ElectroDBMethodTypes; config: any; results: R; success: boolean; } export type ElectroEvent = ElectroQueryEvent | ElectroResultsEvent; export type ElectroEventType = Pick; export type ElectroEventListener = (event: ElectroEvent) => void; // todo: coming soon, more events! // | { // name: "error"; // type: "configuration_error" | "invalid_query" | "dynamodb_client"; // message: string; // details: ElectroError; // } | { // name: "error"; // type: "user_defined"; // message: string; // details: ElectroValidationError; // } | { // name: "warn"; // type: "deprecation_warning" | "optimization_suggestion"; // message: string; // details: any; // } | { // name: "info"; // type: "client_updated" | "table_overwritten"; // message: string; // details: any; // }; export type EntityIdentifiers> = E extends Entity ? AllTableIndexCompositeAttributes : never; export type EntityItem> = E extends Entity< infer A, infer F, infer C, infer S > ? ResponseItem : never; export type CreateEntityItem> = E extends Entity ? PutItem : never; export type BatchWriteEntityItem> = E extends Entity ? PutItem[] : never; export type BatchGetEntityItem> = E extends Entity ? ResponseItem[] : never; export type UpdateEntityResponseItem> = E extends Entity ? AllTableIndexCompositeAttributes : never; export type UpdateEntityItem> = E extends Entity ? SetItem : never; export type UpdateAddEntityItem> = E extends Entity ? AddItem : never; export type UpdateSubtractEntityItem> = E extends Entity ? SubtractItem : never; export type UpdateAppendEntityItem> = E extends Entity ? AppendItem : never; export type UpdateRemoveEntityItem> = E extends Entity ? RemoveItem : never; export type UpdateDeleteEntityItem> = E extends Entity ? DeleteItem : never; export type EntityRecord> = E extends Entity ? Item : never; export type CollectionItem< SERVICE extends Service, COLLECTION extends keyof SERVICE["collections"], > = SERVICE extends Service ? Pick< { [EntityName in keyof E]: E[EntityName] extends Entity< infer A, infer F, infer C, infer S > ? COLLECTION extends keyof CollectionAssociations ? EntityName extends CollectionAssociations[COLLECTION] ? ResponseItem[] : never : never : never; }, COLLECTION extends keyof CollectionAssociations ? CollectionAssociations[COLLECTION] : never > : never; export type QueryResponse> = { data: EntityItem[]; cursor: string | null; }; export type CreateEntityResponse> = { data: CreateEntityItem; }; export type BatchWriteResponse> = E extends Entity ? { unprocessed: AllTableIndexCompositeAttributes[]; } : never; export type BatchGetResponse> = E extends Entity ? { data: EntityItem[]; unprocessed: AllTableIndexCompositeAttributes[]; } : never; export type UpdateEntityResponse> = { data: UpdateEntityResponseItem; }; export type UpdateAddEntityResponse> = { data: UpdateAddEntityItem; }; export type UpdateSubtractEntityResponse> = { data: UpdateSubtractEntityItem; }; export type UpdateAppendEntityResponse> = { data: UpdateAppendEntityItem; }; export type UpdateRemoveEntityResponse> = { data: UpdateRemoveEntityItem; }; export type UpdateDeleteEntityResponse> = { data: UpdateDeleteEntityItem; }; export type CollectionResponse< SERVICE extends Service, COLLECTION extends keyof SERVICE["collections"], > = { data: CollectionItem; cursor: string | null; }; export interface QueryBranches< A extends string, F extends string, C extends string, S extends Schema, ResponseItem, IndexCompositeAttributes, > { go: GoQueryTerminal; params: ParamTerminal; where: WhereClause< A, F, C, S, Item, QueryBranches >; } export interface RecordsActionOptions< A extends string, F extends string, C extends string, S extends Schema, ResponseItem, IndexCompositeAttributes, > { go: QueryRecordsGo; params: ParamRecord; where: WhereClause< A, F, C, S, Item, RecordsActionOptions >; } export type TransactionItemCode = | "None" | "ConditionalCheckFailed" | "ItemCollectionSizeLimitExceeded" | "TransactionConflict" | "ProvisionedThroughputExceeded" | "ThrottlingError" | "ValidationError"; export type TransactionItem = { item: null | T; rejected: boolean; code: TransactionItemCode; message?: string | undefined; }; type CommittedTransactionResult = Params & { [TransactionSymbol]: T; }; export interface SingleRecordOperationOptions< A extends string, F extends string, C extends string, S extends Schema, ResponseType, > { go: GoGetTerminal; params: ParamTerminal; where: WhereClause< A, F, C, S, Item, SingleRecordOperationOptions >; } type GoGetTerminalTransaction< A extends string, F extends string, C extends string, S extends Schema, ResponseItem, Params, > = >( options?: Options, ) => Options extends GoQueryTerminalOptions ? CommittedTransactionResult< { [Name in keyof ResponseItem as Name extends Attr ? Name : never]: ResponseItem[Name]; }, Params > : CommittedTransactionResult; type GoSingleTerminalTransaction< A extends string, F extends string, C extends string, S extends Schema, ResponseItem, Params, > = ( options?: Options, ) => CommittedTransactionResult; export interface SingleRecordOperationOptionsTransaction< A extends string, F extends string, C extends string, S extends Schema, ResponseType, Params, > { commit: GoSingleTerminalTransaction; where: WhereClause< A, F, C, S, Item, SingleRecordOperationOptionsTransaction >; } export interface GetOperationOptionsTransaction< A extends string, F extends string, C extends string, S extends Schema, ResponseType, Params, > { commit: GoGetTerminalTransaction; } export type DeleteRecordOperationGoTransaction< ResponseType, Options = TransactWriteQueryOptions, > = ( options?: Options, ) => CommittedTransactionResult; export interface DeleteRecordOperationOptionsTransaction< A extends string, F extends string, C extends string, S extends Schema, ResponseType, > { commit: DeleteRecordOperationGoTransaction< ResponseType, TransactWriteQueryOptions >; where: WhereClause< A, F, C, S, Item, DeleteRecordOperationOptionsTransaction >; } export type PutRecordGoTransaction< ResponseType, Options = TransactWriteQueryOptions, > = ( options?: Options, ) => CommittedTransactionResult; export interface PutRecordOperationOptionsTransaction< A extends string, F extends string, C extends string, S extends Schema, ResponseType, > { commit: PutRecordGoTransaction; where: WhereClause< A, F, C, S, Item, PutRecordOperationOptionsTransaction >; } export type UpdateRecordGoTransaction = < T = ResponseType, Options extends TransactWriteQueryOptions = TransactWriteQueryOptions, >( options?: Options, ) => CommittedTransactionResult, TransactWriteItem>; export interface SetRecordActionOptionsTransaction< A extends string, F extends string, C extends string, S extends Schema, SetAttr, IndexCompositeAttributes, TableItem, > { commit: UpdateRecordGoTransaction; params: ParamRecord; set: SetRecordTransaction< A, F, C, S, SetItem, IndexCompositeAttributes, TableItem >; remove: RemoveRecordTransaction< A, F, C, S, Array>, IndexCompositeAttributes, TableItem >; add: SetRecordTransaction< A, F, C, S, AddItem, IndexCompositeAttributes, TableItem >; subtract: SetRecordTransaction< A, F, C, S, SubtractItem, IndexCompositeAttributes, TableItem >; append: SetRecordTransaction< A, F, C, S, AppendItem, IndexCompositeAttributes, TableItem >; delete: SetRecordTransaction< A, F, C, S, DeleteItem, IndexCompositeAttributes, TableItem >; data: DataUpdateMethodRecordTransaction< A, F, C, S, Item, IndexCompositeAttributes, TableItem >; composite: UpdateComposite< A, F, C, S, SetRecordActionOptionsTransaction< A, F, C, S, SetAttr, IndexCompositeAttributes, TableItem > >; where: WhereClause< A, F, C, S, Item, SetRecordActionOptionsTransaction< A, F, C, S, SetAttr, IndexCompositeAttributes, TableItem > >; } export type RemoveRecordTransaction< A extends string, F extends string, C extends string, S extends Schema, RemoveAttr, IndexCompositeAttributes, TableItem, > = ( properties: RemoveAttr, ) => SetRecordActionOptionsTransaction< A, F, C, S, RemoveAttr, IndexCompositeAttributes, TableItem >; export type SetRecordTransaction< A extends string, F extends string, C extends string, S extends Schema, SetAttr, IndexCompositeAttributes, TableItem, > = ( properties: SetAttr, ) => SetRecordActionOptionsTransaction< A, F, C, S, SetAttr, IndexCompositeAttributes, TableItem >; export type DataUpdateMethodRecordTransaction< A extends string, F extends string, C extends string, S extends Schema, SetAttr, IndexCompositeAttributes, TableItem, > = DataUpdateMethod< A, F, C, S, UpdateData, SetRecordActionOptionsTransaction< A, F, C, S, SetAttr, IndexCompositeAttributes, TableItem > >; export interface BatchGetRecordOperationOptions< A extends string, F extends string, C extends string, S extends Schema, ResponseType, > { go: GoBatchGetTerminal; params: ParamTerminal; } export interface PutRecordOperationOptions< A extends string, F extends string, C extends string, S extends Schema, ResponseType, > { go: PutRecordGo; params: ParamRecord; where: WhereClause< A, F, C, S, Item, PutRecordOperationOptions >; } type RequiredKeys = Exclude< { [K in keyof T]-?: {} extends Pick ? never : K }[keyof T], symbol >; type OverlappingProperties = { [Key in keyof T1 as Key extends keyof T2 ? Key : never]: Key extends keyof T2 ? T2[Key] : never; }; type NonOverlappingProperties = { [Key in keyof T1 as Key extends keyof T2 ? never : Key]: T1[Key]; }; export type UpsertRecordOperationOptionsTransaction< A extends string, F extends string, C extends string, S extends Schema, ResponseType, FullExpectedItem, RemainingExpectedItem, ProvidedItem, > = [RequiredKeys] extends [never] ? { commit: PutRecordGoTransaction; where: WhereClause< A, F, C, S, Item, UpsertRecordOperationOptionsTransaction< A, F, C, S, ResponseType, FullExpectedItem, RemainingExpectedItem, ProvidedItem > >; set: < ReceivedItem extends Partial< OverlappingProperties> >, >( item: ReceivedItem, ) => UpsertRecordOperationOptionsTransaction< A, F, C, S, ResponseType, FullExpectedItem, NonOverlappingProperties, NonOverlappingProperties >; ifNotExists: < ReceivedItem extends Partial< OverlappingProperties> >, >( item: ReceivedItem, ) => UpsertRecordOperationOptionsTransaction< A, F, C, S, ResponseType, FullExpectedItem, NonOverlappingProperties, NonOverlappingProperties >; add: < ReceivedItem extends Partial< OverlappingProperties> >, >( item: ReceivedItem, ) => UpsertRecordOperationOptionsTransaction< A, F, C, S, ResponseType, FullExpectedItem, NonOverlappingProperties, NonOverlappingProperties >; subtract: < ReceivedItem extends Partial< OverlappingProperties< RemainingExpectedItem, SubtractItem > >, >( item: ReceivedItem, ) => UpsertRecordOperationOptionsTransaction< A, F, C, S, ResponseType, FullExpectedItem, NonOverlappingProperties, NonOverlappingProperties >; append: < ReceivedItem extends Partial< OverlappingProperties> >, >( item: ReceivedItem, ) => UpsertRecordOperationOptionsTransaction< A, F, C, S, ResponseType, FullExpectedItem, NonOverlappingProperties, NonOverlappingProperties >; } : { // these are strings to give context to the user this is a builder pattern commit: | `Missing required attributes to perform upsert` | `Required: ${RequiredKeys}`; where: WhereClause< A, F, C, S, Item, UpsertRecordOperationOptionsTransaction< A, F, C, S, ResponseType, FullExpectedItem, RemainingExpectedItem, ProvidedItem > >; set: < ReceivedItem extends Partial< OverlappingProperties> >, >( item: ReceivedItem, ) => UpsertRecordOperationOptionsTransaction< A, F, C, S, ResponseType, FullExpectedItem, NonOverlappingProperties, NonOverlappingProperties >; ifNotExists: < ReceivedItem extends Partial< OverlappingProperties> >, >( item: ReceivedItem, ) => UpsertRecordOperationOptionsTransaction< A, F, C, S, ResponseType, FullExpectedItem, NonOverlappingProperties, NonOverlappingProperties >; add: < ReceivedItem extends Partial< OverlappingProperties> >, >( item: ReceivedItem, ) => UpsertRecordOperationOptionsTransaction< A, F, C, S, ResponseType, FullExpectedItem, NonOverlappingProperties, NonOverlappingProperties >; subtract: < ReceivedItem extends Partial< OverlappingProperties< RemainingExpectedItem, SubtractItem > >, >( item: ReceivedItem, ) => UpsertRecordOperationOptionsTransaction< A, F, C, S, ResponseType, FullExpectedItem, NonOverlappingProperties, NonOverlappingProperties >; append: < ReceivedItem extends Partial< OverlappingProperties> >, >( item: ReceivedItem, ) => UpsertRecordOperationOptionsTransaction< A, F, C, S, ResponseType, FullExpectedItem, NonOverlappingProperties, NonOverlappingProperties >; }; export type UpsertRecordOperationOptions< A extends string, F extends string, C extends string, S extends Schema, ResponseType, FullExpectedItem, RemainingExpectedItem, ProvidedItem, > = [RequiredKeys] extends [never] ? { go: UpsertRecordGo< ResponseType, AllTableIndexCompositeAttributes >; params: ParamRecord; where: WhereClause< A, F, C, S, Item, UpsertRecordOperationOptions< A, F, C, S, ResponseType, FullExpectedItem, RemainingExpectedItem, ProvidedItem > >; set: < ReceivedItem extends Partial< OverlappingProperties> >, >( item: ReceivedItem, ) => UpsertRecordOperationOptions< A, F, C, S, ResponseType, FullExpectedItem, NonOverlappingProperties, NonOverlappingProperties >; ifNotExists: < ReceivedItem extends Partial< OverlappingProperties> >, >( item: ReceivedItem, ) => UpsertRecordOperationOptions< A, F, C, S, ResponseType, FullExpectedItem, NonOverlappingProperties, NonOverlappingProperties >; add: < ReceivedItem extends Partial< OverlappingProperties> >, >( item: ReceivedItem, ) => UpsertRecordOperationOptions< A, F, C, S, ResponseType, FullExpectedItem, NonOverlappingProperties, NonOverlappingProperties >; subtract: < ReceivedItem extends Partial< OverlappingProperties< RemainingExpectedItem, SubtractItem > >, >( item: ReceivedItem, ) => UpsertRecordOperationOptions< A, F, C, S, ResponseType, FullExpectedItem, NonOverlappingProperties, NonOverlappingProperties >; append: < ReceivedItem extends Partial< OverlappingProperties> >, >( item: ReceivedItem, ) => UpsertRecordOperationOptions< A, F, C, S, ResponseType, FullExpectedItem, NonOverlappingProperties, NonOverlappingProperties >; } : { // these are strings to give context to the user this is a builder pattern go: | `Missing required attributes to perform upsert` | `Required: ${RequiredKeys}`; params: | `Missing required attributes to perform upsert` | `Required: ${RequiredKeys}`; where: WhereClause< A, F, C, S, Item, UpsertRecordOperationOptions< A, F, C, S, ResponseType, FullExpectedItem, RemainingExpectedItem, ProvidedItem > >; set: < ReceivedItem extends Partial< OverlappingProperties> >, >( item: ReceivedItem, ) => UpsertRecordOperationOptions< A, F, C, S, ResponseType, FullExpectedItem, NonOverlappingProperties, NonOverlappingProperties >; ifNotExists: < ReceivedItem extends Partial< OverlappingProperties> >, >( item: ReceivedItem, ) => UpsertRecordOperationOptions< A, F, C, S, ResponseType, FullExpectedItem, NonOverlappingProperties, NonOverlappingProperties >; add: < ReceivedItem extends Partial< OverlappingProperties> >, >( item: ReceivedItem, ) => UpsertRecordOperationOptions< A, F, C, S, ResponseType, FullExpectedItem, NonOverlappingProperties, NonOverlappingProperties >; subtract: < ReceivedItem extends Partial< OverlappingProperties< RemainingExpectedItem, SubtractItem > >, >( item: ReceivedItem, ) => UpsertRecordOperationOptions< A, F, C, S, ResponseType, FullExpectedItem, NonOverlappingProperties, NonOverlappingProperties >; append: < ReceivedItem extends Partial< OverlappingProperties> >, >( item: ReceivedItem, ) => UpsertRecordOperationOptions< A, F, C, S, ResponseType, FullExpectedItem, NonOverlappingProperties, NonOverlappingProperties >; }; export interface DeleteRecordOperationOptions< A extends string, F extends string, C extends string, S extends Schema, ResponseType, > { go: DeleteRecordOperationGo< ResponseType, AllTableIndexCompositeAttributes >; params: ParamRecord; where: WhereClause< A, F, C, S, Item, DeleteRecordOperationOptions >; } export interface BatchWriteOperationOptions< A extends string, F extends string, C extends string, S extends Schema, ResponseType, > { go: BatchWriteGo; params: ParamRecord; } export interface SetRecordActionOptions< A extends string, F extends string, C extends string, S extends Schema, SetAttr, IndexCompositeAttributes, TableItem, > { go: UpdateRecordGo>; params: ParamRecord; set: SetRecord< A, F, C, S, SetItem, IndexCompositeAttributes, TableItem >; // ifNotExists: SetRecord,IndexCompositeAttributes,TableItem>; remove: SetRecord< A, F, C, S, Array>, IndexCompositeAttributes, TableItem >; add: SetRecord< A, F, C, S, AddItem, IndexCompositeAttributes, TableItem >; subtract: SetRecord< A, F, C, S, SubtractItem, IndexCompositeAttributes, TableItem >; append: SetRecord< A, F, C, S, AppendItem, IndexCompositeAttributes, TableItem >; delete: SetRecord< A, F, C, S, DeleteItem, IndexCompositeAttributes, TableItem >; composite: UpdateComposite< A, F, C, S, SetRecordActionOptions< A, F, C, S, SetAttr, IndexCompositeAttributes, TableItem > >; data: DataUpdateMethodRecord< A, F, C, S, Item, IndexCompositeAttributes, TableItem >; where: WhereClause< A, F, C, S, Item, SetRecordActionOptions< A, F, C, S, SetAttr, IndexCompositeAttributes, TableItem > >; } export type SetRecord< A extends string, F extends string, C extends string, S extends Schema, SetAttr, IndexCompositeAttributes, TableItem, > = ( properties: SetAttr, ) => SetRecordActionOptions< A, F, C, S, SetAttr, IndexCompositeAttributes, TableItem >; export type RemoveRecord< A extends string, F extends string, C extends string, S extends Schema, RemoveAttr, IndexCompositeAttributes, TableItem, > = ( properties: RemoveAttr, ) => SetRecordActionOptions< A, F, C, S, RemoveAttr, IndexCompositeAttributes, TableItem >; export type DataUpdateMethodRecord< A extends string, F extends string, C extends string, S extends Schema, SetAttr, IndexCompositeAttributes, TableItem, > = DataUpdateMethod< A, F, C, S, UpdateData, SetRecordActionOptions< A, F, C, S, SetAttr, IndexCompositeAttributes, TableItem > >; interface QueryOperations< A extends string, F extends string, C extends string, S extends Schema, CompositeAttributes, ResponseItem, IndexCompositeAttributes, > { between: ( skCompositeAttributesStart: CompositeAttributes, skCompositeAttributesEnd: CompositeAttributes, ) => QueryBranches; gt: ( skCompositeAttributes: CompositeAttributes, ) => QueryBranches; gte: ( skCompositeAttributes: CompositeAttributes, ) => QueryBranches; lt: ( skCompositeAttributes: CompositeAttributes, ) => QueryBranches; lte: ( skCompositeAttributes: CompositeAttributes, ) => QueryBranches; begins: ( skCompositeAttributes: CompositeAttributes, ) => QueryBranches; go: GoQueryTerminal; params: ParamTerminal; where: WhereClause< A, F, C, S, Item, QueryBranches >; } type IndexKeyComposite< A extends string, F extends string, C extends string, S extends Schema, I extends keyof S["indexes"], > = IndexCompositeAttributes & TableIndexCompositeAttributes; type IndexKeyCompositeWithMaybeTableIndex< A extends string, F extends string, C extends string, S extends Schema, I extends keyof S["indexes"], > = IndexCompositeAttributes & Partial>; type IndexKeyCompositeFromItem< A extends string, F extends string, C extends string, S extends Schema, I extends keyof S["indexes"], > = Partial> & Partial>; type ConversionOptions = { strict?: "all" | "pk" | "none"; }; export type Conversions< A extends string, F extends string, C extends string, S extends Schema, > = { fromComposite: { toCursor: ( composite: { [I in keyof S["indexes"]]: IndexKeyCompositeWithMaybeTableIndex< A, F, C, S, I >; }[keyof S["indexes"]], ) => string; toKeys: >( composite: { [I in keyof S["indexes"]]: IndexKeyCompositeWithMaybeTableIndex< A, F, C, S, I >; }[keyof S["indexes"]], options?: ConversionOptions, ) => T; }; fromKeys: { toComposite: < T = { [I in keyof S["indexes"]]: IndexKeyCompositeFromItem; }[keyof S["indexes"]], >( keys: Record, ) => T; toCursor: (keys: Record) => string; }; fromCursor: { toKeys: >(cursor: string) => T; toComposite: < T = Partial<{ [I in keyof S["indexes"]]: IndexKeyCompositeFromItem; }>[keyof S["indexes"]], >( cursor: string, ) => T; }; byAccessPattern: { [I in keyof S["indexes"]]: { fromKeys: { toCursor: (keys: Record) => string; // keys supplied may include the table index, maybe not so composite attributes for the table index are `Partial` toComposite: >( keys: Record, options?: ConversionOptions, ) => T; }; fromCursor: { toKeys: >( cursor: string, options?: ConversionOptions, ) => T; // a cursor must have the table index defined along with the keys for the index (if applicable) toComposite: >( cursor: string, options?: ConversionOptions, ) => T; }; fromComposite: { // a cursor must have the table index defined along with the keys for the index (if applicable) toCursor: ( composite: IndexKeyComposite, options?: ConversionOptions, ) => string; // maybe the only keys you need are for this index and not the toKeys: >( composite: IndexKeyCompositeWithMaybeTableIndex, options?: ConversionOptions, ) => T; }; }; }; }; export type Queries< A extends string, F extends string, C extends string, S extends Schema, > = { [I in keyof S["indexes"]]: < CompositeAttributes extends IndexCompositeAttributes, >( composite: CompositeAttributes, ) => IndexSKAttributes extends infer SK ? // If there is no SK, dont show query operations (when an empty array is provided) [keyof SK] extends [never] ? QueryBranches< A, F, C, S, ResponseItem, AllTableIndexCompositeAttributes & Required > : // If there is no SK, dont show query operations (When no PK is specified) S["indexes"][I] extends IndexWithSortKey ? QueryOperations< A, F, C, S, // Omit the composite attributes already provided Omit< Partial>, keyof CompositeAttributes >, ResponseItem, AllTableIndexCompositeAttributes & Required & SK > : QueryBranches< A, F, C, S, ResponseItem, AllTableIndexCompositeAttributes & Required & SK > : never; }; export type ParseSingleInput = | { Item?: { [key: string]: any }; } | { Attributes?: { [key: string]: any }; } | null; export type ParseMultiInput = { Items?: { [key: string]: any }[]; }; export type ReturnValues = | "default" | "none" | "all_old" | "updated_old" | "all_new" | "updated_new"; export interface QueryOptions { cursor?: string | null; params?: object; table?: string; limit?: number; count?: number; originalErr?: boolean; ignoreOwnership?: boolean; pages?: number | "all"; listeners?: Array; logger?: ElectroEventListener; data?: "raw" | "includeKeys" | "attributes"; order?: "asc" | "desc"; consistent?: boolean; } // subset of QueryOptions export interface ParseOptions { attributes?: ReadonlyArray; ignoreOwnership?: boolean; } export interface UpdateQueryOptions extends QueryOptions { response?: | "default" | "none" | "all_old" | "updated_old" | "all_new" | "updated_new"; } export interface UpdateQueryParams { response?: | "default" | "none" | "all_old" | "updated_old" | "all_new" | "updated_new"; table?: string; params?: object; originalErr?: boolean; } export interface DeleteQueryOptions extends QueryOptions { response?: "default" | "none" | "all_old"; } export interface PutQueryOptions extends QueryOptions { response?: "default" | "none" | "all_old" | "all_new"; } export type ParamOptions = { cursor?: string | null; params?: object; table?: string; limit?: number; response?: | "default" | "none" | "all_old" | "updated_old" | "all_new" | "updated_new"; order?: "asc" | "desc"; consistent?: boolean; } & QueryExecutionComparisonParts; export interface BulkOptions extends QueryOptions { unprocessed?: "raw" | "item"; /** * @deprecated use "concurrent" instead */ concurrency?: number; concurrent?: number; preserveBatchOrder?: boolean; } export type OptionalDefaultEntityIdentifiers = { __edb_e__?: string; __edb_v__?: string; }; interface GoBatchGetTerminalOptions { data?: "raw" | "includeKeys" | "attributes"; table?: string; limit?: number; params?: object; originalErr?: boolean; ignoreOwnership?: boolean; pages?: number; attributes?: ReadonlyArray; unprocessed?: "raw" | "item"; /** * @deprecated use "concurrent" instead */ concurrency?: number; concurrent?: number; preserveBatchOrder?: boolean; listeners?: Array; logger?: ElectroEventListener; consistent?: boolean; } export type ExecutionOptionCompare = "keys" | "attributes" | "v2"; export type QueryExecutionComparisonParts = { compare?: "keys" | "attributes" } | { /** * @deprecated 'v2' exists to ease user migration to ElectroDB v3. Support for this option will eventually be dropped. */ compare?: "v2" } type ServiceQueryGoTerminalOptions = { cursor?: string | null; data?: "raw" | "includeKeys" | "attributes"; table?: string; limit?: number; params?: object; originalErr?: boolean; ignoreOwnership?: boolean; pages?: number | "all"; listeners?: Array; logger?: ElectroEventListener; order?: "asc" | "desc"; hydrate?: boolean; consistent?: boolean; } & QueryExecutionComparisonParts; type GoQueryTerminalOptions = { cursor?: string | null; data?: "raw" | "includeKeys" | "attributes"; table?: string; limit?: number; count?: number; params?: object; originalErr?: boolean; ignoreOwnership?: boolean; pages?: number | "all"; attributes?: ReadonlyArray; listeners?: Array; logger?: ElectroEventListener; order?: "asc" | "desc"; hydrate?: boolean; consistent?: boolean; } & QueryExecutionComparisonParts; interface TransactWriteQueryOptions { data?: "raw" | "includeKeys" | "attributes"; table?: string; params?: object; originalErr?: boolean; ignoreOwnership?: boolean; listeners?: Array; logger?: ElectroEventListener; response?: "all_old"; } interface TransactGetQueryOptions { data?: "raw" | "includeKeys" | "attributes"; table?: string; params?: object; originalErr?: boolean; ignoreOwnership?: boolean; attributes?: ReadonlyArray; listeners?: Array; logger?: ElectroEventListener; consistent?: boolean; } export type ParamTerminalOptions = { table?: string; limit?: number; params?: object; originalErr?: boolean; consistent?: boolean; attributes?: ReadonlyArray; response?: | "default" | "none" | "all_old" | "updated_old" | "all_new" | "updated_new"; order?: "asc" | "desc"; } & QueryExecutionComparisonParts; type GoBatchGetTerminal< A extends string, F extends string, C extends string, S extends Schema, ResponseItem, > = >( options?: Options, ) => Options extends GoBatchGetTerminalOptions ? "preserveBatchOrder" extends keyof Options ? Options["preserveBatchOrder"] extends true ? Promise<{ data: Array< Resolve< | { [Name in keyof ResponseItem as Name extends Attr ? Name : never]: ResponseItem[Name]; } | null > >; unprocessed: Array< Resolve> >; }> : Promise<{ data: Array< Resolve<{ [Name in keyof ResponseItem as Name extends Attr ? Name : never]: ResponseItem[Name]; }> >; unprocessed: Array< Resolve> >; }> : Promise<{ data: Array< Resolve<{ [Name in keyof ResponseItem as Name extends Attr ? Name : never]: ResponseItem[Name]; }> >; unprocessed: Array< Resolve> >; }> : "preserveBatchOrder" extends keyof Options ? Options["preserveBatchOrder"] extends true ? Promise<{ data: Array>; unprocessed: Array< Resolve> >; }> : Promise<{ data: Array>; unprocessed: Array< Resolve> >; }> : Promise<{ data: Array>; unprocessed: Array>>; }>; type GoGetTerminal< A extends string, F extends string, C extends string, S extends Schema, ResponseItem, > = >( options?: Options, ) => Options extends GoQueryTerminalOptions ? Promise<{ data: | { [Name in keyof ResponseItem as Name extends Attr ? Name : never]: ResponseItem[Name]; } | null; }> : Promise<{ data: ResponseItem | null }>; export type GoQueryTerminal< A extends string, F extends string, C extends string, S extends Schema, Item, > = >( options?: Options, ) => Options extends GoQueryTerminalOptions ? Promise<{ data: Array<{ [Name in keyof Item as Name extends Attr ? Name : never]: Item[Name]; }>; cursor: string | null; }> : Promise<{ data: Array; cursor: string | null }>; export type EntityParseMultipleItems< A extends string, F extends string, C extends string, S extends Schema, ResponseItem, > = >( item: ParseMultiInput, options?: Options, ) => Options extends ParseOptions ? { data: Array<{ [Name in keyof ResponseItem as Name extends Attr ? Name : never]: ResponseItem[Name]; }>; cursor?: string | null; } : { data: Array; cursor?: string | null }; export type ParamTerminal< A extends string, F extends string, C extends string, S extends Schema, ResponseItem, > = < P extends any = any, Options extends ParamTerminalOptions< keyof ResponseItem > = ParamTerminalOptions, >( options?: Options, ) => P; export type ServiceQueryRecordsGo< ResponseType, Options = ServiceQueryGoTerminalOptions, > = ( options?: Options, ) => Promise<{ data: T; cursor: string | null }>; export type QueryRecordsGo = >( options?: Options, ) => Options extends GoQueryTerminalOptions ? Promise<{ data: Array<{ [Name in keyof Item as Name extends Attr ? Name : never]: Item[Name]; }>; cursor: string | null; }> : Promise<{ data: Array; cursor: string | null }>; export type UpdateRecordGo = < T = ResponseType, Options extends UpdateQueryOptions = UpdateQueryOptions, >( options?: Options, ) => Options extends infer O ? "response" extends keyof O ? O["response"] extends "all_new" ? Promise<{ data: T }> : O["response"] extends "all_old" ? Promise<{ data: T }> : O["response"] extends "default" ? Promise<{ data: Keys }> : O["response"] extends "none" ? Promise<{ data: null }> : Promise<{ data: Partial }> : Promise<{ data: Keys }> : never; export type UpsertRecordGo = < T = ResponseType, Options extends UpdateQueryOptions = UpdateQueryOptions, >( options?: Options, ) => Options extends infer O ? "response" extends keyof O ? O["response"] extends "all_new" ? Promise<{ data: T }> : O["response"] extends "all_old" ? Promise<{ data: T }> : O["response"] extends "default" ? Promise<{ data: Keys }> : O["response"] extends "none" ? Promise<{ data: null }> : Promise<{ data: Partial }> : Promise<{ data: Keys }> : never; export type PutRecordGo = < T = ResponseType, Options extends PutQueryOptions = PutQueryOptions, >( options?: Options, ) => Promise<{ data: T }>; export type DeleteRecordOperationGo = < T = ResponseType, Options extends DeleteQueryOptions = DeleteQueryOptions, >( options?: Options, ) => Options extends infer O ? "response" extends keyof O ? O["response"] extends "all_old" ? Promise<{ data: T | null }> : O["response"] extends "default" ? Promise<{ data: Keys }> : O["response"] extends "none" ? Promise<{ data: null }> : Promise<{ data: Keys | null }> : Promise<{ data: Keys }> : never; export type BatchWriteGo = ( options?: O, ) => Promise<{ unprocessed: ResponseType }>; export type ParamRecord =

>( options?: Options, ) => P; export class ElectroError extends Error { readonly name: "ElectroError"; readonly code: number; readonly date: number; readonly cause: E | undefined; readonly isElectroError: boolean; readonly params: >() => T | null; readonly ref: { readonly code: number; readonly section: string; readonly name: string; readonly sym: unique symbol; }; } export interface ElectroValidationErrorFieldReference { /** * The json path to the attribute that had a validation error */ readonly field: string; /** * A description of the validation error for that attribute */ readonly reason: string; /** * Index of the value passed (present only in List attribute validation errors) */ readonly index: number | undefined; /** * The error thrown from the attribute's validate callback (if applicable) */ readonly cause: T | undefined; } export class ElectroValidationError< T extends Error = Error, > extends ElectroError { readonly fields: ReadonlyArray>; } export interface ReadOnlyAttribute { readonly readOnly: true; } export interface RequiredAttribute { required: true; } export interface HiddenAttribute { readonly hidden: true; } export interface DefaultedAttribute { readonly default: any; } export interface SecondaryIndex { readonly index: string; } export interface NestedBooleanAttribute { readonly type: "boolean"; readonly required?: boolean; readonly hidden?: boolean; readonly readOnly?: boolean; readonly get?: (val: boolean, item: any) => boolean | undefined | void; readonly set?: (val?: boolean, item?: any) => boolean | undefined | void; readonly default?: boolean | (() => boolean); readonly validate?: ((val: boolean) => boolean) readonly field?: string; } export interface BooleanAttribute { readonly type: "boolean"; readonly required?: boolean; readonly hidden?: boolean; readonly readOnly?: boolean; readonly get?: (val: boolean, item: any) => boolean | undefined | void; readonly set?: (val?: boolean, item?: any) => boolean | undefined | void; readonly default?: boolean | (() => boolean); readonly validate?: ((val: boolean) => boolean) readonly field?: string; readonly label?: string; readonly watch?: ReadonlyArray | "*"; readonly padding?: { length: number; char: string; }; } export interface NestedNumberAttribute { readonly type: "number"; readonly required?: boolean; readonly hidden?: boolean; readonly readOnly?: boolean; readonly get?: (val: number, item: any) => number | undefined | void; readonly set?: (val?: number, item?: any) => number | undefined | void; readonly default?: number | (() => number); readonly validate?: ((val: number) => boolean) readonly field?: string; } export interface NumberAttribute { readonly type: "number"; readonly required?: boolean; readonly hidden?: boolean; readonly readOnly?: boolean; readonly get?: (val: number, item: any) => number | undefined | void; readonly set?: (val?: number, item?: any) => number | undefined | void; readonly default?: number | (() => number); readonly validate?: ((val: number) => boolean) readonly field?: string; readonly label?: string; readonly watch?: ReadonlyArray | "*"; readonly padding?: { length: number; char: string; }; } export interface NestedStringAttribute { readonly type: "string"; readonly required?: boolean; readonly hidden?: boolean; readonly readOnly?: boolean; readonly get?: (val: string, item: any) => string | undefined | void; readonly set?: (val?: string, item?: any) => string | undefined | void; readonly default?: string | (() => string); readonly validate?: | ((val: string) => boolean) | RegExp; readonly field?: string; } export interface StringAttribute { readonly type: "string"; readonly required?: boolean; readonly hidden?: boolean; readonly readOnly?: boolean; readonly get?: (val: string, item: any) => string | undefined | void; readonly set?: (val?: string, item?: any) => string | undefined | void; readonly default?: string | (() => string); readonly validate?: | ((val: string) => boolean) | RegExp; readonly field?: string; readonly label?: string; readonly watch?: ReadonlyArray | "*"; readonly padding?: { length: number; char: string; }; } export interface NestedEnumAttribute { readonly type: ReadonlyArray; readonly required?: boolean; readonly hidden?: boolean; readonly readOnly?: boolean; readonly get?: (val: any, item: any) => any | undefined | void; readonly set?: (val?: any, item?: any) => any | undefined | void; readonly default?: string | (() => string); readonly validate?: ((val: any) => boolean) readonly field?: string; readonly label?: string; } export interface EnumAttribute { readonly type: ReadonlyArray; readonly required?: boolean; readonly hidden?: boolean; readonly readOnly?: boolean; readonly get?: (val: any, item: any) => any | undefined | void; readonly set?: (val?: any, item?: any) => any | undefined | void; readonly default?: string | (() => string); readonly validate?: ((val: any) => boolean) readonly field?: string; readonly label?: string; readonly watch?: ReadonlyArray | "*"; } export interface NestedAnyAttribute { readonly type: "any"; readonly required?: boolean; readonly hidden?: boolean; readonly readOnly?: boolean; readonly get?: (val: any, item: any) => any | undefined | void; readonly set?: (val?: any, item?: any) => any | undefined | void; readonly default?: any | (() => any); readonly validate?: ((val: any) => boolean) readonly field?: string; } export interface AnyAttribute { readonly type: "any"; readonly required?: boolean; readonly hidden?: boolean; readonly readOnly?: boolean; readonly get?: (val: any, item: any) => any | undefined | void; readonly set?: (val?: any, item?: any) => any | undefined | void; readonly default?: any | (() => any); readonly validate?: ((val: any) => boolean) readonly field?: string; readonly label?: string; readonly watch?: ReadonlyArray | "*"; } export interface NestedMapAttribute { readonly type: "map"; readonly properties: { readonly [name: string]: NestedAttributes; }; readonly required?: boolean; readonly hidden?: boolean; readonly readOnly?: boolean; readonly get?: ( val: Record, item: any, ) => Record | undefined | void; readonly set?: ( val?: Record, item?: any, ) => Record | undefined | void; readonly default?: Record | (() => Record); readonly validate?: ((val: Record) => boolean) readonly field?: string; } export interface MapAttribute { readonly type: "map"; readonly properties: { readonly [name: string]: NestedAttributes; }; readonly required?: boolean; readonly hidden?: boolean; readonly readOnly?: boolean; readonly get?: ( val: Record, item: any, ) => Record | undefined | void; readonly set?: ( val?: Record, item?: any, ) => Record | undefined | void; readonly default?: Record | (() => Record); readonly validate?: ((val: Record) => boolean) readonly field?: string; readonly watch?: ReadonlyArray | "*"; } export interface NestedCustomListAttribute { readonly type: "list"; readonly items: CustomAttribute; readonly required?: boolean; readonly hidden?: boolean; readonly readOnly?: boolean; readonly get?: ( val: Array, item: any, ) => Array | undefined | void; readonly set?: ( val?: Array, item?: any, ) => Array | undefined | void; readonly default?: Array | (() => Array); readonly validate?: ((val: Array) => boolean) } export interface NestedStringListAttribute { readonly type: "list"; readonly items: { readonly type: "string"; readonly required?: boolean; readonly hidden?: boolean; readonly readOnly?: boolean; readonly get?: (val: string, item: any) => string | undefined | void; readonly set?: (val?: string, item?: any) => string | undefined | void; readonly default?: string | (() => string); readonly validate?: | ((val: string) => boolean) | RegExp; readonly field?: string; }; readonly required?: boolean; readonly hidden?: boolean; readonly readOnly?: boolean; readonly get?: ( val: Array, item: any, ) => Array | undefined | void; readonly set?: ( val?: Array, item?: any, ) => Array | undefined | void; readonly default?: Array | (() => Array); readonly validate?: ((val: Array) => boolean) } export interface StringListAttribute { readonly type: "list"; readonly items: { readonly type: "string"; readonly required?: boolean; readonly hidden?: boolean; readonly readOnly?: boolean; readonly get?: (val: string, item: any) => string | undefined | void; readonly set?: (val?: string, item?: any) => string | undefined | void; readonly default?: string | (() => string); readonly validate?: | ((val: string) => boolean) | RegExp; readonly field?: string; }; readonly required?: boolean; readonly hidden?: boolean; readonly readOnly?: boolean; readonly get?: ( val: Array, item: any, ) => Array | undefined | void; readonly set?: ( val?: Array, item?: any, ) => Array | undefined | void; readonly default?: Array | (() => Array); readonly validate?: ((val: Array) => boolean) readonly watch?: ReadonlyArray | "*"; } export interface NestedNumberListAttribute { readonly type: "list"; readonly items: NestedNumberAttribute; readonly required?: boolean; readonly hidden?: boolean; readonly readOnly?: boolean; readonly get?: ( val: Array, item: any, ) => Array | undefined | void; readonly set?: ( val?: Array, item?: any, ) => Array | undefined | void; readonly default?: Array | (() => Array); readonly validate?: ((val: Array) => boolean) readonly field?: string; } export interface NumberListAttribute { readonly type: "list"; readonly items: NestedNumberAttribute; readonly required?: boolean; readonly hidden?: boolean; readonly readOnly?: boolean; readonly get?: ( val: Array, item: any, ) => Array | undefined | void; readonly set?: ( val?: Array, item?: any, ) => Array | undefined | void; readonly default?: Array | (() => Array); readonly validate?: ((val: Array) => boolean) readonly field?: string; readonly watch?: ReadonlyArray | "*"; } export interface NestedMapListAttribute { readonly type: "list"; readonly items: NestedMapAttribute; readonly required?: boolean; readonly hidden?: boolean; readonly readOnly?: boolean; readonly get?: ( val: Record[], item: any, ) => Record[] | undefined | void; readonly set?: ( val?: Record[], item?: any, ) => Record[] | undefined | void; readonly default?: Record[] | (() => Record[]); readonly validate?: ((val: Record[]) => boolean) readonly field?: string; } export interface NestedAnyListAttribute { readonly type: "list"; readonly items: NestedAnyAttribute; readonly required?: boolean; readonly hidden?: boolean; readonly readOnly?: boolean; readonly get?: ( val: Record[], item: any, ) => Record[] | undefined | void; readonly set?: ( val?: Record[], item?: any, ) => Record[] | undefined | void; readonly default?: Record[] | (() => Record[]); readonly validate?: ((val: Record[]) => boolean) readonly field?: string; } export interface MapListAttribute { readonly type: "list"; readonly items: NestedMapAttribute; readonly required?: boolean; readonly hidden?: boolean; readonly readOnly?: boolean; readonly get?: ( val: Record[], item: any, ) => Record[] | undefined | void; readonly set?: ( val?: Record[], item?: any, ) => Record[] | undefined | void; readonly default?: Record[] | (() => Record[]); readonly validate?: ((val: Record[]) => boolean) readonly field?: string; readonly watch?: ReadonlyArray | "*"; } export interface CustomListAttribute { readonly type: "list"; readonly items: NestedCustomAttribute; readonly required?: boolean; readonly hidden?: boolean; readonly readOnly?: boolean; readonly get?: ( val: Array, item: any, ) => Array | undefined | void; readonly set?: ( val?: Array, item?: any, ) => Array | undefined | void; readonly default?: Array | (() => Array); readonly validate?: ((val: Array) => boolean); readonly field?: string; readonly watch?: ReadonlyArray | "*"; } export interface AnyListAttribute { readonly type: "list"; readonly items: NestedAnyAttribute; readonly required?: boolean; readonly hidden?: boolean; readonly readOnly?: boolean; readonly get?: ( val: Array, item: any, ) => Array | undefined | void; readonly set?: ( val?: Array, item?: any, ) => Array | undefined | void; readonly default?: Array | (() => Array); readonly validate?: ((val: Array) => boolean) readonly field?: string; readonly watch?: ReadonlyArray | "*"; } export interface NestedStringSetAttribute { readonly type: "set"; readonly items: "string"; readonly required?: boolean; readonly hidden?: boolean; readonly readOnly?: boolean; readonly get?: ( val: Array, item: any, ) => Array | undefined | void; readonly set?: ( val?: Array, item?: any, ) => Array | undefined | void; readonly default?: Array | (() => Array); readonly validate?: | ((val: Array) => boolean) | RegExp; readonly field?: string; } export interface NestedEnumNumberSetAttribute { readonly type: "set"; readonly items: ReadonlyArray; readonly required?: boolean; readonly hidden?: boolean; readonly readOnly?: boolean; readonly get?: ( val: Array, item: any, ) => Array | undefined | void; readonly set?: ( val?: Array, item?: any, ) => Array | undefined | void; readonly default?: Array | (() => Array); readonly validate?: ((val: Array) => boolean) readonly field?: string; } export interface EnumNumberSetAttribute { readonly type: "set"; readonly items: ReadonlyArray; readonly required?: boolean; readonly hidden?: boolean; readonly readOnly?: boolean; readonly get?: ( val: Array, item: any, ) => Array | undefined | void; readonly set?: ( val?: Array, item?: any, ) => Array | undefined | void; readonly default?: Array | (() => Array); readonly validate?: ((val: Array) => boolean) readonly field?: string; readonly watch?: ReadonlyArray | "*"; } export interface NestedEnumStringSetAttribute { readonly type: "set"; readonly items: ReadonlyArray; readonly required?: boolean; readonly hidden?: boolean; readonly readOnly?: boolean; readonly get?: ( val: Array, item: any, ) => Array | undefined | void; readonly set?: ( val?: Array, item?: any, ) => Array | undefined | void; readonly default?: Array | (() => Array); readonly validate?: | ((val: Array) => boolean) | RegExp; readonly field?: string; } export interface EnumStringSetAttribute { readonly type: "set"; readonly items: ReadonlyArray; readonly required?: boolean; readonly hidden?: boolean; readonly readOnly?: boolean; readonly get?: ( val: Array, item: any, ) => Array | undefined | void; readonly set?: ( val?: Array, item?: any, ) => Array | undefined | void; readonly default?: Array | (() => Array); readonly validate?: | ((val: Array) => boolean) | RegExp; readonly field?: string; readonly watch?: ReadonlyArray | "*"; } export interface StringSetAttribute { readonly type: "set"; readonly items: "string"; readonly required?: boolean; readonly hidden?: boolean; readonly readOnly?: boolean; readonly get?: ( val: Array, item: any, ) => Array | undefined | void; readonly set?: ( val?: Array, item?: any, ) => Array | undefined | void; readonly default?: Array | (() => Array); readonly validate?: | ((val: Array) => boolean) | RegExp; readonly field?: string; readonly watch?: ReadonlyArray | "*"; } export interface NestedNumberSetAttribute { readonly type: "set"; readonly items: "number"; readonly required?: boolean; readonly hidden?: boolean; readonly readOnly?: boolean; readonly get?: ( val: Array, item: any, ) => Array | undefined | void; readonly set?: ( val?: Array, item?: any, ) => Array | undefined | void; readonly default?: Array | (() => Array); readonly validate?: ((val: Array) => boolean) readonly field?: string; } export interface NumberSetAttribute { readonly type: "set"; readonly items: "number"; readonly required?: boolean; readonly hidden?: boolean; readonly readOnly?: boolean; readonly get?: ( val: Array, item: any, ) => Array | undefined | void; readonly set?: ( val?: Array, item?: any, ) => Array | undefined | void; readonly default?: Array | (() => Array); readonly validate?: ((val: Array) => boolean) readonly field?: string; readonly watch?: ReadonlyArray | "*"; } interface CustomAttributeTypeName { readonly [CustomAttributeSymbol]: T; } interface CustomPrimitiveTypeName { readonly [OpaquePrimitiveSymbol]: T; } export type OpaquePrimitiveTypeName = T extends string ? "string" & CustomPrimitiveTypeName : T extends number ? "number" & CustomPrimitiveTypeName : T extends boolean ? "boolean" & CustomPrimitiveTypeName : never; type CustomAttribute = { readonly type: CustomAttributeTypeName | OpaquePrimitiveTypeName; readonly required?: boolean; readonly hidden?: boolean; readonly readOnly?: boolean; readonly get?: (val: any, item: any) => any | undefined | void; readonly set?: (val?: any, item?: any) => any | undefined | void; readonly default?: any | (() => any); readonly validate?: ((val: any) => boolean) readonly field?: string; readonly watch?: ReadonlyArray | "*"; }; type NestedCustomAttribute = { readonly type: CustomAttributeTypeName | OpaquePrimitiveTypeName; readonly required?: boolean; readonly hidden?: boolean; readonly readOnly?: boolean; readonly get?: (val: any, item: any) => any | undefined | void; readonly set?: (val?: any, item?: any) => any | undefined | void; readonly default?: any | (() => any); readonly validate?: ((val: any) => boolean) readonly field?: string; }; export type Attribute = | BooleanAttribute | NumberAttribute | StringAttribute | EnumAttribute | AnyAttribute | MapAttribute | StringSetAttribute | NumberSetAttribute | StringListAttribute | NumberListAttribute | MapListAttribute | AnyListAttribute | CustomListAttribute | CustomAttribute | EnumNumberSetAttribute | EnumStringSetAttribute; export type NestedAttributes = | NestedBooleanAttribute | NestedNumberAttribute | NestedStringAttribute | NestedAnyAttribute | NestedMapAttribute | NestedStringListAttribute | NestedCustomListAttribute | NestedNumberListAttribute | NestedMapListAttribute | NestedAnyListAttribute | NestedStringSetAttribute | NestedNumberSetAttribute | NestedEnumAttribute | NestedCustomAttribute | NestedEnumNumberSetAttribute | NestedEnumStringSetAttribute; export interface IndexWithSortKey { readonly sk: { readonly field: string; readonly composite: ReadonlyArray; readonly template?: string; }; } export type AccessPatternCollection = C | ReadonlyArray; export type KeyCastOption = "string" | "number"; export type KeyCasingOption = "upper" | "lower" | "none" | "default"; export interface Schema { readonly model: { readonly entity: string; readonly service: string; readonly version: string; }; readonly attributes: { readonly [a in A]: Attribute; }; readonly indexes: { [accessPattern: string]: { readonly project?: "keys_only"; readonly index?: string; readonly scope?: string; readonly type?: "clustered" | "isolated"; readonly collection?: AccessPatternCollection; readonly condition?: (composite: Record) => boolean; readonly pk: { readonly casing?: KeyCasingOption; readonly field: string; readonly composite: ReadonlyArray; readonly template?: string; readonly cast?: KeyCastOption; }; readonly sk?: { readonly casing?: KeyCasingOption; readonly field: string; readonly composite: ReadonlyArray; readonly template?: string; readonly cast?: KeyCastOption; }; }; }; } export type Attributes = Record; export type IndexCollections< A extends string, F extends string, C extends string, S extends Schema, > = { [i in keyof S["indexes"]]: S["indexes"][i]["collection"] extends AccessPatternCollection< infer Name > ? Name : never; }[keyof S["indexes"]]; export type IndexCollectionsMap< A extends string, F extends string, C extends string, S extends Schema, > = { [i in keyof S["indexes"]]: S["indexes"][i]["collection"] extends AccessPatternCollection< infer Name > ? Name : never; }; type ClusteredIndexNameMap< A extends string, F extends string, C extends string, S extends Schema, > = { [I in keyof S["indexes"] as S["indexes"][I] extends { type: "clustered" } ? I : never]: S["indexes"][I]["collection"] extends AccessPatternCollection< infer Name > ? Name : never; }; type ThingValues = T[keyof T]; type IsolatedIndexNameMap< A extends string, F extends string, C extends string, S extends Schema, > = { [I in keyof S["indexes"] as S["indexes"][I] extends { type: "clustered" } ? never : I]: S["indexes"][I]["collection"] extends AccessPatternCollection< infer Name > ? Name : never; }; export type ClusteredIndexCollections< A extends string, F extends string, C extends string, S extends Schema, > = ThingValues>; export type IsolatedIndexCollections< A extends string, F extends string, C extends string, S extends Schema, > = ThingValues>; export type EntityCollections< A extends string, F extends string, C extends string, S extends Schema, > = { [N in IndexCollections]: { [i in keyof S["indexes"]]: S["indexes"][i]["collection"] extends AccessPatternCollection< infer Name > ? Name extends N ? i : never : never; }[keyof S["indexes"]]; }; export type ClusteredEntityCollections< A extends string, F extends string, C extends string, S extends Schema, > = { [N in ClusteredIndexCollections]: { [I in keyof S["indexes"]]: S["indexes"][I]["collection"] extends AccessPatternCollection< infer Name > ? Name extends N ? I : never : never; }[keyof S["indexes"]]; }; export type IsolatedEntityCollections< A extends string, F extends string, C extends string, S extends Schema, > = { [N in IsolatedIndexCollections]: { [I in keyof S["indexes"]]: S["indexes"][I]["collection"] extends AccessPatternCollection< infer Name > ? Name extends N ? I : never : never; }[keyof S["indexes"]]; }; declare const SkipSymbol: unique symbol; type SkipValue = typeof SkipSymbol; type PartialDefinedKeys = { [P in keyof T as [undefined] extends [T[P]] ? never : SkipValue extends T[P] ? never : P]?: T[P] | undefined; }; export type ItemAttribute = A["type"] extends infer T ? T extends OpaquePrimitiveTypeName ? OP : T extends CustomAttributeTypeName ? CA : T extends infer R ? R extends "string" ? string : R extends "number" ? number : R extends "boolean" ? boolean : R extends ReadonlyArray ? E : R extends "map" ? "properties" extends keyof A ? { [P in keyof A["properties"]]: A["properties"][P] extends infer M ? M extends Attribute ? ItemAttribute : never : never; } : never : R extends "list" ? "items" extends keyof A ? A["items"] extends infer I ? I extends Attribute ? Array> : never : never : never : R extends "set" ? "items" extends keyof A ? A["items"] extends infer I ? I extends "string" ? string[] : I extends "number" ? number[] : I extends ReadonlyArray ? ENUM[] : never : never : never : R extends "any" ? any : never : never : never; export type ReturnedAttribute = A["type"] extends infer T ? T extends OpaquePrimitiveTypeName ? OP : T extends CustomAttributeTypeName ? CA : T extends infer R ? R extends "static" ? never : R extends "string" ? string : R extends "number" ? number : R extends "boolean" ? boolean : R extends ReadonlyArray ? E : R extends "map" ? "properties" extends keyof A ? { [P in keyof A["properties"] as A["properties"][P] extends RequiredAttribute ? P : never]: A["properties"][P] extends infer M ? M extends Attribute ? ReturnedAttribute : never : never; } & { [P in keyof A["properties"] as A["properties"][P] extends | HiddenAttribute | RequiredAttribute ? never : P]?: A["properties"][P] extends infer M ? M extends Attribute ? ReturnedAttribute | undefined : never : never; } : never : R extends "list" ? "items" extends keyof A ? A["items"] extends infer I ? I extends Attribute ? ReturnedAttribute[] : never : never : never : R extends "set" ? "items" extends keyof A ? A["items"] extends infer I ? I extends "string" ? string[] : I extends "number" ? number[] : I extends ReadonlyArray ? ENUM[] : never : never : never : R extends "any" ? any : never : never : never; export type CreatedAttribute = A["type"] extends OpaquePrimitiveTypeName ? T : A["type"] extends CustomAttributeTypeName ? T : A["type"] extends infer R ? R extends "static" ? never : R extends "string" ? string : R extends "number" ? number : R extends "boolean" ? boolean : R extends ReadonlyArray ? E : R extends "map" ? "properties" extends keyof A ? { [P in keyof A["properties"] as A["properties"][P] extends RequiredAttribute ? A["properties"][P] extends DefaultedAttribute ? never : P : never]: A["properties"][P] extends infer M ? M extends Attribute ? CreatedAttribute : never : never; } & { [P in keyof A["properties"] as A["properties"][P] extends HiddenAttribute ? never : P]?: A["properties"][P] extends infer M ? M extends Attribute ? CreatedAttribute | undefined : never : never; } : never : R extends "list" ? "items" extends keyof A ? A["items"] extends infer I ? I extends Attribute ? CreatedAttribute[] : never : never : never : R extends "set" ? "items" extends keyof A ? A["items"] extends infer I ? I extends "string" ? string[] : I extends "number" ? number[] : I extends ReadonlyArray ? ENUM[] : never : never : never : R extends "any" ? any : never : never; export type ReturnedItem< A extends string, F extends string, C extends string, S extends Schema, Attr extends S["attributes"], > = { [a in keyof Attr]: ReturnedAttribute; }; export type CreatedItem< A extends string, F extends string, C extends string, S extends Schema, Attr extends S["attributes"], > = { [a in keyof Attr]: CreatedAttribute; }; export type EditableItemAttribute = A["type"] extends OpaquePrimitiveTypeName ? T : A["type"] extends CustomAttributeTypeName ? T : A extends ReadOnlyAttribute ? never : A["type"] extends infer R ? R extends "static" ? never : R extends "string" ? string : R extends "number" ? number : R extends "boolean" ? boolean : R extends ReadonlyArray ? E : R extends "map" ? "properties" extends keyof A ? { [P in keyof A["properties"] as A["properties"][P] extends ReadOnlyAttribute ? never : P]: A["properties"][P] extends infer M ? M extends Attribute ? EditableItemAttribute : never : never; } : never : R extends "list" ? "items" extends keyof A ? A["items"] extends infer I ? I extends Attribute ? Array> : never : never : never : R extends "set" ? "items" extends keyof A ? A["items"] extends infer I ? I extends "string" ? string[] : I extends "number" ? number[] : I extends ReadonlyArray ? ENUM[] : never : never : never : R extends "any" ? any : never : never; export type UpdatableItemAttribute = A["type"] extends OpaquePrimitiveTypeName ? T : A["type"] extends CustomAttributeTypeName ? T : A extends ReadOnlyAttribute ? never : A["type"] extends infer R ? R extends "static" ? never : R extends "string" ? string : R extends "number" ? number : R extends "boolean" ? boolean : R extends ReadonlyArray ? E : R extends "map" ? "properties" extends keyof A ? { [P in keyof A["properties"] as A["properties"][P] extends ReadOnlyAttribute ? never : A["properties"][P] extends RequiredAttribute ? P : never]: A["properties"][P] extends infer M ? M extends Attribute ? UpdatableItemAttribute : never : never; } & { [P in keyof A["properties"] as A["properties"][P] extends ReadOnlyAttribute ? never : A["properties"][P] extends RequiredAttribute ? never : P]?: A["properties"][P] extends infer M ? M extends Attribute ? UpdatableItemAttribute : never : never; } : never : R extends "list" ? "items" extends keyof A ? A["items"] extends infer I ? I extends Attribute ? Array> : never : never : never : R extends "set" ? "items" extends keyof A ? A["items"] extends infer I ? I extends "string" ? string[] : I extends "number" ? number[] : I extends ReadonlyArray ? ENUM[] : never : never : never : R extends "any" ? any : never : never; type UpdateComposite< A extends string, F extends string, C extends string, S extends Schema, Response, > = ( compositeAttributes: Partial< { [I in keyof S["indexes"] as I extends infer Name ? Name extends TableIndexName ? never : Name : never]: IndexPKAttributes & IndexSKAttributes; }[keyof S["indexes"] extends infer KeyName ? KeyName extends TableIndexName ? never : KeyName : never] >, ) => Response; export type RemovableItemAttribute = A["type"] extends OpaquePrimitiveTypeName ? T : A["type"] extends CustomAttributeTypeName ? T : A extends ReadOnlyAttribute | RequiredAttribute ? never : A["type"] extends infer R ? R extends "static" ? never : R extends "string" ? string : R extends "number" ? number : R extends "boolean" ? boolean : R extends ReadonlyArray ? E : R extends "map" ? "properties" extends keyof A ? { [P in keyof A["properties"] as A["properties"][P] extends | ReadOnlyAttribute | RequiredAttribute ? never : P]?: A["properties"][P] extends infer M ? M extends Attribute ? UpdatableItemAttribute : never : never; } : never : R extends "list" ? "items" extends keyof A ? A["items"] extends infer I ? I extends Attribute ? Array> : never : never : never : R extends "set" ? "items" extends keyof A ? A["items"] extends infer I ? I extends "string" ? string[] : I extends "number" ? number[] : I extends ReadonlyArray ? ENUM[] : never : never : never : R extends "any" ? any : never : never; export type Item< A extends string, F extends string, C extends string, S extends Schema, Attr extends Attributes, > = { [a in keyof Attr]: ItemAttribute; }; export type ItemTypeDescription< A extends string, F extends string, C extends string, S extends Schema, > = { [a in keyof S["attributes"]]: S["attributes"][a]["type"] extends infer R ? R : never; }; export type RequiredAttributes< A extends string, F extends string, C extends string, S extends Schema, > = ExtractKeysOfValueType< { [a in keyof S["attributes"]]: S["attributes"][a] extends RequiredAttribute ? true : false; }, true >; export type HiddenAttributes< A extends string, F extends string, C extends string, S extends Schema, > = ExtractKeysOfValueType< { [a in keyof S["attributes"]]: S["attributes"][a] extends HiddenAttribute ? true : false; }, true >; export type ReadOnlyAttributes< A extends string, F extends string, C extends string, S extends Schema, > = ExtractKeysOfValueType< { [a in keyof S["attributes"]]: S["attributes"][a] extends ReadOnlyAttribute ? true : false; }, true >; type ExtractKeysOfValueType = { [I in keyof T]: T[I] extends K ? I : never; }[keyof T]; export type TableIndexes< A extends string, F extends string, C extends string, S extends Schema, > = { [i in keyof S["indexes"]]: S["indexes"][i] extends SecondaryIndex ? "secondary" : "table"; }; export type TableIndexName< A extends string, F extends string, C extends string, S extends Schema, > = ExtractKeysOfValueType, "table">; export type PKCompositeAttributes< A extends string, F extends string, C extends string, S extends Schema, > = { [i in keyof S["indexes"]]: S["indexes"][i]["pk"]["composite"] extends ReadonlyArray< infer Composite > ? Composite : never; }; export type SKCompositeAttributes< A extends string, F extends string, C extends string, S extends Schema, > = { [i in keyof S["indexes"]]: S["indexes"][i] extends IndexWithSortKey ? S["indexes"][i]["sk"]["composite"] extends ReadonlyArray ? Composite : never : never; }; export type TableIndexPKCompositeAttributes< A extends string, F extends string, C extends string, S extends Schema, > = Pick, TableIndexName>; export type TableIndexSKCompositeAttributes< A extends string, F extends string, C extends string, S extends Schema, > = Pick, TableIndexName>; export type IndexPKCompositeAttributes< A extends string, F extends string, C extends string, S extends Schema, I extends keyof S["indexes"], > = Pick, I>; export type IndexSKCompositeAttributes< A extends string, F extends string, C extends string, S extends Schema, I extends keyof S["indexes"], > = Pick, I>; export type TableIndexPKAttributes< A extends string, F extends string, C extends string, S extends Schema, > = TableIndexName extends keyof TableIndexPKCompositeAttributes< A, F, C, S > ? TableIndexPKCompositeAttributes[TableIndexName< A, F, C, S >] extends keyof Item ? Pick< Item, TableIndexPKCompositeAttributes[TableIndexName] > : never : never; export type TableIndexSKAttributes< A extends string, F extends string, C extends string, S extends Schema, > = TableIndexSKCompositeAttributes[TableIndexName< A, F, C, S >] extends keyof S["attributes"] ? Pick< Item, TableIndexSKCompositeAttributes[TableIndexName] > : Item; export type IndexPKAttributes< A extends string, F extends string, C extends string, S extends Schema, I extends keyof S["indexes"], > = I extends keyof IndexPKCompositeAttributes ? IndexPKCompositeAttributes[I] extends keyof Item< A, F, C, S, S["attributes"] > ? Pick< Item, IndexPKCompositeAttributes[I] > : never : never; export type IndexSKAttributes< A extends string, F extends string, C extends string, S extends Schema, I extends keyof S["indexes"], > = IndexSKCompositeAttributes[I] extends keyof S["attributes"] ? Pick< Item, IndexSKCompositeAttributes[I] > : Item; export type TableIndexCompositeAttributes< A extends string, F extends string, C extends string, S extends Schema, > = TableIndexPKAttributes & Partial>; export type AllTableIndexCompositeAttributes< A extends string, F extends string, C extends string, S extends Schema, > = TableIndexPKAttributes & TableIndexSKAttributes; export type IndexCompositeAttributes< A extends string, F extends string, C extends string, S extends Schema, I extends keyof S["indexes"], > = IndexPKAttributes & Partial>; export type TableItem< A extends string, F extends string, C extends string, S extends Schema, > = AllTableIndexCompositeAttributes & Pick< ReturnedItem, RequiredAttributes > & Partial< Omit< ReturnedItem, RequiredAttributes > >; export type ResponseItem< A extends string, F extends string, C extends string, S extends Schema, > = Omit, HiddenAttributes>; export type RequiredPutItems< A extends string, F extends string, C extends string, S extends Schema, > = { [Attribute in keyof S["attributes"]]: "default" extends keyof S["attributes"][Attribute] ? false : "required" extends keyof S["attributes"][Attribute] ? true extends S["attributes"][Attribute]["required"] ? true : Attribute extends keyof TableIndexCompositeAttributes ? true : false : Attribute extends keyof TableIndexCompositeAttributes ? true : false; }; export type PutItem< A extends string, F extends string, C extends string, S extends Schema, > = Pick< CreatedItem, ExtractKeysOfValueType, true> > & Partial>; export type UpsertItem< A extends string, F extends string, C extends string, S extends Schema, > = Partial>; export type UpdateData< A extends string, F extends string, C extends string, S extends Schema, > = Omit< { [Attr in keyof S["attributes"]]: EditableItemAttribute< S["attributes"][Attr] >; }, | keyof AllTableIndexCompositeAttributes | ReadOnlyAttributes >; export type SetItem< A extends string, F extends string, C extends string, S extends Schema, > = // UpdatableItemAttribute Omit< { [Attr in keyof S["attributes"]]?: UpdatableItemAttribute< S["attributes"][Attr] >; }, | keyof AllTableIndexCompositeAttributes | ReadOnlyAttributes >; // type RemoveItem> = // Array> export type RemoveItem< A extends string, F extends string, C extends string, S extends Schema, > = Array< keyof Omit< { [Attr in keyof S["attributes"]]?: RemovableItemAttribute< S["attributes"][Attr] >; }, | keyof AllTableIndexCompositeAttributes | ReadOnlyAttributes | RequiredAttributes > >; export type AppendItem< A extends string, F extends string, C extends string, S extends Schema, > = { [P in keyof ItemTypeDescription as ItemTypeDescription< A, F, C, S >[P] extends "list" | "any" | "custom" | CustomAttributeTypeName ? P : never]?: P extends keyof SetItem ? SetItem[P] | undefined : never; }; export type AddItem< A extends string, F extends string, C extends string, S extends Schema, > = { [P in keyof ItemTypeDescription as ItemTypeDescription< A, F, C, S >[P] extends | "number" | "any" | "set" | "custom" | CustomAttributeTypeName | OpaquePrimitiveTypeName ? P : never]?: P extends keyof SetItem ? SetItem[P] | undefined : never; }; export type SubtractItem< A extends string, F extends string, C extends string, S extends Schema, > = { [P in keyof ItemTypeDescription as ItemTypeDescription< A, F, C, S >[P] extends "number" | "any" | "custom" | OpaquePrimitiveTypeName ? P : never]?: P extends keyof SetItem ? SetItem[P] | undefined : never; }; export type DeleteItem< A extends string, F extends string, C extends string, S extends Schema, > = { [P in keyof ItemTypeDescription as ItemTypeDescription< A, F, C, S >[P] extends "any" | "set" | "custom" | CustomAttributeTypeName ? P : never]?: P extends keyof SetItem ? SetItem[P] | undefined : never; }; export declare const WhereSymbol: unique symbol; export declare const UpdateDataSymbol: unique symbol; export declare const CustomAttributeSymbol: unique symbol; export declare const OpaquePrimitiveSymbol: unique symbol; export declare const TransactionSymbol: unique symbol; export type WhereAttributeSymbol = { [WhereSymbol]: void; } & T extends string ? T : T extends number ? T : T extends boolean ? T : T extends { [key: string]: any } ? { [key in keyof T]: WhereAttributeSymbol } : T extends ReadonlyArray ? ReadonlyArray> : T extends Array ? Array> : T; export type WhereAttributes< A extends string, F extends string, C extends string, S extends Schema, I extends Item, > = { [Attr in keyof I]: WhereAttributeSymbol; }; export type DataUpdateAttributeSymbol = { [UpdateDataSymbol]: void; } & T extends string ? T : T extends number ? T : T extends boolean ? T : T extends { [key: string]: any } ? { [key in keyof T]: DataUpdateAttributeSymbol } : T extends ReadonlyArray ? ReadonlyArray> : T extends Array ? Array> : [T] extends [never] ? never : T; export type DataUpdateAttributeValues< A extends DataUpdateAttributeSymbol, > = A extends DataUpdateAttributeSymbol ? T extends string ? T : T extends number ? T : T extends boolean ? T : T extends { [key: string]: any } ? { [key in keyof T]?: DataUpdateAttributeValues } : T extends ReadonlyArray ? ReadonlyArray> : T extends Array ? Array> : [T] extends [never] ? never : T : never; export type DataUpdateAttributes< A extends string, F extends string, C extends string, S extends Schema, I extends UpdateData, > = { [Attr in keyof I]: DataUpdateAttributeSymbol; }; export interface WhereOperations< A extends string, F extends string, C extends string, S extends Schema, I extends Item, > { eq: >(attr: A, value: T) => string; ne: >(attr: A, value: T) => string; gt: >(attr: A, value: T) => string; lt: >(attr: A, value: T) => string; gte: >(attr: A, value: T) => string; lte: >(attr: A, value: T) => string; between: >( attr: A, value: T, value2: T, ) => string; begins: >(attr: A, value: T) => string; exists: >(attr: A) => string; notExists: >(attr: A) => string; contains: >( attr: A, value: A extends WhereAttributeSymbol ? V extends Array ? I : V : never, ) => string; notContains: >( attr: A, value: A extends WhereAttributeSymbol ? V extends Array ? I : V : never, ) => string; value: >( attr: A, value: A extends WhereAttributeSymbol ? V : never, ) => A extends WhereAttributeSymbol ? V : never; name: >(attr: A) => string; size: >(attr: A) => number; type: >( attr: A, type: DynamoDBAttributeType, ) => string; field: (name: string) => string; escape: ( value: T, ) => T extends string ? string : T extends number ? number : T extends boolean ? boolean : never; } export interface DataUpdateOperations< A extends string, F extends string, C extends string, S extends Schema, I extends UpdateData, > { set: >( attr: A, value: DataUpdateAttributeValues, ) => any; remove: >( attr: [T] extends [never] ? never : A, ) => any; append: >( attr: A, value: DataUpdateAttributeValues extends Array ? DataUpdateAttributeValues : never, ) => any; add: >( attr: A, value: A extends DataUpdateAttributeSymbol ? V extends number | Array ? V : [V] extends [any] ? V : never : never, defaultValue?: A extends DataUpdateAttributeSymbol ? V extends number ? V : never : never, ) => any; subtract: >( attr: A, value: A extends DataUpdateAttributeSymbol ? V extends number ? V : [V] extends [any] ? V : never : never, defaultValue?: A extends DataUpdateAttributeSymbol ? V extends number ? V : never : never, ) => any; delete: >( attr: A, value: A extends DataUpdateAttributeSymbol ? V extends Array ? V : [V] extends [any] ? V : never : never, ) => any; del: >( attr: A, value: A extends DataUpdateAttributeSymbol ? V extends Array ? V : never : never, ) => any; value: >( attr: A, value: DataUpdateAttributeValues, ) => Required>; name: >(attr: A) => any; ifNotExists: >( attr: A, value: DataUpdateAttributeValues, ) => any; } export interface UpsertDataUpdateOperations< A extends string, F extends string, C extends string, S extends Schema, I extends UpdateData, > { set: >( attr: A, value: DataUpdateAttributeValues, ) => any; append: >( attr: A, value: DataUpdateAttributeValues extends Array ? DataUpdateAttributeValues : never, ) => any; add: >( attr: A, value: A extends DataUpdateAttributeSymbol ? V extends number | Array ? V : [V] extends [any] ? V : never : never, defaultValue?: A extends DataUpdateAttributeSymbol ? V extends number ? V : never : never, ) => any; subtract: >( attr: A, value: A extends DataUpdateAttributeSymbol ? V extends number ? V : [V] extends [any] ? V : never : never, defaultValue?: A extends DataUpdateAttributeSymbol ? V extends number ? V : never : never, ) => any; ifNotExists: >( attr: A, value: DataUpdateAttributeValues, ) => any; } export type WhereCallback< A extends string, F extends string, C extends string, S extends Schema, I extends Item, > = >( attributes: W, operations: WhereOperations, ) => string; export type DataUpdateCallback< A extends string, F extends string, C extends string, S extends Schema, I extends UpdateData, > = >( attributes: W, operations: DataUpdateOperations, ) => any; export type UpsertDataUpdateCallback< A extends string, F extends string, C extends string, S extends Schema, I extends UpdateData, > = >( attributes: W, operations: UpsertDataUpdateOperations, ) => any; export type WhereClause< A extends string, F extends string, C extends string, S extends Schema, I extends Item, T, > = (where: WhereCallback) => T; export type DataUpdateMethod< A extends string, F extends string, C extends string, S extends Schema, I extends UpdateData, T, > = (update: DataUpdateCallback) => T; export type UpsertDataUpdateMethod< A extends string, F extends string, C extends string, S extends Schema, I extends UpdateData, T, > = (update: UpsertDataUpdateCallback) => T; type Resolve = T extends Function | string | number | boolean ? T : { [Key in keyof T]: Resolve }; export type EntityConfiguration = { table?: string; client?: DocumentClient; listeners?: Array; logger?: ElectroEventListener; identifiers?: { entity?: string; version?: string; }; ignoreOwnership?: boolean; }; export class Entity< A extends string, F extends string, C extends string, S extends Schema, > { readonly schema: S; private config?: EntityConfiguration; constructor(schema: S, config?: EntityConfiguration); get( key: AllTableIndexCompositeAttributes, ): SingleRecordOperationOptions>; get( key: AllTableIndexCompositeAttributes[], ): BatchGetRecordOperationOptions>; delete( key: AllTableIndexCompositeAttributes, ): DeleteRecordOperationOptions>; delete( key: AllTableIndexCompositeAttributes[], ): BatchWriteOperationOptions< A, F, C, S, AllTableIndexCompositeAttributes[] >; remove( key: AllTableIndexCompositeAttributes, ): DeleteRecordOperationOptions>; put( record: PutItem, ): PutRecordOperationOptions>; put( record: PutItem[], ): BatchWriteOperationOptions< A, F, C, S, AllTableIndexCompositeAttributes[] >; create( record: PutItem, ): PutRecordOperationOptions>; upsert>( record: InitialItem, ): UpsertRecordOperationOptions< A, F, C, S, ResponseItem, PutItem, [keyof InitialItem] extends [never] ? PutItem : Omit, keyof InitialItem>, InitialItem >; update(key: AllTableIndexCompositeAttributes): { set: SetRecord< A, F, C, S, SetItem, TableIndexCompositeAttributes, Partial> >; ifNotExists: SetRecord< A, F, C, S, SetItem, TableIndexCompositeAttributes, Partial> >; remove: RemoveRecord< A, F, C, S, RemoveItem, TableIndexCompositeAttributes, Partial> >; add: SetRecord< A, F, C, S, AddItem, TableIndexCompositeAttributes, Partial> >; subtract: SetRecord< A, F, C, S, SubtractItem, TableIndexCompositeAttributes, Partial> >; append: SetRecord< A, F, C, S, AppendItem, TableIndexCompositeAttributes, Partial> >; delete: SetRecord< A, F, C, S, DeleteItem, TableIndexCompositeAttributes, Partial> >; data: DataUpdateMethodRecord< A, F, C, S, Item, TableIndexCompositeAttributes, Partial> >; composite: UpdateComposite< A, F, C, S, SetRecordActionOptions< A, F, C, S, SetItem, TableIndexCompositeAttributes, Partial> > >; }; patch(key: AllTableIndexCompositeAttributes): { set: SetRecord< A, F, C, S, SetItem, TableIndexCompositeAttributes, ResponseItem >; remove: RemoveRecord< A, F, C, S, RemoveItem, TableIndexCompositeAttributes, ResponseItem >; ifNotExists: SetRecord< A, F, C, S, SetItem, TableIndexCompositeAttributes, Partial> >; add: SetRecord< A, F, C, S, AddItem, TableIndexCompositeAttributes, ResponseItem >; subtract: SetRecord< A, F, C, S, SubtractItem, TableIndexCompositeAttributes, ResponseItem >; append: SetRecord< A, F, C, S, AppendItem, TableIndexCompositeAttributes, ResponseItem >; delete: SetRecord< A, F, C, S, DeleteItem, TableIndexCompositeAttributes, ResponseItem >; data: DataUpdateMethodRecord< A, F, C, S, Item, TableIndexCompositeAttributes, ResponseItem >; composite: UpdateComposite< A, F, C, S, SetRecordActionOptions< A, F, C, S, SetItem, TableIndexCompositeAttributes, ResponseItem > >; }; find( record: Partial>, ): RecordsActionOptions< A, F, C, S, ResponseItem, AllTableIndexCompositeAttributes >; match( record: Partial>, ): RecordsActionOptions< A, F, C, S, ResponseItem, AllTableIndexCompositeAttributes >; scan: RecordsActionOptions< A, F, C, S, ResponseItem, TableIndexCompositeAttributes >; query: Queries; parse>>( item: ParseSingleInput, options?: Options, ): Options extends ParseOptions ? { data: | { [Name in keyof ResponseItem as Name extends Attr ? Name : never]: ResponseItem[Name]; } | null; } : { data: ResponseItem | null }; parse>>( item: ParseMultiInput, options?: Options, ): Options extends ParseOptions ? { data: Array<{ [Name in keyof ResponseItem as Name extends Attr ? Name : never]: ResponseItem[Name]; }>; cursor: string | null; } : { data: Array>; cursor: string | null }; setIdentifier(type: "entity" | "version", value: string): void; setTableName(tableName: string): void; getTableName(): string | undefined; setClient(client: DocumentClient): void; client: any; } declare function createConversions< A extends string, F extends string, C extends string, S extends Schema, >(entity: Entity): Conversions; export class TransactWriteEntity< A extends string, F extends string, C extends string, S extends Schema, > { readonly schema: S; constructor(schema: S); check( key: AllTableIndexCompositeAttributes, ): SingleRecordOperationOptionsTransaction< A, F, C, S, ResponseItem, TransactWriteItem >; delete( key: AllTableIndexCompositeAttributes, ): DeleteRecordOperationOptionsTransaction< A, F, C, S, ResponseItem >; remove( key: AllTableIndexCompositeAttributes, ): DeleteRecordOperationOptionsTransaction< A, F, C, S, ResponseItem >; put( record: PutItem, ): PutRecordOperationOptionsTransaction>; create( record: PutItem, ): PutRecordOperationOptionsTransaction>; upsert>( record: InitialItem, ): UpsertRecordOperationOptionsTransaction< A, F, C, S, ResponseItem, PutItem, [keyof InitialItem] extends [never] ? PutItem : Omit, keyof InitialItem>, InitialItem >; update(key: AllTableIndexCompositeAttributes): { set: SetRecordTransaction< A, F, C, S, SetItem, TableIndexCompositeAttributes, ResponseItem >; remove: RemoveRecordTransaction< A, F, C, S, RemoveItem, TableIndexCompositeAttributes, ResponseItem >; add: SetRecordTransaction< A, F, C, S, AddItem, TableIndexCompositeAttributes, ResponseItem >; subtract: SetRecordTransaction< A, F, C, S, SubtractItem, TableIndexCompositeAttributes, ResponseItem >; append: SetRecordTransaction< A, F, C, S, AppendItem, TableIndexCompositeAttributes, ResponseItem >; delete: SetRecordTransaction< A, F, C, S, DeleteItem, TableIndexCompositeAttributes, ResponseItem >; data: DataUpdateMethodRecordTransaction< A, F, C, S, Item, TableIndexCompositeAttributes, ResponseItem >; }; patch(key: AllTableIndexCompositeAttributes): { set: SetRecordTransaction< A, F, C, S, SetItem, TableIndexCompositeAttributes, ResponseItem >; remove: RemoveRecordTransaction< A, F, C, S, RemoveItem, TableIndexCompositeAttributes, ResponseItem >; add: SetRecordTransaction< A, F, C, S, AddItem, TableIndexCompositeAttributes, ResponseItem >; subtract: SetRecordTransaction< A, F, C, S, SubtractItem, TableIndexCompositeAttributes, ResponseItem >; append: SetRecordTransaction< A, F, C, S, AppendItem, TableIndexCompositeAttributes, ResponseItem >; delete: SetRecordTransaction< A, F, C, S, DeleteItem, TableIndexCompositeAttributes, ResponseItem >; data: DataUpdateMethodRecordTransaction< A, F, C, S, Item, TableIndexCompositeAttributes, ResponseItem >; }; } export class TransactGetEntity< A extends string, F extends string, C extends string, S extends Schema, > { readonly schema: S; constructor(schema: S); get( key: AllTableIndexCompositeAttributes, ): GetOperationOptionsTransaction< A, F, C, S, ResponseItem, TransactGetItem >; } type TransactWriteFunctionOptions = { token?: string; logger?: ElectroEventListener; }; type TransactGetFunctionOptions = {}; type TransactWriteExtractedType< T extends readonly any[], A extends readonly any[] = [], > = T extends [infer F, ...infer R] ? F extends CommittedTransactionResult ? TransactWriteExtractedType]> : never : A; type TransactGetExtractedType< T extends readonly any[], A extends readonly any[] = [], > = T extends [infer F, ...infer R] ? F extends CommittedTransactionResult ? TransactGetExtractedType]> : never : A; type TransactWriteEntities< E extends { [name: string]: Entity }, > = { [EntityName in keyof E]: E[EntityName] extends Entity< infer A, infer F, infer C, infer S > ? TransactWriteEntity : never; }; type TransactGetEntities< E extends { [name: string]: Entity }, > = { [EntityName in keyof E]: E[EntityName] extends Entity< infer A, infer F, infer C, infer S > ? TransactGetEntity : never; }; type TransactWriteFunction< E extends { [name: string]: Entity }, T, R extends ReadonlyArray>, > = (entities: TransactWriteEntities) => [...R]; type TransactGetFunction< E extends { [name: string]: Entity }, T, R extends ReadonlyArray>, > = (entities: TransactGetEntities) => [...R]; export type ServiceConfiguration = { table?: string; client?: DocumentClient; listeners?: Array; logger?: ElectroEventListener; }; declare function createWriteTransaction< E extends { [name: string]: Entity }, T, R extends ReadonlyArray>, >( entities: E, fn: TransactWriteFunction, ): { go: (options?: TransactWriteFunctionOptions) => Promise<{ canceled: boolean; data: TransactWriteExtractedType; }>; params: < O extends TransactWriteFunctionOptions = TransactWriteFunctionOptions, >( options?: O, ) => TransactWriteCommandInput; }; declare function createGetTransaction< E extends { [name: string]: Entity }, T, R extends ReadonlyArray>, >( entities: E, fn: TransactGetFunction, ): { go: (options?: TransactGetFunctionOptions) => Promise<{ canceled: boolean; data: TransactGetExtractedType; }>; params: ( options?: O, ) => TransactGetCommandInput; }; export class Service }> { entities: E; collections: ClusteredCollectionQueries< E, ClusteredCollectionAssociations > & IsolatedCollectionQueries>; transaction: { write: < T, R extends ReadonlyArray>, >( fn: TransactWriteFunction, ) => { go: (options?: TransactWriteFunctionOptions) => Promise<{ canceled: boolean; data: TransactWriteExtractedType; }>; params: < O extends TransactWriteFunctionOptions = TransactWriteFunctionOptions, >( options?: O, ) => TransactWriteCommandInput; }; get: < T, R extends ReadonlyArray>, >( fn: TransactGetFunction, ) => { go: (options?: TransactGetFunctionOptions) => Promise<{ canceled: boolean; data: TransactGetExtractedType; }>; params: < O extends TransactGetFunctionOptions = TransactGetFunctionOptions, >( options?: O, ) => TransactGetCommandInput; }; }; constructor(entities: E, config?: ServiceConfiguration); setTableName(tableName: string): void; getTableName(): string | undefined; setClient(client: DocumentClient): void; } type CustomAttributeDefinition = { readonly required?: boolean; readonly hidden?: boolean; readonly readOnly?: boolean; readonly get?: (val: T, item: any) => T | undefined | void; readonly set?: (val?: T, item?: any) => T | undefined | void; readonly default?: T | (() => T); readonly validate?: ((val: T) => boolean) readonly field?: string; readonly watch?: ReadonlyArray | "*"; }; /** @depricated use 'CustomAttributeType' or 'OpaquePrimitiveType' instead */ declare function createCustomAttribute< T, A extends Readonly> = Readonly< CustomAttributeDefinition >, >(definition?: A): A & { type: CustomAttributeTypeName }; declare function CustomAttributeType( base: T extends string ? "string" : T extends number ? "number" : T extends boolean ? "boolean" : "any", ): T extends string | number | boolean ? OpaquePrimitiveTypeName : CustomAttributeTypeName; declare function createSchema< A extends string, F extends string, C extends string, S extends Schema, >(schema: S): S;