velocious 1.0.644 → 1.0.645

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 (259) hide show
  1. package/README.md +11 -9
  2. package/build/authorization/ability.js +36 -13
  3. package/build/background-jobs/adapter.js +9 -0
  4. package/build/background-jobs/main.js +35 -10
  5. package/build/background-jobs/store.js +217 -38
  6. package/build/background-jobs/types.js +15 -0
  7. package/build/configuration-types.js +1 -1
  8. package/build/configuration.js +45 -9
  9. package/build/database/drivers/base-column.js +8 -0
  10. package/build/database/drivers/mssql/sql/update.js +1 -3
  11. package/build/database/drivers/mysql/sql/update.js +1 -3
  12. package/build/database/drivers/pgsql/column.js +22 -0
  13. package/build/database/drivers/pgsql/sql/update.js +1 -3
  14. package/build/database/drivers/sqlite/sql/alter-table.js +11 -1
  15. package/build/database/drivers/sqlite/sql/update.js +1 -3
  16. package/build/database/query/index.js +2 -2
  17. package/build/database/query/model-class-query.js +26 -10
  18. package/build/database/query/preloader/has-many.js +4 -1
  19. package/build/database/query/query-data.js +2 -1
  20. package/build/database/query/update-base.js +14 -0
  21. package/build/database/query/with-count.js +3 -1
  22. package/build/database/record/acts-as-list.js +37 -13
  23. package/build/database/record/attachments/store.js +336 -26
  24. package/build/database/record/auditing.js +6 -3
  25. package/build/database/record/index.js +197 -42
  26. package/build/database/record/instance-relationships/belongs-to.js +2 -1
  27. package/build/database/record/validators/uniqueness.js +8 -5
  28. package/build/environment-handlers/node/cli/commands/generate/frontend-models.js +24 -8
  29. package/build/frontend-model-controller.js +136 -53
  30. package/build/frontend-model-resource/base-resource.js +87 -37
  31. package/build/frontend-model-resource/velocious-attachment-resource.js +98 -31
  32. package/build/frontend-models/base.js +307 -59
  33. package/build/frontend-models/preloader.js +6 -3
  34. package/build/frontend-models/query.js +15 -6
  35. package/build/frontend-models/resource-definition.js +21 -2
  36. package/build/frontend-models/use-destroyed-event.js +1 -1
  37. package/build/frontend-models/use-model-class-event.js +2 -2
  38. package/build/frontend-models/use-updated-event.js +1 -1
  39. package/build/frontend-models/websocket-channel.js +256 -93
  40. package/build/frontend-models/websocket-publishers.js +218 -18
  41. package/build/http-server/client/websocket-session.js +13 -1
  42. package/build/http-server/websocket-channel.js +15 -2
  43. package/build/src/authorization/ability.d.ts +9 -3
  44. package/build/src/authorization/ability.d.ts.map +1 -1
  45. package/build/src/authorization/ability.js +33 -14
  46. package/build/src/background-jobs/adapter.d.ts +6 -0
  47. package/build/src/background-jobs/adapter.d.ts.map +1 -1
  48. package/build/src/background-jobs/adapter.js +9 -1
  49. package/build/src/background-jobs/main.d.ts +6 -0
  50. package/build/src/background-jobs/main.d.ts.map +1 -1
  51. package/build/src/background-jobs/main.js +34 -11
  52. package/build/src/background-jobs/store.d.ts +66 -12
  53. package/build/src/background-jobs/store.d.ts.map +1 -1
  54. package/build/src/background-jobs/store.js +191 -35
  55. package/build/src/background-jobs/types.d.ts +55 -0
  56. package/build/src/background-jobs/types.d.ts.map +1 -1
  57. package/build/src/background-jobs/types.js +16 -1
  58. package/build/src/configuration-types.d.ts +3 -3
  59. package/build/src/configuration-types.d.ts.map +1 -1
  60. package/build/src/configuration-types.js +2 -2
  61. package/build/src/configuration.d.ts +18 -8
  62. package/build/src/configuration.d.ts.map +1 -1
  63. package/build/src/configuration.js +38 -7
  64. package/build/src/database/drivers/base-column.d.ts +5 -0
  65. package/build/src/database/drivers/base-column.d.ts.map +1 -1
  66. package/build/src/database/drivers/base-column.js +8 -1
  67. package/build/src/database/drivers/mssql/sql/update.d.ts.map +1 -1
  68. package/build/src/database/drivers/mssql/sql/update.js +2 -4
  69. package/build/src/database/drivers/mysql/sql/update.d.ts.map +1 -1
  70. package/build/src/database/drivers/mysql/sql/update.js +2 -4
  71. package/build/src/database/drivers/pgsql/column.d.ts +5 -0
  72. package/build/src/database/drivers/pgsql/column.d.ts.map +1 -1
  73. package/build/src/database/drivers/pgsql/column.js +19 -1
  74. package/build/src/database/drivers/pgsql/sql/update.d.ts.map +1 -1
  75. package/build/src/database/drivers/pgsql/sql/update.js +2 -4
  76. package/build/src/database/drivers/sqlite/sql/alter-table.d.ts.map +1 -1
  77. package/build/src/database/drivers/sqlite/sql/alter-table.js +6 -2
  78. package/build/src/database/drivers/sqlite/sql/update.d.ts.map +1 -1
  79. package/build/src/database/drivers/sqlite/sql/update.js +2 -4
  80. package/build/src/database/query/index.d.ts +4 -4
  81. package/build/src/database/query/index.d.ts.map +1 -1
  82. package/build/src/database/query/index.js +3 -3
  83. package/build/src/database/query/model-class-query.d.ts +8 -2
  84. package/build/src/database/query/model-class-query.d.ts.map +1 -1
  85. package/build/src/database/query/model-class-query.js +25 -11
  86. package/build/src/database/query/preloader/has-many.d.ts.map +1 -1
  87. package/build/src/database/query/preloader/has-many.js +4 -2
  88. package/build/src/database/query/query-data.d.ts.map +1 -1
  89. package/build/src/database/query/query-data.js +3 -2
  90. package/build/src/database/query/update-base.d.ts +7 -0
  91. package/build/src/database/query/update-base.d.ts.map +1 -1
  92. package/build/src/database/query/update-base.js +13 -1
  93. package/build/src/database/query/with-count.d.ts.map +1 -1
  94. package/build/src/database/query/with-count.js +3 -2
  95. package/build/src/database/record/acts-as-list.d.ts.map +1 -1
  96. package/build/src/database/record/acts-as-list.js +35 -14
  97. package/build/src/database/record/attachments/store.d.ts +67 -0
  98. package/build/src/database/record/attachments/store.d.ts.map +1 -1
  99. package/build/src/database/record/attachments/store.js +301 -25
  100. package/build/src/database/record/auditing.d.ts.map +1 -1
  101. package/build/src/database/record/auditing.js +7 -4
  102. package/build/src/database/record/index.d.ts +78 -26
  103. package/build/src/database/record/index.d.ts.map +1 -1
  104. package/build/src/database/record/index.js +171 -42
  105. package/build/src/database/record/instance-relationships/belongs-to.d.ts.map +1 -1
  106. package/build/src/database/record/instance-relationships/belongs-to.js +3 -2
  107. package/build/src/database/record/validators/uniqueness.d.ts.map +1 -1
  108. package/build/src/database/record/validators/uniqueness.js +8 -6
  109. package/build/src/environment-handlers/node/cli/commands/generate/frontend-models.d.ts +4 -4
  110. package/build/src/environment-handlers/node/cli/commands/generate/frontend-models.d.ts.map +1 -1
  111. package/build/src/environment-handlers/node/cli/commands/generate/frontend-models.js +24 -12
  112. package/build/src/frontend-model-controller.d.ts +29 -8
  113. package/build/src/frontend-model-controller.d.ts.map +1 -1
  114. package/build/src/frontend-model-controller.js +122 -51
  115. package/build/src/frontend-model-resource/base-resource.d.ts +51 -24
  116. package/build/src/frontend-model-resource/base-resource.d.ts.map +1 -1
  117. package/build/src/frontend-model-resource/base-resource.js +83 -37
  118. package/build/src/frontend-model-resource/velocious-attachment-resource.d.ts +45 -26
  119. package/build/src/frontend-model-resource/velocious-attachment-resource.d.ts.map +1 -1
  120. package/build/src/frontend-model-resource/velocious-attachment-resource.js +89 -31
  121. package/build/src/frontend-models/base.d.ts +53 -20
  122. package/build/src/frontend-models/base.d.ts.map +1 -1
  123. package/build/src/frontend-models/base.js +275 -59
  124. package/build/src/frontend-models/preloader.d.ts.map +1 -1
  125. package/build/src/frontend-models/preloader.js +6 -4
  126. package/build/src/frontend-models/query.d.ts +2 -2
  127. package/build/src/frontend-models/query.d.ts.map +1 -1
  128. package/build/src/frontend-models/query.js +14 -7
  129. package/build/src/frontend-models/resource-definition.d.ts.map +1 -1
  130. package/build/src/frontend-models/resource-definition.js +20 -3
  131. package/build/src/frontend-models/use-destroyed-event.d.ts +1 -1
  132. package/build/src/frontend-models/use-destroyed-event.d.ts.map +1 -1
  133. package/build/src/frontend-models/use-destroyed-event.js +2 -2
  134. package/build/src/frontend-models/use-model-class-event.d.ts +2 -2
  135. package/build/src/frontend-models/use-model-class-event.d.ts.map +1 -1
  136. package/build/src/frontend-models/use-model-class-event.js +3 -3
  137. package/build/src/frontend-models/use-updated-event.d.ts +1 -1
  138. package/build/src/frontend-models/use-updated-event.d.ts.map +1 -1
  139. package/build/src/frontend-models/use-updated-event.js +2 -2
  140. package/build/src/frontend-models/websocket-channel.d.ts +60 -41
  141. package/build/src/frontend-models/websocket-channel.d.ts.map +1 -1
  142. package/build/src/frontend-models/websocket-channel.js +225 -85
  143. package/build/src/frontend-models/websocket-publishers.d.ts +9 -0
  144. package/build/src/frontend-models/websocket-publishers.d.ts.map +1 -1
  145. package/build/src/frontend-models/websocket-publishers.js +190 -19
  146. package/build/src/http-server/client/websocket-session.d.ts.map +1 -1
  147. package/build/src/http-server/client/websocket-session.js +11 -2
  148. package/build/src/http-server/websocket-channel.d.ts +20 -8
  149. package/build/src/http-server/websocket-channel.d.ts.map +1 -1
  150. package/build/src/http-server/websocket-channel.js +15 -3
  151. package/build/src/sync/sync-api-client.d.ts.map +1 -1
  152. package/build/src/sync/sync-api-client.js +4 -3
  153. package/build/src/sync/sync-client.d.ts.map +1 -1
  154. package/build/src/sync/sync-client.js +3 -2
  155. package/build/src/sync/sync-envelope-replay-service.d.ts.map +1 -1
  156. package/build/src/sync/sync-envelope-replay-service.js +6 -5
  157. package/build/src/sync/sync-publisher.d.ts.map +1 -1
  158. package/build/src/sync/sync-publisher.js +4 -3
  159. package/build/src/testing/browser-frontend-model-event-hook-scenarios.d.ts +2 -2
  160. package/build/src/testing/browser-frontend-model-event-hook-scenarios.d.ts.map +1 -1
  161. package/build/src/testing/browser-frontend-model-event-hook-scenarios.js +3 -3
  162. package/build/src/testing/test-profiler.d.ts +4 -4
  163. package/build/src/testing/test-profiler.d.ts.map +1 -1
  164. package/build/src/testing/test-profiler.js +3 -3
  165. package/build/src/testing/test-runner.d.ts +271 -117
  166. package/build/src/testing/test-runner.d.ts.map +1 -1
  167. package/build/src/testing/test-runner.js +496 -427
  168. package/build/src/testing/test.d.ts +11 -72
  169. package/build/src/testing/test.d.ts.map +1 -1
  170. package/build/src/testing/test.js +131 -284
  171. package/build/src/testing/velocious-attempt-executor.d.ts +14 -29
  172. package/build/src/testing/velocious-attempt-executor.d.ts.map +1 -1
  173. package/build/src/testing/velocious-attempt-executor.js +52 -46
  174. package/build/src/testing/velocious-runner-reporter.d.ts +29 -34
  175. package/build/src/testing/velocious-runner-reporter.d.ts.map +1 -1
  176. package/build/src/testing/velocious-runner-reporter.js +145 -57
  177. package/build/src/testing/velocious-suite-hook-executor.d.ts +5 -23
  178. package/build/src/testing/velocious-suite-hook-executor.d.ts.map +1 -1
  179. package/build/src/testing/velocious-suite-hook-executor.js +22 -47
  180. package/build/src/testing/velocious-test-arguments.d.ts +11 -6
  181. package/build/src/testing/velocious-test-arguments.d.ts.map +1 -1
  182. package/build/src/testing/velocious-test-arguments.js +18 -10
  183. package/build/src/utils/model-primary-key.d.ts +73 -0
  184. package/build/src/utils/model-primary-key.d.ts.map +1 -0
  185. package/build/src/utils/model-primary-key.js +144 -0
  186. package/build/sync/sync-api-client.js +3 -2
  187. package/build/sync/sync-client.js +2 -1
  188. package/build/sync/sync-envelope-replay-service.js +5 -4
  189. package/build/sync/sync-publisher.js +3 -2
  190. package/build/testing/browser-frontend-model-event-hook-scenarios.js +2 -2
  191. package/build/testing/test-profiler.js +2 -2
  192. package/build/testing/test-runner.js +493 -449
  193. package/build/testing/test.js +164 -306
  194. package/build/testing/velocious-attempt-executor.js +55 -45
  195. package/build/testing/velocious-runner-reporter.js +156 -58
  196. package/build/testing/velocious-suite-hook-executor.js +22 -50
  197. package/build/testing/velocious-test-arguments.js +19 -10
  198. package/build/tsconfig.tsbuildinfo +1 -1
  199. package/build/utils/model-primary-key.js +171 -0
  200. package/package.json +5 -4
  201. package/src/authorization/ability.js +36 -13
  202. package/src/background-jobs/adapter.js +9 -0
  203. package/src/background-jobs/main.js +35 -10
  204. package/src/background-jobs/store.js +217 -38
  205. package/src/background-jobs/types.js +15 -0
  206. package/src/configuration-types.js +1 -1
  207. package/src/configuration.js +45 -9
  208. package/src/database/drivers/base-column.js +8 -0
  209. package/src/database/drivers/mssql/sql/update.js +1 -3
  210. package/src/database/drivers/mysql/sql/update.js +1 -3
  211. package/src/database/drivers/pgsql/column.js +22 -0
  212. package/src/database/drivers/pgsql/sql/update.js +1 -3
  213. package/src/database/drivers/sqlite/sql/alter-table.js +11 -1
  214. package/src/database/drivers/sqlite/sql/update.js +1 -3
  215. package/src/database/query/index.js +2 -2
  216. package/src/database/query/model-class-query.js +26 -10
  217. package/src/database/query/preloader/has-many.js +4 -1
  218. package/src/database/query/query-data.js +2 -1
  219. package/src/database/query/update-base.js +14 -0
  220. package/src/database/query/with-count.js +3 -1
  221. package/src/database/record/acts-as-list.js +37 -13
  222. package/src/database/record/attachments/store.js +336 -26
  223. package/src/database/record/auditing.js +6 -3
  224. package/src/database/record/index.js +197 -42
  225. package/src/database/record/instance-relationships/belongs-to.js +2 -1
  226. package/src/database/record/validators/uniqueness.js +8 -5
  227. package/src/environment-handlers/node/cli/commands/generate/frontend-models.js +24 -8
  228. package/src/frontend-model-controller.js +136 -53
  229. package/src/frontend-model-resource/base-resource.js +87 -37
  230. package/src/frontend-model-resource/velocious-attachment-resource.js +98 -31
  231. package/src/frontend-models/base.js +307 -59
  232. package/src/frontend-models/preloader.js +6 -3
  233. package/src/frontend-models/query.js +15 -6
  234. package/src/frontend-models/resource-definition.js +21 -2
  235. package/src/frontend-models/use-destroyed-event.js +1 -1
  236. package/src/frontend-models/use-model-class-event.js +2 -2
  237. package/src/frontend-models/use-updated-event.js +1 -1
  238. package/src/frontend-models/websocket-channel.js +256 -93
  239. package/src/frontend-models/websocket-publishers.js +218 -18
  240. package/src/http-server/client/websocket-session.js +13 -1
  241. package/src/http-server/websocket-channel.js +15 -2
  242. package/src/sync/sync-api-client.js +3 -2
  243. package/src/sync/sync-client.js +2 -1
  244. package/src/sync/sync-envelope-replay-service.js +5 -4
  245. package/src/sync/sync-publisher.js +3 -2
  246. package/src/testing/browser-frontend-model-event-hook-scenarios.js +2 -2
  247. package/src/testing/test-profiler.js +2 -2
  248. package/src/testing/test-runner.js +493 -449
  249. package/src/testing/test.js +164 -306
  250. package/src/testing/velocious-attempt-executor.js +55 -45
  251. package/src/testing/velocious-runner-reporter.js +156 -58
  252. package/src/testing/velocious-suite-hook-executor.js +22 -50
  253. package/src/testing/velocious-test-arguments.js +19 -10
  254. package/src/utils/model-primary-key.js +171 -0
  255. package/build/src/testing/testing-package-adapter.d.ts +0 -9
  256. package/build/src/testing/testing-package-adapter.d.ts.map +0 -1
  257. package/build/src/testing/testing-package-adapter.js +0 -69
  258. package/build/testing/testing-package-adapter.js +0 -76
  259. package/src/testing/testing-package-adapter.js +0 -76
