@kaspernj/api-maker 1.0.402 → 1.0.404
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 +1 -1
- package/src/model-class-require.mjs +7 -2
- package/src/use-model.mjs +5 -1
package/package.json
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import {digg} from "diggerize"
|
|
2
1
|
import * as inflection from "inflection"
|
|
3
2
|
import * as models from "./models.mjs.erb"
|
|
4
3
|
|
|
5
4
|
export default (modelName) => {
|
|
6
5
|
const requireName = inflection.camelize(modelName)
|
|
7
|
-
const ModelClass =
|
|
6
|
+
const ModelClass = models[requireName]
|
|
7
|
+
|
|
8
|
+
if (!ModelClass) {
|
|
9
|
+
const modelClasses = Object.keys(models).sort()
|
|
10
|
+
|
|
11
|
+
throw new Error(`No model called ${modelName} in ${modelClasses.join(", ")}`)
|
|
12
|
+
}
|
|
8
13
|
|
|
9
14
|
return ModelClass
|
|
10
15
|
}
|
package/src/use-model.mjs
CHANGED
|
@@ -167,7 +167,11 @@ const useModel = (modelClassArg, argsArg = {}) => {
|
|
|
167
167
|
}
|
|
168
168
|
}, [args.onDestroyed, s.s.model?.id()])
|
|
169
169
|
|
|
170
|
-
const result = {
|
|
170
|
+
const result = {
|
|
171
|
+
model: s.s.model,
|
|
172
|
+
modelId,
|
|
173
|
+
notFound: s.s.notFound
|
|
174
|
+
}
|
|
171
175
|
|
|
172
176
|
result[modelVariableName] = s.s.model
|
|
173
177
|
result[`${modelVariableName}Id`] = modelId
|