@api-client/core 0.18.12 → 0.18.14

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 (269) hide show
  1. package/build/src/browser.d.ts +0 -3
  2. package/build/src/browser.d.ts.map +1 -1
  3. package/build/src/browser.js +0 -3
  4. package/build/src/browser.js.map +1 -1
  5. package/build/src/index.d.ts +2 -5
  6. package/build/src/index.d.ts.map +1 -1
  7. package/build/src/index.js +2 -5
  8. package/build/src/index.js.map +1 -1
  9. package/build/src/lib/logging/DefaultLogger.d.ts +14 -0
  10. package/build/src/lib/logging/DefaultLogger.d.ts.map +1 -1
  11. package/build/src/lib/logging/DefaultLogger.js +27 -0
  12. package/build/src/lib/logging/DefaultLogger.js.map +1 -1
  13. package/build/src/lib/logging/index.d.ts +4 -0
  14. package/build/src/lib/logging/index.d.ts.map +1 -0
  15. package/build/src/lib/logging/index.js +10 -0
  16. package/build/src/lib/logging/index.js.map +1 -0
  17. package/build/src/modeling/DomainValidation.d.ts +78 -0
  18. package/build/src/modeling/DomainValidation.d.ts.map +1 -1
  19. package/build/src/modeling/DomainValidation.js +78 -0
  20. package/build/src/modeling/DomainValidation.js.map +1 -1
  21. package/build/src/modeling/validation/entity_validation.d.ts +17 -3
  22. package/build/src/modeling/validation/entity_validation.d.ts.map +1 -1
  23. package/build/src/modeling/validation/entity_validation.js +51 -10
  24. package/build/src/modeling/validation/entity_validation.js.map +1 -1
  25. package/build/src/models/ClientCertificate.d.ts +1 -1
  26. package/build/src/models/ClientCertificate.js.map +1 -1
  27. package/build/src/models/RequestConfig.d.ts +1 -1
  28. package/build/src/models/RequestConfig.js.map +1 -1
  29. package/build/src/models/SerializableError.d.ts +1 -1
  30. package/build/src/models/SerializableError.d.ts.map +1 -1
  31. package/build/src/models/SerializableError.js.map +1 -1
  32. package/build/src/proxy/RequestProxy.d.ts.map +1 -1
  33. package/build/src/proxy/RequestProxy.js +2 -2
  34. package/build/src/proxy/RequestProxy.js.map +1 -1
  35. package/build/src/runtime/http-engine/CoreEngine.d.ts +218 -139
  36. package/build/src/runtime/http-engine/CoreEngine.d.ts.map +1 -1
  37. package/build/src/runtime/http-engine/CoreEngine.js +716 -870
  38. package/build/src/runtime/http-engine/CoreEngine.js.map +1 -1
  39. package/build/src/runtime/http-engine/PayloadSupport.d.ts.map +1 -1
  40. package/build/src/runtime/http-engine/PayloadSupport.js +2 -1
  41. package/build/src/runtime/http-engine/PayloadSupport.js.map +1 -1
  42. package/build/src/runtime/http-engine/auth/AuthManager.d.ts +73 -0
  43. package/build/src/runtime/http-engine/auth/AuthManager.d.ts.map +1 -0
  44. package/build/src/runtime/http-engine/auth/AuthManager.js +186 -0
  45. package/build/src/runtime/http-engine/auth/AuthManager.js.map +1 -0
  46. package/build/src/runtime/http-engine/auth/index.d.ts +2 -0
  47. package/build/src/runtime/http-engine/auth/index.d.ts.map +1 -0
  48. package/build/src/runtime/http-engine/auth/index.js +2 -0
  49. package/build/src/runtime/http-engine/auth/index.js.map +1 -0
  50. package/build/src/runtime/http-engine/certificates/CertificateManager.d.ts +11 -0
  51. package/build/src/runtime/http-engine/certificates/CertificateManager.d.ts.map +1 -0
  52. package/build/src/runtime/http-engine/certificates/CertificateManager.js +76 -0
  53. package/build/src/runtime/http-engine/certificates/CertificateManager.js.map +1 -0
  54. package/build/src/runtime/http-engine/certificates/index.d.ts +2 -0
  55. package/build/src/runtime/http-engine/certificates/index.d.ts.map +1 -0
  56. package/build/src/runtime/http-engine/certificates/index.js +2 -0
  57. package/build/src/runtime/http-engine/certificates/index.js.map +1 -0
  58. package/build/src/runtime/http-engine/compression/CompressionManager.d.ts +25 -0
  59. package/build/src/runtime/http-engine/compression/CompressionManager.d.ts.map +1 -0
  60. package/build/src/runtime/http-engine/compression/CompressionManager.js +89 -0
  61. package/build/src/runtime/http-engine/compression/CompressionManager.js.map +1 -0
  62. package/build/src/runtime/http-engine/compression/index.d.ts +2 -0
  63. package/build/src/runtime/http-engine/compression/index.d.ts.map +1 -0
  64. package/build/src/runtime/http-engine/compression/index.js +2 -0
  65. package/build/src/runtime/http-engine/compression/index.js.map +1 -0
  66. package/build/src/runtime/http-engine/connections/ConnectionManager.d.ts +57 -0
  67. package/build/src/runtime/http-engine/connections/ConnectionManager.d.ts.map +1 -0
  68. package/build/src/runtime/http-engine/connections/ConnectionManager.js +78 -0
  69. package/build/src/runtime/http-engine/connections/ConnectionManager.js.map +1 -0
  70. package/build/src/runtime/http-engine/connections/DigestAuthHandler.d.ts +70 -0
  71. package/build/src/runtime/http-engine/connections/DigestAuthHandler.d.ts.map +1 -0
  72. package/build/src/runtime/http-engine/connections/DigestAuthHandler.js +184 -0
  73. package/build/src/runtime/http-engine/connections/DigestAuthHandler.js.map +1 -0
  74. package/build/src/runtime/http-engine/connections/DirectConnection.d.ts +22 -0
  75. package/build/src/runtime/http-engine/connections/DirectConnection.d.ts.map +1 -0
  76. package/build/src/runtime/http-engine/connections/DirectConnection.js +105 -0
  77. package/build/src/runtime/http-engine/connections/DirectConnection.js.map +1 -0
  78. package/build/src/runtime/http-engine/connections/ProxyAuthHandler.d.ts +60 -0
  79. package/build/src/runtime/http-engine/connections/ProxyAuthHandler.d.ts.map +1 -0
  80. package/build/src/runtime/http-engine/connections/ProxyAuthHandler.js +138 -0
  81. package/build/src/runtime/http-engine/connections/ProxyAuthHandler.js.map +1 -0
  82. package/build/src/runtime/http-engine/connections/ProxyConnection.d.ts +14 -0
  83. package/build/src/runtime/http-engine/connections/ProxyConnection.d.ts.map +1 -0
  84. package/build/src/runtime/http-engine/connections/ProxyConnection.js +47 -0
  85. package/build/src/runtime/http-engine/connections/ProxyConnection.js.map +1 -0
  86. package/build/src/runtime/http-engine/connections/TunnelConnection.d.ts +13 -0
  87. package/build/src/runtime/http-engine/connections/TunnelConnection.d.ts.map +1 -0
  88. package/build/src/runtime/http-engine/connections/TunnelConnection.js +175 -0
  89. package/build/src/runtime/http-engine/connections/TunnelConnection.js.map +1 -0
  90. package/build/src/runtime/http-engine/connections/index.d.ts +7 -0
  91. package/build/src/runtime/http-engine/connections/index.d.ts.map +1 -0
  92. package/build/src/runtime/http-engine/connections/index.js +7 -0
  93. package/build/src/runtime/http-engine/connections/index.js.map +1 -0
  94. package/build/src/runtime/http-engine/constants.d.ts +69 -0
  95. package/build/src/runtime/http-engine/constants.d.ts.map +1 -0
  96. package/build/src/runtime/http-engine/constants.js +90 -0
  97. package/build/src/runtime/http-engine/constants.js.map +1 -0
  98. package/build/src/runtime/http-engine/cookies/CookieProcessor.d.ts +5 -0
  99. package/build/src/runtime/http-engine/cookies/CookieProcessor.d.ts.map +1 -0
  100. package/build/src/runtime/http-engine/cookies/CookieProcessor.js +20 -0
  101. package/build/src/runtime/http-engine/cookies/CookieProcessor.js.map +1 -0
  102. package/build/src/runtime/http-engine/cookies/index.d.ts +2 -0
  103. package/build/src/runtime/http-engine/cookies/index.d.ts.map +1 -0
  104. package/build/src/runtime/http-engine/cookies/index.js +2 -0
  105. package/build/src/runtime/http-engine/cookies/index.js.map +1 -0
  106. package/build/src/runtime/http-engine/errors/HttpEngineErrors.d.ts +156 -0
  107. package/build/src/runtime/http-engine/errors/HttpEngineErrors.d.ts.map +1 -0
  108. package/build/src/runtime/http-engine/errors/HttpEngineErrors.js +227 -0
  109. package/build/src/runtime/http-engine/errors/HttpEngineErrors.js.map +1 -0
  110. package/build/src/runtime/http-engine/errors/index.d.ts +2 -0
  111. package/build/src/runtime/http-engine/errors/index.d.ts.map +1 -0
  112. package/build/src/runtime/http-engine/errors/index.js +2 -0
  113. package/build/src/runtime/http-engine/errors/index.js.map +1 -0
  114. package/build/src/runtime/http-engine/message/MessageBuilder.d.ts +66 -0
  115. package/build/src/runtime/http-engine/message/MessageBuilder.d.ts.map +1 -0
  116. package/build/src/runtime/http-engine/message/MessageBuilder.js +161 -0
  117. package/build/src/runtime/http-engine/message/MessageBuilder.js.map +1 -0
  118. package/build/src/runtime/http-engine/message/MessageProcessor.d.ts +27 -0
  119. package/build/src/runtime/http-engine/message/MessageProcessor.d.ts.map +1 -0
  120. package/build/src/runtime/http-engine/message/MessageProcessor.js +51 -0
  121. package/build/src/runtime/http-engine/message/MessageProcessor.js.map +1 -0
  122. package/build/src/runtime/http-engine/message/index.d.ts +3 -0
  123. package/build/src/runtime/http-engine/message/index.d.ts.map +1 -0
  124. package/build/src/runtime/http-engine/message/index.js +3 -0
  125. package/build/src/runtime/http-engine/message/index.js.map +1 -0
  126. package/build/src/runtime/http-engine/ntlm/NtlmAuth.d.ts +2 -8
  127. package/build/src/runtime/http-engine/ntlm/NtlmAuth.d.ts.map +1 -1
  128. package/build/src/runtime/http-engine/ntlm/NtlmAuth.js +11 -5
  129. package/build/src/runtime/http-engine/ntlm/NtlmAuth.js.map +1 -1
  130. package/build/src/runtime/http-engine/ntlm/NtlmMessage.js +6 -6
  131. package/build/src/runtime/http-engine/ntlm/NtlmMessage.js.map +1 -1
  132. package/build/src/runtime/http-engine/parsers/BodyParser.d.ts +39 -0
  133. package/build/src/runtime/http-engine/parsers/BodyParser.d.ts.map +1 -0
  134. package/build/src/runtime/http-engine/parsers/BodyParser.js +145 -0
  135. package/build/src/runtime/http-engine/parsers/BodyParser.js.map +1 -0
  136. package/build/src/runtime/http-engine/parsers/HeadersParser.d.ts +29 -0
  137. package/build/src/runtime/http-engine/parsers/HeadersParser.d.ts.map +1 -0
  138. package/build/src/runtime/http-engine/parsers/HeadersParser.js +88 -0
  139. package/build/src/runtime/http-engine/parsers/HeadersParser.js.map +1 -0
  140. package/build/src/runtime/http-engine/parsers/HttpResponseParser.d.ts +91 -0
  141. package/build/src/runtime/http-engine/parsers/HttpResponseParser.d.ts.map +1 -0
  142. package/build/src/runtime/http-engine/parsers/HttpResponseParser.js +236 -0
  143. package/build/src/runtime/http-engine/parsers/HttpResponseParser.js.map +1 -0
  144. package/build/src/runtime/http-engine/parsers/StatusParser.d.ts +20 -0
  145. package/build/src/runtime/http-engine/parsers/StatusParser.d.ts.map +1 -0
  146. package/build/src/runtime/http-engine/parsers/StatusParser.js +51 -0
  147. package/build/src/runtime/http-engine/parsers/StatusParser.js.map +1 -0
  148. package/build/src/runtime/http-engine/parsers/index.d.ts +5 -0
  149. package/build/src/runtime/http-engine/parsers/index.d.ts.map +1 -0
  150. package/build/src/runtime/http-engine/parsers/index.js +5 -0
  151. package/build/src/runtime/http-engine/parsers/index.js.map +1 -0
  152. package/build/src/runtime/http-engine/response/ResponseProcessor.d.ts +22 -0
  153. package/build/src/runtime/http-engine/response/ResponseProcessor.d.ts.map +1 -0
  154. package/build/src/runtime/http-engine/response/ResponseProcessor.js +25 -0
  155. package/build/src/runtime/http-engine/response/ResponseProcessor.js.map +1 -0
  156. package/build/src/runtime/http-engine/response/index.d.ts +2 -0
  157. package/build/src/runtime/http-engine/response/index.d.ts.map +1 -0
  158. package/build/src/runtime/http-engine/response/index.js +2 -0
  159. package/build/src/runtime/http-engine/response/index.js.map +1 -0
  160. package/build/src/runtime/http-engine/statistics/StatisticsProcessor.d.ts +7 -0
  161. package/build/src/runtime/http-engine/statistics/StatisticsProcessor.d.ts.map +1 -0
  162. package/build/src/runtime/http-engine/statistics/StatisticsProcessor.js +40 -0
  163. package/build/src/runtime/http-engine/statistics/StatisticsProcessor.js.map +1 -0
  164. package/build/src/runtime/http-engine/statistics/index.d.ts +2 -0
  165. package/build/src/runtime/http-engine/statistics/index.d.ts.map +1 -0
  166. package/build/src/runtime/http-engine/statistics/index.js +2 -0
  167. package/build/src/runtime/http-engine/statistics/index.js.map +1 -0
  168. package/build/src/runtime/http-engine/url/UrlProcessor.d.ts +24 -0
  169. package/build/src/runtime/http-engine/url/UrlProcessor.d.ts.map +1 -0
  170. package/build/src/runtime/http-engine/url/UrlProcessor.js +50 -0
  171. package/build/src/runtime/http-engine/url/UrlProcessor.js.map +1 -0
  172. package/build/src/runtime/http-engine/url/index.d.ts +2 -0
  173. package/build/src/runtime/http-engine/url/index.d.ts.map +1 -0
  174. package/build/src/runtime/http-engine/url/index.js +2 -0
  175. package/build/src/runtime/http-engine/url/index.js.map +1 -0
  176. package/build/src/runtime/http-runner/HttpRequestRunner.d.ts +3 -3
  177. package/build/src/runtime/http-runner/HttpRequestRunner.d.ts.map +1 -1
  178. package/build/src/runtime/http-runner/HttpRequestRunner.js.map +1 -1
  179. package/build/src/runtime/node/InteropInterfaces.d.ts +3 -3
  180. package/build/src/runtime/node/InteropInterfaces.d.ts.map +1 -1
  181. package/build/src/runtime/node/InteropInterfaces.js.map +1 -1
  182. package/build/src/runtime/node/ProjectRequestRunner.d.ts +2 -2
  183. package/build/src/runtime/node/ProjectRequestRunner.d.ts.map +1 -1
  184. package/build/src/runtime/node/ProjectRequestRunner.js.map +1 -1
  185. package/build/src/runtime/node/ProjectRunner.d.ts.map +1 -1
  186. package/build/src/runtime/node/ProjectRunner.js +2 -2
  187. package/build/src/runtime/node/ProjectRunner.js.map +1 -1
  188. package/build/tsconfig.tsbuildinfo +1 -1
  189. package/package.json +2 -2
  190. package/src/lib/logging/DefaultLogger.ts +32 -0
  191. package/src/modeling/DomainValidation.ts +78 -0
  192. package/src/modeling/validation/entity_validation.ts +59 -10
  193. package/src/models/ClientCertificate.ts +1 -1
  194. package/src/models/RequestConfig.ts +1 -1
  195. package/src/models/SerializableError.ts +1 -1
  196. package/src/proxy/RequestProxy.ts +2 -2
  197. package/src/runtime/http-engine/CoreEngine.ts +858 -893
  198. package/src/runtime/http-engine/PayloadSupport.ts +2 -1
  199. package/src/runtime/http-engine/auth/AuthManager.ts +242 -0
  200. package/src/runtime/http-engine/certificates/CertificateManager.ts +74 -0
  201. package/src/runtime/http-engine/compression/CompressionManager.ts +99 -0
  202. package/src/runtime/http-engine/connections/ConnectionManager.ts +123 -0
  203. package/src/runtime/http-engine/connections/DigestAuthHandler.ts +238 -0
  204. package/src/runtime/http-engine/connections/DirectConnection.ts +134 -0
  205. package/src/runtime/http-engine/connections/ProxyAuthHandler.ts +179 -0
  206. package/src/runtime/http-engine/connections/ProxyConnection.ts +55 -0
  207. package/src/runtime/http-engine/connections/TunnelConnection.ts +192 -0
  208. package/src/runtime/http-engine/constants.ts +103 -0
  209. package/src/runtime/http-engine/cookies/CookieProcessor.ts +25 -0
  210. package/src/runtime/http-engine/errors/HttpEngineErrors.ts +319 -0
  211. package/src/runtime/http-engine/message/MessageBuilder.ts +201 -0
  212. package/src/runtime/http-engine/message/MessageProcessor.ts +73 -0
  213. package/src/runtime/http-engine/ntlm/NtlmAuth.ts +16 -13
  214. package/src/runtime/http-engine/ntlm/NtlmMessage.ts +6 -6
  215. package/src/runtime/http-engine/parsers/BodyParser.ts +171 -0
  216. package/src/runtime/http-engine/parsers/HeadersParser.ts +103 -0
  217. package/src/runtime/http-engine/parsers/HttpResponseParser.ts +280 -0
  218. package/src/runtime/http-engine/parsers/StatusParser.ts +69 -0
  219. package/src/runtime/http-engine/response/ResponseProcessor.ts +46 -0
  220. package/src/runtime/http-engine/statistics/StatisticsProcessor.ts +52 -0
  221. package/src/runtime/http-engine/url/UrlProcessor.ts +55 -0
  222. package/src/runtime/http-runner/HttpRequestRunner.ts +3 -3
  223. package/src/runtime/node/InteropInterfaces.ts +3 -3
  224. package/src/runtime/node/ProjectRequestRunner.ts +2 -2
  225. package/src/runtime/node/ProjectRunner.ts +2 -2
  226. package/tests/servers/ProxyServer.ts +32 -19
  227. package/tests/servers/express-routes/ApiEndpoint.ts +24 -0
  228. package/tests/servers/express-routes/BasicAuthRoute.ts +36 -0
  229. package/tests/servers/express-routes/BearerAuthRoute.ts +35 -0
  230. package/tests/servers/express-routes/NTLMRoute.ts +2 -3
  231. package/tests/servers/express-routes/PostApi.ts +15 -2
  232. package/tests/servers/express-routes/RedirectsApi.ts +12 -1
  233. package/tests/servers/express-routes/ResponsesApi.ts +1 -1
  234. package/tests/servers/express-routes/StreamApi.ts +19 -0
  235. package/tests/servers/oauth2mock/ServerMock.js +1 -1
  236. package/tests/unit/modeling/validation/entity_validation.spec.ts +95 -0
  237. package/tests/unit/runtime/http-engine/HttpResponseParser.spec.ts +337 -0
  238. package/tests/unit/runtime/http-engine/abort.spec.ts +4 -5
  239. package/tests/unit/runtime/http-engine/auth.spec.ts +7 -58
  240. package/tests/unit/runtime/http-engine/certificates/CertificateManager.spec.ts +482 -0
  241. package/tests/unit/runtime/http-engine/certificates.spec.ts +2 -2
  242. package/tests/unit/runtime/http-engine/compression/CompressionManager.spec.ts +498 -0
  243. package/tests/unit/runtime/http-engine/compression.spec.ts +3 -72
  244. package/tests/unit/runtime/http-engine/connections/ConnectionManager.spec.ts +379 -0
  245. package/tests/unit/runtime/http-engine/connections/DigestAuthHandler.spec.ts +164 -0
  246. package/tests/unit/runtime/http-engine/core_engine.spec.ts +561 -0
  247. package/tests/unit/runtime/http-engine/engine_statuses.spec.ts +2 -2
  248. package/tests/unit/runtime/http-engine/events.spec.ts +2 -2
  249. package/tests/unit/runtime/http-engine/headers.spec.ts +2 -88
  250. package/tests/unit/runtime/http-engine/hosts.spec.ts +2 -2
  251. package/tests/unit/runtime/http-engine/http-get.spec.ts +2 -2
  252. package/tests/unit/runtime/http-engine/http-post.spec.ts +2 -2
  253. package/tests/unit/runtime/http-engine/logger.spec.ts +0 -8
  254. package/tests/unit/runtime/http-engine/message.spec.ts +2 -194
  255. package/tests/unit/runtime/http-engine/params.spec.ts +4 -4
  256. package/tests/unit/runtime/http-engine/proxy.spec.ts +15 -14
  257. package/tests/unit/runtime/http-engine/redirects.spec.ts +2 -2
  258. package/tests/unit/runtime/http-engine/responses.spec.ts +170 -277
  259. package/tests/unit/runtime/http-engine/timeout.spec.ts +3 -3
  260. package/tests/unit/runtime/http-engine/timings.spec.ts +2 -2
  261. package/tests/unit/runtime/proxy/HttpProjectProxy.spec.ts +25 -28
  262. package/tests/unit/runtime/runners/project_runner.spec.ts +2 -2
  263. package/tests/unit/runtime/runners/request_runner.spec.ts +2 -2
  264. package/build/src/runtime/http-engine/HttpEngine.d.ts +0 -311
  265. package/build/src/runtime/http-engine/HttpEngine.d.ts.map +0 -1
  266. package/build/src/runtime/http-engine/HttpEngine.js +0 -802
  267. package/build/src/runtime/http-engine/HttpEngine.js.map +0 -1
  268. package/src/runtime/http-engine/HttpEngine.ts +0 -952
  269. package/tests/unit/runtime/http-engine/connecting.spec.ts +0 -140
