velocious 1.0.666 → 1.0.668

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 (174) hide show
  1. package/README.md +40 -11
  2. package/build/background-jobs/adapter-client.js +22 -0
  3. package/build/background-jobs/adapter.js +15 -0
  4. package/build/background-jobs/client.js +147 -1
  5. package/build/background-jobs/job-semantics.js +30 -0
  6. package/build/background-jobs/job.js +26 -1
  7. package/build/background-jobs/local-adapter.js +36 -8
  8. package/build/background-jobs/local-store.js +410 -39
  9. package/build/background-jobs/main.js +69 -2
  10. package/build/background-jobs/platform-job.js +26 -1
  11. package/build/background-jobs/runtime.js +58 -0
  12. package/build/background-jobs/store.js +374 -6
  13. package/build/background-jobs/types.js +27 -2
  14. package/build/background-jobs/web/controller.js +1 -0
  15. package/build/configuration.js +30 -6
  16. package/build/database/drivers/mssql/column.js +2 -2
  17. package/build/database/drivers/mssql/table.js +19 -5
  18. package/build/database/pool/async-tracked-multi-connection.js +2 -1
  19. package/build/database/query/alter-table-base.js +8 -1
  20. package/build/database/record/attachments/store.js +2 -2
  21. package/build/environment-handlers/node/cli/commands/test/timing-manifest/merge.js +2 -48
  22. package/build/environment-handlers/node/cli/commands/test.js +17 -69
  23. package/build/frontend-model-controller.js +22 -2
  24. package/build/frontend-models/websocket-channel.js +18 -0
  25. package/build/http-server/client/websocket-session.js +41 -4
  26. package/build/http-server/websocket-channel.js +14 -0
  27. package/build/http-server/websocket-event-log-store.js +85 -12
  28. package/build/http-server/websocket-events-host.js +17 -7
  29. package/build/src/background-jobs/adapter-client.d.ts +17 -0
  30. package/build/src/background-jobs/adapter-client.d.ts.map +1 -1
  31. package/build/src/background-jobs/adapter-client.js +19 -1
  32. package/build/src/background-jobs/adapter.d.ts +15 -0
  33. package/build/src/background-jobs/adapter.d.ts.map +1 -1
  34. package/build/src/background-jobs/adapter.js +14 -1
  35. package/build/src/background-jobs/client.d.ts +17 -0
  36. package/build/src/background-jobs/client.d.ts.map +1 -1
  37. package/build/src/background-jobs/client.js +129 -1
  38. package/build/src/background-jobs/job-semantics.d.ts +18 -0
  39. package/build/src/background-jobs/job-semantics.d.ts.map +1 -1
  40. package/build/src/background-jobs/job-semantics.js +28 -1
  41. package/build/src/background-jobs/job.d.ts +15 -0
  42. package/build/src/background-jobs/job.d.ts.map +1 -1
  43. package/build/src/background-jobs/job.js +21 -2
  44. package/build/src/background-jobs/local-adapter.d.ts +23 -8
  45. package/build/src/background-jobs/local-adapter.d.ts.map +1 -1
  46. package/build/src/background-jobs/local-adapter.js +35 -9
  47. package/build/src/background-jobs/local-store.d.ts +120 -5
  48. package/build/src/background-jobs/local-store.d.ts.map +1 -1
  49. package/build/src/background-jobs/local-store.js +366 -40
  50. package/build/src/background-jobs/main.d.ts +24 -2
  51. package/build/src/background-jobs/main.d.ts.map +1 -1
  52. package/build/src/background-jobs/main.js +68 -3
  53. package/build/src/background-jobs/platform-job.d.ts +15 -0
  54. package/build/src/background-jobs/platform-job.d.ts.map +1 -1
  55. package/build/src/background-jobs/platform-job.js +19 -2
  56. package/build/src/background-jobs/runtime.d.ts +39 -0
  57. package/build/src/background-jobs/runtime.d.ts.map +1 -1
  58. package/build/src/background-jobs/runtime.js +49 -1
  59. package/build/src/background-jobs/store.d.ts +100 -1
  60. package/build/src/background-jobs/store.d.ts.map +1 -1
  61. package/build/src/background-jobs/store.js +334 -8
  62. package/build/src/background-jobs/types.d.ts +97 -4
  63. package/build/src/background-jobs/types.d.ts.map +1 -1
  64. package/build/src/background-jobs/types.js +28 -3
  65. package/build/src/background-jobs/web/controller.d.ts.map +1 -1
  66. package/build/src/background-jobs/web/controller.js +2 -1
  67. package/build/src/configuration.d.ts +18 -1
  68. package/build/src/configuration.d.ts.map +1 -1
  69. package/build/src/configuration.js +28 -6
  70. package/build/src/database/drivers/mssql/column.d.ts.map +1 -1
  71. package/build/src/database/drivers/mssql/column.js +2 -2
  72. package/build/src/database/drivers/mssql/table.d.ts.map +1 -1
  73. package/build/src/database/drivers/mssql/table.js +19 -5
  74. package/build/src/database/pool/async-tracked-multi-connection.d.ts.map +1 -1
  75. package/build/src/database/pool/async-tracked-multi-connection.js +3 -2
  76. package/build/src/database/query/alter-table-base.d.ts.map +1 -1
  77. package/build/src/database/query/alter-table-base.js +9 -2
  78. package/build/src/database/record/attachments/store.js +3 -3
  79. package/build/src/environment-handlers/node/cli/commands/test/timing-manifest/merge.d.ts.map +1 -1
  80. package/build/src/environment-handlers/node/cli/commands/test/timing-manifest/merge.js +3 -47
  81. package/build/src/environment-handlers/node/cli/commands/test.d.ts +2 -28
  82. package/build/src/environment-handlers/node/cli/commands/test.d.ts.map +1 -1
  83. package/build/src/environment-handlers/node/cli/commands/test.js +10 -61
  84. package/build/src/frontend-model-controller.d.ts.map +1 -1
  85. package/build/src/frontend-model-controller.js +18 -3
  86. package/build/src/frontend-models/websocket-channel.d.ts +9 -0
  87. package/build/src/frontend-models/websocket-channel.d.ts.map +1 -1
  88. package/build/src/frontend-models/websocket-channel.js +16 -1
  89. package/build/src/http-server/client/websocket-session.d.ts +25 -2
  90. package/build/src/http-server/client/websocket-session.d.ts.map +1 -1
  91. package/build/src/http-server/client/websocket-session.js +40 -5
  92. package/build/src/http-server/websocket-channel.d.ts +11 -0
  93. package/build/src/http-server/websocket-channel.d.ts.map +1 -1
  94. package/build/src/http-server/websocket-channel.js +14 -1
  95. package/build/src/http-server/websocket-event-log-store.d.ts +60 -41
  96. package/build/src/http-server/websocket-event-log-store.d.ts.map +1 -1
  97. package/build/src/http-server/websocket-event-log-store.js +79 -12
  98. package/build/src/http-server/websocket-events-host.d.ts +10 -3
  99. package/build/src/http-server/websocket-events-host.d.ts.map +1 -1
  100. package/build/src/http-server/websocket-events-host.js +17 -8
  101. package/build/src/testing/test-files-finder.d.ts +17 -117
  102. package/build/src/testing/test-files-finder.d.ts.map +1 -1
  103. package/build/src/testing/test-files-finder.js +29 -294
  104. package/build/src/testing/test-filter-parser.d.ts +32 -22
  105. package/build/src/testing/test-filter-parser.d.ts.map +1 -1
  106. package/build/src/testing/test-filter-parser.js +25 -217
  107. package/build/src/testing/test-profile-activity.d.ts +1 -6
  108. package/build/src/testing/test-profile-activity.d.ts.map +1 -1
  109. package/build/src/testing/test-profile-activity.js +2 -12
  110. package/build/src/testing/test-profile-output.d.ts +1 -40
  111. package/build/src/testing/test-profile-output.d.ts.map +1 -1
  112. package/build/src/testing/test-profile-output.js +2 -217
  113. package/build/src/testing/test-profiler.d.ts +15 -659
  114. package/build/src/testing/test-profiler.d.ts.map +1 -1
  115. package/build/src/testing/test-profiler.js +35 -833
  116. package/build/src/testing/test-runner.d.ts +10 -1
  117. package/build/src/testing/test-runner.d.ts.map +1 -1
  118. package/build/src/testing/test-runner.js +26 -4
  119. package/build/src/testing/test-suite-splitter.d.ts +1 -128
  120. package/build/src/testing/test-suite-splitter.d.ts.map +1 -1
  121. package/build/src/testing/test-suite-splitter.js +2 -259
  122. package/build/src/testing/timing-manifest.d.ts +5 -93
  123. package/build/src/testing/timing-manifest.d.ts.map +1 -1
  124. package/build/src/testing/timing-manifest.js +4 -283
  125. package/build/src/testing/velocious-attempt-executor.d.ts.map +1 -1
  126. package/build/src/testing/velocious-attempt-executor.js +8 -2
  127. package/build/testing/test-files-finder.js +32 -343
  128. package/build/testing/test-filter-parser.js +29 -248
  129. package/build/testing/test-profile-activity.js +1 -12
  130. package/build/testing/test-profile-output.js +8 -253
  131. package/build/testing/test-profiler.js +38 -895
  132. package/build/testing/test-runner.js +33 -9
  133. package/build/testing/test-suite-splitter.js +1 -301
  134. package/build/testing/timing-manifest.js +10 -344
  135. package/build/testing/velocious-attempt-executor.js +7 -1
  136. package/package.json +3 -3
  137. package/scripts/test-browser.js +30 -6
  138. package/scripts/verify-docker-dev-environment.js +13 -1
  139. package/src/background-jobs/adapter-client.js +22 -0
  140. package/src/background-jobs/adapter.js +15 -0
  141. package/src/background-jobs/client.js +147 -1
  142. package/src/background-jobs/job-semantics.js +30 -0
  143. package/src/background-jobs/job.js +26 -1
  144. package/src/background-jobs/local-adapter.js +36 -8
  145. package/src/background-jobs/local-store.js +410 -39
  146. package/src/background-jobs/main.js +69 -2
  147. package/src/background-jobs/platform-job.js +26 -1
  148. package/src/background-jobs/runtime.js +58 -0
  149. package/src/background-jobs/store.js +374 -6
  150. package/src/background-jobs/types.js +27 -2
  151. package/src/background-jobs/web/controller.js +1 -0
  152. package/src/configuration.js +30 -6
  153. package/src/database/drivers/mssql/column.js +2 -2
  154. package/src/database/drivers/mssql/table.js +19 -5
  155. package/src/database/pool/async-tracked-multi-connection.js +2 -1
  156. package/src/database/query/alter-table-base.js +8 -1
  157. package/src/database/record/attachments/store.js +2 -2
  158. package/src/environment-handlers/node/cli/commands/test/timing-manifest/merge.js +2 -48
  159. package/src/environment-handlers/node/cli/commands/test.js +17 -69
  160. package/src/frontend-model-controller.js +22 -2
  161. package/src/frontend-models/websocket-channel.js +18 -0
  162. package/src/http-server/client/websocket-session.js +41 -4
  163. package/src/http-server/websocket-channel.js +14 -0
  164. package/src/http-server/websocket-event-log-store.js +85 -12
  165. package/src/http-server/websocket-events-host.js +17 -7
  166. package/src/testing/test-files-finder.js +32 -343
  167. package/src/testing/test-filter-parser.js +29 -248
  168. package/src/testing/test-profile-activity.js +1 -12
  169. package/src/testing/test-profile-output.js +8 -253
  170. package/src/testing/test-profiler.js +38 -895
  171. package/src/testing/test-runner.js +33 -9
  172. package/src/testing/test-suite-splitter.js +1 -301
  173. package/src/testing/timing-manifest.js +10 -344
  174. package/src/testing/velocious-attempt-executor.js +7 -1
