@kaspernj/api-maker 1.0.132 → 1.0.133

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 CHANGED
@@ -16,7 +16,7 @@
16
16
  ]
17
17
  },
18
18
  "name": "@kaspernj/api-maker",
19
- "version": "1.0.132",
19
+ "version": "1.0.133",
20
20
  "description": "",
21
21
  "main": "index.js",
22
22
  "repository": {
@@ -14,7 +14,7 @@ const {ValidationErrors} = require("./validation-errors.cjs")
14
14
 
15
15
  const shared = {}
16
16
 
17
- module.exports = class BaseModel {
17
+ class BaseModel {
18
18
  static modelClassData () {
19
19
  throw new Error("modelClassData should be overriden by child")
20
20
  }
@@ -825,3 +825,7 @@ module.exports = class BaseModel {
825
825
  }
826
826
  }
827
827
  }
828
+
829
+ BaseModel.apiMakerType = "BaseModel"
830
+
831
+ module.exports = BaseModel
@@ -5,7 +5,7 @@ const inflection = require("inflection")
5
5
  const {merge} = require("./merge.cjs")
6
6
  const Result = require("./result.cjs")
7
7
 
8
- module.exports = class ApiMakerCollection {
8
+ class ApiMakerCollection {
9
9
  constructor (args, queryArgs = {}) {
10
10
  this.queryArgs = queryArgs
11
11
  this.args = args
@@ -248,3 +248,7 @@ module.exports = class ApiMakerCollection {
248
248
  )
249
249
  }
250
250
  }
251
+
252
+ ApiMakerCollection.apiMakerType = "Collection"
253
+
254
+ module.exports = ApiMakerCollection
@@ -16,7 +16,7 @@ module.exports = class Serializer {
16
16
  }
17
17
 
18
18
  serializeArgument (arg) {
19
- if (typeof arg == "function" && arg.modelClassData && arg.modelName) {
19
+ if (typeof arg == "function" && arg.apiMakerType == "BaseModel") {
20
20
  return {
21
21
  api_maker_type: "resource",
22
22
  name: digg(arg.modelClassData(), "name")
@@ -38,7 +38,7 @@ 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") {
41
+ } else if (typeof arg == "object" && arg.constructor && arg.constructor.apiMakerType == "Collection") {
42
42
  return {
43
43
  api_maker_type: "collection",
44
44
  value: this.serializeObject(arg)