@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.
Files changed (58) hide show
  1. package/.eslintrc.js +39 -33
  2. package/__tests__/cable-connection-pool.test.js +4 -4
  3. package/__tests__/custom-error.test.js +13 -0
  4. package/__tests__/model-name.test.js +16 -10
  5. package/__tests__/routes-native.test.js +15 -33
  6. package/__tests__/support/task.js +5 -5
  7. package/__tests__/support/user.js +5 -5
  8. package/index.js +0 -4
  9. package/package.json +7 -6
  10. package/src/api.cjs +15 -15
  11. package/src/base-model.cjs +82 -81
  12. package/src/cable-connection-pool.cjs +11 -11
  13. package/src/cable-subscription-pool.cjs +34 -34
  14. package/src/cable-subscription.cjs +2 -2
  15. package/src/can-can-loader.jsx +7 -7
  16. package/src/can-can.cjs +17 -16
  17. package/src/collection.cjs +36 -36
  18. package/src/command-submit-data.cjs +10 -11
  19. package/src/commands-pool.cjs +13 -13
  20. package/src/custom-error.cjs +20 -14
  21. package/src/deserializer.cjs +7 -7
  22. package/src/devise.cjs +15 -15
  23. package/src/error-logger.cjs +9 -9
  24. package/src/event-connection.jsx +6 -6
  25. package/src/event-created.jsx +8 -8
  26. package/src/event-destroyed.jsx +6 -6
  27. package/src/event-emitter-listener.jsx +6 -6
  28. package/src/event-listener.jsx +8 -8
  29. package/src/event-model-class.jsx +6 -6
  30. package/src/event-updated.jsx +10 -10
  31. package/src/instance-of-class-name.cjs +5 -7
  32. package/src/key-value-store.cjs +21 -18
  33. package/src/logger.cjs +4 -4
  34. package/src/merge.cjs +4 -4
  35. package/src/model-events.cjs +6 -5
  36. package/src/model-name.cjs +6 -5
  37. package/src/model-prop-type.cjs +11 -13
  38. package/src/model-recipes-loader.cjs +4 -4
  39. package/src/model-recipes-model-loader.cjs +39 -14
  40. package/src/models-response-reader.cjs +10 -10
  41. package/src/money-formatter.cjs +11 -11
  42. package/src/params.cjs +7 -7
  43. package/src/preloaded.cjs +6 -6
  44. package/src/resource-route.cjs +14 -12
  45. package/src/resource-routes.jsx +9 -4
  46. package/src/result.cjs +7 -7
  47. package/src/routes-native.cjs +6 -6
  48. package/src/routes.cjs +1 -1
  49. package/src/serializer.cjs +9 -9
  50. package/src/services.cjs +3 -3
  51. package/src/session-status-updater.cjs +14 -14
  52. package/src/source-maps-loader.cjs +11 -11
  53. package/src/translated-collections.cjs +2 -1
  54. package/src/updated-attribute.jsx +17 -14
  55. package/src/validation-error.cjs +5 -8
  56. package/src/validation-errors.cjs +16 -16
  57. package/src/event-location-changed.jsx +0 -21
  58. package/src/history-listener.jsx +0 -20
package/src/api.cjs CHANGED
@@ -3,23 +3,23 @@ const FormDataObjectizer = require("form-data-objectizer")
3
3
  const qs = require("qs")
4
4
 
