- Feature:
getEntityByType
helper added to thesingleTable.schema
to facilitate dynamic entity extractions - Fix:
GenericIndexMappingFns
return types were not properly defined as aRecord<string, ...>
- Fix:
swapParams
typing for partition param matching when creating an entity/index fix. If we had an incomplete paramMatch before, the resulting type for the keyGetter would not be properly merged.
Quick example:
export const pProjectPartition = schema.createPartition({
name: 'PROJECT_PARTITION',
getPartitionKey: ({ projectId }: { projectId: string }) => ['PROJECT', projectId],
entries: {
comments: ({ timestamp, taskId }: { projectId: string; taskId: string }) => [
'TASK',
taskId,
'COMMENT',
timestamp,
],
// ...other entries
},
});
interface TaskComment {
project: string;
task: string;
timestamp: string;
user: string;
id: string;
text: string;
}
export const eTaskComment = pProjectPartition
.use('comments')
.create<TaskComment>()
.entity({
type: 'TASK_COMMENT',
paramMatch: {
projectId: 'project',
taskId: 'task',
// we do not need to match timestamp, as the prop exists on TaskComment
},
autoGen: {
onCreate: {
timestamp: 'timestamp',
id: 'KSUID',
},
onUpdate: {
updatedAt: 'timestamp',
},
},
});
// before the fix: eTaskComment.getKey() params would be inferred as project/timestamp only
// now: correctly infers project/task/timestamp as the valid key params
- Fix:
IndexPartition
type forrangeQueries
- it was typed as the parsed obj (which happens at the entity level) instead of a pass-through. - Fix: Double low level transact params log on single table removed
- Type Enhance: Resolved entity type when
extend
is present was reworked to present some weird behavior withOmit
- Fix: Type for
ExtendableSingleTableEntity
adjusted based on new conditionalparser
property
-
Fix
: DynamoDBv3
tests breaking due tocommands
property missing -
Feature
: Entity can now receive anextend
function upon creation:type tUser = { id: string; name: string; dob: string; // ... more props } const User = table.schema.createEntity<User>().withParams({ // ...other props extend: ({ dob }) => ({ age: calculateAge(dob) }) })
The example above represent a property addition, the user calculated
age
. It will be present automatically after every retrieval call fromfromEntity
. Its also applied to thefromCollection
result.
Fix
entity index param generation prevented from passing an object with{ undefined: undefined }
down
ejectTransactParams
method added to theSingleTable
instance. Useful if you need to merge actions from other tables and want the proper param conversions done with the table config
- Type Enhance:
createSet
now properly infers DynamoDB version and arguments to give its result value - FIX :
createSet
was referencing itself on an infinite loop
- Removed the "You must provided a type parameter" type hack from
partition.use('XX').create<T>()
. It was causing the.entity({})
calls from it to be glitchy when the typeT
passed was atype T = Some & Other
declaration. Future revisions might evaluate how to enforce the type param down
rangeKeyGenerator
type onSingleTable.typeIndex
now correctly allowsundefined
as value. Useful for opting out the automatic generation
- New utility types exposed:
ExtractTableConfig
: Get the config object from your SingleTable instance
const table = new SingleTable({
// .. config
})
type YourConfig = ExtractTableConfig<typeof table>
ExtendableSingleTableEntity
: Create helper types that expect an entity
import { SingleTable, ExtractTableConfig, ExtendableSingleTableEntity, FromEntity } from 'dynamodb-provider'
const table = new SingleTable({
// .. config
})
type YourConfig = ExtractTableConfig<typeof table>
type EntityActions<Entity extends ExtendableSingleTableEntity> = FromEntity<Entity, YourConfig>
// easily reference the type of a table.schema.fromEntity(XXX) result
ExtendableCollection
: Create helper types that expect a collection
import { SingleTable, ExtractTableConfig, ExtendableCollection, FromCollection } from 'dynamodb-provider'
const table = new SingleTable({
// .. config
})
type YourConfig = ExtractTableConfig<typeof table>
type CollectionActions<Collection extends ExtendableCollection> = FromCollection<Entity, YourConfig>
// easily reference the type of a table.schema.fromCollection(XXX) result
- First version release. Stable.
- ExtendableSingleTableEntity type fix for the new transact param generators
- type of
ExtendableCRUDProps
responsible for definingfromEntity
adjusted to new entity transact param getters
transact
params generation added to entity. Now you can simplify transact params creations:
await table.executeTransaction([
{
create: entity1.getCreationParams({...})
},
{
create: entity2.getCreationParams({...})
},
// ...
])
// to
await table.executeTransaction([
entity1.transactCreateParams({...}),
entity2.transactUpdateParams({...}),
entity3.transactDeleteParams({...}),
entity4.transactValidadeParams({...}),
// ...
])
blockInternalPropUpdate
configuration added to SingleTable. now by default, any update that references any internal table prop will throw. You can disable this behavior and use thebadUpdateValidation
to only block the ones you want
- some Collection, FromEntity and FromCollection types exposed
- Early release
- Documentation Incomplete
Expect a lot of updates while we push to v1.0.0 and reach stability and follow SEMVER properly.
Usage in production before than is not recommended