@kaspernj/api-maker 1.0.143 → 1.0.146
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +1 -0
- package/package.json +2 -2
- package/src/base-model.cjs +5 -3
- package/src/model-load-wrapper.jsx +4 -1
- package/src/money-formatter.cjs +1 -1
package/.eslintrc.js
CHANGED
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
]
|
|
17
17
|
},
|
|
18
18
|
"name": "@kaspernj/api-maker",
|
|
19
|
-
"version": "1.0.
|
|
19
|
+
"version": "1.0.146",
|
|
20
20
|
"description": "",
|
|
21
21
|
"main": "index.js",
|
|
22
22
|
"repository": {
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"@babel/eslint-parser": "^7.16.3",
|
|
66
66
|
"@babel/preset-env": "^7.12.11",
|
|
67
67
|
"@babel/preset-react": "^7.12.10",
|
|
68
|
-
"babel-jest": "^
|
|
68
|
+
"babel-jest": "^28.0.3",
|
|
69
69
|
"eslint": "^8.2.0",
|
|
70
70
|
"eslint-find-rules": "^4.0.0",
|
|
71
71
|
"eslint-plugin-jest": "^26.0.0",
|
package/src/base-model.cjs
CHANGED
|
@@ -366,8 +366,8 @@ class BaseModel {
|
|
|
366
366
|
}
|
|
367
367
|
|
|
368
368
|
isNewRecord () {
|
|
369
|
-
if (this.newRecord
|
|
370
|
-
return
|
|
369
|
+
if (this.newRecord !== undefined) {
|
|
370
|
+
return this.newRecord
|
|
371
371
|
} else if ("id" in this.modelData && this.modelData.id) {
|
|
372
372
|
return false
|
|
373
373
|
} else {
|
|
@@ -676,7 +676,9 @@ class BaseModel {
|
|
|
676
676
|
if (attributeName in attributes) return null
|
|
677
677
|
}
|
|
678
678
|
|
|
679
|
-
|
|
679
|
+
if (this.isPersisted()) {
|
|
680
|
+
throw new AttributeNotLoadedError(`No such attribute: ${digg(this.modelClassData(), "name")}#${attributeName}: ${JSON.stringify(this.modelData)}`)
|
|
681
|
+
}
|
|
680
682
|
}
|
|
681
683
|
|
|
682
684
|
isAttributeLoaded (attributeName) {
|
|
@@ -48,7 +48,10 @@ export default (WrappedComponent, ModelClass, args = {}) => class modelLoadWrapp
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
const modelData = Object.assign(defaults, args.newAttributes, modelDataFromParams)
|
|
51
|
-
const model = new ModelClass(
|
|
51
|
+
const model = new ModelClass({
|
|
52
|
+
isNewRecord: true,
|
|
53
|
+
data: {a: modelData}
|
|
54
|
+
})
|
|
52
55
|
|
|
53
56
|
this.setState({model})
|
|
54
57
|
}
|
package/src/money-formatter.cjs
CHANGED
|
@@ -57,7 +57,7 @@ module.exports = class MoneyFormatter {
|
|
|
57
57
|
static isMoney(value) {
|
|
58
58
|
if (value instanceof Money) return true
|
|
59
59
|
|
|
60
|
-
if (typeof value == "object" && value && Object.keys(value).length == 2 &&
|
|
60
|
+
if (typeof value == "object" && value && Object.keys(value).length == 2 && "amount" in value && "currency" in value)
|
|
61
61
|
return true
|
|
62
62
|
|
|
63
63
|
return false
|