5
5
  module.exports = class Api {
6
- static get(path, pathParams = null) {
6
+ static get (path, pathParams = null) {
7
7
  return this.requestLocal({path, pathParams, method: "GET"})
8
8
  }
9
9
 
10
- static delete(path, pathParams = null) {
10
+ static delete (path, pathParams = null) {
11
11
  return this.requestLocal({path, pathParams, method: "DELETE"})
12
12
  }
13
13
 
14
- static patch(path, data = {}) {
14
+ static patch (path, data = {}) {
15
15
  return this.requestLocal({path, data, method: "PATCH"})
16
16
  }
17
17
 
18
- static post(path, data = {}) {
18
+ static post (path, data = {}) {
19
19
  return this.requestLocal({path, data, method: "POST"})
20
20
  }
21
21
 
22
- static request(args) {
22
+ static request (args) {
23
23
  let path = args.path
24
24
 
25
25
  if (args.pathParams) {
@@ -32,7 +32,7 @@ module.exports = class Api {
32
32
  xhr.open(args.method, path, true)
33
33
 
34
34
  if (args.headers) {
35
- for(const headerName in args.headers) {
35
+ for (const headerName in args.headers) {
36
36
  xhr.setRequestHeader(headerName, args.headers[headerName])
37
37
  }
38
38
  }
@@ -59,41 +59,41 @@ module.exports = class Api {
59
59
  })
60
60
  }
61
61
 
62
- static requestLocal(args) {
62
+ static requestLocal (args) {
63
63
  if (!args.headers) {
64
- args["headers"] = {}
64
+ args.headers = {}
65
65
  }
66
66
 
67
67
  const token = this._token()
68
68
 
69
69
  if (token) {
70
- args["headers"]["X-CSRF-Token"] = token
70
+ args.headers["X-CSRF-Token"] = token
71
71
  }
72
72
 
73
73
  if (args.data) {
74
- args["headers"]["Content-Type"] = "application/json"
75
- args["data"] = JSON.stringify(args.data)
74
+ args.headers["Content-Type"] = "application/json"
75
+ args.data = JSON.stringify(args.data)
76
76
  }
77
77
 
78
78
  if (args.rawData) {
79
- args["data"] = args.rawData
79
+ args.data = args.rawData
80
80
  }
81
81
 
82
82
  return this.request(args)
83
83
  }
84
84
 
85
- static put(path, data = {}) {
85
+ static put (path, data = {}) {
86
86
  return this.requestLocal({path, data, method: "PUT"})
87
87
  }
88
88
 
89
- static _token() {
89
+ static _token () {
90
90
  const tokenElement = document.querySelector("meta[name='csrf-token']")
91
91
 
92
92
  if (tokenElement)
93
93
  return tokenElement.getAttribute("content")
94
94
  }
95
95
 
96
- static _parseResponse(xhr) {
96
+ static _parseResponse (xhr) {
97
97
  const responseType = xhr.getResponseHeader("content-type")
98
98
 
99
99
  if (responseType && responseType.startsWith("application/json")) {
@@ -16,11 +16,11 @@ const {ValidationErrors} = require("./validation-errors.cjs")
16
16
  const shared = {}
17
17
 
18
18
  module.exports = class BaseModel {
19
- static modelClassData() {
19
+ static modelClassData () {
20
20
  throw new Error("modelClassData should be overriden by child")
21
21
  }
22
22
 
23
- static async find(id) {
23
+ static async find (id) {
24
24
  const primaryKeyName = this.modelClassData().primaryKey
25
25
  const query = {}
26
26
  query[`${primaryKeyName}_eq`] = id
@@ -34,30 +34,30 @@ module.exports = class BaseModel {
34
34
  }
35
35
  }
36
36
 
37
- static async findOrCreateBy(findOrCreateByArgs, args = {}) {
37
+ static async findOrCreateBy (findOrCreateByArgs, args = {}) {
38
38
  const result = await Services.current().sendRequest("Models::FindOrCreateBy", {
39
39
  additional_data: args.additionalData,
40
40
  find_or_create_by_args: findOrCreateByArgs,
41
- resource_name: digg(this.modelClassData(), "name"),
41
+ resource_name: digg(this.modelClassData(), "name")
42
42
  })
43
43
  const model = digg(result, "model")
44
44
 
45
45
  return model
46
46
  }
47
47
 
48
- static modelName() {
48
+ static modelName () {
49
49
  return new ModelName({i18n: shared.i18n, modelClassData: this.modelClassData()})
50
50
  }
51
51
 
52
- static ransack(query = {}) {
52
+ static ransack (query = {}) {
53
53
  return new Collection({modelClass: this}, {ransack: query})
54
54
  }
55
55
 
56
- static setI18n(i18n) {
56
+ static setI18n (i18n) {
57
57
  shared.i18n = i18n
58
58
  }
59
59
 
60
- constructor(args = {}) {
60
+ constructor (args = {}) {
61
61
  this.changes = {}
62
62
  this.newRecord = args.isNewRecord
63
63
  this.relationshipsCache = {}
@@ -76,8 +76,8 @@ module.exports = class BaseModel {
76
76
  }
77
77
  }
78
78
 
79
- assignAttributes(newAttributes) {
80
- for(const key in newAttributes) {
79
+ assignAttributes (newAttributes) {
80
+ for (const key in newAttributes) {
81
81
  const newValue = newAttributes[key]
82
82
 
83
83
  let applyChange = true
@@ -103,11 +103,11 @@ module.exports = class BaseModel {
103
103
  }
104
104
  }
105
105
 
106
- attributes() {
106
+ attributes () {
107
107
  return digg(this, "modelData")
108
108
  }
109
109
 
110
- can(givenAbilityName) {
110
+ can (givenAbilityName) {
111
111
  const abilityName = inflection.underscore(givenAbilityName)
112
112
 
113
113
  if (!(abilityName in this.abilities)) {
@@ -117,17 +117,17 @@ module.exports = class BaseModel {
117
117
  return this.abilities[abilityName]
118
118
  }
119
119
 
120
- clone() {
121
- const clone = new this.constructor
120
+ clone () {
121
+ const clone = new this.constructor()
122
122
 
123
- clone.abilities = Object.assign({}, this.abilities)
124
- clone.modelData = Object.assign({}, this.modelData)
125
- clone.relationshipsCache = Object.assign({}, this.relationshipsCache)
123
+ clone.abilities = {...this.abilities}
124
+ clone.modelData = {...this.modelData}
125
+ clone.relationshipsCache = {...this.relationshipsCache}
126
126
 
127
127
  return clone
128
128
  }
129
129
 
130
- cacheKey() {
130
+ cacheKey () {
131
131
  if (this.isPersisted()) {
132
132
  const keyParts = [
133
133
  this.modelClassData().paramKey,
@@ -152,11 +152,11 @@ module.exports = class BaseModel {
152
152
  }
153
153
  }
154
154
 
155
- static all() {
155
+ static all () {
156
156
  return this.ransack()
157
157
  }
158
158
 
159
- async create(attributes, options) {
159
+ async create (attributes, options) {
160
160
  if (attributes) this.assignAttributes(attributes)
161
161
  const paramKey = this.modelClassData().paramKey
162
162
  const modelData = this.getAttributes()
@@ -190,7 +190,7 @@ module.exports = class BaseModel {
190
190
  return {model: this, response}
191
191
  }
192
192
 
193
- async createRaw(rawData, options = {}) {
193
+ async createRaw (rawData, options = {}) {
194
194
  const objectData = this._objectDataFromGivenRawData(rawData, options)
195
195
 
196
196
  let response
@@ -204,7 +204,8 @@ module.exports = class BaseModel {
204
204
  command: `${this.modelClassData().collectionName}-create`,
205
205
  collectionName: this.modelClassData().collectionName,
206
206
  primaryKey: this.primaryKey(),
207
- type: "create"},
207
+ type: "create"
208
+ },
208
209
  {}
209
210
  )
210
211
  } catch (error) {
@@ -220,7 +221,7 @@ module.exports = class BaseModel {
220
221
  return {model: this, response}
221
222
  }
222
223
 
223
- async destroy() {
224
+ async destroy () {
224
225
  const response = await CommandsPool.addCommand(
225
226
  {
226
227
  args: {query_params: this.collection && this.collection.params()},
@@ -240,11 +241,11 @@ module.exports = class BaseModel {
240
241
 
241
242
  return {model: this, response}
242
243
  } else {
243
- handleResponseError(response)
244
+ this.handleResponseError(response)
244
245
  }
245
246
  }
246
247
 
247
- async ensureAbilities(listOfAbilities) {
248
+ async ensureAbilities (listOfAbilities) {
248
249
  // Populate an array with a list of abilities currently not loaded
249
250
  const abilitiesToLoad = []
250
251
 
@@ -279,27 +280,27 @@ module.exports = class BaseModel {
279
280
  }
280
281
  }
281
282
 
282
- getAttributes() {
283
+ getAttributes () {
283
284
  return Object.assign(this.modelData, this.changes)
284
285
  }
285
286
 
286
- handleResponseError(response) {
287
+ handleResponseError (response) {
287
288
  this.parseValidationErrors(response)
288
289
  throw new new CustomError("Response wasn't successful", {model: this, response})
289
290
  }
290
291
 
291
- identifierKey() {
292
+ identifierKey () {
292
293
  if (!this._identifierKey) this._identifierKey = this.isPersisted() ? this.primaryKey() : this.uniqueKey()
293
294
 
294
295
  return this._identifierKey
295
296
  }
296
297
 
297
- isAssociationLoaded(associationName) {
298
+ isAssociationLoaded (associationName) {
298
299
  if (associationName in this.relationshipsCache) return true
299
300
  return false
300
301
  }
301
302
 
302
- parseValidationErrors(error, options) {
303
+ parseValidationErrors (error, options) {
303
304
  if (!(error instanceof CustomError)) return
304
305
  if (!error.args.response.validation_errors) return
305
306
 
@@ -315,24 +316,24 @@ module.exports = class BaseModel {
315
316
  }
316
317
  }
317
318
 
318
- sendValidationErrorsEvent(validationErrors, options) {
319
+ sendValidationErrorsEvent (validationErrors, options) {
319
320
  if (options && options.form) {
320
321
  const event = this.newCustomEvent(validationErrors)
321
322
  options.form.dispatchEvent(event)
322
323
  }
323
324
  }
324
325
 
325
- newCustomEvent(validationErrors) {
326
+ newCustomEvent (validationErrors) {
326
327
  return new CustomEvent("validation-errors", {detail: validationErrors})
327
328
  }
328
329
 
329
- static humanAttributeName(attributeName) {
330
+ static humanAttributeName (attributeName) {
330
331
  const keyName = digg(this.modelClassData(), "i18nKey")
331
332
 
332
333
  return shared.i18n.t(`activerecord.attributes.${keyName}.${BaseModel.snakeCase(attributeName)}`, {defaultValue: attributeName})
333
334
  }
334
335
 
335
- isAttributeChanged(attributeName) {
336
+ isAttributeChanged (attributeName) {
336
337
  const attributeNameUnderscore = inflection.underscore(attributeName)
337
338
  const attributeData = this.modelClassData().attributes.find((attribute) => digg(attribute, "name") == attributeNameUnderscore)
338
339
 
@@ -355,7 +356,7 @@ module.exports = class BaseModel {
355
356
  return changedMethod(oldValue, newValue)
356
357
  }
357
358
 
358
- isChanged() {
359
+ isChanged () {
359
360
  const keys = Object.keys(this.changes)
360
361
 
361
362
  if (keys.length > 0) {
@@ -365,7 +366,7 @@ module.exports = class BaseModel {
365
366
  }
366
367
  }
367
368
 
368
- isNewRecord() {
369
+ isNewRecord () {
369
370
  if (this.newRecord === false) {
370
371
  return false
371
372
  } else if ("id" in this.modelData && this.modelData.id) {
@@ -375,23 +376,23 @@ module.exports = class BaseModel {
375
376
  }
376
377
  }
377
378
 
378
- isPersisted() {
379
+ isPersisted () {
379
380
  return !this.isNewRecord()
380
381
  }
381
382
 
382
- static snakeCase(string) {
383
+ static snakeCase (string) {
383
384
  return inflection.underscore(string)
384
385
  }
385
386
 
386
- savedChangeToAttribute(attributeName) {
387
+ savedChangeToAttribute (attributeName) {
387
388
  if (!this.previousModelData)
388
389
  return false
389
390
 
390
391
  const attributeNameUnderscore = inflection.underscore(attributeName)
391
- const attributeData = this.modelClassData().attributes.find(attribute => attribute.name == attributeNameUnderscore)
392
+ const attributeData = this.modelClassData().attributes.find((attribute) => attribute.name == attributeNameUnderscore)
392
393
 
393
394
  if (!attributeData) {
394
- const attributeNames = this.modelClassData().attributes.map(attribute => attribute.name)
395
+ const attributeNames = this.modelClassData().attributes.map((attribute) => attribute.name)
395
396
  throw new Error(`Couldn't find an attribute by that name: "${attributeName}" in: ${attributeNames.join(", ")}`)
396
397
  }
397
398
 
@@ -409,27 +410,27 @@ module.exports = class BaseModel {
409
410
  return changedMethod(oldValue, newValue)
410
411
  }
411
412
 
412
- setNewModel(model) {
413
+ setNewModel (model) {
413
414
  this.setNewModelData(model)
414
415
  this.relationshipsCache = digg(model, "relationshipsCache")
415
416
  }
416
417
 
417
- setNewModelData(model) {
418
+ setNewModelData (model) {
418
419
  this.previousModelData = digg(this, "modelData")
419
420
  this.modelData = digg(model, "modelData")
420
421
  }
421
422
 
422
- _isDateChanged(oldValue, newValue) {
423
+ _isDateChanged (oldValue, newValue) {
423
424
  if (Date.parse(oldValue) != Date.parse(newValue))
424
425
  return true
425
426
  }
426
427
 
427
- _isIntegerChanged(oldValue, newValue) {
428
- if (parseInt(oldValue) != parseInt(newValue))
428
+ _isIntegerChanged (oldValue, newValue) {
429
+ if (parseInt(oldValue, 10) != parseInt(newValue, 10))
429
430
  return true
430
431
  }
431
432
 
432
- _isStringChanged(oldValue, newValue) {
433
+ _isStringChanged (oldValue, newValue) {
433
434
  const oldConvertedValue = `${oldValue}`
434
435
  const newConvertedValue = `${newValue}`
435
436
 
@@ -437,11 +438,11 @@ module.exports = class BaseModel {
437
438
  return true
438
439
  }
439
440
 
440
- modelClassData() {
441
+ modelClassData () {
441
442
  return this.constructor.modelClassData()
442
443
  }
443
444
 
444
- async reload() {
445
+ async reload () {
445
446
  const params = this.collection && this.collection.params()
446
447
  const primaryKeyName = this.modelClassData().primaryKey
447
448
  const ransackParams = {}
@@ -468,7 +469,7 @@ module.exports = class BaseModel {
468
469
  this.changes = {}
469
470
  }
470
471
 
471
- save() {
472
+ save () {
472
473
  if (this.isNewRecord()) {
473
474
  return this.create()
474
475
  } else {
@@ -476,7 +477,7 @@ module.exports = class BaseModel {
476
477
  }
477
478
  }
478
479
 
479
- saveRaw(rawData, options = {}) {
480
+ saveRaw (rawData, options = {}) {
480
481
  if (this.isNewRecord()) {
481
482
  return this.createRaw(rawData, options)
482
483
  } else {
@@ -484,7 +485,7 @@ module.exports = class BaseModel {
484
485
  }
485
486
  }
486
487
 
487
- async update(newAttributes, options) {
488
+ async update (newAttributes, options) {
488
489
  if (newAttributes)
489
490
  this.assignAttributes(newAttributes)
490
491
 
@@ -525,21 +526,21 @@ module.exports = class BaseModel {
525
526
 
526
527
  return {response, model: this}
527
528
  } else {
528
- handleResponseError(response)
529
+ this.handleResponseError(response)
529
530
  }
530
531
  }
531
532
 
532
- _refreshModelFromResponse(response) {
533
+ _refreshModelFromResponse (response) {
533
534
  const newModel = ModelsResponseReader.first(digg(response, "model"))
534
535
  this.setNewModel(newModel)
535
536
  }
536
537
 
537
- _refreshModelDataFromResponse(response) {
538
+ _refreshModelDataFromResponse (response) {
538
539
  const newModel = ModelsResponseReader.first(digg(response, "model"))
539
540
  this.setNewModelData(newModel)
540
541
  }
541
542
 
542
- _objectDataFromGivenRawData(rawData, options) {
543
+ _objectDataFromGivenRawData (rawData, options) {
543
544
  if (rawData instanceof FormData || rawData.nodeName == "FORM") {
544
545
  const formData = FormDataObjectizer.formDataFromObject(rawData, options)
545
546
 
@@ -549,7 +550,7 @@ module.exports = class BaseModel {
549
550
  return rawData
550
551
  }
551
552
 
552
- async updateRaw(rawData, options = {}) {
553
+ async updateRaw (rawData, options = {}) {
553
554
  const objectData = this._objectDataFromGivenRawData(rawData, options)
554
555
 
555
556
  let response
@@ -581,11 +582,11 @@ module.exports = class BaseModel {
581
582
  return {response, model: this}
582
583
  }
583
584
 
584
- isValid() {
585
+ isValid () {
585
586
  throw new Error("Not implemented yet")
586
587
  }
587
588
 
588
- async isValidOnServer() {
589
+ async isValidOnServer () {
589
590
  const modelData = this.getAttributes()
590
591
  const paramKey = this.modelClassData().paramKey
591
592
  const dataToUse = {}
@@ -607,18 +608,18 @@ module.exports = class BaseModel {
607
608
  return {valid: response.valid, errors: response.errors}
608
609
  }
609
610
 
610
- modelClass() {
611
+ modelClass () {
611
612
  return this.constructor
612
613
  }
613
614
 
614
- preloadRelationship(relationshipName, model) {
615
+ preloadRelationship (relationshipName, model) {
615
616
  this.relationshipsCache[BaseModel.snakeCase(relationshipName)] = model
616
617
  }
617
618
 
618
- uniqueKey() {
619
+ uniqueKey () {
619
620
  if (!this.uniqueKeyValue) {
620
- const min = 500000000000000000
621
- const max = 999999999999999999
621
+ const min = 5000000000000000
622
+ const max = 9007199254740991
622
623
  const randomBetween = Math.floor(Math.random() * (max - min + 1) + min)
623
624
  this.uniqueKeyValue = randomBetween
624
625
  }
@@ -626,15 +627,15 @@ module.exports = class BaseModel {
626
627
  return this.uniqueKeyValue
627
628
  }
628
629
 
629
- static _callCollectionCommand(args, commandArgs) {
630
+ static _callCollectionCommand (args, commandArgs) {
630
631
  return CommandsPool.addCommand(args, commandArgs)
631
632
  }
632
633
 
633
- _callMemberCommand(args, commandArgs) {
634
+ _callMemberCommand (args, commandArgs) {
634
635
  return CommandsPool.addCommand(args, commandArgs)
635
636
  }
636
637
 
637
- static _postDataFromArgs(args) {
638
+ static _postDataFromArgs (args) {
638
639
  let postData
639
640
 
640
641
  if (args) {
@@ -650,13 +651,13 @@ module.exports = class BaseModel {
650
651
  return postData
651
652
  }
652
653
 
653
- readAttribute(attributeName) {
654
+ readAttribute (attributeName) {
654
655
  const attributeNameUnderscore = inflection.underscore(attributeName)
655
656
 
656
657
  return this.readAttributeUnderscore(attributeNameUnderscore)
657
658
  }
658
659
 
659
- readAttributeUnderscore(attributeName) {
660
+ readAttributeUnderscore (attributeName) {
660
661
  if (attributeName in this.changes) {
661
662
  return this.changes[attributeName]
662
663
  } else if (attributeName in this.modelData) {
@@ -671,7 +672,7 @@ module.exports = class BaseModel {
671
672
  throw new AttributeNotLoadedError(`No such attribute: ${digg(this.modelClassData(), "name")}#${attributeName}`)
672
673
  }
673
674
 
674
- isAttributeLoaded(attributeName) {
675
+ isAttributeLoaded (attributeName) {
675
676
  const attributeNameUnderscore = inflection.underscore(attributeName)
676
677
 
677
678
  if (attributeNameUnderscore in this.changes) return true
@@ -679,7 +680,7 @@ module.exports = class BaseModel {
679
680
  return false
680
681
  }
681
682
 
682
- _isPresent(value) {
683
+ _isPresent (value) {
683
684
  if (!value) {
684
685
  return false
685
686
  } else if (typeof value == "string" && value.match(/^\s*$/)) {
@@ -689,7 +690,7 @@ module.exports = class BaseModel {
689
690
  return true
690
691
  }
691
692
 
692
- async _loadBelongsToReflection(args, queryArgs = {}) {
693
+ async _loadBelongsToReflection (args, queryArgs = {}) {
693
694
  if (args.reflectionName in this.relationshipsCache) {
694
695
  return this.relationshipsCache[args.reflectionName]
695
696
  } else {
@@ -700,7 +701,7 @@ module.exports = class BaseModel {
700
701
  }
701
702
  }
702
703
 
703
- _readBelongsToReflection({reflectionName}) {
704
+ _readBelongsToReflection ({reflectionName}) {
704
705
  if (!(reflectionName in this.relationshipsCache)) {
705
706
  if (this.isNewRecord())
706
707
  return null
@@ -714,7 +715,7 @@ module.exports = class BaseModel {
714
715
  return this.relationshipsCache[reflectionName]
715
716
  }
716
717
 
717
- async _loadHasManyReflection(args, queryArgs = {}) {
718
+ async _loadHasManyReflection (args, queryArgs = {}) {
718
719
  if (args.reflectionName in this.relationshipsCache) {
719
720
  return this.relationshipsCache[args.reflectionName]
720
721
  }
@@ -727,7 +728,7 @@ module.exports = class BaseModel {
727
728
  return models
728
729
  }
729
730
 
730
- async _loadHasOneReflection(args, queryArgs = {}) {
731
+ async _loadHasOneReflection (args, queryArgs = {}) {
731
732
  if (args.reflectionName in this.relationshipsCache) {
732
733
  return this.relationshipsCache[args.reflectionName]
733
734
  } else {
@@ -740,7 +741,7 @@ module.exports = class BaseModel {
740
741
  }
741
742
  }
742
743
 
743
- _readHasOneReflection({reflectionName}) {
744
+ _readHasOneReflection ({reflectionName}) {
744
745
  if (!(reflectionName in this.relationshipsCache)) {
745
746
  if (this.isNewRecord())
746
747
  return null
@@ -754,14 +755,14 @@ module.exports = class BaseModel {
754
755
  return this.relationshipsCache[reflectionName]
755
756
  }
756
757
 
757
- _readModelDataFromArgs(args) {
758
+ _readModelDataFromArgs (args) {
758
759
  this.abilities = args.data.b || {}
759
760
  this.collection = args.collection
760
761
  this.modelData = args.data.a
761
762
  this.preloadedRelationships = args.data.r
762
763
  }
763
764
 
764
- _readPreloadedRelationships(preloaded) {
765
+ _readPreloadedRelationships (preloaded) {
765
766
  if (!this.preloadedRelationships) {
766
767
  return
767
768
  }
@@ -791,7 +792,7 @@ module.exports = class BaseModel {
791
792
  } else if (Array.isArray(relationshipData)) {
792
793
  const result = []
793
794
 
794
- for(const relationshipId of relationshipData) {
795
+ for (const relationshipId of relationshipData) {
795
796
  const model = preloaded.getModel(relationshipType, relationshipId)
796
797
 
797
798
  result.push(model)
@@ -805,11 +806,11 @@ module.exports = class BaseModel {
805
806
  }
806
807
  }
807
808
 
808
- primaryKey() {
809
+ primaryKey () {
809
810
  return this.readAttributeUnderscore(digg(this.modelClassData(), "primaryKey"))
810
811
  }
811
812
 
812
- static _token() {
813
+ static _token () {
813
814
  const csrfTokenElement = document.querySelector("meta[name='csrf-token']")
814
815
 
815
816
  if (csrfTokenElement) {