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.
- package/README.md +11 -9
- package/build/authorization/ability.js +36 -13
- package/build/background-jobs/adapter.js +9 -0
- package/build/background-jobs/main.js +35 -10
- package/build/background-jobs/store.js +217 -38
- package/build/background-jobs/types.js +15 -0
- package/build/configuration-types.js +1 -1
- package/build/configuration.js +45 -9
- package/build/database/drivers/base-column.js +8 -0
- package/build/database/drivers/mssql/sql/update.js +1 -3
- package/build/database/drivers/mysql/sql/update.js +1 -3
- package/build/database/drivers/pgsql/column.js +22 -0
- package/build/database/drivers/pgsql/sql/update.js +1 -3
- package/build/database/drivers/sqlite/sql/alter-table.js +11 -1
- package/build/database/drivers/sqlite/sql/update.js +1 -3
- package/build/database/query/index.js +2 -2
- package/build/database/query/model-class-query.js +26 -10
- package/build/database/query/preloader/has-many.js +4 -1
- package/build/database/query/query-data.js +2 -1
- package/build/database/query/update-base.js +14 -0
- package/build/database/query/with-count.js +3 -1
- package/build/database/record/acts-as-list.js +37 -13
- package/build/database/record/attachments/store.js +336 -26
- package/build/database/record/auditing.js +6 -3
- package/build/database/record/index.js +197 -42
- package/build/database/record/instance-relationships/belongs-to.js +2 -1
- package/build/database/record/validators/uniqueness.js +8 -5
- package/build/environment-handlers/node/cli/commands/generate/frontend-models.js +24 -8
- package/build/frontend-model-controller.js +136 -53
- package/build/frontend-model-resource/base-resource.js +87 -37
- package/build/frontend-model-resource/velocious-attachment-resource.js +98 -31
- package/build/frontend-models/base.js +307 -59
- package/build/frontend-models/preloader.js +6 -3
- package/build/frontend-models/query.js +15 -6
- package/build/frontend-models/resource-definition.js +21 -2
- package/build/frontend-models/use-destroyed-event.js +1 -1
- package/build/frontend-models/use-model-class-event.js +2 -2
- package/build/frontend-models/use-updated-event.js +1 -1
- package/build/frontend-models/websocket-channel.js +256 -93
- package/build/frontend-models/websocket-publishers.js +218 -18
- package/build/http-server/client/websocket-session.js +13 -1
- package/build/http-server/websocket-channel.js +15 -2
- package/build/src/authorization/ability.d.ts +9 -3
- package/build/src/authorization/ability.d.ts.map +1 -1
- package/build/src/authorization/ability.js +33 -14
- package/build/src/background-jobs/adapter.d.ts +6 -0
- package/build/src/background-jobs/adapter.d.ts.map +1 -1
- package/build/src/background-jobs/adapter.js +9 -1
- package/build/src/background-jobs/main.d.ts +6 -0
- package/build/src/background-jobs/main.d.ts.map +1 -1
- package/build/src/background-jobs/main.js +34 -11
- package/build/src/background-jobs/store.d.ts +66 -12
- package/build/src/background-jobs/store.d.ts.map +1 -1
- package/build/src/background-jobs/store.js +191 -35
- package/build/src/background-jobs/types.d.ts +55 -0
- package/build/src/background-jobs/types.d.ts.map +1 -1
- package/build/src/background-jobs/types.js +16 -1
- package/build/src/configuration-types.d.ts +3 -3
- package/build/src/configuration-types.d.ts.map +1 -1
- package/build/src/configuration-types.js +2 -2
- package/build/src/configuration.d.ts +18 -8
- package/build/src/configuration.d.ts.map +1 -1
- package/build/src/configuration.js +38 -7
- package/build/src/database/drivers/base-column.d.ts +5 -0
- package/build/src/database/drivers/base-column.d.ts.map +1 -1
- package/build/src/database/drivers/base-column.js +8 -1
- package/build/src/database/drivers/mssql/sql/update.d.ts.map +1 -1
- package/build/src/database/drivers/mssql/sql/update.js +2 -4
- package/build/src/database/drivers/mysql/sql/update.d.ts.map +1 -1
- package/build/src/database/drivers/mysql/sql/update.js +2 -4
- package/build/src/database/drivers/pgsql/column.d.ts +5 -0
- package/build/src/database/drivers/pgsql/column.d.ts.map +1 -1
- package/build/src/database/drivers/pgsql/column.js +19 -1
- package/build/src/database/drivers/pgsql/sql/update.d.ts.map +1 -1
- package/build/src/database/drivers/pgsql/sql/update.js +2 -4
- package/build/src/database/drivers/sqlite/sql/alter-table.d.ts.map +1 -1
- package/build/src/database/drivers/sqlite/sql/alter-table.js +6 -2
- package/build/src/database/drivers/sqlite/sql/update.d.ts.map +1 -1
- package/build/src/database/drivers/sqlite/sql/update.js +2 -4
- package/build/src/database/query/index.d.ts +4 -4
- package/build/src/database/query/index.d.ts.map +1 -1
- package/build/src/database/query/index.js +3 -3
- package/build/src/database/query/model-class-query.d.ts +8 -2
- package/build/src/database/query/model-class-query.d.ts.map +1 -1
- package/build/src/database/query/model-class-query.js +25 -11
- package/build/src/database/query/preloader/has-many.d.ts.map +1 -1
- package/build/src/database/query/preloader/has-many.js +4 -2
- package/build/src/database/query/query-data.d.ts.map +1 -1
- package/build/src/database/query/query-data.js +3 -2
- package/build/src/database/query/update-base.d.ts +7 -0
- package/build/src/database/query/update-base.d.ts.map +1 -1
- package/build/src/database/query/update-base.js +13 -1
- package/build/src/database/query/with-count.d.ts.map +1 -1
- package/build/src/database/query/with-count.js +3 -2
- package/build/src/database/record/acts-as-list.d.ts.map +1 -1
- package/build/src/database/record/acts-as-list.js +35 -14
- package/build/src/database/record/attachments/store.d.ts +67 -0
- package/build/src/database/record/attachments/store.d.ts.map +1 -1
- package/build/src/database/record/attachments/store.js +301 -25
- package/build/src/database/record/auditing.d.ts.map +1 -1
- package/build/src/database/record/auditing.js +7 -4
- package/build/src/database/record/index.d.ts +78 -26
- package/build/src/database/record/index.d.ts.map +1 -1
- package/build/src/database/record/index.js +171 -42
- package/build/src/database/record/instance-relationships/belongs-to.d.ts.map +1 -1
- package/build/src/database/record/instance-relationships/belongs-to.js +3 -2
- package/build/src/database/record/validators/uniqueness.d.ts.map +1 -1
- package/build/src/database/record/validators/uniqueness.js +8 -6
- package/build/src/environment-handlers/node/cli/commands/generate/frontend-models.d.ts +4 -4
- package/build/src/environment-handlers/node/cli/commands/generate/frontend-models.d.ts.map +1 -1
- package/build/src/environment-handlers/node/cli/commands/generate/frontend-models.js +24 -12
- package/build/src/frontend-model-controller.d.ts +29 -8
- package/build/src/frontend-model-controller.d.ts.map +1 -1
- package/build/src/frontend-model-controller.js +122 -51
- package/build/src/frontend-model-resource/base-resource.d.ts +51 -24
- package/build/src/frontend-model-resource/base-resource.d.ts.map +1 -1
- package/build/src/frontend-model-resource/base-resource.js +83 -37
- package/build/src/frontend-model-resource/velocious-attachment-resource.d.ts +45 -26
- package/build/src/frontend-model-resource/velocious-attachment-resource.d.ts.map +1 -1
- package/build/src/frontend-model-resource/velocious-attachment-resource.js +89 -31
- package/build/src/frontend-models/base.d.ts +53 -20
- package/build/src/frontend-models/base.d.ts.map +1 -1
- package/build/src/frontend-models/base.js +275 -59
- package/build/src/frontend-models/preloader.d.ts.map +1 -1
- package/build/src/frontend-models/preloader.js +6 -4
- package/build/src/frontend-models/query.d.ts +2 -2
- package/build/src/frontend-models/query.d.ts.map +1 -1
- package/build/src/frontend-models/query.js +14 -7
- package/build/src/frontend-models/resource-definition.d.ts.map +1 -1
- package/build/src/frontend-models/resource-definition.js +20 -3
- package/build/src/frontend-models/use-destroyed-event.d.ts +1 -1
- package/build/src/frontend-models/use-destroyed-event.d.ts.map +1 -1
- package/build/src/frontend-models/use-destroyed-event.js +2 -2
- package/build/src/frontend-models/use-model-class-event.d.ts +2 -2
- package/build/src/frontend-models/use-model-class-event.d.ts.map +1 -1
- package/build/src/frontend-models/use-model-class-event.js +3 -3
- package/build/src/frontend-models/use-updated-event.d.ts +1 -1
- package/build/src/frontend-models/use-updated-event.d.ts.map +1 -1
- package/build/src/frontend-models/use-updated-event.js +2 -2
- package/build/src/frontend-models/websocket-channel.d.ts +60 -41
- package/build/src/frontend-models/websocket-channel.d.ts.map +1 -1
- package/build/src/frontend-models/websocket-channel.js +225 -85
- package/build/src/frontend-models/websocket-publishers.d.ts +9 -0
- package/build/src/frontend-models/websocket-publishers.d.ts.map +1 -1
- package/build/src/frontend-models/websocket-publishers.js +190 -19
- package/build/src/http-server/client/websocket-session.d.ts.map +1 -1
- package/build/src/http-server/client/websocket-session.js +11 -2
- package/build/src/http-server/websocket-channel.d.ts +20 -8
- package/build/src/http-server/websocket-channel.d.ts.map +1 -1
- package/build/src/http-server/websocket-channel.js +15 -3
- package/build/src/sync/sync-api-client.d.ts.map +1 -1
- package/build/src/sync/sync-api-client.js +4 -3
- package/build/src/sync/sync-client.d.ts.map +1 -1
- package/build/src/sync/sync-client.js +3 -2
- package/build/src/sync/sync-envelope-replay-service.d.ts.map +1 -1
- package/build/src/sync/sync-envelope-replay-service.js +6 -5
- package/build/src/sync/sync-publisher.d.ts.map +1 -1
- package/build/src/sync/sync-publisher.js +4 -3
- package/build/src/testing/browser-frontend-model-event-hook-scenarios.d.ts +2 -2
- package/build/src/testing/browser-frontend-model-event-hook-scenarios.d.ts.map +1 -1
- package/build/src/testing/browser-frontend-model-event-hook-scenarios.js +3 -3
- package/build/src/testing/test-profiler.d.ts +4 -4
- package/build/src/testing/test-profiler.d.ts.map +1 -1
- package/build/src/testing/test-profiler.js +3 -3
- package/build/src/testing/test-runner.d.ts +271 -117
- package/build/src/testing/test-runner.d.ts.map +1 -1
- package/build/src/testing/test-runner.js +496 -427
- package/build/src/testing/test.d.ts +11 -72
- package/build/src/testing/test.d.ts.map +1 -1
- package/build/src/testing/test.js +131 -284
- package/build/src/testing/velocious-attempt-executor.d.ts +14 -29
- package/build/src/testing/velocious-attempt-executor.d.ts.map +1 -1
- package/build/src/testing/velocious-attempt-executor.js +52 -46
- package/build/src/testing/velocious-runner-reporter.d.ts +29 -34
- package/build/src/testing/velocious-runner-reporter.d.ts.map +1 -1
- package/build/src/testing/velocious-runner-reporter.js +145 -57
- package/build/src/testing/velocious-suite-hook-executor.d.ts +5 -23
- package/build/src/testing/velocious-suite-hook-executor.d.ts.map +1 -1
- package/build/src/testing/velocious-suite-hook-executor.js +22 -47
- package/build/src/testing/velocious-test-arguments.d.ts +11 -6
- package/build/src/testing/velocious-test-arguments.d.ts.map +1 -1
- package/build/src/testing/velocious-test-arguments.js +18 -10
- package/build/src/utils/model-primary-key.d.ts +73 -0
- package/build/src/utils/model-primary-key.d.ts.map +1 -0
- package/build/src/utils/model-primary-key.js +144 -0
- package/build/sync/sync-api-client.js +3 -2
- package/build/sync/sync-client.js +2 -1
- package/build/sync/sync-envelope-replay-service.js +5 -4
- package/build/sync/sync-publisher.js +3 -2
- package/build/testing/browser-frontend-model-event-hook-scenarios.js +2 -2
- package/build/testing/test-profiler.js +2 -2
- package/build/testing/test-runner.js +493 -449
- package/build/testing/test.js +164 -306
- package/build/testing/velocious-attempt-executor.js +55 -45
- package/build/testing/velocious-runner-reporter.js +156 -58
- package/build/testing/velocious-suite-hook-executor.js +22 -50
- package/build/testing/velocious-test-arguments.js +19 -10
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/utils/model-primary-key.js +171 -0
- package/package.json +5 -4
- package/src/authorization/ability.js +36 -13
- package/src/background-jobs/adapter.js +9 -0
- package/src/background-jobs/main.js +35 -10
- package/src/background-jobs/store.js +217 -38
- package/src/background-jobs/types.js +15 -0
- package/src/configuration-types.js +1 -1
- package/src/configuration.js +45 -9
- package/src/database/drivers/base-column.js +8 -0
- package/src/database/drivers/mssql/sql/update.js +1 -3
- package/src/database/drivers/mysql/sql/update.js +1 -3
- package/src/database/drivers/pgsql/column.js +22 -0
- package/src/database/drivers/pgsql/sql/update.js +1 -3
- package/src/database/drivers/sqlite/sql/alter-table.js +11 -1
- package/src/database/drivers/sqlite/sql/update.js +1 -3
- package/src/database/query/index.js +2 -2
- package/src/database/query/model-class-query.js +26 -10
- package/src/database/query/preloader/has-many.js +4 -1
- package/src/database/query/query-data.js +2 -1
- package/src/database/query/update-base.js +14 -0
- package/src/database/query/with-count.js +3 -1
- package/src/database/record/acts-as-list.js +37 -13
- package/src/database/record/attachments/store.js +336 -26
- package/src/database/record/auditing.js +6 -3
- package/src/database/record/index.js +197 -42
- package/src/database/record/instance-relationships/belongs-to.js +2 -1
- package/src/database/record/validators/uniqueness.js +8 -5
- package/src/environment-handlers/node/cli/commands/generate/frontend-models.js +24 -8
- package/src/frontend-model-controller.js +136 -53
- package/src/frontend-model-resource/base-resource.js +87 -37
- package/src/frontend-model-resource/velocious-attachment-resource.js +98 -31
- package/src/frontend-models/base.js +307 -59
- package/src/frontend-models/preloader.js +6 -3
- package/src/frontend-models/query.js +15 -6
- package/src/frontend-models/resource-definition.js +21 -2
- package/src/frontend-models/use-destroyed-event.js +1 -1
- package/src/frontend-models/use-model-class-event.js +2 -2
- package/src/frontend-models/use-updated-event.js +1 -1
- package/src/frontend-models/websocket-channel.js +256 -93
- package/src/frontend-models/websocket-publishers.js +218 -18
- package/src/http-server/client/websocket-session.js +13 -1
- package/src/http-server/websocket-channel.js +15 -2
- package/src/sync/sync-api-client.js +3 -2
- package/src/sync/sync-client.js +2 -1
- package/src/sync/sync-envelope-replay-service.js +5 -4
- package/src/sync/sync-publisher.js +3 -2
- package/src/testing/browser-frontend-model-event-hook-scenarios.js +2 -2
- package/src/testing/test-profiler.js +2 -2
- package/src/testing/test-runner.js +493 -449
- package/src/testing/test.js +164 -306
- package/src/testing/velocious-attempt-executor.js +55 -45
- package/src/testing/velocious-runner-reporter.js +156 -58
- package/src/testing/velocious-suite-hook-executor.js +22 -50
- package/src/testing/velocious-test-arguments.js +19 -10
- package/src/utils/model-primary-key.js +171 -0
- package/build/src/testing/testing-package-adapter.d.ts +0 -9
- package/build/src/testing/testing-package-adapter.d.ts.map +0 -1
- package/build/src/testing/testing-package-adapter.js +0 -69
- package/build/testing/testing-package-adapter.js +0 -76
- 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
|
-
*
|
|
21
|
-
* @param {
|
|
22
|
-
* @
|
|
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
|
|
25
|
-
const
|
|
26
|
+
async resolve({test}) {
|
|
27
|
+
const compatibility = await this.testRunner.testCompatibility(test)
|
|
26
28
|
|
|
27
|
-
|
|
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 {
|
|
34
|
+
* @param {PackageTestDeclaration} testData - Test registration.
|
|
35
35
|
* @returns {TestArgs} - Independent test arguments.
|
|
36
36
|
*/
|
|
37
37
|
copy(testData) {
|
|
38
|
-
|
|
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdGluZy1wYWNrYWdlLWFkYXB0ZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvdGVzdGluZy90ZXN0aW5nLXBhY2thZ2UtYWRhcHRlci5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxZQUFZO0FBRVosT0FBTyxFQUFDLGtCQUFrQixFQUFDLE1BQU0sb0JBQW9CLENBQUE7QUFFckQseUZBQXlGO0FBRXpGLDJDQUEyQztBQUMzQyxNQUFNLGtCQUFrQixHQUFHLElBQUksT0FBTyxFQUFFLENBQUE7QUFFeEM7Ozs7R0FJRztBQUNILFNBQVMsZUFBZSxDQUFDLE9BQU87SUFDOUIsTUFBTS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IgKGNvbnN0IHN1aXRlIG9mIGRlZmF1bHRUZXN0Q29udGV4dC5yZWdpc3RyeS5zdWl0ZXMpIHtcbiAgICBpZiAoc3luY2hyb25pemVkU3VpdGVzLmhhcyhzdWl0ZSkpIGNvbnRpbnVlXG4gICAgaWYgKHRlc3RzLnN1YnNbc3VpdGUubmFtZV0pIHRocm93IG5ldyBFcnJvcihgRHVwbGljYXRlIHRlc3QgZGVzY3JpcHRpb246ICR7c3VpdGUubmFtZX1gKVxuXG4gICAgdGVzdHMuc3Vic1tzdWl0ZS5uYW1lXSA9IHJ1bm5lclN1aXRlKHN1aXRlLCB0ZXN0cy5hcmdzKVxuICAgIHN5bmNocm9uaXplZFN1aXRlcy5hZGQoc3VpdGUpXG4gIH1cbn1cbiJdfQ==
|
|
@@ -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
|
-
}
|