diff --git a/src/v1/commands/putItem/command.ts b/src/v1/commands/putItem/command.ts index 9e23a4ec9..645e5e5fb 100644 --- a/src/v1/commands/putItem/command.ts +++ b/src/v1/commands/putItem/command.ts @@ -56,18 +56,14 @@ export class PutItemCommand< static commandType = 'put' as const public entity: ENTITY - public _item?: PutItemInput + public _item?: PutItemInput public item: (nextItem: PutItemInput) => PutItemCommand public _options: OPTIONS public options: >( nextOptions: NEXT_OPTIONS ) => PutItemCommand - constructor( - entity: ENTITY, - item?: PutItemInput, - options: OPTIONS = {} as OPTIONS - ) { + constructor(entity: ENTITY, item?: PutItemInput, options: OPTIONS = {} as OPTIONS) { this.entity = entity this._item = item this._options = options diff --git a/src/v1/commands/putItem/putItemParams/putItemParams.ts b/src/v1/commands/putItem/putItemParams/putItemParams.ts index bbfd989ef..d6dbcc0c4 100644 --- a/src/v1/commands/putItem/putItemParams/putItemParams.ts +++ b/src/v1/commands/putItem/putItemParams/putItemParams.ts @@ -12,7 +12,7 @@ import { parsePutItemOptions } from './parsePutItemOptions' export const putItemParams = >( entity: ENTITY, - input: PutItemInput, + input: PutItemInput, putItemOptions: OPTIONS = {} as OPTIONS ): PutCommandInput => { const validInput = parseEntityPutCommandInput(entity, input) diff --git a/src/v1/commands/putItem/types.ts b/src/v1/commands/putItem/types.ts index 9f8c6a159..4930339e5 100644 --- a/src/v1/commands/putItem/types.ts +++ b/src/v1/commands/putItem/types.ts @@ -22,9 +22,9 @@ import type { OptionalizeUndefinableProperties } from 'v1/types/optionalizeUndef import type { EntityV2 } from 'v1/entity/class' import type { If } from 'v1/types/if' -type MustBeDefined< +export type MustBeDefined< ATTRIBUTE extends Attribute, - REQUIRE_INDEPENDENT_DEFAULTS extends boolean = false + REQUIRED_DEFAULTS extends 'none' | 'independent' | 'all' = 'none' > = // Enforce Required attributes that don't have default values ATTRIBUTE extends { required: AtLeastOnce | Always } & ( @@ -32,16 +32,23 @@ type MustBeDefined< | { key: false; defaults: { put: undefined } } ) ? true - : If< - REQUIRE_INDEPENDENT_DEFAULTS, - // Add attributes with independent defaults if REQUIRE_INDEPENDENT_DEFAULTS is true - ATTRIBUTE extends + : // Add attributes with independent defaults if REQUIRED_DEFAULTS is 'independent' + REQUIRED_DEFAULTS extends 'independent' + ? ATTRIBUTE extends + | { key: true; defaults: { key: undefined | ComputedDefault } } + | { key: false; defaults: { put: undefined | ComputedDefault } } + ? false + : true + : // Add all required attributes and those with independent defaults if REQUIRED_DEFAULTS is 'all' + REQUIRED_DEFAULTS extends 'all' + ? ATTRIBUTE extends { required: AtLeastOnce | Always } + ? true + : ATTRIBUTE extends | { key: true; defaults: { key: undefined | ComputedDefault } } | { key: false; defaults: { put: undefined | ComputedDefault } } - ? false - : true, - false - > + ? false + : true + : false /** * User input of a PUT command for a given Entity or Schema @@ -52,7 +59,7 @@ type MustBeDefined< */ export type PutItemInput< SCHEMA extends EntityV2 | Schema, - REQUIRE_INDEPENDENT_DEFAULTS extends boolean = false + REQUIRED_DEFAULTS extends 'none' | 'independent' | 'all' = 'none' > = EntityV2 extends SCHEMA ? Item : Schema extends SCHEMA @@ -62,14 +69,14 @@ export type PutItemInput< { [KEY in keyof SCHEMA['attributes']]: AttributePutItemInput< SCHEMA['attributes'][KEY], - REQUIRE_INDEPENDENT_DEFAULTS + REQUIRED_DEFAULTS > }, // Sadly we override optional AnyAttributes as 'unknown | undefined' => 'unknown' (undefined lost in the process) O.SelectKeys > : SCHEMA extends EntityV2 - ? PutItemInput + ? PutItemInput : never /** @@ -81,25 +88,25 @@ export type PutItemInput< */ export type AttributePutItemInput< ATTRIBUTE extends Attribute, - REQUIRE_INDEPENDENT_DEFAULTS extends boolean = false + REQUIRED_DEFAULTS extends 'none' | 'independent' | 'all' = 'none' > = Attribute extends ATTRIBUTE ? AttributeValue | undefined : - | If, never, undefined> + | If, never, undefined> | (ATTRIBUTE extends AnyAttribute ? unknown : ATTRIBUTE extends PrimitiveAttribute ? ResolvePrimitiveAttribute : ATTRIBUTE extends SetAttribute - ? Set> + ? Set> : ATTRIBUTE extends ListAttribute - ? AttributePutItemInput[] + ? AttributePutItemInput[] : ATTRIBUTE extends MapAttribute ? OptionalizeUndefinableProperties< { [KEY in keyof ATTRIBUTE['attributes']]: AttributePutItemInput< ATTRIBUTE['attributes'][KEY], - REQUIRE_INDEPENDENT_DEFAULTS + REQUIRED_DEFAULTS > }, // Sadly we override optional AnyAttributes as 'unknown | undefined' => 'unknown' (undefined lost in the process) @@ -109,9 +116,9 @@ export type AttributePutItemInput< ? { [KEY in ResolvePrimitiveAttribute]?: AttributePutItemInput< ATTRIBUTE['elements'], - REQUIRE_INDEPENDENT_DEFAULTS + REQUIRED_DEFAULTS > } : ATTRIBUTE extends AnyOfAttribute - ? AttributePutItemInput + ? AttributePutItemInput : never) diff --git a/src/v1/commands/types/KeyInput.ts b/src/v1/commands/types/KeyInput.ts index dd8957eb2..d2f66e889 100644 --- a/src/v1/commands/types/KeyInput.ts +++ b/src/v1/commands/types/KeyInput.ts @@ -23,17 +23,24 @@ import type { If } from 'v1/types/if' type MustBeDefined< ATTRIBUTE extends Attribute, - REQUIRE_INDEPENDENT_DEFAULTS extends boolean = false + REQUIRED_DEFAULTS extends 'none' | 'independent' | 'all' = 'none' > = // Enforce Required attributes that don't have default values ATTRIBUTE extends { required: Always; defaults: { key: undefined } } ? true - : // Add attributes with independent defaults if REQUIRE_INDEPENDENT_DEFAULTS is true - If< - REQUIRE_INDEPENDENT_DEFAULTS, - ATTRIBUTE extends { defaults: { key: undefined | ComputedDefault } } ? false : true, - false - > + : // Add attributes with independent defaults if REQUIRED_DEFAULTS is 'independent' + REQUIRED_DEFAULTS extends 'independent' + ? ATTRIBUTE extends { defaults: { key: undefined | ComputedDefault } } + ? false + : true + : // Add all required attributes and those with independent defaults if REQUIRED_DEFAULTS is 'all' + REQUIRED_DEFAULTS extends 'all' + ? ATTRIBUTE extends { required: Always } + ? true + : ATTRIBUTE extends { defaults: { key: undefined | ComputedDefault } } + ? false + : true + : false /** * Key input of a single item command (GET, DELETE ...) for an Entity or Schema @@ -43,7 +50,7 @@ type MustBeDefined< */ export type KeyInput< SCHEMA extends EntityV2 | Schema, - REQUIRE_INDEPENDENT_DEFAULTS extends boolean = false + REQUIRED_DEFAULTS extends 'none' | 'independent' | 'all' = 'none' > = EntityV2 extends SCHEMA ? MapAttributeValue : Schema extends SCHEMA @@ -54,14 +61,14 @@ export type KeyInput< // Keep only key attributes [KEY in O.SelectKeys]: AttributeKeyInput< SCHEMA['attributes'][KEY], - REQUIRE_INDEPENDENT_DEFAULTS + REQUIRED_DEFAULTS > }, // Sadly we override optional AnyAttributes as 'unknown | undefined' => 'unknown' (undefined lost in the process) O.SelectKeys > : SCHEMA extends EntityV2 - ? KeyInput + ? KeyInput : never /** @@ -72,26 +79,26 @@ export type KeyInput< */ export type AttributeKeyInput< ATTRIBUTE extends Attribute, - REQUIRE_INDEPENDENT_DEFAULTS extends boolean = false + REQUIRED_DEFAULTS extends 'none' | 'independent' | 'all' = 'none' > = Attribute extends ATTRIBUTE ? AttributeValue | undefined : - | If, never, undefined> + | If, never, undefined> | (ATTRIBUTE extends AnyAttribute ? unknown : ATTRIBUTE extends PrimitiveAttribute ? ResolvePrimitiveAttribute : ATTRIBUTE extends SetAttribute - ? Set> + ? Set> : ATTRIBUTE extends ListAttribute - ? AttributeKeyInput[] + ? AttributeKeyInput[] : ATTRIBUTE extends MapAttribute ? OptionalizeUndefinableProperties< { // Keep only key attributes [KEY in O.SelectKeys]: AttributeKeyInput< ATTRIBUTE['attributes'][KEY], - REQUIRE_INDEPENDENT_DEFAULTS + REQUIRED_DEFAULTS > }, // Sadly we override optional AnyAttributes as 'unknown | undefined' => 'unknown' (undefined lost in the process) @@ -101,9 +108,9 @@ export type AttributeKeyInput< ? { [KEY in ResolvePrimitiveAttribute]?: AttributeKeyInput< ATTRIBUTE['elements'], - REQUIRE_INDEPENDENT_DEFAULTS + REQUIRED_DEFAULTS > } : ATTRIBUTE extends AnyOfAttribute - ? AttributeKeyInput + ? AttributeKeyInput : never) diff --git a/src/v1/commands/updateItem/command.ts b/src/v1/commands/updateItem/command.ts index b8144f660..23304281a 100644 --- a/src/v1/commands/updateItem/command.ts +++ b/src/v1/commands/updateItem/command.ts @@ -56,18 +56,14 @@ export class UpdateItemCommand< static commandType = 'put' as const public entity: ENTITY - public _item?: UpdateItemInput + public _item?: UpdateItemInput public item: (nextItem: UpdateItemInput) => UpdateItemCommand public _options: OPTIONS public options: >( nextOptions: NEXT_OPTIONS ) => UpdateItemCommand - constructor( - entity: ENTITY, - item?: UpdateItemInput, - options: OPTIONS = {} as OPTIONS - ) { + constructor(entity: ENTITY, item?: UpdateItemInput, options: OPTIONS = {} as OPTIONS) { this.entity = entity this._item = item this._options = options diff --git a/src/v1/commands/updateItem/types.ts b/src/v1/commands/updateItem/types.ts index 69b6fb93a..bf8b59d34 100644 --- a/src/v1/commands/updateItem/types.ts +++ b/src/v1/commands/updateItem/types.ts @@ -106,7 +106,7 @@ export type UpdateItemInputExtension = type MustBeDefined< ATTRIBUTE extends Attribute, - REQUIRE_INDEPENDENT_DEFAULTS extends boolean = false + REQUIRED_DEFAULTS extends 'none' | 'independent' | 'all' = 'none' > = // Enforce Required attributes that don't have default values ATTRIBUTE extends { required: Always } & ( @@ -114,16 +114,25 @@ type MustBeDefined< | { key: false; defaults: { update: undefined } } ) ? true - : REQUIRE_INDEPENDENT_DEFAULTS extends true - ? // Add attributes with independent defaults if REQUIRE_INDEPENDENT_DEFAULTS is true - ATTRIBUTE extends + : // Add attributes with independent defaults if REQUIRED_DEFAULTS is 'independent' + REQUIRED_DEFAULTS extends 'independent' + ? ATTRIBUTE extends | { key: true; defaults: { key: undefined | ComputedDefault } } | { key: false; defaults: { update: undefined | ComputedDefault } } ? false : true + : // Add all required attributes and those with independent defaults if REQUIRED_DEFAULTS is 'all' + REQUIRED_DEFAULTS extends 'all' + ? ATTRIBUTE extends { required: Always } + ? true + : ATTRIBUTE extends + | { key: true; defaults: { key: undefined | ComputedDefault } } + | { key: false; defaults: { update: undefined | ComputedDefault } } + ? false + : true : false -type CanBeRemoved = ATTRIBUTE extends { required: 'never' } +type CanBeRemoved = ATTRIBUTE extends { required: Never } ? true : false @@ -136,7 +145,7 @@ type CanBeRemoved = ATTRIBUTE extends { required: ' */ export type UpdateItemInput< SCHEMA extends EntityV2 | Schema = EntityV2, - REQUIRE_INDEPENDENT_DEFAULTS extends boolean = false + REQUIRED_DEFAULTS extends 'none' | 'independent' | 'all' = 'none' > = EntityV2 extends SCHEMA ? Item : Schema extends SCHEMA @@ -146,7 +155,7 @@ export type UpdateItemInput< { [KEY in keyof SCHEMA['attributes']]: AttributeUpdateItemInput< SCHEMA['attributes'][KEY], - REQUIRE_INDEPENDENT_DEFAULTS, + REQUIRED_DEFAULTS, SchemaAttributePath > }, @@ -154,7 +163,7 @@ export type UpdateItemInput< O.SelectKeys > : SCHEMA extends EntityV2 - ? UpdateItemInput + ? UpdateItemInput : never export type Reference< @@ -210,12 +219,12 @@ type AttributeUpdateItemCompleteInput = Attribute e */ export type AttributeUpdateItemInput< ATTRIBUTE extends Attribute = Attribute, - REQUIRE_INDEPENDENT_DEFAULTS extends boolean = false, + REQUIRED_DEFAULTS extends 'none' | 'independent' | 'all' = 'none', SCHEMA_ATTRIBUTE_PATHS extends string = string > = Attribute extends ATTRIBUTE ? AttributeValue | undefined : - | If, never, undefined> + | If, never, undefined> | If, $REMOVE, never> // Not using Reference<...> for improved type display | GET< @@ -283,7 +292,7 @@ export type AttributeUpdateItemInput< [INDEX in number]?: | AttributeUpdateItemInput< ATTRIBUTE['elements'], - REQUIRE_INDEPENDENT_DEFAULTS, + REQUIRED_DEFAULTS, SCHEMA_ATTRIBUTE_PATHS > | $REMOVE @@ -320,7 +329,7 @@ export type AttributeUpdateItemInput< { [KEY in keyof ATTRIBUTE['attributes']]: AttributeUpdateItemInput< ATTRIBUTE['attributes'][KEY], - REQUIRE_INDEPENDENT_DEFAULTS, + REQUIRED_DEFAULTS, SCHEMA_ATTRIBUTE_PATHS > }, @@ -339,7 +348,7 @@ export type AttributeUpdateItemInput< [KEY in ResolvePrimitiveAttribute]?: | AttributeUpdateItemInput< ATTRIBUTE['elements'], - REQUIRE_INDEPENDENT_DEFAULTS, + REQUIRED_DEFAULTS, SCHEMA_ATTRIBUTE_PATHS > | $REMOVE @@ -349,7 +358,7 @@ export type AttributeUpdateItemInput< : ATTRIBUTE extends AnyOfAttribute ? AttributeUpdateItemInput< ATTRIBUTE['elements'][number], - REQUIRE_INDEPENDENT_DEFAULTS, + REQUIRED_DEFAULTS, SCHEMA_ATTRIBUTE_PATHS > : never) diff --git a/src/v1/commands/updateItem/updateItemParams/updateItemParams.ts b/src/v1/commands/updateItem/updateItemParams/updateItemParams.ts index bc1020970..2366c0cea 100644 --- a/src/v1/commands/updateItem/updateItemParams/updateItemParams.ts +++ b/src/v1/commands/updateItem/updateItemParams/updateItemParams.ts @@ -19,7 +19,7 @@ export const updateItemParams = < OPTIONS extends UpdateItemOptions >( entity: ENTITY, - input: UpdateItemInput, + input: UpdateItemInput, updateItemOptions: OPTIONS = {} as OPTIONS ): UpdateCommandInput => { const validInput = parseEntityUpdateCommandInput(entity, input) diff --git a/src/v1/entity/class.ts b/src/v1/entity/class.ts index 87189d7f3..3d88e3a9c 100644 --- a/src/v1/entity/class.ts +++ b/src/v1/entity/class.ts @@ -109,7 +109,7 @@ export class EntityV2< timestamps?: NarrowTimestampsOptions } & If< NeedsKeyCompute, - { computeKey: (keyInput: KeyInput) => PrimaryKey }, + { computeKey: (keyInput: KeyInput) => PrimaryKey
}, { computeKey?: undefined } > & // Weirdly using If here triggers an infinite type recursion error diff --git a/src/v1/entity/generics/PutDefaultsComputer/attribute.ts b/src/v1/entity/generics/PutDefaultsComputer/attribute.ts index dcada9385..baea89c50 100644 --- a/src/v1/entity/generics/PutDefaultsComputer/attribute.ts +++ b/src/v1/entity/generics/PutDefaultsComputer/attribute.ts @@ -25,7 +25,7 @@ export type AttributePutDefaultsComputer< // TODO: Prevent nested ComputedDefaults in anyOf | AnyOfAttribute ) & { defaults: { put: ComputedDefault } } - ? (...contextInputs: CONTEXT_INPUTS) => AttributePutItemInput + ? (...contextInputs: CONTEXT_INPUTS) => AttributePutItemInput : ATTRIBUTE extends ListAttribute ? ListAttributePutDefaultsComputer : ATTRIBUTE extends MapAttribute diff --git a/src/v1/entity/generics/PutDefaultsComputer/list.ts b/src/v1/entity/generics/PutDefaultsComputer/list.ts index 9efc7a50a..deb37cb7c 100644 --- a/src/v1/entity/generics/PutDefaultsComputer/list.ts +++ b/src/v1/entity/generics/PutDefaultsComputer/list.ts @@ -13,7 +13,7 @@ export type ListAttributePutDefaultsComputer< >, LIST_ATTRIBUTE_DEFAULT_COMPUTER = OmitUndefinedProperties<{ _list: LIST_ATTRIBUTE extends { defaults: { put: ComputedDefault } } - ? (...contextInputs: CONTEXT_INPUTS) => AttributePutItemInput + ? (...contextInputs: CONTEXT_INPUTS) => AttributePutItemInput : undefined _elements: ELEMENTS_DEFAULT_COMPUTER extends undefined ? undefined diff --git a/src/v1/entity/generics/PutDefaultsComputer/map.ts b/src/v1/entity/generics/PutDefaultsComputer/map.ts index d6014c85f..daff266b9 100644 --- a/src/v1/entity/generics/PutDefaultsComputer/map.ts +++ b/src/v1/entity/generics/PutDefaultsComputer/map.ts @@ -11,7 +11,7 @@ export type MapAttributePutDefaultsComputer< { [KEY in keyof MAP_ATTRIBUTE['attributes']]: AttributePutDefaultsComputer< MAP_ATTRIBUTE['attributes'][KEY], - [AttributePutItemInput, ...CONTEXT_INPUTS] + [AttributePutItemInput, ...CONTEXT_INPUTS] > } >, @@ -22,7 +22,7 @@ export type MapAttributePutDefaultsComputer< [KEY in keyof ATTRIBUTES_DEFAULT_COMPUTERS]: ATTRIBUTES_DEFAULT_COMPUTERS[KEY] } _map: MAP_ATTRIBUTE extends { defaults: { put: ComputedDefault } } - ? (...contextInputs: CONTEXT_INPUTS) => AttributePutItemInput + ? (...contextInputs: CONTEXT_INPUTS) => AttributePutItemInput : undefined }> > = keyof MAP_ATTRIBUTE_DEFAULT_COMPUTER extends never diff --git a/src/v1/entity/generics/PutDefaultsComputer/record.ts b/src/v1/entity/generics/PutDefaultsComputer/record.ts index 57e151d28..29b9c9d8a 100644 --- a/src/v1/entity/generics/PutDefaultsComputer/record.ts +++ b/src/v1/entity/generics/PutDefaultsComputer/record.ts @@ -9,11 +9,11 @@ export type RecordAttributePutDefaultsComputer< CONTEXT_INPUTS extends any[], ELEMENTS_DEFAULT_COMPUTER = AttributePutDefaultsComputer< RECORD_ATTRIBUTE['elements'], - [AttributePutItemInput, ...CONTEXT_INPUTS] + [AttributePutItemInput, ...CONTEXT_INPUTS] >, RECORD_ATTRIBUTE_DEFAULT_COMPUTER = OmitUndefinedProperties<{ _record: RECORD_ATTRIBUTE extends { defaults: { put: ComputedDefault } } - ? (...contextInputs: CONTEXT_INPUTS) => AttributePutItemInput + ? (...contextInputs: CONTEXT_INPUTS) => AttributePutItemInput : undefined _elements: ELEMENTS_DEFAULT_COMPUTER extends undefined ? undefined diff --git a/src/v1/entity/generics/PutDefaultsComputer/schema.ts b/src/v1/entity/generics/PutDefaultsComputer/schema.ts index d27971fff..31e5cfd2c 100644 --- a/src/v1/entity/generics/PutDefaultsComputer/schema.ts +++ b/src/v1/entity/generics/PutDefaultsComputer/schema.ts @@ -10,7 +10,7 @@ export type SchemaPutDefaultsComputer< { [KEY in keyof SCHEMA['attributes']]: AttributePutDefaultsComputer< SCHEMA['attributes'][KEY], - [PutItemInput] + [PutItemInput] > } > diff --git a/src/v1/entity/generics/UpdateDefaultsComputer/attribute.ts b/src/v1/entity/generics/UpdateDefaultsComputer/attribute.ts index 5c4b8c831..9b3aa7462 100644 --- a/src/v1/entity/generics/UpdateDefaultsComputer/attribute.ts +++ b/src/v1/entity/generics/UpdateDefaultsComputer/attribute.ts @@ -28,7 +28,7 @@ export type AttributeUpdateDefaultsComputer< ) & { defaults: { update: ComputedDefault } } ? ( ...contextInputs: CONTEXT_INPUTS - ) => AttributeUpdateItemInput + ) => AttributeUpdateItemInput : ATTRIBUTE extends ListAttribute ? ListAttributeUpdateDefaultsComputer : ATTRIBUTE extends MapAttribute diff --git a/src/v1/entity/generics/UpdateDefaultsComputer/list.ts b/src/v1/entity/generics/UpdateDefaultsComputer/list.ts index f9fe660e0..9ac47a1dc 100644 --- a/src/v1/entity/generics/UpdateDefaultsComputer/list.ts +++ b/src/v1/entity/generics/UpdateDefaultsComputer/list.ts @@ -17,7 +17,7 @@ export type ListAttributeUpdateDefaultsComputer< _list: LIST_ATTRIBUTE extends { defaults: { update: ComputedDefault } } ? ( ...contextInputs: CONTEXT_INPUTS - ) => AttributeUpdateItemInput + ) => AttributeUpdateItemInput : undefined _elements: ELEMENTS_DEFAULT_COMPUTER extends undefined ? undefined diff --git a/src/v1/entity/generics/UpdateDefaultsComputer/map.ts b/src/v1/entity/generics/UpdateDefaultsComputer/map.ts index 9a81d918d..6ac2cd23c 100644 --- a/src/v1/entity/generics/UpdateDefaultsComputer/map.ts +++ b/src/v1/entity/generics/UpdateDefaultsComputer/map.ts @@ -12,7 +12,10 @@ export type MapAttributeUpdateDefaultsComputer< { [KEY in keyof MAP_ATTRIBUTE['attributes']]: AttributeUpdateDefaultsComputer< MAP_ATTRIBUTE['attributes'][KEY], - [AttributeUpdateItemInput, ...CONTEXT_INPUTS], + [ + AttributeUpdateItemInput, + ...CONTEXT_INPUTS + ], SCHEMA_ATTRIBUTE_PATHS > } @@ -26,7 +29,7 @@ export type MapAttributeUpdateDefaultsComputer< _map: MAP_ATTRIBUTE extends { defaults: { update: ComputedDefault } } ? ( ...contextInputs: CONTEXT_INPUTS - ) => AttributeUpdateItemInput + ) => AttributeUpdateItemInput : undefined }> > = keyof MAP_ATTRIBUTE_DEFAULT_COMPUTER extends never diff --git a/src/v1/entity/generics/UpdateDefaultsComputer/record.ts b/src/v1/entity/generics/UpdateDefaultsComputer/record.ts index 20f87f53c..23e3bdb4f 100644 --- a/src/v1/entity/generics/UpdateDefaultsComputer/record.ts +++ b/src/v1/entity/generics/UpdateDefaultsComputer/record.ts @@ -11,7 +11,7 @@ export type RecordAttributeUpdateDefaultsComputer< ELEMENTS_DEFAULT_COMPUTER = AttributeUpdateDefaultsComputer< RECORD_ATTRIBUTE['elements'], [ - AttributeUpdateItemInput, + AttributeUpdateItemInput, ...CONTEXT_INPUTS ], SCHEMA_ATTRIBUTE_PATHS @@ -20,7 +20,7 @@ export type RecordAttributeUpdateDefaultsComputer< _record: RECORD_ATTRIBUTE extends { defaults: { update: ComputedDefault } } ? ( ...contextInputs: CONTEXT_INPUTS - ) => AttributeUpdateItemInput + ) => AttributeUpdateItemInput : undefined _elements: ELEMENTS_DEFAULT_COMPUTER extends undefined ? undefined diff --git a/src/v1/entity/generics/UpdateDefaultsComputer/schema.ts b/src/v1/entity/generics/UpdateDefaultsComputer/schema.ts index 6ca59e19e..0def7e0d4 100644 --- a/src/v1/entity/generics/UpdateDefaultsComputer/schema.ts +++ b/src/v1/entity/generics/UpdateDefaultsComputer/schema.ts @@ -11,7 +11,7 @@ export type SchemaUpdateDefaultsComputer< { [KEY in keyof SCHEMA['attributes']]: AttributeUpdateDefaultsComputer< SCHEMA['attributes'][KEY], - [UpdateItemInput], + [UpdateItemInput], SchemaAttributePath > } diff --git a/src/v1/playground/schema.ts b/src/v1/playground/schema.ts index a85aa09a6..ef8d98f39 100644 --- a/src/v1/playground/schema.ts +++ b/src/v1/playground/schema.ts @@ -68,7 +68,11 @@ const playgroundSchema2 = schema({ type PlaygroundSchema2FormattedItem = FormattedAttribute type PlaygroundSchema2HasComputedDefault = HasComputedDefaults type PlaygroundSchema2PutItemInput = PutItemInput -type PlaygroundSchema2PutItemInputWithDefaults = PutItemInput +type PlaygroundSchema2PutItemInputWithDefaults = PutItemInput< + typeof playgroundSchema2, + 'independent' +> +type PlaygroundSchema2PutItemInputWithLinks = PutItemInput const playgroundSchema3 = schema({ keyEl: string().key(), diff --git a/src/v1/test-tools/mocks/putItemCommand.ts b/src/v1/test-tools/mocks/putItemCommand.ts index 21ad9a930..78c9a3c3e 100644 --- a/src/v1/test-tools/mocks/putItemCommand.ts +++ b/src/v1/test-tools/mocks/putItemCommand.ts @@ -22,8 +22,8 @@ export class PutItemCommandMock< entity: ENTITY; [$mockedEntity]: MockedEntity - _item?: PutItemInput - item: (nextItem: PutItemInput) => PutItemCommandMock + _item?: PutItemInput + item: (nextItem: PutItemInput) => PutItemCommandMock _options: OPTIONS options: >( nextOptions: NEXT_OPTIONS @@ -31,7 +31,7 @@ export class PutItemCommandMock< constructor( mockedEntity: MockedEntity, - item?: PutItemInput, + item?: PutItemInput, options: OPTIONS = {} as OPTIONS ) { this.entity = mockedEntity[$entity] diff --git a/src/v1/test-tools/mocks/updateItemCommand.ts b/src/v1/test-tools/mocks/updateItemCommand.ts index 98db32a7a..48b11dd7c 100644 --- a/src/v1/test-tools/mocks/updateItemCommand.ts +++ b/src/v1/test-tools/mocks/updateItemCommand.ts @@ -27,8 +27,8 @@ export class UpdateItemCommandMock< entity: ENTITY; [$mockedEntity]: MockedEntity - _item?: UpdateItemInput - item: (nextItem: UpdateItemInput) => UpdateItemCommandMock + _item?: UpdateItemInput + item: (nextItem: UpdateItemInput) => UpdateItemCommandMock _options: OPTIONS options: >( nextOptions: NEXT_OPTIONS @@ -36,7 +36,7 @@ export class UpdateItemCommandMock< constructor( mockedEntity: MockedEntity, - item?: UpdateItemInput, + item?: UpdateItemInput, options: OPTIONS = {} as OPTIONS ) { this.entity = mockedEntity[$entity]