@kaspernj/api-maker 1.0.130 → 1.0.131
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/devise.cjs +2 -10
- package/src/serializer.cjs +5 -0
package/package.json
CHANGED
package/src/devise.cjs
CHANGED
|
@@ -49,18 +49,10 @@ module.exports = class ApiMakerDevise {
|
|
|
49
49
|
|
|
50
50
|
const postData = {username, password, args}
|
|
51
51
|
const response = await Services.current().sendRequest("Devise::SignIn", postData)
|
|
52
|
-
const modelClass = digg(require("@kaspernj/api-maker/src/models"), inflection.camelize(args.scope))
|
|
53
|
-
const modelInstance = new modelClass(digg(response, "model_data"))
|
|
54
52
|
|
|
55
|
-
let model
|
|
53
|
+
let model = response.model
|
|
56
54
|
|
|
57
|
-
if (
|
|
58
|
-
model = await args.loadQuery.clone().ransack({id_eq: modelInstance.id()}).first()
|
|
59
|
-
|
|
60
|
-
if (!model) throw new Error(`Couldn't read user with ID ${modelInstance.id()}`)
|
|
61
|
-
} else {
|
|
62
|
-
model = modelInstance
|
|
63
|
-
}
|
|
55
|
+
if (Array.isArray(model)) model = model[0]
|
|
64
56
|
|
|
65
57
|
await CanCan.current().resetAbilities()
|
|
66
58
|
|
package/src/serializer.cjs
CHANGED
|
@@ -38,6 +38,11 @@ module.exports = class Serializer {
|
|
|
38
38
|
}
|
|
39
39
|
} else if (Array.isArray(arg)) {
|
|
40
40
|
return this.serializeArray(arg)
|
|
41
|
+
} else if (typeof arg == "object" && arg.constructor.name == "ApiMakerCollection") {
|
|
42
|
+
return {
|
|
43
|
+
api_maker_type: "collection",
|
|
44
|
+
value: this.serializeObject(arg)
|
|
45
|
+
}
|
|
41
46
|
} else if (typeof arg == "object" && arg !== null && arg.constructor.name == "Object") {
|
|
42
47
|
return this.serializeObject(arg)
|
|
43
48
|
} else {
|