@api-client/core 0.19.10 → 0.19.12

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 (466) hide show
  1. package/LICENSE.md +9 -63
  2. package/bin/test.ts +1 -12
  3. package/build/src/browser.d.ts +3 -16
  4. package/build/src/browser.d.ts.map +1 -1
  5. package/build/src/browser.js +2 -17
  6. package/build/src/browser.js.map +1 -1
  7. package/build/src/events/EventTypes.d.ts +0 -6
  8. package/build/src/events/EventTypes.d.ts.map +1 -1
  9. package/build/src/events/EventTypes.js +0 -2
  10. package/build/src/events/EventTypes.js.map +1 -1
  11. package/build/src/events/Events.d.ts +0 -2
  12. package/build/src/events/Events.d.ts.map +1 -1
  13. package/build/src/events/Events.js +0 -2
  14. package/build/src/events/Events.js.map +1 -1
  15. package/build/src/index.d.ts +3 -16
  16. package/build/src/index.d.ts.map +1 -1
  17. package/build/src/index.js +2 -17
  18. package/build/src/index.js.map +1 -1
  19. package/build/src/modeling/ApiValidation.d.ts +26 -0
  20. package/build/src/modeling/ApiValidation.d.ts.map +1 -0
  21. package/build/src/modeling/ApiValidation.js +73 -0
  22. package/build/src/modeling/ApiValidation.js.map +1 -0
  23. package/build/src/modeling/Bindings.d.ts +3 -3
  24. package/build/src/modeling/Bindings.d.ts.map +1 -1
  25. package/build/src/modeling/Bindings.js.map +1 -1
  26. package/build/src/modeling/DomainAssociation.d.ts +5 -5
  27. package/build/src/modeling/DomainAssociation.d.ts.map +1 -1
  28. package/build/src/modeling/DomainAssociation.js.map +1 -1
  29. package/build/src/modeling/DomainEntity.d.ts +2 -3
  30. package/build/src/modeling/DomainEntity.d.ts.map +1 -1
  31. package/build/src/modeling/DomainEntity.js +1 -1
  32. package/build/src/modeling/DomainEntity.js.map +1 -1
  33. package/build/src/modeling/DomainProperty.d.ts +2 -3
  34. package/build/src/modeling/DomainProperty.d.ts.map +1 -1
  35. package/build/src/modeling/DomainProperty.js +1 -1
  36. package/build/src/modeling/DomainProperty.js.map +1 -1
  37. package/build/src/modeling/DomainValidation.d.ts +10 -4
  38. package/build/src/modeling/DomainValidation.d.ts.map +1 -1
  39. package/build/src/modeling/DomainValidation.js +55 -72
  40. package/build/src/modeling/DomainValidation.js.map +1 -1
  41. package/build/src/modeling/ai/types.d.ts +2 -2
  42. package/build/src/modeling/ai/types.d.ts.map +1 -1
  43. package/build/src/modeling/ai/types.js.map +1 -1
  44. package/build/src/{amf → modeling/amf}/DataValueGenerator.d.ts +1 -1
  45. package/build/src/modeling/amf/DataValueGenerator.d.ts.map +1 -0
  46. package/build/src/{amf → modeling/amf}/DataValueGenerator.js +2 -3
  47. package/build/src/modeling/amf/DataValueGenerator.js.map +1 -0
  48. package/build/src/modeling/amf/ShapeGenerator.d.ts +20 -20
  49. package/build/src/modeling/amf/ShapeGenerator.d.ts.map +1 -1
  50. package/build/src/modeling/amf/ShapeGenerator.js +16 -18
  51. package/build/src/modeling/amf/ShapeGenerator.js.map +1 -1
  52. package/build/src/modeling/amf/core_types.d.ts +9 -0
  53. package/build/src/modeling/amf/core_types.d.ts.map +1 -0
  54. package/build/src/modeling/amf/core_types.js +45 -0
  55. package/build/src/modeling/amf/core_types.js.map +1 -0
  56. package/build/src/modeling/validation/api_model_rules.d.ts +1 -2
  57. package/build/src/modeling/validation/api_model_rules.d.ts.map +1 -1
  58. package/build/src/modeling/validation/api_model_rules.js +0 -26
  59. package/build/src/modeling/validation/api_model_rules.js.map +1 -1
  60. package/build/src/modeling/validation/association_validation.d.ts +4 -4
  61. package/build/src/modeling/validation/association_validation.d.ts.map +1 -1
  62. package/build/src/modeling/validation/association_validation.js.map +1 -1
  63. package/build/src/modeling/validation/entity_validation.d.ts +6 -6
  64. package/build/src/modeling/validation/entity_validation.d.ts.map +1 -1
  65. package/build/src/modeling/validation/entity_validation.js.map +1 -1
  66. package/build/src/modeling/validation/property_validation.d.ts +3 -3
  67. package/build/src/modeling/validation/property_validation.d.ts.map +1 -1
  68. package/build/src/modeling/validation/property_validation.js.map +1 -1
  69. package/build/src/modeling/validation/rules.d.ts +2 -2
  70. package/build/src/modeling/validation/rules.d.ts.map +1 -1
  71. package/build/src/modeling/validation/rules.js.map +1 -1
  72. package/build/src/modeling/validation/semantic_validation.d.ts +2 -2
  73. package/build/src/modeling/validation/semantic_validation.d.ts.map +1 -1
  74. package/build/src/modeling/validation/semantic_validation.js.map +1 -1
  75. package/build/src/models/http-flows/LegacyTranslator.js +1 -1
  76. package/build/src/models/http-flows/LegacyTranslator.js.map +1 -1
  77. package/build/src/runtime/http-runner/HttpFlows.js +1 -1
  78. package/build/src/runtime/http-runner/HttpFlows.js.map +1 -1
  79. package/build/tsconfig.tsbuildinfo +1 -1
  80. package/eslint.config.js +0 -1
  81. package/package.json +11 -14
  82. package/src/events/EventTypes.ts +0 -2
  83. package/src/events/Events.ts +0 -2
  84. package/src/modeling/ApiValidation.ts +86 -0
  85. package/src/modeling/Bindings.ts +3 -3
  86. package/src/modeling/DomainAssociation.ts +5 -5
  87. package/src/modeling/DomainEntity.ts +3 -4
  88. package/src/modeling/DomainProperty.ts +3 -4
  89. package/src/modeling/DomainValidation.ts +57 -74
  90. package/src/modeling/ai/types.ts +2 -2
  91. package/src/{amf → modeling/amf}/DataValueGenerator.ts +3 -4
  92. package/src/modeling/amf/ShapeGenerator.ts +45 -61
  93. package/src/modeling/amf/core_types.ts +47 -0
  94. package/src/modeling/validation/api_model_rules.ts +1 -31
  95. package/src/modeling/validation/association_validation.ts +6 -6
  96. package/src/modeling/validation/entity_validation.ts +11 -11
  97. package/src/modeling/validation/property_validation.ts +4 -4
  98. package/src/modeling/validation/rules.ts +6 -3
  99. package/src/modeling/validation/semantic_validation.ts +11 -11
  100. package/src/models/http-flows/LegacyTranslator.ts +1 -1
  101. package/src/runtime/http-runner/HttpFlows.ts +1 -1
  102. package/tests/unit/{amf → modeling/amf}/data_value_generator.spec.ts +2 -2
  103. package/tests/unit/modeling/amf/shape_generator.spec.ts +146 -167
  104. package/tests/unit/modeling/domain_asociation.spec.ts +13 -13
  105. package/tests/unit/modeling/domain_validation.spec.ts +7 -13
  106. package/tests/unit/modeling/validation/api_model_rules.spec.ts +11 -9
  107. package/tests/unit/runtime/runners/http_assertion_runner.spec.ts +1 -1
  108. package/tests/unit/runtime/runners/http_flow_runner.spec.ts +1 -1
  109. package/tests/unit/runtime/runners/project_runner.spec.ts +1 -1
  110. package/tests/unit/runtime/runners/request_runner.spec.ts +1 -1
  111. package/tests/unit/runtime/runners/serial_runner.spec.ts +1 -1
  112. package/build/src/amf/AmfMixin.d.ts +0 -396
  113. package/build/src/amf/AmfMixin.d.ts.map +0 -1
  114. package/build/src/amf/AmfMixin.js +0 -1138
  115. package/build/src/amf/AmfMixin.js.map +0 -1
  116. package/build/src/amf/AmfSerializer.d.ts +0 -137
  117. package/build/src/amf/AmfSerializer.d.ts.map +0 -1
  118. package/build/src/amf/AmfSerializer.js +0 -1947
  119. package/build/src/amf/AmfSerializer.js.map +0 -1
  120. package/build/src/amf/AmfTypes.d.ts +0 -25
  121. package/build/src/amf/AmfTypes.d.ts.map +0 -1
  122. package/build/src/amf/AmfTypes.js +0 -143
  123. package/build/src/amf/AmfTypes.js.map +0 -1
  124. package/build/src/amf/ApiExampleGenerator.d.ts +0 -40
  125. package/build/src/amf/ApiExampleGenerator.d.ts.map +0 -1
  126. package/build/src/amf/ApiExampleGenerator.js +0 -112
  127. package/build/src/amf/ApiExampleGenerator.js.map +0 -1
  128. package/build/src/amf/ApiMonacoSchemaGenerator.d.ts +0 -68
  129. package/build/src/amf/ApiMonacoSchemaGenerator.d.ts.map +0 -1
  130. package/build/src/amf/ApiMonacoSchemaGenerator.js +0 -248
  131. package/build/src/amf/ApiMonacoSchemaGenerator.js.map +0 -1
  132. package/build/src/amf/ApiSchemaGenerator.d.ts +0 -56
  133. package/build/src/amf/ApiSchemaGenerator.d.ts.map +0 -1
  134. package/build/src/amf/ApiSchemaGenerator.js +0 -94
  135. package/build/src/amf/ApiSchemaGenerator.js.map +0 -1
  136. package/build/src/amf/ApiSchemaValues.d.ts +0 -111
  137. package/build/src/amf/ApiSchemaValues.d.ts.map +0 -1
  138. package/build/src/amf/ApiSchemaValues.js +0 -463
  139. package/build/src/amf/ApiSchemaValues.js.map +0 -1
  140. package/build/src/amf/DataValueGenerator.d.ts.map +0 -1
  141. package/build/src/amf/DataValueGenerator.js.map +0 -1
  142. package/build/src/amf/Parsing.d.ts +0 -48
  143. package/build/src/amf/Parsing.d.ts.map +0 -1
  144. package/build/src/amf/Parsing.js +0 -2
  145. package/build/src/amf/Parsing.js.map +0 -1
  146. package/build/src/amf/Utils.d.ts +0 -37
  147. package/build/src/amf/Utils.d.ts.map +0 -1
  148. package/build/src/amf/Utils.js +0 -169
  149. package/build/src/amf/Utils.js.map +0 -1
  150. package/build/src/amf/data-node/DataNodeBase.d.ts +0 -34
  151. package/build/src/amf/data-node/DataNodeBase.d.ts.map +0 -1
  152. package/build/src/amf/data-node/DataNodeBase.js +0 -77
  153. package/build/src/amf/data-node/DataNodeBase.js.map +0 -1
  154. package/build/src/amf/data-node/JsonDataNodeGenerator.d.ts +0 -15
  155. package/build/src/amf/data-node/JsonDataNodeGenerator.d.ts.map +0 -1
  156. package/build/src/amf/data-node/JsonDataNodeGenerator.js +0 -23
  157. package/build/src/amf/data-node/JsonDataNodeGenerator.js.map +0 -1
  158. package/build/src/amf/data-node/UrlEncodedDataNodeGenerator.d.ts +0 -14
  159. package/build/src/amf/data-node/UrlEncodedDataNodeGenerator.d.ts.map +0 -1
  160. package/build/src/amf/data-node/UrlEncodedDataNodeGenerator.js +0 -48
  161. package/build/src/amf/data-node/UrlEncodedDataNodeGenerator.js.map +0 -1
  162. package/build/src/amf/data-node/XmlDataNodeGenerator.d.ts +0 -22
  163. package/build/src/amf/data-node/XmlDataNodeGenerator.d.ts.map +0 -1
  164. package/build/src/amf/data-node/XmlDataNodeGenerator.js +0 -34
  165. package/build/src/amf/data-node/XmlDataNodeGenerator.js.map +0 -1
  166. package/build/src/amf/definitions/Amf.d.ts +0 -363
  167. package/build/src/amf/definitions/Amf.d.ts.map +0 -1
  168. package/build/src/amf/definitions/Amf.js +0 -3
  169. package/build/src/amf/definitions/Amf.js.map +0 -1
  170. package/build/src/amf/definitions/Api.d.ts +0 -383
  171. package/build/src/amf/definitions/Api.d.ts.map +0 -1
  172. package/build/src/amf/definitions/Api.js +0 -2
  173. package/build/src/amf/definitions/Api.js.map +0 -1
  174. package/build/src/amf/definitions/Base.d.ts +0 -12
  175. package/build/src/amf/definitions/Base.d.ts.map +0 -1
  176. package/build/src/amf/definitions/Base.js +0 -2
  177. package/build/src/amf/definitions/Base.js.map +0 -1
  178. package/build/src/amf/definitions/Namespace.d.ts +0 -327
  179. package/build/src/amf/definitions/Namespace.d.ts.map +0 -1
  180. package/build/src/amf/definitions/Namespace.js +0 -346
  181. package/build/src/amf/definitions/Namespace.js.map +0 -1
  182. package/build/src/amf/definitions/Shapes.d.ts +0 -312
  183. package/build/src/amf/definitions/Shapes.d.ts.map +0 -1
  184. package/build/src/amf/definitions/Shapes.js +0 -87
  185. package/build/src/amf/definitions/Shapes.js.map +0 -1
  186. package/build/src/amf/models/AmfDataNode.d.ts +0 -67
  187. package/build/src/amf/models/AmfDataNode.d.ts.map +0 -1
  188. package/build/src/amf/models/AmfDataNode.js +0 -192
  189. package/build/src/amf/models/AmfDataNode.js.map +0 -1
  190. package/build/src/amf/shape/ShapeBase.d.ts +0 -74
  191. package/build/src/amf/shape/ShapeBase.d.ts.map +0 -1
  192. package/build/src/amf/shape/ShapeBase.js +0 -93
  193. package/build/src/amf/shape/ShapeBase.js.map +0 -1
  194. package/build/src/amf/shape/ShapeJsonSchemaGenerator.d.ts +0 -47
  195. package/build/src/amf/shape/ShapeJsonSchemaGenerator.d.ts.map +0 -1
  196. package/build/src/amf/shape/ShapeJsonSchemaGenerator.js +0 -420
  197. package/build/src/amf/shape/ShapeJsonSchemaGenerator.js.map +0 -1
  198. package/build/src/amf/shape/ShapeXmlSchemaGenerator.d.ts +0 -85
  199. package/build/src/amf/shape/ShapeXmlSchemaGenerator.d.ts.map +0 -1
  200. package/build/src/amf/shape/ShapeXmlSchemaGenerator.js +0 -852
  201. package/build/src/amf/shape/ShapeXmlSchemaGenerator.js.map +0 -1
  202. package/build/src/events/amf/AmfEventTypes.d.ts +0 -7
  203. package/build/src/events/amf/AmfEventTypes.d.ts.map +0 -1
  204. package/build/src/events/amf/AmfEventTypes.js +0 -7
  205. package/build/src/events/amf/AmfEventTypes.js.map +0 -1
  206. package/build/src/events/amf/AmfEvents.d.ts +0 -34
  207. package/build/src/events/amf/AmfEvents.d.ts.map +0 -1
  208. package/build/src/events/amf/AmfEvents.js +0 -63
  209. package/build/src/events/amf/AmfEvents.js.map +0 -1
  210. package/build/src/mocking/RandExp.d.ts +0 -55
  211. package/build/src/mocking/RandExp.d.ts.map +0 -1
  212. package/build/src/mocking/RandExp.js +0 -302
  213. package/build/src/mocking/RandExp.js.map +0 -1
  214. package/build/src/mocking/lib/ret.d.ts +0 -16
  215. package/build/src/mocking/lib/ret.d.ts.map +0 -1
  216. package/build/src/mocking/lib/ret.js +0 -284
  217. package/build/src/mocking/lib/ret.js.map +0 -1
  218. package/data/apis/APIC-187/APIC-187.raml +0 -21
  219. package/data/apis/APIC-187/dataType.raml +0 -132
  220. package/data/apis/APIC-187/example.raml +0 -84
  221. package/data/apis/APIC-188/APIC-188.raml +0 -21
  222. package/data/apis/APIC-188/dataType.raml +0 -132
  223. package/data/apis/APIC-188/example.raml +0 -84
  224. package/data/apis/APIC-233/APIC-233.raml +0 -15
  225. package/data/apis/APIC-391/APIC-391.raml +0 -44
  226. package/data/apis/APIC-391/examples/post-body-request-example.raml +0 -7
  227. package/data/apis/APIC-483/APIC-483.raml +0 -16
  228. package/data/apis/APIC-483/example/list-of-bank-succ.json +0 -32
  229. package/data/apis/APIC-483/schema/response-retrieve-list-bank.json +0 -68
  230. package/data/apis/APIC-487/APIC-487.raml +0 -36
  231. package/data/apis/APIC-655/APIC-655.raml +0 -44
  232. package/data/apis/APIC-655/delivery.json +0 -12
  233. package/data/apis/APIC-689/APIC-689.raml +0 -20
  234. package/data/apis/APIC-690/APIC-690.raml +0 -17
  235. package/data/apis/APIC-690/datatypes/Address.raml +0 -10
  236. package/data/apis/APIC-690/datatypes/Customer.raml +0 -17
  237. package/data/apis/APIC-690/examples/CustomerExample2.raml +0 -17
  238. package/data/apis/APIC-690/examples/CustomersExample.raml +0 -34
  239. package/data/apis/SE-10469/Purchase-Order-oagis-id-dd32f9c6c01048a19e15c423c9c741ae.json +0 -1383
  240. package/data/apis/SE-10469/SE-10469.raml +0 -11
  241. package/data/apis/SE-13092/Examples/PersonExample.raml +0 -7
  242. package/data/apis/SE-13092/SE-13092.raml +0 -37
  243. package/data/apis/SE-13092/datatypes/Address.raml +0 -5
  244. package/data/apis/SE-13092/datatypes/InlineType.raml +0 -5
  245. package/data/apis/SE-13092/datatypes/Person.raml +0 -15
  246. package/data/apis/SE-22063/SE-22063.raml +0 -14
  247. package/data/apis/SE-22063/stock.raml +0 -41
  248. package/data/apis/amf-helper-api/amf-helper-api.raml +0 -1024
  249. package/data/apis/amf-helper-api/examples/comment-example.json +0 -42
  250. package/data/apis/amf-helper-api/examples/commentCreateRequest-example.json +0 -7
  251. package/data/apis/amf-helper-api/examples/commentList-example.json +0 -48
  252. package/data/apis/amf-helper-api/examples/person.json +0 -14
  253. package/data/apis/amf-helper-api/examples/person.raml +0 -13
  254. package/data/apis/amf-helper-api/examples/person.xml +0 -14
  255. package/data/apis/amf-helper-api/libraries/comment-lib.raml +0 -143
  256. package/data/apis/amf-helper-api/library.raml +0 -7
  257. package/data/apis/amf-helper-api/schemas/person.json +0 -104
  258. package/data/apis/amf-helper-api/schemas/person.xsd +0 -26
  259. package/data/apis/amf-helper-api/traits/file.raml +0 -33
  260. package/data/apis/amf-helper-api/traits/pagination.raml +0 -80
  261. package/data/apis/amf-helper-api/traits/results.raml +0 -19
  262. package/data/apis/amf-helper-api/traits/visibility.raml +0 -14
  263. package/data/apis/amf-helper-api/types/app-person.raml +0 -101
  264. package/data/apis/amf-helper-api/types/dimensions.raml +0 -24
  265. package/data/apis/amf-helper-api/types/external-type.raml +0 -7
  266. package/data/apis/amf-helper-api/types/image.raml +0 -23
  267. package/data/apis/amf-helper-api/types/product.raml +0 -52
  268. package/data/apis/amf-helper-api/types/resource.raml +0 -11
  269. package/data/apis/amf-helper-api/types/standard-request.raml +0 -50
  270. package/data/apis/amf-helper-api/types/user.raml +0 -37
  271. package/data/apis/arc-demo-api/arc-demo-api.raml +0 -468
  272. package/data/apis/arc-demo-api/examples/e400.xml +0 -4
  273. package/data/apis/arc-demo-api/examples/e401.xml +0 -4
  274. package/data/apis/arc-demo-api/examples/e404.xml +0 -4
  275. package/data/apis/arc-demo-api/examples/image.xml +0 -5
  276. package/data/apis/arc-demo-api/examples/messages-example.json +0 -22
  277. package/data/apis/arc-demo-api/examples/messages-sent-example.json +0 -15
  278. package/data/apis/arc-demo-api/examples/person.json +0 -14
  279. package/data/apis/arc-demo-api/examples/person.url.encoded +0 -1
  280. package/data/apis/arc-demo-api/examples/person.xml +0 -14
  281. package/data/apis/arc-demo-api/examples/product.xml +0 -9
  282. package/data/apis/arc-demo-api/library.raml +0 -36
  283. package/data/apis/arc-demo-api/resourceTypes/app-person.raml +0 -49
  284. package/data/apis/arc-demo-api/resourceTypes/example-types.raml +0 -45
  285. package/data/apis/arc-demo-api/resourceTypes/image.raml +0 -23
  286. package/data/apis/arc-demo-api/resourceTypes/message-sent-type.raml +0 -23
  287. package/data/apis/arc-demo-api/resourceTypes/message-type.raml +0 -33
  288. package/data/apis/arc-demo-api/resourceTypes/product.raml +0 -52
  289. package/data/apis/arc-demo-api/resourceTypes/resource.raml +0 -11
  290. package/data/apis/arc-demo-api/schemas/error-response.xsd +0 -11
  291. package/data/apis/arc-demo-api/schemas/image.xsd +0 -11
  292. package/data/apis/arc-demo-api/schemas/person.json +0 -104
  293. package/data/apis/arc-demo-api/schemas/person.xsd +0 -26
  294. package/data/apis/arc-demo-api/schemas/product.xsd +0 -17
  295. package/data/apis/arc-demo-api/securitySchemes/basic.raml +0 -5
  296. package/data/apis/arc-demo-api/securitySchemes/oauth_2_0.raml +0 -29
  297. package/data/apis/arc-demo-api/securitySchemes/x-custom.raml +0 -26
  298. package/data/apis/arc-demo-api/traits/adminable.raml +0 -23
  299. package/data/apis/arc-demo-api/traits/pagination.raml +0 -83
  300. package/data/apis/arc-demo-api/traits/rate-limited.raml +0 -9
  301. package/data/apis/async-api/async-api.yaml +0 -96
  302. package/data/apis/example-generator-api/contact-email-example.raml +0 -6
  303. package/data/apis/example-generator-api/contact-example.raml +0 -5
  304. package/data/apis/example-generator-api/contact-fax-example.raml +0 -5
  305. package/data/apis/example-generator-api/contact-website-example.raml +0 -2
  306. package/data/apis/example-generator-api/example-1.raml +0 -6
  307. package/data/apis/example-generator-api/example-2.raml +0 -9
  308. package/data/apis/example-generator-api/example-3.raml +0 -4
  309. package/data/apis/example-generator-api/example-4.raml +0 -2
  310. package/data/apis/example-generator-api/example-5.raml +0 -4
  311. package/data/apis/example-generator-api/example-6.raml +0 -2
  312. package/data/apis/example-generator-api/example-7.raml +0 -5
  313. package/data/apis/example-generator-api/example-generator-api.raml +0 -423
  314. package/data/apis/example-generator-api/example.json +0 -14
  315. package/data/apis/example-generator-api/example.xml +0 -15
  316. package/data/apis/example-generator-api/example.xsd +0 -26
  317. package/data/apis/example-generator-api/examples/employee.raml +0 -7
  318. package/data/apis/example-generator-api/examples/employees.raml +0 -7
  319. package/data/apis/example-generator-api/linked-named-example.raml +0 -21
  320. package/data/apis/example-generator-api/named-example-with-link.raml +0 -5
  321. package/data/apis/example-generator-api/named-example.raml +0 -9
  322. package/data/apis/example-generator-api/user-json-example.raml +0 -17
  323. package/data/apis/example-generator-api/user-raml-example.raml +0 -37
  324. package/data/apis/example-generator-api/user.json +0 -8
  325. package/data/apis/example-generator-api/user.raml +0 -18
  326. package/data/apis/example-generator-api/users-json-example.raml +0 -17
  327. package/data/apis/example-generator-api/users-raml-example.raml +0 -32
  328. package/data/apis/example-generator-api/users.json +0 -8
  329. package/data/apis/expanded-api/expanded-api.raml +0 -8
  330. package/data/apis/flattened-api/flattened-api.raml +0 -8
  331. package/data/apis/multiple-servers/multiple-servers.yaml +0 -112
  332. package/data/apis/oas-3-api/oas-3-api.yaml +0 -356
  333. package/data/apis/oas-date/oas-date.yaml +0 -28
  334. package/data/apis/oas-types/oas-types.yaml +0 -159
  335. package/data/apis/oas-unions/oas-unions.yaml +0 -75
  336. package/data/apis/petstore/petstore.yaml +0 -954
  337. package/data/apis/raml-date/raml-date.raml +0 -28
  338. package/data/apis/recursive/recursive.raml +0 -14
  339. package/data/apis/schema-api/examples/person.json +0 -14
  340. package/data/apis/schema-api/examples/person.raml +0 -14
  341. package/data/apis/schema-api/examples/person.url.encoded +0 -1
  342. package/data/apis/schema-api/examples/person.xml +0 -14
  343. package/data/apis/schema-api/library/demo-types.raml +0 -43
  344. package/data/apis/schema-api/schema-api.raml +0 -656
  345. package/data/apis/schema-api/schemas/person.json +0 -104
  346. package/data/apis/schema-api/schemas/person.xsd +0 -26
  347. package/data/apis/schema-api/types/DemoPerson.raml +0 -67
  348. package/data/apis/secured-api/oauth-2-custom-settings.raml +0 -143
  349. package/data/apis/secured-api/oauth2-header-delivery.raml +0 -13
  350. package/data/apis/secured-api/oauth2-no-delivery.raml +0 -8
  351. package/data/apis/secured-api/oauth2-no-grants.raml +0 -12
  352. package/data/apis/secured-api/oauth2-pkce.raml +0 -13
  353. package/data/apis/secured-api/oauth2-query-delivery.raml +0 -13
  354. package/data/apis/secured-api/oauth_1_0.raml +0 -8
  355. package/data/apis/secured-api/oauth_1_0_no-settings.raml +0 -3
  356. package/data/apis/secured-api/oauth_1_0_no-signature.raml +0 -7
  357. package/data/apis/secured-api/oauth_1_0_signature.raml +0 -8
  358. package/data/apis/secured-api/passthrough-querystring.raml +0 -16
  359. package/data/apis/secured-api/passthrough.raml +0 -24
  360. package/data/apis/secured-api/secured-api.raml +0 -231
  361. package/data/apis/secured-api/x-custom.raml +0 -33
  362. package/data/apis/secured-api/x-other.raml +0 -29
  363. package/data/apis/secured-api/x-query-string.raml +0 -16
  364. package/data/apis/tracked-examples/datatypes/employee.raml +0 -5
  365. package/data/apis/tracked-examples/examples/employee.raml +0 -4
  366. package/data/apis/tracked-examples/examples/employees.raml +0 -8
  367. package/data/apis/tracked-examples/tracked-to-linked.raml +0 -28
  368. package/data/model.js +0 -129
  369. package/data/models/APIC-187.json +0 -11416
  370. package/data/models/APIC-188.json +0 -11416
  371. package/data/models/APIC-233.json +0 -539
  372. package/data/models/APIC-391.json +0 -1903
  373. package/data/models/APIC-483.json +0 -3110
  374. package/data/models/APIC-487.json +0 -1225
  375. package/data/models/APIC-655.json +0 -3145
  376. package/data/models/APIC-689.json +0 -797
  377. package/data/models/APIC-690.json +0 -5992
  378. package/data/models/SE-10469.json +0 -22898
  379. package/data/models/SE-13092.json +0 -2769
  380. package/data/models/SE-22063.json +0 -2314
  381. package/data/models/amf-helper-api.json +0 -84457
  382. package/data/models/arc-demo-api.json +0 -52041
  383. package/data/models/async-api.json +0 -3227
  384. package/data/models/example-generator-api.json +0 -45209
  385. package/data/models/expanded-api.json +0 -251
  386. package/data/models/flattened-api.json +0 -251
  387. package/data/models/multiple-servers.json +0 -2769
  388. package/data/models/oas-3-api.json +0 -10590
  389. package/data/models/oas-date.json +0 -637
  390. package/data/models/oas-types.json +0 -5352
  391. package/data/models/oas-unions.json +0 -1935
  392. package/data/models/petstore.json +0 -27712
  393. package/data/models/raml-date.json +0 -1114
  394. package/data/models/recursive.json +0 -610
  395. package/data/models/schema-api.json +0 -35527
  396. package/data/models/secured-api.json +0 -21071
  397. package/data/models/tracked-to-linked.json +0 -1914
  398. package/src/amf/AmfMixin.ts +0 -1726
  399. package/src/amf/AmfSerializer.ts +0 -2358
  400. package/src/amf/AmfTypes.ts +0 -147
  401. package/src/amf/ApiExampleGenerator.ts +0 -122
  402. package/src/amf/ApiMonacoSchemaGenerator.ts +0 -332
  403. package/src/amf/ApiSchemaGenerator.ts +0 -115
  404. package/src/amf/ApiSchemaValues.ts +0 -509
  405. package/src/amf/Parsing.ts +0 -50
  406. package/src/amf/Utils.ts +0 -172
  407. package/src/amf/data-node/DataNodeBase.ts +0 -83
  408. package/src/amf/data-node/JsonDataNodeGenerator.ts +0 -24
  409. package/src/amf/data-node/README.md +0 -3
  410. package/src/amf/data-node/UrlEncodedDataNodeGenerator.ts +0 -49
  411. package/src/amf/data-node/XmlDataNodeGenerator.ts +0 -46
  412. package/src/amf/definitions/Amf.ts +0 -440
  413. package/src/amf/definitions/Api.ts +0 -445
  414. package/src/amf/definitions/Base.ts +0 -13
  415. package/src/amf/definitions/Namespace.ts +0 -357
  416. package/src/amf/definitions/Shapes.ts +0 -438
  417. package/src/amf/models/AmfDataNode.ts +0 -210
  418. package/src/amf/shape/README.md +0 -4
  419. package/src/amf/shape/ShapeBase.ts +0 -174
  420. package/src/amf/shape/ShapeJsonSchemaGenerator.ts +0 -457
  421. package/src/amf/shape/ShapeXmlSchemaGenerator.ts +0 -933
  422. package/src/events/amf/AmfEventTypes.ts +0 -6
  423. package/src/events/amf/AmfEvents.ts +0 -78
  424. package/src/mocking/RandExp.ts +0 -335
  425. package/src/mocking/lib/ret.ts +0 -279
  426. package/tests/unit/amf/APIC-187.spec.ts +0 -41
  427. package/tests/unit/amf/APIC-188.spec.ts +0 -30
  428. package/tests/unit/amf/APIC-233.spec.ts +0 -32
  429. package/tests/unit/amf/APIC-391.spec.ts +0 -39
  430. package/tests/unit/amf/APIC-487.spec.ts +0 -44
  431. package/tests/unit/amf/APIC-655.spec.ts +0 -41
  432. package/tests/unit/amf/APIC-689.spec.ts +0 -28
  433. package/tests/unit/amf/APIC-690.spec.ts +0 -93
  434. package/tests/unit/amf/AmfLoader.ts +0 -538
  435. package/tests/unit/amf/AmfMixin.spec.ts +0 -1707
  436. package/tests/unit/amf/ApiExampleGenerator.spec.ts +0 -250
  437. package/tests/unit/amf/ApiMonacoSchemaGenerator.spec.ts +0 -183
  438. package/tests/unit/amf/ApiSchemaValues.spec.ts +0 -602
  439. package/tests/unit/amf/Namepsace.spec.ts +0 -494
  440. package/tests/unit/amf/SE-10469.spec.ts +0 -35
  441. package/tests/unit/amf/SE-13092.spec.ts +0 -64
  442. package/tests/unit/amf/SE-22063.spec.ts +0 -45
  443. package/tests/unit/amf/raml-examples.spec.ts +0 -43
  444. package/tests/unit/amf/schema_gen_array.spec.ts +0 -199
  445. package/tests/unit/amf/schema_gen_oas.spec.ts +0 -140
  446. package/tests/unit/amf/schema_gen_object.spec.ts +0 -279
  447. package/tests/unit/amf/schema_gen_scalar.spec.ts +0 -143
  448. package/tests/unit/amf/schema_gen_union.spec.ts +0 -401
  449. package/tests/unit/amf/schema_gen_unknown.spec.ts +0 -42
  450. package/tests/unit/amf/schema_gen_xml.spec.ts +0 -726
  451. package/tests/unit/amf/serializer/APIC-483.spec.ts +0 -36
  452. package/tests/unit/amf/serializer/Anotations.spec.ts +0 -50
  453. package/tests/unit/amf/serializer/Api.spec.ts +0 -210
  454. package/tests/unit/amf/serializer/Documentation.spec.ts +0 -52
  455. package/tests/unit/amf/serializer/Endpoints.spec.ts +0 -172
  456. package/tests/unit/amf/serializer/Operations.spec.ts +0 -330
  457. package/tests/unit/amf/serializer/Parameters.spec.ts +0 -149
  458. package/tests/unit/amf/serializer/PayloadExamples.spec.ts +0 -152
  459. package/tests/unit/amf/serializer/Security.spec.ts +0 -626
  460. package/tests/unit/amf/serializer/Server.spec.ts +0 -78
  461. package/tests/unit/amf/serializer/Shapes.spec.ts +0 -304
  462. package/tests/unit/amf/serializer/SourceMaps.spec.ts +0 -52
  463. package/tests/unit/amf/shapes/ShapeXmlSchemaGenerator.spec.ts +0 -28
  464. package/tests/unit/amf/tracked-to-linked.spec.ts +0 -90
  465. package/tests/unit/amf/xml-data-processing.spec.ts +0 -217
  466. package/tests/unit/events/amf.spec.ts +0 -151
