sensedeep / dynamodb-onetable

DynamoDB access and management for one table designs with NodeJS
https://doc.onetable.io/
MIT License
689 stars 109 forks source link

Add (multidimensional) enum array typing #535

Closed thoom76 closed 4 months ago

thoom76 commented 4 months ago

Context

Assume we have the following schema:

export const TheSchema {
    ...,
    models: {
        SomeModel: {
            brands: {
                type: Array,
                    required: true,
                items: {
                        type: String,
                    enum: Object.values(Brand)
                }
            }
        }
    }
}

the following Entity type:

export type SomeModelEntity = Entity<typeof TheSchema.models.SomeModel>;

and the following code:

const {brands}: SomeModelEntity = {
    ...
}

Previously

when we check the type of brands we're seeing that it has the type string[] instead of the type Brand[]

New

When we check the type of brands we'll see that it has type Brand[]

mobsense commented 4 months ago

thank you. We'll test this out.

Michael

thoom76 commented 4 months ago

@mobsense Fixed the typing issue, do you want me to create tests for the typing itself?

mobsense commented 4 months ago

Is that possible?

thoom76 commented 4 months ago

Added the tests :+1:

thoom76 commented 4 months ago

@mobsense Idk if you guys are aware of it. When simply cloning the repo, making some changes and running npm run test locally results in succeeding tests while the CI/CD pipeline fails on the same changes. Running nvm use 20 && npm ci && npm run build --if-present && npm run lint --if-present && npm run test:v2 && npm run test:v3 like the pipeline job did the work for me to get the same results.

mobsense commented 4 months ago

Thank you for the patch.

mobsense commented 4 months ago

@mobsense Idk if you guys are aware of it. When simply cloning the repo, making some changes and running npm run test locally results in succeeding tests while the CI/CD pipeline fails on the same changes. Running nvm use 20 && npm ci && npm run build --if-present && npm run lint --if-present && npm run test:v2 && npm run test:v3 like the pipeline job did the work for me to get the same results.

Not really sure what you mean. The CI/CD seems to be working fine. When does it not work?