@kaspernj/api-maker 1.0.285 → 1.0.287

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.285",
19
+ "version": "1.0.287",
20
20
  "type": "module",
21
21
  "description": "",
22
22
  "main": "index.js",
@@ -74,7 +74,7 @@
74
74
  "eslint-find-rules": "^4.0.0",
75
75
  "eslint-plugin-jest": "^27.0.1",
76
76
  "eslint-plugin-react": "^7.23.2",
77
- "i18n-on-steroids": "^1.0.5",
77
+ "i18n-on-steroids": "^1.0.7",
78
78
  "jest": "^29.0.1",
79
79
  "jsdom": "^22.0.0"
80
80
  }
@@ -39,13 +39,24 @@ export default class CacheKeyGenerator {
39
39
  for (const relationshipType in model.relationships) {
40
40
  this.recordModelType(relationshipType)
41
41
 
42
- for (const anotherModel of model.relationships[relationshipType]) {
43
- if (this.isModelRecorded(relationshipType, anotherModel)) {
42
+ const loadedRelationship = model.relationships[relationshipType]
43
+
44
+ if (Array.isArray(loadedRelationship)) { // has_many
45
+ for (const anotherModel of loadedRelationship) {
46
+ if (this.isModelRecorded(relationshipType, anotherModel)) {
47
+ continue
48
+ }
49
+
50
+ this.recordModel(relationshipType, anotherModel)
51
+ this.fillModels(anotherModel)
52
+ }
53
+ } else if (loadedRelationship) { // belongs_to, has_one
54
+ if (this.isModelRecorded(relationshipType, loadedRelationship)) {
44
55
  continue
45
56
  }
46
57
 
47
- this.recordModel(relationshipType, anotherModel)
48
- this.fillModels(anotherModel)
58
+ this.recordModel(relationshipType, loadedRelationship)
59
+ this.fillModels(loadedRelationship)
49
60
  }
50
61
  }
51
62
 
@@ -33,8 +33,10 @@ export default class ApiMakerRoutesNative {
33
33
 
34
34
  if (variableMatch) {
35
35
  localizedPathParts.push({type: "variable", count: variableCount++})
36
- } else {
37
- localizedPathParts.push({type: "pathPart", name: dig(this.routeTranslationParts, locale, pathPart) || pathPart})
36
+ } else if (pathPart) {
37
+ const name = this.i18n.t(`routes.${pathPart}`, null, {default: pathPart, locale})
38
+
39
+ localizedPathParts.push({type: "pathPart", name})
38
40
  }
39
41
  }
40
42
 
@@ -63,6 +65,7 @@ export default class ApiMakerRoutesNative {
63
65
  }
64
66
 
65
67
  loadRouteTranslations (i18n) {
68
+ this.i18n = i18n
66
69
  const locales = digg(i18n, "locales")
67
70
 
68
71
  for (const locale in locales) {