@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,1947 +0,0 @@
1
- import { AmfMixin, findAmfType, getArrayItems } from './AmfMixin.js';
2
- import { AmfNamespace as ns } from './definitions/Namespace.js';
3
- /**
4
- * A class that takes AMF's ld+json model and outputs JavaScript interface of it.
5
- */
6
- export class AmfSerializer extends AmfMixin(Object) {
7
- /**
8
- * @param graph Optional AMF generated graph model.
9
- */
10
- constructor(graph) {
11
- super();
12
- if (graph) {
13
- this.amf = graph;
14
- }
15
- }
16
- /**
17
- * @param types The list of graph object types. When not defined it returns an empty array.
18
- * @returns The expanded types.
19
- */
20
- readTypes(types, context) {
21
- let target = types;
22
- if (typeof target === 'string') {
23
- target = [target];
24
- }
25
- if (!Array.isArray(target)) {
26
- return [];
27
- }
28
- return target.map((type) => this._expandKey(type, context));
29
- }
30
- /**
31
- * @param object The API to serialize.
32
- * @returns API summary, without complex objects.
33
- */
34
- apiSummary(object) {
35
- const context = object['@context'];
36
- const result = {
37
- id: object['@id'],
38
- types: this.readTypes(object['@type'], context),
39
- customDomainProperties: this.customDomainProperties(object, context),
40
- sourceMaps: this.sourceMap(object),
41
- schemes: [],
42
- accepts: [],
43
- contentType: [],
44
- documentations: [],
45
- tags: [],
46
- };
47
- const name = this._getValue(object, ns.aml.vocabularies.core.name, context);
48
- if (name && typeof name === 'string') {
49
- result.name = name;
50
- }
51
- const description = this._getValue(object, ns.aml.vocabularies.core.description, context);
52
- if (description && typeof description === 'string') {
53
- result.description = description;
54
- }
55
- const version = this._getValue(object, ns.aml.vocabularies.core.version, context);
56
- if (version && typeof version === 'string') {
57
- result.version = version;
58
- }
59
- const termsOfService = this._getValue(object, ns.aml.vocabularies.core.termsOfService, context);
60
- if (termsOfService && typeof termsOfService === 'string') {
61
- result.termsOfService = termsOfService;
62
- }
63
- const accepts = object[this._getAmfKey(ns.aml.vocabularies.apiContract.accepts, context)];
64
- if (Array.isArray(accepts) && accepts.length) {
65
- result.accepts = this._getValueArray(object, ns.aml.vocabularies.apiContract.accepts, context);
66
- }
67
- const contentType = object[this._getAmfKey(ns.aml.vocabularies.apiContract.contentType, context)];
68
- if (Array.isArray(contentType) && contentType.length) {
69
- result.contentType = this._getValueArray(object, ns.aml.vocabularies.apiContract.contentType, context);
70
- }
71
- const schemes = object[this._getAmfKey(ns.aml.vocabularies.apiContract.scheme, context)];
72
- if (Array.isArray(schemes) && schemes.length) {
73
- result.schemes = this._getValueArray(object, ns.aml.vocabularies.apiContract.scheme, context);
74
- }
75
- let provider = object[this._getAmfKey(ns.aml.vocabularies.core.provider, context)];
76
- if (Array.isArray(provider)) {
77
- ;
78
- [provider] = provider;
79
- }
80
- if (provider) {
81
- result.provider = this.provider(provider);
82
- }
83
- let license = object[this._getAmfKey(ns.aml.vocabularies.core.license, context)];
84
- if (Array.isArray(license)) {
85
- ;
86
- [license] = license;
87
- }
88
- if (license) {
89
- result.license = this.license(license);
90
- }
91
- const tags = object[this._getAmfKey(ns.aml.vocabularies.apiContract.tag, context)];
92
- if (Array.isArray(tags) && tags.length) {
93
- result.tags = tags.map((t) => this.tag(t));
94
- }
95
- const docs = object[this._getAmfKey(ns.aml.vocabularies.core.documentation, context)];
96
- if (Array.isArray(docs) && docs.length) {
97
- result.documentations = docs.map((d) => this.documentation(d));
98
- }
99
- return result;
100
- }
101
- api(object, context) {
102
- const objectContext = context || object['@context'];
103
- const result = this.apiSummary(object);
104
- result.endPoints = [];
105
- result.servers = [];
106
- result.security = [];
107
- const endPoints = object[this._getAmfKey(ns.aml.vocabularies.apiContract.endpoint, objectContext)];
108
- if (Array.isArray(endPoints) && endPoints.length) {
109
- result.endPoints = endPoints.map((e) => this.endPoint(e, objectContext));
110
- }
111
- const servers = object[this._getAmfKey(ns.aml.vocabularies.apiContract.server, objectContext)];
112
- if (Array.isArray(servers) && servers.length) {
113
- result.servers = servers.map((s) => this.server(s, objectContext));
114
- }
115
- const security = object[this._getAmfKey(ns.aml.vocabularies.security.security, objectContext)];
116
- if (Array.isArray(security) && security.length) {
117
- result.security = security.map((s) => this.securityRequirement(s, objectContext));
118
- }
119
- return result;
120
- }
121
- webApi(object, context) {
122
- return this.api(object, context);
123
- }
124
- asyncApi(object, context) {
125
- return this.api(object, context);
126
- }
127
- provider(object, context) {
128
- const objectContext = context || object['@context'];
129
- const result = {
130
- id: object['@id'],
131
- types: this.readTypes(object['@type'], objectContext),
132
- customDomainProperties: this.customDomainProperties(object, objectContext),
133
- sourceMaps: this.sourceMap(object, objectContext),
134
- };
135
- const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext);
136
- if (name && typeof name === 'string') {
137
- result.name = name;
138
- }
139
- const url = this._getLinkValue(object, ns.aml.vocabularies.core.url, objectContext);
140
- if (url && typeof url === 'string') {
141
- result.url = url;
142
- }
143
- const email = this._getValue(object, ns.aml.vocabularies.core.email, objectContext);
144
- if (email && typeof email === 'string') {
145
- result.email = email;
146
- }
147
- return result;
148
- }
149
- license(object, context) {
150
- const objectContext = context || object['@context'];
151
- const result = {
152
- id: object['@id'],
153
- types: this.readTypes(object['@type'], objectContext),
154
- customDomainProperties: this.customDomainProperties(object, objectContext),
155
- sourceMaps: this.sourceMap(object, objectContext),
156
- };
157
- const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext);
158
- if (name && typeof name === 'string') {
159
- result.name = name;
160
- }
161
- const url = this._getLinkValue(object, ns.aml.vocabularies.core.url, objectContext);
162
- if (url && typeof url === 'string') {
163
- result.url = url;
164
- }
165
- return result;
166
- }
167
- /**
168
- * @param object The AMF Server to serialize.
169
- * @returns Serialized Server
170
- */
171
- server(object, context) {
172
- const objectContext = context || object['@context'];
173
- const url = this._getValue(object, ns.aml.vocabularies.core.urlTemplate, objectContext) || '';
174
- const result = {
175
- id: object['@id'],
176
- types: this.readTypes(object['@type'], objectContext),
177
- url,
178
- variables: [],
179
- customDomainProperties: this.customDomainProperties(object, objectContext),
180
- sourceMaps: this.sourceMap(object, objectContext),
181
- };
182
- const description = this._getValue(object, ns.aml.vocabularies.core.description, objectContext);
183
- if (description && typeof description === 'string') {
184
- result.description = description;
185
- }
186
- const variables = object[this._getAmfKey(ns.aml.vocabularies.apiContract.variable, objectContext)];
187
- if (Array.isArray(variables) && variables.length) {
188
- result.variables = variables.map((p) => this.parameter(p, objectContext));
189
- }
190
- const protocol = this._getValue(object, ns.aml.vocabularies.apiContract.protocol, objectContext);
191
- const protocolVersion = this._getValue(object, ns.aml.vocabularies.apiContract.protocolVersion, objectContext);
192
- if (protocol) {
193
- result.protocol = protocol;
194
- }
195
- if (protocolVersion) {
196
- result.protocolVersion = protocolVersion;
197
- }
198
- const security = object[this._getAmfKey(ns.aml.vocabularies.security.security, objectContext)];
199
- if (Array.isArray(security) && security.length) {
200
- result.security = security.map((p) => this.securityRequirement(p, objectContext));
201
- }
202
- return result;
203
- }
204
- /**
205
- * @param object The Parameter to serialize.
206
- * @returns Serialized Parameter
207
- */
208
- parameter(object, context) {
209
- const objectContext = context || object['@context'];
210
- const result = {
211
- id: object['@id'],
212
- types: this.readTypes(object['@type'], objectContext),
213
- payloads: [],
214
- examples: [],
215
- customDomainProperties: this.customDomainProperties(object, objectContext),
216
- sourceMaps: this.sourceMap(object, objectContext),
217
- };
218
- const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext);
219
- if (name && typeof name === 'string') {
220
- result.name = name;
221
- }
222
- const paramName = this._getValue(object, ns.aml.vocabularies.apiContract.paramName, objectContext);
223
- if (paramName && typeof paramName === 'string') {
224
- result.paramName = paramName;
225
- }
226
- const description = this._getValue(object, ns.aml.vocabularies.core.description, objectContext);
227
- if (description && typeof description === 'string') {
228
- result.description = description;
229
- }
230
- const required = this._getValue(object, ns.aml.vocabularies.apiContract.required, objectContext);
231
- if (typeof required === 'boolean') {
232
- result.required = required;
233
- }
234
- const allowEmptyValue = this._getValue(object, ns.aml.vocabularies.apiContract.allowEmptyValue, objectContext);
235
- if (typeof allowEmptyValue === 'boolean') {
236
- result.allowEmptyValue = allowEmptyValue;
237
- }
238
- const deprecated = this._getValue(object, ns.aml.vocabularies.document.deprecated, objectContext);
239
- if (typeof deprecated === 'boolean') {
240
- result.deprecated = deprecated;
241
- }
242
- const explode = this._getValue(object, ns.aml.vocabularies.apiContract.explode, objectContext);
243
- if (typeof explode === 'boolean') {
244
- result.explode = explode;
245
- }
246
- const allowReserved = this._getValue(object, ns.aml.vocabularies.apiContract.allowReserved, objectContext);
247
- if (typeof allowReserved === 'boolean') {
248
- result.allowReserved = allowReserved;
249
- }
250
- const style = this._getValue(object, ns.aml.vocabularies.apiContract.style, objectContext);
251
- if (style && typeof style === 'string') {
252
- result.style = style;
253
- }
254
- const binding = this._getValue(object, ns.aml.vocabularies.apiContract.binding, objectContext);
255
- if (binding && typeof binding === 'string') {
256
- result.binding = binding;
257
- }
258
- const schemas = object[this._getAmfKey(ns.aml.vocabularies.shapes.schema, objectContext)];
259
- if (Array.isArray(schemas) && schemas.length) {
260
- const [schema] = schemas;
261
- result.schema = this.unknownShape(schema, {
262
- trackedId: object['@id'],
263
- }, objectContext);
264
- }
265
- const payloads = object[this._getAmfKey(ns.aml.vocabularies.apiContract.payload, objectContext)];
266
- if (Array.isArray(payloads) && payloads.length) {
267
- result.payloads = payloads.map((p) => this.payload(p, objectContext));
268
- }
269
- const examples = object[this._getAmfKey(ns.aml.vocabularies.apiContract.examples, objectContext)];
270
- if (Array.isArray(examples) && examples.length) {
271
- result.examples = examples.map((e) => this.example(e, objectContext));
272
- }
273
- return result;
274
- }
275
- unknownShape(object, options, context) {
276
- const objectContext = context || object['@context'];
277
- const types = this.readTypes(object['@type'], objectContext);
278
- if (types.includes(ns.aml.vocabularies.shapes.ScalarShape)) {
279
- return this.scalarShape(object, options, objectContext);
280
- }
281
- if (types.includes(ns.w3.shacl.NodeShape)) {
282
- return this.nodeShape(object, options, objectContext);
283
- }
284
- if (types.includes(ns.aml.vocabularies.shapes.UnionShape)) {
285
- return this.unionShape(object, options, objectContext);
286
- }
287
- if (types.includes(ns.aml.vocabularies.shapes.FileShape)) {
288
- return this.fileShape(object, options, objectContext);
289
- }
290
- if (types.includes(ns.aml.vocabularies.shapes.SchemaShape)) {
291
- return this.schemaShape(object, options, objectContext);
292
- }
293
- // this must be before the ArrayShape
294
- if (types.includes(ns.aml.vocabularies.shapes.TupleShape)) {
295
- return this.tupleShape(object, options, objectContext);
296
- }
297
- if (types.includes(ns.aml.vocabularies.shapes.ArrayShape) ||
298
- types.includes(ns.aml.vocabularies.shapes.MatrixShape)) {
299
- return this.arrayShape(object, options, objectContext);
300
- }
301
- if (types.includes(ns.aml.vocabularies.shapes.RecursiveShape)) {
302
- return this.recursiveShape(object, objectContext);
303
- }
304
- // recursiveShape
305
- return this.anyShape(object, options, objectContext);
306
- }
307
- isLink(object, context) {
308
- const objectContext = context || object['@context'];
309
- return !!this._getLinkValue(object, ns.aml.vocabularies.document.linkTarget, objectContext);
310
- }
311
- getLinkTarget(object, context) {
312
- const objectContext = context || object['@context'];
313
- const id = this._getLinkValue(object, ns.aml.vocabularies.document.linkTarget, objectContext);
314
- if (!id) {
315
- return undefined;
316
- }
317
- return this[findAmfType](id, objectContext);
318
- }
319
- shape(object, context) {
320
- const objectContext = context || object['@context'];
321
- this._resolve(object);
322
- let linkLabel;
323
- let target = object;
324
- if (this.isLink(target)) {
325
- linkLabel = this._getValue(target, ns.aml.vocabularies.document.linkLabel, objectContext);
326
- const id = this._getLinkValue(target, ns.aml.vocabularies.document.linkTarget, objectContext);
327
- const value = this[findAmfType](id, objectContext);
328
- if (value) {
329
- target = value;
330
- }
331
- }
332
- const result = {
333
- id: target['@id'],
334
- types: this.readTypes(object['@type'], objectContext),
335
- values: [],
336
- inherits: [],
337
- or: [],
338
- and: [],
339
- xone: [],
340
- customDomainProperties: this.customDomainProperties(object, objectContext),
341
- sourceMaps: this.sourceMap(object, objectContext),
342
- };
343
- if (linkLabel) {
344
- result.linkLabel = linkLabel;
345
- }
346
- const name = this._getValue(target, ns.w3.shacl.name, objectContext);
347
- if (name && typeof name === 'string') {
348
- result.name = name;
349
- }
350
- const displayName = this._getValue(target, ns.aml.vocabularies.core.displayName, objectContext);
351
- if (displayName && typeof displayName === 'string') {
352
- result.displayName = displayName;
353
- }
354
- else {
355
- const coreName = this._getValue(target, ns.aml.vocabularies.core.name, objectContext);
356
- if (coreName && typeof coreName === 'string') {
357
- result.displayName = coreName;
358
- }
359
- }
360
- const description = this._getValue(target, ns.aml.vocabularies.core.description, objectContext);
361
- if (description && typeof description === 'string') {
362
- result.description = description;
363
- }
364
- const defaultValueStr = this._getValue(target, ns.w3.shacl.defaultValueStr, objectContext);
365
- if (defaultValueStr && typeof defaultValueStr === 'string') {
366
- result.defaultValueStr = defaultValueStr;
367
- }
368
- const deprecated = this._getValue(target, ns.aml.vocabularies.shapes.deprecated, objectContext);
369
- if (typeof deprecated === 'boolean') {
370
- result.deprecated = deprecated;
371
- }
372
- const readOnly = this._getValue(target, ns.aml.vocabularies.shapes.readOnly, objectContext);
373
- if (typeof readOnly === 'boolean') {
374
- result.readOnly = readOnly;
375
- }
376
- const writeOnly = this._getValue(target, ns.aml.vocabularies.shapes.writeOnly, objectContext);
377
- if (typeof writeOnly === 'boolean') {
378
- result.writeOnly = writeOnly;
379
- }
380
- const defValue = target[this._getAmfKey(ns.w3.shacl.defaultValue, objectContext)];
381
- if (Array.isArray(defValue) && defValue.length) {
382
- result.defaultValue = this.unknownDataNode(defValue[0], objectContext);
383
- }
384
- // @TODO:
385
- // if (Array.isArray(inherits) && inherits.length) {
386
- // result.inherits = inherits.map((item) => this.unknownShape(item));
387
- // }
388
- const orKey = this._getAmfKey(ns.w3.shacl.or, objectContext);
389
- const orGroup = target[orKey];
390
- if (Array.isArray(orGroup) && orGroup.length) {
391
- result.or = orGroup.map((item) => this.unknownShape(item, undefined, objectContext));
392
- }
393
- const andKey = this._getAmfKey(ns.w3.shacl.and, objectContext);
394
- const andGroup = target[andKey];
395
- if (Array.isArray(andGroup) && andGroup.length) {
396
- result.and = andGroup.map((item) => this.unknownShape(item, undefined, objectContext));
397
- }
398
- const xoneKey = this._getAmfKey(ns.w3.shacl.xone, objectContext);
399
- const xone = target[xoneKey];
400
- if (Array.isArray(xone) && xone.length) {
401
- result.xone = xone.map((item) => this.unknownShape(item, undefined, objectContext));
402
- }
403
- const valuesList = target[this._getAmfKey(ns.w3.shacl.in, objectContext)];
404
- if (Array.isArray(valuesList) && valuesList.length) {
405
- const [values] = valuesList;
406
- const prefix = ns.w3.rdfSchema.key;
407
- const prefixCompact = this._getAmfKey(prefix, objectContext);
408
- Object.keys(values).forEach((key) => {
409
- if (key.startsWith(prefix) || key.startsWith(prefixCompact)) {
410
- let value = values[key];
411
- if (Array.isArray(value)) {
412
- ;
413
- [value] = value;
414
- }
415
- const processed = this.unknownDataNode(value, objectContext);
416
- if (processed) {
417
- result.values.push(processed);
418
- }
419
- }
420
- });
421
- }
422
- const notKey = this._getAmfKey(ns.w3.shacl.not, objectContext);
423
- let not = target[notKey];
424
- if (not) {
425
- if (Array.isArray(not)) {
426
- ;
427
- [not] = not;
428
- }
429
- result.not = this.unknownShape(not, undefined, objectContext);
430
- }
431
- return result;
432
- }
433
- anyShape(object, options = {}, context) {
434
- const objectContext = context || object['@context'];
435
- let target = object;
436
- const result = this.shape(target, objectContext);
437
- if (this.isLink(target)) {
438
- const value = this.getLinkTarget(target, objectContext);
439
- if (value) {
440
- target = value;
441
- }
442
- }
443
- result.examples = [];
444
- const examples = target[this._getAmfKey(ns.aml.vocabularies.apiContract.examples, objectContext)];
445
- if (Array.isArray(examples) && examples.length) {
446
- if (options.trackedId) {
447
- const filtered = this.filterTrackedExamples(examples, options.trackedId, objectContext);
448
- result.examples = filtered.map((item) => this.example(item, objectContext));
449
- }
450
- else {
451
- const filtered = this.filterNonTrackedExamples(examples, objectContext);
452
- result.examples = filtered.map((item) => this.example(item, objectContext));
453
- }
454
- }
455
- const docs = target[this._getAmfKey(ns.aml.vocabularies.core.documentation, objectContext)];
456
- if (Array.isArray(docs) && docs.length) {
457
- const [documentation] = docs;
458
- result.documentation = this.documentation(documentation, objectContext);
459
- }
460
- const xml = target[this._getAmfKey(ns.aml.vocabularies.shapes.xmlSerialization, objectContext)];
461
- if (Array.isArray(xml) && xml.length) {
462
- result.xmlSerialization = this.xmlSerializer(xml[0], objectContext);
463
- }
464
- return result;
465
- }
466
- /**
467
- * Filters examples that should be rendered for a payload identified by `trackedId`.
468
- *
469
- * This function is copied from old `api-example-generator/ExampleGenerator`.
470
- */
471
- filterTrackedExamples(examples, trackedId, context) {
472
- const { docSourceMaps } = ns.aml.vocabularies;
473
- const sourceKey = this._getAmfKey(docSourceMaps.sources, context);
474
- const trackedKey = this._getAmfKey(docSourceMaps.trackedElement, context);
475
- const longId = trackedId.indexOf('amf') === -1 ? `amf://id${trackedId}` : trackedId;
476
- return examples.filter((item) => {
477
- let example = item;
478
- if (Array.isArray(example)) {
479
- ;
480
- [example] = example;
481
- }
482
- let sm = example[sourceKey];
483
- if (!sm) {
484
- return true;
485
- }
486
- if (Array.isArray(sm)) {
487
- ;
488
- [sm] = sm;
489
- }
490
- let tracked = sm[trackedKey];
491
- if (!tracked) {
492
- return true;
493
- }
494
- if (Array.isArray(tracked)) {
495
- ;
496
- [tracked] = tracked;
497
- }
498
- const { value } = this.synthesizedField(tracked, context);
499
- if (!value) {
500
- return true;
501
- }
502
- const ids = value.split(',');
503
- if (ids.indexOf(longId) !== -1 || ids.indexOf(trackedId) !== -1) {
504
- return true;
505
- }
506
- return false;
507
- });
508
- }
509
- /**
510
- * Kind of the opposite of the `filterTrackedExamples`. It gathers examples that only have been
511
- * defined for the parent Shape (ed in the type declaration). It filters out all examples
512
- * defined in a payload.
513
- */
514
- filterNonTrackedExamples(examples, context) {
515
- const { docSourceMaps } = ns.aml.vocabularies;
516
- const sourceKey = this._getAmfKey(docSourceMaps.sources, context);
517
- const trackedKey = this._getAmfKey(docSourceMaps.trackedElement, context);
518
- return examples.filter((item) => {
519
- let example = item;
520
- if (Array.isArray(example)) {
521
- ;
522
- [example] = example;
523
- }
524
- let sm = example[sourceKey];
525
- if (!sm) {
526
- return true;
527
- }
528
- if (Array.isArray(sm)) {
529
- ;
530
- [sm] = sm;
531
- }
532
- let tracked = sm[trackedKey];
533
- if (!tracked) {
534
- return true;
535
- }
536
- if (Array.isArray(tracked)) {
537
- ;
538
- [tracked] = tracked;
539
- }
540
- const { value } = this.synthesizedField(tracked, context);
541
- if (!value) {
542
- return true;
543
- }
544
- return false;
545
- });
546
- }
547
- scalarShape(object, options = {}, context) {
548
- const objectContext = context || object['@context'];
549
- let target = object;
550
- const result = this.anyShape(target, options, objectContext);
551
- if (this.isLink(target)) {
552
- const value = this.getLinkTarget(target, objectContext);
553
- if (value) {
554
- target = value;
555
- }
556
- }
557
- const pattern = this._getValue(target, ns.w3.shacl.pattern, objectContext);
558
- if (pattern && typeof pattern === 'string') {
559
- result.pattern = pattern;
560
- }
561
- const dataType = this._getLinkValue(target, ns.w3.shacl.datatype, objectContext);
562
- if (dataType && typeof dataType === 'string') {
563
- result.dataType = dataType;
564
- }
565
- const format = this._getValue(target, ns.aml.vocabularies.shapes.format, objectContext);
566
- if (format && typeof format === 'string') {
567
- result.format = format;
568
- }
569
- const multipleOf = this._getValue(target, ns.aml.vocabularies.shapes.multipleOf, objectContext);
570
- if (typeof multipleOf === 'number') {
571
- result.multipleOf = multipleOf;
572
- }
573
- const minInclusive = this._getValue(target, ns.w3.shacl.minInclusive, objectContext);
574
- if (typeof minInclusive === 'number') {
575
- result.minimum = minInclusive;
576
- result.exclusiveMinimum = false;
577
- }
578
- const maxInclusive = this._getValue(target, ns.w3.shacl.maxInclusive, objectContext);
579
- if (typeof maxInclusive === 'number') {
580
- result.maximum = maxInclusive;
581
- result.exclusiveMaximum = false;
582
- }
583
- const minLength = this._getValue(target, ns.w3.shacl.minLength, objectContext);
584
- if (typeof minLength === 'number') {
585
- result.minLength = minLength;
586
- }
587
- const maxLength = this._getValue(target, ns.w3.shacl.maxLength, objectContext);
588
- if (typeof maxLength === 'number') {
589
- result.maxLength = maxLength;
590
- }
591
- return result;
592
- }
593
- nodeShape(object, options = {}, context) {
594
- const objectContext = context || object['@context'];
595
- let target = object;
596
- const result = this.anyShape(target, options, objectContext);
597
- if (this.isLink(target)) {
598
- const value = this.getLinkTarget(target, objectContext);
599
- if (value) {
600
- target = value;
601
- }
602
- }
603
- const discriminator = this._getValue(target, ns.aml.vocabularies.shapes.discriminator, objectContext);
604
- if (discriminator && typeof discriminator === 'string') {
605
- result.discriminator = discriminator;
606
- }
607
- const discriminatorValue = this._getValue(target, ns.aml.vocabularies.shapes.discriminatorValue, objectContext);
608
- if (discriminatorValue && typeof discriminatorValue === 'string') {
609
- result.discriminatorValue = discriminatorValue;
610
- }
611
- const closed = this._getValue(target, ns.w3.shacl.closed, objectContext);
612
- if (typeof closed === 'boolean') {
613
- result.closed = closed;
614
- }
615
- result.customShapeProperties = [];
616
- result.customShapePropertyDefinitions = [];
617
- result.dependencies = [];
618
- // todo: not sure what the keys are.
619
- // if (!minProperties.isNull) {
620
- // result.minProperties = minProperties.value();
621
- // }
622
- // if (!maxProperties.isNull) {
623
- // result.maxProperties = maxProperties.value();
624
- // }
625
- // if (Array.isArray(customShapeProperties) && customShapeProperties.length) {
626
- // result.customShapeProperties = customShapeProperties.map((item) => item.id);
627
- // } else {
628
- // result.customShapeProperties = [];
629
- // }
630
- // if (Array.isArray(customShapePropertyDefinitions) && customShapePropertyDefinitions.length) {
631
- // result.customShapePropertyDefinitions = customShapePropertyDefinitions.map((item) => item.id);
632
- // } else {
633
- // result.customShapePropertyDefinitions = [];
634
- // }
635
- const properties = target[this._getAmfKey(ns.w3.shacl.property, objectContext)];
636
- if (Array.isArray(properties) && properties.length) {
637
- result.properties = properties.map((item) => this.propertyShape(item, objectContext));
638
- }
639
- else {
640
- result.properties = [];
641
- }
642
- // if (Array.isArray(dependencies) && dependencies.length) {
643
- // result.dependencies = dependencies.map((item) => item.id);
644
- // } else {
645
- // result.dependencies = [];
646
- // }
647
- return result;
648
- }
649
- propertyShape(object, context) {
650
- const objectContext = context || object['@context'];
651
- let target = object;
652
- const result = this.shape(target, objectContext);
653
- if (this.isLink(target)) {
654
- const value = this.getLinkTarget(target, objectContext);
655
- if (value) {
656
- target = value;
657
- }
658
- }
659
- const path = this._getLinkValue(target, ns.w3.shacl.path, objectContext);
660
- if (path && typeof path === 'string') {
661
- result.path = path;
662
- }
663
- const minCount = this._getValue(target, ns.w3.shacl.minCount, objectContext);
664
- if (typeof minCount === 'number') {
665
- result.minCount = minCount;
666
- }
667
- const maxCount = this._getValue(target, ns.w3.shacl.maxCount, objectContext);
668
- if (typeof maxCount === 'number') {
669
- result.maxCount = maxCount;
670
- }
671
- // if (!patternName.isNullOrEmpty) {
672
- // result.patternName = patternName.value();
673
- // }
674
- const ranges = target[this._getAmfKey(ns.aml.vocabularies.shapes.range, objectContext)];
675
- if (Array.isArray(ranges) && ranges.length) {
676
- const [range] = ranges;
677
- result.range = this.unknownShape(range, undefined, objectContext);
678
- }
679
- return result;
680
- }
681
- unionShape(object, options = {}, context) {
682
- const objectContext = context || object['@context'];
683
- const anyOf = object[this._getAmfKey(ns.aml.vocabularies.shapes.anyOf, objectContext)];
684
- const result = this.anyShape(object, options, objectContext);
685
- if (Array.isArray(anyOf) && anyOf.length) {
686
- const opt = { ...options, trackedId: undefined };
687
- result.anyOf = anyOf.map((shape) => this.unknownShape(shape, opt, objectContext));
688
- }
689
- else {
690
- result.anyOf = [];
691
- }
692
- return result;
693
- }
694
- fileShape(object, options = {}, context) {
695
- const objectContext = context || object['@context'];
696
- let target = object;
697
- const result = this.anyShape(target, options, objectContext);
698
- if (this.isLink(target)) {
699
- const value = this.getLinkTarget(target, objectContext);
700
- if (value) {
701
- target = value;
702
- }
703
- }
704
- const pattern = this._getValue(target, ns.w3.shacl.pattern, objectContext);
705
- if (pattern && typeof pattern === 'string') {
706
- result.pattern = pattern;
707
- }
708
- const fileTypes = this._getValueArray(target, ns.aml.vocabularies.shapes.fileType, objectContext);
709
- if (Array.isArray(fileTypes) && fileTypes.length) {
710
- result.fileTypes = fileTypes;
711
- }
712
- const minLength = this._getValue(target, ns.w3.shacl.minLength, objectContext);
713
- if (typeof minLength === 'number') {
714
- result.minLength = minLength;
715
- }
716
- const maxLength = this._getValue(target, ns.w3.shacl.maxLength, objectContext);
717
- if (typeof maxLength === 'number') {
718
- result.maxLength = maxLength;
719
- }
720
- const minInclusive = this._getValue(target, ns.w3.shacl.minInclusive, objectContext);
721
- if (typeof minInclusive === 'number') {
722
- result.minimum = minInclusive;
723
- result.exclusiveMinimum = false;
724
- }
725
- const maxInclusive = this._getValue(target, ns.w3.shacl.maxInclusive, objectContext);
726
- if (typeof maxInclusive === 'number') {
727
- result.maximum = maxInclusive;
728
- result.exclusiveMaximum = false;
729
- }
730
- const format = this._getValue(target, ns.aml.vocabularies.shapes.format, objectContext);
731
- if (format && typeof format === 'string') {
732
- result.format = format;
733
- }
734
- const multipleOf = this._getValue(target, ns.aml.vocabularies.shapes.multipleOf, objectContext);
735
- if (typeof multipleOf === 'number') {
736
- result.multipleOf = multipleOf;
737
- }
738
- return result;
739
- }
740
- schemaShape(object, options = {}, context) {
741
- const objectContext = context || object['@context'];
742
- let target = object;
743
- const result = this.anyShape(target, options, objectContext);
744
- if (this.isLink(target)) {
745
- const value = this.getLinkTarget(target, objectContext);
746
- if (value) {
747
- target = value;
748
- }
749
- }
750
- const mediaType = this._getValue(target, ns.aml.vocabularies.core.mediaType, objectContext);
751
- if (mediaType && typeof mediaType === 'string') {
752
- result.mediaType = mediaType;
753
- }
754
- const raw = this._getValue(target, ns.aml.vocabularies.document.raw, objectContext);
755
- if (raw && typeof raw === 'string') {
756
- result.raw = raw;
757
- }
758
- return result;
759
- }
760
- recursiveShape(object, context) {
761
- const objectContext = context || object['@context'];
762
- let target = object;
763
- const result = this.shape(target, objectContext);
764
- if (this.isLink(target)) {
765
- const value = this.getLinkTarget(target, objectContext);
766
- if (value) {
767
- target = value;
768
- }
769
- }
770
- const fp = this._getLinkValue(object, ns.aml.vocabularies.shapes.fixPoint, objectContext);
771
- if (fp && typeof fp === 'string') {
772
- result.fixPoint = fp;
773
- }
774
- return result;
775
- }
776
- dataArrangeShape(object, options = {}, context) {
777
- const objectContext = context || object['@context'];
778
- let target = object;
779
- const result = this.anyShape(target, options, objectContext);
780
- if (this.isLink(target)) {
781
- const value = this.getLinkTarget(target, objectContext);
782
- if (value) {
783
- target = value;
784
- }
785
- }
786
- //
787
- // const { minItems, maxItems, uniqueItems } = object;
788
- // if (!minItems.isNull) {
789
- // result.minItems = minItems.value();
790
- // }
791
- // if (!maxItems.isNull) {
792
- // result.maxItems = maxItems.value();
793
- // }
794
- // if (!uniqueItems.isNull) {
795
- // result.uniqueItems = uniqueItems.value();
796
- // }
797
- return result;
798
- }
799
- arrayShape(object, options = {}, context) {
800
- const objectContext = context || object['@context'];
801
- let target = object;
802
- const result = this.dataArrangeShape(target, options, objectContext);
803
- if (this.isLink(target)) {
804
- const value = this.getLinkTarget(target, objectContext);
805
- if (value) {
806
- target = value;
807
- }
808
- }
809
- const items = target[this._getAmfKey(ns.aml.vocabularies.shapes.items, objectContext)];
810
- if (Array.isArray(items) && items.length) {
811
- const [item] = items;
812
- result.items = this.unknownShape(item, undefined, objectContext);
813
- }
814
- return result;
815
- }
816
- tupleShape(object, options, context) {
817
- const objectContext = context || object['@context'];
818
- let target = object;
819
- const result = this.dataArrangeShape(target, options, objectContext);
820
- if (this.isLink(target)) {
821
- const value = this.getLinkTarget(target, objectContext);
822
- if (value) {
823
- target = value;
824
- }
825
- }
826
- const items = target[this._getAmfKey(ns.aml.vocabularies.shapes.items, objectContext)];
827
- const prefix = this._getAmfKey(ns.w3.rdfSchema.key, objectContext);
828
- if (Array.isArray(items) && items.length) {
829
- result.items = [];
830
- items.forEach((item) => {
831
- if (Array.isArray(item)) {
832
- ;
833
- [item] = item;
834
- }
835
- Object.keys(item)
836
- .filter((k) => k.startsWith(prefix))
837
- .forEach((key) => {
838
- let shape = item[key];
839
- if (Array.isArray(shape)) {
840
- ;
841
- [shape] = shape;
842
- }
843
- const value = this.unknownShape(shape, undefined, objectContext);
844
- result.items.push(value);
845
- });
846
- });
847
- }
848
- else {
849
- result.items = [];
850
- }
851
- return result;
852
- }
853
- /**
854
- * @param object The CreativeWork to serialize.
855
- * @returns Serialized CreativeWork
856
- */
857
- documentation(object, context) {
858
- const objectContext = context || object['@context'];
859
- const result = {
860
- id: object['@id'],
861
- types: this.readTypes(object['@type'], objectContext),
862
- customDomainProperties: this.customDomainProperties(object, objectContext),
863
- sourceMaps: this.sourceMap(object, objectContext),
864
- };
865
- const url = this._getLinkValue(object, ns.aml.vocabularies.core.url, objectContext);
866
- if (url && typeof url === 'string') {
867
- result.url = url;
868
- }
869
- const description = this._getValue(object, ns.aml.vocabularies.core.description, objectContext);
870
- if (description && typeof description === 'string') {
871
- result.description = description;
872
- }
873
- const title = this._getValue(object, ns.aml.vocabularies.core.title, objectContext);
874
- if (title && typeof title === 'string') {
875
- result.title = title;
876
- }
877
- return result;
878
- }
879
- /**
880
- * @param object The Example to serialize.
881
- * @returns Serialized Example
882
- */
883
- example(object, context) {
884
- const objectContext = context || object['@context'];
885
- this._resolve(object);
886
- const result = {
887
- id: object['@id'],
888
- types: this.readTypes(object['@type'], objectContext),
889
- customDomainProperties: this.customDomainProperties(object, objectContext),
890
- sourceMaps: this.sourceMap(object, objectContext),
891
- strict: false,
892
- };
893
- const strict = this._getValue(object, ns.aml.vocabularies.document.strict, objectContext);
894
- if (typeof strict === 'boolean') {
895
- result.strict = strict;
896
- }
897
- const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext);
898
- if (name && typeof name === 'string') {
899
- result.name = name;
900
- }
901
- const displayName = this._getValue(object, ns.aml.vocabularies.core.displayName, objectContext);
902
- if (displayName && typeof displayName === 'string') {
903
- result.displayName = displayName;
904
- }
905
- const description = this._getValue(object, ns.aml.vocabularies.core.description, objectContext);
906
- if (description && typeof description === 'string') {
907
- result.description = description;
908
- }
909
- const raw = this._getValue(object, ns.aml.vocabularies.document.raw, objectContext);
910
- if (raw && typeof raw === 'string') {
911
- result.value = raw;
912
- }
913
- const location = this._getValue(object, ns.aml.vocabularies.document.location, objectContext);
914
- if (location && typeof location === 'string') {
915
- result.location = location;
916
- }
917
- // if (!mediaType.isNullOrEmpty) {
918
- // result.mediaType = mediaType.value();
919
- // }
920
- const structuredValue = object[this._getAmfKey(ns.aml.vocabularies.document.structuredValue, objectContext)];
921
- if (Array.isArray(structuredValue) && structuredValue.length) {
922
- const [value] = structuredValue;
923
- result.structuredValue = this.unknownDataNode(value, objectContext);
924
- }
925
- return result;
926
- }
927
- xmlSerializer(object, context) {
928
- const objectContext = context || object['@context'];
929
- const result = {
930
- id: object['@id'],
931
- types: this.readTypes(object['@type'], objectContext),
932
- customDomainProperties: this.customDomainProperties(object, objectContext),
933
- sourceMaps: this.sourceMap(object, objectContext),
934
- };
935
- const xmlAttribute = this._getValue(object, ns.aml.vocabularies.shapes.xmlAttribute, objectContext);
936
- if (typeof xmlAttribute === 'boolean') {
937
- result.attribute = xmlAttribute;
938
- }
939
- const wrapped = this._getValue(object, ns.aml.vocabularies.shapes.xmlWrapped, objectContext);
940
- if (typeof wrapped === 'boolean') {
941
- result.wrapped = wrapped;
942
- }
943
- const name = this._getValue(object, ns.aml.vocabularies.shapes.xmlName, objectContext);
944
- if (name && typeof name === 'string') {
945
- result.name = name;
946
- }
947
- const xmlNs = this._getValue(object, ns.aml.vocabularies.shapes.xmlNamespace, objectContext);
948
- if (xmlNs && typeof xmlNs === 'string') {
949
- result.namespace = xmlNs;
950
- }
951
- const xmlPrefix = this._getValue(object, ns.aml.vocabularies.shapes.xmlPrefix, objectContext);
952
- if (xmlPrefix && typeof xmlPrefix === 'string') {
953
- result.prefix = xmlPrefix;
954
- }
955
- return result;
956
- }
957
- unknownDataNode(object, context) {
958
- const types = this.readTypes(object['@type'], context);
959
- if (types.includes(ns.aml.vocabularies.data.Scalar)) {
960
- return this.scalarNode(object, context);
961
- }
962
- if (types.includes(ns.aml.vocabularies.data.Object)) {
963
- return this.objectNode(object, context);
964
- }
965
- if (types.includes(ns.aml.vocabularies.data.Array)) {
966
- return this.arrayNode(object, context);
967
- }
968
- return undefined;
969
- }
970
- dataNode(object, context) {
971
- const result = {
972
- id: object['@id'],
973
- types: this.readTypes(object['@type'], context),
974
- customDomainProperties: this.customDomainProperties(object, context),
975
- };
976
- const name = this._getValue(object, ns.aml.vocabularies.core.name, context);
977
- if (name && typeof name === 'string') {
978
- result.name = name;
979
- }
980
- return result;
981
- }
982
- scalarNode(object, context) {
983
- const objectContext = context || object['@context'];
984
- const result = this.dataNode(object, context);
985
- const value = this._getValue(object, ns.aml.vocabularies.data.value, objectContext);
986
- if (value && typeof value === 'string') {
987
- result.value = value;
988
- }
989
- const dataType = this._getLinkValue(object, ns.w3.shacl.datatype, objectContext);
990
- if (dataType && typeof dataType === 'string') {
991
- result.dataType = dataType;
992
- }
993
- return result;
994
- }
995
- objectNode(object, context) {
996
- const objectContext = context || object['@context'];
997
- const result = this.dataNode(object, context);
998
- result.properties = {};
999
- const prefix = ns.aml.vocabularies.data.key;
1000
- const prefixCompact = `${this._getAmfKey(prefix, objectContext)}:`;
1001
- Object.keys(object).forEach((key) => {
1002
- if (key.startsWith(prefix) || key.startsWith(prefixCompact)) {
1003
- let value = object[key];
1004
- if (Array.isArray(value)) {
1005
- ;
1006
- [value] = value;
1007
- }
1008
- const name = key.replace(prefix, '').replace(prefixCompact, '');
1009
- const nodeValue = this.unknownDataNode(value, context);
1010
- if (nodeValue) {
1011
- result.properties[name] = nodeValue;
1012
- }
1013
- }
1014
- });
1015
- return result;
1016
- }
1017
- arrayNode(object, context) {
1018
- const objectContext = context || object['@context'];
1019
- const result = this.dataNode(object, objectContext);
1020
- result.members = [];
1021
- const members = this._computePropertyArray(object, ns.w3.rdfSchema.member);
1022
- if (Array.isArray(members) && members.length) {
1023
- members.forEach((n) => {
1024
- const item = this.unknownDataNode(n);
1025
- if (item) {
1026
- result.members.push(item);
1027
- }
1028
- });
1029
- }
1030
- return result;
1031
- }
1032
- /**
1033
- * Adds the custom domain properties to the currently processed property, a.k.a annotations.
1034
- * @returns The list of custom domain properties.
1035
- */
1036
- customDomainProperties(object, context) {
1037
- const result = [];
1038
- const objectContext = context || object['@context'];
1039
- const ids = this._getLinkValues(object, ns.aml.vocabularies.document.customDomainProperties, objectContext);
1040
- if (Array.isArray(ids) && ids.length) {
1041
- ids.forEach((id) => {
1042
- const key = `amf://id${id}`;
1043
- let value = (object[id] || object[key]);
1044
- if (!value) {
1045
- return;
1046
- }
1047
- if (Array.isArray(value)) {
1048
- ;
1049
- [value] = value;
1050
- }
1051
- const extension = this.unknownDataNode(value, objectContext);
1052
- const name = this._getValue(value, ns.aml.vocabularies.core.extensionName, objectContext);
1053
- if (!name || !extension) {
1054
- return;
1055
- }
1056
- const cdp = {
1057
- id: key,
1058
- name,
1059
- extension,
1060
- };
1061
- result.push(cdp);
1062
- });
1063
- }
1064
- return result;
1065
- }
1066
- endPoint(object, context) {
1067
- const objectContext = context || object['@context'];
1068
- const result = {
1069
- id: object['@id'],
1070
- types: this.readTypes(object['@type'], objectContext),
1071
- customDomainProperties: this.customDomainProperties(object, objectContext),
1072
- sourceMaps: this.sourceMap(object),
1073
- path: '',
1074
- operations: [],
1075
- parameters: [],
1076
- payloads: [],
1077
- servers: [],
1078
- security: [],
1079
- extends: [],
1080
- };
1081
- const path = this._getValue(object, ns.aml.vocabularies.apiContract.path, objectContext);
1082
- if (path && typeof path === 'string') {
1083
- result.path = path;
1084
- }
1085
- const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext);
1086
- if (name && typeof name === 'string') {
1087
- result.name = name;
1088
- }
1089
- const description = this._getValue(object, ns.aml.vocabularies.core.description, objectContext);
1090
- if (description && typeof description === 'string') {
1091
- result.description = description;
1092
- }
1093
- const summary = this._getValue(object, ns.aml.vocabularies.core.summary, objectContext);
1094
- if (summary && typeof summary === 'string') {
1095
- result.summary = summary;
1096
- }
1097
- const operations = this[getArrayItems](object, ns.aml.vocabularies.apiContract.supportedOperation, objectContext);
1098
- if (Array.isArray(operations) && operations.length) {
1099
- result.operations = operations.map((i) => this.operation(i, objectContext));
1100
- }
1101
- const parameters = this[getArrayItems](object, ns.aml.vocabularies.apiContract.parameter, objectContext);
1102
- if (Array.isArray(parameters) && parameters.length) {
1103
- result.parameters = parameters.map((i) => this.parameter(i, objectContext));
1104
- }
1105
- const payloads = this[getArrayItems](object, ns.aml.vocabularies.apiContract.payload, objectContext);
1106
- if (Array.isArray(payloads) && payloads.length) {
1107
- result.payloads = payloads.map((i) => this.payload(/** @type IAmfPayload */ i, objectContext));
1108
- }
1109
- const servers = this[getArrayItems](object, ns.aml.vocabularies.apiContract.server, objectContext);
1110
- if (Array.isArray(servers) && servers.length) {
1111
- result.servers = servers.map((i) => this.server(i, objectContext));
1112
- }
1113
- const security = this[getArrayItems](object, ns.aml.vocabularies.security.security, objectContext);
1114
- if (Array.isArray(security) && security.length) {
1115
- result.security = security.map((i) => this.securityRequirement(i, objectContext));
1116
- }
1117
- const extensions = this[getArrayItems](object, ns.aml.vocabularies.document.extends, objectContext);
1118
- if (Array.isArray(extensions) && extensions.length) {
1119
- result.extends = [];
1120
- extensions.forEach((ex) => {
1121
- let extension = ex;
1122
- if (Array.isArray(extension)) {
1123
- ;
1124
- [extension] = extension;
1125
- }
1126
- if (this._hasType(extension, ns.aml.vocabularies.apiContract.ParametrizedResourceType, objectContext)) {
1127
- result.extends.push(this.parametrizedResourceType(extension, objectContext));
1128
- }
1129
- else if (this._hasType(extension, ns.aml.vocabularies.apiContract.ParametrizedTrait, objectContext)) {
1130
- result.extends.push(this.parametrizedTrait(extension, objectContext));
1131
- }
1132
- });
1133
- }
1134
- return result;
1135
- }
1136
- operation(object, context) {
1137
- const objectContext = context || object['@context'];
1138
- const result = {
1139
- id: object['@id'],
1140
- types: this.readTypes(object['@type'], objectContext),
1141
- customDomainProperties: this.customDomainProperties(object, objectContext),
1142
- sourceMaps: this.sourceMap(object),
1143
- method: '',
1144
- deprecated: false,
1145
- callbacks: [],
1146
- responses: [],
1147
- servers: [],
1148
- security: [],
1149
- accepts: [],
1150
- schemes: [],
1151
- contentType: [],
1152
- tags: [],
1153
- extends: [],
1154
- };
1155
- const method = this._getValue(object, ns.aml.vocabularies.apiContract.method, objectContext);
1156
- if (method && typeof method === 'string') {
1157
- result.method = method;
1158
- }
1159
- const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext);
1160
- if (name && typeof name === 'string') {
1161
- result.name = name;
1162
- }
1163
- const description = this._getValue(object, ns.aml.vocabularies.core.description, objectContext);
1164
- if (description && typeof description === 'string') {
1165
- result.description = description;
1166
- }
1167
- const summary = this._getValue(object, ns.aml.vocabularies.apiContract.guiSummary, objectContext);
1168
- if (summary && typeof summary === 'string') {
1169
- result.summary = summary;
1170
- }
1171
- const deprecated = this._getValue(object, ns.aml.vocabularies.core.deprecated, objectContext);
1172
- if (typeof deprecated === 'boolean') {
1173
- result.deprecated = deprecated;
1174
- }
1175
- const operationId = this._getValue(object, ns.aml.vocabularies.apiContract.operationId, objectContext);
1176
- if (operationId && typeof operationId === 'string') {
1177
- result.operationId = operationId;
1178
- }
1179
- const accepts = this._getValueArray(object, ns.aml.vocabularies.apiContract.accepts, objectContext);
1180
- if (Array.isArray(accepts)) {
1181
- result.accepts = accepts;
1182
- }
1183
- const schemes = this._getValueArray(object, ns.aml.vocabularies.apiContract.scheme, objectContext);
1184
- if (Array.isArray(schemes)) {
1185
- result.schemes = schemes;
1186
- }
1187
- const contentType = this._getValueArray(object, ns.aml.vocabularies.apiContract.contentType, objectContext);
1188
- if (Array.isArray(contentType)) {
1189
- result.contentType = contentType;
1190
- }
1191
- let expects = object[this._getAmfKey(ns.aml.vocabularies.apiContract.expects, objectContext)];
1192
- if (expects) {
1193
- if (Array.isArray(expects)) {
1194
- ;
1195
- [expects] = expects;
1196
- }
1197
- result.request = this.request(expects, objectContext);
1198
- }
1199
- let documentation = object[this._getAmfKey(ns.aml.vocabularies.core.documentation, objectContext)];
1200
- if (documentation) {
1201
- if (Array.isArray(documentation)) {
1202
- ;
1203
- [documentation] = documentation;
1204
- }
1205
- result.documentation = this.documentation(documentation, objectContext);
1206
- }
1207
- const responses = object[this._getAmfKey(ns.aml.vocabularies.apiContract.returns, objectContext)];
1208
- if (Array.isArray(responses)) {
1209
- result.responses = responses.map((r) => this.response(r, objectContext));
1210
- }
1211
- const callbacks = object[this._getAmfKey(ns.aml.vocabularies.apiContract.callback, objectContext)];
1212
- if (Array.isArray(callbacks)) {
1213
- result.callbacks = callbacks.map((c) => this.callback(c, objectContext));
1214
- }
1215
- const servers = object[this._getAmfKey(ns.aml.vocabularies.apiContract.server, objectContext)];
1216
- if (Array.isArray(servers)) {
1217
- result.servers = servers.map((s) => this.server(s));
1218
- }
1219
- const security = object[this._getAmfKey(ns.aml.vocabularies.security.security, objectContext)];
1220
- if (Array.isArray(security)) {
1221
- result.security = security.map((s) => this.securityRequirement(s, objectContext));
1222
- }
1223
- const tags = object[this._getAmfKey(ns.aml.vocabularies.apiContract.tag, objectContext)];
1224
- if (Array.isArray(tags) && tags.length) {
1225
- result.tags = tags.map((s) => this.tag(s, objectContext));
1226
- }
1227
- const traits = object[this._getAmfKey(ns.aml.vocabularies.document.extends, objectContext)];
1228
- if (Array.isArray(traits) && traits.length) {
1229
- result.extends = traits.map((t) => this.parametrizedTrait(t, objectContext));
1230
- }
1231
- return result;
1232
- }
1233
- tag(object, context) {
1234
- const objectContext = context || object['@context'];
1235
- const result = {
1236
- id: object['@id'],
1237
- types: this.readTypes(object['@type'], objectContext),
1238
- customDomainProperties: this.customDomainProperties(object, objectContext),
1239
- sourceMaps: this.sourceMap(object),
1240
- name: '',
1241
- };
1242
- const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext);
1243
- if (name && typeof name === 'string') {
1244
- result.name = name;
1245
- }
1246
- return result;
1247
- }
1248
- callback(object, context) {
1249
- const objectContext = context || object['@context'];
1250
- const result = {
1251
- id: object['@id'],
1252
- types: this.readTypes(object['@type'], objectContext),
1253
- customDomainProperties: this.customDomainProperties(object, objectContext),
1254
- sourceMaps: this.sourceMap(object),
1255
- };
1256
- const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext);
1257
- if (name && typeof name === 'string') {
1258
- result.name = name;
1259
- }
1260
- const expression = this._getValue(object, ns.aml.vocabularies.apiContract.expression, objectContext);
1261
- if (expression && typeof expression === 'string') {
1262
- result.expression = expression;
1263
- }
1264
- let endpoint = object[this._getAmfKey(ns.aml.vocabularies.apiContract.endpoint, objectContext)];
1265
- if (endpoint) {
1266
- if (Array.isArray(endpoint)) {
1267
- ;
1268
- [endpoint] = endpoint;
1269
- }
1270
- result.endpoint = this.endPoint(endpoint, objectContext);
1271
- }
1272
- return result;
1273
- }
1274
- request(object, context) {
1275
- const objectContext = context || object['@context'];
1276
- const result = {
1277
- id: object['@id'],
1278
- types: this.readTypes(object['@type'], objectContext),
1279
- customDomainProperties: this.customDomainProperties(object, objectContext),
1280
- sourceMaps: this.sourceMap(object),
1281
- required: false,
1282
- headers: [],
1283
- queryParameters: [],
1284
- payloads: [],
1285
- uriParameters: [],
1286
- cookieParameters: [],
1287
- };
1288
- const description = this._getValue(object, ns.aml.vocabularies.core.description, objectContext);
1289
- if (description && typeof description === 'string') {
1290
- result.description = description;
1291
- }
1292
- const required = this._getValue(object, ns.aml.vocabularies.apiContract.required, objectContext);
1293
- if (required && typeof required === 'boolean') {
1294
- result.required = required;
1295
- }
1296
- let queryString = object[this._getAmfKey(ns.aml.vocabularies.apiContract.queryString, objectContext)];
1297
- if (queryString) {
1298
- if (Array.isArray(queryString)) {
1299
- ;
1300
- [queryString] = queryString;
1301
- }
1302
- result.queryString = this.unknownShape(queryString, undefined, objectContext);
1303
- }
1304
- const headers = this[getArrayItems](object, ns.aml.vocabularies.apiContract.header, objectContext);
1305
- if (Array.isArray(headers) && headers.length) {
1306
- result.headers = headers.map((p) => this.parameter(p, objectContext));
1307
- }
1308
- const queryParameters = this[getArrayItems](object, ns.aml.vocabularies.apiContract.parameter, objectContext);
1309
- if (Array.isArray(queryParameters) && queryParameters.length) {
1310
- result.queryParameters = queryParameters.map((p) => this.parameter(p, objectContext));
1311
- }
1312
- const uriParameters = this[getArrayItems](object, ns.aml.vocabularies.apiContract.uriParameter, objectContext);
1313
- if (Array.isArray(uriParameters) && uriParameters.length) {
1314
- result.uriParameters = uriParameters.map((p) => this.parameter(p, objectContext));
1315
- }
1316
- const cookieParameters = this[getArrayItems](object, ns.aml.vocabularies.apiContract.cookieParameter, objectContext);
1317
- if (Array.isArray(cookieParameters) && cookieParameters.length) {
1318
- result.cookieParameters = cookieParameters.map((p) => this.parameter(p, objectContext));
1319
- }
1320
- const payloads = this[getArrayItems](object, ns.aml.vocabularies.apiContract.payload, objectContext);
1321
- if (Array.isArray(payloads) && payloads.length) {
1322
- result.payloads = payloads.map((p) => this.payload(p, objectContext));
1323
- }
1324
- return result;
1325
- }
1326
- response(object, context) {
1327
- const objectContext = context || object['@context'];
1328
- const result = {
1329
- id: object['@id'],
1330
- types: this.readTypes(object['@type'], objectContext),
1331
- customDomainProperties: this.customDomainProperties(object, objectContext),
1332
- sourceMaps: this.sourceMap(object, objectContext),
1333
- headers: [],
1334
- payloads: [],
1335
- examples: [],
1336
- links: [],
1337
- };
1338
- const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext);
1339
- if (name && typeof name === 'string') {
1340
- result.name = name;
1341
- }
1342
- const description = this._getValue(object, ns.aml.vocabularies.core.description, objectContext);
1343
- if (description && typeof description === 'string') {
1344
- result.description = description;
1345
- }
1346
- const statusCode = this._getValue(object, ns.aml.vocabularies.apiContract.statusCode, objectContext);
1347
- if (statusCode && typeof statusCode === 'string') {
1348
- result.statusCode = statusCode;
1349
- }
1350
- const headers = this[getArrayItems](object, ns.aml.vocabularies.apiContract.header, objectContext);
1351
- if (Array.isArray(headers) && headers.length) {
1352
- result.headers = headers.map((p) => this.parameter(p, objectContext));
1353
- }
1354
- const payloads = this[getArrayItems](object, ns.aml.vocabularies.apiContract.payload, objectContext);
1355
- if (Array.isArray(payloads) && payloads.length) {
1356
- result.payloads = payloads.map((p) => this.payload(p, objectContext));
1357
- }
1358
- const examples = object[this._getAmfKey(ns.aml.vocabularies.apiContract.examples, objectContext)];
1359
- if (Array.isArray(examples) && examples.length) {
1360
- result.examples = examples.map((e) => this.example(e, objectContext));
1361
- }
1362
- const links = object[this._getAmfKey(ns.aml.vocabularies.apiContract.link, objectContext)];
1363
- if (Array.isArray(links) && links.length) {
1364
- result.links = links.map((p) => this.templatedLink(p, objectContext));
1365
- }
1366
- return result;
1367
- }
1368
- payload(object, context) {
1369
- const objectContext = context || object['@context'];
1370
- const result = {
1371
- id: object['@id'],
1372
- types: this.readTypes(object['@type'], objectContext),
1373
- customDomainProperties: this.customDomainProperties(object, objectContext),
1374
- sourceMaps: this.sourceMap(object, objectContext),
1375
- examples: [],
1376
- // encoding: [],
1377
- };
1378
- const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext);
1379
- if (name && typeof name === 'string') {
1380
- result.name = name;
1381
- }
1382
- const mediaType = this._getValue(object, ns.aml.vocabularies.core.mediaType, objectContext);
1383
- if (mediaType && typeof mediaType === 'string') {
1384
- result.mediaType = mediaType;
1385
- }
1386
- let schema = object[this._getAmfKey(ns.aml.vocabularies.shapes.schema, objectContext)];
1387
- if (schema) {
1388
- if (Array.isArray(schema)) {
1389
- ;
1390
- [schema] = schema;
1391
- }
1392
- result.schema = this.unknownShape(schema, {
1393
- trackedId: result.id,
1394
- }, objectContext);
1395
- }
1396
- const examples = object[this._getAmfKey(ns.aml.vocabularies.apiContract.examples, objectContext)];
1397
- if (Array.isArray(examples) && examples.length) {
1398
- result.examples = examples.map((e) => this.example(e, objectContext));
1399
- }
1400
- // if (Array.isArray(encoding) && encoding.length) {
1401
- // result.encoding = encoding.map((p) => p.id);
1402
- // }
1403
- return result;
1404
- }
1405
- templatedLink(object, context) {
1406
- const objectContext = context || object['@context'];
1407
- const result = {
1408
- id: object['@id'],
1409
- types: this.readTypes(object['@type'], objectContext),
1410
- customDomainProperties: this.customDomainProperties(object, objectContext),
1411
- sourceMaps: this.sourceMap(object, objectContext),
1412
- mapping: [],
1413
- };
1414
- const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext);
1415
- if (name && typeof name === 'string') {
1416
- result.name = name;
1417
- }
1418
- const description = this._getValue(object, ns.aml.vocabularies.core.description, objectContext);
1419
- if (description && typeof description === 'string') {
1420
- result.description = description;
1421
- }
1422
- const operationId = this._getValue(object, ns.aml.vocabularies.apiContract.operationId, objectContext);
1423
- if (operationId && typeof operationId === 'string') {
1424
- result.operationId = operationId;
1425
- }
1426
- let server = object[this._getAmfKey(ns.aml.vocabularies.apiContract.server, objectContext)];
1427
- if (server) {
1428
- if (Array.isArray(server)) {
1429
- ;
1430
- [server] = server;
1431
- }
1432
- result.server = this.server(server, objectContext);
1433
- }
1434
- let mapping = object[this._getAmfKey(ns.aml.vocabularies.apiContract.mapping, objectContext)];
1435
- if (mapping) {
1436
- if (mapping && !Array.isArray(mapping)) {
1437
- mapping = [mapping];
1438
- }
1439
- if (mapping) {
1440
- result.mapping = mapping.map((item) => this.iriTemplateMapping(item, objectContext));
1441
- }
1442
- }
1443
- // if (!template.isNullOrEmpty) {
1444
- // result.template = template.value();
1445
- // }
1446
- // if (!requestBody.isNullOrEmpty) {
1447
- // result.requestBody = requestBody.value();
1448
- // }
1449
- return result;
1450
- }
1451
- iriTemplateMapping(object, context) {
1452
- const objectContext = context || object['@context'];
1453
- const result = {
1454
- id: object['@id'],
1455
- types: this.readTypes(object['@type'], objectContext),
1456
- customDomainProperties: this.customDomainProperties(object, objectContext),
1457
- sourceMaps: this.sourceMap(object, objectContext),
1458
- };
1459
- const templateVariable = this._getValue(object, ns.aml.vocabularies.apiContract.templateVariable, objectContext);
1460
- if (templateVariable && typeof templateVariable === 'string') {
1461
- result.templateVariable = templateVariable;
1462
- }
1463
- const linkExpression = this._getValue(object, ns.aml.vocabularies.apiContract.linkExpression, objectContext);
1464
- if (linkExpression && typeof linkExpression === 'string') {
1465
- result.linkExpression = linkExpression;
1466
- }
1467
- return result;
1468
- }
1469
- parametrizedSecurityScheme(object, context) {
1470
- const objectContext = context || object['@context'];
1471
- const result = {
1472
- id: object['@id'],
1473
- types: this.readTypes(object['@type'], objectContext),
1474
- customDomainProperties: this.customDomainProperties(object, objectContext),
1475
- sourceMaps: this.sourceMap(object, objectContext),
1476
- };
1477
- const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext);
1478
- if (name && typeof name === 'string') {
1479
- result.name = name;
1480
- }
1481
- let scheme = object[this._getAmfKey(ns.aml.vocabularies.security.scheme, objectContext)];
1482
- if (scheme) {
1483
- if (Array.isArray(scheme)) {
1484
- ;
1485
- [scheme] = scheme;
1486
- }
1487
- result.scheme = this.securityScheme(scheme, objectContext);
1488
- }
1489
- let settings = object[this._getAmfKey(ns.aml.vocabularies.security.settings, objectContext)];
1490
- if (settings) {
1491
- if (Array.isArray(settings)) {
1492
- ;
1493
- [settings] = settings;
1494
- }
1495
- result.settings = this.securitySettings(settings, objectContext);
1496
- }
1497
- return result;
1498
- }
1499
- securitySchemeListItem(object, context) {
1500
- const objectContext = context || object['@context'];
1501
- const result = {
1502
- id: object['@id'],
1503
- types: this.readTypes(object['@type'], objectContext),
1504
- type: '',
1505
- };
1506
- const type = this._getValue(object, ns.aml.vocabularies.security.type, objectContext);
1507
- if (type && typeof type === 'string') {
1508
- result.type = type;
1509
- }
1510
- const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext);
1511
- if (name && typeof name === 'string') {
1512
- result.name = name;
1513
- }
1514
- const displayName = this._getValue(object, ns.aml.vocabularies.core.displayName, objectContext);
1515
- if (displayName && typeof displayName === 'string') {
1516
- result.displayName = displayName;
1517
- }
1518
- return result;
1519
- }
1520
- securityScheme(object, context) {
1521
- const objectContext = context || object['@context'];
1522
- const result = {
1523
- id: object['@id'],
1524
- types: this.readTypes(object['@type'], objectContext),
1525
- customDomainProperties: this.customDomainProperties(object, objectContext),
1526
- sourceMaps: this.sourceMap(object, objectContext),
1527
- headers: [],
1528
- queryParameters: [],
1529
- responses: [],
1530
- };
1531
- const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext);
1532
- if (name && typeof name === 'string') {
1533
- result.name = name;
1534
- }
1535
- const displayName = this._getValue(object, ns.aml.vocabularies.core.displayName, objectContext);
1536
- if (displayName && typeof displayName === 'string') {
1537
- result.displayName = displayName;
1538
- }
1539
- const description = this._getValue(object, ns.aml.vocabularies.core.description, objectContext);
1540
- if (description && typeof description === 'string') {
1541
- result.description = description;
1542
- }
1543
- const type = this._getValue(object, ns.aml.vocabularies.security.type, objectContext);
1544
- if (type && typeof type === 'string') {
1545
- result.type = type;
1546
- }
1547
- let settings = object[this._getAmfKey(ns.aml.vocabularies.security.settings, objectContext)];
1548
- if (settings) {
1549
- if (Array.isArray(settings)) {
1550
- ;
1551
- [settings] = settings;
1552
- }
1553
- result.settings = this.securitySettings(settings, objectContext);
1554
- }
1555
- let queryString = object[this._getAmfKey(ns.aml.vocabularies.apiContract.queryString, objectContext)];
1556
- if (queryString) {
1557
- if (Array.isArray(queryString)) {
1558
- ;
1559
- [queryString] = queryString;
1560
- }
1561
- result.queryString = this.unknownShape(queryString, undefined, objectContext);
1562
- }
1563
- const headers = this[getArrayItems](object, ns.aml.vocabularies.apiContract.header, objectContext);
1564
- if (Array.isArray(headers) && headers.length) {
1565
- result.headers = headers.map((p) => this.parameter(p, objectContext));
1566
- }
1567
- const queryParameters = this[getArrayItems](object, ns.aml.vocabularies.apiContract.parameter, objectContext);
1568
- if (Array.isArray(queryParameters) && queryParameters.length) {
1569
- result.queryParameters = queryParameters.map((p) => this.parameter(p, objectContext));
1570
- }
1571
- const responses = this[getArrayItems](object, ns.aml.vocabularies.apiContract.response, objectContext);
1572
- if (Array.isArray(responses) && responses.length) {
1573
- result.responses = responses.map((p) => this.response(p, objectContext));
1574
- }
1575
- return result;
1576
- }
1577
- securityRequirement(object, context) {
1578
- const objectContext = context || object['@context'];
1579
- const result = {
1580
- id: object['@id'],
1581
- types: this.readTypes(object['@type'], objectContext),
1582
- customDomainProperties: this.customDomainProperties(object, objectContext),
1583
- sourceMaps: this.sourceMap(object, objectContext),
1584
- schemes: [],
1585
- };
1586
- const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext);
1587
- if (name && typeof name === 'string') {
1588
- result.name = name;
1589
- }
1590
- const schemes = object[this._getAmfKey(ns.aml.vocabularies.security.schemes, objectContext)];
1591
- if (Array.isArray(schemes) && schemes.length) {
1592
- result.schemes = schemes.map((p) => this.parametrizedSecurityScheme(p, objectContext));
1593
- }
1594
- return result;
1595
- }
1596
- securitySettings(object, context) {
1597
- const objectContext = context || object['@context'];
1598
- const types = this.readTypes(object['@type'], objectContext);
1599
- if (types.includes(ns.aml.vocabularies.security.OAuth1Settings)) {
1600
- return this.oAuth1Settings(object, objectContext);
1601
- }
1602
- if (types.includes(ns.aml.vocabularies.security.OAuth2Settings)) {
1603
- return this.oAuth2Settings(object, objectContext);
1604
- }
1605
- if (types.includes(ns.aml.vocabularies.security.ApiKeySettings)) {
1606
- return this.apiKeySettings(object, objectContext);
1607
- }
1608
- if (types.includes(ns.aml.vocabularies.security.HttpSettings)) {
1609
- return this.httpSettings(object, objectContext);
1610
- }
1611
- if (types.includes(ns.aml.vocabularies.security.OpenIdConnectSettings)) {
1612
- return this.openIdConnectSettings(object, objectContext);
1613
- }
1614
- return this.settings(object, objectContext);
1615
- }
1616
- /**
1617
- * @param {IAmfSettings} object
1618
- * @param context
1619
- * @returns {IApiSecuritySettings}
1620
- */
1621
- settings(object, context) {
1622
- const objectContext = context || object['@context'];
1623
- const result = {
1624
- id: object['@id'],
1625
- types: this.readTypes(object['@type'], objectContext),
1626
- customDomainProperties: this.customDomainProperties(object, objectContext),
1627
- sourceMaps: this.sourceMap(object, objectContext),
1628
- };
1629
- // if (additionalProperties && additionalProperties.id) {
1630
- // result.additionalProperties = this.unknownDataNode(additionalProperties);
1631
- // }
1632
- return result;
1633
- }
1634
- oAuth1Settings(object, context) {
1635
- const objectContext = context || object['@context'];
1636
- const result = this.settings(object, objectContext);
1637
- const authorizationUri = this._getValue(object, ns.aml.vocabularies.security.authorizationUri, objectContext);
1638
- if (authorizationUri && typeof authorizationUri === 'string') {
1639
- result.authorizationUri = authorizationUri;
1640
- }
1641
- const requestTokenUri = this._getValue(object, ns.aml.vocabularies.security.requestTokenUri, objectContext);
1642
- if (requestTokenUri && typeof requestTokenUri === 'string') {
1643
- result.requestTokenUri = requestTokenUri;
1644
- }
1645
- const tokenCredentialsUri = this._getValue(object, ns.aml.vocabularies.security.tokenCredentialsUri, objectContext);
1646
- if (tokenCredentialsUri && typeof tokenCredentialsUri === 'string') {
1647
- result.tokenCredentialsUri = tokenCredentialsUri;
1648
- }
1649
- const signatures = this._getValueArray(object, ns.aml.vocabularies.security.signature, objectContext);
1650
- if (Array.isArray(signatures) && signatures.length) {
1651
- result.signatures = signatures;
1652
- }
1653
- else {
1654
- result.signatures = [];
1655
- }
1656
- return result;
1657
- }
1658
- oAuth2Settings(object, context) {
1659
- const objectContext = context || object['@context'];
1660
- const result = this.settings(object, objectContext);
1661
- const grants = this._getValueArray(object, ns.aml.vocabularies.security.authorizationGrant, objectContext);
1662
- if (Array.isArray(grants) && grants.length) {
1663
- result.authorizationGrants = grants;
1664
- }
1665
- else {
1666
- result.authorizationGrants = [];
1667
- }
1668
- const flows = object[this._getAmfKey(ns.aml.vocabularies.security.flows, objectContext)];
1669
- if (Array.isArray(flows) && flows.length) {
1670
- result.flows = flows.map((p) => this.oAuth2Flow(p, objectContext));
1671
- }
1672
- else {
1673
- result.flows = [];
1674
- }
1675
- return result;
1676
- }
1677
- oAuth2Flow(object, context) {
1678
- const objectContext = context || object['@context'];
1679
- const result = {
1680
- id: object['@id'],
1681
- types: this.readTypes(object['@type'], objectContext),
1682
- customDomainProperties: this.customDomainProperties(object, objectContext),
1683
- scopes: [],
1684
- sourceMaps: this.sourceMap(object, objectContext),
1685
- };
1686
- const authorizationUri = this._getValue(object, ns.aml.vocabularies.security.authorizationUri, objectContext);
1687
- if (authorizationUri && typeof authorizationUri === 'string') {
1688
- result.authorizationUri = authorizationUri;
1689
- }
1690
- const accessTokenUri = this._getValue(object, ns.aml.vocabularies.security.accessTokenUri, objectContext);
1691
- if (accessTokenUri && typeof accessTokenUri === 'string') {
1692
- result.accessTokenUri = accessTokenUri;
1693
- }
1694
- const flow = this._getValue(object, ns.aml.vocabularies.security.flow, objectContext);
1695
- if (flow && typeof flow === 'string') {
1696
- result.flow = flow;
1697
- }
1698
- const refreshUri = this._getValue(object, ns.aml.vocabularies.security.refreshUri, objectContext);
1699
- if (refreshUri && typeof refreshUri === 'string') {
1700
- result.refreshUri = refreshUri;
1701
- }
1702
- const scopes = object[this._getAmfKey(ns.aml.vocabularies.security.scope, objectContext)];
1703
- if (Array.isArray(scopes) && scopes.length) {
1704
- result.scopes = scopes.map((p) => this.scope(p, objectContext));
1705
- }
1706
- return result;
1707
- }
1708
- scope(object, context) {
1709
- const objectContext = context || object['@context'];
1710
- const result = {
1711
- id: object['@id'],
1712
- types: this.readTypes(object['@type'], objectContext),
1713
- customDomainProperties: this.customDomainProperties(object, objectContext),
1714
- sourceMaps: this.sourceMap(object, objectContext),
1715
- };
1716
- const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext);
1717
- if (name && typeof name === 'string') {
1718
- result.name = name;
1719
- }
1720
- const description = this._getValue(object, ns.aml.vocabularies.core.description, objectContext);
1721
- if (description && typeof description === 'string') {
1722
- result.description = description;
1723
- }
1724
- return result;
1725
- }
1726
- apiKeySettings(object, context) {
1727
- const objectContext = context || object['@context'];
1728
- const result = this.settings(object, objectContext);
1729
- const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext);
1730
- if (name && typeof name === 'string') {
1731
- result.name = name;
1732
- }
1733
- const inParam = this._getValue(object, ns.aml.vocabularies.security.in, objectContext);
1734
- if (inParam && typeof inParam === 'string') {
1735
- result.in = inParam;
1736
- }
1737
- return result;
1738
- }
1739
- httpSettings(object, context) {
1740
- const objectContext = context || object['@context'];
1741
- const result = this.settings(object, objectContext);
1742
- const scheme = this._getValue(object, ns.aml.vocabularies.security.scheme, objectContext);
1743
- if (scheme && typeof scheme === 'string') {
1744
- result.scheme = scheme;
1745
- }
1746
- const bearerFormat = this._getValue(object, ns.aml.vocabularies.security.bearerFormat, objectContext);
1747
- if (bearerFormat && typeof bearerFormat === 'string') {
1748
- result.bearerFormat = bearerFormat;
1749
- }
1750
- return result;
1751
- }
1752
- openIdConnectSettings(object, context) {
1753
- const objectContext = context || object['@context'];
1754
- const result = this.settings(object, objectContext);
1755
- const url = this._getValue(object, ns.aml.vocabularies.security.openIdConnectUrl, objectContext);
1756
- if (url && typeof url === 'string') {
1757
- result.url = url;
1758
- }
1759
- return result;
1760
- }
1761
- /**
1762
- * Serializes source maps, when available.
1763
- */
1764
- sourceMap(object, context) {
1765
- const objectContext = context || object['@context'];
1766
- let sm = object[this._getAmfKey(ns.aml.vocabularies.docSourceMaps.sources, objectContext)];
1767
- if (!sm) {
1768
- return undefined;
1769
- }
1770
- if (Array.isArray(sm)) {
1771
- ;
1772
- [sm] = sm;
1773
- }
1774
- const result = {
1775
- id: sm['@id'],
1776
- types: this.readTypes(sm['@type']),
1777
- };
1778
- const synthesizedField = sm[this._getAmfKey(ns.aml.vocabularies.docSourceMaps.synthesizedField, objectContext)];
1779
- if (Array.isArray(synthesizedField) && synthesizedField.length) {
1780
- result.synthesizedField = synthesizedField.map((i) => this.synthesizedField(i, objectContext));
1781
- }
1782
- const lexical = sm[this._getAmfKey(ns.aml.vocabularies.docSourceMaps.lexical, objectContext)];
1783
- if (Array.isArray(lexical) && lexical.length) {
1784
- result.lexical = lexical.map((i) => this.synthesizedField(i, objectContext));
1785
- }
1786
- const trackedElement = sm[this._getAmfKey(ns.aml.vocabularies.docSourceMaps.trackedElement, objectContext)];
1787
- if (Array.isArray(trackedElement) && trackedElement.length) {
1788
- result.trackedElement = this.synthesizedField(trackedElement[0], objectContext);
1789
- }
1790
- const autoName = sm[this._getAmfKey(ns.aml.vocabularies.docSourceMaps.autoGeneratedName, objectContext)];
1791
- if (Array.isArray(autoName) && autoName.length) {
1792
- result.autoGeneratedName = autoName.map((i) => this.synthesizedField(i, objectContext));
1793
- }
1794
- const jsonSchema = sm[this._getAmfKey(ns.aml.vocabularies.docSourceMaps.parsedJsonSchema, objectContext)];
1795
- if (Array.isArray(jsonSchema) && jsonSchema.length) {
1796
- result.parsedJsonSchema = this.synthesizedField(jsonSchema[0], objectContext);
1797
- }
1798
- const declaredElement = sm[this._getAmfKey(ns.aml.vocabularies.docSourceMaps.declaredElement, objectContext)];
1799
- if (Array.isArray(declaredElement) && declaredElement.length) {
1800
- result.declaredElement = this.synthesizedField(declaredElement[0], objectContext);
1801
- }
1802
- return result;
1803
- }
1804
- synthesizedField(object, context) {
1805
- // compact model
1806
- if (typeof object === 'string') {
1807
- return {
1808
- id: 'synthesizedField/generated',
1809
- value: object,
1810
- };
1811
- }
1812
- const result = {
1813
- id: object['@id'],
1814
- value: '',
1815
- };
1816
- const element = this._getValue(object, ns.aml.vocabularies.docSourceMaps.element, context);
1817
- if (typeof element === 'string') {
1818
- result.element = element;
1819
- }
1820
- const value = this._getValue(object, ns.aml.vocabularies.docSourceMaps.value, context);
1821
- if (typeof value === 'string') {
1822
- result.value = value;
1823
- }
1824
- return result;
1825
- }
1826
- parametrizedDeclaration(object, context) {
1827
- const objectContext = context || object['@context'];
1828
- const result = {
1829
- id: object['@id'],
1830
- types: this.readTypes(object['@type'], objectContext),
1831
- variables: [],
1832
- customDomainProperties: this.customDomainProperties(object, objectContext),
1833
- sourceMaps: this.sourceMap(object, objectContext),
1834
- };
1835
- const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext);
1836
- if (name && typeof name === 'string') {
1837
- result.name = name;
1838
- }
1839
- const variables = object[this._getAmfKey(ns.aml.vocabularies.document.variable, objectContext)];
1840
- if (Array.isArray(variables)) {
1841
- variables.forEach((item) => {
1842
- result.variables.push(this.variableValue(item, objectContext));
1843
- });
1844
- }
1845
- const targets = object[this._getAmfKey(ns.aml.vocabularies.document.target, objectContext)];
1846
- if (Array.isArray(targets) && targets.length) {
1847
- const [target] = targets;
1848
- result.target = this.abstractDeclaration(target, objectContext);
1849
- }
1850
- return result;
1851
- }
1852
- parametrizedTrait(object, context) {
1853
- const objectContext = context || object['@context'];
1854
- const result = this.parametrizedDeclaration(object, objectContext);
1855
- return result;
1856
- }
1857
- parametrizedResourceType(object, context) {
1858
- const objectContext = context || object['@context'];
1859
- const result = this.parametrizedDeclaration(object, objectContext);
1860
- return result;
1861
- }
1862
- variableValue(object, context) {
1863
- const objectContext = context || object['@context'];
1864
- const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext);
1865
- const result = {
1866
- id: object['@id'],
1867
- types: this.readTypes(object['@type'], objectContext),
1868
- customDomainProperties: this.customDomainProperties(object, objectContext),
1869
- sourceMaps: this.sourceMap(object, objectContext),
1870
- name,
1871
- };
1872
- const values = object[this._getAmfKey(ns.aml.vocabularies.document.value, objectContext)];
1873
- if (Array.isArray(values)) {
1874
- const [item] = values;
1875
- result.value = this.unknownDataNode(item, objectContext);
1876
- }
1877
- return result;
1878
- }
1879
- abstractDeclaration(object, context) {
1880
- const objectContext = context || object['@context'];
1881
- const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext);
1882
- const result = {
1883
- id: object['@id'],
1884
- types: this.readTypes(object['@type'], objectContext),
1885
- customDomainProperties: this.customDomainProperties(object, objectContext),
1886
- sourceMaps: this.sourceMap(object, objectContext),
1887
- name,
1888
- variables: [],
1889
- };
1890
- const variables = this._getValueArray(object, ns.aml.vocabularies.document.variable, objectContext);
1891
- if (Array.isArray(variables)) {
1892
- result.variables = variables;
1893
- }
1894
- const description = this._getValue(object, ns.aml.vocabularies.core.description, objectContext);
1895
- if (description && typeof description === 'string') {
1896
- result.description = description;
1897
- }
1898
- const dataNode = object[this._getAmfKey(ns.aml.vocabularies.document.dataNode, objectContext)];
1899
- if (Array.isArray(dataNode)) {
1900
- const [item] = dataNode;
1901
- result.dataNode = this.unknownDataNode(item, objectContext);
1902
- }
1903
- return result;
1904
- }
1905
- /**
1906
- * @param object The EndPoint to serialize as a list item.
1907
- * @returns Serialized EndPoint as a list item.
1908
- */
1909
- endPointWithOperationsListItem(object, context) {
1910
- const path = this._getValue(object, ns.aml.vocabularies.apiContract.path, context);
1911
- const result = {
1912
- id: object['@id'],
1913
- path,
1914
- operations: [],
1915
- };
1916
- const operations = this[getArrayItems](object, ns.aml.vocabularies.apiContract.supportedOperation, context);
1917
- if (Array.isArray(operations) && operations.length) {
1918
- result.operations = operations.map((i) => this.operationListItem(i, context));
1919
- }
1920
- const name = this._getValue(object, ns.aml.vocabularies.core.name, context);
1921
- if (name && typeof name === 'string') {
1922
- result.name = name;
1923
- }
1924
- return result;
1925
- }
1926
- /**
1927
- * @param object The Operation to serialize as a list item.
1928
- * @param context A context to use. If not set, it looks for the context of the passed model
1929
- * @returns Serialized Operation as a list item.
1930
- */
1931
- operationListItem(object, context) {
1932
- const result = {
1933
- id: object['@id'],
1934
- method: '',
1935
- };
1936
- const method = this._getValue(object, ns.aml.vocabularies.apiContract.method, context);
1937
- if (method && typeof method === 'string') {
1938
- result.method = method;
1939
- }
1940
- const name = this._getValue(object, ns.aml.vocabularies.core.name, context);
1941
- if (name && typeof name === 'string') {
1942
- result.name = name;
1943
- }
1944
- return result;
1945
- }
1946
- }
1947
- //# sourceMappingURL=AmfSerializer.js.map