@@ -1,14 +1,3 @@
1
1
  // @ts-check
2
2
 
3
- /**
4
- * Validates a low-cardinality activity label suitable for profile output.
5
- * @param {string} name - Activity name.
6
- * @returns {string} - Validated name.
7
- */
8
- export function validateTestActivityName(name) {
9
- if (typeof name !== "string" || !/^[a-z][a-z0-9]*(?:[._:-][a-z0-9]+)*$/.test(name) || name.length > 64) {
10
- throw new Error("Test profile activity name must be a lowercase identifier of at most 64 characters")
11
- }
12
-
13
- return name
14
- }
3
+ export { validateTestActivityName } from "@velocious/testing/profiling"
@@ -1,255 +1,10 @@
1
1
  // @ts-check
2
2
 
3
- import fs from "node:fs/promises"
4
- import path from "node:path"
5
- import { roundProfileDuration } from "./test-profiler.js"
6
- import { validateTimingManifest } from "./timing-manifest.js"
7
-
8
- const FORBIDDEN_PROFILE_FIELDS = new Set([
9
- "bind",
10
- "binds",
11
- "checkoutname",
12
- "credential",
13
- "credentials",
14
- "databasename",
15
- "error",
16
- "host",
17
- "password",
18
- "reusekey",
19
- "sql",
20
- "stack",
21
- "tenant",
22
- "username"
23
- ])
24
- const PHASE_ORDER = [
25
- "discovery",
26
- "imports",
27
- "testing config/global setup",
28
- "beforeAll",
29
- "beforeEach",
30
- "test body",
31
- "afterEach",
32
- "afterAll",
33
- "custom",
34
- "runner overhead",
35
- "total"
36
- ]
37
- let atomicWriteSequence = 0
38
-
39
- /**
40
- * Recursively rejects fields that are forbidden from rich profile output.
41
- * @param {ReturnType<typeof JSON.parse>} value - Profile value.
42
- * @param {string} [pathName] - Diagnostic field path.
43
- * @returns {void}
44
- */
45
- function assertProfilePrivacy(value, pathName = "profile") {
46
- if (!value || typeof value !== "object") return
47
-
48
- if (Array.isArray(value)) {
49
- for (let index = 0; index < value.length; index++) {
50
- assertProfilePrivacy(value[index], `${pathName}[${index}]`)
51
- }
52
- return
53
- }
54
-
55
- for (const [key, childValue] of Object.entries(value)) {
56
- if (FORBIDDEN_PROFILE_FIELDS.has(key.toLowerCase())) {
57
- throw new Error(`Forbidden profile field: ${pathName}.${key}`)
58
- }
59
-
60
- assertProfilePrivacy(childValue, `${pathName}.${key}`)
61
- }
62
- }
63
-
64
- /**
65
- * Recursively rounds duration fields and rejects invalid duration values.
66
- * @param {ReturnType<typeof JSON.parse>} value - Profile value.
67
- * @param {string | undefined} [parentKey] - Parent field name.
68
- * @returns {void}
69
- */
70
- function normalizeDurations(value, parentKey) {
71
- if (!value || typeof value !== "object") return
72
-
73
- if (Array.isArray(value)) {
74
- for (const childValue of value) normalizeDurations(childValue, parentKey)
75
- return
76
- }
77
-
78
- for (const [key, childValue] of Object.entries(value)) {
79
- const durationField = key.endsWith("Ms") || parentKey === "cpuMs"
80
-
81
- if (durationField && typeof childValue === "number") {
82
- if (typeof childValue !== "number" || !Number.isFinite(childValue) || childValue < 0) {
83
- throw new Error(`Invalid test profile duration field: ${key}`)
84
- }
85
-
86
- value[key] = roundProfileDuration(childValue)
87
- continue
88
- }
89
-
90
- if (key.endsWith("Ms") && key !== "cpuMs") {
91
- throw new Error(`Invalid test profile duration field: ${key}`)
92
- }
93
-
94
- normalizeDurations(childValue, key)
95
- }
96
- }
97
-
98
- /**
99
- * Returns a normalized JSON-safe rich profile.
100
- * @param {ReturnType<typeof JSON.parse>} profile - Rich profile document.
101
- * @returns {ReturnType<typeof JSON.parse>} - Normalized document.
102
- */
103
- function normalizedProfile(profile) {
104
- if (profile?.schema !== "velocious.test-profile" || profile?.schemaVersion !== 1) {
105
- throw new Error("Invalid Velocious test profile schema")
106
- }
107
-
108
- assertProfilePrivacy(profile)
109
- const normalized = JSON.parse(JSON.stringify(profile))
110
-
111
- normalizeDurations(normalized)
112
- return normalized
113
- }
114
-
115
- /**
116
- * Writes text through a same-directory temporary file and atomic rename.
117
- * @param {string} outputPath - Final output path.
118
- * @param {string} content - Complete output content.
119
- * @returns {Promise<void>} - Resolves after rename.
120
- */
121
- async function atomicWrite(outputPath, content) {
122
- const directory = path.dirname(outputPath)
123
- const sequence = ++atomicWriteSequence
124
- const temporaryPath = path.join(directory, `.${path.basename(outputPath)}.${process.pid}.${sequence}.tmp`)
125
- let temporaryFileCreated = false
126
-
127
- await fs.mkdir(directory, {recursive: true})
128
-
129
- try {
130
- await fs.writeFile(temporaryPath, content, {encoding: "utf8", flag: "wx"})
131
- temporaryFileCreated = true
132
- await fs.rename(temporaryPath, outputPath)
133
- } catch (error) {
134
- if (temporaryFileCreated) {
135
- try {
136
- await fs.unlink(temporaryPath)
137
- } catch (cleanupError) {
138
- if (!(cleanupError instanceof Error) || !("code" in cleanupError) || cleanupError.code !== "ENOENT") {
139
- throw new AggregateError(
140
- [error, cleanupError],
141
- `Failed to write and clean up test profile output: ${outputPath}`,
142
- {cause: cleanupError}
143
- )
144
- }
145
- }
146
- }
147
-
148
- throw error
149
- }
150
- }
151
-
152
- /**
153
- * Creates a sorted plain timing manifest.
154
- * @param {ReturnType<typeof JSON.parse>} profile - Rich profile document.
155
- * @returns {Record<string, number>} - Sorted file-duration map.
156
- */
157
- export function timingManifestFromProfile(profile) {
158
- /** @type {Record<string, number>} */
159
- const manifest = {}
160
- const validatedManifest = validateTimingManifest(profile.timingManifest || {}, {source: "Test profile timing manifest"})
161
-
162
- for (const [filePath, durationMs] of Object.entries(validatedManifest)) {
163
- manifest[filePath] = roundProfileDuration(durationMs)
164
- }
165
-
166
- return manifest
167
- }
168
-
169
- /**
170
- * Atomically writes a canonical splitter-compatible timing manifest.
171
- * @param {object} args - Output arguments.
172
- * @param {string} args.outputPath - Final output path.
173
- * @param {Record<string, number>} args.timingManifest - Validated or candidate timing manifest.
174
- * @returns {Promise<void>} - Resolves after atomic replacement.
175
- */
176
- export async function writeTimingManifest({outputPath, timingManifest}) {
177
- const normalized = validateTimingManifest(timingManifest)
178
- /** @type {Record<string, number>} */
179
- const rounded = {}
180
-
181
- for (const [filePath, durationMs] of Object.entries(normalized)) {
182
- rounded[filePath] = roundProfileDuration(durationMs)
183
- }
184
-
185
- await atomicWrite(outputPath, `${JSON.stringify(rounded, null, 2)}\n`)
186
- }
187
-
188
- /**
189
- * Atomically writes requested test profile outputs.
190
- * @param {object} args - Output options.
191
- * @param {ReturnType<typeof JSON.parse>} args.profile - Rich profile document.
192
- * @param {string} [args.profileJsonPath] - Rich JSON path.
193
- * @param {string} [args.timingManifestOutputPath] - Plain timing manifest path.
194
- * @returns {Promise<void>} - Resolves after all requested writes.
195
- */
196
- export async function writeTestProfileOutputs({profile, profileJsonPath, timingManifestOutputPath}) {
197
- const normalized = normalizedProfile(profile)
198
- const timingManifest = timingManifestFromProfile(normalized)
199
-
200
- normalized.timingManifest = timingManifest
201
-
202
- if (profileJsonPath) {
203
- await atomicWrite(profileJsonPath, `${JSON.stringify(normalized, null, 2)}\n`)
204
- }
205
-
206
- if (timingManifestOutputPath) {
207
- await writeTimingManifest({outputPath: timingManifestOutputPath, timingManifest})
208
- }
209
- }
210
-
211
- /**
212
- * Formats a compact Benchmark-style console summary.
213
- * @param {ReturnType<typeof JSON.parse>} profile - Rich profile document.
214
- * @param {{profileJsonPath?: string, timingManifestOutputPath?: string}} [outputs] - Written output paths.
215
- * @returns {string} - Console summary.
216
- */
217
- export function formatTestProfileSummary(profile, outputs = {}) {
218
- const lines = [
219
- "Test profile",
220
- "Phase".padEnd(31) + "Count".padStart(5) + "Real ms".padStart(13) + "CPU ms".padStart(13)
221
- ]
222
-
223
- for (const phase of PHASE_ORDER) {
224
- const aggregate = profile.phases?.[phase]
225
-
226
- if (!aggregate) continue
227
-
228
- lines.push(
229
- phase.padEnd(31) +
230
- String(aggregate.count).padStart(5) +
231
- aggregate.totalMs.toFixed(3).padStart(13) +
232
- aggregate.cpuMs.total.toFixed(3).padStart(13)
233
- )
234
- }
235
-
236
- if (profile.pools?.length > 0) {
237
- lines.push("Pools")
238
-
239
- for (const pool of profile.pools) {
240
- lines.push(
241
- `Pool ${pool.identifier}: created=${pool.connectionCreation.count}` +
242
- ` failed=${pool.connectionCreation.failedCount}` +
243
- ` wait=${pool.checkoutWait.count}/${pool.checkoutWait.totalMs.toFixed(3)}ms` +
244
- ` timeouts=${pool.checkoutTimeoutCount}` +
245
- ` reaped=${pool.idleReap.disposalCount}` +
246
- ` peak=${pool.peakLiveConnections}`
247
- )
248
- }
249
- }
250
-
251
- if (outputs.profileJsonPath) lines.push(`Rich JSON: ${outputs.profileJsonPath}`)
252
- if (outputs.timingManifestOutputPath) lines.push(`Timing manifest: ${outputs.timingManifestOutputPath}`)
253
-
254
- return lines.join("\n")
255
- }
3
+ export {
4
+ formatTestProfileSummary,
5
+ loadTimingManifest,
6
+ resolveTestProfileOptions,
7
+ timingManifestFromProfile,
8
+ writeTestProfileOutputs,
9
+ writeTimingManifest
10
+ } from "@velocious/testing/node"