@@ -4,6 +4,7 @@ import restArgsError from "../utils/rest-args-error.js"
4
4
 
5
5
  /** @typedef {import("./test-runner.js").TestArgs} TestArgs */
6
6
  /** @typedef {import("./test-runner.js").TestData} TestData */
7
+ /** @typedef {import("@velocious/testing/runner").TestDeclaration} PackageTestDeclaration */
7
8
 
8
9
  export default class VelociousTestArguments {
9
10
  /**
@@ -17,25 +18,33 @@ export default class VelociousTestArguments {
17
18
  }
18
19
 
19
20
  /**
20
- * Builds the stable framework-owned argument object for one selected test.
21
- * @param {TestData} testData - Selected test registration.
22
- * @returns {Promise<TestArgs>} - Attempt-shared callback arguments.
21
+ * Resolves stable Velocious arguments after package-owned table arguments.
22
+ * @param {object} input - Package resolver input.
23
+ * @param {PackageTestDeclaration} input.test - Selected declaration.
24
+ * @returns {Promise<ReturnType<typeof JSON.parse>[]>} - Callback arguments.
23
25
  */
24
- async build(testData) {
25
- const testArgs = this.copy(testData)
26
+ async resolve({test}) {
27
+ const compatibility = await this.testRunner.testCompatibility(test)
26
28
 
27
- await this.inject(testArgs)
28
-
29
- return testArgs
29
+ return [...test.rowArguments, compatibility.testArgs]
30
30
  }
31
31
 
32
32
  /**
33
33
  * Copies declaration metadata before selection can inspect it.
34
- * @param {TestData} testData - Test registration.
34
+ * @param {PackageTestDeclaration} testData - Test registration.
35
35
  * @returns {TestArgs} - Independent test arguments.
36
36
  */
37
37
  copy(testData) {
38
- return /** @type {TestArgs} */ (Object.assign({}, testData.args))
38
+ const testArgs = /** @type {TestArgs} */ (Object.assign({}, testData.options))
39
+
40
+ if (testArgs.retry === undefined && typeof testData.options.retries === "number") {
41
+ testArgs.retry = testData.options.retries
42
+ }
43
+ if (testArgs.timeoutSeconds === undefined && typeof testData.options.timeoutMs === "number") {
44
+ testArgs.timeoutSeconds = testData.options.timeoutMs / 1000
45
+ }
46
+
47
+ return testArgs
39
48
  }
40
49
 
41
50
  /**
@@ -0,0 +1,171 @@
1
+ // @ts-check
2
+
3
+ import isPlainObject from "./plain-object.js"
4
+
5
+ /** @typedef {string | number} ModelPrimaryKeyScalar */
6
+ /** @typedef {string | string[]} ModelPrimaryKeyDefinition */
7
+ /** @typedef {Record<string, ModelPrimaryKeyScalar>} CompositeModelPrimaryKeyValue */
8
+ /** @typedef {ModelPrimaryKeyScalar | CompositeModelPrimaryKeyValue} ModelPrimaryKeyValue */
9
+
10
+ /**
11
+ * Validates an untrusted composite identity and returns its definition-ordered values.
12
+ * @param {string[]} primaryKey - Composite primary-key definition.
13
+ * @param {ReturnType<typeof JSON.parse>} value - Candidate identity.
14
+ * @returns {CompositeModelPrimaryKeyValue} - Validated identity.
15
+ */
16
+ export function validatedCompositePrimaryKeyValue(primaryKey, value) {
17
+ if (!isPlainObject(value)) {
18
+ throw new TypeError("Expected composite primary key identity to be a plain object.")
19
+ }
20
+
21
+ const valueKeys = Object.keys(value)
22
+
23
+ if (valueKeys.length !== primaryKey.length || primaryKey.some((key) => !Object.prototype.hasOwnProperty.call(value, key))) {
24
+ throw new TypeError(`Expected composite primary key identity fields: ${primaryKey.join(", ")}.`)
25
+ }
26
+
27
+ /** @type {CompositeModelPrimaryKeyValue} */
28
+ const validatedValue = {}
29
+
30
+ for (const key of primaryKey) {
31
+ const keyValue = value[key]
32
+
33
+ if (typeof keyValue !== "string" && typeof keyValue !== "number") {
34
+ throw new TypeError(`Expected composite primary key identity field '${key}' to be a string or number.`)
35
+ }
36
+
37
+ validatedValue[key] = keyValue
38
+ }
39
+
40
+ return validatedValue
41
+ }
42
+
43
+ /**
44
+ * Returns a scalar primary-key definition or fails at a feature boundary that cannot represent composite identities.
45
+ * @param {ModelPrimaryKeyDefinition} primaryKey - Primary-key definition.
46
+ * @param {string} operation - Operation requiring a scalar identity.
47
+ * @returns {string} - Scalar primary-key column or attribute name.
48
+ */
49
+ export function scalarModelPrimaryKey(primaryKey, operation) {
50
+ if (Array.isArray(primaryKey)) {
51
+ throw new Error(`${operation} does not support composite primary keys.`)
52
+ }
53
+
54
+ return primaryKey
55
+ }
56
+
57
+ /**
58
+ * Returns a scalar identity or fails at a feature boundary that cannot represent composite identities.
59
+ * @param {ModelPrimaryKeyValue} value - Model identity.
60
+ * @param {string} operation - Operation requiring a scalar identity.
61
+ * @returns {ModelPrimaryKeyScalar} - Scalar identity.
62
+ */
63
+ export function scalarModelPrimaryKeyValue(value, operation) {
64
+ if (typeof value !== "string" && typeof value !== "number") {
65
+ throw new Error(`${operation} does not support composite primary keys.`)
66
+ }
67
+
68
+ return value
69
+ }
70
+
71
+ /**
72
+ * Builds query conditions from a scalar or composite model identity.
73
+ * @param {ModelPrimaryKeyDefinition} primaryKey - Primary-key definition.
74
+ * @param {ReturnType<typeof JSON.parse>} value - Candidate identity.
75
+ * @returns {Record<string, ModelPrimaryKeyScalar>} - Primary-key query conditions.
76
+ */
77
+ export function modelPrimaryKeyConditions(primaryKey, value) {
78
+ if (Array.isArray(primaryKey)) return validatedCompositePrimaryKeyValue(primaryKey, value)
79
+
80
+ return {[primaryKey]: /** @type {ModelPrimaryKeyScalar} */ (value)}
81
+ }
82
+
83
+ /**
84
+ * Builds a qualified SQL predicate matching any supplied composite identity.
85
+ * @param {object} args - Arguments.
86
+ * @param {typeof import("../database/record/index.js").default} args.modelClass - Model class owning the identity attributes.
87
+ * @param {string[]} args.primaryKey - Composite primary-key definition.
88
+ * @param {import("../database/query/model-class-query.js").default<typeof import("../database/record/index.js").default>} args.query - Query receiving the predicate.
89
+ * @param {ModelPrimaryKeyValue[]} args.values - Candidate identities.
90
+ * @returns {string} - Qualified SQL predicate.
91
+ */
92
+ export function compositeModelPrimaryKeyCohortSql({modelClass, primaryKey, query, values}) {
93
+ if (values.length === 0) return "(1 = 0)"
94
+
95
+ const tableSql = query.driver.quoteTable(query.getTableReferenceForJoin())
96
+
97
+ return `(${values.map((value) => {
98
+ const conditions = modelPrimaryKeyConditions(primaryKey, value)
99
+ const identitySql = primaryKey.map((attributeName) => {
100
+ const columnName = modelClass.getColumnNameForAttributeName(attributeName)
101
+
102
+ return `${tableSql}.${query.driver.quoteColumn(columnName)} = ${query.driver.quote(conditions[attributeName])}`
103
+ }).join(" AND ")
104
+
105
+ return `(${identitySql})`
106
+ }).join(" OR ")})`
107
+ }
108
+
109
+ /**
110
+ * Reads a scalar or composite identity through the owning model's value reader.
111
+ * @param {ModelPrimaryKeyDefinition} primaryKey - Primary-key definition.
112
+ * @param {(key: string) => ReturnType<typeof JSON.parse>} read - Primary-key value reader.
113
+ * @returns {ModelPrimaryKeyValue} - Model identity.
114
+ */
115
+ export function readModelPrimaryKeyValue(primaryKey, read) {
116
+ if (!Array.isArray(primaryKey)) return /** @type {ModelPrimaryKeyScalar} */ (read(primaryKey))
117
+
118
+ /** @type {CompositeModelPrimaryKeyValue} */
119
+ const value = {}
120
+
121
+ for (const key of primaryKey) value[key] = /** @type {ModelPrimaryKeyScalar} */ (read(key))
122
+
123
+ return validatedCompositePrimaryKeyValue(primaryKey, value)
124
+ }
125
+
126
+ /**
127
+ * Returns an unambiguous map key while preserving legacy scalar map keys.
128
+ * @param {ModelPrimaryKeyDefinition} primaryKey - Primary-key definition.
129
+ * @param {ReturnType<typeof JSON.parse>} value - Candidate identity.
130
+ * @returns {string} - Canonical identity key.
131
+ */
132
+ export function modelPrimaryKeyCacheKey(primaryKey, value) {
133
+ if (!Array.isArray(primaryKey)) return String(value)
134
+
135
+ const validatedValue = validatedCompositePrimaryKeyValue(primaryKey, value)
136
+
137
+ return JSON.stringify(primaryKey.map((key) => validatedValue[key]))
138
+ }
139
+
140
+ /**
141
+ * Restores a model identity from its canonical string representation.
142
+ * @param {ModelPrimaryKeyDefinition} primaryKey - Primary-key definition.
143
+ * @param {string} cacheKey - Canonical identity key.
144
+ * @returns {ModelPrimaryKeyValue} - Restored identity.
145
+ */
146
+ export function modelPrimaryKeyValueFromCacheKey(primaryKey, cacheKey) {
147
+ if (!Array.isArray(primaryKey)) return cacheKey
148
+
149
+ let parsed
150
+
151
+ try {
152
+ parsed = JSON.parse(cacheKey)
153
+ } catch (error) {
154
+ if (!(error instanceof SyntaxError)) throw error
155
+
156
+ throw new TypeError("Expected composite primary key cache value to be valid JSON.", {cause: error})
157
+ }
158
+
159
+ if (!Array.isArray(parsed) || parsed.length !== primaryKey.length) {
160
+ throw new TypeError(`Expected composite primary key cache value with ${primaryKey.length} fields.`)
161
+ }
162
+
163
+ /** @type {CompositeModelPrimaryKeyValue} */
164
+ const value = {}
165
+
166
+ for (let index = 0; index < primaryKey.length; index += 1) {
167
+ value[primaryKey[index]] = parsed[index]
168
+ }
169
+
170
+ return validatedCompositePrimaryKeyValue(primaryKey, value)
171
+ }
@@ -1,9 +0,0 @@
1
- import { defaultTestContext } from "@velocious/testing";
2
- export type TestingPackageSuite = (typeof defaultTestContext.registry.suites)[number];
3
- /**
4
- * Makes newly imported public-package suites visible to the Velocious runner.
5
- * @param {import("./test-runner.js").TestsArgument} tests - Velocious root test tree.
6
- * @returns {void}
7
- */
8
- export declare function synchronizeTestingPackageTests(tests: import("./test-runner.js").TestsArgument): void;
9
- //# sourceMappingURL=testing-package-adapter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"testing-package-adapter.d.ts","sourceRoot":"","sources":["../../../src/testing/testing-package-adapter.js"],"names":[],"mappings":"AAEA,OAAO,EAAC,kBAAkB,EAAC,MAAM,oBAAoB,CAAA;AAEjD,YAA+D,mBAAmB,GAAxE,CAAC,OAAO,kBAAkB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAqB;AA0DtF;;;;GAIG;AACH,wBAAgB,8BAA8B,CAAC,KAAK,EAHzC,OAAO,kBAAkB,EAAE,aAGc,GAFvC,IAAI,CAUhB"}
@@ -1,69 +0,0 @@
1
- // @ts-check
2
- import { defaultTestContext } from "@velocious/testing";
3
- /** @typedef {(typeof defaultTestContext.registry.suites)[number]} TestingPackageSuite */
4
- /** @type {WeakSet<TestingPackageSuite>} */
5
- const synchronizedSuites = new WeakSet();
6
- /**
7
- * Converts public-package declaration options to the legacy runner contract.
8
- * @param {TestingPackageSuite["options"]} options - Public declaration options.
9
- * @returns {import("./test-runner.js").TestArgs} - Velocious runner arguments.
10
- */
11
- function runnerArguments(options) {
12
- const args = { ...options };
13
- if (args.retry === undefined && typeof args.retries === "number")
14
- args.retry = args.retries;
15
- if (args.timeoutSeconds === undefined && typeof args.timeoutMs === "number") {
16
- args.timeoutSeconds = args.timeoutMs / 1000;
17
- }
18
- return args;
19
- }
20
- /**
21
- * Converts one public package suite to the Velocious runner's tree shape.
22
- * @param {TestingPackageSuite} suite - Public suite declaration.
23
- * @param {import("./test-runner.js").TestArgs} inheritedArgs - Arguments inherited from the parent scope.
24
- * @returns {import("./test-runner.js").TestsArgument} - Velocious test tree.
25
- */
26
- function runnerSuite(suite, inheritedArgs) {
27
- /** @type {Record<string, import("./test-runner.js").TestData>} */
28
- const suiteTests = {};
29
- /** @type {Record<string, import("./test-runner.js").TestsArgument>} */
30
- const nestedSuites = {};
31
- const suiteArgs = { ...inheritedArgs, ...runnerArguments(suite.options) };
32
- for (const test of suite.tests) {
33
- suiteTests[test.name] = {
34
- args: { ...suiteArgs, ...runnerArguments(test.options) },
35
- filePath: test.location.filePath,
36
- function: test.callback,
37
- line: test.location.line
38
- };
39
- }
40
- for (const nestedSuite of suite.suites)
41
- nestedSuites[nestedSuite.name] = runnerSuite(nestedSuite, suiteArgs);
42
- return {
43
- afterAlls: suite.hooks.afterAll.map((hook) => ({ callback: hook.callback })),
44
- afterEaches: suite.hooks.afterEach.map((hook) => ({ callback: hook.callback })),
45
- args: suiteArgs,
46
- beforeAlls: suite.hooks.beforeAll.map((hook) => ({ callback: hook.callback })),
47
- beforeEaches: suite.hooks.beforeEach.map((hook) => ({ callback: hook.callback })),
48
- filePath: suite.location.filePath,
49
- line: suite.location.line,
50
- subs: nestedSuites,
51
- tests: suiteTests
52
- };
53
- }
54
- /**
55
- * Makes newly imported public-package suites visible to the Velocious runner.
56
- * @param {import("./test-runner.js").TestsArgument} tests - Velocious root test tree.
57
- * @returns {void}
58
- */
59
- export function synchronizeTestingPackageTests(tests) {
60
- for (const suite of defaultTestContext.registry.suites) {
61
- if (synchronizedSuites.has(suite))
62
- continue;
63
- if (tests.subs[suite.name])
64
- throw new Error(`Duplicate test description: ${suite.name}`);
65
- tests.subs[suite.name] = runnerSuite(suite, tests.args);
66
- synchronizedSuites.add(suite);
67
- }
68
- }
69
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdGluZy1wYWNrYWdlLWFkYXB0ZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvdGVzdGluZy90ZXN0aW5nLXBhY2thZ2UtYWRhcHRlci5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxZQUFZO0FBRVosT0FBTyxFQUFDLGtCQUFrQixFQUFDLE1BQU0sb0JBQW9CLENBQUE7QUFFckQseUZBQXlGO0FBRXpGLDJDQUEyQztBQUMzQyxNQUFNLGtCQUFrQixHQUFHLElBQUksT0FBTyxFQUFFLENBQUE7QUFFeEM7Ozs7R0FJRztBQUNILFNBQVMsZUFBZSxDQUFDLE9BQU87SUFDOUIsTUFBTSxJQUFJLEdBQUcsRUFBQyxHQUFHLE9BQU8sRUFBQyxDQUFBO0lBRXpCLElBQUksSUFBSSxDQUFDLEtBQUssS0FBSyxTQUFTLElBQUksT0FBTyxJQUFJLENBQUMsT0FBTyxLQUFLLFFBQVE7UUFBRSxJQUFJLENBQUMsS0FBSyxHQUFHLElBQUksQ0FBQyxPQUFPLENBQUE7SUFDM0YsSUFBSSxJQUFJLENBQUMsY0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3JpcHRpb246ICR7c3VpdGUubmFtZX1gKVxuXG4gICAgdGVzdHMuc3Vic1tzdWl0ZS5uYW1lXSA9IHJ1bm5lclN1aXRlKHN1aXRlLCB0ZXN0cy5hcmdzKVxuICAgIHN5bmNocm9uaXplZFN1aXRlcy5hZGQoc3VpdGUpXG4gIH1cbn1cbiJdfQ==
@@ -1,76 +0,0 @@
1
- // @ts-check
2
-
3
- import {defaultTestContext} from "@velocious/testing"
4
-
5
- /** @typedef {(typeof defaultTestContext.registry.suites)[number]} TestingPackageSuite */
6
-
7
- /** @type {WeakSet<TestingPackageSuite>} */
8
- const synchronizedSuites = new WeakSet()
9
-
10
- /**
11
- * Converts public-package declaration options to the legacy runner contract.
12
- * @param {TestingPackageSuite["options"]} options - Public declaration options.
13
- * @returns {import("./test-runner.js").TestArgs} - Velocious runner arguments.
14
- */
15
- function runnerArguments(options) {
16
- const args = {...options}
17
-
18
- if (args.retry === undefined && typeof args.retries === "number") args.retry = args.retries
19
- if (args.timeoutSeconds === undefined && typeof args.timeoutMs === "number") {
20
- args.timeoutSeconds = args.timeoutMs / 1000
21
- }
22
-
23
- return args
24
- }
25
-
26
- /**
27
- * Converts one public package suite to the Velocious runner's tree shape.
28
- * @param {TestingPackageSuite} suite - Public suite declaration.
29
- * @param {import("./test-runner.js").TestArgs} inheritedArgs - Arguments inherited from the parent scope.
30
- * @returns {import("./test-runner.js").TestsArgument} - Velocious test tree.
31
- */
32
- function runnerSuite(suite, inheritedArgs) {
33
- /** @type {Record<string, import("./test-runner.js").TestData>} */
34
- const suiteTests = {}
35
- /** @type {Record<string, import("./test-runner.js").TestsArgument>} */
36
- const nestedSuites = {}
37
- const suiteArgs = {...inheritedArgs, ...runnerArguments(suite.options)}
38
-
39
- for (const test of suite.tests) {
40
- suiteTests[test.name] = {
41
- args: {...suiteArgs, ...runnerArguments(test.options)},
42
- filePath: test.location.filePath,
43
- function: test.callback,
44
- line: test.location.line
45
- }
46
- }
47
-
48
- for (const nestedSuite of suite.suites) nestedSuites[nestedSuite.name] = runnerSuite(nestedSuite, suiteArgs)
49
-
50
- return {
51
- afterAlls: suite.hooks.afterAll.map((hook) => ({callback: hook.callback})),
52
- afterEaches: suite.hooks.afterEach.map((hook) => ({callback: hook.callback})),
53
- args: suiteArgs,
54
- beforeAlls: suite.hooks.beforeAll.map((hook) => ({callback: hook.callback})),
55
- beforeEaches: suite.hooks.beforeEach.map((hook) => ({callback: hook.callback})),
56
- filePath: suite.location.filePath,
57
- line: suite.location.line,
58
- subs: nestedSuites,
59
- tests: suiteTests
60
- }
61
- }
62
-
63
- /**
64
- * Makes newly imported public-package suites visible to the Velocious runner.
65
- * @param {import("./test-runner.js").TestsArgument} tests - Velocious root test tree.
66
- * @returns {void}
67
- */
68
- export function synchronizeTestingPackageTests(tests) {
69
- for (const suite of defaultTestContext.registry.suites) {
70
- if (synchronizedSuites.has(suite)) continue
71
- if (tests.subs[suite.name]) throw new Error(`Duplicate test description: ${suite.name}`)
72
-
73
- tests.subs[suite.name] = runnerSuite(suite, tests.args)
74
- synchronizedSuites.add(suite)
75
- }
76
- }
@@ -1,76 +0,0 @@
1
- // @ts-check
2
-
3
- import {defaultTestContext} from "@velocious/testing"
4
-
5
- /** @typedef {(typeof defaultTestContext.registry.suites)[number]} TestingPackageSuite */
6
-
7
- /** @type {WeakSet<TestingPackageSuite>} */
8
- const synchronizedSuites = new WeakSet()
9
-
10
- /**
11
- * Converts public-package declaration options to the legacy runner contract.
12
- * @param {TestingPackageSuite["options"]} options - Public declaration options.
13
- * @returns {import("./test-runner.js").TestArgs} - Velocious runner arguments.
14
- */
15
- function runnerArguments(options) {
16
- const args = {...options}
17
-
18
- if (args.retry === undefined && typeof args.retries === "number") args.retry = args.retries
19
- if (args.timeoutSeconds === undefined && typeof args.timeoutMs === "number") {
20
- args.timeoutSeconds = args.timeoutMs / 1000
21
- }
22
-
23
- return args
24
- }
25
-
26
- /**
27
- * Converts one public package suite to the Velocious runner's tree shape.
28
- * @param {TestingPackageSuite} suite - Public suite declaration.
29
- * @param {import("./test-runner.js").TestArgs} inheritedArgs - Arguments inherited from the parent scope.
30
- * @returns {import("./test-runner.js").TestsArgument} - Velocious test tree.
31
- */
32
- function runnerSuite(suite, inheritedArgs) {
33
- /** @type {Record<string, import("./test-runner.js").TestData>} */
34
- const suiteTests = {}
35
- /** @type {Record<string, import("./test-runner.js").TestsArgument>} */
36
- const nestedSuites = {}
37
- const suiteArgs = {...inheritedArgs, ...runnerArguments(suite.options)}
38
-
39
- for (const test of suite.tests) {
40
- suiteTests[test.name] = {
41
- args: {...suiteArgs, ...runnerArguments(test.options)},
42
- filePath: test.location.filePath,
43
- function: test.callback,
44
- line: test.location.line
45
- }
46
- }
47
-
48
- for (const nestedSuite of suite.suites) nestedSuites[nestedSuite.name] = runnerSuite(nestedSuite, suiteArgs)
49
-
50
- return {
51
- afterAlls: suite.hooks.afterAll.map((hook) => ({callback: hook.callback})),
52
- afterEaches: suite.hooks.afterEach.map((hook) => ({callback: hook.callback})),
53
- args: suiteArgs,
54
- beforeAlls: suite.hooks.beforeAll.map((hook) => ({callback: hook.callback})),
55
- beforeEaches: suite.hooks.beforeEach.map((hook) => ({callback: hook.callback})),
56
- filePath: suite.location.filePath,
57
- line: suite.location.line,
58
- subs: nestedSuites,
59
- tests: suiteTests
60
- }
61
- }
62
-
63
- /**
64
- * Makes newly imported public-package suites visible to the Velocious runner.
65
- * @param {import("./test-runner.js").TestsArgument} tests - Velocious root test tree.
66
- * @returns {void}
67
- */
68
- export function synchronizeTestingPackageTests(tests) {
69
- for (const suite of defaultTestContext.registry.suites) {
70
- if (synchronizedSuites.has(suite)) continue
71
- if (tests.subs[suite.name]) throw new Error(`Duplicate test description: ${suite.name}`)
72
-
73
- tests.subs[suite.name] = runnerSuite(suite, tests.args)
74
- synchronizedSuites.add(suite)
75
- }
76
- }