@@ -1,8 +1,86 @@
1
1
  import { DataDomain } from './DataDomain.js';
2
2
  import { DomainImpactReport } from './types.js';
3
+ /**
4
+ * DomainValidation performs comprehensive validation on a data domain and its components.
5
+ *
6
+ * This class orchestrates validation across all domain elements including entities, properties,
7
+ * associations, and semantics. It ensures that the data domain is well-formed and follows
8
+ * established conventions before it can be published or used in API generation.
9
+ *
10
+ * ## Validation Scope
11
+ *
12
+ * The validation process covers:
13
+ * - **Entities**: Structure, naming, primary keys, and inheritance
14
+ * - **Properties**: Naming conventions, data types, and constraints
15
+ * - **Associations**: Relationships, targets, and naming
16
+ * - **Semantics**: Recommended patterns and best practices
17
+ *
18
+ * ## Validation Severity Levels
19
+ *
20
+ * - **Error**: Blocking issues that prevent domain publication
21
+ * - **Warning**: Issues that may cause problems but don't block publication
22
+ * - **Info**: Recommendations for best practices
23
+ *
24
+ * ## Usage
25
+ *
26
+ * ```typescript
27
+ * const domain = new DataDomain()
28
+ * // ... add entities, properties, associations
29
+ *
30
+ * const validator = new DomainValidation(domain)
31
+ * const report = validator.validate()
32
+ *
33
+ * if (report.canProceed) {
34
+ * // Domain is valid and can be published
35
+ * } else {
36
+ * // Handle validation errors
37
+ * console.log(report.impact)
38
+ * }
39
+ * ```
40
+ *
41
+ * ## Validation Rules
42
+ *
43
+ * ### Entity Validation Rules
44
+ * - **Primary Key**: Each entity must have a primary key (can be inherited)
45
+ * - **Minimum Properties**: Entities should have properties or associations (can be inherited)
46
+ * - **Naming**: Entity names must follow PostgreSQL naming conventions
47
+ * - **Uniqueness**: Entity names must be unique within the domain
48
+ *
49
+ * ### Property Validation Rules
50
+ * - **Naming**: Properties must follow PostgreSQL column naming conventions
51
+ * - **Length**: Names must be 2-59 characters long
52
+ * - **Format**: Names must start with letter/underscore, contain only alphanumeric/underscore
53
+ * - **Reserved Words**: Names cannot be PostgreSQL reserved keywords
54
+ * - **Case**: Snake case is recommended (lowercase with underscores)
55
+ *
56
+ * ### Association Validation Rules
57
+ * - **Targets**: Associations must have at least one target entity
58
+ * - **Target Existence**: Target entities must exist in the domain
59
+ * - **Naming**: Same rules as properties
60
+ *
61
+ * ### Semantic Validation Rules
62
+ * - **User Entity**: Recommended to have at least one entity with User semantic
63
+ * - **Timestamps**: Recommended to have CreatedTimestamp and UpdatedTimestamp properties
64
+ * - **Soft Delete**: Recommended to have soft delete capability for entities
65
+ * - **Data Types**: Semantic-specific data type validation
66
+ *
67
+ * @see {@link EntityValidation} for detailed entity validation rules
68
+ * @see {@link PropertyValidation} for detailed property validation rules
69
+ * @see {@link AssociationValidation} for detailed association validation rules
70
+ * @see {@link SemanticValidation} for detailed semantic validation rules
71
+ */
3
72
  export declare class DomainValidation {
4
73
  private root;
5
74
  constructor(root: DataDomain);
75
+ /**
76
+ * Performs comprehensive validation on the entire data domain.
77
+ *
78
+ * This method validates all entities, properties, associations, and semantics
79
+ * in the domain. It returns a detailed report of all validation issues found,
80
+ * categorized by severity level.
81
+ *
82
+ * @returns A comprehensive validation report with all issues found
83
+ */
6
84
  validate(): DomainImpactReport;
7
85
  }
8
86
  //# sourceMappingURL=DomainValidation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DomainValidation.d.ts","sourceRoot":"","sources":["../../../src/modeling/DomainValidation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAM/C,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,IAAI,CAAY;gBAEZ,IAAI,EAAE,UAAU;IAI5B,QAAQ,IAAI,kBAAkB;CAyF/B"}
