neoxia / dynamodels Goto Github PK
View Code? Open in Web Editor NEWTypescript overlay to easily interact with DynamoDB. Fluid syntax library offering pagination, auto-escape of reserved words and many more.
License: MIT License
Typescript overlay to easily interact with DynamoDB. Fluid syntax library offering pagination, auto-escape of reserved words and many more.
License: MIT License
Currently there is no batch write method.
Provide an overlay over DocumentClient.batchWrite that automatically split array of operations in batch respecting the AWS limitations.
A single BatchWriteItem request can contain up to 25 write requests (PutItem or DeleteItem)
To perform a batch write operation using the AWS SDK DocumentClient v3, you can use the batchWrite method. This method allows you to perform batch write operations on one or more tables in a DynamoDB database.
The compatibility with autoCreatedAt and autoUpdatedAt must be maintained with this new method.
Breaking changes !
Would be great to prefix protected methods _save, _create etc...
The Model class is abstract and need to be subclassed, but now we can't create methods called get, save with a different signature which is annoying
Dynamodels v1.3.3
Enhancement
We should be able to call a get-item method in addition of the save-item one.
CI tests are not passing in CI because of a dynamodb-local connection even if they're passing localy.
Run npm run test:ci
> [email protected] test:ci
> LOCAL_DYNAMODB_HOST=localhost LOCAL_DYNAMODB_PORT=8022 npx jest --runInBand --config jest.config.json --coverage --detectOpenHandles
Fatal: Cannot create table for tests UnrecognizedClientException: The Access Key ID or security token is invalid.
at throwDefaultError (/home/runner/work/dynamodels/dynamodels/node_modules/@smithy/smithy-client/dist-cjs/default-error-handler.js:8:22)
at /home/runner/work/dynamodels/dynamodels/node_modules/@smithy/smithy-client/dist-cjs/default-error-handler.js:18:39
at de_CreateTableCommandError (/home/runner/work/dynamodels/dynamodels/node_modules/@aws-sdk/client-dynamodb/dist-cjs/protocols/Aws_json1_0.js:6[4](https://github.com/neoxia/dynamodels/actions/runs/6233596966/job/17640767645?pr=278#step:7:5)2:20)
at process.processTicksAndRejections (node:internal/process/task_queues:9[5](https://github.com/neoxia/dynamodels/actions/runs/6233596966/job/17640767645?pr=278#step:7:6):5)
at async /home/runner/work/dynamodels/dynamodels/node_modules/@smithy/middleware-serde/dist-cjs/deserializerMiddleware.js:7:24
at async /home/runner/work/dynamodels/dynamodels/node_modules/@aws-sdk/middleware-signing/dist-cjs/awsAuthMiddleware.js:14:20
at async /home/runner/work/dynamodels/dynamodels/node_modules/@smithy/middleware-retry/dist-cjs/retryMiddleware.js:27:4[6](https://github.com/neoxia/dynamodels/actions/runs/6233596966/job/17640767645?pr=278#step:7:7)
at async /home/runner/work/dynamodels/dynamodels/node_modules/@aws-sdk/middleware-logger/dist-cjs/loggerMiddleware.js:[7](https://github.com/neoxia/dynamodels/actions/runs/6233596966/job/17640767645?pr=278#step:7:8):26
at async Promise.all (index 2)
at async exports.default (/home/runner/work/dynamodels/dynamodels/test/hooks/setup.ts:6:9) {
'$fault': 'client',
'$metadata': {
httpStatusCode: 400,
requestId: 'd36d0eb5-a6c4-4f[8](https://github.com/neoxia/dynamodels/actions/runs/6233596966/job/17640767645?pr=278#step:7:9)8-aa43-e5dea31a1[9](https://github.com/neoxia/dynamodels/actions/runs/6233596966/job/17640767645?pr=278#step:7:10)f0',
extendedRequestId: undefined,
cfId: undefined,
attempts: 1,
totalRetryDelay: 0
},
__type: 'com.amazonaws.dynamodb.v201208[10](https://github.com/neoxia/dynamodels/actions/runs/6233596966/job/17640767645?pr=278#step:7:11)#UnrecognizedClientException'
master
branch failed. π¨I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.
You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. Iβm sure you can resolve this πͺ.
Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.
Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master
branch. You can also manually restart the failed CI job that runs semantic-release.
If you are not sure how to resolve this, here is some links that can help you:
If those donβt help, or if this issue is reporting something you think isnβt right, you can always ask the humans behind semantic-release.
The npm token configured in the NPM_TOKEN
environment variable must be a valid token allowing to publish to the registry https://registry.npmjs.org/
.
If you are using Two-Factor Authentication, make configure the auth-only
level is supported. semantic-release cannot publish with the default auth-and-writes
level.
Please make sure to set the NPM_TOKEN
environment variable in your CI with the exact value of the npm token.
Good luck with your project β¨
Your semantic-release bot π¦π
Currently only a harcoded string is allowed as table name in Models definitons.
Add an option to source the table name from AWS Systems Manager (SSM) Parameter Store.
Instead of the table name, we pass a SSM ARN and the value is swapped on run-time.
Thus it would be possible to update the table name without redeployment (useful after a backup, for example).
export class MyModel extends Model<unknown> {
tableName = 'arn:aws:ssm:<aws-region>:<aws-account-id>:database-name-prod';
}
The behavior to implement is the following:
There are some vulnerabilities affecting Dynamodels. (babel & wordwrap)
Some dependencies from AWS SDK should be updated as well.
Would allow more than an interface, mapping toJson() method etc...
Model<Entity> were Entity is an extendable class with mapping etc... utilities
It would be good to have the ability to specify on model construction that we forbid scan.
class MyModel extends Model<unknown> {
allowScan = false;
}
If you perform a Model.prototype.scan
it will throw if allowScan === false
It would be useful to have automatically generated fields createdAt and updatedAt that are kept up to date when entities are updated.
class MyModel extends Model<unknown> {
autoCreatedAt = true; // false in super class
autoUpdatedAt = true; // false in super class
}
The createdAt
is set at the initial creation and remains unchanged. It is set only when using DocumentClient.create
method. And the validity of the field is not maintained by dynamodels on DocumentClient.save
.
Please make sure to update the updatedAt during subsequent calls to the DocumentClient.update
and DocumentClient.save
methods.
Affected version : v2.0.1
Current behavior:
When trying to use filter on nested attributes:
const myModel = new MyModel(); // With any Dynamodels model
const value = await myModel
.query()
.keys({
pk: 'something',
})
.filter(attr('key.#key2').eq('something-to-match'))
.execAll();
We get the following error:
ValidationException: ExpressionAttributeNames contains invalid key: Syntax error; key: "#key1.#key2f1a48369fb1b4fbf98c2ec8893a95063"
When it should just returns the filtered list.
The issues seems to be related to ExpressionAttributeNames mapping that is like this :
ExpressionAttributeNames: {
'#sk': 'sk',
'#key1.#key2f1a48369fb1b4fbf98c2ec8893a95063': 'key1.#key2'
}
When it should be like that:
ExpressionAttributeNames: {
'#sk': 'sk',
'#key12f1a48369fb1b4fbf98c2ec8893a95063' : 'key1',
'#key2<some-other-uuid>: 'key2'
}
Imho, we should just be able to type 'key1.key2.key3' and Dynamodels should parse this and understand that this is a nested attribute case and correctly fills the ExpressionAttributeNames.
When trying to save an invalid payload where hashkey is missing, dynamodels returns no item to save as type guard is based on hashkey !== undefined.
It should rather return validation error.
Provide a method that returns the number of items in the table
public async count(exact?: boolean): Promise<number>
Use the describeTable API if exact
is not specified.
The result will be returned quickly but is only refreshed every 6 hours.
Otherwise perform a full scan to get the exact count, which is time-consuming and not recommended
would be nice
And just ignore them
Affected version : v2.0.1
Current behavior:
Two useful imports come from 'dynamodels/dist/src/filter-conditions':
import { attr, not } from 'dynamodels/dist/src/filter-conditions';
We should just be able to imports them from 'dynamodels'.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.