@@ -1 +1 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OG;IACO,oBAAoB,CAAC,EAAU,EAAE,KAAkB;QAC3D,MAAM,MAAM,GAAG,UAAU,CAAC,EAAE,CAAC,CAAA;QAC7B,MAAM,CAAC,KAAK,GAAG,KAAK,CAAA;QACpB,OAAO,MAAM,CAAA;IACf,CAAC;CACF","sourcesContent":["import { type AssociationBindings, type PropertyWebBindings } from '../Bindings.js'\nimport type { DomainAssociation } from '../DomainAssociation.js'\nimport type { DomainProperty } from '../DomainProperty.js'\nimport type { DomainEntity } from '../DomainEntity.js'\nimport { IAmfExampleTypes, modelTypeToAmfDataType } from '../../amf/AmfTypes.js'\nimport { AmfNamespace } from '../../amf/definitions/Namespace.js'\nimport {\n anyShape,\n arrayShape,\n fileShape,\n IApiAnyShape,\n IApiArrayShape,\n IApiDataExample,\n IApiFileShape,\n IApiNodeShape,\n IApiPropertyShape,\n IApiRecursiveShape,\n IApiScalarShape,\n IApiShape,\n IApiUnionShape,\n IShapeUnion,\n nodeShape,\n propertyShape,\n recursiveShape,\n scalarShape,\n unionShape,\n} from '../../amf/definitions/Shapes.js'\nimport { AmfDataNode } from '../../amf/models/AmfDataNode.js'\nimport { DataValueGenerator } from '../../amf/DataValueGenerator.js'\nimport { nanoid } from '../../nanoid.js'\nimport { DomainEntityKind, DomainPropertyKind } from '../../models/kinds.js'\nimport type { PropertySchema } from '../types.js'\n\nconst UNION_TYPE_ANY_OF = 'anyOf'\nconst UNION_TYPE_ALL_OF = 'allOf'\nconst UNION_TYPE_ONE_OF = 'oneOf'\nconst UNION_TYPE_NOT = 'not'\nconst DATA_TYPE_STRING = 'string'\nconst DATA_TYPE_BINARY = 'binary'\n\n/**\n * Serializes Data Domain elements (DomainEntity, DomainProperty, DomainAssociation)\n * to AMF shapes.\n *\n * This class provides a mechanism to translate a data domain model, defined using\n * custom classes like `DomainEntity`, `DomainProperty`, and `DomainAssociation`,\n * into AMF (API Modeling Framework) shapes. AMF shapes are a standardized way\n * to represent API structures and data models, enabling interoperability and tooling.\n *\n * This is particularly useful when you have a custom data model and need to\n * generate API definitions (e.g., RAML or OAS) from it.\n *\n * **Key Features:**\n *\n * - **Data Domain to AMF Translation:** Converts data domain elements into\n * their corresponding AMF shape representations.\n * - **Recursive Shape Handling:** Detects and handles recursive relationships\n * within the data model to prevent infinite loops during shape generation.\n * - **Union Type Support:** Supports the creation of union types in AMF\n * to represent associations that can point to multiple different entity types.\n * - **Binding Integration:** Leverages binding information (e.g., web bindings)\n * to customize the generated AMF shapes based on the target API format.\n * - **Example and Default Value Generation:** Integrates with a `DataValueGenerator`\n * to automatically generate example values and default values for properties\n * within the AMF shapes.\n *\n * **Usage:**\n *\n * 1. Create an instance of the `ShapeGenerator`.\n * 2. Call the appropriate method (e.g., `entity()`, `property()`, `associationShape()`)\n * to generate the AMF shape for a specific data domain element.\n * 3. The returned AMF shape can then be used with other AMF tools to generate\n * API definitions or perform other API-related tasks.\n */\nexport class ShapeGenerator {\n #valueGenerator?: DataValueGenerator\n\n /**\n * Used with data domain value generation for entity properties.\n * Lazily loaded class only when functions are used.\n * This needs to be a class instances because some functions are incremental\n */\n get valueGenerator(): DataValueGenerator {\n // we need a new instance of the generator for each shape generation\n // as the generator is stateful and we need to reset it for each shape.\n if (!this.#valueGenerator) {\n this.#valueGenerator = new DataValueGenerator()\n }\n return this.#valueGenerator\n }\n\n /**\n * Serializes a `DomainEntity` to an AMF node shape.\n *\n * This method is the entry point for converting a `DomainEntity` into its\n * AMF representation. It handles recursive relationships, property serialization,\n * and inheritance from parent entities.\n *\n * @param input The `DomainEntity` to serialize.\n * @param visited A `Set` of keys of already generated entities. This prevents\n * recursive shape generation and avoids infinite loops. Defaults to a new empty `Set`.\n * @returns An `IApiNodeShape` or `IApiRecursiveShape` representing the entity in AMF.\n * Returns a `IApiRecursiveShape` if a recursive loop is detected.\n * @example\n * ```typescript\n * const generator = new ShapeGenerator();\n * const amfShape = generator.entity(myDomainEntity);\n * ```\n */\n entity(input: DomainEntity, visited = new Set<string>()): IApiNodeShape | IApiRecursiveShape {\n if (visited.has(input.key)) {\n // create a recursive shape.\n return this.createRecursiveShape(input)\n }\n visited.add(input.key)\n const result = nodeShape(input.key)\n result.id = input.key\n this.updateBaseProperties(input, result)\n result.properties = []\n for (const item of input.listProperties()) {\n // we check whether the property is hidden.\n // This is not happening when calling the `property()` because this method\n // always returns the AMF shape.\n const wb = item.readBinding('web') as PropertyWebBindings | undefined\n if (wb && wb.hidden) {\n continue\n }\n const shape = this.property(item)\n result.properties.push(shape)\n }\n for (const assoc of input.listAssociations()) {\n const wb = assoc.readBinding('web') as AssociationBindings | undefined\n if (wb && wb.hidden) {\n continue\n }\n const prop = this.associationProperty(assoc, visited)\n result.properties.push(prop)\n }\n for (const parent of input.listParents()) {\n const shape = this.entity(parent, visited)\n result.inherits.push(shape)\n }\n return result\n }\n\n /**\n * Serializes a `DomainProperty` to an AMF property shape.\n *\n * This method converts a `DomainProperty` into an `IApiPropertyShape`,\n * defining its characteristics such as data type, required status, and\n * range (the shape of the property's value).\n *\n * @param input The `DomainProperty` to serialize.\n * @returns An `IApiPropertyShape` representing the property in AMF.\n * @example\n * ```typescript\n * const generator = new ShapeGenerator();\n * const amfShape = generator.property(myDomainProperty);\n * ```\n */\n property(input: DomainProperty): IApiPropertyShape {\n const { required, key } = input\n const result = propertyShape(key)\n result.path = `${AmfNamespace.aml.vocabularies.data.key}${input.info.name}`\n if (required) {\n result.minCount = 1\n }\n result.range = this.getRange(input)\n\n // for example, Example generator needs to know the name of the property\n // as it does not look into the \"range\" object.\n this.updateBaseProperties(input, result)\n\n // sync the name of the property shape with the range, in case it was changed by the bindings\n if (result.range.name) {\n result.name = result.range.name\n }\n return result\n }\n\n /**\n * Serializes a `DomainAssociation` to an AMF property shape, handling the\n * association's target entity or entities.\n *\n * This method is similar to `property()`, but it specifically handles\n * associations between entities. It determines the range of the property\n * based on the association's target(s) and generates the appropriate\n * AMF shape (e.g., a scalar shape for a linked schema, a union shape for\n * multiple targets).\n *\n * @param input The `DomainAssociation` to serialize.\n * @param visited A `Set` of keys of already generated entities. This prevents\n * recursive shape generation and avoids infinite loops. Defaults to a new empty `Set`.\n * @returns An `IApiPropertyShape` representing the association in AMF.\n * @example\n * ```typescript\n * const generator = new ShapeGenerator();\n * const amfShape = generator.associationProperty(myDomainAssociation);\n * ```\n */\n associationProperty(input: DomainAssociation, visited: Set<string> = new Set<string>()): IApiPropertyShape {\n const { required, key } = input\n const result = propertyShape(key)\n result.path = `${AmfNamespace.aml.vocabularies.data.key}${input.info.name}`\n if (required) {\n result.minCount = 1\n }\n result.range = this.associationShape(input, visited)\n\n this.updateBaseProperties(input, result)\n return result\n }\n\n /**\n * Generates a shape for an association. Most likely you want to use the `associationProperty()` method instead.\n *\n * @param input The data association instance.\n * @param visited A `Set` of keys of already generated entities. This prevents\n * recursive shape generation and avoids infinite loops. Defaults to a new empty `Set`.\n * @returns The range value for the PropertyShape.\n */\n associationShape(input: DomainAssociation, visited: Set<string> = new Set<string>()): IShapeUnion | undefined {\n const schema = input.schema\n if (schema && schema.linked) {\n return this.createLinkedShape(input)\n }\n const items = this.associationUnion(input, visited)\n if (!items) {\n return\n }\n if (Array.isArray(items)) {\n return this.createUnionShape(input, items)\n }\n const unionType = (schema && schema.unionType) || UNION_TYPE_ANY_OF\n if (unionType === UNION_TYPE_NOT) {\n // Need to investigate more about \"not\" union type.\n // AMF supports it, but I am not sure how to handle it.\n const wrapper = anyShape(input.key)\n wrapper.id = `not-shape-${input.key}`\n wrapper.not = items\n return wrapper\n }\n if (input.multiple) {\n return this.refactorShapeToArray(input.key, items)\n }\n return items\n }\n\n /**\n * @param input The data association instance.\n * @returns An AMF API scalar shape with the link to the schema.\n */\n protected createLinkedShape(input: DomainAssociation): IApiScalarShape {\n // This is a link to the schema. In an API that would be the id\n // of a resource to request the data from.\n const range = scalarShape(input.key)\n range.id = `link-${input.key}`\n range.dataType = modelTypeToAmfDataType(DATA_TYPE_STRING)\n return range\n }\n\n protected createUnionShape(input: DomainAssociation, items: IShapeUnion[]): IApiUnionShape | IApiArrayShape {\n const range = unionShape(input.key)\n this.updateBaseProperties(input, range)\n range.anyOf = []\n const unionType = (input.schema && input.schema.unionType) || UNION_TYPE_ANY_OF\n if (unionType === UNION_TYPE_ANY_OF) {\n range.anyOf = items\n } else if (unionType === UNION_TYPE_ALL_OF) {\n range.and = items\n } else if (unionType === UNION_TYPE_ONE_OF) {\n range.xone = items\n } else {\n // the \"not\" union type only supports a single schema.\n // I am not sure how this should be handled. Will take the first one\n // for now.\n range.not = items[0]\n }\n if (input.multiple) {\n return this.refactorShapeToArray(input.key, range)\n }\n return range\n }\n\n /**\n * Generates a shape list for an union. Most likely you want to use the `associationProperty()` method instead.\n *\n * @param input The data association instance.\n * @returns The range value for the PropertyShape.\n */\n associationUnion(\n input: DomainAssociation,\n visited: Set<string> = new Set<string>()\n ): IShapeUnion | IShapeUnion[] | undefined {\n const result: IShapeUnion[] = []\n for (const item of input.listTargets()) {\n result.push(this.entity(item, visited))\n }\n if (!result.length) {\n return undefined\n }\n if (result.length > 1) {\n return result\n }\n return result[0]\n }\n\n /**\n * The DomainProperty may have both the `schema` and the `bindings`. For AMF shape we read `schema` for\n * default value, examples, and enum values. We also look for the `web`\n * bindings for more detailed definition of a shape.\n *\n * @param input\n */\n protected getRange(input: DomainProperty): IApiArrayShape | IApiFileShape | IApiScalarShape {\n const bindings = input.readBinding('web') as PropertyWebBindings | undefined\n let schema: PropertySchema | undefined\n if (input.schema) {\n schema = input.schema\n }\n const { multiple, type } = input\n if (multiple) {\n return this.createArrayShape(input, schema, bindings)\n }\n if (type === DATA_TYPE_BINARY) {\n return this.createFileShape(input, bindings)\n }\n return this.createScalarShape(input, schema, bindings)\n }\n\n /**\n * Normally this would be part of generating a scalar schema but the the property is an array this\n * is generated on the array and not on the range.\n *\n * @param result The scalar or array shape.\n * @param schema The property schema\n * @param type The data type of the parent property as set on the `range`\n * @param isArray Whether the DomainProperty is multiple\n */\n protected setShapeSchema(\n input: DomainProperty,\n result: IApiAnyShape,\n schema: PropertySchema,\n type: string,\n isArray?: boolean\n ): void {\n if (schema.defaultValue) {\n const { type: dfFormat } = schema.defaultValue\n const { value } = schema.defaultValue\n if (dfFormat === 'function') {\n const tmp = this.valueGenerator.generate(value, input.type)\n if (tmp !== DataValueGenerator.noValue) {\n const dt = AmfDataNode.scalar(tmp as string, dfFormat)\n result.defaultValue = dt.toJSON()\n }\n } else {\n const dt = AmfDataNode.scalar(value, type)\n result.defaultValue = dt.toJSON()\n }\n }\n if (Array.isArray(schema.enum)) {\n result.values = schema.enum.map((i) => AmfDataNode.scalar(i, type).toJSON())\n }\n if (Array.isArray(schema.examples)) {\n if (isArray) {\n result.examples = this.createArrayExamples(schema.examples, type)\n } else {\n result.examples = this.createExamples(schema.examples, type)\n }\n }\n }\n\n protected createArrayShape(\n input: DomainProperty,\n schema?: PropertySchema,\n bindings?: PropertyWebBindings\n ): IApiArrayShape {\n const result = arrayShape(input.key)\n const { type } = input\n if (type === DATA_TYPE_BINARY) {\n // we do not pass schema to the range generator as we set schema's properties on the array shape.\n result.items = this.createFileShape(input, bindings)\n } else {\n result.items = this.createScalarShape(input, undefined, bindings)\n }\n if (schema) {\n const type = (result.items as IApiScalarShape).dataType as string\n this.setShapeSchema(input, result, schema, type, input.multiple)\n }\n return result\n }\n\n protected createScalarShape(\n input: DomainProperty,\n schema?: PropertySchema,\n bindings?: PropertyWebBindings\n ): IApiScalarShape {\n const result = scalarShape(input.key)\n this.updateBaseProperties(input, result)\n this.setScalarCommonProperties(result, input, bindings)\n if (!result.dataType) {\n result.dataType = modelTypeToAmfDataType(input.type, bindings)\n }\n if (schema) {\n this.setShapeSchema(input, result, schema, result.dataType as string, input.multiple)\n }\n return result\n }\n\n protected createExamples(examples: string[], type: string): IApiDataExample[] {\n const result: IApiDataExample[] = []\n for (const current of examples) {\n const item: IApiDataExample = {\n id: nanoid(),\n customDomainProperties: [],\n strict: true,\n types: IAmfExampleTypes,\n structuredValue: AmfDataNode.scalar(current, type).toJSON(),\n }\n result.push(item)\n }\n return result\n }\n\n protected createArrayExamples(examples: string[], type: string): IApiDataExample[] {\n const item: IApiDataExample = {\n id: nanoid(),\n customDomainProperties: [],\n strict: true,\n types: IAmfExampleTypes,\n }\n const value = new AmfDataNode('array')\n for (const item of examples) {\n const member = AmfDataNode.scalar(item, type)\n value.addMember(member)\n }\n item.structuredValue = value.toJSON()\n return [item]\n }\n\n protected createFileShape(input: DomainProperty, bindings?: PropertyWebBindings): IApiFileShape {\n const result = fileShape(input.key)\n this.updateBaseProperties(input, result)\n if (bindings) {\n if (Array.isArray(bindings.fileTypes)) {\n result.fileTypes = bindings.fileTypes\n }\n this.setScalarCommonProperties(result, input, bindings)\n if (bindings.format === 'base64') {\n result.format = AmfNamespace.w3.xmlSchema.base64Binary\n }\n }\n return result\n }\n\n protected setScalarCommonProperties(\n result: IApiFileShape | IApiScalarShape,\n input: DomainProperty,\n bindings?: PropertyWebBindings\n ): void {\n if (bindings?.name) {\n result.name = bindings.name\n }\n if (bindings?.xml) {\n result.xmlSerialization = bindings.xml\n }\n const { schema, type } = input\n if (schema) {\n if (schema.pattern) {\n result.pattern = schema.pattern\n }\n if (typeof schema.multipleOf === 'number') {\n result.multipleOf = schema.multipleOf\n }\n if (typeof schema.minimum === 'number') {\n if (type === DATA_TYPE_STRING) {\n result.minLength = schema.minimum\n } else {\n result.minimum = schema.minimum\n }\n }\n if (typeof schema.maximum === 'number') {\n if (type === DATA_TYPE_STRING) {\n result.maxLength = schema.maximum\n } else {\n result.maximum = schema.maximum\n }\n }\n if (typeof schema.exclusiveMinimum === 'boolean') {\n result.exclusiveMinimum = schema.exclusiveMinimum\n }\n if (typeof schema.exclusiveMaximum === 'boolean') {\n result.exclusiveMaximum = schema.exclusiveMaximum\n }\n }\n if (bindings?.format) {\n switch (bindings.format) {\n case 'base64':\n result.format = AmfNamespace.w3.xmlSchema.base64Binary\n break\n case 'double':\n result.format = AmfNamespace.w3.xmlSchema.double\n break\n case 'float':\n result.format = AmfNamespace.w3.xmlSchema.float\n break\n case 'int32':\n result.format = AmfNamespace.w3.xmlSchema.integer\n break\n case 'int64':\n result.format = AmfNamespace.w3.xmlSchema.integer\n break\n }\n // result.format = bindings.format\n }\n if (typeof input.readOnly === 'boolean') {\n result.readOnly = input.readOnly\n }\n if (typeof input.writeOnly === 'boolean') {\n result.writeOnly = input.writeOnly\n }\n }\n\n protected updateBaseProperties(input: DomainProperty | DomainAssociation | DomainEntity, target: IApiShape): void {\n target.name = input.info.name\n target.displayName = input.info.displayName\n target.description = input.info.description\n if (input.kind === DomainPropertyKind) {\n target.deprecated = (input as DomainProperty).deprecated\n } else if (input.kind === DomainEntityKind) {\n target.deprecated = (input as DomainEntity).deprecated\n }\n }\n\n protected createRecursiveShape(input: DomainEntity): IApiRecursiveShape {\n return recursiveShape(input.key, input.key)\n }\n\n /**\n * Translates the shape to an array shape. This happens when data model property\n * is changed from 'multiple' to not-multiple and back.\n *\n * @param id The key of the parameter or an association\n * @param shape The shape to wrap as an array.\n * @returns Array shape.\n */\n protected refactorShapeToArray(id: string, shape: IShapeUnion): IApiArrayShape {\n const result = arrayShape(id)\n result.items = shape\n return result\n }\n}\n"]}
1
+ {"version":3,"file":"ShapeGenerator.js","sourceRoot":"","sources":["../../../../src/modeling/amf/ShapeGenerator.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AACxD,OAAO,EAAE,YAAY,EAAe,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACrG,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAG5E,MAAM,iBAAiB,GAAG,OAAO,CAAA;AACjC,MAAM,iBAAiB,GAAG,OAAO,CAAA;AACjC,MAAM,iBAAiB,GAAG,OAAO,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KAAK,SAAS,EAAE,CAAC;YACzC,MAAM,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAA;QACpC,CAAC;IACH,CAAC;IAES,oBAAoB,CAC5B,KAAwD,EACxD,MAAwB;QAExB,MAAM,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAA;QAC7B,MAAM,CAAC,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,WAAW,CAAA;QAC3C,MAAM,CAAC,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,WAAW,CAAA;QAC3C,IAAI,KAAK,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;YACtC,MAAM,CAAC,UAAU,GAAI,KAAwB,CAAC,UAAU,CAAA;QAC1D,CAAC;aAAM,IAAI,KAAK,CAAC,IAAI,KAAK,gBAAgB,EAAE,CAAC;YAC3C,MAAM,CAAC,UAAU,GAAI,KAAsB,CAAC,UAAU,CAAA;QACxD,CAAC;IACH,CAAC;IAES,oBAAoB,CAAC,KAAmB;QAChD,OAAO,YAAY,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,CAAA;IAC1D,CAAC;IAED;;;;;;;OAOG;IACO,oBAAoB,CAAC,EAAU,EAAE,KAAyB;QAClE,MAAM,MAAM,GAAG,YAAY,CAAC,UAAU,CAAC,EAAE,CAAC,CAAA;QAC1C,MAAM,CAAC,KAAK,GAAG,KAAK,CAAA;QACpB,OAAO,MAAM,CAAA;IACf,CAAC;CACF","sourcesContent":["import { type AssociationBindings, type PropertyWebBindings } from '../Bindings.js'\nimport type { DomainAssociation } from '../DomainAssociation.js'\nimport type { DomainProperty } from '../DomainProperty.js'\nimport type { DomainEntity } from '../DomainEntity.js'\nimport { modelTypeToAmfDataType } from './core_types.js'\nimport { AmfNamespace, type Shapes, AmfDataNode, AmfTypes, ShapeHelpers } from '@api-client/amf-core'\nimport { DataValueGenerator } from './DataValueGenerator.js'\nimport { nanoid } from '../../nanoid.js'\nimport { DomainEntityKind, DomainPropertyKind } from '../../models/kinds.js'\nimport type { PropertySchema } from '../types.js'\n\nconst UNION_TYPE_ANY_OF = 'anyOf'\nconst UNION_TYPE_ALL_OF = 'allOf'\nconst UNION_TYPE_ONE_OF = 'oneOf'\nconst UNION_TYPE_NOT = 'not'\nconst DATA_TYPE_STRING = 'string'\nconst DATA_TYPE_BINARY = 'binary'\n\n/**\n * Serializes Data Domain elements (DomainEntity, DomainProperty, DomainAssociation)\n * to AMF shapes.\n *\n * This class provides a mechanism to translate a data domain model, defined using\n * custom classes like `DomainEntity`, `DomainProperty`, and `DomainAssociation`,\n * into AMF (API Modeling Framework) shapes. AMF shapes are a standardized way\n * to represent API structures and data models, enabling interoperability and tooling.\n *\n * This is particularly useful when you have a custom data model and need to\n * generate API definitions (e.g., RAML or OAS) from it.\n *\n * **Key Features:**\n *\n * - **Data Domain to AMF Translation:** Converts data domain elements into\n * their corresponding AMF shape representations.\n * - **Recursive Shape Handling:** Detects and handles recursive relationships\n * within the data model to prevent infinite loops during shape generation.\n * - **Union Type Support:** Supports the creation of union types in AMF\n * to represent associations that can point to multiple different entity types.\n * - **Binding Integration:** Leverages binding information (e.g., web bindings)\n * to customize the generated AMF shapes based on the target API format.\n * - **Example and Default Value Generation:** Integrates with a `DataValueGenerator`\n * to automatically generate example values and default values for properties\n * within the AMF shapes.\n *\n * **Usage:**\n *\n * 1. Create an instance of the `ShapeGenerator`.\n * 2. Call the appropriate method (e.g., `entity()`, `property()`, `associationShape()`)\n * to generate the AMF shape for a specific data domain element.\n * 3. The returned AMF shape can then be used with other AMF tools to generate\n * API definitions or perform other API-related tasks.\n */\nexport class ShapeGenerator {\n #valueGenerator?: DataValueGenerator\n\n /**\n * Used with data domain value generation for entity properties.\n * Lazily loaded class only when functions are used.\n * This needs to be a class instances because some functions are incremental\n */\n get valueGenerator(): DataValueGenerator {\n // we need a new instance of the generator for each shape generation\n // as the generator is stateful and we need to reset it for each shape.\n if (!this.#valueGenerator) {\n this.#valueGenerator = new DataValueGenerator()\n }\n return this.#valueGenerator\n }\n\n /**\n * Serializes a `DomainEntity` to an AMF node shape.\n *\n * This method is the entry point for converting a `DomainEntity` into its\n * AMF representation. It handles recursive relationships, property serialization,\n * and inheritance from parent entities.\n *\n * @param input The `DomainEntity` to serialize.\n * @param visited A `Set` of keys of already generated entities. This prevents\n * recursive shape generation and avoids infinite loops. Defaults to a new empty `Set`.\n * @returns An `IApiNodeShape` or `IApiRecursiveShape` representing the entity in AMF.\n * Returns a `IApiRecursiveShape` if a recursive loop is detected.\n * @example\n * ```typescript\n * const generator = new ShapeGenerator();\n * const amfShape = generator.entity(myDomainEntity);\n * ```\n */\n entity(input: DomainEntity, visited = new Set<string>()): Shapes.IApiNodeShape | Shapes.IApiRecursiveShape {\n if (visited.has(input.key)) {\n // create a recursive shape.\n return this.createRecursiveShape(input)\n }\n visited.add(input.key)\n const result = ShapeHelpers.nodeShape(input.key)\n result.id = input.key\n this.updateBaseProperties(input, result)\n result.properties = []\n for (const item of input.listProperties()) {\n // we check whether the property is hidden.\n // This is not happening when calling the `property()` because this method\n // always returns the AMF shape.\n const wb = item.readBinding('web') as PropertyWebBindings | undefined\n if (wb && wb.hidden) {\n continue\n }\n const shape = this.property(item)\n result.properties.push(shape)\n }\n for (const assoc of input.listAssociations()) {\n const wb = assoc.readBinding('web') as AssociationBindings | undefined\n if (wb && wb.hidden) {\n continue\n }\n const prop = this.associationProperty(assoc, visited)\n result.properties.push(prop)\n }\n for (const parent of input.listParents()) {\n const shape = this.entity(parent, visited)\n result.inherits.push(shape)\n }\n return result\n }\n\n /**\n * Serializes a `DomainProperty` to an AMF property shape.\n *\n * This method converts a `DomainProperty` into an `IApiPropertyShape`,\n * defining its characteristics such as data type, required status, and\n * range (the shape of the property's value).\n *\n * @param input The `DomainProperty` to serialize.\n * @returns An `IApiPropertyShape` representing the property in AMF.\n * @example\n * ```typescript\n * const generator = new ShapeGenerator();\n * const amfShape = generator.property(myDomainProperty);\n * ```\n */\n property(input: DomainProperty): Shapes.IApiPropertyShape {\n const { required, key } = input\n const result = ShapeHelpers.propertyShape(key)\n result.path = `${AmfNamespace.aml.vocabularies.data.key}${input.info.name}`\n if (required) {\n result.minCount = 1\n }\n result.range = this.getRange(input)\n\n // for example, Example generator needs to know the name of the property\n // as it does not look into the \"range\" object.\n this.updateBaseProperties(input, result)\n\n // sync the name of the property shape with the range, in case it was changed by the bindings\n if (result.range.name) {\n result.name = result.range.name\n }\n return result\n }\n\n /**\n * Serializes a `DomainAssociation` to an AMF property shape, handling the\n * association's target entity or entities.\n *\n * This method is similar to `property()`, but it specifically handles\n * associations between entities. It determines the range of the property\n * based on the association's target(s) and generates the appropriate\n * AMF shape (e.g., a scalar shape for a linked schema, a union shape for\n * multiple targets).\n *\n * @param input The `DomainAssociation` to serialize.\n * @param visited A `Set` of keys of already generated entities. This prevents\n * recursive shape generation and avoids infinite loops. Defaults to a new empty `Set`.\n * @returns An `IApiPropertyShape` representing the association in AMF.\n * @example\n * ```typescript\n * const generator = new ShapeGenerator();\n * const amfShape = generator.associationProperty(myDomainAssociation);\n * ```\n */\n associationProperty(input: DomainAssociation, visited: Set<string> = new Set<string>()): Shapes.IApiPropertyShape {\n const { required, key } = input\n const result = ShapeHelpers.propertyShape(key)\n result.path = `${AmfNamespace.aml.vocabularies.data.key}${input.info.name}`\n if (required) {\n result.minCount = 1\n }\n result.range = this.associationShape(input, visited)\n\n this.updateBaseProperties(input, result)\n return result\n }\n\n /**\n * Generates a shape for an association. Most likely you want to use the `associationProperty()` method instead.\n *\n * @param input The data association instance.\n * @param visited A `Set` of keys of already generated entities. This prevents\n * recursive shape generation and avoids infinite loops. Defaults to a new empty `Set`.\n * @returns The range value for the PropertyShape.\n */\n associationShape(input: DomainAssociation, visited: Set<string> = new Set<string>()): Shapes.IShapeUnion | undefined {\n const schema = input.schema\n if (schema && schema.linked) {\n return this.createLinkedShape(input)\n }\n const items = this.associationUnion(input, visited)\n if (!items) {\n return\n }\n if (Array.isArray(items)) {\n return this.createUnionShape(input, items)\n }\n const unionType = (schema && schema.unionType) || UNION_TYPE_ANY_OF\n if (unionType === UNION_TYPE_NOT) {\n // Need to investigate more about \"not\" union type.\n // AMF supports it, but I am not sure how to handle it.\n const wrapper = ShapeHelpers.anyShape(input.key)\n wrapper.id = `not-shape-${input.key}`\n wrapper.not = items\n return wrapper\n }\n if (input.multiple) {\n return this.refactorShapeToArray(input.key, items)\n }\n return items\n }\n\n /**\n * @param input The data association instance.\n * @returns An AMF API scalar shape with the link to the schema.\n */\n protected createLinkedShape(input: DomainAssociation): Shapes.IApiScalarShape {\n // This is a link to the schema. In an API that would be the id\n // of a resource to request the data from.\n const range = ShapeHelpers.scalarShape(input.key)\n range.id = `link-${input.key}`\n range.dataType = modelTypeToAmfDataType(DATA_TYPE_STRING)\n return range\n }\n\n protected createUnionShape(\n input: DomainAssociation,\n items: Shapes.IShapeUnion[]\n ): Shapes.IApiUnionShape | Shapes.IApiArrayShape {\n const range = ShapeHelpers.unionShape(input.key)\n this.updateBaseProperties(input, range)\n range.anyOf = []\n const unionType = (input.schema && input.schema.unionType) || UNION_TYPE_ANY_OF\n if (unionType === UNION_TYPE_ANY_OF) {\n range.anyOf = items\n } else if (unionType === UNION_TYPE_ALL_OF) {\n range.and = items\n } else if (unionType === UNION_TYPE_ONE_OF) {\n range.xone = items\n } else {\n // the \"not\" union type only supports a single schema.\n // I am not sure how this should be handled. Will take the first one\n // for now.\n range.not = items[0]\n }\n if (input.multiple) {\n return this.refactorShapeToArray(input.key, range)\n }\n return range\n }\n\n /**\n * Generates a shape list for an union. Most likely you want to use the `associationProperty()` method instead.\n *\n * @param input The data association instance.\n * @returns The range value for the PropertyShape.\n */\n associationUnion(\n input: DomainAssociation,\n visited: Set<string> = new Set<string>()\n ): Shapes.IShapeUnion | Shapes.IShapeUnion[] | undefined {\n const result: Shapes.IShapeUnion[] = []\n for (const item of input.listTargets()) {\n result.push(this.entity(item, visited))\n }\n if (!result.length) {\n return undefined\n }\n if (result.length > 1) {\n return result\n }\n return result[0]\n }\n\n /**\n * The DomainProperty may have both the `schema` and the `bindings`. For AMF shape we read `schema` for\n * default value, examples, and enum values. We also look for the `web`\n * bindings for more detailed definition of a shape.\n *\n * @param input\n */\n protected getRange(input: DomainProperty): Shapes.IApiArrayShape | Shapes.IApiFileShape | Shapes.IApiScalarShape {\n const bindings = input.readBinding('web') as PropertyWebBindings | undefined\n let schema: PropertySchema | undefined\n if (input.schema) {\n schema = input.schema\n }\n const { multiple, type } = input\n if (multiple) {\n return this.createArrayShape(input, schema, bindings)\n }\n if (type === DATA_TYPE_BINARY) {\n return this.createFileShape(input, bindings)\n }\n return this.createScalarShape(input, schema, bindings)\n }\n\n /**\n * Normally this would be part of generating a scalar schema but the the property is an array this\n * is generated on the array and not on the range.\n *\n * @param result The scalar or array shape.\n * @param schema The property schema\n * @param type The data type of the parent property as set on the `range`\n * @param isArray Whether the DomainProperty is multiple\n */\n protected setShapeSchema(\n input: DomainProperty,\n result: Shapes.IApiAnyShape,\n schema: PropertySchema,\n type: string,\n isArray?: boolean\n ): void {\n if (schema.defaultValue) {\n const { type: dfFormat } = schema.defaultValue\n const { value } = schema.defaultValue\n if (dfFormat === 'function') {\n const tmp = this.valueGenerator.generate(value, input.type)\n if (tmp !== DataValueGenerator.noValue) {\n const dt = AmfDataNode.scalar(tmp as string, dfFormat)\n result.defaultValue = dt.toJSON()\n }\n } else {\n const dt = AmfDataNode.scalar(value, type)\n result.defaultValue = dt.toJSON()\n }\n }\n if (Array.isArray(schema.enum)) {\n result.values = schema.enum.map((i) => AmfDataNode.scalar(i, type).toJSON())\n }\n if (Array.isArray(schema.examples)) {\n if (isArray) {\n result.examples = this.createArrayExamples(schema.examples, type)\n } else {\n result.examples = this.createExamples(schema.examples, type)\n }\n }\n }\n\n protected createArrayShape(\n input: DomainProperty,\n schema?: PropertySchema,\n bindings?: PropertyWebBindings\n ): Shapes.IApiArrayShape {\n const result = ShapeHelpers.arrayShape(input.key)\n const { type } = input\n if (type === DATA_TYPE_BINARY) {\n // we do not pass schema to the range generator as we set schema's properties on the array shape.\n result.items = this.createFileShape(input, bindings)\n } else {\n result.items = this.createScalarShape(input, undefined, bindings)\n }\n if (schema) {\n const type = (result.items as Shapes.IApiScalarShape).dataType as string\n this.setShapeSchema(input, result, schema, type, input.multiple)\n }\n return result\n }\n\n protected createScalarShape(\n input: DomainProperty,\n schema?: PropertySchema,\n bindings?: PropertyWebBindings\n ): Shapes.IApiScalarShape {\n const result = ShapeHelpers.scalarShape(input.key)\n this.updateBaseProperties(input, result)\n this.setScalarCommonProperties(result, input, bindings)\n if (!result.dataType) {\n result.dataType = modelTypeToAmfDataType(input.type, bindings)\n }\n if (schema) {\n this.setShapeSchema(input, result, schema, result.dataType as string, input.multiple)\n }\n return result\n }\n\n protected createExamples(examples: string[], type: string): Shapes.IApiDataExample[] {\n const result: Shapes.IApiDataExample[] = []\n for (const current of examples) {\n const item: Shapes.IApiDataExample = {\n id: nanoid(),\n customDomainProperties: [],\n strict: true,\n types: [...AmfTypes.IAmfExampleTypes],\n structuredValue: AmfDataNode.scalar(current, type).toJSON(),\n }\n result.push(item)\n }\n return result\n }\n\n protected createArrayExamples(examples: string[], type: string): Shapes.IApiDataExample[] {\n const item: Shapes.IApiDataExample = {\n id: nanoid(),\n customDomainProperties: [],\n strict: true,\n types: [...AmfTypes.IAmfExampleTypes],\n }\n const value = new AmfDataNode('array')\n for (const item of examples) {\n const member = AmfDataNode.scalar(item, type)\n value.addMember(member)\n }\n item.structuredValue = value.toJSON()\n return [item]\n }\n\n protected createFileShape(input: DomainProperty, bindings?: PropertyWebBindings): Shapes.IApiFileShape {\n const result = ShapeHelpers.fileShape(input.key)\n this.updateBaseProperties(input, result)\n if (bindings) {\n if (Array.isArray(bindings.fileTypes)) {\n result.fileTypes = bindings.fileTypes\n }\n this.setScalarCommonProperties(result, input, bindings)\n if (bindings.format === 'base64') {\n result.format = AmfNamespace.w3.xmlSchema.base64Binary\n }\n }\n return result\n }\n\n protected setScalarCommonProperties(\n result: Shapes.IApiFileShape | Shapes.IApiScalarShape,\n input: DomainProperty,\n bindings?: PropertyWebBindings\n ): void {\n if (bindings?.name) {\n result.name = bindings.name\n }\n if (bindings?.xml) {\n result.xmlSerialization = bindings.xml\n }\n const { schema, type } = input\n if (schema) {\n if (schema.pattern) {\n result.pattern = schema.pattern\n }\n if (typeof schema.multipleOf === 'number') {\n result.multipleOf = schema.multipleOf\n }\n if (typeof schema.minimum === 'number') {\n if (type === DATA_TYPE_STRING) {\n result.minLength = schema.minimum\n } else {\n result.minimum = schema.minimum\n }\n }\n if (typeof schema.maximum === 'number') {\n if (type === DATA_TYPE_STRING) {\n result.maxLength = schema.maximum\n } else {\n result.maximum = schema.maximum\n }\n }\n if (typeof schema.exclusiveMinimum === 'boolean') {\n result.exclusiveMinimum = schema.exclusiveMinimum\n }\n if (typeof schema.exclusiveMaximum === 'boolean') {\n result.exclusiveMaximum = schema.exclusiveMaximum\n }\n }\n if (bindings?.format) {\n switch (bindings.format) {\n case 'base64':\n result.format = AmfNamespace.w3.xmlSchema.base64Binary\n break\n case 'double':\n result.format = AmfNamespace.w3.xmlSchema.double\n break\n case 'float':\n result.format = AmfNamespace.w3.xmlSchema.float\n break\n case 'int32':\n result.format = AmfNamespace.w3.xmlSchema.integer\n break\n case 'int64':\n result.format = AmfNamespace.w3.xmlSchema.integer\n break\n }\n // result.format = bindings.format\n }\n if (typeof input.readOnly === 'boolean') {\n result.readOnly = input.readOnly\n }\n if (typeof input.writeOnly === 'boolean') {\n result.writeOnly = input.writeOnly\n }\n }\n\n protected updateBaseProperties(\n input: DomainProperty | DomainAssociation | DomainEntity,\n target: Shapes.IApiShape\n ): void {\n target.name = input.info.name\n target.displayName = input.info.displayName\n target.description = input.info.description\n if (input.kind === DomainPropertyKind) {\n target.deprecated = (input as DomainProperty).deprecated\n } else if (input.kind === DomainEntityKind) {\n target.deprecated = (input as DomainEntity).deprecated\n }\n }\n\n protected createRecursiveShape(input: DomainEntity): Shapes.IApiRecursiveShape {\n return ShapeHelpers.recursiveShape(input.key, input.key)\n }\n\n /**\n * Translates the shape to an array shape. This happens when data model property\n * is changed from 'multiple' to not-multiple and back.\n *\n * @param id The key of the parameter or an association\n * @param shape The shape to wrap as an array.\n * @returns Array shape.\n */\n protected refactorShapeToArray(id: string, shape: Shapes.IShapeUnion): Shapes.IApiArrayShape {\n const result = ShapeHelpers.arrayShape(id)\n result.items = shape\n return result\n }\n}\n"]}
@@ -0,0 +1,9 @@
1
+ import { PropertyWebBindings } from '../Bindings.js';
2
+ import { DomainPropertyType } from '../DataFormat.js';
3
+ /**
4
+ * Translates the DomainProperty type to an AMF data type.
5
+ * @param type The property data type
6
+ * @returns AMF shape dataType
7
+ */
8
+ export declare function modelTypeToAmfDataType(type: DomainPropertyType, bindings?: PropertyWebBindings): string;
9
+ //# sourceMappingURL=core_types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core_types.d.ts","sourceRoot":"","sources":["../../../../src/modeling/amf/core_types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAGrD;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,kBAAkB,EAAE,QAAQ,CAAC,EAAE,mBAAmB,GAAG,MAAM,CAqCvG"}
@@ -0,0 +1,45 @@
1
+ import { AmfNamespace } from '@api-client/amf-core';
2
+ /**
3
+ * Translates the DomainProperty type to an AMF data type.
4
+ * @param type The property data type
5
+ * @returns AMF shape dataType
6
+ */
7
+ export function modelTypeToAmfDataType(type, bindings) {
8
+ if (type === 'number') {
9
+ if (bindings?.format === 'int32' || bindings?.format === 'int64') {
10
+ return AmfNamespace.w3.xmlSchema.integer;
11
+ }
12
+ return AmfNamespace.w3.xmlSchema.number;
13
+ }
14
+ if (type === 'boolean') {
15
+ return AmfNamespace.aml.vocabularies.shapes.boolean;
16
+ }
17
+ if (type === 'date') {
18
+ return AmfNamespace.w3.xmlSchema.date;
19
+ }
20
+ if (type === 'datetime') {
21
+ return AmfNamespace.w3.xmlSchema.dateTime;
22
+ }
23
+ if (type === 'time') {
24
+ return AmfNamespace.aml.vocabularies.shapes.dateTimeOnly;
25
+ }
26
+ if (type === 'binary' && bindings && bindings.format === 'base64') {
27
+ return AmfNamespace.w3.xmlSchema.base64Binary;
28
+ }
29
+ return AmfNamespace.w3.xmlSchema.string;
30
+ // switch (type) {
31
+ // // case 'nil':
32
+ // // return AmfNamespace.aml.vocabularies.shapes.nil
33
+ // // case 'any':
34
+ // // return AmfNamespace.aml.vocabularies.shapes.AnyShape
35
+ // default:
36
+ // if (type === 'binary' && bindings && bindings.format === 'base64') {
37
+ // return AmfNamespace.w3.xmlSchema.base64Binary
38
+ // }
39
+ // // if (bindings && bindings.format === 'binary') {
40
+ // // return AmfNamespace.w3.xmlSchema.base64Binary
41
+ // // }
42
+ // return AmfNamespace.w3.xmlSchema.string
43
+ // }
44
+ }
45
+ //# sourceMappingURL=core_types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core_types.js","sourceRoot":"","sources":["../../../../src/modeling/amf/core_types.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAEnD;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAwB,EAAE,QAA8B;IAC7F,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;QACtB,IAAI,QAAQ,EAAE,MAAM,KAAK,OAAO,IAAI,QAAQ,EAAE,MAAM,KAAK,OAAO,EAAE,CAAC;YACjE,OAAO,YAAY,CAAC,EAAE,CAAC,SAAS,CAAC,OAAO,CAAA;QAC1C,CAAC;QACD,OAAO,YAAY,CAAC,EAAE,CAAC,SAAS,CAAC,MAAM,CAAA;IACzC,CAAC;IACD,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,CAAA;IACrD,CAAC;IACD,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;QACpB,OAAO,YAAY,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,CAAA;IACvC,CAAC;IACD,IAAI,IAAI,KAAK,UAAU,EAAE,CAAC;QACxB,OAAO,YAAY,CAAC,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAA;IAC3C,CAAC;IACD,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;QACpB,OAAO,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,YAAY,CAAA;IAC1D,CAAC;IACD,IAAI,IAAI,KAAK,QAAQ,IAAI,QAAQ,IAAI,QAAQ,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;QAClE,OAAO,YAAY,CAAC,EAAE,CAAC,SAAS,CAAC,YAAY,CAAA;IAC/C,CAAC;IACD,OAAO,YAAY,CAAC,EAAE,CAAC,SAAS,CAAC,MAAM,CAAA;IACvC,kBAAkB;IAClB,mBAAmB;IACnB,yDAAyD;IACzD,mBAAmB;IACnB,8DAA8D;IAC9D,aAAa;IACb,2EAA2E;IAC3E,sDAAsD;IACtD,QAAQ;IACR,yDAAyD;IACzD,yDAAyD;IACzD,WAAW;IACX,8CAA8C;IAC9C,IAAI;AACN,CAAC","sourcesContent":["import { PropertyWebBindings } from '../Bindings.js'\nimport { DomainPropertyType } from '../DataFormat.js'\nimport { AmfNamespace } from '@api-client/amf-core'\n\n/**\n * Translates the DomainProperty type to an AMF data type.\n * @param type The property data type\n * @returns AMF shape dataType\n */\nexport function modelTypeToAmfDataType(type: DomainPropertyType, bindings?: PropertyWebBindings): string {\n if (type === 'number') {\n if (bindings?.format === 'int32' || bindings?.format === 'int64') {\n return AmfNamespace.w3.xmlSchema.integer\n }\n return AmfNamespace.w3.xmlSchema.number\n }\n if (type === 'boolean') {\n return AmfNamespace.aml.vocabularies.shapes.boolean\n }\n if (type === 'date') {\n return AmfNamespace.w3.xmlSchema.date\n }\n if (type === 'datetime') {\n return AmfNamespace.w3.xmlSchema.dateTime\n }\n if (type === 'time') {\n return AmfNamespace.aml.vocabularies.shapes.dateTimeOnly\n }\n if (type === 'binary' && bindings && bindings.format === 'base64') {\n return AmfNamespace.w3.xmlSchema.base64Binary\n }\n return AmfNamespace.w3.xmlSchema.string\n // switch (type) {\n // // case 'nil':\n // // return AmfNamespace.aml.vocabularies.shapes.nil\n // // case 'any':\n // // return AmfNamespace.aml.vocabularies.shapes.AnyShape\n // default:\n // if (type === 'binary' && bindings && bindings.format === 'base64') {\n // return AmfNamespace.w3.xmlSchema.base64Binary\n // }\n // // if (bindings && bindings.format === 'binary') {\n // // return AmfNamespace.w3.xmlSchema.base64Binary\n // // }\n // return AmfNamespace.w3.xmlSchema.string\n // }\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import type { ApiModel } from '../ApiModel.js';
2
2
  import type { ExposedEntity } from '../ExposedEntity.js';
3
3
  import type { Action } from '../actions/Action.js';
4
- import type { ApiModelValidationItem, ApiModelValidationResult } from '../types.js';
4
+ import type { ApiModelValidationItem } from '../types.js';
5
5
  /**
6
6
  * Validates the core properties and metadata of an ApiModel.
7
7
  */
@@ -11,5 +11,4 @@ export declare function validateApiModelSecurity(model: ApiModel): ApiModelValid
11
11
  export declare function validateApiModelMetadata(model: ApiModel): ApiModelValidationItem[];
12
12
  export declare function validateAction(action: Action, parent: ExposedEntity, apiModelKey: string): ApiModelValidationItem[];
13
13
  export declare function validateExposedEntity(entity: ExposedEntity, apiModel: ApiModel): ApiModelValidationItem[];
14
- export declare function validateApiModel(model: ApiModel): ApiModelValidationResult;
15
14
  //# sourceMappingURL=api_model_rules.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"api_model_rules.d.ts","sourceRoot":"","sources":["../../../../src/modeling/validation/api_model_rules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAA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AgB,0BAA0B,CAAC,KAAK,EAAE,QAAQ,GAAG,sBAAsB,EAAE,CA+BpF;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,QAAQ,GAAG,sBAAsB,EAAE,CAuKlF;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,QAAQ,GAAG,sBAAsB,EAAE,CAuElF;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,GAAG,sBAAsB,EAAE,CA2FnH;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,GAAG,sBAAsB,EAAE,CAsKzG"}
@@ -570,30 +570,4 @@ export function validateExposedEntity(entity, apiModel) {
570
570
  }
571
571
  return issues;
572
572
  }
573
- export function validateApiModel(model) {
574
- const issues = [];
575
- issues.push(...validateApiModelInfo(model));
576
- issues.push(...validateApiModelDependency(model));
577
- issues.push(...validateApiModelSecurity(model));
578
- issues.push(...validateApiModelMetadata(model));
579
- if (!model.exposes || model.exposes.size === 0) {
580
- issues.push({
581
- code: createCode('API', 'NO_EXPOSURES'),
582
- message: 'Your API currently has no exposed data for external clients to request.',
583
- suggestion: 'Expose a data model so apps can communicate with it.',
584
- severity: 'warning',
585
- context: { apiModelKey: model.key, kind: ApiModelKind, key: model.key, property: 'exposes' },
586
- });
587
- }
588
- else {
589
- for (const exposure of model.exposes.values()) {
590
- issues.push(...validateExposedEntity(exposure, model));
591
- }
592
- }
593
- const hasErrors = issues.some((i) => i.severity === 'error');
594
- return {
595
- isValid: !hasErrors,
596
- issues,
597
- };
598
- }
599
573
  //# sourceMappingURL=api_model_rules.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"api_model_rules.js","sourceRoot":"","sources":["../../../../src/modeling/validation/api_model_rules.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,OAAO,EAAE,YAAY,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CAAC,KAAK,CAAC,CAAC,CAAA;IAE/C,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;QAC/C,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,UAAU,CAAC,KAAK,EAAE,cAAc,CAAC;YACvC,OAAO,EAAE,yEAAyE;YAClF,UAAU,EAAE,sDAAsD;YAClE,QAAQ,EAAE,SAAS;YACnB,OAAO,EAAE,EAAE,WAAW,EAAE,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAE;SAC7F,CAAC,CAAA;IACJ,CAAC;SAAM,CAAC;QACN,KAAK,MAAM,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;YAC9C,MAAM,CAAC,IAAI,CAAC,GAAG,qBAAqB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAA;QACxD,CAAC;IACH,CAAC;IAED,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAA;IAE5D,OAAO;QACL,OAAO,EAAE,CAAC,SAAS;QACnB,MAAM;KACP,CAAA;AACH,CAAC","sourcesContent":["import type { ApiModel } from '../ApiModel.js'\nimport type { ExposedEntity } from '../ExposedEntity.js'\nimport type { Action } from '../actions/Action.js'\nimport { ListAction } from '../actions/ListAction.js'\nimport { DeleteAction } from '../actions/DeleteAction.js'\nimport { UpdateAction } from '../actions/UpdateAction.js'\nimport { SearchAction } from '../actions/SearchAction.js'\nimport type { RolesBasedAccessControl, UsernamePasswordConfiguration } from '../types.js'\nimport type { ApiModelValidationItem, ApiModelValidationResult, ApiModelValidationContext } from '../types.js'\nimport { ApiModelKind, ExposedEntityKind } from '../../models/kinds.js'\nimport { SemanticType } from '../Semantics.js'\n\n/**\n * Creates a unique validation code.\n * @param entity The entity type (e.g., 'API', 'EXPOSURE', 'ACTION')\n * @param issue The issue identifier (e.g., 'MISSING_NAME')\n */\nfunction createCode(entity: string, issue: string): string {\n return `${entity}_${issue}`\n}\n\n/**\n * Validates the core properties and metadata of an ApiModel.\n */\nexport function validateApiModelInfo(model: ApiModel): ApiModelValidationItem[] {\n const issues: ApiModelValidationItem[] = []\n const context: ApiModelValidationContext = {\n apiModelKey: model.key,\n kind: ApiModelKind,\n key: model.key,\n }\n\n if (model.kind !== ApiModelKind) {\n issues.push({\n code: createCode('API', 'INVALID_KIND'),\n message: 'The API model type is incorrect.',\n suggestion: 'Set the model type to \"ApiModel\".',\n severity: 'error',\n context: { ...context, property: 'kind' },\n })\n }\n\n if (!model.key || typeof model.key !== 'string' || model.key.trim() === '') {\n issues.push({\n code: createCode('API', 'MISSING_KEY'),\n message: 'The API model is missing a unique identifier.',\n suggestion: 'Provide a valid name to use as a unique identifier.',\n severity: 'error',\n context: { ...context, property: 'key' },\n })\n }\n\n if (!model.info || !model.info.name || model.info.name.trim() === '') {\n issues.push({\n code: createCode('API', 'MISSING_NAME'),\n message: 'The API model has no defined name.',\n suggestion: 'Provide a descriptive name for your API.',\n severity: 'error',\n context: { ...context, property: 'info.name' },\n })\n }\n\n if (!model.info || !model.info.description || model.info.description.trim() === '') {\n issues.push({\n code: createCode('API', 'MISSING_DESCRIPTION'),\n message: 'Adding a description helps others understand your API.',\n suggestion: 'Add a description to clarify the purpose of this API.',\n severity: 'warning',\n context: { ...context, property: 'info.description' },\n })\n }\n\n return issues\n}\n\nexport function validateApiModelDependency(model: ApiModel): ApiModelValidationItem[] {\n const issues: ApiModelValidationItem[] = []\n const context: ApiModelValidationContext = {\n apiModelKey: model.key,\n kind: ApiModelKind,\n key: model.key,\n }\n\n const domain = model.domain\n if (!domain) {\n issues.push({\n code: createCode('API', 'MISSING_DOMAIN'),\n message: 'No Data Domain is attached to the API.',\n suggestion: 'Select a Data Domain from the settings to power your API.',\n severity: 'error',\n context,\n })\n return issues // Can't validate version if it doesn't exist\n }\n\n if (!domain.info || !domain.info.version) {\n issues.push({\n code: createCode('API', 'MISSING_DOMAIN_VERSION'),\n message: 'The selected Data Domain is missing a version number.',\n suggestion: 'Specify a version for the attached Data Domain.',\n severity: 'error',\n context,\n })\n }\n\n return issues\n}\n\nexport function validateApiModelSecurity(model: ApiModel): ApiModelValidationItem[] {\n const issues: ApiModelValidationItem[] = []\n const context: ApiModelValidationContext = {\n apiModelKey: model.key,\n kind: ApiModelKind,\n key: model.key,\n }\n\n // Resolve User target\n const userEntity = model.domain && model.user ? model.domain.findEntity(model.user.key, model.user.domain) : undefined\n\n // Authentication\n if (!model.authentication) {\n issues.push({\n code: createCode('API', 'MISSING_AUTHENTICATION'),\n message: 'The API is missing authentication settings.',\n suggestion: 'Go to the security settings and configure how users authenticate.',\n severity: 'error',\n context: { ...context, property: 'authentication' },\n })\n } else if (model.authentication.strategy === 'UsernamePassword') {\n const auth = model.authentication as UsernamePasswordConfiguration\n if (!auth.passwordKey) {\n issues.push({\n code: createCode('API', 'MISSING_PASSWORD_KEY'),\n message: 'Username & Password authentication requires a specific field for the password.',\n suggestion:\n 'Select which field in your user profile should store the password. ' +\n 'The data domain model should have a password data semantic on that property.',\n severity: 'error',\n context: { ...context, property: 'authentication.passwordKey' },\n })\n } else if (userEntity) {\n const passwordProp = Array.from(userEntity.properties).find((p) => p.key === auth.passwordKey)\n if (passwordProp && !passwordProp.hasSemantic(SemanticType.Password)) {\n issues.push({\n code: createCode('API', 'MISSING_PASSWORD_SEMANTIC'),\n message: 'The selected password field is missing the Password data semantic.',\n suggestion: 'Go to the Data Modeler and add the \"Password\" semantic to this property.',\n severity: 'error',\n context: { ...context, property: 'authentication.passwordKey' },\n })\n }\n }\n\n if (userEntity) {\n const hasUsernameSemantic = Array.from(userEntity.properties).some(\n (p) => typeof p.hasSemantic === 'function' && p.hasSemantic(SemanticType.Username)\n )\n if (!hasUsernameSemantic) {\n issues.push({\n code: createCode('API', 'MISSING_USERNAME_SEMANTIC'),\n message: 'Username & Password authentication requires a field with the Username data semantic.',\n suggestion: 'Go to the Data Modeler and add the \"Username\" semantic to the property used for login.',\n severity: 'error',\n context: { ...context, property: 'user' },\n })\n }\n }\n }\n\n // Authorization\n if (!model.authorization) {\n issues.push({\n code: createCode('API', 'MISSING_AUTHORIZATION'),\n message: 'The API is missing authorization settings.',\n suggestion: 'Go to the security settings and configure how to handle user permissions.',\n severity: 'error',\n context: { ...context, property: 'authorization' },\n })\n } else if (model.authorization.strategy === 'RBAC') {\n const rbac = model.authorization as RolesBasedAccessControl\n if (!rbac.roleKey) {\n issues.push({\n code: createCode('API', 'MISSING_ROLE_KEY'),\n message: 'Role-based access control is selected but no role field has been defined.',\n suggestion: \"Select which field in your user profile determines the user's role.\",\n severity: 'error',\n context: { ...context, property: 'authorization.roleKey' },\n })\n } else if (userEntity) {\n const roleProp = Array.from(userEntity.properties).find((p) => p.key === rbac.roleKey)\n if (roleProp && !roleProp.hasSemantic(SemanticType.UserRole)) {\n issues.push({\n code: createCode('API', 'MISSING_ROLE_SEMANTIC'),\n message: 'The selected role field is missing the User Role data semantic.',\n suggestion: 'Go to the Data Modeler and add the \"User Role\" semantic to this property.',\n severity: 'error',\n context: { ...context, property: 'authorization.roleKey' },\n })\n }\n }\n }\n\n // Session\n if (!model.session) {\n issues.push({\n code: createCode('API', 'MISSING_SESSION'),\n message: 'The API is missing session configuration.',\n suggestion: 'Configure how user sessions will be handled.',\n severity: 'error',\n context: { ...context, property: 'session' },\n })\n } else {\n if (!model.session.secret) {\n issues.push({\n code: createCode('API', 'MISSING_SESSION_SECRET'),\n message: 'A secure encryption key is required for sessions.',\n suggestion: 'Provide a strong security key in the session settings.',\n severity: 'error',\n context: { ...context, property: 'session.secret' },\n })\n }\n\n if (!model.session.properties || model.session.properties.length === 0) {\n issues.push({\n code: createCode('API', 'MISSING_SESSION_PROPERTIES'),\n message: 'The session token needs to include at least one piece of user information, like an ID.',\n suggestion: 'Select fields that should be stored securely inside the session payload.',\n severity: 'error',\n context: { ...context, property: 'session.properties' },\n })\n } else if (model.authorization && model.authorization.strategy === 'RBAC') {\n const rbac = model.authorization as RolesBasedAccessControl\n if (rbac.roleKey && !model.session.properties.includes(rbac.roleKey)) {\n issues.push({\n code: createCode('API', 'MISSING_RBAC_SESSION_PROPERTY'),\n message: 'The user role must be included in the session data for permissions to work.',\n suggestion: 'Make sure your selected role field is checked in the session settings.',\n severity: 'error',\n context: { ...context, property: 'session.properties' },\n })\n }\n }\n\n const { cookie, jwt } = model.session\n if ((!cookie || !cookie.enabled) && (!jwt || !jwt.enabled)) {\n issues.push({\n code: createCode('API', 'MISSING_SESSION_TRANSPORT'),\n message: 'No delivery method for sessions (like cookies or tokens) is enabled.',\n suggestion: 'Enable at least one session delivery mechanism in the security settings.',\n severity: 'error',\n context: { ...context, property: 'session' },\n })\n }\n }\n\n // User Target\n if (!model.user) {\n issues.push({\n code: createCode('API', 'MISSING_USER_ENTITY'),\n message: 'You need to specify what kind of object represents your users.',\n suggestion: 'Select a model from your domain that stores your user accounts.',\n severity: 'error',\n context: { ...context, property: 'user' },\n })\n } else if (model.domain && !model.domain.findEntity(model.user.key, model.user.domain)) {\n issues.push({\n code: createCode('API', 'INVALID_USER_ENTITY'),\n message: 'The selected user model no longer exists in your data domain.',\n suggestion: 'Please navigate to security settings and select a valid user model.',\n severity: 'error',\n context: { ...context, property: 'user' },\n })\n }\n\n return issues\n}\n\nexport function validateApiModelMetadata(model: ApiModel): ApiModelValidationItem[] {\n const issues: ApiModelValidationItem[] = []\n const context: ApiModelValidationContext = {\n apiModelKey: model.key,\n kind: ApiModelKind,\n key: model.key,\n }\n\n const urlRegex = /^https?:\\/\\//i\n const emailRegex = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/\n\n if (model.contact) {\n if (model.contact.email && !emailRegex.test(model.contact.email)) {\n issues.push({\n code: createCode('API', 'INVALID_CONTACT_EMAIL'),\n message: 'The contact email address looks invalid.',\n suggestion: 'Please double check the email address formatting.',\n severity: 'error',\n context: { ...context, property: 'contact.email' },\n })\n }\n if (model.contact.url && !urlRegex.test(model.contact.url)) {\n issues.push({\n code: createCode('API', 'INVALID_CONTACT_URL'),\n message: 'The contact link looks invalid.',\n suggestion: 'Provide a working link, starting with http:// or https://.',\n severity: 'error',\n context: { ...context, property: 'contact.url' },\n })\n }\n } else {\n issues.push({\n code: createCode('API', 'MISSING_CONTACT'),\n message: 'A contact email or link is highly recommended for API consumers.',\n suggestion: 'Add an email or help desk link in the metadata tab.',\n severity: 'info',\n context: { ...context, property: 'contact' },\n })\n }\n\n if (model.license) {\n if (model.license.url && !urlRegex.test(model.license.url)) {\n issues.push({\n code: createCode('API', 'INVALID_LICENSE_URL'),\n message: 'The license link looks invalid.',\n suggestion: 'Provide a working link, starting with http:// or https://.',\n severity: 'error',\n context: { ...context, property: 'license.url' },\n })\n }\n } else {\n issues.push({\n code: createCode('API', 'MISSING_LICENSE'),\n message: 'Adding a license to your API helps users understand its usage rights.',\n suggestion: 'Add the name and a link to your API license terms.',\n severity: 'info',\n context: { ...context, property: 'license' },\n })\n }\n\n if (!model.termsOfService) {\n issues.push({\n code: createCode('API', 'MISSING_TOS'),\n message: 'Terms of Service help legal compliance.',\n suggestion: 'Add a link to the terms of your API service.',\n severity: 'info',\n context: { ...context, property: 'termsOfService' },\n })\n }\n\n return issues\n}\n\nexport function validateAction(action: Action, parent: ExposedEntity, apiModelKey: string): ApiModelValidationItem[] {\n const issues: ApiModelValidationItem[] = []\n const context: ApiModelValidationContext = {\n apiModelKey,\n kind: 'Action',\n key: action.kind, // Actions lack nanoids, kind represents its type\n parentExposedEntityKey: parent.key,\n }\n\n if (ListAction.isListAction(action)) {\n if (!action.pagination || !action.pagination.kind) {\n issues.push({\n code: createCode('ACTION', 'LIST_MISSING_PAGINATION'),\n message: 'A List action must have a defined pagination strategy.',\n suggestion: 'Configure how results are loaded (e.g. by page or by a continuous cursor).',\n severity: 'error',\n context: { ...context, property: 'pagination' },\n })\n }\n if (\n (!action.filterableFields || action.filterableFields.length === 0) &&\n (!action.sortableFields || action.sortableFields.length === 0)\n ) {\n issues.push({\n code: createCode('ACTION', 'LIST_MISSING_FILTERS'),\n message: 'Listing all elements without filters or sorting could be overwhelming for large tables.',\n suggestion: 'Select a few important fields to allow sorting and searching by.',\n severity: 'warning',\n context,\n })\n }\n }\n\n if (SearchAction.isSearchAction(action)) {\n if (!action.fields || action.fields.length === 0) {\n issues.push({\n code: createCode('ACTION', 'SEARCH_MISSING_FIELDS'),\n message: 'A Search action needs to know which fields to look in.',\n suggestion: 'Select the properties (like names or emails) that the search will run on.',\n severity: 'error',\n context: { ...context, property: 'fields' },\n })\n }\n }\n\n if (DeleteAction.isDeleteAction(action)) {\n if (!action.strategy) {\n issues.push({\n code: createCode('ACTION', 'DELETE_MISSING_STRATEGY'),\n message: 'A Delete action must know if you want to completely erase the record, or just hide it.',\n suggestion: 'Configure the deletion type (permanent or soft).',\n severity: 'error',\n context: { ...context, property: 'strategy' },\n })\n } else if (action.strategy === 'hard') {\n issues.push({\n code: createCode('ACTION', 'DELETE_HARD_WARNING'),\n message: 'Permanent delete is active. There will be no way to restore deleted data.',\n suggestion: 'Consider switching to \"soft delete\" if users might need to undo mistakes.',\n severity: 'info',\n context: { ...context, property: 'strategy' },\n })\n }\n }\n\n if (UpdateAction.isUpdateAction(action)) {\n if (!action.allowedMethods || action.allowedMethods.length === 0) {\n issues.push({\n code: createCode('ACTION', 'UPDATE_MISSING_METHODS'),\n message:\n 'An Update action must define how the data is sent (PUT replaces everything; PATCH applies partial changes).',\n suggestion: 'Select at least one allowed HTTP method.',\n severity: 'error',\n context: { ...context, property: 'allowedMethods' },\n })\n }\n }\n\n const allRateLimiters = action.getAllRateLimiters()\n const oneHasRules = allRateLimiters.some((i) => i.rules.length)\n if (!oneHasRules) {\n issues.push({\n code: createCode('ACTION', 'MISSING_RATE_LIMITS'),\n message: 'It is best practice to configure a rate limit so your API is not overwhelmed.',\n suggestion: 'Set a reasonable maximum request speed for this operation.',\n severity: 'warning',\n context,\n })\n }\n\n return issues\n}\n\nexport function validateExposedEntity(entity: ExposedEntity, apiModel: ApiModel): ApiModelValidationItem[] {\n const issues: ApiModelValidationItem[] = []\n const context: ApiModelValidationContext = {\n apiModelKey: apiModel.key,\n kind: ExposedEntityKind,\n key: entity.key,\n }\n\n // Valid Entity Reference\n if (!entity.entity || !entity.entity.key) {\n issues.push({\n code: createCode('EXPOSURE', 'MISSING_ENTITY_REF'),\n message: 'This exposed endpoint does not point to a specific data model.',\n suggestion: 'Select which database entity this endpoint should serve.',\n severity: 'error',\n context: { ...context, property: 'entity' },\n })\n } else if (apiModel.domain && !apiModel.domain.findEntity(entity.entity.key, entity.entity.domain)) {\n issues.push({\n code: createCode('EXPOSURE', 'INVALID_ENTITY_REF'),\n message: 'This endpoint points to a data model that no longer exists.',\n suggestion: 'Select a new valid database model or delete this endpoint.',\n severity: 'error',\n context: { ...context, property: 'entity' },\n })\n }\n\n // Path Integrity\n if (entity.hasCollection) {\n if (!entity.collectionPath) {\n issues.push({\n code: createCode('EXPOSURE', 'MISSING_COLLECTION_PATH'),\n message: 'When an endpoint exposes a collection, it must define what its base URL path is.',\n suggestion: 'Add a path (e.g., \"/items\").',\n severity: 'error',\n context: { ...context, property: 'collectionPath' },\n })\n } else {\n const parts = entity.collectionPath.split('/').filter(Boolean)\n if (parts.length !== 1 || !entity.collectionPath.startsWith('/')) {\n issues.push({\n code: createCode('EXPOSURE', 'INVALID_COLLECTION_PATH'),\n message: 'The collection URL should start with \"/\" and have no extra slashes.',\n suggestion: `Ensure the path looks like exactly \"/${parts[0] || 'subresource'}\".`,\n severity: 'error',\n context: { ...context, property: 'collectionPath' },\n })\n }\n }\n\n if (!entity.resourcePath) {\n issues.push({\n code: createCode('EXPOSURE', 'MISSING_RESOURCE_PATH'),\n message: 'You need an identifier to locate single items.',\n suggestion: 'Specify the identification parameter format, like \"{id}\".',\n severity: 'error',\n context: { ...context, property: 'resourcePath' },\n })\n } else if (entity.collectionPath) {\n const colRegex = new RegExp(`^${entity.collectionPath}/\\\\{[a-zA-Z0-9_]+\\\\}$`)\n if (!colRegex.test(entity.resourcePath)) {\n issues.push({\n code: createCode('EXPOSURE', 'INVALID_RESOURCE_PATH_FORMAT'),\n message: 'The single item route should match exactly your collection path plus one identifier variable.',\n suggestion: `Make sure the item path is formatted exactly like \"${entity.collectionPath}/{id}\".`,\n severity: 'error',\n context: { ...context, property: 'resourcePath' },\n })\n }\n }\n } else {\n if (!entity.resourcePath) {\n issues.push({\n code: createCode('EXPOSURE', 'MISSING_RESOURCE_PATH'),\n message: 'Endpoints representing a single item must declare their URL route.',\n suggestion: 'Set the URL path (such as \"/profile\").',\n severity: 'error',\n context: { ...context, property: 'resourcePath' },\n })\n } else {\n const parts = entity.resourcePath.split('/').filter(Boolean)\n if (parts.length !== 2 || !entity.resourcePath.startsWith('/')) {\n issues.push({\n code: createCode('EXPOSURE', 'INVALID_RESOURCE_PATH_FORMAT'),\n message: 'The URL route must only contain two exact parts or levels.',\n suggestion: 'Simplify the endpoint URL to prevent deep-nesting.',\n severity: 'error',\n context: { ...context, property: 'resourcePath' },\n })\n }\n }\n }\n\n // Path Collisions\n if (entity.isRoot) {\n if (entity.collectionPath) {\n const collectionCollision = apiModel.findCollectionPathCollision(entity.collectionPath, entity.key)\n if (collectionCollision) {\n issues.push({\n code: createCode('EXPOSURE', 'ROOT_COLLECTION_COLLISION'),\n message: `The route \"${entity.collectionPath}\" is already used by another view.`,\n suggestion: 'Give this resource a different path to avoid conflicts.',\n severity: 'error',\n context: { ...context, property: 'collectionPath' },\n })\n }\n }\n\n if (entity.resourcePath) {\n const resourceCollision = apiModel.findResourcePathCollision(entity.resourcePath, entity.key)\n if (resourceCollision) {\n issues.push({\n code: createCode('EXPOSURE', 'ROOT_RESOURCE_COLLISION'),\n message: `The route \"${entity.resourcePath}\" is already used by another view.`,\n suggestion: 'Give this single-item resource a different path to avoid conflicts.',\n severity: 'error',\n context: { ...context, property: 'resourcePath' },\n })\n }\n }\n }\n\n // Minimum Actions\n if (!entity.actions || entity.actions.length === 0) {\n issues.push({\n code: createCode('EXPOSURE', 'MISSING_ACTIONS'),\n message: 'This exposed view does not let users do anything.',\n suggestion: 'Enable at least one operation like Create, Read, or Update.',\n severity: 'error',\n context: { ...context, property: 'actions' },\n })\n } else {\n for (const action of entity.actions) {\n issues.push(...validateAction(action, entity, apiModel.key))\n\n // Check inheritance of access rules\n // For a rule to exist, it might be on the action, the exposure, any parent, or the apiModel.\n let hasAuth = false\n if (action.accessRule && action.accessRule.length > 0) hasAuth = true\n if (!hasAuth && entity.accessRule && entity.accessRule.length > 0) hasAuth = true\n\n let curr = entity.parent?.key\n while (curr && !hasAuth) {\n const p = apiModel.exposes.get(curr)\n if (p && p.accessRule && p.accessRule.length > 0) {\n hasAuth = true\n break\n }\n curr = p?.parent?.key\n }\n\n if (!hasAuth && apiModel.accessRule && apiModel.accessRule.length > 0) hasAuth = true\n\n if (!hasAuth) {\n issues.push({\n code: createCode('ACTION', 'MISSING_ACCESS_RULES'),\n message: `The ${action.kind} action has no security rules attached, making it entirely inaccessible or open.`,\n suggestion: 'Allow specific user roles to access this operation.',\n severity: 'error',\n context: { ...context, kind: 'Action', key: action.kind }, // using action.kind as the key context equivalent\n })\n }\n }\n }\n\n return issues\n}\n\nexport function validateApiModel(model: ApiModel): ApiModelValidationResult {\n const issues: ApiModelValidationItem[] = []\n\n issues.push(...validateApiModelInfo(model))\n issues.push(...validateApiModelDependency(model))\n issues.push(...validateApiModelSecurity(model))\n issues.push(...validateApiModelMetadata(model))\n\n if (!model.exposes || model.exposes.size === 0) {\n issues.push({\n code: createCode('API', 'NO_EXPOSURES'),\n message: 'Your API currently has no exposed data for external clients to request.',\n suggestion: 'Expose a data model so apps can communicate with it.',\n severity: 'warning',\n context: { apiModelKey: model.key, kind: ApiModelKind, key: model.key, property: 'exposes' },\n })\n } else {\n for (const exposure of model.exposes.values()) {\n issues.push(...validateExposedEntity(exposure, model))\n }\n }\n\n const hasErrors = issues.some((i) => i.severity === 'error')\n\n return {\n isValid: !hasErrors,\n issues,\n }\n}\n"]}
1
+ {"version":3,"file":"api_model_rules.js","sourceRoot":"","sources":["../../../../src/modeling/validation/api_model_rules.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAGzD,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C;;;;GAIG;AACH,SAAS,UAAU,CAAC,MAAc,EAAE,KAAa;IAC/C,OAAO,GAAG,MAAM,IAAI,KAAK,EAAE,CAAA;AAC7B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAe;IAClD,MAAM,MAAM,GAA6B,EAAE,CAAA;IAC3C,MAAM,OAAO,GAA8B;QACzC,WAAW,EAAE,KAAK,CAAC,GAAG;QACtB,IAAI,EAAE,YAAY;QAClB,GAAG,EAAE,KAAK,CAAC,GAAG;KACf,CAAA;IAED,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;QAChC,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,UAAU,CAAC,KAAK,EAAE,cAAc,CAAC;YACvC,OAAO,EAAE,kCAAkC;YAC3C,UAAU,EAAE,mCAAmC;YAC/C,QAAQ,EAAE,OAAO;YACjB,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE;SAC1C,CAAC,CAAA;IACJ,CAAC;IAED,IAAI,CAAC,KAAK,CAAC,GAAG,IAA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ExposedEntity.js'\nimport type { Action } from '../actions/Action.js'\nimport { ListAction } from '../actions/ListAction.js'\nimport { DeleteAction } from '../actions/DeleteAction.js'\nimport { UpdateAction } from '../actions/UpdateAction.js'\nimport { SearchAction } from '../actions/SearchAction.js'\nimport type { RolesBasedAccessControl, UsernamePasswordConfiguration } from '../types.js'\nimport type { ApiModelValidationItem, ApiModelValidationContext } from '../types.js'\nimport { ApiModelKind, ExposedEntityKind } from '../../models/kinds.js'\nimport { SemanticType } from '../Semantics.js'\n\n/**\n * Creates a unique validation code.\n * @param entity The entity type (e.g., 'API', 'EXPOSURE', 'ACTION')\n * @param issue The issue identifier (e.g., 'MISSING_NAME')\n */\nfunction createCode(entity: string, issue: string): string {\n return `${entity}_${issue}`\n}\n\n/**\n * Validates the core properties and metadata of an ApiModel.\n */\nexport function validateApiModelInfo(model: ApiModel): ApiModelValidationItem[] {\n const issues: ApiModelValidationItem[] = []\n const context: ApiModelValidationContext = {\n apiModelKey: model.key,\n kind: ApiModelKind,\n key: model.key,\n }\n\n if (model.kind !== ApiModelKind) {\n issues.push({\n code: createCode('API', 'INVALID_KIND'),\n message: 'The API model type is incorrect.',\n suggestion: 'Set the model type to \"ApiModel\".',\n severity: 'error',\n context: { ...context, property: 'kind' },\n })\n }\n\n if (!model.key || typeof model.key !== 'string' || model.key.trim() === '') {\n issues.push({\n code: createCode('API', 'MISSING_KEY'),\n message: 'The API model is missing a unique identifier.',\n suggestion: 'Provide a valid name to use as a unique identifier.',\n severity: 'error',\n context: { ...context, property: 'key' },\n })\n }\n\n if (!model.info || !model.info.name || model.info.name.trim() === '') {\n issues.push({\n code: createCode('API', 'MISSING_NAME'),\n message: 'The API model has no defined name.',\n suggestion: 'Provide a descriptive name for your API.',\n severity: 'error',\n context: { ...context, property: 'info.name' },\n })\n }\n\n if (!model.info || !model.info.description || model.info.description.trim() === '') {\n issues.push({\n code: createCode('API', 'MISSING_DESCRIPTION'),\n message: 'Adding a description helps others understand your API.',\n suggestion: 'Add a description to clarify the purpose of this API.',\n severity: 'warning',\n context: { ...context, property: 'info.description' },\n })\n }\n\n return issues\n}\n\nexport function validateApiModelDependency(model: ApiModel): ApiModelValidationItem[] {\n const issues: ApiModelValidationItem[] = []\n const context: ApiModelValidationContext = {\n apiModelKey: model.key,\n kind: ApiModelKind,\n key: model.key,\n }\n\n const domain = model.domain\n if (!domain) {\n issues.push({\n code: createCode('API', 'MISSING_DOMAIN'),\n message: 'No Data Domain is attached to the API.',\n suggestion: 'Select a Data Domain from the settings to power your API.',\n severity: 'error',\n context,\n })\n return issues // Can't validate version if it doesn't exist\n }\n\n if (!domain.info || !domain.info.version) {\n issues.push({\n code: createCode('API', 'MISSING_DOMAIN_VERSION'),\n message: 'The selected Data Domain is missing a version number.',\n suggestion: 'Specify a version for the attached Data Domain.',\n severity: 'error',\n context,\n })\n }\n\n return issues\n}\n\nexport function validateApiModelSecurity(model: ApiModel): ApiModelValidationItem[] {\n const issues: ApiModelValidationItem[] = []\n const context: ApiModelValidationContext = {\n apiModelKey: model.key,\n kind: ApiModelKind,\n key: model.key,\n }\n\n // Resolve User target\n const userEntity = model.domain && model.user ? model.domain.findEntity(model.user.key, model.user.domain) : undefined\n\n // Authentication\n if (!model.authentication) {\n issues.push({\n code: createCode('API', 'MISSING_AUTHENTICATION'),\n message: 'The API is missing authentication settings.',\n suggestion: 'Go to the security settings and configure how users authenticate.',\n severity: 'error',\n context: { ...context, property: 'authentication' },\n })\n } else if (model.authentication.strategy === 'UsernamePassword') {\n const auth = model.authentication as UsernamePasswordConfiguration\n if (!auth.passwordKey) {\n issues.push({\n code: createCode('API', 'MISSING_PASSWORD_KEY'),\n message: 'Username & Password authentication requires a specific field for the password.',\n suggestion:\n 'Select which field in your user profile should store the password. ' +\n 'The data domain model should have a password data semantic on that property.',\n severity: 'error',\n context: { ...context, property: 'authentication.passwordKey' },\n })\n } else if (userEntity) {\n const passwordProp = Array.from(userEntity.properties).find((p) => p.key === auth.passwordKey)\n if (passwordProp && !passwordProp.hasSemantic(SemanticType.Password)) {\n issues.push({\n code: createCode('API', 'MISSING_PASSWORD_SEMANTIC'),\n message: 'The selected password field is missing the Password data semantic.',\n suggestion: 'Go to the Data Modeler and add the \"Password\" semantic to this property.',\n severity: 'error',\n context: { ...context, property: 'authentication.passwordKey' },\n })\n }\n }\n\n if (userEntity) {\n const hasUsernameSemantic = Array.from(userEntity.properties).some(\n (p) => typeof p.hasSemantic === 'function' && p.hasSemantic(SemanticType.Username)\n )\n if (!hasUsernameSemantic) {\n issues.push({\n code: createCode('API', 'MISSING_USERNAME_SEMANTIC'),\n message: 'Username & Password authentication requires a field with the Username data semantic.',\n suggestion: 'Go to the Data Modeler and add the \"Username\" semantic to the property used for login.',\n severity: 'error',\n context: { ...context, property: 'user' },\n })\n }\n }\n }\n\n // Authorization\n if (!model.authorization) {\n issues.push({\n code: createCode('API', 'MISSING_AUTHORIZATION'),\n message: 'The API is missing authorization settings.',\n suggestion: 'Go to the security settings and configure how to handle user permissions.',\n severity: 'error',\n context: { ...context, property: 'authorization' },\n })\n } else if (model.authorization.strategy === 'RBAC') {\n const rbac = model.authorization as RolesBasedAccessControl\n if (!rbac.roleKey) {\n issues.push({\n code: createCode('API', 'MISSING_ROLE_KEY'),\n message: 'Role-based access control is selected but no role field has been defined.',\n suggestion: \"Select which field in your user profile determines the user's role.\",\n severity: 'error',\n context: { ...context, property: 'authorization.roleKey' },\n })\n } else if (userEntity) {\n const roleProp = Array.from(userEntity.properties).find((p) => p.key === rbac.roleKey)\n if (roleProp && !roleProp.hasSemantic(SemanticType.UserRole)) {\n issues.push({\n code: createCode('API', 'MISSING_ROLE_SEMANTIC'),\n message: 'The selected role field is missing the User Role data semantic.',\n suggestion: 'Go to the Data Modeler and add the \"User Role\" semantic to this property.',\n severity: 'error',\n context: { ...context, property: 'authorization.roleKey' },\n })\n }\n }\n }\n\n // Session\n if (!model.session) {\n issues.push({\n code: createCode('API', 'MISSING_SESSION'),\n message: 'The API is missing session configuration.',\n suggestion: 'Configure how user sessions will be handled.',\n severity: 'error',\n context: { ...context, property: 'session' },\n })\n } else {\n if (!model.session.secret) {\n issues.push({\n code: createCode('API', 'MISSING_SESSION_SECRET'),\n message: 'A secure encryption key is required for sessions.',\n suggestion: 'Provide a strong security key in the session settings.',\n severity: 'error',\n context: { ...context, property: 'session.secret' },\n })\n }\n\n if (!model.session.properties || model.session.properties.length === 0) {\n issues.push({\n code: createCode('API', 'MISSING_SESSION_PROPERTIES'),\n message: 'The session token needs to include at least one piece of user information, like an ID.',\n suggestion: 'Select fields that should be stored securely inside the session payload.',\n severity: 'error',\n context: { ...context, property: 'session.properties' },\n })\n } else if (model.authorization && model.authorization.strategy === 'RBAC') {\n const rbac = model.authorization as RolesBasedAccessControl\n if (rbac.roleKey && !model.session.properties.includes(rbac.roleKey)) {\n issues.push({\n code: createCode('API', 'MISSING_RBAC_SESSION_PROPERTY'),\n message: 'The user role must be included in the session data for permissions to work.',\n suggestion: 'Make sure your selected role field is checked in the session settings.',\n severity: 'error',\n context: { ...context, property: 'session.properties' },\n })\n }\n }\n\n const { cookie, jwt } = model.session\n if ((!cookie || !cookie.enabled) && (!jwt || !jwt.enabled)) {\n issues.push({\n code: createCode('API', 'MISSING_SESSION_TRANSPORT'),\n message: 'No delivery method for sessions (like cookies or tokens) is enabled.',\n suggestion: 'Enable at least one session delivery mechanism in the security settings.',\n severity: 'error',\n context: { ...context, property: 'session' },\n })\n }\n }\n\n // User Target\n if (!model.user) {\n issues.push({\n code: createCode('API', 'MISSING_USER_ENTITY'),\n message: 'You need to specify what kind of object represents your users.',\n suggestion: 'Select a model from your domain that stores your user accounts.',\n severity: 'error',\n context: { ...context, property: 'user' },\n })\n } else if (model.domain && !model.domain.findEntity(model.user.key, model.user.domain)) {\n issues.push({\n code: createCode('API', 'INVALID_USER_ENTITY'),\n message: 'The selected user model no longer exists in your data domain.',\n suggestion: 'Please navigate to security settings and select a valid user model.',\n severity: 'error',\n context: { ...context, property: 'user' },\n })\n }\n\n return issues\n}\n\nexport function validateApiModelMetadata(model: ApiModel): ApiModelValidationItem[] {\n const issues: ApiModelValidationItem[] = []\n const context: ApiModelValidationContext = {\n apiModelKey: model.key,\n kind: ApiModelKind,\n key: model.key,\n }\n\n const urlRegex = /^https?:\\/\\//i\n const emailRegex = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/\n\n if (model.contact) {\n if (model.contact.email && !emailRegex.test(model.contact.email)) {\n issues.push({\n code: createCode('API', 'INVALID_CONTACT_EMAIL'),\n message: 'The contact email address looks invalid.',\n suggestion: 'Please double check the email address formatting.',\n severity: 'error',\n context: { ...context, property: 'contact.email' },\n })\n }\n if (model.contact.url && !urlRegex.test(model.contact.url)) {\n issues.push({\n code: createCode('API', 'INVALID_CONTACT_URL'),\n message: 'The contact link looks invalid.',\n suggestion: 'Provide a working link, starting with http:// or https://.',\n severity: 'error',\n context: { ...context, property: 'contact.url' },\n })\n }\n } else {\n issues.push({\n code: createCode('API', 'MISSING_CONTACT'),\n message: 'A contact email or link is highly recommended for API consumers.',\n suggestion: 'Add an email or help desk link in the metadata tab.',\n severity: 'info',\n context: { ...context, property: 'contact' },\n })\n }\n\n if (model.license) {\n if (model.license.url && !urlRegex.test(model.license.url)) {\n issues.push({\n code: createCode('API', 'INVALID_LICENSE_URL'),\n message: 'The license link looks invalid.',\n suggestion: 'Provide a working link, starting with http:// or https://.',\n severity: 'error',\n context: { ...context, property: 'license.url' },\n })\n }\n } else {\n issues.push({\n code: createCode('API', 'MISSING_LICENSE'),\n message: 'Adding a license to your API helps users understand its usage rights.',\n suggestion: 'Add the name and a link to your API license terms.',\n severity: 'info',\n context: { ...context, property: 'license' },\n })\n }\n\n if (!model.termsOfService) {\n issues.push({\n code: createCode('API', 'MISSING_TOS'),\n message: 'Terms of Service help legal compliance.',\n suggestion: 'Add a link to the terms of your API service.',\n severity: 'info',\n context: { ...context, property: 'termsOfService' },\n })\n }\n\n return issues\n}\n\nexport function validateAction(action: Action, parent: ExposedEntity, apiModelKey: string): ApiModelValidationItem[] {\n const issues: ApiModelValidationItem[] = []\n const context: ApiModelValidationContext = {\n apiModelKey,\n kind: 'Action',\n key: action.kind, // Actions lack nanoids, kind represents its type\n parentExposedEntityKey: parent.key,\n }\n\n if (ListAction.isListAction(action)) {\n if (!action.pagination || !action.pagination.kind) {\n issues.push({\n code: createCode('ACTION', 'LIST_MISSING_PAGINATION'),\n message: 'A List action must have a defined pagination strategy.',\n suggestion: 'Configure how results are loaded (e.g. by page or by a continuous cursor).',\n severity: 'error',\n context: { ...context, property: 'pagination' },\n })\n }\n if (\n (!action.filterableFields || action.filterableFields.length === 0) &&\n (!action.sortableFields || action.sortableFields.length === 0)\n ) {\n issues.push({\n code: createCode('ACTION', 'LIST_MISSING_FILTERS'),\n message: 'Listing all elements without filters or sorting could be overwhelming for large tables.',\n suggestion: 'Select a few important fields to allow sorting and searching by.',\n severity: 'warning',\n context,\n })\n }\n }\n\n if (SearchAction.isSearchAction(action)) {\n if (!action.fields || action.fields.length === 0) {\n issues.push({\n code: createCode('ACTION', 'SEARCH_MISSING_FIELDS'),\n message: 'A Search action needs to know which fields to look in.',\n suggestion: 'Select the properties (like names or emails) that the search will run on.',\n severity: 'error',\n context: { ...context, property: 'fields' },\n })\n }\n }\n\n if (DeleteAction.isDeleteAction(action)) {\n if (!action.strategy) {\n issues.push({\n code: createCode('ACTION', 'DELETE_MISSING_STRATEGY'),\n message: 'A Delete action must know if you want to completely erase the record, or just hide it.',\n suggestion: 'Configure the deletion type (permanent or soft).',\n severity: 'error',\n context: { ...context, property: 'strategy' },\n })\n } else if (action.strategy === 'hard') {\n issues.push({\n code: createCode('ACTION', 'DELETE_HARD_WARNING'),\n message: 'Permanent delete is active. There will be no way to restore deleted data.',\n suggestion: 'Consider switching to \"soft delete\" if users might need to undo mistakes.',\n severity: 'info',\n context: { ...context, property: 'strategy' },\n })\n }\n }\n\n if (UpdateAction.isUpdateAction(action)) {\n if (!action.allowedMethods || action.allowedMethods.length === 0) {\n issues.push({\n code: createCode('ACTION', 'UPDATE_MISSING_METHODS'),\n message:\n 'An Update action must define how the data is sent (PUT replaces everything; PATCH applies partial changes).',\n suggestion: 'Select at least one allowed HTTP method.',\n severity: 'error',\n context: { ...context, property: 'allowedMethods' },\n })\n }\n }\n\n const allRateLimiters = action.getAllRateLimiters()\n const oneHasRules = allRateLimiters.some((i) => i.rules.length)\n if (!oneHasRules) {\n issues.push({\n code: createCode('ACTION', 'MISSING_RATE_LIMITS'),\n message: 'It is best practice to configure a rate limit so your API is not overwhelmed.',\n suggestion: 'Set a reasonable maximum request speed for this operation.',\n severity: 'warning',\n context,\n })\n }\n\n return issues\n}\n\nexport function validateExposedEntity(entity: ExposedEntity, apiModel: ApiModel): ApiModelValidationItem[] {\n const issues: ApiModelValidationItem[] = []\n const context: ApiModelValidationContext = {\n apiModelKey: apiModel.key,\n kind: ExposedEntityKind,\n key: entity.key,\n }\n\n // Valid Entity Reference\n if (!entity.entity || !entity.entity.key) {\n issues.push({\n code: createCode('EXPOSURE', 'MISSING_ENTITY_REF'),\n message: 'This exposed endpoint does not point to a specific data model.',\n suggestion: 'Select which database entity this endpoint should serve.',\n severity: 'error',\n context: { ...context, property: 'entity' },\n })\n } else if (apiModel.domain && !apiModel.domain.findEntity(entity.entity.key, entity.entity.domain)) {\n issues.push({\n code: createCode('EXPOSURE', 'INVALID_ENTITY_REF'),\n message: 'This endpoint points to a data model that no longer exists.',\n suggestion: 'Select a new valid database model or delete this endpoint.',\n severity: 'error',\n context: { ...context, property: 'entity' },\n })\n }\n\n // Path Integrity\n if (entity.hasCollection) {\n if (!entity.collectionPath) {\n issues.push({\n code: createCode('EXPOSURE', 'MISSING_COLLECTION_PATH'),\n message: 'When an endpoint exposes a collection, it must define what its base URL path is.',\n suggestion: 'Add a path (e.g., \"/items\").',\n severity: 'error',\n context: { ...context, property: 'collectionPath' },\n })\n } else {\n const parts = entity.collectionPath.split('/').filter(Boolean)\n if (parts.length !== 1 || !entity.collectionPath.startsWith('/')) {\n issues.push({\n code: createCode('EXPOSURE', 'INVALID_COLLECTION_PATH'),\n message: 'The collection URL should start with \"/\" and have no extra slashes.',\n suggestion: `Ensure the path looks like exactly \"/${parts[0] || 'subresource'}\".`,\n severity: 'error',\n context: { ...context, property: 'collectionPath' },\n })\n }\n }\n\n if (!entity.resourcePath) {\n issues.push({\n code: createCode('EXPOSURE', 'MISSING_RESOURCE_PATH'),\n message: 'You need an identifier to locate single items.',\n suggestion: 'Specify the identification parameter format, like \"{id}\".',\n severity: 'error',\n context: { ...context, property: 'resourcePath' },\n })\n } else if (entity.collectionPath) {\n const colRegex = new RegExp(`^${entity.collectionPath}/\\\\{[a-zA-Z0-9_]+\\\\}$`)\n if (!colRegex.test(entity.resourcePath)) {\n issues.push({\n code: createCode('EXPOSURE', 'INVALID_RESOURCE_PATH_FORMAT'),\n message: 'The single item route should match exactly your collection path plus one identifier variable.',\n suggestion: `Make sure the item path is formatted exactly like \"${entity.collectionPath}/{id}\".`,\n severity: 'error',\n context: { ...context, property: 'resourcePath' },\n })\n }\n }\n } else {\n if (!entity.resourcePath) {\n issues.push({\n code: createCode('EXPOSURE', 'MISSING_RESOURCE_PATH'),\n message: 'Endpoints representing a single item must declare their URL route.',\n suggestion: 'Set the URL path (such as \"/profile\").',\n severity: 'error',\n context: { ...context, property: 'resourcePath' },\n })\n } else {\n const parts = entity.resourcePath.split('/').filter(Boolean)\n if (parts.length !== 2 || !entity.resourcePath.startsWith('/')) {\n issues.push({\n code: createCode('EXPOSURE', 'INVALID_RESOURCE_PATH_FORMAT'),\n message: 'The URL route must only contain two exact parts or levels.',\n suggestion: 'Simplify the endpoint URL to prevent deep-nesting.',\n severity: 'error',\n context: { ...context, property: 'resourcePath' },\n })\n }\n }\n }\n\n // Path Collisions\n if (entity.isRoot) {\n if (entity.collectionPath) {\n const collectionCollision = apiModel.findCollectionPathCollision(entity.collectionPath, entity.key)\n if (collectionCollision) {\n issues.push({\n code: createCode('EXPOSURE', 'ROOT_COLLECTION_COLLISION'),\n message: `The route \"${entity.collectionPath}\" is already used by another view.`,\n suggestion: 'Give this resource a different path to avoid conflicts.',\n severity: 'error',\n context: { ...context, property: 'collectionPath' },\n })\n }\n }\n\n if (entity.resourcePath) {\n const resourceCollision = apiModel.findResourcePathCollision(entity.resourcePath, entity.key)\n if (resourceCollision) {\n issues.push({\n code: createCode('EXPOSURE', 'ROOT_RESOURCE_COLLISION'),\n message: `The route \"${entity.resourcePath}\" is already used by another view.`,\n suggestion: 'Give this single-item resource a different path to avoid conflicts.',\n severity: 'error',\n context: { ...context, property: 'resourcePath' },\n })\n }\n }\n }\n\n // Minimum Actions\n if (!entity.actions || entity.actions.length === 0) {\n issues.push({\n code: createCode('EXPOSURE', 'MISSING_ACTIONS'),\n message: 'This exposed view does not let users do anything.',\n suggestion: 'Enable at least one operation like Create, Read, or Update.',\n severity: 'error',\n context: { ...context, property: 'actions' },\n })\n } else {\n for (const action of entity.actions) {\n issues.push(...validateAction(action, entity, apiModel.key))\n\n // Check inheritance of access rules\n // For a rule to exist, it might be on the action, the exposure, any parent, or the apiModel.\n let hasAuth = false\n if (action.accessRule && action.accessRule.length > 0) hasAuth = true\n if (!hasAuth && entity.accessRule && entity.accessRule.length > 0) hasAuth = true\n\n let curr = entity.parent?.key\n while (curr && !hasAuth) {\n const p = apiModel.exposes.get(curr)\n if (p && p.accessRule && p.accessRule.length > 0) {\n hasAuth = true\n break\n }\n curr = p?.parent?.key\n }\n\n if (!hasAuth && apiModel.accessRule && apiModel.accessRule.length > 0) hasAuth = true\n\n if (!hasAuth) {\n issues.push({\n code: createCode('ACTION', 'MISSING_ACCESS_RULES'),\n message: `The ${action.kind} action has no security rules attached, making it entirely inaccessible or open.`,\n suggestion: 'Allow specific user roles to access this operation.',\n severity: 'error',\n context: { ...context, kind: 'Action', key: action.kind }, // using action.kind as the key context equivalent\n })\n }\n }\n }\n\n return issues\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import type { DataDomain } from '../DataDomain.js';
2
2
  import type { DomainAssociation } from '../DomainAssociation.js';
3
- import { type DomainValidation } from './rules.js';
3
+ import { type DomainValidationSchema } from './rules.js';
4
4
  /**
5
5
  * AssociationValidation is a class that performs validation on associations in a data domain.
6
6
  * Note that an association in most cases is a property of an entity.
@@ -14,7 +14,7 @@ export declare class AssociationValidation {
14
14
  * @param target The target association to validate. Can be a string with
15
15
  * the association key or a DomainAssociation object.
16
16
  */
17
- validate(target: string | DomainAssociation): DomainValidation[];
17
+ validate(target: string | DomainAssociation): DomainValidationSchema[];
18
18
  /**
19
19
  * Validates the association name.
20
20
  *
@@ -28,11 +28,11 @@ export declare class AssociationValidation {
28
28
  * - (recommendation) Column names should be in lower case.
29
29
  * @param association The association to validate
30
30
  */
31
- validateName(association: DomainAssociation): DomainValidation[];
31
+ validateName(association: DomainAssociation): DomainValidationSchema[];
32
32
  /**
33
33
  * Validates the association targets.
34
34
  * @param association The association to validate
35
35
  */
36
- validateTargets(association: DomainAssociation): DomainValidation[];
36
+ validateTargets(association: DomainAssociation): DomainValidationSchema[];
37
37
  }
38
38
  //# sourceMappingURL=association_validation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"association_validation.d.ts","sourceRoot":"","sources":["../../../../src/modeling/validation/association_validation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAEhE,OAAO,EAAE,KAAK,gBAAgB,EAAwB,MAAM,YAAY,CAAA;AAExE;;;GAGG;AACH,qBAAa,qBAAqB;IACpB,SAAS,CAAC,MAAM,EAAE,UAAU;gBAAlB,MAAM,EAAE,UAAU;IACxC;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,GAAG,gBAAgB,EAAE;IA6BhE;;;;;;;;;;;;OAYG;IACH,YAAY,CAAC,WAAW,EAAE,iBAAiB,GAAG,gBAAgB,EAAE;IAIhE;;;OAGG;IACH,eAAe,CAAC,WAAW,EAAE,iBAAiB,GAAG,gBAAgB,EAAE;CAsCpE"}
1
+ {"version":3,"file":"association_validation.d.ts","sourceRoot":"","sources":["../../../../src/modeling/validation/association_validation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAEhE,OAAO,EAAE,KAAK,sBAAsB,EAAwB,MAAM,YAAY,CAAA;AAE9E;;;GAGG;AACH,qBAAa,qBAAqB;IACpB,SAAS,CAAC,MAAM,EAAE,UAAU;gBAAlB,MAAM,EAAE,UAAU;IACxC;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,GAAG,sBAAsB,EAAE;IA6BtE;;;;;;;;;;;;OAYG;IACH,YAAY,CAAC,WAAW,EAAE,iBAAiB,GAAG,sBAAsB,EAAE;IAItE;;;OAGG;IACH,eAAe,CAAC,WAAW,EAAE,iBAAiB,GAAG,sBAAsB,EAAE;CAsC1E"}
@@ -1 +1 @@
1
- {"version":3,"file":"association_validation.js","sourceRoot":"","sources":["../../../../src/modeling/validation/association_validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAI7D,OAAO,EAAyB,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAExE;;;GAGG;AACH,MAAM,OAAO,qBAAqB;IACV;IAAtB,YAAsB,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;IAAG,CAAC;IAC5C;;;;;OAKG;IACH,QAAQ,CAAC,MAAkC;QACzC,MAAM,OAAO,GAAuB,EAAE,CAAA;QACtC,IAAI,WAA0C,CAAA;QAC9C,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC/B,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC,CAAA;QAC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EAAE,UAAU;gBAChB,OAAO;gBACP,IAAI;gBACJ,QAAQ,EAAE,OAAO;gBACjB,GAAG,EAAE,WAAW,CAAC,GAAG;gBACpB,IAAI,EAAE,WAAW,CAAC,IAAI;gBACtB,MAAM,EAAE,YAAY,CAAC,GAAG;aACzB,CAAC,CAAA;YACF,OAAO,OAAO,CAAA;QAChB,CAAC;QACD,KAAK,MAAM,MAAM,IAAI,WAAW,CAAC,OAAO,EAAE,CAAC;YACzC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;YAChE,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,MAAM,OAAO,GAAG,QAAQ,KAAK,wCAAwC,MAAM,CAAC,GAAG,IAAI,CAAA;gBACnF,MAAM,IAAI,GAAG,2CAA2C,CAAA;gBACxD,OAAO,CAAC,IAAI,CAAC;oBACX,KAAK,EAAE,SAAS;oBAChB,IAAI,EAAE,QAAQ;oBACd,OAAO;oBACP,IAAI;oBACJ,QAAQ,EAAE,OAAO;oBACjB,GAAG,EAAE,WAAW,CAAC,GAAG;oBACpB,IAAI,EAAE,WAAW,CAAC,IAAI;oBACtB,MAAM,EAAE,YAAY,CAAC,GAAG;iBACzB,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;CACF","sourcesContent":["import { DomainAssociationKind } from '../../models/kinds.js'\nimport type { DataDomain } from '../DataDomain.js'\nimport type { DomainAssociation } from '../DomainAssociation.js'\nimport type { DomainEntity } from '../DomainEntity.js'\nimport { type DomainValidation, validatePropertyName } from './rules.js'\n\n/**\n * AssociationValidation is a class that performs validation on associations in a data domain.\n * Note that an association in most cases is a property of an entity.\n */\nexport class AssociationValidation {\n constructor(protected domain: DataDomain) {}\n /**\n * Performs all the validation rules on the association.\n * If you are interested in a specific rule, use the specific method.\n * @param target The target association to validate. Can be a string with\n * the association key or a DomainAssociation object.\n */\n validate(target: string | DomainAssociation): DomainValidation[] {\n const results: DomainValidation[] = []\n let association: DomainAssociation | undefined\n if (typeof target === 'string') {\n association = this.domain.findAssociation(target)\n } else {\n association = target\n }\n if (!association) {\n const message = `The \"${target}\" association does not exist.`\n const help = `The association must be defined in the domain.`\n results.push({\n field: '*',\n rule: 'exists',\n message,\n help,\n key: target as string,\n kind: DomainAssociationKind,\n severity: 'error',\n })\n return results\n }\n const name = this.validateName(association)\n results.push(...name)\n const targets = this.validateTargets(association)\n results.push(...targets)\n return results\n }\n\n /**\n * Validates the association name.\n *\n * @remarks\n * - A association must have a name defined.\n * - The name has to follow the same rules as the names in a PostgreSQL database.\n * - Column names can only contain letters (a-z, A-Z), numbers (0-9), and underscores (_).\n * - The name must start with a letter (a-z, A-Z) or an underscore (_).\n * - PostgreSQL limits column names to a maximum of 59 characters.\n * - (our rule) Column names are case insensitive.\n * - (recommendation) Column names should be in lower case.\n * @param association The association to validate\n */\n validateName(association: DomainAssociation): DomainValidation[] {\n return validatePropertyName(association)\n }\n\n /**\n * Validates the association targets.\n * @param association The association to validate\n */\n validateTargets(association: DomainAssociation): DomainValidation[] {\n const results: DomainValidation[] = []\n const label = association.info.getLabel()\n const parentEntity = association.getParentInstance() as DomainEntity\n if (!association.targets.length) {\n const message = `The \"${label}\" association has no target.`\n const help = `An association must have at least one target.`\n results.push({\n field: 'targets',\n rule: 'required',\n message,\n help,\n severity: 'error',\n key: association.key,\n kind: association.kind,\n parent: parentEntity.key,\n })\n return results\n }\n for (const target of association.targets) {\n const entity = this.domain.findEntity(target.key, target.domain)\n if (!entity) {\n const message = `The \"${label}\" association has an invalid target \"${target.key}\".`\n const help = `The target must be defined in the domain.`\n results.push({\n field: 'targets',\n rule: 'exists',\n message,\n help,\n severity: 'error',\n key: association.key,\n kind: association.kind,\n parent: parentEntity.key,\n })\n }\n }\n return results\n }\n}\n"]}
1
+ {"version":3,"file":"association_validation.js","sourceRoot":"","sources":["../../../../src/modeling/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C,IAAI;oBACtB,MAAM,EAAE,YAAY,CAAC,GAAG;iBACzB,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;CACF","sourcesContent":["import { DomainAssociationKind } from '../../models/kinds.js'\nimport type { DataDomain } from '../DataDomain.js'\nimport type { DomainAssociation } from '../DomainAssociation.js'\nimport type { DomainEntity } from '../DomainEntity.js'\nimport { type DomainValidationSchema, validatePropertyName } from './rules.js'\n\n/**\n * AssociationValidation is a class that performs validation on associations in a data domain.\n * Note that an association in most cases is a property of an entity.\n */\nexport class AssociationValidation {\n constructor(protected domain: DataDomain) {}\n /**\n * Performs all the validation rules on the association.\n * If you are interested in a specific rule, use the specific method.\n * @param target The target association to validate. Can be a string with\n * the association key or a DomainAssociation object.\n */\n validate(target: string | DomainAssociation): DomainValidationSchema[] {\n const results: DomainValidationSchema[] = []\n let association: DomainAssociation | undefined\n if (typeof target === 'string') {\n association = this.domain.findAssociation(target)\n } else {\n association = target\n }\n if (!association) {\n const message = `The \"${target}\" association does not exist.`\n const help = `The association must be defined in the domain.`\n results.push({\n field: '*',\n rule: 'exists',\n message,\n help,\n key: target as string,\n kind: DomainAssociationKind,\n severity: 'error',\n })\n return results\n }\n const name = this.validateName(association)\n results.push(...name)\n const targets = this.validateTargets(association)\n results.push(...targets)\n return results\n }\n\n /**\n * Validates the association name.\n *\n * @remarks\n * - A association must have a name defined.\n * - The name has to follow the same rules as the names in a PostgreSQL database.\n * - Column names can only contain letters (a-z, A-Z), numbers (0-9), and underscores (_).\n * - The name must start with a letter (a-z, A-Z) or an underscore (_).\n * - PostgreSQL limits column names to a maximum of 59 characters.\n * - (our rule) Column names are case insensitive.\n * - (recommendation) Column names should be in lower case.\n * @param association The association to validate\n */\n validateName(association: DomainAssociation): DomainValidationSchema[] {\n return validatePropertyName(association)\n }\n\n /**\n * Validates the association targets.\n * @param association The association to validate\n */\n validateTargets(association: DomainAssociation): DomainValidationSchema[] {\n const results: DomainValidationSchema[] = []\n const label = association.info.getLabel()\n const parentEntity = association.getParentInstance() as DomainEntity\n if (!association.targets.length) {\n const message = `The \"${label}\" association has no target.`\n const help = `An association must have at least one target.`\n results.push({\n field: 'targets',\n rule: 'required',\n message,\n help,\n severity: 'error',\n key: association.key,\n kind: association.kind,\n parent: parentEntity.key,\n })\n return results\n }\n for (const target of association.targets) {\n const entity = this.domain.findEntity(target.key, target.domain)\n if (!entity) {\n const message = `The \"${label}\" association has an invalid target \"${target.key}\".`\n const help = `The target must be defined in the domain.`\n results.push({\n field: 'targets',\n rule: 'exists',\n message,\n help,\n severity: 'error',\n key: association.key,\n kind: association.kind,\n parent: parentEntity.key,\n })\n }\n }\n return results\n }\n}\n"]}