@carlonicora/nextjs-jsonapi 1.1.1 → 1.3.0

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 (230) hide show
  1. package/dist/{BlockNoteEditor-6NVBI7XL.js → BlockNoteEditor-CNXQ3WL3.js} +7 -7
  2. package/dist/{BlockNoteEditor-6NVBI7XL.js.map → BlockNoteEditor-CNXQ3WL3.js.map} +1 -1
  3. package/dist/{BlockNoteEditor-4VOBTXWC.mjs → BlockNoteEditor-DC33K4IF.mjs} +3 -3
  4. package/dist/{chunk-KPRHIJO6.js → chunk-KDFDGXCX.js} +53 -53
  5. package/dist/{chunk-KPRHIJO6.js.map → chunk-KDFDGXCX.js.map} +1 -1
  6. package/dist/{chunk-FYRFMABS.js → chunk-L6LH7WA4.js} +21 -2
  7. package/dist/chunk-L6LH7WA4.js.map +1 -0
  8. package/dist/{chunk-MA2L2PL2.mjs → chunk-MHVXFWZY.mjs} +20 -1
  9. package/dist/chunk-MHVXFWZY.mjs.map +1 -0
  10. package/dist/{chunk-HP4Q5ZVG.mjs → chunk-Y4XI3AZR.mjs} +3 -3
  11. package/dist/client/index.js +3 -3
  12. package/dist/client/index.mjs +2 -2
  13. package/dist/components/index.js +3 -3
  14. package/dist/components/index.mjs +2 -2
  15. package/dist/contexts/index.js +3 -3
  16. package/dist/contexts/index.mjs +2 -2
  17. package/dist/features/index.d.mts +3 -1
  18. package/dist/features/index.d.ts +3 -1
  19. package/dist/features/index.js +4 -2
  20. package/dist/features/index.js.map +1 -1
  21. package/dist/features/index.mjs +3 -1
  22. package/dist/hooks/index.js +3 -3
  23. package/dist/hooks/index.mjs +2 -2
  24. package/dist/scripts/generate-web-module/generator.d.ts +15 -0
  25. package/dist/scripts/generate-web-module/generator.d.ts.map +1 -0
  26. package/dist/scripts/generate-web-module/generator.js +320 -0
  27. package/dist/scripts/generate-web-module/generator.js.map +1 -0
  28. package/dist/scripts/generate-web-module/index.d.ts +16 -0
  29. package/dist/scripts/generate-web-module/index.d.ts.map +1 -0
  30. package/dist/scripts/generate-web-module/index.js +80 -0
  31. package/dist/scripts/generate-web-module/index.js.map +1 -0
  32. package/dist/scripts/generate-web-module/templates/components/container.template.d.ts +14 -0
  33. package/dist/scripts/generate-web-module/templates/components/container.template.d.ts.map +1 -0
  34. package/dist/scripts/generate-web-module/templates/components/container.template.js +124 -0
  35. package/dist/scripts/generate-web-module/templates/components/container.template.js.map +1 -0
  36. package/dist/scripts/generate-web-module/templates/components/content.template.d.ts +15 -0
  37. package/dist/scripts/generate-web-module/templates/components/content.template.d.ts.map +1 -0
  38. package/dist/scripts/generate-web-module/templates/components/content.template.js +39 -0
  39. package/dist/scripts/generate-web-module/templates/components/content.template.js.map +1 -0
  40. package/dist/scripts/generate-web-module/templates/components/deleter.template.d.ts +14 -0
  41. package/dist/scripts/generate-web-module/templates/components/deleter.template.d.ts.map +1 -0
  42. package/dist/scripts/generate-web-module/templates/components/deleter.template.js +51 -0
  43. package/dist/scripts/generate-web-module/templates/components/deleter.template.js.map +1 -0
  44. package/dist/scripts/generate-web-module/templates/components/details.template.d.ts +14 -0
  45. package/dist/scripts/generate-web-module/templates/components/details.template.d.ts.map +1 -0
  46. package/dist/scripts/generate-web-module/templates/components/details.template.js +109 -0
  47. package/dist/scripts/generate-web-module/templates/components/details.template.js.map +1 -0
  48. package/dist/scripts/generate-web-module/templates/components/editor.template.d.ts +14 -0
  49. package/dist/scripts/generate-web-module/templates/components/editor.template.d.ts.map +1 -0
  50. package/dist/scripts/generate-web-module/templates/components/editor.template.js +459 -0
  51. package/dist/scripts/generate-web-module/templates/components/editor.template.js.map +1 -0
  52. package/dist/scripts/generate-web-module/templates/components/index.d.ts +15 -0
  53. package/dist/scripts/generate-web-module/templates/components/index.d.ts.map +1 -0
  54. package/dist/scripts/generate-web-module/templates/components/index.js +29 -0
  55. package/dist/scripts/generate-web-module/templates/components/index.js.map +1 -0
  56. package/dist/scripts/generate-web-module/templates/components/list-container.template.d.ts +14 -0
  57. package/dist/scripts/generate-web-module/templates/components/list-container.template.d.ts.map +1 -0
  58. package/dist/scripts/generate-web-module/templates/components/list-container.template.js +30 -0
  59. package/dist/scripts/generate-web-module/templates/components/list-container.template.js.map +1 -0
  60. package/dist/scripts/generate-web-module/templates/components/list.template.d.ts +14 -0
  61. package/dist/scripts/generate-web-module/templates/components/list.template.d.ts.map +1 -0
  62. package/dist/scripts/generate-web-module/templates/components/list.template.js +84 -0
  63. package/dist/scripts/generate-web-module/templates/components/list.template.js.map +1 -0
  64. package/dist/scripts/generate-web-module/templates/components/multi-selector.template.d.ts +14 -0
  65. package/dist/scripts/generate-web-module/templates/components/multi-selector.template.d.ts.map +1 -0
  66. package/dist/scripts/generate-web-module/templates/components/multi-selector.template.js +184 -0
  67. package/dist/scripts/generate-web-module/templates/components/multi-selector.template.js.map +1 -0
  68. package/dist/scripts/generate-web-module/templates/components/selector.template.d.ts +14 -0
  69. package/dist/scripts/generate-web-module/templates/components/selector.template.d.ts.map +1 -0
  70. package/dist/scripts/generate-web-module/templates/components/selector.template.js +199 -0
  71. package/dist/scripts/generate-web-module/templates/components/selector.template.js.map +1 -0
  72. package/dist/scripts/generate-web-module/templates/context.template.d.ts +14 -0
  73. package/dist/scripts/generate-web-module/templates/context.template.d.ts.map +1 -0
  74. package/dist/scripts/generate-web-module/templates/context.template.js +121 -0
  75. package/dist/scripts/generate-web-module/templates/context.template.js.map +1 -0
  76. package/dist/scripts/generate-web-module/templates/data/fields.template.d.ts +14 -0
  77. package/dist/scripts/generate-web-module/templates/data/fields.template.d.ts.map +1 -0
  78. package/dist/scripts/generate-web-module/templates/data/fields.template.js +55 -0
  79. package/dist/scripts/generate-web-module/templates/data/fields.template.js.map +1 -0
  80. package/dist/scripts/generate-web-module/templates/data/index.d.ts +10 -0
  81. package/dist/scripts/generate-web-module/templates/data/index.d.ts.map +1 -0
  82. package/dist/scripts/generate-web-module/templates/data/index.js +26 -0
  83. package/dist/scripts/generate-web-module/templates/data/index.js.map +1 -0
  84. package/dist/scripts/generate-web-module/templates/data/interface.template.d.ts +14 -0
  85. package/dist/scripts/generate-web-module/templates/data/interface.template.d.ts.map +1 -0
  86. package/dist/scripts/generate-web-module/templates/data/interface.template.js +116 -0
  87. package/dist/scripts/generate-web-module/templates/data/interface.template.js.map +1 -0
  88. package/dist/scripts/generate-web-module/templates/data/model.template.d.ts +14 -0
  89. package/dist/scripts/generate-web-module/templates/data/model.template.d.ts.map +1 -0
  90. package/dist/scripts/generate-web-module/templates/data/model.template.js +274 -0
  91. package/dist/scripts/generate-web-module/templates/data/model.template.js.map +1 -0
  92. package/dist/scripts/generate-web-module/templates/data/service.template.d.ts +14 -0
  93. package/dist/scripts/generate-web-module/templates/data/service.template.d.ts.map +1 -0
  94. package/dist/scripts/generate-web-module/templates/data/service.template.js +168 -0
  95. package/dist/scripts/generate-web-module/templates/data/service.template.js.map +1 -0
  96. package/dist/scripts/generate-web-module/templates/index.d.ts +12 -0
  97. package/dist/scripts/generate-web-module/templates/index.d.ts.map +1 -0
  98. package/dist/scripts/generate-web-module/templates/index.js +37 -0
  99. package/dist/scripts/generate-web-module/templates/index.js.map +1 -0
  100. package/dist/scripts/generate-web-module/templates/module.template.d.ts +14 -0
  101. package/dist/scripts/generate-web-module/templates/module.template.d.ts.map +1 -0
  102. package/dist/scripts/generate-web-module/templates/module.template.js +64 -0
  103. package/dist/scripts/generate-web-module/templates/module.template.js.map +1 -0
  104. package/dist/scripts/generate-web-module/templates/pages/detail-page.template.d.ts +14 -0
  105. package/dist/scripts/generate-web-module/templates/pages/detail-page.template.d.ts.map +1 -0
  106. package/dist/scripts/generate-web-module/templates/pages/detail-page.template.js +65 -0
  107. package/dist/scripts/generate-web-module/templates/pages/detail-page.template.js.map +1 -0
  108. package/dist/scripts/generate-web-module/templates/pages/index.d.ts +8 -0
  109. package/dist/scripts/generate-web-module/templates/pages/index.d.ts.map +1 -0
  110. package/dist/scripts/generate-web-module/templates/pages/index.js +13 -0
  111. package/dist/scripts/generate-web-module/templates/pages/index.js.map +1 -0
  112. package/dist/scripts/generate-web-module/templates/pages/list-page.template.d.ts +14 -0
  113. package/dist/scripts/generate-web-module/templates/pages/list-page.template.d.ts.map +1 -0
  114. package/dist/scripts/generate-web-module/templates/pages/list-page.template.js +37 -0
  115. package/dist/scripts/generate-web-module/templates/pages/list-page.template.js.map +1 -0
  116. package/dist/scripts/generate-web-module/templates/table-hook.template.d.ts +14 -0
  117. package/dist/scripts/generate-web-module/templates/table-hook.template.d.ts.map +1 -0
  118. package/dist/scripts/generate-web-module/templates/table-hook.template.js +174 -0
  119. package/dist/scripts/generate-web-module/templates/table-hook.template.js.map +1 -0
  120. package/dist/scripts/generate-web-module/transformers/field-mapper.d.ts +55 -0
  121. package/dist/scripts/generate-web-module/transformers/field-mapper.d.ts.map +1 -0
  122. package/dist/scripts/generate-web-module/transformers/field-mapper.js +179 -0
  123. package/dist/scripts/generate-web-module/transformers/field-mapper.js.map +1 -0
  124. package/dist/scripts/generate-web-module/transformers/i18n-generator.d.ts +78 -0
  125. package/dist/scripts/generate-web-module/transformers/i18n-generator.d.ts.map +1 -0
  126. package/dist/scripts/generate-web-module/transformers/i18n-generator.js +182 -0
  127. package/dist/scripts/generate-web-module/transformers/i18n-generator.js.map +1 -0
  128. package/dist/scripts/generate-web-module/transformers/import-resolver.d.ts +106 -0
  129. package/dist/scripts/generate-web-module/transformers/import-resolver.d.ts.map +1 -0
  130. package/dist/scripts/generate-web-module/transformers/import-resolver.js +193 -0
  131. package/dist/scripts/generate-web-module/transformers/import-resolver.js.map +1 -0
  132. package/dist/scripts/generate-web-module/transformers/index.d.ts +12 -0
  133. package/dist/scripts/generate-web-module/transformers/index.d.ts.map +1 -0
  134. package/dist/scripts/generate-web-module/transformers/index.js +28 -0
  135. package/dist/scripts/generate-web-module/transformers/index.js.map +1 -0
  136. package/dist/scripts/generate-web-module/transformers/name-transformer.d.ts +60 -0
  137. package/dist/scripts/generate-web-module/transformers/name-transformer.d.ts.map +1 -0
  138. package/dist/scripts/generate-web-module/transformers/name-transformer.js +115 -0
  139. package/dist/scripts/generate-web-module/transformers/name-transformer.js.map +1 -0
  140. package/dist/scripts/generate-web-module/transformers/parent-detector.d.ts +57 -0
  141. package/dist/scripts/generate-web-module/transformers/parent-detector.d.ts.map +1 -0
  142. package/dist/scripts/generate-web-module/transformers/parent-detector.js +88 -0
  143. package/dist/scripts/generate-web-module/transformers/parent-detector.js.map +1 -0
  144. package/dist/scripts/generate-web-module/transformers/relationship-resolver.d.ts +68 -0
  145. package/dist/scripts/generate-web-module/transformers/relationship-resolver.d.ts.map +1 -0
  146. package/dist/scripts/generate-web-module/transformers/relationship-resolver.js +219 -0
  147. package/dist/scripts/generate-web-module/transformers/relationship-resolver.js.map +1 -0
  148. package/dist/scripts/generate-web-module/types/field-mapping.types.d.ts +68 -0
  149. package/dist/scripts/generate-web-module/types/field-mapping.types.d.ts.map +1 -0
  150. package/dist/scripts/generate-web-module/types/field-mapping.types.js +129 -0
  151. package/dist/scripts/generate-web-module/types/field-mapping.types.js.map +1 -0
  152. package/dist/scripts/generate-web-module/types/index.d.ts +9 -0
  153. package/dist/scripts/generate-web-module/types/index.d.ts.map +1 -0
  154. package/dist/scripts/generate-web-module/types/index.js +25 -0
  155. package/dist/scripts/generate-web-module/types/index.js.map +1 -0
  156. package/dist/scripts/generate-web-module/types/json-schema.interface.d.ts +40 -0
  157. package/dist/scripts/generate-web-module/types/json-schema.interface.d.ts.map +1 -0
  158. package/dist/scripts/generate-web-module/types/json-schema.interface.js +10 -0
  159. package/dist/scripts/generate-web-module/types/json-schema.interface.js.map +1 -0
  160. package/dist/scripts/generate-web-module/types/template-data.interface.d.ts +128 -0
  161. package/dist/scripts/generate-web-module/types/template-data.interface.d.ts.map +1 -0
  162. package/dist/scripts/generate-web-module/types/template-data.interface.js +9 -0
  163. package/dist/scripts/generate-web-module/types/template-data.interface.js.map +1 -0
  164. package/dist/scripts/generate-web-module/utils/bootstrapper-updater.d.ts +29 -0
  165. package/dist/scripts/generate-web-module/utils/bootstrapper-updater.d.ts.map +1 -0
  166. package/dist/scripts/generate-web-module/utils/bootstrapper-updater.js +153 -0
  167. package/dist/scripts/generate-web-module/utils/bootstrapper-updater.js.map +1 -0
  168. package/dist/scripts/generate-web-module/utils/file-writer.d.ts +38 -0
  169. package/dist/scripts/generate-web-module/utils/file-writer.d.ts.map +1 -0
  170. package/dist/scripts/generate-web-module/utils/file-writer.js +126 -0
  171. package/dist/scripts/generate-web-module/utils/file-writer.js.map +1 -0
  172. package/dist/scripts/generate-web-module/utils/i18n-updater.d.ts +28 -0
  173. package/dist/scripts/generate-web-module/utils/i18n-updater.d.ts.map +1 -0
  174. package/dist/scripts/generate-web-module/utils/i18n-updater.js +122 -0
  175. package/dist/scripts/generate-web-module/utils/i18n-updater.js.map +1 -0
  176. package/dist/scripts/generate-web-module/utils/index.d.ts +9 -0
  177. package/dist/scripts/generate-web-module/utils/index.d.ts.map +1 -0
  178. package/dist/scripts/generate-web-module/utils/index.js +20 -0
  179. package/dist/scripts/generate-web-module/utils/index.js.map +1 -0
  180. package/dist/scripts/generate-web-module/validators/json-schema-validator.d.ts +46 -0
  181. package/dist/scripts/generate-web-module/validators/json-schema-validator.d.ts.map +1 -0
  182. package/dist/scripts/generate-web-module/validators/json-schema-validator.js +265 -0
  183. package/dist/scripts/generate-web-module/validators/json-schema-validator.js.map +1 -0
  184. package/package.json +27 -21
  185. package/scripts/generate-web-module/generator.ts +363 -0
  186. package/scripts/generate-web-module/index.ts +49 -0
  187. package/scripts/generate-web-module/templates/components/container.template.ts +129 -0
  188. package/scripts/generate-web-module/templates/components/content.template.ts +40 -0
  189. package/scripts/generate-web-module/templates/components/deleter.template.ts +51 -0
  190. package/scripts/generate-web-module/templates/components/details.template.ts +115 -0
  191. package/scripts/generate-web-module/templates/components/editor.template.ts +495 -0
  192. package/scripts/generate-web-module/templates/components/index.ts +18 -0
  193. package/scripts/generate-web-module/templates/components/list-container.template.ts +30 -0
  194. package/scripts/generate-web-module/templates/components/list.template.ts +91 -0
  195. package/scripts/generate-web-module/templates/components/multi-selector.template.ts +184 -0
  196. package/scripts/generate-web-module/templates/components/selector.template.ts +199 -0
  197. package/scripts/generate-web-module/templates/context.template.ts +121 -0
  198. package/scripts/generate-web-module/templates/data/fields.template.ts +64 -0
  199. package/scripts/generate-web-module/templates/data/index.ts +10 -0
  200. package/scripts/generate-web-module/templates/data/interface.template.ts +136 -0
  201. package/scripts/generate-web-module/templates/data/model.template.ts +327 -0
  202. package/scripts/generate-web-module/templates/data/service.template.ts +185 -0
  203. package/scripts/generate-web-module/templates/index.ts +34 -0
  204. package/scripts/generate-web-module/templates/module.template.ts +69 -0
  205. package/scripts/generate-web-module/templates/pages/detail-page.template.ts +65 -0
  206. package/scripts/generate-web-module/templates/pages/index.ts +8 -0
  207. package/scripts/generate-web-module/templates/pages/list-page.template.ts +37 -0
  208. package/scripts/generate-web-module/templates/table-hook.template.ts +182 -0
  209. package/scripts/generate-web-module/transformers/field-mapper.ts +201 -0
  210. package/scripts/generate-web-module/transformers/i18n-generator.ts +199 -0
  211. package/scripts/generate-web-module/transformers/import-resolver.ts +250 -0
  212. package/scripts/generate-web-module/transformers/index.ts +12 -0
  213. package/scripts/generate-web-module/transformers/name-transformer.ts +115 -0
  214. package/scripts/generate-web-module/transformers/parent-detector.ts +87 -0
  215. package/scripts/generate-web-module/transformers/relationship-resolver.ts +221 -0
  216. package/scripts/generate-web-module/tsconfig.json +24 -0
  217. package/scripts/generate-web-module/types/field-mapping.types.ts +141 -0
  218. package/scripts/generate-web-module/types/index.ts +9 -0
  219. package/scripts/generate-web-module/types/json-schema.interface.ts +42 -0
  220. package/scripts/generate-web-module/types/template-data.interface.ts +164 -0
  221. package/scripts/generate-web-module/utils/bootstrapper-updater.ts +145 -0
  222. package/scripts/generate-web-module/utils/file-writer.ts +115 -0
  223. package/scripts/generate-web-module/utils/i18n-updater.ts +108 -0
  224. package/scripts/generate-web-module/utils/index.ts +9 -0
  225. package/scripts/generate-web-module/validators/json-schema-validator.ts +306 -0
  226. package/src/features/user/index.ts +1 -1
  227. package/dist/chunk-FYRFMABS.js.map +0 -1
  228. package/dist/chunk-MA2L2PL2.mjs.map +0 -1
  229. /package/dist/{BlockNoteEditor-4VOBTXWC.mjs.map → BlockNoteEditor-DC33K4IF.mjs.map} +0 -0
  230. /package/dist/{chunk-HP4Q5ZVG.mjs.map → chunk-Y4XI3AZR.mjs.map} +0 -0
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ /**
3
+ * Name Transformer
4
+ *
5
+ * Transforms module names to various case conventions
6
+ * needed for code generation.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.transformNames = transformNames;
10
+ exports.toCamelCase = toCamelCase;
11
+ exports.toKebabCase = toKebabCase;
12
+ exports.toPascalCase = toPascalCase;
13
+ exports.toTitleCase = toTitleCase;
14
+ exports.pluralize = pluralize;
15
+ exports.singularize = singularize;
16
+ /**
17
+ * Transform a module name to all necessary case conventions
18
+ *
19
+ * @param moduleName - PascalCase module name (e.g., "Comment")
20
+ * @param endpoint - Optional kebab-case plural endpoint (e.g., "comments"), derived from moduleName if not provided
21
+ * @returns All name transformations
22
+ */
23
+ function transformNames(moduleName, endpoint) {
24
+ const pluralPascal = toPascalCase(pluralize(moduleName));
25
+ const pluralCamel = toCamelCase(pluralPascal);
26
+ const pluralKebab = endpoint || toKebabCase(pluralize(moduleName));
27
+ return {
28
+ pascalCase: moduleName,
29
+ camelCase: toCamelCase(moduleName),
30
+ kebabCase: toKebabCase(moduleName),
31
+ pluralPascal,
32
+ pluralCamel,
33
+ pluralKebab,
34
+ titleCase: toTitleCase(moduleName),
35
+ pluralTitleCase: toTitleCase(pluralPascal),
36
+ };
37
+ }
38
+ /**
39
+ * Convert PascalCase to camelCase
40
+ *
41
+ * @param str - PascalCase string
42
+ * @returns camelCase string
43
+ */
44
+ function toCamelCase(str) {
45
+ return str.charAt(0).toLowerCase() + str.slice(1);
46
+ }
47
+ /**
48
+ * Convert PascalCase to kebab-case
49
+ *
50
+ * @param str - PascalCase string
51
+ * @returns kebab-case string
52
+ */
53
+ function toKebabCase(str) {
54
+ return str
55
+ .replace(/([A-Z])/g, "-$1")
56
+ .toLowerCase()
57
+ .replace(/^-/, "");
58
+ }
59
+ /**
60
+ * Convert string to PascalCase
61
+ *
62
+ * @param str - Any case string
63
+ * @returns PascalCase string
64
+ */
65
+ function toPascalCase(str) {
66
+ return str.charAt(0).toUpperCase() + str.slice(1);
67
+ }
68
+ /**
69
+ * Convert PascalCase/camelCase to Title Case with spaces
70
+ * e.g., "firstName" -> "First Name", "UserProfile" -> "User Profile"
71
+ *
72
+ * @param str - PascalCase or camelCase string
73
+ * @returns Title Case string with spaces
74
+ */
75
+ function toTitleCase(str) {
76
+ return str
77
+ .replace(/([A-Z])/g, " $1")
78
+ .replace(/^./, (char) => char.toUpperCase())
79
+ .trim();
80
+ }
81
+ /**
82
+ * Simple pluralization
83
+ * Note: This is a basic implementation. For production, consider using a library like 'pluralize'
84
+ *
85
+ * @param str - Singular form
86
+ * @returns Plural form
87
+ */
88
+ function pluralize(str) {
89
+ if (str.endsWith("s")) {
90
+ return str + "es";
91
+ }
92
+ if (str.endsWith("y") && !["a", "e", "i", "o", "u"].includes(str[str.length - 2])) {
93
+ return str.slice(0, -1) + "ies";
94
+ }
95
+ return str + "s";
96
+ }
97
+ /**
98
+ * Simple singularization (reverse of pluralize)
99
+ *
100
+ * @param str - Plural form
101
+ * @returns Singular form
102
+ */
103
+ function singularize(str) {
104
+ if (str.endsWith("ies")) {
105
+ return str.slice(0, -3) + "y";
106
+ }
107
+ if (str.endsWith("ses") || str.endsWith("xes") || str.endsWith("zes")) {
108
+ return str.slice(0, -2);
109
+ }
110
+ if (str.endsWith("s") && !str.endsWith("ss")) {
111
+ return str.slice(0, -1);
112
+ }
113
+ return str;
114
+ }
115
+ //# sourceMappingURL=name-transformer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"name-transformer.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,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7C,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC1B,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Parent Class Detector
3
+ *
4
+ * Determines whether a module should extend Content or AbstractApiData
5
+ * based on the presence of Content-specific fields.
6
+ */
7
+ import { JsonFieldDefinition } from "../types/json-schema.interface";
8
+ /**
9
+ * Check if a module should extend Content based on its fields
10
+ *
11
+ * @param fields - Array of field definitions from JSON schema
12
+ * @returns true if the module should extend Content
13
+ */
14
+ export declare function detectExtendsContent(fields: JsonFieldDefinition[]): boolean;
15
+ /**
16
+ * Get the parent class name based on detection result
17
+ *
18
+ * @param extendsContent - Whether the module extends Content
19
+ * @returns Parent class name
20
+ */
21
+ export declare function getParentClassName(extendsContent: boolean): string;
22
+ /**
23
+ * Get the parent interface name based on detection result
24
+ *
25
+ * @param extendsContent - Whether the module extends Content
26
+ * @returns Parent interface name
27
+ */
28
+ export declare function getParentInterfaceName(extendsContent: boolean): string;
29
+ /**
30
+ * Get the parent input type name based on detection result
31
+ *
32
+ * @param extendsContent - Whether the module extends Content
33
+ * @returns Parent input type or null if standalone
34
+ */
35
+ export declare function getParentInputType(extendsContent: boolean): string | null;
36
+ /**
37
+ * Get the import path for the parent class
38
+ *
39
+ * @param extendsContent - Whether the module extends Content
40
+ * @returns Import path for parent class
41
+ */
42
+ export declare function getParentClassImport(extendsContent: boolean): string;
43
+ /**
44
+ * Check if the module needs to call super.addContentInput() in createJsonApi
45
+ *
46
+ * @param extendsContent - Whether the module extends Content
47
+ * @returns true if super.addContentInput() should be called
48
+ */
49
+ export declare function needsAddContentInput(extendsContent: boolean): boolean;
50
+ /**
51
+ * Get fields that are inherited from Content and should not be declared
52
+ *
53
+ * @param extendsContent - Whether the module extends Content
54
+ * @returns Array of field names to exclude from generation
55
+ */
56
+ export declare function getInheritedFields(extendsContent: boolean): string[];
57
+ //# sourceMappingURL=parent-detector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parent-detector.d.ts","sourceRoot":"","sources":["../../../../scripts/generate-web-module/transformers/parent-detector.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAGrE;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,mBAAmB,EAAE,GAAG,OAAO,CAG3E;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,cAAc,EAAE,OAAO,GAAG,MAAM,CAElE;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,cAAc,EAAE,OAAO,GAAG,MAAM,CAEtE;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,cAAc,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAEzE;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,cAAc,EAAE,OAAO,GAAG,MAAM,CAKpE;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,cAAc,EAAE,OAAO,GAAG,OAAO,CAErE;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,cAAc,EAAE,OAAO,GAAG,MAAM,EAAE,CAMpE"}
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ /**
3
+ * Parent Class Detector
4
+ *
5
+ * Determines whether a module should extend Content or AbstractApiData
6
+ * based on the presence of Content-specific fields.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.detectExtendsContent = detectExtendsContent;
10
+ exports.getParentClassName = getParentClassName;
11
+ exports.getParentInterfaceName = getParentInterfaceName;
12
+ exports.getParentInputType = getParentInputType;
13
+ exports.getParentClassImport = getParentClassImport;
14
+ exports.needsAddContentInput = needsAddContentInput;
15
+ exports.getInheritedFields = getInheritedFields;
16
+ const field_mapping_types_1 = require("../types/field-mapping.types");
17
+ /**
18
+ * Check if a module should extend Content based on its fields
19
+ *
20
+ * @param fields - Array of field definitions from JSON schema
21
+ * @returns true if the module should extend Content
22
+ */
23
+ function detectExtendsContent(fields) {
24
+ const fieldNames = fields.map((f) => f.name);
25
+ return field_mapping_types_1.CONTENT_INDICATOR_FIELDS.some((indicator) => fieldNames.includes(indicator));
26
+ }
27
+ /**
28
+ * Get the parent class name based on detection result
29
+ *
30
+ * @param extendsContent - Whether the module extends Content
31
+ * @returns Parent class name
32
+ */
33
+ function getParentClassName(extendsContent) {
34
+ return extendsContent ? "Content" : "AbstractApiData";
35
+ }
36
+ /**
37
+ * Get the parent interface name based on detection result
38
+ *
39
+ * @param extendsContent - Whether the module extends Content
40
+ * @returns Parent interface name
41
+ */
42
+ function getParentInterfaceName(extendsContent) {
43
+ return extendsContent ? "ContentInterface" : "BaseInterface";
44
+ }
45
+ /**
46
+ * Get the parent input type name based on detection result
47
+ *
48
+ * @param extendsContent - Whether the module extends Content
49
+ * @returns Parent input type or null if standalone
50
+ */
51
+ function getParentInputType(extendsContent) {
52
+ return extendsContent ? "ContentInput" : null;
53
+ }
54
+ /**
55
+ * Get the import path for the parent class
56
+ *
57
+ * @param extendsContent - Whether the module extends Content
58
+ * @returns Import path for parent class
59
+ */
60
+ function getParentClassImport(extendsContent) {
61
+ if (extendsContent) {
62
+ return '@carlonicora/nextjs-jsonapi/core';
63
+ }
64
+ return '@carlonicora/nextjs-jsonapi/core';
65
+ }
66
+ /**
67
+ * Check if the module needs to call super.addContentInput() in createJsonApi
68
+ *
69
+ * @param extendsContent - Whether the module extends Content
70
+ * @returns true if super.addContentInput() should be called
71
+ */
72
+ function needsAddContentInput(extendsContent) {
73
+ return extendsContent;
74
+ }
75
+ /**
76
+ * Get fields that are inherited from Content and should not be declared
77
+ *
78
+ * @param extendsContent - Whether the module extends Content
79
+ * @returns Array of field names to exclude from generation
80
+ */
81
+ function getInheritedFields(extendsContent) {
82
+ if (extendsContent) {
83
+ // These fields are already in Content, don't redeclare them
84
+ return ["name", "tldr", "abstract", "relevance"];
85
+ }
86
+ return [];
87
+ }
88
+ //# sourceMappingURL=parent-detector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parent-detector.js","sourceRoot":"","sources":["../../../../scripts/generate-web-module/transformers/parent-detector.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAWH,oDAGC;AAQD,gDAEC;AAQD,wDAEC;AAQD,gDAEC;AAQD,oDAKC;AAQD,oDAEC;AAQD,gDAMC;AA9ED,sEAAwE;AAExE;;;;;GAKG;AACH,SAAgB,oBAAoB,CAAC,MAA6B;IAChE,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAC7C,OAAO,8CAAwB,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;AACtF,CAAC;AAED;;;;;GAKG;AACH,SAAgB,kBAAkB,CAAC,cAAuB;IACxD,OAAO,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,iBAAiB,CAAC;AACxD,CAAC;AAED;;;;;GAKG;AACH,SAAgB,sBAAsB,CAAC,cAAuB;IAC5D,OAAO,cAAc,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,eAAe,CAAC;AAC/D,CAAC;AAED;;;;;GAKG;AACH,SAAgB,kBAAkB,CAAC,cAAuB;IACxD,OAAO,cAAc,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC;AAChD,CAAC;AAED;;;;;GAKG;AACH,SAAgB,oBAAoB,CAAC,cAAuB;IAC1D,IAAI,cAAc,EAAE,CAAC;QACnB,OAAO,kCAAkC,CAAC;IAC5C,CAAC;IACD,OAAO,kCAAkC,CAAC;AAC5C,CAAC;AAED;;;;;GAKG;AACH,SAAgB,oBAAoB,CAAC,cAAuB;IAC1D,OAAO,cAAc,CAAC;AACxB,CAAC;AAED;;;;;GAKG;AACH,SAAgB,kBAAkB,CAAC,cAAuB;IACxD,IAAI,cAAc,EAAE,CAAC;QACnB,4DAA4D;QAC5D,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;IACnD,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Relationship Resolver
3
+ *
4
+ * Resolves JSON relationship definitions to frontend representations
5
+ * including form fields, imports, and service methods.
6
+ */
7
+ import { JsonRelationshipDefinition } from "../types/json-schema.interface";
8
+ import { FrontendRelationship, RelationshipServiceMethod } from "../types/template-data.interface";
9
+ /**
10
+ * Resolve a JSON relationship to frontend representation
11
+ *
12
+ * @param rel - JSON relationship definition
13
+ * @returns Frontend relationship representation
14
+ */
15
+ export declare function resolveRelationship(rel: JsonRelationshipDefinition): FrontendRelationship;
16
+ /**
17
+ * Resolve all relationships from JSON schema
18
+ *
19
+ * @param relationships - Array of JSON relationship definitions
20
+ * @returns Array of frontend relationship representations
21
+ */
22
+ export declare function resolveRelationships(relationships: JsonRelationshipDefinition[]): FrontendRelationship[];
23
+ /**
24
+ * Map directory value to web path
25
+ * e.g., "features" -> "features", "foundations" -> "foundations"
26
+ *
27
+ * @param directory - Directory value from JSON
28
+ * @returns Web path segment
29
+ */
30
+ export declare function mapDirectoryToWebPath(directory: string): string;
31
+ /**
32
+ * Generate service method definitions for relationships
33
+ *
34
+ * @param relationships - Array of frontend relationships
35
+ * @returns Array of service method definitions
36
+ */
37
+ export declare function generateServiceMethods(relationships: FrontendRelationship[]): RelationshipServiceMethod[];
38
+ /**
39
+ * Get unique selector imports needed for the editor
40
+ *
41
+ * @param relationships - Array of frontend relationships
42
+ * @returns Deduplicated array of import statements
43
+ */
44
+ export declare function getSelectorImports(relationships: FrontendRelationship[]): string[];
45
+ /**
46
+ * Get form JSX for a relationship field
47
+ *
48
+ * @param rel - Frontend relationship
49
+ * @param moduleName - Module name for i18n keys
50
+ * @returns JSX code for the relationship selector
51
+ */
52
+ export declare function getRelationshipFormJsx(rel: FrontendRelationship, moduleName: string): string;
53
+ /**
54
+ * Get default value expression for a relationship in form
55
+ *
56
+ * @param rel - Frontend relationship
57
+ * @param modelVarName - Variable name for the model (e.g., "article")
58
+ * @returns Expression for default value
59
+ */
60
+ export declare function getDefaultValueExpression(rel: FrontendRelationship, modelVarName: string): string;
61
+ /**
62
+ * Get payload mapping for a relationship
63
+ *
64
+ * @param rel - Frontend relationship
65
+ * @returns Payload field assignment code
66
+ */
67
+ export declare function getPayloadMapping(rel: FrontendRelationship): string;
68
+ //# sourceMappingURL=relationship-resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relationship-resolver.d.ts","sourceRoot":"","sources":["../../../../scripts/generate-web-module/transformers/relationship-resolver.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAInG;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,0BAA0B,GAAG,oBAAoB,CA+DzF;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,0BAA0B,EAAE,GAAG,oBAAoB,EAAE,CAExG;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAG/D;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,aAAa,EAAE,oBAAoB,EAAE,GAAG,yBAAyB,EAAE,CAUzG;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,oBAAoB,EAAE,GAAG,MAAM,EAAE,CAclF;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAyB5F;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAoBjG;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,oBAAoB,GAAG,MAAM,CAMnE"}
@@ -0,0 +1,219 @@
1
+ "use strict";
2
+ /**
3
+ * Relationship Resolver
4
+ *
5
+ * Resolves JSON relationship definitions to frontend representations
6
+ * including form fields, imports, and service methods.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.resolveRelationship = resolveRelationship;
10
+ exports.resolveRelationships = resolveRelationships;
11
+ exports.mapDirectoryToWebPath = mapDirectoryToWebPath;
12
+ exports.generateServiceMethods = generateServiceMethods;
13
+ exports.getSelectorImports = getSelectorImports;
14
+ exports.getRelationshipFormJsx = getRelationshipFormJsx;
15
+ exports.getDefaultValueExpression = getDefaultValueExpression;
16
+ exports.getPayloadMapping = getPayloadMapping;
17
+ const field_mapping_types_1 = require("../types/field-mapping.types");
18
+ const name_transformer_1 = require("./name-transformer");
19
+ /**
20
+ * Resolve a JSON relationship to frontend representation
21
+ *
22
+ * @param rel - JSON relationship definition
23
+ * @returns Frontend relationship representation
24
+ */
25
+ function resolveRelationship(rel) {
26
+ const isAuthor = rel.variant === field_mapping_types_1.AUTHOR_VARIANT;
27
+ const effectiveName = rel.variant || rel.name;
28
+ const effectiveNameLower = (0, name_transformer_1.toCamelCase)(effectiveName);
29
+ const modelKebab = (0, name_transformer_1.toKebabCase)(rel.name);
30
+ // Form field ID
31
+ const formFieldId = effectiveNameLower;
32
+ const formFieldIdPlural = (0, name_transformer_1.pluralize)(effectiveNameLower);
33
+ // Payload field ID for API calls
34
+ let payloadFieldId;
35
+ if (rel.single) {
36
+ payloadFieldId = `${effectiveNameLower}Id`;
37
+ }
38
+ else {
39
+ payloadFieldId = `${(0, name_transformer_1.toCamelCase)(rel.name)}Ids`;
40
+ }
41
+ // Selector component name
42
+ let selectorComponent;
43
+ if (rel.single) {
44
+ selectorComponent = `${rel.name}Selector`;
45
+ }
46
+ else {
47
+ selectorComponent = `${rel.name}MultiSelector`;
48
+ }
49
+ // Zod schema
50
+ let zodSchema;
51
+ if (isAuthor) {
52
+ zodSchema = rel.nullable
53
+ ? `${field_mapping_types_1.AUTHOR_ZOD_SCHEMA}.optional()`
54
+ : `${field_mapping_types_1.AUTHOR_ZOD_SCHEMA}.refine((data) => data.id && data.id.length > 0, { message: t(\`generic.relationships.author.error\`) })`;
55
+ }
56
+ else if (rel.single) {
57
+ zodSchema = rel.nullable
58
+ ? `${field_mapping_types_1.ENTITY_ZOD_SCHEMA}.optional()`
59
+ : `${field_mapping_types_1.ENTITY_ZOD_SCHEMA}.refine((data) => data.id && data.id.length > 0, { message: t(\`generic.relationships.${effectiveNameLower}.error\`) })`;
60
+ }
61
+ else {
62
+ zodSchema = rel.nullable ? `z.array(${field_mapping_types_1.ENTITY_ZOD_SCHEMA}).optional()` : `z.array(${field_mapping_types_1.ENTITY_ZOD_SCHEMA})`;
63
+ }
64
+ // Import paths - map directory to web path
65
+ const webDirectory = mapDirectoryToWebPath(rel.directory);
66
+ const importPath = `@/features/${webDirectory}/${modelKebab}/components/forms/${selectorComponent}`;
67
+ const interfaceImportPath = `@/features/${webDirectory}/${modelKebab}/data/${rel.name}Interface`;
68
+ const serviceImportPath = `@/features/${webDirectory}/${modelKebab}/data/${rel.name}Service`;
69
+ return {
70
+ name: rel.name,
71
+ variant: rel.variant,
72
+ directory: rel.directory,
73
+ single: rel.single,
74
+ nullable: rel.nullable,
75
+ formFieldId,
76
+ formFieldIdPlural,
77
+ payloadFieldId,
78
+ selectorComponent,
79
+ zodSchema,
80
+ importPath,
81
+ interfaceImportPath,
82
+ serviceImportPath,
83
+ interfaceName: `${rel.name}Interface`,
84
+ modelKebab,
85
+ };
86
+ }
87
+ /**
88
+ * Resolve all relationships from JSON schema
89
+ *
90
+ * @param relationships - Array of JSON relationship definitions
91
+ * @returns Array of frontend relationship representations
92
+ */
93
+ function resolveRelationships(relationships) {
94
+ return relationships.map(resolveRelationship);
95
+ }
96
+ /**
97
+ * Map directory value to web path
98
+ * e.g., "features" -> "features", "foundations" -> "foundations"
99
+ *
100
+ * @param directory - Directory value from JSON
101
+ * @returns Web path segment
102
+ */
103
+ function mapDirectoryToWebPath(directory) {
104
+ // The directory value maps directly to the web path
105
+ return directory;
106
+ }
107
+ /**
108
+ * Generate service method definitions for relationships
109
+ *
110
+ * @param relationships - Array of frontend relationships
111
+ * @returns Array of service method definitions
112
+ */
113
+ function generateServiceMethods(relationships) {
114
+ return relationships.map((rel) => {
115
+ const effectiveName = rel.variant || rel.name;
116
+ return {
117
+ methodName: `findManyBy${(0, name_transformer_1.toPascalCase)(effectiveName)}`,
118
+ paramName: `${(0, name_transformer_1.toCamelCase)(effectiveName)}Id`,
119
+ relationshipName: rel.name,
120
+ relationshipEndpoint: (0, name_transformer_1.pluralize)((0, name_transformer_1.toKebabCase)(rel.name)),
121
+ };
122
+ });
123
+ }
124
+ /**
125
+ * Get unique selector imports needed for the editor
126
+ *
127
+ * @param relationships - Array of frontend relationships
128
+ * @returns Deduplicated array of import statements
129
+ */
130
+ function getSelectorImports(relationships) {
131
+ const imports = new Set();
132
+ relationships.forEach((rel) => {
133
+ // Don't import User selector from same module - it's typically a library import
134
+ if (rel.name === "User" && rel.variant === field_mapping_types_1.AUTHOR_VARIANT) {
135
+ // User selector is imported from library or user feature
136
+ imports.add(`import { UserSelector } from "@/features/foundations/user/components/forms/UserSelector";`);
137
+ }
138
+ else {
139
+ imports.add(`import ${rel.selectorComponent} from "${rel.importPath}";`);
140
+ }
141
+ });
142
+ return Array.from(imports);
143
+ }
144
+ /**
145
+ * Get form JSX for a relationship field
146
+ *
147
+ * @param rel - Frontend relationship
148
+ * @param moduleName - Module name for i18n keys
149
+ * @returns JSX code for the relationship selector
150
+ */
151
+ function getRelationshipFormJsx(rel, moduleName) {
152
+ const isRequired = !rel.nullable;
153
+ const lowerModuleName = moduleName.toLowerCase();
154
+ if (rel.single) {
155
+ // Single selector
156
+ if (rel.variant === field_mapping_types_1.AUTHOR_VARIANT) {
157
+ // Author is auto-set, usually not shown in form or read-only
158
+ return "";
159
+ }
160
+ return `<${rel.name}Selector
161
+ id="${rel.formFieldId}"
162
+ form={form}
163
+ label={t(\`generic.relationships.${rel.formFieldId}.label\`)}
164
+ placeholder={t(\`generic.relationships.${rel.formFieldId}.placeholder\`)}
165
+ ${isRequired ? "isRequired" : ""}
166
+ />`;
167
+ }
168
+ else {
169
+ // Multi selector
170
+ return `<${rel.name}MultiSelector
171
+ id="${rel.formFieldId}"
172
+ form={form}
173
+ label={t(\`types.${(0, name_transformer_1.pluralize)((0, name_transformer_1.toKebabCase)(rel.name))}\`, { count: 2 })}
174
+ />`;
175
+ }
176
+ }
177
+ /**
178
+ * Get default value expression for a relationship in form
179
+ *
180
+ * @param rel - Frontend relationship
181
+ * @param modelVarName - Variable name for the model (e.g., "article")
182
+ * @returns Expression for default value
183
+ */
184
+ function getDefaultValueExpression(rel, modelVarName) {
185
+ const propertyName = rel.variant ? (0, name_transformer_1.toCamelCase)(rel.variant) : (0, name_transformer_1.toCamelCase)(rel.name);
186
+ const pluralPropertyName = (0, name_transformer_1.pluralize)(propertyName);
187
+ if (rel.single) {
188
+ if (rel.variant === field_mapping_types_1.AUTHOR_VARIANT) {
189
+ // Author has special shape with avatar
190
+ return `${modelVarName}?.${propertyName}
191
+ ? { id: ${modelVarName}.${propertyName}.id, name: ${modelVarName}.${propertyName}.name, avatar: ${modelVarName}.${propertyName}.avatar }
192
+ : undefined`;
193
+ }
194
+ return `${modelVarName}?.${propertyName}
195
+ ? { id: ${modelVarName}.${propertyName}.id, name: ${modelVarName}.${propertyName}.name }
196
+ : undefined`;
197
+ }
198
+ else {
199
+ // Multi-select
200
+ return `${modelVarName}?.${pluralPropertyName}
201
+ ? ${modelVarName}.${pluralPropertyName}.map((item) => ({ id: item.id, name: item.name }))
202
+ : []`;
203
+ }
204
+ }
205
+ /**
206
+ * Get payload mapping for a relationship
207
+ *
208
+ * @param rel - Frontend relationship
209
+ * @returns Payload field assignment code
210
+ */
211
+ function getPayloadMapping(rel) {
212
+ if (rel.single) {
213
+ return `${rel.payloadFieldId}: values.${rel.formFieldId}?.id`;
214
+ }
215
+ else {
216
+ return `${rel.payloadFieldId}: values.${rel.formFieldId} ? values.${rel.formFieldId}.map((item) => item.id) : []`;
217
+ }
218
+ }
219
+ //# sourceMappingURL=relationship-resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relationship-resolver.js","sourceRoot":"","sources":["../../../../scripts/generate-web-module/transformers/relationship-resolver.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAaH,kDA+DC;AAQD,oDAEC;AASD,sDAGC;AAQD,wDAUC;AAQD,gDAcC;AASD,wDAyBC;AASD,8DAoBC;AAQD,8CAMC;AAnND,sEAAoG;AACpG,yDAAuF;AAEvF;;;;;GAKG;AACH,SAAgB,mBAAmB,CAAC,GAA+B;IACjE,MAAM,QAAQ,GAAG,GAAG,CAAC,OAAO,KAAK,oCAAc,CAAC;IAChD,MAAM,aAAa,GAAG,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC;IAC9C,MAAM,kBAAkB,GAAG,IAAA,8BAAW,EAAC,aAAa,CAAC,CAAC;IACtD,MAAM,UAAU,GAAG,IAAA,8BAAW,EAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAEzC,gBAAgB;IAChB,MAAM,WAAW,GAAG,kBAAkB,CAAC;IACvC,MAAM,iBAAiB,GAAG,IAAA,4BAAS,EAAC,kBAAkB,CAAC,CAAC;IAExD,iCAAiC;IACjC,IAAI,cAAsB,CAAC;IAC3B,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC;QACf,cAAc,GAAG,GAAG,kBAAkB,IAAI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AAO,CAAC,CAAC,CAAC,IAAA,8BAAW,EAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAA,8BAAW,EAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACpF,MAAM,kBAAkB,GAAG,IAAA,4BAAS,EAAC,YAAY,CAAC,CAAC;IAEnD,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC;QACf,IAAI,GAAG,CAAC,OAAO,KAAK,oCAAc,EAAE,CAAC;YACnC,uCAAuC;YACvC,OAAO,GAAG,YAAY,KAAK,YAAY;kBAC3B,YAAY,IAAI,YAAY,cAAc,YAAY,IAAI,YAAY,kBAAkB,YAAY,IAAI,YAAY;oBAClH,CAAC;QACjB,CAAC;QACD,OAAO,GAAG,YAAY,KAAK,YAAY;kBACzB,YAAY,IAAI,YAAY,cAAc,YAAY,IAAI,YAAY;oBACpE,CAAC;IACnB,CAAC;SAAM,CAAC;QACN,eAAe;QACf,OAAO,GAAG,YAAY,KAAK,kBAAkB;YACrC,YAAY,IAAI,kBAAkB;aACjC,CAAC;IACZ,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAgB,iBAAiB,CAAC,GAAyB;IACzD,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC;QACf,OAAO,GAAG,GAAG,CAAC,cAAc,YAAY,GAAG,CAAC,WAAW,MAAM,CAAC;IAChE,CAAC;SAAM,CAAC;QACN,OAAO,GAAG,GAAG,CAAC,cAAc,YAAY,GAAG,CAAC,WAAW,aAAa,GAAG,CAAC,WAAW,8BAA8B,CAAC;IACpH,CAAC;AACH,CAAC"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Field Mapping Types
3
+ *
4
+ * Defines the mapping rules between JSON schema field types
5
+ * and their TypeScript, Zod, and form component equivalents.
6
+ */
7
+ import { FormComponentType } from "./template-data.interface";
8
+ /**
9
+ * Mapping from JSON type to TypeScript type
10
+ */
11
+ export declare const JSON_TO_TS_TYPE: Record<string, string>;
12
+ /**
13
+ * Mapping from JSON type to Zod schema (base, without modifiers)
14
+ */
15
+ export declare const JSON_TO_ZOD_BASE: Record<string, string>;
16
+ /**
17
+ * Special field names that get specific form components
18
+ */
19
+ export declare const SPECIAL_FIELD_COMPONENTS: Record<string, FormComponentType>;
20
+ /**
21
+ * Default form component by type
22
+ */
23
+ export declare const TYPE_TO_FORM_COMPONENT: Record<string, FormComponentType>;
24
+ /**
25
+ * Fields that indicate the module extends Content
26
+ */
27
+ export declare const CONTENT_INDICATOR_FIELDS: string[];
28
+ /**
29
+ * Standard fields added to all modules
30
+ */
31
+ export declare const STANDARD_FIELDS: string[];
32
+ /**
33
+ * Author variant special handling
34
+ */
35
+ export declare const AUTHOR_VARIANT = "Author";
36
+ /**
37
+ * Zod schema for author relationships
38
+ */
39
+ export declare const AUTHOR_ZOD_SCHEMA = "userObjectSchema";
40
+ /**
41
+ * Zod schema for entity relationships (non-author)
42
+ */
43
+ export declare const ENTITY_ZOD_SCHEMA = "entityObjectSchema";
44
+ /**
45
+ * Default icon for new modules
46
+ */
47
+ export declare const DEFAULT_MODULE_ICON = "FileTextIcon";
48
+ /**
49
+ * Get TypeScript type for a field
50
+ */
51
+ export declare function getTsType(jsonType: string): string;
52
+ /**
53
+ * Get base Zod schema for a field type
54
+ */
55
+ export declare function getZodBase(jsonType: string): string;
56
+ /**
57
+ * Get form component for a field
58
+ */
59
+ export declare function getFormComponent(fieldName: string, fieldType: string): FormComponentType;
60
+ /**
61
+ * Check if a field name indicates BlockNoteEditor should be used
62
+ */
63
+ export declare function isContentField(fieldName: string): boolean;
64
+ /**
65
+ * Build complete Zod schema for a field
66
+ */
67
+ export declare function buildZodSchema(fieldType: string, nullable: boolean, fieldName: string): string;
68
+ //# sourceMappingURL=field-mapping.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-mapping.types.d.ts","sourceRoot":"","sources":["../../../../scripts/generate-web-module/types/field-mapping.types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EA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