@kaspernj/api-maker 1.0.138 → 1.0.141
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/package.json +19 -19
- package/src/config.js +15 -0
- package/src/money-formatter.cjs +9 -0
- package/src/routes-native.cjs +2 -1
- package/src/routes.cjs +2 -0
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.141",
|
|
20
20
|
"description": "",
|
|
21
21
|
"main": "index.js",
|
|
22
22
|
"repository": {
|
|
@@ -34,6 +34,24 @@
|
|
|
34
34
|
"eslint-find-rules": "eslint-find-rules",
|
|
35
35
|
"test": "jest"
|
|
36
36
|
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@rails/actioncable": ">= 6.1.0",
|
|
39
|
+
"clone-deep": ">= 4.0.1",
|
|
40
|
+
"debounce": ">= 1.2.1",
|
|
41
|
+
"diggerize": ">= 1.0.4",
|
|
42
|
+
"epic-locks": ">= 1.0.1",
|
|
43
|
+
"form-data-objectizer": ">= 1.0.0",
|
|
44
|
+
"form-serialize": ">= 0.7.2",
|
|
45
|
+
"format-number": ">= 3.0.0",
|
|
46
|
+
"inflection": ">= 1.12.0",
|
|
47
|
+
"js-money": ">= 0.6.3",
|
|
48
|
+
"numberable": ">= 1.0.0",
|
|
49
|
+
"object-to-formdata": ">= 4.1.0",
|
|
50
|
+
"qs": ">= 6.9.3",
|
|
51
|
+
"replaceall": ">= 0.1.6",
|
|
52
|
+
"strftime": ">= 0.10.0",
|
|
53
|
+
"wake-event": ">= 0.0.1"
|
|
54
|
+
},
|
|
37
55
|
"peerDependencies": {
|
|
38
56
|
"prop-types": "^15.7.2",
|
|
39
57
|
"prop-types-exact": ">= 1.2.0",
|
|
@@ -55,23 +73,5 @@
|
|
|
55
73
|
"i18n-on-steroids": "^1.0.2",
|
|
56
74
|
"jest": "^27.0.6",
|
|
57
75
|
"jsdom": "^19.0.0"
|
|
58
|
-
},
|
|
59
|
-
"dependencies": {
|
|
60
|
-
"@rails/actioncable": ">= 6.1.0",
|
|
61
|
-
"clone-deep": ">= 4.0.1",
|
|
62
|
-
"debounce": ">= 1.2.1",
|
|
63
|
-
"diggerize": ">= 1.0.4",
|
|
64
|
-
"epic-locks": ">= 1.0.1",
|
|
65
|
-
"form-data-objectizer": ">= 1.0.0",
|
|
66
|
-
"form-serialize": ">= 0.7.2",
|
|
67
|
-
"format-number": ">= 3.0.0",
|
|
68
|
-
"inflection": ">= 1.12.0",
|
|
69
|
-
"js-money": ">= 0.6.3",
|
|
70
|
-
"numberable": ">= 1.0.0",
|
|
71
|
-
"object-to-formdata": ">= 4.1.0",
|
|
72
|
-
"qs": ">= 6.9.3",
|
|
73
|
-
"replaceall": ">= 0.1.6",
|
|
74
|
-
"strftime": ">= 0.10.0",
|
|
75
|
-
"wake-event": ">= 0.0.1"
|
|
76
76
|
}
|
|
77
77
|
}
|
package/src/config.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
class ApiMakerConfig {
|
|
2
|
+
getCurrenciesCollection() {
|
|
3
|
+
if (!this._currenciesCollection) throw new Error("Currencies collection hasn't been set")
|
|
4
|
+
|
|
5
|
+
return this._currenciesCollection
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
setCurrenciesCollection(newCurrenciesCollection) {
|
|
9
|
+
this._currenciesCollection = newCurrenciesCollection
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const apiMakerConfig = new ApiMakerConfig()
|
|
14
|
+
|
|
15
|
+
export default apiMakerConfig
|
package/src/money-formatter.cjs
CHANGED
|
@@ -54,6 +54,15 @@ module.exports = class MoneyFormatter {
|
|
|
54
54
|
return moneyCurrency
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
static isMoney(value) {
|
|
58
|
+
if (value instanceof Money) return true
|
|
59
|
+
|
|
60
|
+
if (typeof value == "object" && value && Object.keys(value).length == 2 && value.amount && value.currency)
|
|
61
|
+
return true
|
|
62
|
+
|
|
63
|
+
return false
|
|
64
|
+
}
|
|
65
|
+
|
|
57
66
|
constructor (money, args = {}) {
|
|
58
67
|
this.args = args
|
|
59
68
|
this.money = money
|
package/src/routes-native.cjs
CHANGED
|
@@ -97,7 +97,8 @@ module.exports = class ApiMakerRoutesNative {
|
|
|
97
97
|
if (pathPart.type == "pathPart") {
|
|
98
98
|
return pathPart.name
|
|
99
99
|
} else if (pathPart.type == "variable") {
|
|
100
|
-
|
|
100
|
+
// Args might not contain the right amount of variables, so dont change this to 'digg'
|
|
101
|
+
return dig(args, digg(pathPart, "count"))
|
|
101
102
|
} else {
|
|
102
103
|
throw new Error(`Unhandled path part type: ${pathPart.type}`)
|
|
103
104
|
}
|
package/src/routes.cjs
CHANGED
|
@@ -3,6 +3,8 @@ const inflection = require("inflection")
|
|
|
3
3
|
|
|
4
4
|
module.exports = class ApiMakerRoutes {
|
|
5
5
|
constructor ({jsRoutes, locale, routeDefinitions}) {
|
|
6
|
+
if (!jsRoutes) throw new Error("'jsRoutes' wasn't given")
|
|
7
|
+
|
|
6
8
|
this.jsRoutes = jsRoutes
|
|
7
9
|
this.routeDefinitions = routeDefinitions
|
|
8
10
|
|