@kaspernj/api-maker 1.0.125 → 1.0.128
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 +39 -33
- package/__tests__/cable-connection-pool.test.js +4 -4
- package/__tests__/custom-error.test.js +13 -0
- package/__tests__/model-name.test.js +16 -10
- package/__tests__/routes-native.test.js +15 -33
- package/__tests__/support/task.js +5 -5
- package/__tests__/support/user.js +5 -5
- package/index.js +0 -4
- package/package.json +7 -6
- package/src/api.cjs +15 -15
- package/src/base-model.cjs +82 -81
- package/src/cable-connection-pool.cjs +11 -11
- package/src/cable-subscription-pool.cjs +34 -34
- package/src/cable-subscription.cjs +2 -2
- package/src/can-can-loader.jsx +7 -7
- package/src/can-can.cjs +17 -16
- package/src/collection.cjs +36 -36
- package/src/command-submit-data.cjs +10 -11
- package/src/commands-pool.cjs +13 -13
- package/src/custom-error.cjs +20 -14
- package/src/deserializer.cjs +7 -7
- package/src/devise.cjs +15 -15
- package/src/error-logger.cjs +9 -9
- package/src/event-connection.jsx +6 -6
- package/src/event-created.jsx +8 -8
- package/src/event-destroyed.jsx +6 -6
- package/src/event-emitter-listener.jsx +6 -6
- package/src/event-listener.jsx +8 -8
- package/src/event-model-class.jsx +6 -6
- package/src/event-updated.jsx +10 -10
- package/src/instance-of-class-name.cjs +5 -7
- package/src/key-value-store.cjs +21 -18
- package/src/logger.cjs +4 -4
- package/src/merge.cjs +4 -4
- package/src/model-events.cjs +6 -5
- package/src/model-name.cjs +6 -5
- package/src/model-prop-type.cjs +11 -13
- package/src/model-recipes-loader.cjs +4 -4
- package/src/model-recipes-model-loader.cjs +39 -14
- package/src/models-response-reader.cjs +10 -10
- package/src/money-formatter.cjs +11 -11
- package/src/params.cjs +7 -7
- package/src/preloaded.cjs +6 -6
- package/src/resource-route.cjs +14 -12
- package/src/resource-routes.jsx +9 -4
- package/src/result.cjs +7 -7
- package/src/routes-native.cjs +6 -6
- package/src/routes.cjs +1 -1
- package/src/serializer.cjs +9 -9
- package/src/services.cjs +3 -3
- package/src/session-status-updater.cjs +14 -14
- package/src/source-maps-loader.cjs +11 -11
- package/src/translated-collections.cjs +2 -1
- package/src/updated-attribute.jsx +17 -14
- package/src/validation-error.cjs +5 -8
- package/src/validation-errors.cjs +16 -16
- package/src/event-location-changed.jsx +0 -21
- package/src/history-listener.jsx +0 -20
package/.eslintrc.js
CHANGED
|
@@ -9,6 +9,7 @@ module.exports = {
|
|
|
9
9
|
"plugin:react/recommended",
|
|
10
10
|
"plugin:jest/recommended"
|
|
11
11
|
],
|
|
12
|
+
parser: "@babel/eslint-parser",
|
|
12
13
|
parserOptions: {
|
|
13
14
|
ecmaFeatures: {
|
|
14
15
|
jsx: true
|
|
@@ -36,62 +37,62 @@ module.exports = {
|
|
|
36
37
|
"block-scoped-var": "error",
|
|
37
38
|
"block-spacing": "error",
|
|
38
39
|
"brace-style": "error",
|
|
39
|
-
"class-methods-use-this": "
|
|
40
|
+
"class-methods-use-this": "off",
|
|
40
41
|
"comma-dangle": "error",
|
|
41
42
|
"comma-spacing": "error",
|
|
42
43
|
"comma-style": "error",
|
|
43
44
|
"complexity": "error",
|
|
44
45
|
"computed-property-spacing": "error",
|
|
45
|
-
"consistent-return": "
|
|
46
|
+
"consistent-return": "off",
|
|
46
47
|
"consistent-this": "error",
|
|
47
|
-
"curly":
|
|
48
|
+
"curly": "off",
|
|
48
49
|
"default-case": "error",
|
|
49
50
|
"default-case-last": "error",
|
|
50
51
|
"default-param-last": "error",
|
|
51
52
|
"dot-location": ["error", "property"],
|
|
52
53
|
"dot-notation": "error",
|
|
53
54
|
"eol-last": "error",
|
|
54
|
-
"eqeqeq": "
|
|
55
|
+
"eqeqeq": "off",
|
|
56
|
+
"function-call-argument-newline": "off",
|
|
55
57
|
"func-call-spacing": "error",
|
|
56
58
|
"func-name-matching": "error",
|
|
57
59
|
"func-style": "error",
|
|
58
60
|
"function-paren-newline": "error",
|
|
59
61
|
"generator-star-spacing": "error",
|
|
60
62
|
"grouped-accessor-pairs": "error",
|
|
61
|
-
"guard-for-in": "
|
|
63
|
+
"guard-for-in": "off", // Disabled because insane?
|
|
62
64
|
"id-denylist": "error",
|
|
63
65
|
"id-match": "error",
|
|
64
66
|
"implicit-arrow-linebreak": "error",
|
|
65
67
|
"indent": ["error", 2, {"MemberExpression": "off"}],
|
|
66
|
-
"init-declarations": "
|
|
67
|
-
"jest/lowercase-name": ["error", {ignore: ["describe"]}],
|
|
68
|
+
"init-declarations": "off",
|
|
68
69
|
"jest/max-nested-describe": "error",
|
|
69
70
|
"jest/no-alias-methods": "error",
|
|
70
71
|
"jest/no-duplicate-hooks": "error",
|
|
71
|
-
"jest/no-hooks": "
|
|
72
|
+
"jest/no-hooks": "off",
|
|
72
73
|
"jest/no-if": "error",
|
|
73
74
|
"jest/no-large-snapshots": "error",
|
|
74
75
|
"jest/no-restricted-matchers": "error",
|
|
75
76
|
"jest/no-test-return-statement": "error",
|
|
76
77
|
"jest/prefer-expect-resolves": "off", // Needs configuration and no documentation could be found?
|
|
77
78
|
"jest/prefer-hooks-on-top": "error",
|
|
79
|
+
"jest/prefer-lowercase-title": "off",
|
|
78
80
|
"jest/prefer-to-be": "off", // Needs configuration and no documentation could be found?
|
|
79
81
|
"jest/prefer-spy-on": "error",
|
|
80
|
-
"jest/prefer-to-be-null": "error",
|
|
81
|
-
"jest/prefer-to-be-undefined": "error",
|
|
82
82
|
"jest/prefer-to-contain": "error",
|
|
83
83
|
"jest/prefer-todo": "error",
|
|
84
|
+
"jest/require-hook": "error",
|
|
84
85
|
"jest/require-to-throw-message": "error",
|
|
85
86
|
"jest/require-top-level-describe": "error",
|
|
86
87
|
"jest/unbound-method": "error",
|
|
87
88
|
"jsx-quotes": "error",
|
|
88
89
|
"key-spacing": "error",
|
|
89
|
-
"keyword-spacing": "
|
|
90
|
+
"keyword-spacing": "off",
|
|
90
91
|
"linebreak-style": ["error", "unix"],
|
|
91
92
|
"line-comment-position": "off",
|
|
92
93
|
"lines-around-comment": "error",
|
|
93
|
-
"lines-between-class-members": "
|
|
94
|
-
"max-classes-per-file": "
|
|
94
|
+
"lines-between-class-members": "off",
|
|
95
|
+
"max-classes-per-file": "off",
|
|
95
96
|
"max-depth": "error",
|
|
96
97
|
"max-nested-callbacks": "error",
|
|
97
98
|
"max-params": "error",
|
|
@@ -110,7 +111,7 @@ module.exports = {
|
|
|
110
111
|
"no-continue": "error",
|
|
111
112
|
"no-div-regex": "error",
|
|
112
113
|
"no-duplicate-imports": "error",
|
|
113
|
-
"no-else-return": "
|
|
114
|
+
"no-else-return": "off",
|
|
114
115
|
"no-eq-null": "error",
|
|
115
116
|
"no-eval": "error",
|
|
116
117
|
"no-extra-bind": "error",
|
|
@@ -143,7 +144,7 @@ module.exports = {
|
|
|
143
144
|
"no-nonoctal-decimal-escape": "error",
|
|
144
145
|
"no-octal-escape": "error",
|
|
145
146
|
"no-param-reassign": "error",
|
|
146
|
-
"no-plusplus": "
|
|
147
|
+
"no-plusplus": "off",
|
|
147
148
|
"no-promise-executor-return": "error",
|
|
148
149
|
"no-proto": "error",
|
|
149
150
|
"no-restricted-exports": "error",
|
|
@@ -165,8 +166,10 @@ module.exports = {
|
|
|
165
166
|
"no-unmodified-loop-condition": "error",
|
|
166
167
|
"no-unneeded-ternary": "error",
|
|
167
168
|
"no-unreachable-loop": "error",
|
|
169
|
+
"no-unused-private-class-members": "error",
|
|
168
170
|
"no-unsafe-optional-chaining": "error",
|
|
169
171
|
"no-unused-expressions": "error",
|
|
172
|
+
"no-unused-vars": ["error", {"argsIgnorePattern": "^_", "ignoreRestSiblings": true}],
|
|
170
173
|
"no-use-before-define": "error",
|
|
171
174
|
"no-useless-backreference": "error",
|
|
172
175
|
"no-useless-call": "error",
|
|
@@ -178,14 +181,14 @@ module.exports = {
|
|
|
178
181
|
"no-void": "error",
|
|
179
182
|
"no-warning-comments": "off",
|
|
180
183
|
"no-whitespace-before-property": "error",
|
|
181
|
-
"nonblock-statement-body-position": "error",
|
|
184
|
+
"nonblock-statement-body-position": ["error", "any"],
|
|
182
185
|
"object-curly-newline": "error",
|
|
183
186
|
"object-curly-spacing": "error",
|
|
184
187
|
"object-shorthand": "error",
|
|
185
188
|
"one-var-declaration-per-line": "error",
|
|
186
189
|
"operator-assignment": "error",
|
|
187
190
|
"operator-linebreak": "error",
|
|
188
|
-
"padded-blocks": "
|
|
191
|
+
"padded-blocks": ["error", "never"],
|
|
189
192
|
"padding-line-between-statements": "error",
|
|
190
193
|
"prefer-arrow-callback": "error",
|
|
191
194
|
"prefer-exponentiation-operator": "error",
|
|
@@ -201,13 +204,13 @@ module.exports = {
|
|
|
201
204
|
"radix": "error",
|
|
202
205
|
"react/boolean-prop-naming": "error",
|
|
203
206
|
"react/button-has-type": "error",
|
|
204
|
-
"react/default-props-match-prop-types": "
|
|
205
|
-
"react/destructuring-assignment": "
|
|
206
|
-
"react/forbid-component-props": "
|
|
207
|
+
"react/default-props-match-prop-types": "off",
|
|
208
|
+
"react/destructuring-assignment": "off",
|
|
209
|
+
"react/forbid-component-props": "off",
|
|
207
210
|
"react/forbid-dom-props": "error",
|
|
208
211
|
"react/forbid-elements": "error",
|
|
209
212
|
"react/forbid-foreign-prop-types": "error",
|
|
210
|
-
"react/forbid-prop-types": "
|
|
213
|
+
"react/forbid-prop-types": "off",
|
|
211
214
|
"react/function-component-definition": "error",
|
|
212
215
|
"react/jsx-boolean-value": "error",
|
|
213
216
|
"react/jsx-child-element-spacing": "error",
|
|
@@ -220,12 +223,12 @@ module.exports = {
|
|
|
220
223
|
"react/jsx-filename-extension": "error",
|
|
221
224
|
"react/jsx-first-prop-new-line": "error",
|
|
222
225
|
"react/jsx-fragments": "error",
|
|
223
|
-
"react/jsx-handler-names": "
|
|
224
|
-
"react/jsx-indent": "error",
|
|
225
|
-
"react/jsx-indent-props": "error",
|
|
226
|
+
"react/jsx-handler-names": "off",
|
|
227
|
+
"react/jsx-indent": ["error", 2],
|
|
228
|
+
"react/jsx-indent-props": ["error", 2],
|
|
226
229
|
"react/jsx-max-depth": "error",
|
|
227
230
|
"react/jsx-max-props-per-line": "error",
|
|
228
|
-
"react/jsx-newline": "
|
|
231
|
+
"react/jsx-newline": "off",
|
|
229
232
|
"react/jsx-no-bind": "error",
|
|
230
233
|
"react/jsx-no-constructed-context-values": "error",
|
|
231
234
|
"react/jsx-no-literals": "error",
|
|
@@ -234,7 +237,7 @@ module.exports = {
|
|
|
234
237
|
"react/jsx-one-expression-per-line": "error",
|
|
235
238
|
"react/jsx-pascal-case": "error",
|
|
236
239
|
"react/jsx-props-no-multi-spaces": "error",
|
|
237
|
-
"react/jsx-props-no-spreading": "
|
|
240
|
+
"react/jsx-props-no-spreading": "off",
|
|
238
241
|
"react/jsx-sort-default-props": "error",
|
|
239
242
|
"react/jsx-sort-props": "error",
|
|
240
243
|
"react/jsx-tag-spacing": "error",
|
|
@@ -242,16 +245,19 @@ module.exports = {
|
|
|
242
245
|
"react/no-access-state-in-setstate": "error",
|
|
243
246
|
"react/no-adjacent-inline-elements": "error",
|
|
244
247
|
"react/no-array-index-key": "error",
|
|
248
|
+
"react/no-arrow-function-lifecycle": "error",
|
|
245
249
|
"react/no-danger": "error",
|
|
246
250
|
"react/no-did-mount-set-state": "error",
|
|
247
251
|
"react/no-did-update-set-state": "error",
|
|
252
|
+
"react/no-invalid-html-attribute": "error",
|
|
248
253
|
"react/no-multi-comp": "error",
|
|
249
254
|
"react/no-namespace": "error",
|
|
250
255
|
"react/no-redundant-should-component-update": "error",
|
|
251
|
-
"react/no-set-state": "
|
|
256
|
+
"react/no-set-state": "off",
|
|
252
257
|
"react/no-this-in-sfc": "error",
|
|
253
258
|
"react/no-typos": "error",
|
|
254
259
|
"react/no-unstable-nested-components": "error",
|
|
260
|
+
"react/no-unused-class-component-methods": "off",
|
|
255
261
|
"react/no-unused-prop-types": "error",
|
|
256
262
|
"react/no-unused-state": "error",
|
|
257
263
|
"react/no-will-update-set-state": "error",
|
|
@@ -259,12 +265,13 @@ module.exports = {
|
|
|
259
265
|
"react/prefer-exact-props": "error",
|
|
260
266
|
"react/prefer-read-only-props": "error",
|
|
261
267
|
"react/prefer-stateless-function": "error",
|
|
262
|
-
"react/
|
|
268
|
+
"react/prop-types": "off", // Disabled because it doesn't work with propTypesExact
|
|
269
|
+
"react/require-default-props": "off",
|
|
263
270
|
"react/require-optimization": "error",
|
|
264
271
|
"react/self-closing-comp": "error",
|
|
265
|
-
"react/sort-comp": "
|
|
272
|
+
"react/sort-comp": "off",
|
|
266
273
|
"react/sort-prop-types": "error",
|
|
267
|
-
"react/state-in-constructor": "
|
|
274
|
+
"react/state-in-constructor": "off",
|
|
268
275
|
"react/static-property-placement": "error",
|
|
269
276
|
"react/style-prop-object": "error",
|
|
270
277
|
"react/void-dom-elements-no-children": "error",
|
|
@@ -276,6 +283,7 @@ module.exports = {
|
|
|
276
283
|
"sort-imports": "error",
|
|
277
284
|
"sort-vars": "error",
|
|
278
285
|
"space-before-blocks": "error",
|
|
286
|
+
"space-before-function-paren": "error",
|
|
279
287
|
"space-in-parens": "error",
|
|
280
288
|
"space-infix-ops": "error",
|
|
281
289
|
"space-unary-ops": "error",
|
|
@@ -296,7 +304,6 @@ module.exports = {
|
|
|
296
304
|
"camelcase": "off",
|
|
297
305
|
"capitalized-comments": "off",
|
|
298
306
|
"func-names": "off",
|
|
299
|
-
"function-call-argument-newline": "off",
|
|
300
307
|
"id-length": "off",
|
|
301
308
|
"jest/consistent-test-it": "off",
|
|
302
309
|
"jest/prefer-called-with": "off",
|
|
@@ -304,7 +311,7 @@ module.exports = {
|
|
|
304
311
|
"jest/prefer-strict-equal": "off",
|
|
305
312
|
"no-shadow": "off",
|
|
306
313
|
"jest/prefer-to-have-length": "off",
|
|
307
|
-
"max-len": "
|
|
314
|
+
"max-len": ["error", {"code": 160}],
|
|
308
315
|
"max-lines": "off",
|
|
309
316
|
"max-lines-per-function": "off",
|
|
310
317
|
"max-statements": "off",
|
|
@@ -324,7 +331,6 @@ module.exports = {
|
|
|
324
331
|
"require-await": "off",
|
|
325
332
|
"require-unicode-regexp": "off",
|
|
326
333
|
"sort-keys": "off",
|
|
327
|
-
"space-before-function-paren": "off",
|
|
328
334
|
"spaced-comment": "off"
|
|
329
335
|
}
|
|
330
336
|
}
|
|
@@ -75,7 +75,7 @@ describe("CableConnectionPool", () => {
|
|
|
75
75
|
const cableSubscriptionPool = new CableSubscriptionPool()
|
|
76
76
|
|
|
77
77
|
cableSubscriptionPool.connected = true
|
|
78
|
-
cableSubscriptionPool.connectUnsubscriptionForSubscription = function() {
|
|
78
|
+
cableSubscriptionPool.connectUnsubscriptionForSubscription = function () {
|
|
79
79
|
connectedUnsubscribeEvent = true
|
|
80
80
|
}
|
|
81
81
|
cableSubscriptionPool.subscriptions = {
|
|
@@ -109,7 +109,7 @@ describe("CableConnectionPool", () => {
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
cableConnectionPool.connected = false
|
|
112
|
-
cableConnectionPool.connectUpcoming = function() {
|
|
112
|
+
cableConnectionPool.connectUpcoming = function () {
|
|
113
113
|
const subscriptionData = this.upcomingSubscriptionData
|
|
114
114
|
const subscriptions = this.upcomingSubscriptions
|
|
115
115
|
|
|
@@ -173,7 +173,7 @@ describe("CableConnectionPool", () => {
|
|
|
173
173
|
const cableSubscriptionPool = new CableSubscriptionPool()
|
|
174
174
|
|
|
175
175
|
cableSubscriptionPool.connected = true
|
|
176
|
-
cableSubscriptionPool.connectUnsubscriptionForSubscription = function() {
|
|
176
|
+
cableSubscriptionPool.connectUnsubscriptionForSubscription = function () {
|
|
177
177
|
connectedUnsubscribeEvent = true
|
|
178
178
|
}
|
|
179
179
|
cableSubscriptionPool.subscriptions = {
|
|
@@ -201,7 +201,7 @@ describe("CableConnectionPool", () => {
|
|
|
201
201
|
const cableSubscriptionPool = new CableSubscriptionPool()
|
|
202
202
|
|
|
203
203
|
cableSubscriptionPool.connected = true
|
|
204
|
-
cableSubscriptionPool.connectUnsubscriptionForSubscription = function() {
|
|
204
|
+
cableSubscriptionPool.connectUnsubscriptionForSubscription = function () {
|
|
205
205
|
connectedUnsubscribeEvent = true
|
|
206
206
|
}
|
|
207
207
|
cableSubscriptionPool.subscriptions = {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const CustomError = require("../src/custom-error.cjs")
|
|
2
|
+
|
|
3
|
+
describe("CustomError", () => {
|
|
4
|
+
it("handles when response is a string", () => {
|
|
5
|
+
const xhr = {status: 401}
|
|
6
|
+
const response = "An error happened"
|
|
7
|
+
const customError = new CustomError(`Request failed with code: ${xhr.status}`, {response, xhr})
|
|
8
|
+
|
|
9
|
+
expect(customError.message).toEqual("Request failed with code: 401")
|
|
10
|
+
expect(customError.errorMessages()).toEqual(undefined)
|
|
11
|
+
expect(customError.errorTypes()).toEqual(undefined)
|
|
12
|
+
})
|
|
13
|
+
})
|
|
@@ -2,21 +2,27 @@ const I18nOnSteroids = require("i18n-on-steroids")
|
|
|
2
2
|
const i18n = new I18nOnSteroids()
|
|
3
3
|
const ModelName = require("../src/model-name.cjs")
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
const initializeI18n = () => {
|
|
6
|
+
i18n.scanObject({
|
|
7
|
+
da: {
|
|
8
|
+
activerecord: {
|
|
9
|
+
models: {
|
|
10
|
+
user: {
|
|
11
|
+
one: "Bruger",
|
|
12
|
+
other: "Brugere"
|
|
13
|
+
}
|
|
12
14
|
}
|
|
13
15
|
}
|
|
14
16
|
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
})
|
|
18
|
+
i18n.setLocale("da")
|
|
19
|
+
}
|
|
18
20
|
|
|
19
21
|
describe("ModelName", () => {
|
|
22
|
+
beforeEach(() => {
|
|
23
|
+
initializeI18n()
|
|
24
|
+
})
|
|
25
|
+
|
|
20
26
|
test("human", () => {
|
|
21
27
|
const modelClassData = {i18nKey: "user"}
|
|
22
28
|
const modelName = new ModelName({i18n, modelClassData})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const RoutesNative = require("../src/routes-native.cjs")
|
|
2
|
-
const testRoutes = {
|
|
2
|
+
const testRoutes = () => ({
|
|
3
3
|
routes: [
|
|
4
4
|
{"name": "blank", "path": "/blank", "component": "blank"},
|
|
5
5
|
|
|
@@ -10,8 +10,8 @@ const testRoutes = {
|
|
|
10
10
|
{"name": "drink", "path": "/drinks/:id", "component": "drinks/show"},
|
|
11
11
|
{"name": "drinks", "path": "/drinks", "component": "drinks/index"}
|
|
12
12
|
]
|
|
13
|
-
}
|
|
14
|
-
const testTranslations = {
|
|
13
|
+
})
|
|
14
|
+
const testTranslations = () => ({
|
|
15
15
|
locales: {
|
|
16
16
|
da: {
|
|
17
17
|
routes: {
|
|
@@ -26,94 +26,76 @@ const testTranslations = {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
let currentLocale = "en"
|
|
29
|
+
})
|
|
32
30
|
|
|
33
|
-
const routesNative = ({args}) => {
|
|
31
|
+
const routesNative = ({args, currentLocale}) => {
|
|
34
32
|
const test = new RoutesNative({
|
|
35
33
|
getLocale: () => currentLocale
|
|
36
34
|
})
|
|
37
35
|
|
|
38
|
-
test.loadRouteTranslations(testTranslations)
|
|
39
|
-
test.loadRouteDefinitions(testRoutes, args)
|
|
36
|
+
test.loadRouteTranslations(testTranslations())
|
|
37
|
+
test.loadRouteDefinitions(testRoutes(), args)
|
|
40
38
|
|
|
41
39
|
return test
|
|
42
40
|
}
|
|
43
41
|
|
|
44
42
|
describe("RoutesNative", () => {
|
|
45
43
|
it("translates routes from the current locale", () => {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const test = routesNative({args: {localized: true}})
|
|
44
|
+
const test = routesNative({args: {localized: true}, currentLocale: "da"})
|
|
49
45
|
const daRoute = test.editDrinkPath(5)
|
|
50
46
|
|
|
51
47
|
expect(daRoute).toEqual("/da/drinks/5/rediger")
|
|
52
48
|
})
|
|
53
49
|
|
|
54
50
|
it("translates routes from the locale-param", () => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const test = routesNative({args: {localized: true}})
|
|
51
|
+
const test = routesNative({args: {localized: true}, currentLocale: "en"})
|
|
58
52
|
const daRoute = test.editDrinkPath(5, {locale: "da"})
|
|
59
53
|
|
|
60
54
|
expect(daRoute).toEqual("/da/drinks/5/rediger")
|
|
61
55
|
})
|
|
62
56
|
|
|
63
57
|
it("defaults to the locale given by the getLocale callback", () => {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const test = routesNative({args: {localized: true}})
|
|
58
|
+
const test = routesNative({args: {localized: true}, currentLocale: "en"})
|
|
67
59
|
const daRoute = test.editDrinkPath(5)
|
|
68
60
|
|
|
69
61
|
expect(daRoute).toEqual("/en/drinks/5/edit")
|
|
70
62
|
})
|
|
71
63
|
|
|
72
64
|
it("uses the rest of the params as a query string", () => {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const test = routesNative({args: {localized: true}})
|
|
65
|
+
const test = routesNative({args: {localized: true}, currentLocale: "en"})
|
|
76
66
|
const daRoute = test.editDrinkPath(5, {drink: {name: "Pina Colada"}, locale: "da"})
|
|
77
67
|
|
|
78
68
|
expect(daRoute).toEqual("/da/drinks/5/rediger?drink%5Bname%5D=Pina%20Colada")
|
|
79
69
|
})
|
|
80
70
|
|
|
81
71
|
it("translates a route without localization", () => {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const test = routesNative({})
|
|
72
|
+
const test = routesNative({currentLocale: "en"})
|
|
85
73
|
const daRoute = test.editDrinkPath(5, {drink: {name: "Pina Colada"}})
|
|
86
74
|
|
|
87
75
|
expect(daRoute).toEqual("/drinks/5/edit?drink%5Bname%5D=Pina%20Colada")
|
|
88
76
|
})
|
|
89
77
|
|
|
90
78
|
it("generates urls", () => {
|
|
91
|
-
currentLocale = "en"
|
|
92
|
-
|
|
93
79
|
if (!global.location) global.location = {} // eslint-disable-line jest/no-if
|
|
94
80
|
|
|
95
81
|
global.location.host = "localhost"
|
|
96
82
|
global.location.protocol = "http:"
|
|
97
83
|
|
|
98
|
-
const test = routesNative({args: {localized: true}})
|
|
84
|
+
const test = routesNative({args: {localized: true}, currentLocale: "en"})
|
|
99
85
|
const daRoute = test.editDrinkUrl(5, {drink: {name: "Pina Colada"}, locale: "da"})
|
|
100
86
|
|
|
101
87
|
expect(daRoute).toEqual("http://localhost/da/drinks/5/rediger?drink%5Bname%5D=Pina%20Colada")
|
|
102
88
|
})
|
|
103
89
|
|
|
104
90
|
it("generates urls with custom options", () => {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
const test = routesNative({args: {localized: true}})
|
|
91
|
+
const test = routesNative({args: {localized: true}, currentLocale: "en"})
|
|
108
92
|
const daRoute = test.editDrinkUrl(5, {drink: {name: "Pina Colada"}, locale: "da", host: "google.com", port: 123, protocol: "https"})
|
|
109
93
|
|
|
110
94
|
expect(daRoute).toEqual("https://google.com:123/da/drinks/5/rediger?drink%5Bname%5D=Pina%20Colada")
|
|
111
95
|
})
|
|
112
96
|
|
|
113
97
|
it("generates urls without locales", () => {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
const test = routesNative({})
|
|
98
|
+
const test = routesNative({currentLocale: "en"})
|
|
117
99
|
const daRoute = test.editDrinkUrl(5, {drink: {name: "Pina Colada"}, locale: "da", host: "google.com", port: 123, protocol: "https"})
|
|
118
100
|
|
|
119
101
|
expect(daRoute).toEqual("https://google.com:123/drinks/5/edit?drink%5Bname%5D=Pina%20Colada")
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
module.exports = class Task {
|
|
2
|
-
static modelClassData() {
|
|
2
|
+
static modelClassData () {
|
|
3
3
|
return {
|
|
4
4
|
attributes: [],
|
|
5
5
|
name: "Task"
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
static modelName() {
|
|
9
|
+
static modelName () {
|
|
10
10
|
return "Task"
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
constructor({a, b, isNewRecord = false, r} = {}) {
|
|
13
|
+
constructor ({a, b, isNewRecord = false, r} = {}) {
|
|
14
14
|
this.abilities = b
|
|
15
15
|
this._isNewRecord = isNewRecord
|
|
16
16
|
this.modelData = a
|
|
17
17
|
this.relationshipsCache = r
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
isNewRecord() {
|
|
20
|
+
isNewRecord () {
|
|
21
21
|
return this._isNewRecord
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
isPersisted() {
|
|
24
|
+
isPersisted () {
|
|
25
25
|
return !this._isNewRecord
|
|
26
26
|
}
|
|
27
27
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const BaseModel = require("../../src/base-model.cjs")
|
|
2
2
|
|
|
3
3
|
module.exports = class User extends BaseModel {
|
|
4
|
-
static modelClassData() {
|
|
4
|
+
static modelClassData () {
|
|
5
5
|
return {
|
|
6
6
|
attributes: [],
|
|
7
7
|
name: "User",
|
|
@@ -9,11 +9,11 @@ module.exports = class User extends BaseModel {
|
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
static modelName() {
|
|
12
|
+
static modelName () {
|
|
13
13
|
return "User"
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
constructor({a, b, isNewRecord = false, r}) {
|
|
16
|
+
constructor ({a, b, isNewRecord = false, r}) {
|
|
17
17
|
super({a})
|
|
18
18
|
|
|
19
19
|
this.abilities = b
|
|
@@ -22,11 +22,11 @@ module.exports = class User extends BaseModel {
|
|
|
22
22
|
this.relationshipsCache = r
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
isNewRecord() {
|
|
25
|
+
isNewRecord () {
|
|
26
26
|
return this._isNewRecord
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
isPersisted() {
|
|
29
|
+
isPersisted () {
|
|
30
30
|
return !this._isNewRecord
|
|
31
31
|
}
|
|
32
32
|
}
|
package/index.js
CHANGED
|
@@ -16,10 +16,8 @@ const EventCreated = require("./src/event-created").default
|
|
|
16
16
|
const EventDestroyed = require("./src/event-destroyed").default
|
|
17
17
|
const EventEmitterListener = require("./src/event-emitter-listener").default
|
|
18
18
|
const EventListener = require("./src/event-listener").default
|
|
19
|
-
const EventLocationChanged = require("./src/event-location-changed").default
|
|
20
19
|
const EventModelClass = require("./src/event-model-class").default
|
|
21
20
|
const EventUpdated = require("./src/event-updated").default
|
|
22
|
-
const HistoryListener = require("./src/history-listener").default
|
|
23
21
|
const instanceOfClassName = require("./src/instance-of-class-name.cjs")
|
|
24
22
|
const KeyValueStore = require("./src/key-value-store.cjs")
|
|
25
23
|
const Logger = require("./src/logger.cjs")
|
|
@@ -62,10 +60,8 @@ export {
|
|
|
62
60
|
EventDestroyed,
|
|
63
61
|
EventEmitterListener,
|
|
64
62
|
EventListener,
|
|
65
|
-
EventLocationChanged,
|
|
66
63
|
EventModelClass,
|
|
67
64
|
EventUpdated,
|
|
68
|
-
HistoryListener,
|
|
69
65
|
instanceOfClassName,
|
|
70
66
|
KeyValueStore,
|
|
71
67
|
Logger,
|
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.128",
|
|
20
20
|
"description": "",
|
|
21
21
|
"main": "index.js",
|
|
22
22
|
"repository": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"homepage": "https://github.com/kaspernj/api_maker",
|
|
32
32
|
"scripts": {
|
|
33
|
-
"eslint": "eslint",
|
|
33
|
+
"eslint": "eslint --ext .cjs,.js,.jsx",
|
|
34
34
|
"eslint-find-rules": "eslint-find-rules",
|
|
35
35
|
"test": "jest"
|
|
36
36
|
},
|
|
@@ -44,22 +44,23 @@
|
|
|
44
44
|
"stacktrace-parser": ">= 0.1.9"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
+
"@babel/eslint-parser": "^7.16.3",
|
|
47
48
|
"@babel/preset-env": "^7.12.11",
|
|
48
49
|
"@babel/preset-react": "^7.12.10",
|
|
49
50
|
"babel-jest": "^27.0.6",
|
|
50
|
-
"eslint": "^
|
|
51
|
+
"eslint": "^8.2.0",
|
|
51
52
|
"eslint-find-rules": "^4.0.0",
|
|
52
|
-
"eslint-plugin-jest": "^
|
|
53
|
+
"eslint-plugin-jest": "^26.0.0",
|
|
53
54
|
"eslint-plugin-react": "^7.23.2",
|
|
54
55
|
"i18n-on-steroids": "^1.0.2",
|
|
55
56
|
"jest": "^27.0.6",
|
|
56
|
-
"jsdom": "^
|
|
57
|
+
"jsdom": "^19.0.0"
|
|
57
58
|
},
|
|
58
59
|
"dependencies": {
|
|
59
60
|
"@rails/actioncable": ">= 6.1.0",
|
|
60
61
|
"clone-deep": ">= 4.0.1",
|
|
61
62
|
"debounce": ">= 1.2.1",
|
|
62
|
-
"diggerize": ">= 1.0.
|
|
63
|
+
"diggerize": ">= 1.0.4",
|
|
63
64
|
"epic-locks": ">= 1.0.1",
|
|
64
65
|
"form-data-objectizer": ">= 1.0.0",
|
|
65
66
|
"form-serialize": ">= 0.7.2",
|