1
+ {"version":3,"file":"DomainValidation.d.ts","sourceRoot":"","sources":["../../../src/modeling/DomainValidation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAM/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,IAAI,CAAY;gBAEZ,IAAI,EAAE,UAAU;IAI5B;;;;;;;;OAQG;IACH,QAAQ,IAAI,kBAAkB;CAyF/B"}
@@ -3,11 +3,89 @@ import { AssociationValidation } from './validation/association_validation.js';
3
3
  import { EntityValidation } from './validation/entity_validation.js';
4
4
  import { PropertyValidation } from './validation/property_validation.js';
5
5
  import { SemanticValidation } from './validation/semantic_validation.js';
6
+ /**
7
+ * DomainValidation performs comprehensive validation on a data domain and its components.
8
+ *
9
+ * This class orchestrates validation across all domain elements including entities, properties,
10
+ * associations, and semantics. It ensures that the data domain is well-formed and follows
11
+ * established conventions before it can be published or used in API generation.
12
+ *
13
+ * ## Validation Scope
14
+ *
15
+ * The validation process covers:
16
+ * - **Entities**: Structure, naming, primary keys, and inheritance
17
+ * - **Properties**: Naming conventions, data types, and constraints
18
+ * - **Associations**: Relationships, targets, and naming
19
+ * - **Semantics**: Recommended patterns and best practices
20
+ *
21
+ * ## Validation Severity Levels
22
+ *
23
+ * - **Error**: Blocking issues that prevent domain publication
24
+ * - **Warning**: Issues that may cause problems but don't block publication
25
+ * - **Info**: Recommendations for best practices
26
+ *
27
+ * ## Usage
28
+ *
29
+ * ```typescript
30
+ * const domain = new DataDomain()
31
+ * // ... add entities, properties, associations
32
+ *
33
+ * const validator = new DomainValidation(domain)
34
+ * const report = validator.validate()
35
+ *
36
+ * if (report.canProceed) {
37
+ * // Domain is valid and can be published
38
+ * } else {
39
+ * // Handle validation errors
40
+ * console.log(report.impact)
41
+ * }
42
+ * ```
43
+ *
44
+ * ## Validation Rules
45
+ *
46
+ * ### Entity Validation Rules
47
+ * - **Primary Key**: Each entity must have a primary key (can be inherited)
48
+ * - **Minimum Properties**: Entities should have properties or associations (can be inherited)
49
+ * - **Naming**: Entity names must follow PostgreSQL naming conventions
50
+ * - **Uniqueness**: Entity names must be unique within the domain
51
+ *
52
+ * ### Property Validation Rules
53
+ * - **Naming**: Properties must follow PostgreSQL column naming conventions
54
+ * - **Length**: Names must be 2-59 characters long
55
+ * - **Format**: Names must start with letter/underscore, contain only alphanumeric/underscore
56
+ * - **Reserved Words**: Names cannot be PostgreSQL reserved keywords
57
+ * - **Case**: Snake case is recommended (lowercase with underscores)
58
+ *
59
+ * ### Association Validation Rules
60
+ * - **Targets**: Associations must have at least one target entity
61
+ * - **Target Existence**: Target entities must exist in the domain
62
+ * - **Naming**: Same rules as properties
63
+ *
64
+ * ### Semantic Validation Rules
65
+ * - **User Entity**: Recommended to have at least one entity with User semantic
66
+ * - **Timestamps**: Recommended to have CreatedTimestamp and UpdatedTimestamp properties
67
+ * - **Soft Delete**: Recommended to have soft delete capability for entities
68
+ * - **Data Types**: Semantic-specific data type validation
69
+ *
70
+ * @see {@link EntityValidation} for detailed entity validation rules
71
+ * @see {@link PropertyValidation} for detailed property validation rules
72
+ * @see {@link AssociationValidation} for detailed association validation rules
73
+ * @see {@link SemanticValidation} for detailed semantic validation rules
74
+ */
6
75
  export class DomainValidation {
7
76
  root;
8
77
  constructor(root) {
9
78
  this.root = root;
10
79
  }
80
+ /**
81
+ * Performs comprehensive validation on the entire data domain.
82
+ *
83
+ * This method validates all entities, properties, associations, and semantics
84
+ * in the domain. It returns a detailed report of all validation issues found,
85
+ * categorized by severity level.
86
+ *
87
+ * @returns A comprehensive validation report with all issues found
88
+ */
11
89
  validate() {
12
90
  const result = {
13
91
  key: '',
@@ -1 +1 @@
1
- {"version":3,"file":"DomainValidation.js","sourceRoot":"","sources":["../../../src/modeling/DomainValidation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAGnD,OAAO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js'\nimport { DataDomain } from './DataDomain.js'\nimport { DomainImpactReport } from './types.js'\nimport { AssociationValidation } from './validation/association_validation.js'\nimport { EntityValidation } from './validation/entity_validation.js'\nimport { PropertyValidation } from './validation/property_validation.js'\nimport { SemanticValidation } from './validation/semantic_validation.js'\n\nexport class DomainValidation {\n private root: DataDomain\n\n constructor(root: DataDomain) {\n this.root = root\n }\n\n validate(): DomainImpactReport {\n const result: DomainImpactReport = {\n key: '',\n kind: DataDomainKind,\n impact: [],\n canProceed: true,\n }\n const entityValidator = new EntityValidation(this.root)\n const propertyValidator = new PropertyValidation(this.root)\n const associationValidator = new AssociationValidation(this.root)\n const semanticValidator = new SemanticValidation(this.root)\n\n let hasEntities = false\n // Validate entities, properties, and associations\n for (const entity of this.root.listEntities()) {\n if (entity.domain.key !== this.root.key) {\n // we don't need to validate foreign entities\n continue\n }\n hasEntities = true\n const report = entityValidator.validate(entity)\n for (const item of report) {\n const blocking = item.severity === 'error'\n result.canProceed = result.canProceed && !blocking\n result.impact.push({\n key: item.key,\n kind: item.kind,\n type: 'publish',\n impact: item.message,\n resolution: item.help,\n severity: item.severity,\n parent: item.parent,\n })\n }\n for (const property of entity.properties) {\n const report = propertyValidator.validate(property)\n for (const item of report) {\n const blocking = item.severity === 'error'\n result.canProceed = result.canProceed && !blocking\n result.impact.push({\n key: item.key,\n kind: item.kind,\n type: 'publish',\n impact: item.message,\n resolution: item.help,\n severity: item.severity,\n parent: item.parent,\n })\n }\n }\n for (const association of entity.associations) {\n const report = associationValidator.validate(association)\n for (const item of report) {\n const blocking = item.severity === 'error'\n result.canProceed = result.canProceed && !blocking\n result.impact.push({\n key: item.key,\n kind: item.kind,\n type: 'publish',\n impact: item.message,\n resolution: item.help,\n severity: item.severity,\n parent: item.parent,\n })\n }\n }\n }\n if (!hasEntities) {\n // no entities, no need to validate anything else\n return result\n }\n // Validate semantics\n const semanticReport = semanticValidator.validate()\n for (const item of semanticReport) {\n const blocking = item.severity === 'error'\n result.canProceed = result.canProceed && !blocking\n result.impact.push({\n key: item.key,\n kind: item.kind,\n type: 'publish',\n impact: item.message,\n resolution: item.help,\n severity: item.severity,\n parent: item.parent,\n })\n }\n\n return result\n }\n}\n"]}
1
+ {"version":3,"file":"DomainValidation.js","sourceRoot":"","sources":["../../../src/modeling/DomainValidation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAGnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAA;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAA;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAA;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAA;AAExE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,MAAM,OAAO,gBAAgB;IACnB,IAAI,CAAY;IAExB,YAAY,IAAgB;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAED;;;;;;;;OAQG;IACH,QAAQ;QACN,MAAM,MAAM,GAAuB;YACjC,GAAG,EAAE,EAAE;YACP,IAAI,EAAE,cAAc;YACpB,MAAM,EAAE,EAAE;YACV,UAAU,EAAE,IAAI;SACjB,CAAA;QACD,MAAM,eAAe,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACvD,MAAM,iBAAiB,GAAG,IAAI,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC3D,MAAM,oBAAoB,GAAG,IAAI,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACjE,MAAM,iBAAiB,GAAG,IAAI,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAE3D,IAAI,WAAW,GAAG,KAAK,CAAA;QACvB,kDAAkD;QAClD,KAAK,MAAM,MAAM,IAA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AAM,CAAC,MAAM,CAAC,IAAI,CAAC;gBACjB,GAAG,EAAE,IAAI,CAAC,GAAG;gBACb,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,IAAI,EAAE,SAAS;gBACf,MAAM,EAAE,IAAI,CAAC,OAAO;gBACpB,UAAU,EAAE,IAAI,CAAC,IAAI;gBACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,MAAM,EAAE,IAAI,CAAC,MAAM;aACpB,CAAC,CAAA;QACJ,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC;CACF","sourcesContent":["import { DataDomainKind } from '../models/kinds.js'\nimport { DataDomain } from './DataDomain.js'\nimport { DomainImpactReport } from './types.js'\nimport { AssociationValidation } from './validation/association_validation.js'\nimport { EntityValidation } from './validation/entity_validation.js'\nimport { PropertyValidation } from './validation/property_validation.js'\nimport { SemanticValidation } from './validation/semantic_validation.js'\n\n/**\n * DomainValidation performs comprehensive validation on a data domain and its components.\n *\n * This class orchestrates validation across all domain elements including entities, properties,\n * associations, and semantics. It ensures that the data domain is well-formed and follows\n * established conventions before it can be published or used in API generation.\n *\n * ## Validation Scope\n *\n * The validation process covers:\n * - **Entities**: Structure, naming, primary keys, and inheritance\n * - **Properties**: Naming conventions, data types, and constraints\n * - **Associations**: Relationships, targets, and naming\n * - **Semantics**: Recommended patterns and best practices\n *\n * ## Validation Severity Levels\n *\n * - **Error**: Blocking issues that prevent domain publication\n * - **Warning**: Issues that may cause problems but don't block publication\n * - **Info**: Recommendations for best practices\n *\n * ## Usage\n *\n * ```typescript\n * const domain = new DataDomain()\n * // ... add entities, properties, associations\n *\n * const validator = new DomainValidation(domain)\n * const report = validator.validate()\n *\n * if (report.canProceed) {\n * // Domain is valid and can be published\n * } else {\n * // Handle validation errors\n * console.log(report.impact)\n * }\n * ```\n *\n * ## Validation Rules\n *\n * ### Entity Validation Rules\n * - **Primary Key**: Each entity must have a primary key (can be inherited)\n * - **Minimum Properties**: Entities should have properties or associations (can be inherited)\n * - **Naming**: Entity names must follow PostgreSQL naming conventions\n * - **Uniqueness**: Entity names must be unique within the domain\n *\n * ### Property Validation Rules\n * - **Naming**: Properties must follow PostgreSQL column naming conventions\n * - **Length**: Names must be 2-59 characters long\n * - **Format**: Names must start with letter/underscore, contain only alphanumeric/underscore\n * - **Reserved Words**: Names cannot be PostgreSQL reserved keywords\n * - **Case**: Snake case is recommended (lowercase with underscores)\n *\n * ### Association Validation Rules\n * - **Targets**: Associations must have at least one target entity\n * - **Target Existence**: Target entities must exist in the domain\n * - **Naming**: Same rules as properties\n *\n * ### Semantic Validation Rules\n * - **User Entity**: Recommended to have at least one entity with User semantic\n * - **Timestamps**: Recommended to have CreatedTimestamp and UpdatedTimestamp properties\n * - **Soft Delete**: Recommended to have soft delete capability for entities\n * - **Data Types**: Semantic-specific data type validation\n *\n * @see {@link EntityValidation} for detailed entity validation rules\n * @see {@link PropertyValidation} for detailed property validation rules\n * @see {@link AssociationValidation} for detailed association validation rules\n * @see {@link SemanticValidation} for detailed semantic validation rules\n */\nexport class DomainValidation {\n private root: DataDomain\n\n constructor(root: DataDomain) {\n this.root = root\n }\n\n /**\n * Performs comprehensive validation on the entire data domain.\n *\n * This method validates all entities, properties, associations, and semantics\n * in the domain. It returns a detailed report of all validation issues found,\n * categorized by severity level.\n *\n * @returns A comprehensive validation report with all issues found\n */\n validate(): DomainImpactReport {\n const result: DomainImpactReport = {\n key: '',\n kind: DataDomainKind,\n impact: [],\n canProceed: true,\n }\n const entityValidator = new EntityValidation(this.root)\n const propertyValidator = new PropertyValidation(this.root)\n const associationValidator = new AssociationValidation(this.root)\n const semanticValidator = new SemanticValidation(this.root)\n\n let hasEntities = false\n // Validate entities, properties, and associations\n for (const entity of this.root.listEntities()) {\n if (entity.domain.key !== this.root.key) {\n // we don't need to validate foreign entities\n continue\n }\n hasEntities = true\n const report = entityValidator.validate(entity)\n for (const item of report) {\n const blocking = item.severity === 'error'\n result.canProceed = result.canProceed && !blocking\n result.impact.push({\n key: item.key,\n kind: item.kind,\n type: 'publish',\n impact: item.message,\n resolution: item.help,\n severity: item.severity,\n parent: item.parent,\n })\n }\n for (const property of entity.properties) {\n const report = propertyValidator.validate(property)\n for (const item of report) {\n const blocking = item.severity === 'error'\n result.canProceed = result.canProceed && !blocking\n result.impact.push({\n key: item.key,\n kind: item.kind,\n type: 'publish',\n impact: item.message,\n resolution: item.help,\n severity: item.severity,\n parent: item.parent,\n })\n }\n }\n for (const association of entity.associations) {\n const report = associationValidator.validate(association)\n for (const item of report) {\n const blocking = item.severity === 'error'\n result.canProceed = result.canProceed && !blocking\n result.impact.push({\n key: item.key,\n kind: item.kind,\n type: 'publish',\n impact: item.message,\n resolution: item.help,\n severity: item.severity,\n parent: item.parent,\n })\n }\n }\n }\n if (!hasEntities) {\n // no entities, no need to validate anything else\n return result\n }\n // Validate semantics\n const semanticReport = semanticValidator.validate()\n for (const item of semanticReport) {\n const blocking = item.severity === 'error'\n result.canProceed = result.canProceed && !blocking\n result.impact.push({\n key: item.key,\n kind: item.kind,\n type: 'publish',\n impact: item.message,\n resolution: item.help,\n severity: item.severity,\n parent: item.parent,\n })\n }\n\n return result\n }\n}\n"]}
@@ -14,15 +14,29 @@ export declare class EntityValidation {
14
14
  /**
15
15
  * Performs all the validation rules on the entity.
16
16
  * If you are interested in a specific rule, use the specific method.
17
- * @param target The target entity to validate. Can be a string with the entity key or a DomainEntity object.
17
+ * @param target The target entity to validate. Can be a string with
18
+ * the entity key or a DomainEntity object.
18
19
  */
19
20
  validate(target: string | DomainEntity): DomainValidation[];
20
21
  /**
21
- * Validates the entity against the primary key validation rules.
22
+ * Validates the entity primary key.
22
23
  * @param entity The entity to validate
23
- * @returns The list of validation messages.
24
24
  */
25
25
  validatePrimaryKey(entity: DomainEntity): DomainValidation[];
26
+ /**
27
+ * Checks if an entity has properties through its entire inheritance chain.
28
+ * This includes direct properties and properties inherited from any level of parent entities.
29
+ * @param entity The entity to check
30
+ * @returns True if the entity has properties either directly or through inheritance
31
+ */
32
+ private hasPropertiesInherited;
33
+ /**
34
+ * Checks if an entity has associations through its entire inheritance chain.
35
+ * This includes direct associations and associations inherited from any level of parent entities.
36
+ * @param entity The entity to check
37
+ * @returns True if the entity has associations either directly or through inheritance
38
+ */
39
+ private hasAssociationsInherited;
26
40
  /**
27
41
  * Checks if the entity has the minimum required properties.
28
42
  * @param entity The entity to validate
@@ -1 +1 @@
1
- {"version":3,"file":"entity_validation.d.ts","sourceRoot":"","sources":["../../../../src/modeling/validation/entity_validation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAElD;;;;;;GAMG;AACH,qBAAa,gBAAgB;IACf,SAAS,CAAC,MAAM,EAAE,UAAU;gBAAlB,MAAM,EAAE,UAAU;IAExC;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,gBAAgB,EAAE;IAiC3D;;;;OAIG;IACH,kBAAkB,CAAC,MAAM,EAAE,YAAY,GAAG,gBAAgB,EAAE;IAmB5D;;;OAGG;IACH,yBAAyB,CAAC,MAAM,EAAE,YAAY,GAAG,gBAAgB,EAAE;IAkBnE;;;;;;;;;;;;;OAaG;IACH,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,gBAAgB,EAAE;IAuFtD;;;OAGG;IACH,UAAU,CAAC,MAAM,EAAE,YAAY,GAAG,gBAAgB,EAAE;CAwCrD"}
1
+ {"version":3,"file":"entity_validation.d.ts","sourceRoot":"","sources":["../../../../src/modeling/validation/entity_validation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAElD;;;;;;GAMG;AACH,qBAAa,gBAAgB;IACf,SAAS,CAAC,MAAM,EAAE,UAAU;gBAAlB,MAAM,EAAE,UAAU;IAExC;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,gBAAgB,EAAE;IAiC3D;;;OAGG;IACH,kBAAkB,CAAC,MAAM,EAAE,YAAY,GAAG,gBAAgB,EAAE;IAmB5D;;;;;OAKG;IACH,OAAO,CAAC,sBAAsB;IAgB9B;;;;;OAKG;IACH,OAAO,CAAC,wBAAwB;IAgBhC;;;OAGG;IACH,yBAAyB,CAAC,MAAM,EAAE,YAAY,GAAG,gBAAgB,EAAE;IAuBnE;;;;;;;;;;;;;OAaG;IACH,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,gBAAgB,EAAE;IAuFtD;;;OAGG;IACH,UAAU,CAAC,MAAM,EAAE,YAAY,GAAG,gBAAgB,EAAE;CAwCrD"}
@@ -15,7 +15,8 @@ export class EntityValidation {
15
15
  /**
16
16
  * Performs all the validation rules on the entity.
17
17
  * If you are interested in a specific rule, use the specific method.
18
- * @param target The target entity to validate. Can be a string with the entity key or a DomainEntity object.
18
+ * @param target The target entity to validate. Can be a string with
19
+ * the entity key or a DomainEntity object.
19
20
  */
20
21
  validate(target) {
21
22
  const results = [];
@@ -40,20 +41,19 @@ export class EntityValidation {
40
41
  });
41
42
  return results;
42
43
  }
43
- const primary = this.validatePrimaryKey(entity);
44
- results.push(...primary);
45
- const minimum = this.minimumRequiredProperties(entity);
46
- results.push(...minimum);
44
+ const primaryKey = this.validatePrimaryKey(entity);
45
+ results.push(...primaryKey);
46
+ const minimumProperties = this.minimumRequiredProperties(entity);
47
+ results.push(...minimumProperties);
47
48
  const name = this.validateName(entity);
48
49
  results.push(...name);
49
- const uniqueName = this.uniqueName(entity);
50
- results.push(...uniqueName);
50
+ const unique = this.uniqueName(entity);
51
+ results.push(...unique);
51
52
  return results;
52
53
  }
53
54
  /**
54
- * Validates the entity against the primary key validation rules.
55
+ * Validates the entity primary key.
55
56
  * @param entity The entity to validate
56
- * @returns The list of validation messages.
57
57
  */
58
58
  validatePrimaryKey(entity) {
59
59
  const results = [];
@@ -73,13 +73,54 @@ export class EntityValidation {
73
73
  }
74
74
  return results;
75
75
  }
76
+ /**
77
+ * Checks if an entity has properties through its entire inheritance chain.
78
+ * This includes direct properties and properties inherited from any level of parent entities.
79
+ * @param entity The entity to check
80
+ * @returns True if the entity has properties either directly or through inheritance
81
+ */
82
+ hasPropertiesInherited(entity) {
83
+ // Check direct properties first
84
+ if (entity.hasProperties()) {
85
+ return true;
86
+ }
87
+ // Check all parents recursively
88
+ for (const parent of entity.listParents()) {
89
+ if (this.hasPropertiesInherited(parent)) {
90
+ return true;
91
+ }
92
+ }
93
+ return false;
94
+ }
95
+ /**
96
+ * Checks if an entity has associations through its entire inheritance chain.
97
+ * This includes direct associations and associations inherited from any level of parent entities.
98
+ * @param entity The entity to check
99
+ * @returns True if the entity has associations either directly or through inheritance
100
+ */
101
+ hasAssociationsInherited(entity) {
102
+ // Check direct associations first
103
+ if (entity.hasAssociations()) {
104
+ return true;
105
+ }
106
+ // Check all parents recursively
107
+ for (const parent of entity.listParents()) {
108
+ if (this.hasAssociationsInherited(parent)) {
109
+ return true;
110
+ }
111
+ }
112
+ return false;
113
+ }
76
114
  /**
77
115
  * Checks if the entity has the minimum required properties.
78
116
  * @param entity The entity to validate
79
117
  */
80
118
  minimumRequiredProperties(entity) {
81
119
  const results = [];
82
- if (!entity.hasProperties() && !entity.hasAssociations()) {
120
+ // Check if entity has properties or associations through entire inheritance chain
121
+ const hasProperties = this.hasPropertiesInherited(entity);
122
+ const hasAssociations = this.hasAssociationsInherited(entity);
123
+ if (!hasProperties && !hasAssociations) {
83
124
  const message = `The "${entity.info.getLabel()}" entity has no properties. It will be ignored.`;
84
125
  const help = `Entities that have no properties are ignored in the data domain. No schema will be generated for it.`;
85
126
  results.push({
@@ -1 +1 @@
1
- {"version":3,"file":"entity_validation.js","sourceRoot":"","sources":["../../../../src/modeling/validation/entity_validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAGxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAGlD;;;;;;GAMG;AACH,MAAM,OAAO,gBAAgB;IACL;IAAtB,YAAsB,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;IAAG,CAAC;IAE5C;;;;OAIG;IACH,QAAQ,CAAC,MAA6B;QACpC,MAAM,OAAO,GAAuB,EAAE,CAAA;QACtC,IAAI,MAAgC,CAAA;QACpC,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC/B,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;QACzC,CAAC;aAAM,CAAC;YACN,MAAM,GAAG,MAAM,CAAA;QACjB,CAAC;QACD,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,OAAO,GAAG,QAAQ,MAAM,0BAA0B,CAAA;YACxD,MAAM,IAAI,GAAG,2CAA2C,CAAA;YACxD,OAAO,CAAC,IAAI,CAAC;gBACX,KAAK,EAAE,GAAG;gBACV,IAAI,EAAE,QAAQ;gBACd,OAAO;gBACP,IAAI;gBACJ,GAAG,EAAE,MAAgB;gBACrB,IAAI,EAAE,gBAAgB;gBACtB,QAAQ,EAAE,OAAO;aAClB,CAAC,CAAA;YACF,OAAO,OAAO,CAAA;QAChB,CAAC;QACD,MAAM,OAAO,GAAG,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAA;QAC/C,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAA;QACxB,MAAM,OAAO,GAAG,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAA;QACtD,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAA;QACxB,MAAM,IAAI,G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KAAK,CAAC,GAAG,KAAK,MAAM,CAAC,GAAG,EAAE,CAAC;gBACxE,MAAM,OAAO,GAAG,QAAQ,IAAI,2DAA2D,CAAA;gBACvF,MAAM,IAAI,GAAG,0EAA0E,CAAA;gBACvF,OAAO,CAAC,IAAI,CAAC;oBACX,KAAK,EAAE,MAAM;oBACb,IAAI,EAAE,QAAQ;oBACd,OAAO;oBACP,IAAI;oBACJ,QAAQ,EAAE,OAAO;oBACjB,GAAG,EAAE,KAAK,CAAC,GAAG;oBACd,IAAI,EAAE,KAAK,CAAC,IAAI;oBAChB,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG;iBACzB,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;CACF","sourcesContent":["import { DomainEntityKind } from '../../models/kinds.js'\nimport type { DataDomain } from '../DataDomain.js'\nimport type { DomainEntity } from '../DomainEntity.js'\nimport { ReservedKeywords } from './postgresql.js'\nimport type { DomainValidation } from './rules.js'\n\n/**\n * EntityValidation is a class that performs validation on entities in a data domain.\n *\n * @remarks\n * - We do not need to check for parent uniqueness here, because in the graph there can only be one edge\n * between two nodes. Parent relationships are described by an edge in the graph.\n */\nexport class EntityValidation {\n constructor(protected domain: DataDomain) {}\n\n /**\n * Performs all the validation rules on the entity.\n * If you are interested in a specific rule, use the specific method.\n * @param target The target entity to validate. Can be a string with the entity key or a DomainEntity object.\n */\n validate(target: string | DomainEntity): DomainValidation[] {\n const results: DomainValidation[] = []\n let entity: DomainEntity | undefined\n if (typeof target === 'string') {\n entity = this.domain.findEntity(target)\n } else {\n entity = target\n }\n if (!entity) {\n const message = `The \"${target}\" entity does not exist.`\n const help = `The entity must be defined in the domain.`\n results.push({\n field: '*',\n rule: 'exists',\n message,\n help,\n key: target as string,\n kind: DomainEntityKind,\n severity: 'error',\n })\n return results\n }\n const primary = this.validatePrimaryKey(entity)\n results.push(...primary)\n const minimum = this.minimumRequiredProperties(entity)\n results.push(...minimum)\n const name = this.validateName(entity)\n results.push(...name)\n const uniqueName = this.uniqueName(entity)\n results.push(...uniqueName)\n return results\n }\n\n /**\n * Validates the entity against the primary key validation rules.\n * @param entity The entity to validate\n * @returns The list of validation messages.\n */\n validatePrimaryKey(entity: DomainEntity): DomainValidation[] {\n const results: DomainValidation[] = []\n const primary = entity.primaryKey()\n if (!primary) {\n const message = `The \"${entity.info.getLabel()}\" entity has no identifier.`\n const help = `An entity that can exists by itself must have identifier defined.`\n results.push({\n field: 'properties',\n rule: 'primary_key',\n message,\n help,\n severity: 'error',\n key: entity.key,\n kind: entity.kind,\n })\n }\n return results\n }\n\n /**\n * Checks if the entity has the minimum required properties.\n * @param entity The entity to validate\n */\n minimumRequiredProperties(entity: DomainEntity): DomainValidation[] {\n const results: DomainValidation[] = []\n if (!entity.hasProperties() && !entity.hasAssociations()) {\n const message = `The \"${entity.info.getLabel()}\" entity has no properties. It will be ignored.`\n const help = `Entities that have no properties are ignored in the data domain. No schema will be generated for it.`\n results.push({\n field: 'properties',\n rule: 'required',\n message,\n help,\n severity: 'warning',\n key: entity.key,\n kind: entity.kind,\n })\n }\n return results\n }\n\n /**\n * Validates the entity name.\n *\n * @remarks\n * - An entity must have a name defined.\n * - The name has to follow the same rules as the names in a PostgreSQL database.\n * - Table names must start with a letter (a-z) or underscore (_).\n * - Subsequent characters can be letters, digits (0-9), or underscores (_).\n * - Names are case-insensitive.\n * - The maximum length of a table name is 31 characters\n * - Should be snake case (it's a convention, not an error).\n * - Should not be a reserved word (for example: \"IN\", \"SELECT\", \"FROM\", etc.).\n * @param entity The entity to validate\n */\n validateName(entity: DomainEntity): DomainValidation[] {\n const results: DomainValidation[] = []\n const label = entity.info.getLabel()\n if (!entity.info.name) {\n const message = `The \"${label}\" entity has no name.`\n const help = `An entity must have a name.`\n results.push({\n field: 'name',\n rule: 'required',\n message,\n help,\n severity: 'error',\n key: entity.key,\n kind: entity.kind,\n })\n return results\n }\n\n const name = entity.info.name\n if (name.length < 2) {\n const message = `The \"${label}\" entity name is too short.`\n const help = `The name must be at least 2 characters long.`\n results.push({\n field: 'name',\n rule: 'length',\n message,\n help,\n severity: 'error',\n key: entity.key,\n kind: entity.kind,\n })\n }\n if (name.length > 31) {\n const message = `The \"${label}\" entity name is too long.`\n const help = `The name must be at most 31 characters long.`\n results.push({\n field: 'name',\n rule: 'length',\n message,\n help,\n severity: 'error',\n key: entity.key,\n kind: entity.kind,\n })\n }\n if (!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(name)) {\n const message = `The \"${label}\" entity name is invalid.`\n const help = `The name must start with a letter (a-z) or underscore (_). Subsequent characters can be letters, digits (0-9), or underscores (_).`\n results.push({\n field: 'name',\n rule: 'format',\n message,\n help,\n severity: 'error',\n key: entity.key,\n kind: entity.kind,\n })\n }\n if (/^[A-Z]/.test(name)) {\n const message = `The \"${label}\" entity name is not in snake case.`\n const help = `The name should be in snake case (lowercase letters and underscores).`\n results.push({\n field: 'name',\n rule: 'snake_case',\n message,\n help,\n severity: 'info',\n key: entity.key,\n kind: entity.kind,\n })\n }\n if (ReservedKeywords.has(name.toUpperCase())) {\n const message = `The \"${label}\" entity name is a reserved keyword.`\n const help = `The name should not be a reserved keyword.`\n results.push({\n field: 'name',\n rule: 'reserved',\n message,\n help,\n severity: 'error',\n key: entity.key,\n kind: entity.kind,\n })\n }\n return results\n }\n\n /**\n * Checks if the entity name is unique in the data domain.\n * @param entity The entity to validate\n */\n uniqueName(entity: DomainEntity): DomainValidation[] {\n const results: DomainValidation[] = []\n const name = entity.info.name?.toLowerCase()\n if (!name) {\n return results\n }\n // We need to check the unique names in all entities, including foreign ones.\n for (const other of this.domain.listEntities()) {\n if (other.info.name?.toLowerCase() === name && other.key !== entity.key) {\n const message = `The \"${name}\" entity name is already used in the data domain.`\n const help = `The name must be unique. This includes references to other data domains.`\n results.push({\n field: 'name',\n rule: 'unique',\n message,\n help,\n severity: 'error',\n key: other.key,\n kind: other.kind,\n })\n }\n }\n for (const other of this.domain.listAllForeignEntities()) {\n if (other.info.name?.toLowerCase() === name && other.key !== entity.key) {\n const message = `The \"${name}\" entity name is already used in the foreign data domain.`\n const help = `The name must be unique. This includes references to other data domains.`\n results.push({\n field: 'name',\n rule: 'unique',\n message,\n help,\n severity: 'error',\n key: other.key,\n kind: other.kind,\n parent: other.domain.key,\n })\n }\n }\n return results\n }\n}\n"]}
1
+ {"version":3,"file":"entity_validation.js","sourceRoot":"","sources":["../../../../src/modeling/validation/entity_validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAGxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAGlD;;;;;;GAMG;AACH,MAAM,OAAO,gBAAgB;IACL;IAAtB,YAAsB,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;IAAG,CAAC;IAE5C;;;;;OAKG;IACH,QAAQ,CAAC,MAA6B;QACpC,MAAM,OAAO,GAAuB,EAAE,CAAA;QACtC,IAAI,MAAgC,CAAA;QACpC,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC/B,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;QACzC,CAAC;aAAM,CAAC;YACN,MAAM,GAAG,MAAM,CAAA;QACjB,CAAC;QACD,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,OAAO,GAAG,QAAQ,MAAM,0BAA0B,CAAA;YACxD,MAAM,IAAI,GAAG,2CAA2C,CAAA;YACxD,OAAO,CAAC,IAAI,CAAC;gBACX,KAAK,EAAE,GAAG;gBACV,IAAI,EAAE,QAAQ;gBACd,OAAO;gBACP,IAAI;gBACJ,GAAG,EAAE,MAAgB;gBACrB,IAAI,EAAE,gBAAgB;gBACtB,QAAQ,EAAE,OAAO;aAClB,CAAC,CAAA;YACF,OAAO,OAAO,CAAA;QAChB,CAAC;QACD,MAAM,UAAU,GAAG,IAAI,CAAC,kBAAkB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CAAC,IAAI,CAAC;oBACX,KAAK,EAAE,MAAM;oBACb,IAAI,EAAE,QAAQ;oBACd,OAAO;oBACP,IAAI;oBACJ,QAAQ,EAAE,OAAO;oBACjB,GAAG,EAAE,KAAK,CAAC,GAAG;oBACd,IAAI,EAAE,KAAK,CAAC,IAAI;oBAChB,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG;iBACzB,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;CACF","sourcesContent":["import { DomainEntityKind } from '../../models/kinds.js'\nimport type { DataDomain } from '../DataDomain.js'\nimport type { DomainEntity } from '../DomainEntity.js'\nimport { ReservedKeywords } from './postgresql.js'\nimport type { DomainValidation } from './rules.js'\n\n/**\n * EntityValidation is a class that performs validation on entities in a data domain.\n *\n * @remarks\n * - We do not need to check for parent uniqueness here, because in the graph there can only be one edge\n * between two nodes. Parent relationships are described by an edge in the graph.\n */\nexport class EntityValidation {\n constructor(protected domain: DataDomain) {}\n\n /**\n * Performs all the validation rules on the entity.\n * If you are interested in a specific rule, use the specific method.\n * @param target The target entity to validate. Can be a string with\n * the entity key or a DomainEntity object.\n */\n validate(target: string | DomainEntity): DomainValidation[] {\n const results: DomainValidation[] = []\n let entity: DomainEntity | undefined\n if (typeof target === 'string') {\n entity = this.domain.findEntity(target)\n } else {\n entity = target\n }\n if (!entity) {\n const message = `The \"${target}\" entity does not exist.`\n const help = `The entity must be defined in the domain.`\n results.push({\n field: '*',\n rule: 'exists',\n message,\n help,\n key: target as string,\n kind: DomainEntityKind,\n severity: 'error',\n })\n return results\n }\n const primaryKey = this.validatePrimaryKey(entity)\n results.push(...primaryKey)\n const minimumProperties = this.minimumRequiredProperties(entity)\n results.push(...minimumProperties)\n const name = this.validateName(entity)\n results.push(...name)\n const unique = this.uniqueName(entity)\n results.push(...unique)\n return results\n }\n\n /**\n * Validates the entity primary key.\n * @param entity The entity to validate\n */\n validatePrimaryKey(entity: DomainEntity): DomainValidation[] {\n const results: DomainValidation[] = []\n const primary = entity.primaryKey()\n if (!primary) {\n const message = `The \"${entity.info.getLabel()}\" entity has no identifier.`\n const help = `An entity that can exists by itself must have identifier defined.`\n results.push({\n field: 'properties',\n rule: 'primary_key',\n message,\n help,\n severity: 'error',\n key: entity.key,\n kind: entity.kind,\n })\n }\n return results\n }\n\n /**\n * Checks if an entity has properties through its entire inheritance chain.\n * This includes direct properties and properties inherited from any level of parent entities.\n * @param entity The entity to check\n * @returns True if the entity has properties either directly or through inheritance\n */\n private hasPropertiesInherited(entity: DomainEntity): boolean {\n // Check direct properties first\n if (entity.hasProperties()) {\n return true\n }\n\n // Check all parents recursively\n for (const parent of entity.listParents()) {\n if (this.hasPropertiesInherited(parent)) {\n return true\n }\n }\n\n return false\n }\n\n /**\n * Checks if an entity has associations through its entire inheritance chain.\n * This includes direct associations and associations inherited from any level of parent entities.\n * @param entity The entity to check\n * @returns True if the entity has associations either directly or through inheritance\n */\n private hasAssociationsInherited(entity: DomainEntity): boolean {\n // Check direct associations first\n if (entity.hasAssociations()) {\n return true\n }\n\n // Check all parents recursively\n for (const parent of entity.listParents()) {\n if (this.hasAssociationsInherited(parent)) {\n return true\n }\n }\n\n return false\n }\n\n /**\n * Checks if the entity has the minimum required properties.\n * @param entity The entity to validate\n */\n minimumRequiredProperties(entity: DomainEntity): DomainValidation[] {\n const results: DomainValidation[] = []\n\n // Check if entity has properties or associations through entire inheritance chain\n const hasProperties = this.hasPropertiesInherited(entity)\n const hasAssociations = this.hasAssociationsInherited(entity)\n\n if (!hasProperties && !hasAssociations) {\n const message = `The \"${entity.info.getLabel()}\" entity has no properties. It will be ignored.`\n const help = `Entities that have no properties are ignored in the data domain. No schema will be generated for it.`\n results.push({\n field: 'properties',\n rule: 'required',\n message,\n help,\n severity: 'warning',\n key: entity.key,\n kind: entity.kind,\n })\n }\n return results\n }\n\n /**\n * Validates the entity name.\n *\n * @remarks\n * - An entity must have a name defined.\n * - The name has to follow the same rules as the names in a PostgreSQL database.\n * - Table names must start with a letter (a-z) or underscore (_).\n * - Subsequent characters can be letters, digits (0-9), or underscores (_).\n * - Names are case-insensitive.\n * - The maximum length of a table name is 31 characters\n * - Should be snake case (it's a convention, not an error).\n * - Should not be a reserved word (for example: \"IN\", \"SELECT\", \"FROM\", etc.).\n * @param entity The entity to validate\n */\n validateName(entity: DomainEntity): DomainValidation[] {\n const results: DomainValidation[] = []\n const label = entity.info.getLabel()\n if (!entity.info.name) {\n const message = `The \"${label}\" entity has no name.`\n const help = `An entity must have a name.`\n results.push({\n field: 'name',\n rule: 'required',\n message,\n help,\n severity: 'error',\n key: entity.key,\n kind: entity.kind,\n })\n return results\n }\n\n const name = entity.info.name\n if (name.length < 2) {\n const message = `The \"${label}\" entity name is too short.`\n const help = `The name must be at least 2 characters long.`\n results.push({\n field: 'name',\n rule: 'length',\n message,\n help,\n severity: 'error',\n key: entity.key,\n kind: entity.kind,\n })\n }\n if (name.length > 31) {\n const message = `The \"${label}\" entity name is too long.`\n const help = `The name must be at most 31 characters long.`\n results.push({\n field: 'name',\n rule: 'length',\n message,\n help,\n severity: 'error',\n key: entity.key,\n kind: entity.kind,\n })\n }\n if (!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(name)) {\n const message = `The \"${label}\" entity name is invalid.`\n const help = `The name must start with a letter (a-z) or underscore (_). Subsequent characters can be letters, digits (0-9), or underscores (_).`\n results.push({\n field: 'name',\n rule: 'format',\n message,\n help,\n severity: 'error',\n key: entity.key,\n kind: entity.kind,\n })\n }\n if (/^[A-Z]/.test(name)) {\n const message = `The \"${label}\" entity name is not in snake case.`\n const help = `The name should be in snake case (lowercase letters and underscores).`\n results.push({\n field: 'name',\n rule: 'snake_case',\n message,\n help,\n severity: 'info',\n key: entity.key,\n kind: entity.kind,\n })\n }\n if (ReservedKeywords.has(name.toUpperCase())) {\n const message = `The \"${label}\" entity name is a reserved keyword.`\n const help = `The name should not be a reserved keyword.`\n results.push({\n field: 'name',\n rule: 'reserved',\n message,\n help,\n severity: 'error',\n key: entity.key,\n kind: entity.kind,\n })\n }\n return results\n }\n\n /**\n * Checks if the entity name is unique in the data domain.\n * @param entity The entity to validate\n */\n uniqueName(entity: DomainEntity): DomainValidation[] {\n const results: DomainValidation[] = []\n const name = entity.info.name?.toLowerCase()\n if (!name) {\n return results\n }\n // We need to check the unique names in all entities, including foreign ones.\n for (const other of this.domain.listEntities()) {\n if (other.info.name?.toLowerCase() === name && other.key !== entity.key) {\n const message = `The \"${name}\" entity name is already used in the data domain.`\n const help = `The name must be unique. This includes references to other data domains.`\n results.push({\n field: 'name',\n rule: 'unique',\n message,\n help,\n severity: 'error',\n key: other.key,\n kind: other.kind,\n })\n }\n }\n for (const other of this.domain.listAllForeignEntities()) {\n if (other.info.name?.toLowerCase() === name && other.key !== entity.key) {\n const message = `The \"${name}\" entity name is already used in the foreign data domain.`\n const help = `The name must be unique. This includes references to other data domains.`\n results.push({\n field: 'name',\n rule: 'unique',\n message,\n help,\n severity: 'error',\n key: other.key,\n kind: other.kind,\n parent: other.domain.key,\n })\n }\n }\n return results\n }\n}\n"]}
@@ -26,7 +26,7 @@ export interface ICertificateData {
26
26
  export interface ICertificate {
27
27
  kind: typeof Kind;
28
28
  /**
29
- * The data store key to refer.
29
+ * The data store key to refer under which this certificate is stored.
30
30
  */
31
31
  key: string;
32
32
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"ClientCertificate.js","sourceRoot":"","sources":["../../../src/models/ClientCertificate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AASrC,MAAM,CAAC,MAAM,IAAI,GAAG,kBAAkB,CAAA;AAoHtC;;GAEG;AACH,MAAM,OAAO,WAAW;IACtB,IAAI,GAAG,IAAI,CAAA;IACX;;OAEG;IACH,GAAG,CAAQ;IACX;;OAEG;IACH,IAAI,CAAQ;IACZ;;;OAGG;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AK,CAAC,8BAA8B,CAAC,CAAA;QACjD,CAAC;QACD,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAClC,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAA;YACpB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAgC,CAAA;YAClD,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC,IAAI,CAAC,CAAA;QAClC,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAED,MAAM;QACJ,MAAM,MAAM,GAAoB;YAC9B,IAAI,EAAE,IAAI;YACV,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,IAAI,EAAE,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;YACpC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAA;QAED,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACxC,MAAM,KAAK,GAAG,MAAoC,CAAA;YAClD,KAAK,CAAC,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QACnD,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC;CACF","sourcesContent":["import { base64ToBuffer, bufferToBase64 } from '../lib/Buffer.js'\nimport { nanoid } from '../nanoid.js'\nimport {\n Certificate as LegacyCertificate,\n ARCCertificateIndex,\n RequestCertificate,\n} from './legacy/models/ClientCertificate.js'\n\nexport type CertificateType = 'p12' | 'pem'\n\nexport const Kind = 'Core#Certificate'\n\nexport type CertificateDataFormat = string | ArrayBuffer | Uint8Array\n\n/**\n * Represents a single certificate object (cert/key)\n */\nexport interface ICertificateData {\n /**\n * The certificate to use.\n * The `p12` type certificate must be a Buffer.\n */\n data: CertificateDataFormat\n /**\n * A passphrase to use to unlock the certificate.\n */\n passphrase?: string\n /**\n * The original data type of the certificate. This is only used internally by the data store\n * to move between buffers and string values stored in the store.\n * Outside the internal procedure of the data store this\n * is always `undefined` and the `data` contains the original data format.\n */\n type?: 'buffer'\n}\n\nexport interface ICertificate {\n kind: typeof Kind\n /**\n * The data store key to refer.\n */\n key: string\n /**\n * The custom name of the certificate.\n */\n name: string\n /**\n * The timestamp when the certificate was inserted into the data store.\n * Required when returning a result. Auto-generated when inserting, if missing.\n */\n created?: number\n /**\n * Certificate type. Either `p12` or `pem`.\n */\n type: CertificateType\n /**\n * Certificate or list of certificates to use.\n */\n cert: ICertificateData\n}\n\nexport interface IP12Certificate extends ICertificate {\n type: 'p12'\n}\n\n/**\n * Represents a complete certificate configuration required to make\n * an HTTP request.\n */\nexport interface IPemCertificate extends ICertificate {\n type: 'pem'\n /**\n * The key for the `pem` type certificate.\n */\n certKey: ICertificateData\n}\n\nexport type HttpCertificate = IP12Certificate | IPemCertificate | ICertificate\n\n/**\n * @deprecated Do not use this type anymore. Create a cert instance instead.\n */\nexport interface IPemCreateOptions {\n type: 'p12'\n /**\n * The certificate contents.\n */\n cert: CertificateDataFormat\n /**\n * The key contents.\n */\n key: CertificateDataFormat\n /**\n * Optional name for the certificate.\n */\n name?: string\n /**\n * Optional passphrase for the key.\n */\n passphrase?: string\n}\n\n/**\n * @deprecated Do not use this type anymore. Create a cert instance instead.\n */\nexport interface IP12CreateOptions {\n type: 'pem'\n /**\n * The certificate contents.\n */\n cert: CertificateDataFormat\n /**\n * Optional name for the certificate.\n */\n name?: string\n /**\n * Optional passphrase for the certificate.\n */\n passphrase?: string\n}\n\n/**\n * @deprecated Do not use this type anymore. Create a cert instance instead.\n */\nexport type ICertificateCreateOptions = IPemCreateOptions | IP12CreateOptions\n\n/**\n * A class that represents a certificate in the system\n */\nexport class Certificate {\n kind = Kind\n /**\n * The data store key to refer.\n */\n key: string\n /**\n * Custom name of the certificate.\n */\n name: string\n /**\n * Timestamp when the certificate was inserted into the data store.\n * Required when returning a result. Auto-generated when inserting, if missing.\n */\n created = 0\n /**\n * Certificate type. Either `p12` or `pem`.\n */\n type: CertificateType\n /**\n * Certificate or list of certificates to use.\n */\n cert: ICertificateData\n /**\n * The key for the `pem` type certificate.\n */\n certKey?: ICertificateData\n\n /**\n * Creates a new certificate instance for a PEM key\n *\n * @param pem The certificate contents\n * @param key The key contents\n * @param name The certificate name\n * @param keyPassphrase The key passphrase\n */\n static fromPem(\n pem: CertificateDataFormat,\n key: CertificateDataFormat,\n name = 'New PEM certificate',\n keyPassphrase?: string\n ): Certificate {\n const init: IPemCertificate = {\n kind: Kind,\n cert: {\n data: pem,\n },\n certKey: {\n data: key,\n },\n key: nanoid(),\n name,\n type: 'pem',\n created: Date.now(),\n }\n if (keyPassphrase) {\n init.certKey.passphrase = keyPassphrase\n }\n return new Certificate(init)\n }\n\n /**\n * Creates a new certificate instance for a P12 key\n *\n * @param cert The certificate contents\n * @param name The certificate name\n * @param passphrase The key passphrase\n */\n static fromP12(cert: CertificateDataFormat, name = 'New P12 certificate', passphrase?: string): Certificate {\n const init: IP12Certificate = {\n kind: Kind,\n cert: {\n data: cert,\n },\n key: nanoid(),\n name,\n type: 'p12',\n created: Date.now(),\n }\n if (passphrase) {\n init.cert.passphrase = passphrase\n }\n return new Certificate(init)\n }\n\n /**\n * Creates a certificate object from the ARC's legacy certificate definition.\n *\n * @param index The legacy certificate index object. If it has set `_id` it will be used as the `key`.\n * @param index The certificate data object as read from the data store. Do not restore the data\n * to its original format.\n */\n static fromLegacy(index: ARCCertificateIndex, cert: RequestCertificate): Certificate {\n const { name = '', type, created = Date.now(), _id = nanoid() } = index\n if (type === 'pem') {\n const data = Array.isArray(cert.cert) ? cert.cert[0] : cert.cert\n const key = Array.isArray(cert.key) ? cert.key[0] : (cert.key as LegacyCertificate)\n if (!key) {\n throw new Error(`Unable to create a PEM certificate without the key.`)\n }\n const init: IPemCertificate = {\n kind: Kind,\n cert: data as ICertificateData, // these are compatible.\n certKey: key as ICertificateData,\n key: _id,\n name,\n type: 'pem',\n created,\n }\n return new Certificate(init)\n } else if (type === 'p12') {\n const data = Array.isArray(cert.cert) ? cert.cert[0] : cert.cert\n const init: IP12Certificate = {\n kind: Kind,\n cert: data as ICertificateData, // these are compatible.\n key: _id,\n name,\n type: 'p12',\n created,\n }\n return new Certificate(init)\n }\n throw new Error(`Unable to create a certificate. Unknown type: ${type}.`)\n }\n\n constructor(certificate: HttpCertificate) {\n const { type, cert, key = nanoid(), name = '', created = Date.now() } = certificate\n this.key = key\n this.name = name\n this.type = type\n this.cert = Certificate.fromStore(cert)\n this.created = created\n if (type === 'pem') {\n const typed = certificate as IPemCertificate\n this.certKey = Certificate.fromStore(typed.certKey)\n }\n }\n\n /**\n * When needed it reads the certificate's original format.\n * @param data The certificate data.\n * @returns The restored certificate.\n */\n static fromStore(data: ICertificateData): ICertificateData {\n if (data.type) {\n delete data.type\n const content = data.data as string\n data.data = base64ToBuffer(content)\n }\n return data\n }\n\n /**\n * Prepares certificate object to be stored in the data store.\n * If the `data` property is not string then it assumes buffer (either\n * Node's or ArrayBuffer). In this case it converts buffer to base64 string.\n * It also adds `type` property set to `buffer` for the `fromStore()`\n * function to recognize what to do with the data.\n *\n * Note, for optimization, PEM keys should be strings as the content of the\n * certificate is already a base62 string. To spare double base64 conversion\n * use string data.\n *\n * @param data The certificate data object.\n * @throws When data is not set\n */\n static toStore(data: ICertificateData): ICertificateData {\n if (!data) {\n throw new Error('Certificate data is missing.')\n }\n if (!data.data) {\n throw new Error('Certificate content not set.')\n }\n if (typeof data.data !== 'string') {\n data.type = 'buffer'\n const buff = data.data as ArrayBuffer | Uint8Array\n data.data = bufferToBase64(buff)\n }\n return data\n }\n\n toJSON(): HttpCertificate {\n const result: HttpCertificate = {\n kind: Kind,\n key: this.key,\n cert: Certificate.toStore(this.cert),\n name: this.name,\n type: this.type,\n created: this.created,\n }\n\n if (this.type === 'pem' && this.certKey) {\n const typed = result as unknown as IPemCertificate\n typed.certKey = Certificate.toStore(this.certKey)\n }\n\n return result\n }\n}\n"]}
1
+ {"version":3,"file":"ClientCertificate.js","sourceRoot":"","sources":["../../../src/models/ClientCertificate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AASrC,MAAM,CAAC,MAAM,IAAI,GAAG,kBAAkB,CAAA;AAoHtC;;GAEG;AACH,MAAM,OAAO,WAAW;IACtB,IAAI,GAAG,IAAI,CAAA;IACX;;OAEG;IACH,GAAG,CAAQ;IACX;;OAEG;IACH,IAAI,CAAQ;IACZ;;;OAGG;IACH,OAAO,GAAG,CAAC,CAAA;IACX;;OAEG;IACH,IAAI,CAAiB;IACrB;;OAEG;IACH,IAAI,CAAkB;IACtB;;OAEG;IACH,OAAO,CAAmB;IAE1B;;;;;;;OAOG;IACH,MAAM,CAAC,OAAO,CACZ,GAA0B,EAC1B,GAA0B,EAC1B,IAAI,GAAG,qBAAqB,EAC5B,aAAsB;QAEtB,MAAM,IAAI,GAAoB;YAC5B,IAAI,EAAE,IAAI;YACV,IAAI,EAAE;gBACJ,IAAI,EAAE,GAAG;aACV;YACD,OAAO,EAAE;gBACP,IAAI,EAAE,GAAG;aACV;YACD,GAAG,EAAE,MAAM,EAAE;YACb,IAAI;YACJ,IAAI,EAAE,KAAK;YACX,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE;SACpB,CAAA;QACD,IAAI,aAAa,EAAE,CAAC;YAClB,IAAI,CAAC,OAAO,CAAC,UAAU,GAAG,aAAa,CAAA;QACzC,CAAC;QACD,OAAO,IAAI,WAAW,CAAC,IAAI,CAAC,CAAA;IAC9B,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,OAAO,CAAC,IAA2B,EAAE,IAAI,GAAG,qBAAqB,EAAE,UAAmB;QAC3F,MAAM,IAAI,GAAoB;YAC5B,IAAI,EAAE,IAAI;YACV,IAAI,EAAE;gBACJ,IAAI,EAAE,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cesContent":["import { base64ToBuffer, bufferToBase64 } from '../lib/Buffer.js'\nimport { nanoid } from '../nanoid.js'\nimport {\n Certificate as LegacyCertificate,\n ARCCertificateIndex,\n RequestCertificate,\n} from './legacy/models/ClientCertificate.js'\n\nexport type CertificateType = 'p12' | 'pem'\n\nexport const Kind = 'Core#Certificate'\n\nexport type CertificateDataFormat = string | ArrayBuffer | Uint8Array\n\n/**\n * Represents a single certificate object (cert/key)\n */\nexport interface ICertificateData {\n /**\n * The certificate to use.\n * The `p12` type certificate must be a Buffer.\n */\n data: CertificateDataFormat\n /**\n * A passphrase to use to unlock the certificate.\n */\n passphrase?: string\n /**\n * The original data type of the certificate. This is only used internally by the data store\n * to move between buffers and string values stored in the store.\n * Outside the internal procedure of the data store this\n * is always `undefined` and the `data` contains the original data format.\n */\n type?: 'buffer'\n}\n\nexport interface ICertificate {\n kind: typeof Kind\n /**\n * The data store key to refer under which this certificate is stored.\n */\n key: string\n /**\n * The custom name of the certificate.\n */\n name: string\n /**\n * The timestamp when the certificate was inserted into the data store.\n * Required when returning a result. Auto-generated when inserting, if missing.\n */\n created?: number\n /**\n * Certificate type. Either `p12` or `pem`.\n */\n type: CertificateType\n /**\n * Certificate or list of certificates to use.\n */\n cert: ICertificateData\n}\n\nexport interface IP12Certificate extends ICertificate {\n type: 'p12'\n}\n\n/**\n * Represents a complete certificate configuration required to make\n * an HTTP request.\n */\nexport interface IPemCertificate extends ICertificate {\n type: 'pem'\n /**\n * The key for the `pem` type certificate.\n */\n certKey: ICertificateData\n}\n\nexport type HttpCertificate = IP12Certificate | IPemCertificate | ICertificate\n\n/**\n * @deprecated Do not use this type anymore. Create a cert instance instead.\n */\nexport interface IPemCreateOptions {\n type: 'p12'\n /**\n * The certificate contents.\n */\n cert: CertificateDataFormat\n /**\n * The key contents.\n */\n key: CertificateDataFormat\n /**\n * Optional name for the certificate.\n */\n name?: string\n /**\n * Optional passphrase for the key.\n */\n passphrase?: string\n}\n\n/**\n * @deprecated Do not use this type anymore. Create a cert instance instead.\n */\nexport interface IP12CreateOptions {\n type: 'pem'\n /**\n * The certificate contents.\n */\n cert: CertificateDataFormat\n /**\n * Optional name for the certificate.\n */\n name?: string\n /**\n * Optional passphrase for the certificate.\n */\n passphrase?: string\n}\n\n/**\n * @deprecated Do not use this type anymore. Create a cert instance instead.\n */\nexport type ICertificateCreateOptions = IPemCreateOptions | IP12CreateOptions\n\n/**\n * A class that represents a certificate in the system\n */\nexport class Certificate {\n kind = Kind\n /**\n * The data store key to refer.\n */\n key: string\n /**\n * Custom name of the certificate.\n */\n name: string\n /**\n * Timestamp when the certificate was inserted into the data store.\n * Required when returning a result. Auto-generated when inserting, if missing.\n */\n created = 0\n /**\n * Certificate type. Either `p12` or `pem`.\n */\n type: CertificateType\n /**\n * Certificate or list of certificates to use.\n */\n cert: ICertificateData\n /**\n * The key for the `pem` type certificate.\n */\n certKey?: ICertificateData\n\n /**\n * Creates a new certificate instance for a PEM key\n *\n * @param pem The certificate contents\n * @param key The key contents\n * @param name The certificate name\n * @param keyPassphrase The key passphrase\n */\n static fromPem(\n pem: CertificateDataFormat,\n key: CertificateDataFormat,\n name = 'New PEM certificate',\n keyPassphrase?: string\n ): Certificate {\n const init: IPemCertificate = {\n kind: Kind,\n cert: {\n data: pem,\n },\n certKey: {\n data: key,\n },\n key: nanoid(),\n name,\n type: 'pem',\n created: Date.now(),\n }\n if (keyPassphrase) {\n init.certKey.passphrase = keyPassphrase\n }\n return new Certificate(init)\n }\n\n /**\n * Creates a new certificate instance for a P12 key\n *\n * @param cert The certificate contents\n * @param name The certificate name\n * @param passphrase The key passphrase\n */\n static fromP12(cert: CertificateDataFormat, name = 'New P12 certificate', passphrase?: string): Certificate {\n const init: IP12Certificate = {\n kind: Kind,\n cert: {\n data: cert,\n },\n key: nanoid(),\n name,\n type: 'p12',\n created: Date.now(),\n }\n if (passphrase) {\n init.cert.passphrase = passphrase\n }\n return new Certificate(init)\n }\n\n /**\n * Creates a certificate object from the ARC's legacy certificate definition.\n *\n * @param index The legacy certificate index object. If it has set `_id` it will be used as the `key`.\n * @param index The certificate data object as read from the data store. Do not restore the data\n * to its original format.\n */\n static fromLegacy(index: ARCCertificateIndex, cert: RequestCertificate): Certificate {\n const { name = '', type, created = Date.now(), _id = nanoid() } = index\n if (type === 'pem') {\n const data = Array.isArray(cert.cert) ? cert.cert[0] : cert.cert\n const key = Array.isArray(cert.key) ? cert.key[0] : (cert.key as LegacyCertificate)\n if (!key) {\n throw new Error(`Unable to create a PEM certificate without the key.`)\n }\n const init: IPemCertificate = {\n kind: Kind,\n cert: data as ICertificateData, // these are compatible.\n certKey: key as ICertificateData,\n key: _id,\n name,\n type: 'pem',\n created,\n }\n return new Certificate(init)\n } else if (type === 'p12') {\n const data = Array.isArray(cert.cert) ? cert.cert[0] : cert.cert\n const init: IP12Certificate = {\n kind: Kind,\n cert: data as ICertificateData, // these are compatible.\n key: _id,\n name,\n type: 'p12',\n created,\n }\n return new Certificate(init)\n }\n throw new Error(`Unable to create a certificate. Unknown type: ${type}.`)\n }\n\n constructor(certificate: HttpCertificate) {\n const { type, cert, key = nanoid(), name = '', created = Date.now() } = certificate\n this.key = key\n this.name = name\n this.type = type\n this.cert = Certificate.fromStore(cert)\n this.created = created\n if (type === 'pem') {\n const typed = certificate as IPemCertificate\n this.certKey = Certificate.fromStore(typed.certKey)\n }\n }\n\n /**\n * When needed it reads the certificate's original format.\n * @param data The certificate data.\n * @returns The restored certificate.\n */\n static fromStore(data: ICertificateData): ICertificateData {\n if (data.type) {\n delete data.type\n const content = data.data as string\n data.data = base64ToBuffer(content)\n }\n return data\n }\n\n /**\n * Prepares certificate object to be stored in the data store.\n * If the `data` property is not string then it assumes buffer (either\n * Node's or ArrayBuffer). In this case it converts buffer to base64 string.\n * It also adds `type` property set to `buffer` for the `fromStore()`\n * function to recognize what to do with the data.\n *\n * Note, for optimization, PEM keys should be strings as the content of the\n * certificate is already a base62 string. To spare double base64 conversion\n * use string data.\n *\n * @param data The certificate data object.\n * @throws When data is not set\n */\n static toStore(data: ICertificateData): ICertificateData {\n if (!data) {\n throw new Error('Certificate data is missing.')\n }\n if (!data.data) {\n throw new Error('Certificate content not set.')\n }\n if (typeof data.data !== 'string') {\n data.type = 'buffer'\n const buff = data.data as ArrayBuffer | Uint8Array\n data.data = bufferToBase64(buff)\n }\n return data\n }\n\n toJSON(): HttpCertificate {\n const result: HttpCertificate = {\n kind: Kind,\n key: this.key,\n cert: Certificate.toStore(this.cert),\n name: this.name,\n type: this.type,\n created: this.created,\n }\n\n if (this.type === 'pem' && this.certKey) {\n const typed = result as unknown as IPemCertificate\n typed.certKey = Certificate.toStore(this.certKey)\n }\n\n return result\n }\n}\n"]}
@@ -54,7 +54,7 @@ export interface IRequestBaseConfig {
54
54
  */
55
55
  proxyPassword?: string;
56
56
  /**
57
- * THe type of proxy authentication to use.
57
+ * The type of proxy authentication to use.
58
58
  */
59
59
  proxyAuthorization?: 'Basic';
60
60
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"RequestConfig.js","sourceRoot":"","sources":["../../../src/models/RequestConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,QAAQ,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAa,QAAQ,EAAE,MAAM,eAAe,CAAA;AAGnD,MAAM,CAAC,MAAM,IAAI,GAAG,oBAAoB,CAAA;AAyFxC,MAAM,OAAO,aAAa;IACxB,IAAI,GAAG,IAAI,CAAA;IACX;;OAEG;IACH,OAAO,GAAG,KAAK,CAAA;IACf;;;OAGG;IACH,OAAO,CAAS;IAChB;;OAEG;IACH,eAAe,CAAU;IACzB;;OAEG;IACH,oBAAoB,CAAU;IAC9B;;OAEG;IACH,KAAK,CAAa;IAClB;;OAEG;IACH,oBAAoB,CAAU;IAC9B;;OAEG;IACH,cAAc,CAAU;IACxB;;;;;OAKG;IACH,gBAAgB,CAAS;IACzB;;;;OAIG;IACH,aAAa,CAAS;IACtB;;;OAGG;IACH,SAAS,CAAa;IACtB;;;OAGG;I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MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAA;QAC3B,CAAC;QACD,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACvB,MAAM,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAA;QAC3C,CAAC;QACD,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACvB,MAAM,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAA;QAC3C,CAAC;QACD,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAC1B,MAAM,CAAC,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAA;QACjD,CAAC;QACD,gCAAgC;QAChC,OAAO,MAAM,CAAA;IACf,CAAC;CACF","sourcesContent":["import { IHostRule, HostRule } from './HostRule.js'\nimport { IProperty, Property } from './Property.js'\nimport { RequestConfig as LegacyConfig } from './legacy/request/ArcRequest.js'\n\nexport const Kind = 'Core#RequestConfig'\n\nexport interface IRequestBaseConfig {\n /**\n * Request timeout in milliseconds\n * Default no timeout.\n */\n timeout?: number\n /**\n * When false the request object won't follow redirects.\n * @default true\n */\n followRedirects?: boolean\n /**\n * Hosts table configuration.\n */\n hosts?: IHostRule[]\n /**\n * A limit of characters to include into the `sentHttpMessage` property\n * of the request object. 0 to disable limit. Default to 2048.\n * @default 2048\n */\n sentMessageLimit?: number\n /**\n * When set the request adds `accept` and `user-agent` headers if missing.\n */\n defaultHeaders?: boolean\n /**\n * Default `user-agent` header to be used with request when `defaultHeaders`\n * is set.\n *\n * @default api-client\n */\n defaultUserAgent?: string\n /**\n * Default `accept` header to be used with request when `defaultHeaders`\n * is set.\n * @default *\\/*\n */\n defaultAccept?: string\n /**\n * The proxy URI to connect to when making the connection.\n * It should contain the host and port. Default port is 80.\n */\n proxy?: string\n /**\n * The proxy authorization username value.\n */\n proxyUsername?: string\n /**\n * The proxy authorization password value.\n */\n proxyPassword?: string\n /**\n * THe type of proxy authentication to use.\n */\n proxyAuthorization?: 'Basic'\n /**\n * Whether the processor should validate certificates.\n */\n validateCertificates?: boolean\n\n /**\n * Optional signal from an `AbortController`.\n * This is populated only when executing a request. This value is opaque for the data store.\n */\n signal?: AbortSignal\n}\n\n/**\n * API Client request `config` object.\n */\nexport interface IRequestConfig extends IRequestBaseConfig {\n kind: typeof Kind\n /**\n * Whether the processor should use this configuration.\n */\n enabled: boolean\n /**\n * Does not set session (saved) cookies to this request\n */\n ignoreSessionCookies?: boolean\n /**\n * A list of variables to use with the request.\n * Note, request variables override application and Folder variables.\n */\n variables?: IProperty[]\n}\n\nexport class RequestConfig {\n kind = Kind\n /**\n * Whether the processor should use this configuration.\n */\n enabled = false\n /**\n * The request timeout.\n * Default no timeout.\n */\n timeout?: number\n /**\n * Whether or not the request should follow redirects.\n */\n followRedirects?: boolean\n /**\n * Does not set session (saved) cookies to this request\n */\n ignoreSessionCookies?: boolean\n /**\n * Hosts table configuration.\n */\n hosts?: HostRule[]\n /**\n * Whether the processor should validate certificates.\n */\n validateCertificates?: boolean\n /**\n * Whether to put a \"default\" headers (accept and user agent)\n */\n defaultHeaders?: boolean\n /**\n * Default `user-agent` header to be used with request when `defaultHeaders`\n * is set.\n *\n * @default api-client\n */\n defaultUserAgent?: string\n /**\n * Default `accept` header to be used with request when `defaultHeaders`\n * is set.\n * @default *\\/*\n */\n defaultAccept?: string\n /**\n * A list of variables to use with the request.\n * Note, request variables override application and workspace variables.\n */\n variables?: Property[]\n /**\n * The proxy URI to connect to when making the connection.\n * It should contain the host and port. Default port is 80.\n */\n proxy?: string\n /**\n * The proxy authorization username value.\n */\n proxyUsername?: string\n /**\n * The proxy authorization password value.\n */\n proxyPassword?: string\n /**\n * A limit of characters to include into the `sentHttpMessage` property\n * of the request object. 0 to disable limit. Default to 2048.\n * @default 2048\n */\n sentMessageLimit?: number\n\n /**\n * Optional signal from an `AbortController`.\n * This is populated only when executing a request. This value is opaque for the data store.\n */\n signal?: AbortSignal\n\n static withDefaults(): RequestConfig {\n return new RequestConfig({\n kind: Kind,\n enabled: true,\n timeout: 90,\n followRedirects: true,\n ignoreSessionCookies: false,\n validateCertificates: false,\n })\n }\n\n static fromLegacy(config: LegacyConfig): RequestConfig {\n const { enabled, defaultHeaders, followRedirects, ignoreSessionCookies, timeout, validateCertificates } = config\n const init: IRequestConfig = {\n kind: Kind,\n enabled,\n }\n if (typeof defaultHeaders === 'boolean') {\n init.defaultHeaders = defaultHeaders\n }\n if (typeof followRedirects === 'boolean') {\n init.followRedirects = followRedirects\n }\n if (typeof ignoreSessionCookies === 'boolean') {\n init.ignoreSessionCookies = ignoreSessionCookies\n }\n if (typeof validateCertificates === 'boolean') {\n init.validateCertificates = validateCertificates\n }\n if (typeof timeout === 'number') {\n init.timeout = timeout\n }\n return new RequestConfig(init)\n }\n\n /**\n * @param input The request configuration definition used to restore the state.\n */\n constructor(input?: string | IRequestConfig) {\n let init: IRequestConfig\n if (typeof input === 'string') {\n init = JSON.parse(input)\n } else if (typeof input === 'object') {\n init = input\n } else {\n init = {\n kind: Kind,\n enabled: false,\n }\n }\n this.new(init)\n }\n\n /**\n * Creates a new request configuration clearing anything that is so far defined.\n */\n new(init: IRequestConfig): void {\n const {\n enabled,\n followRedirects,\n ignoreSessionCookies,\n validateCertificates,\n defaultHeaders,\n timeout,\n hosts,\n variables,\n defaultAccept,\n defaultUserAgent,\n proxy,\n proxyPassword,\n proxyUsername,\n sentMessageLimit,\n signal,\n } = init\n this.kind = Kind\n if (typeof enabled === 'boolean') {\n this.enabled = enabled\n } else {\n this.enabled = false\n }\n if (typeof followRedirects === 'boolean') {\n this.followRedirects = followRedirects\n } else {\n this.followRedirects = undefined\n }\n if (typeof ignoreSessionCookies === 'boolean') {\n this.ignoreSessionCookies = ignoreSessionCookies\n } else {\n this.ignoreSessionCookies = undefined\n }\n if (typeof validateCertificates === 'boolean') {\n this.validateCertificates = validateCertificates\n } else {\n this.validateCertificates = undefined\n }\n if (typeof defaultHeaders === 'boolean') {\n this.defaultHeaders = defaultHeaders\n } else {\n this.defaultHeaders = undefined\n }\n if (typeof timeout === 'number') {\n this.timeout = timeout\n } else {\n this.timeout = undefined\n }\n if (Array.isArray(hosts)) {\n this.hosts = hosts.map((i) => new HostRule(i))\n } else {\n this.hosts = []\n }\n if (Array.isArray(variables)) {\n this.variables = variables.map((i) => new Property(i))\n } else {\n this.variables = []\n }\n if (typeof defaultAccept === 'string') {\n this.defaultAccept = defaultAccept\n } else {\n this.defaultAccept = undefined\n }\n if (typeof defaultUserAgent === 'string') {\n this.defaultUserAgent = defaultUserAgent\n } else {\n this.defaultUserAgent = undefined\n }\n if (typeof proxy === 'string') {\n this.proxy = proxy\n } else {\n this.proxy = undefined\n }\n if (typeof proxyUsername === 'string') {\n this.proxyUsername = proxyUsername\n } else {\n this.proxyUsername = undefined\n }\n if (typeof proxyPassword === 'string') {\n this.proxyPassword = proxyPassword\n } else {\n this.proxyPassword = undefined\n }\n if (typeof sentMessageLimit === 'number') {\n this.sentMessageLimit = sentMessageLimit\n } else {\n this.sentMessageLimit = undefined\n }\n if (signal) {\n this.signal = signal\n } else {\n this.signal = undefined\n }\n }\n\n toJSON(): IRequestConfig {\n const result: IRequestConfig = {\n kind: Kind,\n enabled: this.enabled,\n }\n if (typeof this.followRedirects === 'boolean') {\n result.followRedirects = this.followRedirects\n }\n if (typeof this.ignoreSessionCookies === 'boolean') {\n result.ignoreSessionCookies = this.ignoreSessionCookies\n }\n if (typeof this.validateCertificates === 'boolean') {\n result.validateCertificates = this.validateCertificates\n }\n if (typeof this.defaultHeaders === 'boolean') {\n result.defaultHeaders = this.defaultHeaders\n }\n if (typeof this.timeout === 'number') {\n result.timeout = this.timeout\n }\n if (Array.isArray(this.hosts) && this.hosts.length) {\n result.hosts = this.hosts.map((i) => i.toJSON())\n }\n if (Array.isArray(this.variables) && this.variables.length) {\n result.variables = this.variables.map((i) => i.toJSON())\n }\n if (this.defaultAccept) {\n result.defaultAccept = this.defaultAccept\n }\n if (this.defaultUserAgent) {\n result.defaultUserAgent = this.defaultUserAgent\n }\n if (this.proxy) {\n result.proxy = this.proxy\n }\n if (this.proxyUsername) {\n result.proxyUsername = this.proxyUsername\n }\n if (this.proxyPassword) {\n result.proxyPassword = this.proxyPassword\n }\n if (this.sentMessageLimit) {\n result.sentMessageLimit = this.sentMessageLimit\n }\n // DO NOT put the `signal` here.\n return result\n }\n}\n"]}
1
+ {"version":3,"file":"RequestConfig.js","sourceRoot":"","sources":["../../../src/models/RequestConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,QAAQ,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAa,QAAQ,EAAE,MAAM,eAAe,CAAA;AAGnD,MAAM,CAAC,MAAM,IAAI,GAAG,oBAAoB,CAAA;AAyFxC,MAAM,OAAO,aAAa;IACxB,IAAI,GAAG,IAAI,CAAA;IACX;;OAEG;IACH,OAAO,GAAG,KAAK,CAAA;IACf;;;OAGG;IACH,OAAO,CAAS;IAChB;;OAEG;IACH,eAAe,CAAU;IACzB;;OAEG;IACH,oBAAoB,CAAU;IAC9B;;OAEG;IACH,KAAK,CAAa;IAClB;;OAEG;IACH,oBAAoB,CAAU;IAC9B;;OAEG;IACH,cAAc,CAAU;IACxB;;;;;OAKG;IACH,gBAAgB,CAAS;IACzB;;;;OAIG;IACH,aAAa,CAAS;IACtB;;;OAGG;IACH,SAAS,CAAa;IACtB;;;OAGG;IACH,KAAK,CAAS;IACd;;OAEG;IACH,aAAa,CAAS;IACtB;;OAEG;IACH,aAAa,CAAS;IACtB;;;;OAIG;IACH,gBAAgB,CAAS;IAEzB;;;OAGG;IACH,MAAM,CAAc;IAEpB,MAAM,CAAC,YAAY;QACjB,OAAO,IAAI,aAAa,CAAC;YACvB,IAAI,EAAE,IAAI;YACV,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,EAAE;YACX,eAAe,EAAE,IAAI;YACrB,oBAAoB,EAAE,KAAK;YAC3B,oBAAoB,EAAE,KAAK;SAC5B,CAAC,CAAA;IACJ,CAAC;IAED,MAAM,CAAC,UAA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D,gCAAgC;QAChC,OAAO,MAAM,CAAA;IACf,CAAC;CACF","sourcesContent":["import { IHostRule, HostRule } from './HostRule.js'\nimport { IProperty, Property } from './Property.js'\nimport { RequestConfig as LegacyConfig } from './legacy/request/ArcRequest.js'\n\nexport const Kind = 'Core#RequestConfig'\n\nexport interface IRequestBaseConfig {\n /**\n * Request timeout in milliseconds\n * Default no timeout.\n */\n timeout?: number\n /**\n * When false the request object won't follow redirects.\n * @default true\n */\n followRedirects?: boolean\n /**\n * Hosts table configuration.\n */\n hosts?: IHostRule[]\n /**\n * A limit of characters to include into the `sentHttpMessage` property\n * of the request object. 0 to disable limit. Default to 2048.\n * @default 2048\n */\n sentMessageLimit?: number\n /**\n * When set the request adds `accept` and `user-agent` headers if missing.\n */\n defaultHeaders?: boolean\n /**\n * Default `user-agent` header to be used with request when `defaultHeaders`\n * is set.\n *\n * @default api-client\n */\n defaultUserAgent?: string\n /**\n * Default `accept` header to be used with request when `defaultHeaders`\n * is set.\n * @default *\\/*\n */\n defaultAccept?: string\n /**\n * The proxy URI to connect to when making the connection.\n * It should contain the host and port. Default port is 80.\n */\n proxy?: string\n /**\n * The proxy authorization username value.\n */\n proxyUsername?: string\n /**\n * The proxy authorization password value.\n */\n proxyPassword?: string\n /**\n * The type of proxy authentication to use.\n */\n proxyAuthorization?: 'Basic'\n /**\n * Whether the processor should validate certificates.\n */\n validateCertificates?: boolean\n\n /**\n * Optional signal from an `AbortController`.\n * This is populated only when executing a request. This value is opaque for the data store.\n */\n signal?: AbortSignal\n}\n\n/**\n * API Client request `config` object.\n */\nexport interface IRequestConfig extends IRequestBaseConfig {\n kind: typeof Kind\n /**\n * Whether the processor should use this configuration.\n */\n enabled: boolean\n /**\n * Does not set session (saved) cookies to this request\n */\n ignoreSessionCookies?: boolean\n /**\n * A list of variables to use with the request.\n * Note, request variables override application and Folder variables.\n */\n variables?: IProperty[]\n}\n\nexport class RequestConfig {\n kind = Kind\n /**\n * Whether the processor should use this configuration.\n */\n enabled = false\n /**\n * The request timeout.\n * Default no timeout.\n */\n timeout?: number\n /**\n * Whether or not the request should follow redirects.\n */\n followRedirects?: boolean\n /**\n * Does not set session (saved) cookies to this request\n */\n ignoreSessionCookies?: boolean\n /**\n * Hosts table configuration.\n */\n hosts?: HostRule[]\n /**\n * Whether the processor should validate certificates.\n */\n validateCertificates?: boolean\n /**\n * Whether to put a \"default\" headers (accept and user agent)\n */\n defaultHeaders?: boolean\n /**\n * Default `user-agent` header to be used with request when `defaultHeaders`\n * is set.\n *\n * @default api-client\n */\n defaultUserAgent?: string\n /**\n * Default `accept` header to be used with request when `defaultHeaders`\n * is set.\n * @default *\\/*\n */\n defaultAccept?: string\n /**\n * A list of variables to use with the request.\n * Note, request variables override application and workspace variables.\n */\n variables?: Property[]\n /**\n * The proxy URI to connect to when making the connection.\n * It should contain the host and port. Default port is 80.\n */\n proxy?: string\n /**\n * The proxy authorization username value.\n */\n proxyUsername?: string\n /**\n * The proxy authorization password value.\n */\n proxyPassword?: string\n /**\n * A limit of characters to include into the `sentHttpMessage` property\n * of the request object. 0 to disable limit. Default to 2048.\n * @default 2048\n */\n sentMessageLimit?: number\n\n /**\n * Optional signal from an `AbortController`.\n * This is populated only when executing a request. This value is opaque for the data store.\n */\n signal?: AbortSignal\n\n static withDefaults(): RequestConfig {\n return new RequestConfig({\n kind: Kind,\n enabled: true,\n timeout: 90,\n followRedirects: true,\n ignoreSessionCookies: false,\n validateCertificates: false,\n })\n }\n\n static fromLegacy(config: LegacyConfig): RequestConfig {\n const { enabled, defaultHeaders, followRedirects, ignoreSessionCookies, timeout, validateCertificates } = config\n const init: IRequestConfig = {\n kind: Kind,\n enabled,\n }\n if (typeof defaultHeaders === 'boolean') {\n init.defaultHeaders = defaultHeaders\n }\n if (typeof followRedirects === 'boolean') {\n init.followRedirects = followRedirects\n }\n if (typeof ignoreSessionCookies === 'boolean') {\n init.ignoreSessionCookies = ignoreSessionCookies\n }\n if (typeof validateCertificates === 'boolean') {\n init.validateCertificates = validateCertificates\n }\n if (typeof timeout === 'number') {\n init.timeout = timeout\n }\n return new RequestConfig(init)\n }\n\n /**\n * @param input The request configuration definition used to restore the state.\n */\n constructor(input?: string | IRequestConfig) {\n let init: IRequestConfig\n if (typeof input === 'string') {\n init = JSON.parse(input)\n } else if (typeof input === 'object') {\n init = input\n } else {\n init = {\n kind: Kind,\n enabled: false,\n }\n }\n this.new(init)\n }\n\n /**\n * Creates a new request configuration clearing anything that is so far defined.\n */\n new(init: IRequestConfig): void {\n const {\n enabled,\n followRedirects,\n ignoreSessionCookies,\n validateCertificates,\n defaultHeaders,\n timeout,\n hosts,\n variables,\n defaultAccept,\n defaultUserAgent,\n proxy,\n proxyPassword,\n proxyUsername,\n sentMessageLimit,\n signal,\n } = init\n this.kind = Kind\n if (typeof enabled === 'boolean') {\n this.enabled = enabled\n } else {\n this.enabled = false\n }\n if (typeof followRedirects === 'boolean') {\n this.followRedirects = followRedirects\n } else {\n this.followRedirects = undefined\n }\n if (typeof ignoreSessionCookies === 'boolean') {\n this.ignoreSessionCookies = ignoreSessionCookies\n } else {\n this.ignoreSessionCookies = undefined\n }\n if (typeof validateCertificates === 'boolean') {\n this.validateCertificates = validateCertificates\n } else {\n this.validateCertificates = undefined\n }\n if (typeof defaultHeaders === 'boolean') {\n this.defaultHeaders = defaultHeaders\n } else {\n this.defaultHeaders = undefined\n }\n if (typeof timeout === 'number') {\n this.timeout = timeout\n } else {\n this.timeout = undefined\n }\n if (Array.isArray(hosts)) {\n this.hosts = hosts.map((i) => new HostRule(i))\n } else {\n this.hosts = []\n }\n if (Array.isArray(variables)) {\n this.variables = variables.map((i) => new Property(i))\n } else {\n this.variables = []\n }\n if (typeof defaultAccept === 'string') {\n this.defaultAccept = defaultAccept\n } else {\n this.defaultAccept = undefined\n }\n if (typeof defaultUserAgent === 'string') {\n this.defaultUserAgent = defaultUserAgent\n } else {\n this.defaultUserAgent = undefined\n }\n if (typeof proxy === 'string') {\n this.proxy = proxy\n } else {\n this.proxy = undefined\n }\n if (typeof proxyUsername === 'string') {\n this.proxyUsername = proxyUsername\n } else {\n this.proxyUsername = undefined\n }\n if (typeof proxyPassword === 'string') {\n this.proxyPassword = proxyPassword\n } else {\n this.proxyPassword = undefined\n }\n if (typeof sentMessageLimit === 'number') {\n this.sentMessageLimit = sentMessageLimit\n } else {\n this.sentMessageLimit = undefined\n }\n if (signal) {\n this.signal = signal\n } else {\n this.signal = undefined\n }\n }\n\n toJSON(): IRequestConfig {\n const result: IRequestConfig = {\n kind: Kind,\n enabled: this.enabled,\n }\n if (typeof this.followRedirects === 'boolean') {\n result.followRedirects = this.followRedirects\n }\n if (typeof this.ignoreSessionCookies === 'boolean') {\n result.ignoreSessionCookies = this.ignoreSessionCookies\n }\n if (typeof this.validateCertificates === 'boolean') {\n result.validateCertificates = this.validateCertificates\n }\n if (typeof this.defaultHeaders === 'boolean') {\n result.defaultHeaders = this.defaultHeaders\n }\n if (typeof this.timeout === 'number') {\n result.timeout = this.timeout\n }\n if (Array.isArray(this.hosts) && this.hosts.length) {\n result.hosts = this.hosts.map((i) => i.toJSON())\n }\n if (Array.isArray(this.variables) && this.variables.length) {\n result.variables = this.variables.map((i) => i.toJSON())\n }\n if (this.defaultAccept) {\n result.defaultAccept = this.defaultAccept\n }\n if (this.defaultUserAgent) {\n result.defaultUserAgent = this.defaultUserAgent\n }\n if (this.proxy) {\n result.proxy = this.proxy\n }\n if (this.proxyUsername) {\n result.proxyUsername = this.proxyUsername\n }\n if (this.proxyPassword) {\n result.proxyPassword = this.proxyPassword\n }\n if (this.sentMessageLimit) {\n result.sentMessageLimit = this.sentMessageLimit\n }\n // DO NOT put the `signal` here.\n return result\n }\n}\n"]}
@@ -18,7 +18,7 @@ export declare class SerializableError {
18
18
  code?: number | string;
19
19
  private stackValue?;
20
20
  get stack(): string | undefined;
21
- readonly name = "SerializableError";
21
+ readonly name: string;
22
22
  constructor(message?: string | Error, options?: IErrorOptions | number | string);
23
23
  new(values: ISerializedError): void;
24
24
  toJSON(): ISerializedError;
@@ -1 +1 @@
1
- {"version":3,"file":"SerializableError.d.ts","sourceRoot":"","sources":["../../../src/models/SerializableError.ts"],"names":[],"mappings":"AAAA,UAAU,aAAa;IACrB,KAAK,CAAC,EAAE,KAAK,CAAA;CACd;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAA;CAC5B;AAED;;;;;GAKG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACtB,OAAO,CAAC,UAAU,CAAC,CAAQ;IAC3B,IAAI,KAAK,IAAI,MAAM,GAAG,SAAS,CAE9B;IAED,QAAQ,CAAC,IAAI,uBAAsB;gBAEvB,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK,EAAE,OAAO,GAAE,aAAa,GAAG,MAAM,GAAG,MAAW;IAgBnF,GAAG,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI;IAYnC,MAAM,IAAI,gBAAgB;IAc1B,QAAQ,IAAI,MAAM;CAGnB"}
1
+ {"version":3,"file":"SerializableError.d.ts","sourceRoot":"","sources":["../../../src/models/SerializableError.ts"],"names":[],"mappings":"AAAA,UAAU,aAAa;IACrB,KAAK,CAAC,EAAE,KAAK,CAAA;CACd;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAA;CAC5B;AAED;;;;;GAKG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,G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