-
-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support primitive arrays in models #98
Conversation
@with-heart @kettanaito is there anything here that I can help with to make this PR ready to go? |
787a0a2
to
b1d8fb8
Compare
Currently, the tests are failing here: FAIL test/model/create.test.ts
● creates a new entity
TypeError: Cannot use 'in' operator to search for '__type' in with-heart
8 | function isInternalEntity(value) {
9 | return (value &&
> 10 | glossary_1.InternalEntityProperty.type in value &&
| ^
11 | glossary_1.InternalEntityProperty.primaryKey in value);
12 | }
13 | exports.isInternalEntity = isInternalEntity;
at isInternalEntity (lib/utils/isInternalEntity.js:10:48)
at Array.every (<anonymous>)
at isManyOfRelation (lib/utils/removeInternalProperties.js:26:42)
at lib/utils/removeInternalProperties.js:46:13
at Array.reduce (<anonymous>)
at Object.removeInternalProperties (lib/utils/removeInternalProperties.js:32:35)
at Object.create (lib/factory.js:73:47)
at Object.<anonymous> (test/model/create.test.ts:18:30) This failure is caused by the data/src/utils/isInternalEntity.ts Lines 6 to 14 in 808295f
So evaluating |
I've introduced the object assertion in |
Array support in model definition was added in #113. Thank you for your work here, @with-heart! |
Closes #97
This PR adds primitive arrays support to models which is discussed in #97.
Changes made to support this feature:
BaseTypesArray
typeBaseTypesArray
toModelDefinition
andLimit
createModel
to use the exact array value rather than executingpropertyDefinition()
object
entities tomanyOf
block inremoveInternalProperties
so that primitive array properties are left aloneThis is my first time exploring
@mswjs/data
, so I could use some feedback on the approach here.I also ran into an issue where I was having to run
yarn build
in order for the tests to use the updated code. Is that typical?