@api-client/core 0.11.11 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (252) hide show
  1. package/Testing.md +1 -1
  2. package/bin/plugins/events/EventPlugin.ts +61 -0
  3. package/bin/plugins/events/assert.ts +193 -0
  4. package/bin/plugins/events/types.ts +6 -0
  5. package/bin/test.ts +8 -1
  6. package/build/src/amf/AmfShapeGenerator.d.ts +6 -3
  7. package/build/src/amf/AmfShapeGenerator.d.ts.map +1 -1
  8. package/build/src/amf/AmfShapeGenerator.js +4 -1
  9. package/build/src/amf/AmfShapeGenerator.js.map +1 -1
  10. package/build/src/amf/AmfTypes.d.ts +2 -2
  11. package/build/src/amf/AmfTypes.d.ts.map +1 -1
  12. package/build/src/amf/AmfTypes.js.map +1 -1
  13. package/build/src/amf/DataValueGenerator.d.ts +15 -15
  14. package/build/src/amf/DataValueGenerator.d.ts.map +1 -1
  15. package/build/src/amf/DataValueGenerator.js +14 -14
  16. package/build/src/amf/DataValueGenerator.js.map +1 -1
  17. package/build/src/browser.d.ts +12 -9
  18. package/build/src/browser.d.ts.map +1 -1
  19. package/build/src/browser.js +11 -8
  20. package/build/src/browser.js.map +1 -1
  21. package/build/src/exceptions/attach_exception.d.ts +11 -0
  22. package/build/src/exceptions/attach_exception.d.ts.map +1 -0
  23. package/build/src/exceptions/attach_exception.js +11 -0
  24. package/build/src/exceptions/attach_exception.js.map +1 -0
  25. package/build/src/exceptions/detach_exception.d.ts +11 -0
  26. package/build/src/exceptions/detach_exception.d.ts.map +1 -0
  27. package/build/src/exceptions/detach_exception.js +11 -0
  28. package/build/src/exceptions/detach_exception.js.map +1 -0
  29. package/build/src/exceptions/remove_model_exception.d.ts +8 -0
  30. package/build/src/exceptions/remove_model_exception.d.ts.map +1 -0
  31. package/build/src/exceptions/remove_model_exception.js +8 -0
  32. package/build/src/exceptions/remove_model_exception.js.map +1 -0
  33. package/build/src/exceptions/remove_namespace_exception.d.ts +8 -0
  34. package/build/src/exceptions/remove_namespace_exception.d.ts.map +1 -0
  35. package/build/src/exceptions/remove_namespace_exception.js +8 -0
  36. package/build/src/exceptions/remove_namespace_exception.js.map +1 -0
  37. package/build/src/index.d.ts +12 -9
  38. package/build/src/index.d.ts.map +1 -1
  39. package/build/src/index.js +11 -8
  40. package/build/src/index.js.map +1 -1
  41. package/build/src/legacy.d.ts +8 -0
  42. package/build/src/legacy.d.ts.map +1 -1
  43. package/build/src/legacy.js +9 -0
  44. package/build/src/legacy.js.map +1 -1
  45. package/build/src/modeling/Bindings.d.ts +2 -2
  46. package/build/src/modeling/Bindings.d.ts.map +1 -1
  47. package/build/src/modeling/Bindings.js.map +1 -1
  48. package/build/src/modeling/DataDomain.d.ts +601 -0
  49. package/build/src/modeling/DataDomain.d.ts.map +1 -0
  50. package/build/src/modeling/DataDomain.js +1142 -0
  51. package/build/src/modeling/DataDomain.js.map +1 -0
  52. package/build/src/modeling/DataFormat.d.ts +42 -41
  53. package/build/src/modeling/DataFormat.d.ts.map +1 -1
  54. package/build/src/modeling/DataFormat.js +30 -131
  55. package/build/src/modeling/DataFormat.js.map +1 -1
  56. package/build/src/modeling/DomainAssociation.d.ts +281 -0
  57. package/build/src/modeling/DomainAssociation.d.ts.map +1 -0
  58. package/build/src/modeling/DomainAssociation.js +440 -0
  59. package/build/src/modeling/DomainAssociation.js.map +1 -0
  60. package/build/src/modeling/DomainElement.d.ts +33 -0
  61. package/build/src/modeling/DomainElement.d.ts.map +1 -0
  62. package/build/src/modeling/DomainElement.js +32 -0
  63. package/build/src/modeling/DomainElement.js.map +1 -0
  64. package/build/src/modeling/DomainEntity.d.ts +383 -0
  65. package/build/src/modeling/DomainEntity.d.ts.map +1 -0
  66. package/build/src/modeling/DomainEntity.js +718 -0
  67. package/build/src/modeling/DomainEntity.js.map +1 -0
  68. package/build/src/modeling/DomainFile.d.ts +25 -0
  69. package/build/src/modeling/DomainFile.d.ts.map +1 -0
  70. package/build/src/modeling/DomainFile.js +86 -0
  71. package/build/src/modeling/DomainFile.js.map +1 -0
  72. package/build/src/modeling/DomainImpactAnalysis.d.ts +60 -47
  73. package/build/src/modeling/DomainImpactAnalysis.d.ts.map +1 -1
  74. package/build/src/modeling/DomainImpactAnalysis.js +201 -132
  75. package/build/src/modeling/DomainImpactAnalysis.js.map +1 -1
  76. package/build/src/modeling/DomainModel.d.ts +226 -0
  77. package/build/src/modeling/DomainModel.d.ts.map +1 -0
  78. package/build/src/modeling/DomainModel.js +401 -0
  79. package/build/src/modeling/DomainModel.js.map +1 -0
  80. package/build/src/modeling/DomainNamespace.d.ts +268 -0
  81. package/build/src/modeling/DomainNamespace.d.ts.map +1 -0
  82. package/build/src/modeling/DomainNamespace.js +512 -0
  83. package/build/src/modeling/DomainNamespace.js.map +1 -0
  84. package/build/src/modeling/DomainProperty.d.ts +281 -0
  85. package/build/src/modeling/DomainProperty.d.ts.map +1 -0
  86. package/build/src/modeling/DomainProperty.js +560 -0
  87. package/build/src/modeling/DomainProperty.js.map +1 -0
  88. package/build/src/modeling/DomainSerialization.d.ts +40 -0
  89. package/build/src/modeling/DomainSerialization.d.ts.map +1 -0
  90. package/build/src/modeling/DomainSerialization.js +288 -0
  91. package/build/src/modeling/DomainSerialization.js.map +1 -0
  92. package/build/src/modeling/DomainVersioning.d.ts +17 -0
  93. package/build/src/modeling/DomainVersioning.d.ts.map +1 -0
  94. package/build/src/modeling/DomainVersioning.js +124 -0
  95. package/build/src/modeling/DomainVersioning.js.map +1 -0
  96. package/build/src/modeling/GraphUtils.d.ts +8 -0
  97. package/build/src/modeling/GraphUtils.d.ts.map +1 -0
  98. package/build/src/modeling/GraphUtils.js +26 -0
  99. package/build/src/modeling/GraphUtils.js.map +1 -0
  100. package/build/src/modeling/amf/ShapeGenerator.d.ts +164 -0
  101. package/build/src/modeling/amf/ShapeGenerator.d.ts.map +1 -0
  102. package/build/src/modeling/amf/ShapeGenerator.js +492 -0
  103. package/build/src/modeling/amf/ShapeGenerator.js.map +1 -0
  104. package/build/src/modeling/{DataAssociation.d.ts → legacy/DataAssociation.d.ts} +10 -5
  105. package/build/src/modeling/legacy/DataAssociation.d.ts.map +1 -0
  106. package/build/src/modeling/{DataAssociation.js → legacy/DataAssociation.js} +9 -6
  107. package/build/src/modeling/legacy/DataAssociation.js.map +1 -0
  108. package/build/src/modeling/{DataEntity.d.ts → legacy/DataEntity.d.ts} +12 -7
  109. package/build/src/modeling/legacy/DataEntity.d.ts.map +1 -0
  110. package/build/src/modeling/{DataEntity.js → legacy/DataEntity.js} +19 -18
  111. package/build/src/modeling/legacy/DataEntity.js.map +1 -0
  112. package/build/src/modeling/{DataEntityBuilder.d.ts → legacy/DataEntityBuilder.d.ts} +3 -2
  113. package/build/src/modeling/legacy/DataEntityBuilder.d.ts.map +1 -0
  114. package/build/src/modeling/{DataEntityBuilder.js → legacy/DataEntityBuilder.js} +3 -2
  115. package/build/src/modeling/legacy/DataEntityBuilder.js.map +1 -0
  116. package/build/src/modeling/legacy/DataImpactAnalysis.d.ts +298 -0
  117. package/build/src/modeling/legacy/DataImpactAnalysis.d.ts.map +1 -0
  118. package/build/src/modeling/legacy/DataImpactAnalysis.js +441 -0
  119. package/build/src/modeling/legacy/DataImpactAnalysis.js.map +1 -0
  120. package/build/src/modeling/{DataModel.d.ts → legacy/DataModel.d.ts} +6 -4
  121. package/build/src/modeling/legacy/DataModel.d.ts.map +1 -0
  122. package/build/src/modeling/{DataModel.js → legacy/DataModel.js} +7 -6
  123. package/build/src/modeling/legacy/DataModel.js.map +1 -0
  124. package/build/src/modeling/{DataNamespace.d.ts → legacy/DataNamespace.d.ts} +22 -3
  125. package/build/src/modeling/legacy/DataNamespace.d.ts.map +1 -0
  126. package/build/src/modeling/{DataNamespace.js → legacy/DataNamespace.js} +7 -3
  127. package/build/src/modeling/legacy/DataNamespace.js.map +1 -0
  128. package/build/src/modeling/{DataProperty.d.ts → legacy/DataProperty.d.ts} +13 -5
  129. package/build/src/modeling/legacy/DataProperty.d.ts.map +1 -0
  130. package/build/src/modeling/{DataProperty.js → legacy/DataProperty.js} +8 -5
  131. package/build/src/modeling/legacy/DataProperty.js.map +1 -0
  132. package/build/src/modeling/observed.d.ts +67 -0
  133. package/build/src/modeling/observed.d.ts.map +1 -0
  134. package/build/src/modeling/observed.js +230 -0
  135. package/build/src/modeling/observed.js.map +1 -0
  136. package/build/src/modeling/types.d.ts +165 -1
  137. package/build/src/modeling/types.d.ts.map +1 -1
  138. package/build/src/modeling/types.js.map +1 -1
  139. package/build/src/models/Thing.d.ts +26 -5
  140. package/build/src/models/Thing.d.ts.map +1 -1
  141. package/build/src/models/Thing.js +193 -91
  142. package/build/src/models/Thing.js.map +1 -1
  143. package/build/src/models/kinds.d.ts +31 -6
  144. package/build/src/models/kinds.d.ts.map +1 -1
  145. package/build/src/models/kinds.js +31 -6
  146. package/build/src/models/kinds.js.map +1 -1
  147. package/build/src/models/store/DataFile.d.ts +3 -1
  148. package/build/src/models/store/DataFile.d.ts.map +1 -1
  149. package/build/src/models/store/DataFile.js +2 -0
  150. package/build/src/models/store/DataFile.js.map +1 -1
  151. package/build/src/models/types.d.ts +12 -0
  152. package/build/src/models/types.d.ts.map +1 -0
  153. package/build/src/models/types.js +2 -0
  154. package/build/src/models/types.js.map +1 -0
  155. package/build/src/runtime/store/FilesSdk.d.ts +2 -2
  156. package/build/src/runtime/store/FilesSdk.d.ts.map +1 -1
  157. package/build/src/runtime/store/FilesSdk.js.map +1 -1
  158. package/data/models/example-generator-api.json +16 -16
  159. package/package.json +20 -6
  160. package/readme.md +1 -1
  161. package/src/amf/AmfShapeGenerator.ts +7 -4
  162. package/src/amf/AmfTypes.ts +2 -2
  163. package/src/amf/DataValueGenerator.ts +21 -21
  164. package/src/exceptions/attach_exception.ts +11 -0
  165. package/src/exceptions/detach_exception.ts +11 -0
  166. package/src/exceptions/remove_model_exception.ts +8 -0
  167. package/src/exceptions/remove_namespace_exception.ts +8 -0
  168. package/src/modeling/Bindings.ts +2 -2
  169. package/src/modeling/DataDomain.ts +1221 -0
  170. package/src/modeling/DataFormat.ts +54 -163
  171. package/src/modeling/DomainAssociation.ts +476 -0
  172. package/src/modeling/DomainElement.ts +50 -0
  173. package/src/modeling/DomainEntity.ts +769 -0
  174. package/src/modeling/DomainFile.ts +94 -0
  175. package/src/modeling/DomainImpactAnalysis.ts +218 -144
  176. package/src/modeling/DomainModel.ts +421 -0
  177. package/src/modeling/DomainNamespace.ts +537 -0
  178. package/src/modeling/DomainProperty.ts +548 -0
  179. package/src/modeling/DomainSerialization.ts +312 -0
  180. package/src/modeling/DomainVersioning.ts +144 -0
  181. package/src/modeling/GraphUtils.ts +28 -0
  182. package/src/modeling/amf/ShapeGenerator.ts +552 -0
  183. package/src/modeling/graph.md +115 -0
  184. package/src/modeling/{DataAssociation.ts → legacy/DataAssociation.ts} +13 -8
  185. package/src/modeling/{DataEntity.ts → legacy/DataEntity.ts} +28 -23
  186. package/src/modeling/{DataEntityBuilder.ts → legacy/DataEntityBuilder.ts} +4 -3
  187. package/src/modeling/legacy/DataImpactAnalysis.ts +530 -0
  188. package/src/modeling/{DataModel.ts → legacy/DataModel.ts} +10 -8
  189. package/src/modeling/{DataNamespace.ts → legacy/DataNamespace.ts} +23 -5
  190. package/src/modeling/{DataProperty.ts → legacy/DataProperty.ts} +15 -7
  191. package/src/modeling/observed.ts +267 -0
  192. package/src/modeling/types.ts +174 -1
  193. package/src/models/Thing.ts +70 -5
  194. package/src/models/kinds.ts +32 -6
  195. package/src/models/store/DataFile.ts +3 -1
  196. package/src/models/types.ts +11 -0
  197. package/src/runtime/store/FilesSdk.ts +2 -2
  198. package/tests/unit/amf/data_value_generator.spec.ts +15 -15
  199. package/tests/unit/legacy-transformers/ARC-legacy-import.spec.ts +1 -1
  200. package/tests/unit/modeling/amf/shape_generator.spec.ts +1174 -0
  201. package/tests/unit/modeling/data_domain.spec.ts +444 -0
  202. package/tests/unit/modeling/data_domain_associations.spec.ts +279 -0
  203. package/tests/unit/modeling/data_domain_change_observers.spec.ts +681 -0
  204. package/tests/unit/modeling/data_domain_entities.spec.ts +449 -0
  205. package/tests/unit/modeling/data_domain_foreign.spec.ts +355 -0
  206. package/tests/unit/modeling/data_domain_models.spec.ts +658 -0
  207. package/tests/unit/modeling/data_domain_namespaces.spec.ts +668 -0
  208. package/tests/unit/modeling/data_domain_property.spec.ts +264 -0
  209. package/tests/unit/modeling/data_domain_serialization.spec.ts +294 -0
  210. package/tests/unit/modeling/domain.property.spec.ts +822 -0
  211. package/tests/unit/modeling/domain_asociation.spec.ts +643 -0
  212. package/tests/unit/modeling/domain_asociation_targets.spec.ts +350 -0
  213. package/tests/unit/modeling/domain_entity.spec.ts +730 -0
  214. package/tests/unit/modeling/domain_entity_associations.spec.ts +330 -0
  215. package/tests/unit/modeling/domain_entity_example_generator_json.spec.ts +988 -0
  216. package/tests/unit/modeling/domain_entity_example_generator_xml.spec.ts +1451 -0
  217. package/tests/unit/modeling/domain_entity_fields.spec.ts +113 -0
  218. package/tests/unit/modeling/domain_entity_generators.spec.ts +20 -0
  219. package/tests/unit/modeling/domain_entity_parents.spec.ts +291 -0
  220. package/tests/unit/modeling/domain_entity_properties.spec.ts +305 -0
  221. package/tests/unit/modeling/{data_file.spec.ts → domain_file.spec.ts} +29 -85
  222. package/tests/unit/modeling/domain_impact_analysis.spec.ts +452 -0
  223. package/tests/unit/modeling/domain_model.spec.ts +568 -0
  224. package/tests/unit/modeling/domain_model_entities.spec.ts +408 -0
  225. package/tests/unit/modeling/domain_namespace.spec.ts +514 -0
  226. package/tests/unit/modeling/domain_namespace_models.spec.ts +324 -0
  227. package/tests/unit/modeling/domain_namespace_namespaces.spec.ts +404 -0
  228. package/tests/unit/modeling/domain_versioning.spec.ts +140 -0
  229. package/tests/unit/{amf → modeling/legacy}/amf_shape_generator.spec.ts +11 -11
  230. package/tests/unit/modeling/{data_association.spec.ts → legacy/data_association.spec.ts} +3 -11
  231. package/tests/unit/modeling/{data_entity.spec.ts → legacy/data_entity.spec.ts} +10 -8
  232. package/tests/unit/modeling/{data_entity_generator_json.spec.ts → legacy/data_entity_generator_json.spec.ts} +1 -1
  233. package/tests/unit/modeling/{data_entity_generator_xml.spec.ts → legacy/data_entity_generator_xml.spec.ts} +1 -1
  234. package/tests/unit/modeling/{data_model.spec.ts → legacy/data_model.spec.ts} +3 -3
  235. package/tests/unit/modeling/{data_namespace.spec.ts → legacy/data_namespace.spec.ts} +3 -10
  236. package/tests/unit/modeling/{data_property.spec.ts → legacy/data_property.spec.ts} +3 -6
  237. package/tests/unit/modeling/{impact_analysis.spec.ts → legacy/impact_analysis.spec.ts} +9 -9
  238. package/tests/unit/models/File/new.spec.ts +1 -1
  239. package/tests/unit/models/HttpProject.spec.ts +3 -3
  240. package/tsconfig.node.json +35 -0
  241. package/build/src/modeling/DataAssociation.d.ts.map +0 -1
  242. package/build/src/modeling/DataAssociation.js.map +0 -1
  243. package/build/src/modeling/DataEntity.d.ts.map +0 -1
  244. package/build/src/modeling/DataEntity.js.map +0 -1
  245. package/build/src/modeling/DataEntityBuilder.d.ts.map +0 -1
  246. package/build/src/modeling/DataEntityBuilder.js.map +0 -1
  247. package/build/src/modeling/DataModel.d.ts.map +0 -1
  248. package/build/src/modeling/DataModel.js.map +0 -1
  249. package/build/src/modeling/DataNamespace.d.ts.map +0 -1
  250. package/build/src/modeling/DataNamespace.js.map +0 -1
  251. package/build/src/modeling/DataProperty.d.ts.map +0 -1
  252. package/build/src/modeling/DataProperty.js.map +0 -1
package/Testing.md CHANGED
@@ -18,4 +18,4 @@ Most core libraries are also tested in the browser. We use the `@web/test-runner
18
18
 
19
19
  The web test runner requires an interactive mode to run. When using the watch mode we need to run two processes, one for compiling TS in watch mode, and the other to run tests in watch mode. This can't be done using `concurrently` or `wireit` as `concurrently` does not pass keyboard input to the process (perhaps a bug) and `wireit` spins child processes without passing terminal events. There is an [https://github.com/modernweb-dev/web/issues/19](issue report) requesting to allow WTR running in non-interactive mode but for now we need to do this manually.
20
20
 
21
- This means, run the `build:test:watch` command in one terminal first, and then `test:watch-only` in the other.
21
+ This means, run the `build:watch` command in one terminal first, and then `test:watch-only` in the other.
@@ -0,0 +1,61 @@
1
+ import type { WaitingOptions } from './types.js'
2
+
3
+ /**
4
+ * A plugin the adds support for various event-related functions in tests.
5
+ */
6
+ export class EventPlugin {
7
+ /**
8
+ * Waits for an event to be fired on a target.
9
+ * @param target The target to listen for the event on.
10
+ * @param type The type of event to listen for.
11
+ * @returns A promise that resolves when the event is fired with the captured event.
12
+ */
13
+ async until(target: EventTarget, type: string, options?: AddEventListenerOptions & WaitingOptions): Promise<Event> {
14
+ const timeout = options?.timeout
15
+ return new Promise((resolve, reject) => {
16
+ const timer =
17
+ typeof timeout === 'number' &&
18
+ setTimeout(() => {
19
+ target.removeEventListener(type, handler)
20
+ reject(new Error(`Timeout waiting for event: ${type}`, { cause: 'E_TIMEOUT' }))
21
+ }, timeout)
22
+ const handler = (event: Event) => {
23
+ if (timer) {
24
+ clearTimeout(timer)
25
+ }
26
+ target.removeEventListener(type, handler)
27
+ resolve(event)
28
+ }
29
+ target.addEventListener(type, handler, options)
30
+ })
31
+ }
32
+
33
+ /**
34
+ * Captures all events of a specific type dispatched on a target within a given timeout.
35
+ * @param target The target to listen for events on.
36
+ * @param type The type of event to capture.
37
+ * @param options Optional settings, including timeout.
38
+ * @returns A promise that resolves with an array of captured events.
39
+ */
40
+ async capture<T extends Event = Event>(
41
+ target: EventTarget,
42
+ type: string,
43
+ options?: AddEventListenerOptions & WaitingOptions
44
+ ): Promise<T[]> {
45
+ const timeout = options?.timeout
46
+ const capturedEvents: T[] = []
47
+
48
+ return new Promise((resolve) => {
49
+ setTimeout(() => {
50
+ target.removeEventListener(type, handler)
51
+ resolve(capturedEvents)
52
+ }, timeout)
53
+
54
+ const handler = (event: Event) => {
55
+ capturedEvents.push(event as T)
56
+ }
57
+
58
+ target.addEventListener(type, handler, options)
59
+ })
60
+ }
61
+ }
@@ -0,0 +1,193 @@
1
+ import { Assert } from '@japa/assert'
2
+ import type { EventPlugin } from './EventPlugin.js'
3
+ import type { WaitingOptions } from './types.js'
4
+
5
+ declare module '@japa/assert' {
6
+ interface Assert {
7
+ events: EventPlugin
8
+ /**
9
+ * Asserts that an event was dispatched on the target.
10
+ * It should be used with asynchronous events dispatched outside of the test's event loop.
11
+ *
12
+ * @param target The event target to listen for the event on.
13
+ * @param type The type of event to listen for.
14
+ * @param options The options to pass to the event listener.
15
+ * @param message The message to display if the assertion fails.
16
+ */
17
+ dispatches(
18
+ target: EventTarget,
19
+ type: string,
20
+ options?: AddEventListenerOptions & WaitingOptions,
21
+ message?: string
22
+ ): Promise<void>
23
+
24
+ /**
25
+ * Asserts that an event was NOT dispatched on the target.
26
+ * It should be used with asynchronous events dispatched outside of the test's event loop.
27
+ *
28
+ * @param target The event target to listen for the event on.
29
+ * @param type The type of event to listen for.
30
+ * @param options The options to pass to the event listener.
31
+ * @param message The message to display if the assertion fails.
32
+ */
33
+ notDispatches(
34
+ target: EventTarget,
35
+ type: string,
36
+ options?: AddEventListenerOptions & WaitingOptions,
37
+ message?: string
38
+ ): Promise<void>
39
+
40
+ /**
41
+ * Asserts that a specific number of events were captured on the target.
42
+ *
43
+ * @param target The event target to listen for the event on.
44
+ * @param type The type of event to listen for.
45
+ * @param count The expected number of events.
46
+ * @param options The options to pass to the event listener.
47
+ * @param message The message to display if the assertion fails.
48
+ */
49
+ dispatchCount(
50
+ target: EventTarget,
51
+ type: string,
52
+ count: number,
53
+ options?: AddEventListenerOptions & WaitingOptions,
54
+ message?: string
55
+ ): Promise<void>
56
+
57
+ /**
58
+ * Asserts that all captured events are of a specific type.
59
+ *
60
+ * @param target The event target to listen for the event on.
61
+ * @param type The type of event to listen for.
62
+ * @param eventConstructor The expected event constructor (e.g., Event, CustomEvent).
63
+ * @param options The options to pass to the event listener.
64
+ * @param message The message to display if the assertion fails.
65
+ */
66
+ dispatchesOfType<T extends Event>(
67
+ target: EventTarget,
68
+ type: string,
69
+ eventConstructor: new (...args: unknown[]) => T,
70
+ options?: AddEventListenerOptions & WaitingOptions,
71
+ message?: string
72
+ ): Promise<void>
73
+ }
74
+ }
75
+
76
+ Assert.macro(
77
+ 'dispatches',
78
+ async function (
79
+ this: Assert,
80
+ target: EventTarget,
81
+ type: string,
82
+ options?: AddEventListenerOptions & WaitingOptions,
83
+ message?: string
84
+ ) {
85
+ this.incrementAssertionsCount()
86
+ let event: Event | undefined
87
+ try {
88
+ event = await this.events.until(target, type, options)
89
+ } catch (e) {
90
+ const error = e as Error
91
+ if (error.cause === 'E_TIMEOUT') {
92
+ this.evaluate(false, `event "${type}" was not dispatched on ${target.constructor.name} within the timeout`, {
93
+ thisObject: target,
94
+ expected: true,
95
+ actual: false,
96
+ showDiff: false,
97
+ operator: 'ok',
98
+ prefix: message,
99
+ })
100
+ return
101
+ }
102
+ throw error
103
+ }
104
+ this.evaluate(!!event, `event "${type}" to be dispatched on ${target.constructor.name}`, {
105
+ thisObject: target,
106
+ expected: !!event,
107
+ actual: !event,
108
+ showDiff: false,
109
+ operator: 'ok',
110
+ prefix: message,
111
+ })
112
+ }
113
+ )
114
+
115
+ Assert.macro(
116
+ 'notDispatches',
117
+ async function (
118
+ this: Assert,
119
+ target: EventTarget,
120
+ type: string,
121
+ options?: AddEventListenerOptions & WaitingOptions,
122
+ message?: string
123
+ ) {
124
+ this.incrementAssertionsCount()
125
+ let event: Event | undefined
126
+ try {
127
+ event = await this.events.until(target, type, options)
128
+ } catch (e) {
129
+ const error = e as Error
130
+ if (error.cause !== 'E_TIMEOUT') {
131
+ throw error
132
+ }
133
+ // Timeout is expected, so we don't need to handle it here.
134
+ }
135
+ this.evaluate(!event, `event "${type}" was dispatched on ${target.constructor.name}`, {
136
+ thisObject: target,
137
+ expected: !event,
138
+ actual: !!event,
139
+ showDiff: false,
140
+ operator: 'ok',
141
+ prefix: message,
142
+ })
143
+ }
144
+ )
145
+
146
+ Assert.macro(
147
+ 'dispatchCount',
148
+ async function (
149
+ this: Assert,
150
+ target: EventTarget,
151
+ type: string,
152
+ count: number,
153
+ options?: AddEventListenerOptions & WaitingOptions,
154
+ message?: string
155
+ ) {
156
+ this.incrementAssertionsCount()
157
+ const events = await this.events.capture(target, type, options)
158
+ this.evaluate(
159
+ events.length === count,
160
+ `Expected ${count} events of type "${type}" on ${target.constructor.name}, but got ${events.length}`,
161
+ {
162
+ thisObject: target,
163
+ expected: count,
164
+ actual: events.length,
165
+ showDiff: false,
166
+ operator: 'equal',
167
+ prefix: message,
168
+ }
169
+ )
170
+ }
171
+ )
172
+
173
+ Assert.macro('dispatchesOfType', async function <
174
+ T extends Event,
175
+ // eslint-disable-next-line max-len
176
+ >(this: Assert, target: EventTarget, type: string, eventConstructor: new (...args: unknown[]) => T, options?: AddEventListenerOptions & WaitingOptions, message?: string) {
177
+ this.incrementAssertionsCount()
178
+ const events = await this.events.capture<T>(target, type, options)
179
+ for (const event of events) {
180
+ this.evaluate(
181
+ event instanceof eventConstructor,
182
+ `Expected event of type "${eventConstructor.name}" but got "${event.constructor.name}"`,
183
+ {
184
+ thisObject: target,
185
+ expected: eventConstructor.name,
186
+ actual: event.constructor.name,
187
+ showDiff: false,
188
+ operator: 'instanceOf',
189
+ prefix: message,
190
+ }
191
+ )
192
+ }
193
+ })
@@ -0,0 +1,6 @@
1
+ export interface WaitingOptions {
2
+ /**
3
+ * The timeout in milliseconds to wait for the operation to complete.
4
+ */
5
+ timeout?: number
6
+ }
package/bin/test.ts CHANGED
@@ -8,6 +8,7 @@ import { TestContext } from '@japa/runner/core'
8
8
  import Servers from './server.js'
9
9
  import { SetupHttpConfig } from './context.js'
10
10
  import * as reporters from '@japa/runner/reporters'
11
+ import { events } from './plugins/events/index.js'
11
12
 
12
13
  const servers = new Servers()
13
14
 
@@ -42,7 +43,13 @@ configure({
42
43
  files: 'tests/functional/**/*.spec.js',
43
44
  },
44
45
  ],
45
- plugins: [assert(), apiClient('http://localhost:3333'), expectTypeOf(), browserClient({ runInSuites: ['browser'] })],
46
+ plugins: [
47
+ assert(),
48
+ apiClient('http://localhost:3333'),
49
+ expectTypeOf(),
50
+ browserClient({ runInSuites: ['browser'] }),
51
+ events(),
52
+ ],
46
53
  reporters: {
47
54
  activated,
48
55
  list: [reporters.spec(), reporters.ndjson(), reporters.dot(), reporters.github()],
@@ -1,7 +1,7 @@
1
1
  import { type PropertyWebBindings } from '../modeling/Bindings.js';
2
- import { DataAssociation } from '../modeling/DataAssociation.js';
3
- import { DataEntity } from '../modeling/DataEntity.js';
4
- import { DataProperty, type DataPropertySchema } from '../modeling/DataProperty.js';
2
+ import { DataAssociation } from '../modeling/legacy/DataAssociation.js';
3
+ import { DataEntity } from '../modeling/legacy/DataEntity.js';
4
+ import { DataProperty, type DataPropertySchema } from '../modeling/legacy/DataProperty.js';
5
5
  import { IApiAnyShape, IApiArrayShape, IApiDataExample, IApiFileShape, IApiNodeShape, IApiPropertyShape, IApiRecursiveShape, IApiScalarShape, IApiShape, IShapeUnion } from './definitions/Shapes.js';
6
6
  import { DataValueGenerator } from './DataValueGenerator.js';
7
7
  /**
@@ -9,6 +9,9 @@ import { DataValueGenerator } from './DataValueGenerator.js';
9
9
  *
10
10
  * This is used when defining entities (according to the `DataEntity` schema)
11
11
  * and then we want to translate this into AMF shapes.
12
+ *
13
+ * @deprecated This class refers to the deprecated old data domain model.
14
+ * Use the `ShapeGenerator` with the new domain model.
12
15
  */
13
16
  export declare class AmfShapeGenerator {
14
17
  #private;
@@ -1 +1 @@
1
- {"version":3,"file":"AmfShapeGenerator.d.ts","sourceRoot":"","sources":["../../../src/amf/AmfShapeGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,EAAE,YAAY,EAAE,KAAK,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AAGnF,OAAO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Ac,GAAG,WAAW;IAKxD;;;;;;;OAOG;IACH,oBAAoB,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,GAAG,cAAc;CAKrE"}
@@ -10,6 +10,9 @@ import { DataValueGenerator } from './DataValueGenerator.js';
10
10
  *
11
11
  * This is used when defining entities (according to the `DataEntity` schema)
12
12
  * and then we want to translate this into AMF shapes.
13
+ *
14
+ * @deprecated This class refers to the deprecated old data domain model.
15
+ * Use the `ShapeGenerator` with the new domain model.
13
16
  */
14
17
  export class AmfShapeGenerator {
15
18
  #valueGenerator;
@@ -211,7 +214,7 @@ export class AmfShapeGenerator {
211
214
  const { value } = schema.defaultValue;
212
215
  if (dfFormat === 'function') {
213
216
  const tmp = this.valueGenerator.generate(value, input.type);
214
- if (tmp !== DataValueGenerator.novalue) {
217
+ if (tmp !== DataValueGenerator.noValue) {
215
218
  const dt = AmfDataNode.scalar(tmp, dfFormat);
216
219
  result.defaultValue = dt.toJSON();
217
220
  }
@@ -1 +1 @@
1
- {"version":3,"file":"AmfShapeGenerator.js","sourceRoot":"","sources":["../../../src/amf/AmfShapeGenerator.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AACzD,OAAO,EACL,QAAQ,EACR,UAAU,EACV,SAAS,EAWT,SAAS,EACT,aAAa,EACb,cAAc,EACd,WAAW,EACX,UAAU,GACX,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAC/B,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAE5D;;;;;GAKG;AACH,MAAM,OAAO,iBAAiB;IAC5B,eAAe,CAAqB;IAEp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AAE,GAAG,KAAK,CAAA;QACvB,OAAO,KAAoB,CAAA;IAC7B,CAAC;IAED;;;;;;;OAOG;IACH,oBAAoB,CAAC,EAAU,EAAE,KAAkB;QACjD,MAAM,MAAM,GAAG,UAAU,CAAC,EAAE,CAAC,CAAA;QAC7B,MAAM,CAAC,KAAK,GAAG,KAAK,CAAA;QACpB,OAAO,MAAM,CAAA;IACf,CAAC;CACF","sourcesContent":["import { type PropertyWebBindings } from '../modeling/Bindings.js'\nimport { DataAssociation } from '../modeling/DataAssociation.js'\nimport { DataEntity } from '../modeling/DataEntity.js'\nimport { DataProperty, type DataPropertySchema } from '../modeling/DataProperty.js'\nimport { IAmfExampleTypes, modelTypeToAmfDataType } from './AmfTypes.js'\nimport { AmfNamespace } from './definitions/Namespace.js'\nimport {\n anyShape,\n arrayShape,\n fileShape,\n IApiAnyShape,\n IApiArrayShape,\n IApiDataExample,\n IApiFileShape,\n IApiNodeShape,\n IApiPropertyShape,\n IApiRecursiveShape,\n IApiScalarShape,\n IApiShape,\n IShapeUnion,\n nodeShape,\n propertyShape,\n recursiveShape,\n scalarShape,\n unionShape,\n} from './definitions/Shapes.js'\nimport { AmfDataNode } from './models/AmfDataNode.js'\nimport v4 from '../lib/uuid.js'\nimport { DataEntityKind, DataPropertyKind } from '../models/kinds.js'\nimport { DataValueGenerator } from './DataValueGenerator.js'\n\n/**\n * Serializes Data shapes (DataEntity, DataProperty, DataAssociation) to AMF-related shapes.\n *\n * This is used when defining entities (according to the `DataEntity` schema)\n * and then we want to translate this into AMF shapes.\n */\nexport class AmfShapeGenerator {\n #valueGenerator?: DataValueGenerator\n\n /**\n * Used with data domain value generation for entity properties.\n * Lazily loaded class only when functions are used.\n * This needs to be a class instances because some functions are incremental\n */\n get valueGenerator(): DataValueGenerator {\n if (!this.#valueGenerator) {\n this.#valueGenerator = new DataValueGenerator()\n }\n return this.#valueGenerator\n }\n\n /**\n * Serializes the Entity to the AMF node shape.\n *\n * @param input The Property to serialize.\n * @param generatedEntities The list keys of already generated entities. This prohibits recursive shape generation.\n */\n entity(input: DataEntity, generatedEntities: string[] = []): IApiNodeShape | IApiRecursiveShape {\n if (generatedEntities.includes(input.key)) {\n // create a recursive shape.\n return this._recursiveShape(input)\n }\n generatedEntities.push(input.key)\n const result = nodeShape(input.key)\n result.id = input.key\n this._updateBaseProperties(input, result)\n result.properties = []\n input.properties.forEach((item) => {\n // we check whether the property is hidden.\n // This is not happening when calling the `property()` because this method\n // always returns the AMF shape.\n const wb = item.readBinding('web') as PropertyWebBindings | undefined\n if (wb && wb.hidden) {\n return\n }\n const shape = this.property(item)\n result.properties.push(shape)\n })\n input.associations.forEach((assoc) => {\n const prop = this.associationProperty(assoc, generatedEntities)\n result.properties.push(prop)\n })\n input.getComputedParents().forEach((parent) => {\n const shape = this.entity(parent, generatedEntities)\n result.inherits.push(shape)\n })\n return result\n }\n\n /**\n * Serializes an Entity Property to the AMF property shape.\n *\n * @param input The Property to serialize.\n */\n property(input: DataProperty): IApiPropertyShape {\n const { required, key } = input\n const result = propertyShape(key)\n result.path = `${AmfNamespace.aml.vocabularies.data.key}${input.info.name}`\n if (required) {\n result.minCount = 1\n }\n result.range = this._readPropertyRange(input)\n\n // for example, Example generator needs to know the name of the property\n // as it does not look into the \"range\" object.\n this._updateBaseProperties(input, result)\n\n // sync the name of the property shape with the range, in case it was changed by the bindings\n if (result.range.name) {\n result.name = result.range.name\n }\n return result\n }\n\n /**\n * Serializes an Entity property to the AMF property shape with association\n * targets as defined in the schema configuration.\n *\n * @param input The Property to serialize.\n */\n associationProperty(input: DataAssociation, generatedEntities: string[] = []): IApiPropertyShape {\n const { required, key } = input\n const result = propertyShape(key)\n result.path = `${AmfNamespace.aml.vocabularies.data.key}${input.info.name}`\n if (required) {\n result.minCount = 1\n }\n result.range = this.associationShape(input, generatedEntities)\n this._updateBaseProperties(input, result)\n return result\n }\n\n /**\n * Generates a shape for an association. Most likely you want to use the `associationProperty()` method instead.\n *\n * @param input The data association instance.\n * @returns The range value for the PropertyShape.\n */\n associationShape(input: DataAssociation, generatedEntities: string[] = []): IShapeUnion | undefined {\n const schema = input.schema\n if (schema && schema.linked) {\n // This is a link to the schema. In an API that would be the id\n // of a resource to request the data from.\n const range = scalarShape(input.key)\n range.id = `link-${input.key}`\n range.dataType = modelTypeToAmfDataType('string')\n return range\n }\n const items = this.associationUnion(input, generatedEntities)\n if (!items) {\n return\n }\n const unionType = (schema && schema.unionType) || 'anyOf'\n if (Array.isArray(items)) {\n const range = unionShape(input.key)\n this._updateBaseProperties(input, range)\n range.anyOf = []\n if (unionType === 'anyOf') {\n range.anyOf = items\n } else if (unionType === 'allOf') {\n range.and = items\n } else if (unionType === 'oneOf') {\n range.xone = items\n } else {\n // not.\n range.not = items[0] // ?\n }\n if (input.multiple) {\n return this.refactorShapeToArray(input.key, range)\n }\n return range\n }\n if (unionType === 'not') {\n const wrapper = anyShape(input.key)\n wrapper.id = `not-shape-${input.key}`\n wrapper.not = items\n return wrapper\n }\n if (input.multiple) {\n return this.refactorShapeToArray(input.key, items)\n }\n return items\n }\n\n /**\n * Generates a shape list for an union. Most likely you want to use the `associationProperty()` method instead.\n *\n * @param input The data association instance.\n * @returns The range value for the PropertyShape.\n */\n associationUnion(input: DataAssociation, generatedEntities: string[] = []): IShapeUnion | IShapeUnion[] | undefined {\n const targets = input.getTargets().map((i) => this.entity(i, generatedEntities))\n if (!targets.length) {\n return undefined\n }\n if (targets.length > 1) {\n return targets\n }\n return targets[0]\n }\n\n /**\n * The DataProperty may have both the `schema` and the `bindings`. For AMF shape we read `schema` for\n * default value, examples, and enum values. We also look for the `web`\n * bindings for more detailed definition of a shape.\n *\n * @param input\n * @returns\n */\n protected _readPropertyRange(input: DataProperty): IApiArrayShape | IApiFileShape | IApiScalarShape {\n const bindings = input.readBinding('web') as PropertyWebBindings | undefined\n let schema: DataPropertySchema | undefined\n if (input.schema) {\n schema = input.schema\n }\n return this._createAmfSchema(input, schema, bindings)\n }\n\n protected _createAmfSchema(\n input: DataProperty,\n schema?: DataPropertySchema,\n bindings?: PropertyWebBindings\n ): IApiArrayShape | IApiFileShape | IApiScalarShape {\n const { multiple, type } = input\n if (multiple) {\n return this._generateArrayShape(input, schema, bindings)\n }\n if (type === 'binary') {\n return this._generateFileShape(input, schema, bindings)\n }\n return this._generateScalarShape(input, schema, bindings)\n }\n\n /**\n * Normally this would be part of generating a scalar schema but the the property is an array this\n * is generated on the array and not on the range.\n *\n * @param result The scalar or array shape.\n * @param schema The property schema\n * @param type The data type of the parent property as set on the `range`\n * @param isArray Whether the DataProperty is multiple\n */\n protected _setShapeSchema(\n input: DataProperty,\n result: IApiAnyShape,\n schema: DataPropertySchema,\n type: string,\n isArray?: boolean\n ): void {\n if (schema.defaultValue) {\n const { type: dfFormat } = schema.defaultValue\n const { value } = schema.defaultValue\n if (dfFormat === 'function') {\n const tmp = this.valueGenerator.generate(value, input.type)\n if (tmp !== DataValueGenerator.novalue) {\n const dt = AmfDataNode.scalar(tmp as string, dfFormat)\n result.defaultValue = dt.toJSON()\n }\n } else {\n const dt = AmfDataNode.scalar(value, type)\n result.defaultValue = dt.toJSON()\n }\n }\n if (Array.isArray(schema.enum)) {\n result.values = schema.enum.map((i) => AmfDataNode.scalar(i, type).toJSON())\n }\n if (Array.isArray(schema.examples)) {\n if (isArray) {\n result.examples = this._generateArrayExamples(schema.examples, type)\n } else {\n result.examples = this._generateExamples(schema.examples, type)\n }\n }\n }\n\n protected _generateArrayShape(\n input: DataProperty,\n schema?: DataPropertySchema,\n bindings?: PropertyWebBindings\n ): IApiArrayShape {\n const result = arrayShape(input.key)\n const { type } = input\n if (type === 'binary') {\n // we do not pass schema to the range generator as we set schema's properties on the array shape.\n result.items = this._generateFileShape(input, undefined, bindings)\n } else {\n result.items = this._generateScalarShape(input, undefined, bindings)\n }\n if (schema) {\n const type = (result.items as IApiScalarShape).dataType as string\n this._setShapeSchema(input, result, schema, type, input.multiple)\n }\n return result\n }\n\n protected _generateScalarShape(\n input: DataProperty,\n schema?: DataPropertySchema,\n bindings?: PropertyWebBindings\n ): IApiScalarShape {\n const result = scalarShape(input.key)\n this._updateBaseProperties(input, result)\n this._fillScalarShapeCommonProperties(result, input, bindings)\n if (!result.dataType) {\n result.dataType = modelTypeToAmfDataType(input.type, bindings)\n }\n if (schema) {\n this._setShapeSchema(input, result, schema, result.dataType as string, input.multiple)\n }\n return result\n }\n\n protected _generateExamples(examples: string[], type: string): IApiDataExample[] {\n return examples.map((current) => {\n const value = AmfDataNode.scalar(current, type).toJSON()\n const item: IApiDataExample = {\n id: v4(),\n customDomainProperties: [],\n strict: true,\n types: IAmfExampleTypes,\n structuredValue: value,\n }\n return item\n })\n }\n\n protected _generateArrayExamples(examples: string[], type: string): IApiDataExample[] {\n const item: IApiDataExample = {\n id: v4(),\n customDomainProperties: [],\n strict: true,\n types: IAmfExampleTypes,\n }\n const value = new AmfDataNode('array')\n examples.forEach((item) => {\n const member = AmfDataNode.scalar(item, type)\n value.addMember(member)\n })\n item.structuredValue = value.toJSON()\n return [item]\n }\n\n protected _generateFileShape(\n input: DataProperty,\n schema?: DataPropertySchema,\n bindings?: PropertyWebBindings\n ): IApiFileShape {\n // if (bindings && bindings.format === 'base64') {\n // // this is a binary format of a string shape\n // }\n const result = fileShape(input.key)\n this._updateBaseProperties(input, result)\n if (bindings) {\n if (Array.isArray(bindings.fileTypes)) {\n result.fileTypes = bindings.fileTypes\n }\n this._fillScalarShapeCommonProperties(result, input, bindings)\n if (bindings.format === 'base64') {\n result.format = AmfNamespace.w3.xmlSchema.base64Binary\n }\n }\n return result\n }\n\n protected _fillScalarShapeCommonProperties(\n result: IApiFileShape | IApiScalarShape,\n input: DataProperty,\n bindings?: PropertyWebBindings\n ): void {\n if (bindings?.name) {\n result.name = bindings.name\n }\n if (bindings?.xml) {\n result.xmlSerialization = bindings.xml\n }\n if (bindings?.pattern) {\n result.pattern = bindings.pattern\n }\n const { schema, type } = input\n if (schema) {\n if (typeof schema.multipleOf === 'number') {\n result.multipleOf = schema.multipleOf\n }\n if (typeof schema.minimum === 'number') {\n if (type === 'string') {\n result.minLength = schema.minimum\n } else {\n result.minimum = schema.minimum\n }\n }\n if (typeof schema.maximum === 'number') {\n if (type === 'string') {\n result.maxLength = schema.maximum\n } else {\n result.maximum = schema.maximum\n }\n }\n if (typeof schema.exclusiveMinimum === 'boolean') {\n result.exclusiveMinimum = schema.exclusiveMinimum\n }\n if (typeof schema.exclusiveMaximum === 'boolean') {\n result.exclusiveMaximum = schema.exclusiveMaximum\n }\n }\n if (bindings?.format) {\n switch (bindings.format) {\n case 'base64':\n result.format = AmfNamespace.w3.xmlSchema.base64Binary\n break\n case 'double':\n result.format = AmfNamespace.w3.xmlSchema.double\n break\n case 'float':\n result.format = AmfNamespace.w3.xmlSchema.float\n break\n case 'int32':\n result.format = AmfNamespace.w3.xmlSchema.integer\n break\n case 'int64':\n result.format = AmfNamespace.w3.xmlSchema.integer\n break\n }\n // result.format = bindings.format\n }\n if (typeof input.readOnly === 'boolean') {\n result.readOnly = input.readOnly\n }\n if (typeof input.writeOnly === 'boolean') {\n result.writeOnly = input.writeOnly\n }\n }\n\n protected _updateBaseProperties(input: DataProperty | DataAssociation | DataEntity, target: IApiShape): void {\n // const bindings = input.readBinding('web') as PropertyWebBindings | undefined\n target.name = input.info.name\n target.displayName = input.info.displayName\n target.description = input.info.description\n if (input.kind === DataPropertyKind) {\n target.deprecated = (input as DataProperty).deprecated\n } else if (input.kind === DataEntityKind) {\n target.deprecated = (input as DataEntity).deprecated\n }\n }\n\n protected _recursiveShape(input: DataEntity): IApiRecursiveShape {\n return recursiveShape(input.key, input.key)\n }\n\n /**\n * Translates generated schema from an array shape to the shape defined in the `items` of the array.\n *\n * @param array The source array.\n * @returns The definition of the `items` of the array.\n */\n refactorArrayToShape(array: IApiArrayShape): IShapeUnion {\n const { items } = array\n return items as IShapeUnion\n }\n\n /**\n * Translates the shape to an array shape. This happens when data model property\n * is changed from 'multiple' to not-multiple and back.\n *\n * @param id The key of the parameter or an association\n * @param shape The shape to wrap as an array.\n * @returns Array shape.\n */\n refactorShapeToArray(id: string, shape: IShapeUnion): IApiArrayShape {\n const result = arrayShape(id)\n result.items = shape\n return result\n }\n}\n"]}
1
+ {"version":3,"file":"AmfShapeGenerator.js","sourceRoot":"","sources":["../../../src/amf/AmfShapeGenerator.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AACzD,OAAO,EACL,QAAQ,EACR,UAAU,EACV,SAAS,EAWT,SAAS,EACT,aAAa,EACb,cAAc,EACd,WAAW,EACX,UAAU,GACX,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAC/B,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAE5D;;;;;;;;GAQG;AACH,MAAM,OAAO,iBAAiB;IAC5B,eAAe,CAAqB;IAEpC;;;;OAIG;IACH,IAAI,cAAc;QAChB,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;YAC1B,IAAI,CAAC,eAAe,GAAG,IAAI,kBAAkB,EAAE,CAAA;QACjD,CAAC;QACD,OAAO,IAAI,CAAC,eAAe,CAAA;IAC7B,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,KAAiB,EAAE,oBAA8B,EAAE;QACxD,IAAI,iBAAiB,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;YAC1C,4BAA4B;YAC5B,OAAO,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAA;QACpC,CAAC;QACD,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QACjC,MAAM,MAAM,GAA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AC,SAAS,CAAA;QACpC,CAAC;IACH,CAAC;IAES,qBAAqB,CAAC,KAAkD,EAAE,MAAiB;QACnG,+EAA+E;QAC/E,MAAM,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAA;QAC7B,MAAM,CAAC,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,WAAW,CAAA;QAC3C,MAAM,CAAC,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,WAAW,CAAA;QAC3C,IAAI,KAAK,CAAC,IAAI,KAAK,gBAAgB,EAAE,CAAC;YACpC,MAAM,CAAC,UAAU,GAAI,KAAsB,CAAC,UAAU,CAAA;QACxD,CAAC;aAAM,IAAI,KAAK,CAAC,IAAI,KAAK,cAAc,EAAE,CAAC;YACzC,MAAM,CAAC,UAAU,GAAI,KAAoB,CAAC,UAAU,CAAA;QACtD,CAAC;IACH,CAAC;IAES,eAAe,CAAC,KAAiB;QACzC,OAAO,cAAc,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,CAAA;IAC7C,CAAC;IAED;;;;;OAKG;IACH,oBAAoB,CAAC,KAAqB;QACxC,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,CAAA;QACvB,OAAO,KAAoB,CAAA;IAC7B,CAAC;IAED;;;;;;;OAOG;IACH,oBAAoB,CAAC,EAAU,EAAE,KAAkB;QACjD,MAAM,MAAM,GAAG,UAAU,CAAC,EAAE,CAAC,CAAA;QAC7B,MAAM,CAAC,KAAK,GAAG,KAAK,CAAA;QACpB,OAAO,MAAM,CAAA;IACf,CAAC;CACF","sourcesContent":["import { type PropertyWebBindings } from '../modeling/Bindings.js'\nimport { DataAssociation } from '../modeling/legacy/DataAssociation.js'\nimport { DataEntity } from '../modeling/legacy/DataEntity.js'\nimport { DataProperty, type DataPropertySchema } from '../modeling/legacy/DataProperty.js'\nimport { IAmfExampleTypes, modelTypeToAmfDataType } from './AmfTypes.js'\nimport { AmfNamespace } from './definitions/Namespace.js'\nimport {\n anyShape,\n arrayShape,\n fileShape,\n IApiAnyShape,\n IApiArrayShape,\n IApiDataExample,\n IApiFileShape,\n IApiNodeShape,\n IApiPropertyShape,\n IApiRecursiveShape,\n IApiScalarShape,\n IApiShape,\n IShapeUnion,\n nodeShape,\n propertyShape,\n recursiveShape,\n scalarShape,\n unionShape,\n} from './definitions/Shapes.js'\nimport { AmfDataNode } from './models/AmfDataNode.js'\nimport v4 from '../lib/uuid.js'\nimport { DataEntityKind, DataPropertyKind } from '../models/kinds.js'\nimport { DataValueGenerator } from './DataValueGenerator.js'\n\n/**\n * Serializes Data shapes (DataEntity, DataProperty, DataAssociation) to AMF-related shapes.\n *\n * This is used when defining entities (according to the `DataEntity` schema)\n * and then we want to translate this into AMF shapes.\n *\n * @deprecated This class refers to the deprecated old data domain model.\n * Use the `ShapeGenerator` with the new domain model.\n */\nexport class AmfShapeGenerator {\n #valueGenerator?: DataValueGenerator\n\n /**\n * Used with data domain value generation for entity properties.\n * Lazily loaded class only when functions are used.\n * This needs to be a class instances because some functions are incremental\n */\n get valueGenerator(): DataValueGenerator {\n if (!this.#valueGenerator) {\n this.#valueGenerator = new DataValueGenerator()\n }\n return this.#valueGenerator\n }\n\n /**\n * Serializes the Entity to the AMF node shape.\n *\n * @param input The Property to serialize.\n * @param generatedEntities The list keys of already generated entities. This prohibits recursive shape generation.\n */\n entity(input: DataEntity, generatedEntities: string[] = []): IApiNodeShape | IApiRecursiveShape {\n if (generatedEntities.includes(input.key)) {\n // create a recursive shape.\n return this._recursiveShape(input)\n }\n generatedEntities.push(input.key)\n const result = nodeShape(input.key)\n result.id = input.key\n this._updateBaseProperties(input, result)\n result.properties = []\n input.properties.forEach((item) => {\n // we check whether the property is hidden.\n // This is not happening when calling the `property()` because this method\n // always returns the AMF shape.\n const wb = item.readBinding('web') as PropertyWebBindings | undefined\n if (wb && wb.hidden) {\n return\n }\n const shape = this.property(item)\n result.properties.push(shape)\n })\n input.associations.forEach((assoc) => {\n const prop = this.associationProperty(assoc, generatedEntities)\n result.properties.push(prop)\n })\n input.getComputedParents().forEach((parent) => {\n const shape = this.entity(parent, generatedEntities)\n result.inherits.push(shape)\n })\n return result\n }\n\n /**\n * Serializes an Entity Property to the AMF property shape.\n *\n * @param input The Property to serialize.\n */\n property(input: DataProperty): IApiPropertyShape {\n const { required, key } = input\n const result = propertyShape(key)\n result.path = `${AmfNamespace.aml.vocabularies.data.key}${input.info.name}`\n if (required) {\n result.minCount = 1\n }\n result.range = this._readPropertyRange(input)\n\n // for example, Example generator needs to know the name of the property\n // as it does not look into the \"range\" object.\n this._updateBaseProperties(input, result)\n\n // sync the name of the property shape with the range, in case it was changed by the bindings\n if (result.range.name) {\n result.name = result.range.name\n }\n return result\n }\n\n /**\n * Serializes an Entity property to the AMF property shape with association\n * targets as defined in the schema configuration.\n *\n * @param input The Property to serialize.\n */\n associationProperty(input: DataAssociation, generatedEntities: string[] = []): IApiPropertyShape {\n const { required, key } = input\n const result = propertyShape(key)\n result.path = `${AmfNamespace.aml.vocabularies.data.key}${input.info.name}`\n if (required) {\n result.minCount = 1\n }\n result.range = this.associationShape(input, generatedEntities)\n this._updateBaseProperties(input, result)\n return result\n }\n\n /**\n * Generates a shape for an association. Most likely you want to use the `associationProperty()` method instead.\n *\n * @param input The data association instance.\n * @returns The range value for the PropertyShape.\n */\n associationShape(input: DataAssociation, generatedEntities: string[] = []): IShapeUnion | undefined {\n const schema = input.schema\n if (schema && schema.linked) {\n // This is a link to the schema. In an API that would be the id\n // of a resource to request the data from.\n const range = scalarShape(input.key)\n range.id = `link-${input.key}`\n range.dataType = modelTypeToAmfDataType('string')\n return range\n }\n const items = this.associationUnion(input, generatedEntities)\n if (!items) {\n return\n }\n const unionType = (schema && schema.unionType) || 'anyOf'\n if (Array.isArray(items)) {\n const range = unionShape(input.key)\n this._updateBaseProperties(input, range)\n range.anyOf = []\n if (unionType === 'anyOf') {\n range.anyOf = items\n } else if (unionType === 'allOf') {\n range.and = items\n } else if (unionType === 'oneOf') {\n range.xone = items\n } else {\n // not.\n range.not = items[0] // ?\n }\n if (input.multiple) {\n return this.refactorShapeToArray(input.key, range)\n }\n return range\n }\n if (unionType === 'not') {\n const wrapper = anyShape(input.key)\n wrapper.id = `not-shape-${input.key}`\n wrapper.not = items\n return wrapper\n }\n if (input.multiple) {\n return this.refactorShapeToArray(input.key, items)\n }\n return items\n }\n\n /**\n * Generates a shape list for an union. Most likely you want to use the `associationProperty()` method instead.\n *\n * @param input The data association instance.\n * @returns The range value for the PropertyShape.\n */\n associationUnion(input: DataAssociation, generatedEntities: string[] = []): IShapeUnion | IShapeUnion[] | undefined {\n const targets = input.getTargets().map((i) => this.entity(i, generatedEntities))\n if (!targets.length) {\n return undefined\n }\n if (targets.length > 1) {\n return targets\n }\n return targets[0]\n }\n\n /**\n * The DataProperty may have both the `schema` and the `bindings`. For AMF shape we read `schema` for\n * default value, examples, and enum values. We also look for the `web`\n * bindings for more detailed definition of a shape.\n *\n * @param input\n * @returns\n */\n protected _readPropertyRange(input: DataProperty): IApiArrayShape | IApiFileShape | IApiScalarShape {\n const bindings = input.readBinding('web') as PropertyWebBindings | undefined\n let schema: DataPropertySchema | undefined\n if (input.schema) {\n schema = input.schema\n }\n return this._createAmfSchema(input, schema, bindings)\n }\n\n protected _createAmfSchema(\n input: DataProperty,\n schema?: DataPropertySchema,\n bindings?: PropertyWebBindings\n ): IApiArrayShape | IApiFileShape | IApiScalarShape {\n const { multiple, type } = input\n if (multiple) {\n return this._generateArrayShape(input, schema, bindings)\n }\n if (type === 'binary') {\n return this._generateFileShape(input, schema, bindings)\n }\n return this._generateScalarShape(input, schema, bindings)\n }\n\n /**\n * Normally this would be part of generating a scalar schema but the the property is an array this\n * is generated on the array and not on the range.\n *\n * @param result The scalar or array shape.\n * @param schema The property schema\n * @param type The data type of the parent property as set on the `range`\n * @param isArray Whether the DataProperty is multiple\n */\n protected _setShapeSchema(\n input: DataProperty,\n result: IApiAnyShape,\n schema: DataPropertySchema,\n type: string,\n isArray?: boolean\n ): void {\n if (schema.defaultValue) {\n const { type: dfFormat } = schema.defaultValue\n const { value } = schema.defaultValue\n if (dfFormat === 'function') {\n const tmp = this.valueGenerator.generate(value, input.type)\n if (tmp !== DataValueGenerator.noValue) {\n const dt = AmfDataNode.scalar(tmp as string, dfFormat)\n result.defaultValue = dt.toJSON()\n }\n } else {\n const dt = AmfDataNode.scalar(value, type)\n result.defaultValue = dt.toJSON()\n }\n }\n if (Array.isArray(schema.enum)) {\n result.values = schema.enum.map((i) => AmfDataNode.scalar(i, type).toJSON())\n }\n if (Array.isArray(schema.examples)) {\n if (isArray) {\n result.examples = this._generateArrayExamples(schema.examples, type)\n } else {\n result.examples = this._generateExamples(schema.examples, type)\n }\n }\n }\n\n protected _generateArrayShape(\n input: DataProperty,\n schema?: DataPropertySchema,\n bindings?: PropertyWebBindings\n ): IApiArrayShape {\n const result = arrayShape(input.key)\n const { type } = input\n if (type === 'binary') {\n // we do not pass schema to the range generator as we set schema's properties on the array shape.\n result.items = this._generateFileShape(input, undefined, bindings)\n } else {\n result.items = this._generateScalarShape(input, undefined, bindings)\n }\n if (schema) {\n const type = (result.items as IApiScalarShape).dataType as string\n this._setShapeSchema(input, result, schema, type, input.multiple)\n }\n return result\n }\n\n protected _generateScalarShape(\n input: DataProperty,\n schema?: DataPropertySchema,\n bindings?: PropertyWebBindings\n ): IApiScalarShape {\n const result = scalarShape(input.key)\n this._updateBaseProperties(input, result)\n this._fillScalarShapeCommonProperties(result, input, bindings)\n if (!result.dataType) {\n result.dataType = modelTypeToAmfDataType(input.type, bindings)\n }\n if (schema) {\n this._setShapeSchema(input, result, schema, result.dataType as string, input.multiple)\n }\n return result\n }\n\n protected _generateExamples(examples: string[], type: string): IApiDataExample[] {\n return examples.map((current) => {\n const value = AmfDataNode.scalar(current, type).toJSON()\n const item: IApiDataExample = {\n id: v4(),\n customDomainProperties: [],\n strict: true,\n types: IAmfExampleTypes,\n structuredValue: value,\n }\n return item\n })\n }\n\n protected _generateArrayExamples(examples: string[], type: string): IApiDataExample[] {\n const item: IApiDataExample = {\n id: v4(),\n customDomainProperties: [],\n strict: true,\n types: IAmfExampleTypes,\n }\n const value = new AmfDataNode('array')\n examples.forEach((item) => {\n const member = AmfDataNode.scalar(item, type)\n value.addMember(member)\n })\n item.structuredValue = value.toJSON()\n return [item]\n }\n\n protected _generateFileShape(\n input: DataProperty,\n schema?: DataPropertySchema,\n bindings?: PropertyWebBindings\n ): IApiFileShape {\n // if (bindings && bindings.format === 'base64') {\n // // this is a binary format of a string shape\n // }\n const result = fileShape(input.key)\n this._updateBaseProperties(input, result)\n if (bindings) {\n if (Array.isArray(bindings.fileTypes)) {\n result.fileTypes = bindings.fileTypes\n }\n this._fillScalarShapeCommonProperties(result, input, bindings)\n if (bindings.format === 'base64') {\n result.format = AmfNamespace.w3.xmlSchema.base64Binary\n }\n }\n return result\n }\n\n protected _fillScalarShapeCommonProperties(\n result: IApiFileShape | IApiScalarShape,\n input: DataProperty,\n bindings?: PropertyWebBindings\n ): void {\n if (bindings?.name) {\n result.name = bindings.name\n }\n if (bindings?.xml) {\n result.xmlSerialization = bindings.xml\n }\n if (bindings?.pattern) {\n result.pattern = bindings.pattern\n }\n const { schema, type } = input\n if (schema) {\n if (typeof schema.multipleOf === 'number') {\n result.multipleOf = schema.multipleOf\n }\n if (typeof schema.minimum === 'number') {\n if (type === 'string') {\n result.minLength = schema.minimum\n } else {\n result.minimum = schema.minimum\n }\n }\n if (typeof schema.maximum === 'number') {\n if (type === 'string') {\n result.maxLength = schema.maximum\n } else {\n result.maximum = schema.maximum\n }\n }\n if (typeof schema.exclusiveMinimum === 'boolean') {\n result.exclusiveMinimum = schema.exclusiveMinimum\n }\n if (typeof schema.exclusiveMaximum === 'boolean') {\n result.exclusiveMaximum = schema.exclusiveMaximum\n }\n }\n if (bindings?.format) {\n switch (bindings.format) {\n case 'base64':\n result.format = AmfNamespace.w3.xmlSchema.base64Binary\n break\n case 'double':\n result.format = AmfNamespace.w3.xmlSchema.double\n break\n case 'float':\n result.format = AmfNamespace.w3.xmlSchema.float\n break\n case 'int32':\n result.format = AmfNamespace.w3.xmlSchema.integer\n break\n case 'int64':\n result.format = AmfNamespace.w3.xmlSchema.integer\n break\n }\n // result.format = bindings.format\n }\n if (typeof input.readOnly === 'boolean') {\n result.readOnly = input.readOnly\n }\n if (typeof input.writeOnly === 'boolean') {\n result.writeOnly = input.writeOnly\n }\n }\n\n protected _updateBaseProperties(input: DataProperty | DataAssociation | DataEntity, target: IApiShape): void {\n // const bindings = input.readBinding('web') as PropertyWebBindings | undefined\n target.name = input.info.name\n target.displayName = input.info.displayName\n target.description = input.info.description\n if (input.kind === DataPropertyKind) {\n target.deprecated = (input as DataProperty).deprecated\n } else if (input.kind === DataEntityKind) {\n target.deprecated = (input as DataEntity).deprecated\n }\n }\n\n protected _recursiveShape(input: DataEntity): IApiRecursiveShape {\n return recursiveShape(input.key, input.key)\n }\n\n /**\n * Translates generated schema from an array shape to the shape defined in the `items` of the array.\n *\n * @param array The source array.\n * @returns The definition of the `items` of the array.\n */\n refactorArrayToShape(array: IApiArrayShape): IShapeUnion {\n const { items } = array\n return items as IShapeUnion\n }\n\n /**\n * Translates the shape to an array shape. This happens when data model property\n * is changed from 'multiple' to not-multiple and back.\n *\n * @param id The key of the parameter or an association\n * @param shape The shape to wrap as an array.\n * @returns Array shape.\n */\n refactorShapeToArray(id: string, shape: IShapeUnion): IApiArrayShape {\n const result = arrayShape(id)\n result.items = shape\n return result\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { type DataPropertyType } from '../modeling/DataFormat.js';
1
+ import { type DomainPropertyType } from '../modeling/DataFormat.js';
2
2
  import { PropertyWebBindings } from '../modeling/Bindings.js';
3
3
  export declare const IAmfScalarTypes: string[];
4
4
  export declare const IAmfArrayTypes: string[];
@@ -21,5 +21,5 @@ export declare const IAmfExampleTypes: string[];
21
21
  * @param type The property data type
22
22
  * @returns AMF shape dataType
23
23
  */
24
- export declare function modelTypeToAmfDataType(type: DataPropertyType, bindings?: PropertyWebBindings): string;
24
+ export declare function modelTypeToAmfDataType(type: DomainPropertyType, bindings?: PropertyWebBindings): string;
25
25
  //# sourceMappingURL=AmfTypes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AmfTypes.d.ts","sourceRoot":"","sources":["../../../src/amf/AmfTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAG7D,eAAO,MAAM,eAAe,UAM3B,CAAA;AACD,eAAO,MAAM,cAAc,UAM1B,CAAA;AACD,eAAO,MAAM,aAAa,UAMzB,CAAA;AACD,eAAO,MAAM,iBAAiB,UAK7B,CAAA;AACD,eAAO,MAAM,YAAY,UAKxB,CAAA;AACD,eAAO,MAAM,cAAc,UAM1B,CAAA;AACD,eAAO,MAAM,aAAa,UAMzB,CAAA;AACD,eAAO,MAAM,YAAY,UAKxB,CAAA;AACD,eAAO,MAAM,eAAe,UAM3B,CAAA;AACD,eAAO,MAAM,cAAc,UAO1B,CAAA;AACD,eAAO,MAAM,kBAAkB,UAK9B,CAAA;AACD,eAAO,MAAM,yBAAyB,UAGrC,CAAA;AAED,eAAO,MAAM,mBAAmB,UAI/B,CAAA;AACD,eAAO,MAAM,kBAAkB,UAK9B,CAAA;AACD,eAAO,MAAM,mBAAmB,UAI/B,CAAA;AACD,eAAO,MAAM,gBAAgB,UAG5B,CAAA;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,gBAAgB,EAAE,QAAQ,CAAC,EAAE,mBAAmB,GAAG,MAAM,CAqCrG"}
1
+ {"version":3,"file":"AmfTypes.d.ts","sourceRoot":"","sources":["../../../src/amf/AmfTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AACnE,OAAO,EAAE,mBAAmB,EAAE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E,CAAC;QACxB,OAAO,YAAY,CAAC,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAA;IAC3C,CAAC;IACD,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;QACpB,OAAO,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,YAAY,CAAA;IAC1D,CAAC;IACD,IAAI,IAAI,KAAK,QAAQ,IAAI,QAAQ,IAAI,QAAQ,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;QAClE,OAAO,YAAY,CAAC,EAAE,CAAC,SAAS,CAAC,YAAY,CAAA;IAC/C,CAAC;IACD,OAAO,YAAY,CAAC,EAAE,CAAC,SAAS,CAAC,MAAM,CAAA;IACvC,kBAAkB;IAClB,mBAAmB;IACnB,yDAAyD;IACzD,mBAAmB;IACnB,8DAA8D;IAC9D,aAAa;IACb,2EAA2E;IAC3E,sDAAsD;IACtD,QAAQ;IACR,yDAAyD;IACzD,yDAAyD;IACzD,WAAW;IACX,8CAA8C;IAC9C,IAAI;AACN,CAAC","sourcesContent":["import { type DataPropertyType } from '../modeling/DataFormat.js'\nimport { PropertyWebBindings } from '../modeling/Bindings.js'\nimport { AmfNamespace } from './definitions/Namespace.js'\n\nexport const IAmfScalarTypes = [\n AmfNamespace.aml.vocabularies.shapes.ScalarShape,\n AmfNamespace.aml.vocabularies.shapes.AnyShape,\n AmfNamespace.w3.shacl.Shape,\n AmfNamespace.aml.vocabularies.shapes.Shape,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\nexport const IAmfArrayTypes = [\n AmfNamespace.aml.vocabularies.shapes.ArrayShape,\n AmfNamespace.aml.vocabularies.shapes.AnyShape,\n AmfNamespace.w3.shacl.Shape,\n AmfNamespace.aml.vocabularies.shapes.Shape,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\nexport const IAmfNodeTypes = [\n AmfNamespace.w3.shacl.NodeShape,\n AmfNamespace.aml.vocabularies.shapes.AnyShape,\n AmfNamespace.w3.shacl.Shape,\n AmfNamespace.aml.vocabularies.shapes.Shape,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\nexport const IAmfPropertyTypes = [\n AmfNamespace.w3.shacl.PropertyShape,\n AmfNamespace.w3.shacl.Shape,\n AmfNamespace.aml.vocabularies.shapes.Shape,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\nexport const IAmfNilTypes = [\n AmfNamespace.aml.vocabularies.shapes.NilShape,\n AmfNamespace.w3.shacl.Shape,\n AmfNamespace.aml.vocabularies.shapes.Shape,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\nexport const IAmfUnionTypes = [\n AmfNamespace.aml.vocabularies.shapes.UnionShape,\n AmfNamespace.aml.vocabularies.shapes.AnyShape,\n AmfNamespace.w3.shacl.Shape,\n AmfNamespace.aml.vocabularies.shapes.Shape,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\nexport const IAmfFileTypes = [\n AmfNamespace.aml.vocabularies.shapes.FileShape,\n AmfNamespace.aml.vocabularies.shapes.AnyShape,\n AmfNamespace.w3.shacl.Shape,\n AmfNamespace.aml.vocabularies.shapes.Shape,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\nexport const IAmfAnyTypes = [\n AmfNamespace.aml.vocabularies.shapes.AnyShape,\n AmfNamespace.w3.shacl.Shape,\n AmfNamespace.aml.vocabularies.shapes.Shape,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\nexport const IAmfSchemaTypes = [\n AmfNamespace.aml.vocabularies.shapes.SchemaShape,\n AmfNamespace.aml.vocabularies.shapes.AnyShape,\n AmfNamespace.w3.shacl.Shape,\n AmfNamespace.aml.vocabularies.shapes.Shape,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\nexport const IAmfTupleTypes = [\n AmfNamespace.aml.vocabularies.shapes.TupleShape,\n AmfNamespace.aml.vocabularies.shapes.ArrayShape,\n AmfNamespace.aml.vocabularies.shapes.AnyShape,\n AmfNamespace.w3.shacl.Shape,\n AmfNamespace.aml.vocabularies.shapes.Shape,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\nexport const IAmfRecursiveTypes = [\n AmfNamespace.aml.vocabularies.shapes.RecursiveShape,\n AmfNamespace.w3.shacl.Shape,\n AmfNamespace.aml.vocabularies.shapes.Shape,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\nexport const IAmfXmlSerializationTypes = [\n AmfNamespace.aml.vocabularies.shapes.XMLSerializer,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\n\nexport const IAmfScalarNodeTypes = [\n AmfNamespace.aml.vocabularies.data.Scalar,\n AmfNamespace.aml.vocabularies.data.Node,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\nexport const IAmfArrayNodeTypes = [\n AmfNamespace.aml.vocabularies.data.Array,\n AmfNamespace.w3.rdfSchema.Seq,\n AmfNamespace.aml.vocabularies.data.Node,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\nexport const IAmfObjectNodeTypes = [\n AmfNamespace.aml.vocabularies.data.Object,\n AmfNamespace.aml.vocabularies.data.Node,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\nexport const IAmfExampleTypes = [\n AmfNamespace.aml.vocabularies.apiContract.Example,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\n\n/**\n * Translates the DataProperty type to an AMF data type.\n * @param type The property data type\n * @returns AMF shape dataType\n */\nexport function modelTypeToAmfDataType(type: DataPropertyType, bindings?: PropertyWebBindings): string {\n if (type === 'number') {\n if (bindings?.format === 'int32' || bindings?.format === 'int64') {\n return AmfNamespace.w3.xmlSchema.integer\n }\n return AmfNamespace.w3.xmlSchema.number\n }\n if (type === 'boolean') {\n return AmfNamespace.aml.vocabularies.shapes.boolean\n }\n if (type === 'date') {\n return AmfNamespace.w3.xmlSchema.date\n }\n if (type === 'datetime') {\n return AmfNamespace.w3.xmlSchema.dateTime\n }\n if (type === 'time') {\n return AmfNamespace.aml.vocabularies.shapes.dateTimeOnly\n }\n if (type === 'binary' && bindings && bindings.format === 'base64') {\n return AmfNamespace.w3.xmlSchema.base64Binary\n }\n return AmfNamespace.w3.xmlSchema.string\n // switch (type) {\n // // case 'nil':\n // // return AmfNamespace.aml.vocabularies.shapes.nil\n // // case 'any':\n // // return AmfNamespace.aml.vocabularies.shapes.AnyShape\n // default:\n // if (type === 'binary' && bindings && bindings.format === 'base64') {\n // return AmfNamespace.w3.xmlSchema.base64Binary\n // }\n // // if (bindings && bindings.format === 'binary') {\n // // return AmfNamespace.w3.xmlSchema.base64Binary\n // // }\n // return AmfNamespace.w3.xmlSchema.string\n // }\n}\n"]}
1
+ {"version":3,"file":"AmfTypes.js","sourceRoot":"","sources":["../../../src/amf/AmfTypes.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAEzD,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,WAAW;IAChD,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,QAAQ;IAC7C,YAAY,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK;IAC3B,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK;IAC1C,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,QAAQ,CAAC,aAAa;CACrD,CAAA;AACD,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,UAAU;IAC/C,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,QAAQ;IAC7C,YAAY,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK;IAC3B,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK;IAC1C,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,QAAQ,CAAC,aAAa;CACrD,CAAA;AACD,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,YAAY,CAAC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Y,CAAC,EAAE,CAAC,SAAS,CAAC,MAAM,CAAA;IACvC,kBAAkB;IAClB,mBAAmB;IACnB,yDAAyD;IACzD,mBAAmB;IACnB,8DAA8D;IAC9D,aAAa;IACb,2EAA2E;IAC3E,sDAAsD;IACtD,QAAQ;IACR,yDAAyD;IACzD,yDAAyD;IACzD,WAAW;IACX,8CAA8C;IAC9C,IAAI;AACN,CAAC","sourcesContent":["import { type DomainPropertyType } from '../modeling/DataFormat.js'\nimport { PropertyWebBindings } from '../modeling/Bindings.js'\nimport { AmfNamespace } from './definitions/Namespace.js'\n\nexport const IAmfScalarTypes = [\n AmfNamespace.aml.vocabularies.shapes.ScalarShape,\n AmfNamespace.aml.vocabularies.shapes.AnyShape,\n AmfNamespace.w3.shacl.Shape,\n AmfNamespace.aml.vocabularies.shapes.Shape,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\nexport const IAmfArrayTypes = [\n AmfNamespace.aml.vocabularies.shapes.ArrayShape,\n AmfNamespace.aml.vocabularies.shapes.AnyShape,\n AmfNamespace.w3.shacl.Shape,\n AmfNamespace.aml.vocabularies.shapes.Shape,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\nexport const IAmfNodeTypes = [\n AmfNamespace.w3.shacl.NodeShape,\n AmfNamespace.aml.vocabularies.shapes.AnyShape,\n AmfNamespace.w3.shacl.Shape,\n AmfNamespace.aml.vocabularies.shapes.Shape,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\nexport const IAmfPropertyTypes = [\n AmfNamespace.w3.shacl.PropertyShape,\n AmfNamespace.w3.shacl.Shape,\n AmfNamespace.aml.vocabularies.shapes.Shape,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\nexport const IAmfNilTypes = [\n AmfNamespace.aml.vocabularies.shapes.NilShape,\n AmfNamespace.w3.shacl.Shape,\n AmfNamespace.aml.vocabularies.shapes.Shape,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\nexport const IAmfUnionTypes = [\n AmfNamespace.aml.vocabularies.shapes.UnionShape,\n AmfNamespace.aml.vocabularies.shapes.AnyShape,\n AmfNamespace.w3.shacl.Shape,\n AmfNamespace.aml.vocabularies.shapes.Shape,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\nexport const IAmfFileTypes = [\n AmfNamespace.aml.vocabularies.shapes.FileShape,\n AmfNamespace.aml.vocabularies.shapes.AnyShape,\n AmfNamespace.w3.shacl.Shape,\n AmfNamespace.aml.vocabularies.shapes.Shape,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\nexport const IAmfAnyTypes = [\n AmfNamespace.aml.vocabularies.shapes.AnyShape,\n AmfNamespace.w3.shacl.Shape,\n AmfNamespace.aml.vocabularies.shapes.Shape,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\nexport const IAmfSchemaTypes = [\n AmfNamespace.aml.vocabularies.shapes.SchemaShape,\n AmfNamespace.aml.vocabularies.shapes.AnyShape,\n AmfNamespace.w3.shacl.Shape,\n AmfNamespace.aml.vocabularies.shapes.Shape,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\nexport const IAmfTupleTypes = [\n AmfNamespace.aml.vocabularies.shapes.TupleShape,\n AmfNamespace.aml.vocabularies.shapes.ArrayShape,\n AmfNamespace.aml.vocabularies.shapes.AnyShape,\n AmfNamespace.w3.shacl.Shape,\n AmfNamespace.aml.vocabularies.shapes.Shape,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\nexport const IAmfRecursiveTypes = [\n AmfNamespace.aml.vocabularies.shapes.RecursiveShape,\n AmfNamespace.w3.shacl.Shape,\n AmfNamespace.aml.vocabularies.shapes.Shape,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\nexport const IAmfXmlSerializationTypes = [\n AmfNamespace.aml.vocabularies.shapes.XMLSerializer,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\n\nexport const IAmfScalarNodeTypes = [\n AmfNamespace.aml.vocabularies.data.Scalar,\n AmfNamespace.aml.vocabularies.data.Node,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\nexport const IAmfArrayNodeTypes = [\n AmfNamespace.aml.vocabularies.data.Array,\n AmfNamespace.w3.rdfSchema.Seq,\n AmfNamespace.aml.vocabularies.data.Node,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\nexport const IAmfObjectNodeTypes = [\n AmfNamespace.aml.vocabularies.data.Object,\n AmfNamespace.aml.vocabularies.data.Node,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\nexport const IAmfExampleTypes = [\n AmfNamespace.aml.vocabularies.apiContract.Example,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\n\n/**\n * Translates the DataProperty type to an AMF data type.\n * @param type The property data type\n * @returns AMF shape dataType\n */\nexport function modelTypeToAmfDataType(type: DomainPropertyType, bindings?: PropertyWebBindings): string {\n if (type === 'number') {\n if (bindings?.format === 'int32' || bindings?.format === 'int64') {\n return AmfNamespace.w3.xmlSchema.integer\n }\n return AmfNamespace.w3.xmlSchema.number\n }\n if (type === 'boolean') {\n return AmfNamespace.aml.vocabularies.shapes.boolean\n }\n if (type === 'date') {\n return AmfNamespace.w3.xmlSchema.date\n }\n if (type === 'datetime') {\n return AmfNamespace.w3.xmlSchema.dateTime\n }\n if (type === 'time') {\n return AmfNamespace.aml.vocabularies.shapes.dateTimeOnly\n }\n if (type === 'binary' && bindings && bindings.format === 'base64') {\n return AmfNamespace.w3.xmlSchema.base64Binary\n }\n return AmfNamespace.w3.xmlSchema.string\n // switch (type) {\n // // case 'nil':\n // // return AmfNamespace.aml.vocabularies.shapes.nil\n // // case 'any':\n // // return AmfNamespace.aml.vocabularies.shapes.AnyShape\n // default:\n // if (type === 'binary' && bindings && bindings.format === 'base64') {\n // return AmfNamespace.w3.xmlSchema.base64Binary\n // }\n // // if (bindings && bindings.format === 'binary') {\n // // return AmfNamespace.w3.xmlSchema.base64Binary\n // // }\n // return AmfNamespace.w3.xmlSchema.string\n // }\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { DataPropertyType } from '../modeling/DataFormat.js';
2
- export declare const novalue: unique symbol;
1
+ import { DomainPropertyType } from '../modeling/DataFormat.js';
2
+ export declare const noValue: unique symbol;
3
3
  /**
4
4
  * A class to be used for generating values from pre-defined functions.
5
5
  * This is used to provide default values for data properties based on specified functions.
@@ -14,45 +14,45 @@ export declare class DataValueGenerator {
14
14
  * A symbol representing the absence of a value.
15
15
  * Used as a return value when a function cannot generate a value of the requested type.
16
16
  */
17
- static readonly novalue: symbol;
17
+ static readonly noValue: symbol;
18
18
  /**
19
19
  * Generates a value based on the provided function name and data type.
20
20
  * @param fn The name of the function to use for value generation (e.g., 'random', 'uuid-v4', 'incremental').
21
21
  * @param type The data type of the value to generate (e.g., 'string', 'number', 'date', 'time', 'datetime').
22
- * @returns The generated value, or the `novalue` symbol if the function or type is not supported.
22
+ * @returns The generated value, or the `noValue` symbol if the function or type is not supported.
23
23
  */
24
- generate(fn: string, type: DataPropertyType): string | typeof novalue;
24
+ generate(fn: string, type: DomainPropertyType): string | typeof noValue;
25
25
  /**
26
26
  * Generates a string value based on the function name.
27
27
  * @param fn The name of the string generation function.
28
- * @returns The generated string value, or `novalue` if the function is not supported.
28
+ * @returns The generated string value, or `noValue` if the function is not supported.
29
29
  */
30
- protected generateString(fn: string): string | typeof novalue;
30
+ protected generateString(fn: string): string | typeof noValue;
31
31
  /**
32
32
  * Generates a number value based on the function name.
33
33
  * @param fn The name of the number generation function.
34
- * @returns The generated number value (as a string), or `novalue` if the function is not supported.
34
+ * @returns The generated number value (as a string), or `noValue` if the function is not supported.
35
35
  */
36
- protected generateNumber(fn: string): string | typeof novalue;
36
+ protected generateNumber(fn: string): string | typeof noValue;
37
37
  /**
38
38
  * Generates a date value based on the function name.
39
39
  * @param fn The name of the date generation function.
40
40
  * @returns The generated date value (as a string in YYYY-MM-DD format),
41
- * or `novalue` if the function is not supported.
41
+ * or `noValue` if the function is not supported.
42
42
  */
43
- protected generateDate(fn: string): string | typeof novalue;
43
+ protected generateDate(fn: string): string | typeof noValue;
44
44
  /**
45
45
  * Generates a time value based on the function name.
46
46
  * @param fn The name of the time generation function.
47
- * @returns The generated time value (as a string in HH:mm:ss format), or `novalue` if the function is not supported.
47
+ * @returns The generated time value (as a string in HH:mm:ss format), or `noValue` if the function is not supported.
48
48
  */
49
- protected generateTime(fn: string): string | typeof novalue;
49
+ protected generateTime(fn: string): string | typeof noValue;
50
50
  /**
51
51
  * Generates a datetime value based on the function name.
52
52
  * @param fn The name of the datetime generation function.
53
53
  * @returns The generated datetime value (as a string in YYYY-MM-DDTHH:mm:ss format),
54
- * or `novalue` if the function is not supported.
54
+ * or `noValue` if the function is not supported.
55
55
  */
56
- protected generateDateTime(fn: string): string | typeof novalue;
56
+ protected generateDateTime(fn: string): string | typeof noValue;
57
57
  }
58
58
  //# sourceMappingURL=DataValueGenerator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DataValueGenerator.d.ts","sourceRoot":"","sources":["../../../src/amf/DataValueGenerator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAE5D,eAAO,MAAM,OAAO,eAAoB,CAAA;AAExC;;;GAGG;AACH,qBAAa,kBAAkB;IAC7B;;;OAGG;IACH,SAAS,CAAC,SAAS,SAAI;IACvB;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,OAAO,SAAU;IAEjC;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,GAAG,MAAM,GAAG,OAAO,OAAO;IAmBrE;;;;OAIG;IACH,SAAS,CAAC,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,OAAO;IAW7D;;;;OAIG;IACH,SAAS,CAAC,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,OAAO;IAS7D;;;;;OAKG;IACH,SAAS,CAAC,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GA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