velocious 1.0.562 → 1.0.564

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 (245) hide show
  1. package/README.md +5 -1
  2. package/build/background-jobs/cron-expression.js +12 -13
  3. package/build/background-jobs/main.js +6 -6
  4. package/build/background-jobs/runner-graceful-shutdown.js +2 -3
  5. package/build/background-jobs/scheduler.js +3 -3
  6. package/build/background-jobs/worker.js +8 -9
  7. package/build/beacon/client.js +3 -4
  8. package/build/configuration-types.js +1 -0
  9. package/build/configuration.js +44 -3
  10. package/build/database/drivers/sqlite/web-persistence.js +2 -5
  11. package/build/database/pool/async-tracked-multi-connection.js +65 -15
  12. package/build/database/pool/base.js +23 -7
  13. package/build/database/query/index.js +21 -22
  14. package/build/database/query/model-class-query.js +5 -6
  15. package/build/database/record/attachments/normalize-input.js +9 -10
  16. package/build/database/record/attachments/store.js +2 -2
  17. package/build/database/record/auditing.js +7 -8
  18. package/build/database/record/index.js +4 -5
  19. package/build/environment-handlers/node/cli/commands/generate/frontend-models.js +1 -2
  20. package/build/frontend-model-controller.js +49 -56
  21. package/build/frontend-models/base.js +17 -19
  22. package/build/frontend-models/outgoing-event-buffer.js +3 -4
  23. package/build/frontend-models/query.js +40 -44
  24. package/build/frontend-models/resource-definition.js +7 -8
  25. package/build/frontend-models/transport-serialization.js +10 -12
  26. package/build/frontend-models/websocket-channel.js +12 -13
  27. package/build/http-server/client/websocket-session.js +7 -8
  28. package/build/http-server/client-delivery-queue.js +167 -0
  29. package/build/http-server/server-client.js +9 -0
  30. package/build/http-server/websocket-event-log-store.js +4 -6
  31. package/build/http-server/websocket-events-host.js +42 -12
  32. package/build/http-server/worker-handler/in-process.js +53 -14
  33. package/build/http-server/worker-handler/index.js +88 -18
  34. package/build/http-server/worker-handler/worker-thread.js +2 -2
  35. package/build/plugins/sqljs-wasm-route.js +3 -5
  36. package/build/src/background-jobs/cron-expression.d.ts +0 -12
  37. package/build/src/background-jobs/cron-expression.d.ts.map +1 -1
  38. package/build/src/background-jobs/cron-expression.js +13 -13
  39. package/build/src/background-jobs/main.d.ts.map +1 -1
  40. package/build/src/background-jobs/main.js +7 -7
  41. package/build/src/background-jobs/runner-graceful-shutdown.d.ts +0 -6
  42. package/build/src/background-jobs/runner-graceful-shutdown.d.ts.map +1 -1
  43. package/build/src/background-jobs/runner-graceful-shutdown.js +3 -3
  44. package/build/src/background-jobs/scheduler.d.ts +0 -3
  45. package/build/src/background-jobs/scheduler.d.ts.map +1 -1
  46. package/build/src/background-jobs/scheduler.js +4 -4
  47. package/build/src/background-jobs/worker.d.ts +0 -8
  48. package/build/src/background-jobs/worker.d.ts.map +1 -1
  49. package/build/src/background-jobs/worker.js +9 -9
  50. package/build/src/beacon/client.d.ts +0 -4
  51. package/build/src/beacon/client.d.ts.map +1 -1
  52. package/build/src/beacon/client.js +4 -4
  53. package/build/src/configuration-types.d.ts +8 -0
  54. package/build/src/configuration-types.d.ts.map +1 -1
  55. package/build/src/configuration-types.js +2 -1
  56. package/build/src/configuration.d.ts +34 -1
  57. package/build/src/configuration.d.ts.map +1 -1
  58. package/build/src/configuration.js +40 -4
  59. package/build/src/database/drivers/sqlite/web-persistence.d.ts +0 -14
  60. package/build/src/database/drivers/sqlite/web-persistence.d.ts.map +1 -1
  61. package/build/src/database/drivers/sqlite/web-persistence.js +3 -3
  62. package/build/src/database/pool/async-tracked-multi-connection.d.ts +29 -1
  63. package/build/src/database/pool/async-tracked-multi-connection.d.ts.map +1 -1
  64. package/build/src/database/pool/async-tracked-multi-connection.js +57 -15
  65. package/build/src/database/pool/base.d.ts +53 -4
  66. package/build/src/database/pool/base.d.ts.map +1 -1
  67. package/build/src/database/pool/base.js +23 -6
  68. package/build/src/database/query/index.d.ts +18 -39
  69. package/build/src/database/query/index.d.ts.map +1 -1
  70. package/build/src/database/query/index.js +22 -22
  71. package/build/src/database/query/model-class-query.d.ts +0 -5
  72. package/build/src/database/query/model-class-query.d.ts.map +1 -1
  73. package/build/src/database/query/model-class-query.js +6 -6
  74. package/build/src/database/record/attachments/normalize-input.d.ts +0 -9
  75. package/build/src/database/record/attachments/normalize-input.d.ts.map +1 -1
  76. package/build/src/database/record/attachments/normalize-input.js +10 -10
  77. package/build/src/database/record/attachments/store.d.ts.map +1 -1
  78. package/build/src/database/record/attachments/store.js +2 -2
  79. package/build/src/database/record/auditing.d.ts +17 -24
  80. package/build/src/database/record/auditing.d.ts.map +1 -1
  81. package/build/src/database/record/auditing.js +8 -8
  82. package/build/src/database/record/index.d.ts +4 -4
  83. package/build/src/database/record/index.d.ts.map +1 -1
  84. package/build/src/database/record/index.js +5 -5
  85. package/build/src/environment-handlers/node/cli/commands/generate/frontend-models.d.ts +0 -39
  86. package/build/src/environment-handlers/node/cli/commands/generate/frontend-models.d.ts.map +1 -1
  87. package/build/src/environment-handlers/node/cli/commands/generate/frontend-models.js +2 -2
  88. package/build/src/frontend-model-controller.d.ts +1 -1
  89. package/build/src/frontend-model-controller.d.ts.map +1 -1
  90. package/build/src/frontend-model-controller.js +50 -50
  91. package/build/src/frontend-models/base.d.ts.map +1 -1
  92. package/build/src/frontend-models/base.js +18 -18
  93. package/build/src/frontend-models/outgoing-event-buffer.d.ts.map +1 -1
  94. package/build/src/frontend-models/outgoing-event-buffer.js +3 -3
  95. package/build/src/frontend-models/query.d.ts +56 -37
  96. package/build/src/frontend-models/query.d.ts.map +1 -1
  97. package/build/src/frontend-models/query.js +39 -39
  98. package/build/src/frontend-models/resource-definition.d.ts +0 -7
  99. package/build/src/frontend-models/resource-definition.d.ts.map +1 -1
  100. package/build/src/frontend-models/resource-definition.js +8 -8
  101. package/build/src/frontend-models/transport-serialization.d.ts +0 -10
  102. package/build/src/frontend-models/transport-serialization.d.ts.map +1 -1
  103. package/build/src/frontend-models/transport-serialization.js +11 -11
  104. package/build/src/frontend-models/websocket-channel.d.ts +0 -12
  105. package/build/src/frontend-models/websocket-channel.d.ts.map +1 -1
  106. package/build/src/frontend-models/websocket-channel.js +13 -13
  107. package/build/src/http-server/client/websocket-session.d.ts.map +1 -1
  108. package/build/src/http-server/client/websocket-session.js +8 -8
  109. package/build/src/http-server/client-delivery-queue.d.ts +121 -0
  110. package/build/src/http-server/client-delivery-queue.d.ts.map +1 -0
  111. package/build/src/http-server/client-delivery-queue.js +152 -0
  112. package/build/src/http-server/server-client.d.ts +6 -0
  113. package/build/src/http-server/server-client.d.ts.map +1 -1
  114. package/build/src/http-server/server-client.js +10 -1
  115. package/build/src/http-server/websocket-event-log-store.d.ts +0 -14
  116. package/build/src/http-server/websocket-event-log-store.d.ts.map +1 -1
  117. package/build/src/http-server/websocket-event-log-store.js +5 -5
  118. package/build/src/http-server/websocket-events-host.d.ts +15 -4
  119. package/build/src/http-server/websocket-events-host.d.ts.map +1 -1
  120. package/build/src/http-server/websocket-events-host.js +39 -13
  121. package/build/src/http-server/worker-handler/in-process.d.ts +19 -1
  122. package/build/src/http-server/worker-handler/in-process.d.ts.map +1 -1
  123. package/build/src/http-server/worker-handler/in-process.js +50 -14
  124. package/build/src/http-server/worker-handler/index.d.ts +36 -4
  125. package/build/src/http-server/worker-handler/index.d.ts.map +1 -1
  126. package/build/src/http-server/worker-handler/index.js +82 -18
  127. package/build/src/http-server/worker-handler/worker-thread.js +3 -3
  128. package/build/src/plugins/sqljs-wasm-route.d.ts.map +1 -1
  129. package/build/src/plugins/sqljs-wasm-route.js +4 -4
  130. package/build/src/sync/conflict-strategy.d.ts +0 -15
  131. package/build/src/sync/conflict-strategy.d.ts.map +1 -1
  132. package/build/src/sync/conflict-strategy.js +3 -3
  133. package/build/src/sync/device-identity.d.ts +0 -45
  134. package/build/src/sync/device-identity.d.ts.map +1 -1
  135. package/build/src/sync/device-identity.js +4 -4
  136. package/build/src/sync/local-mutation-log.d.ts +0 -41
  137. package/build/src/sync/local-mutation-log.d.ts.map +1 -1
  138. package/build/src/sync/local-mutation-log.js +9 -9
  139. package/build/src/sync/offline-grant.d.ts +0 -26
  140. package/build/src/sync/offline-grant.d.ts.map +1 -1
  141. package/build/src/sync/offline-grant.js +4 -4
  142. package/build/src/sync/peer-mutation-bundle.d.ts +0 -14
  143. package/build/src/sync/peer-mutation-bundle.d.ts.map +1 -1
  144. package/build/src/sync/peer-mutation-bundle.js +3 -3
  145. package/build/src/sync/server-change-feed.d.ts.map +1 -1
  146. package/build/src/sync/server-change-feed.js +33 -33
  147. package/build/src/sync/sync-api-client.d.ts +0 -9
  148. package/build/src/sync/sync-api-client.d.ts.map +1 -1
  149. package/build/src/sync/sync-api-client.js +2 -2
  150. package/build/src/sync/sync-envelope-replay-service.d.ts +38 -21
  151. package/build/src/sync/sync-envelope-replay-service.d.ts.map +1 -1
  152. package/build/src/sync/sync-envelope-replay-service.js +18 -18
  153. package/build/src/sync/sync-resource-base.d.ts +0 -7
  154. package/build/src/sync/sync-resource-base.d.ts.map +1 -1
  155. package/build/src/sync/sync-resource-base.js +2 -2
  156. package/build/src/sync/sync-scope-store.d.ts +0 -9
  157. package/build/src/sync/sync-scope-store.d.ts.map +1 -1
  158. package/build/src/sync/sync-scope-store.js +10 -10
  159. package/build/src/testing/test-filter-parser.d.ts +0 -10
  160. package/build/src/testing/test-filter-parser.d.ts.map +1 -1
  161. package/build/src/testing/test-filter-parser.js +11 -11
  162. package/build/src/testing/test-runner.d.ts +25 -91
  163. package/build/src/testing/test-runner.d.ts.map +1 -1
  164. package/build/src/testing/test-runner.js +113 -98
  165. package/build/src/testing/test.d.ts +8 -0
  166. package/build/src/testing/test.d.ts.map +1 -1
  167. package/build/src/testing/test.js +9 -9
  168. package/build/src/utils/backtrace-cleaner.d.ts.map +1 -1
  169. package/build/src/utils/backtrace-cleaner.js +9 -9
  170. package/build/src/utils/model-scope.d.ts +0 -8
  171. package/build/src/utils/model-scope.d.ts.map +1 -1
  172. package/build/src/utils/model-scope.js +3 -3
  173. package/build/src/utils/ransack.d.ts +52 -19
  174. package/build/src/utils/ransack.d.ts.map +1 -1
  175. package/build/src/utils/ransack.js +26 -26
  176. package/build/sync/conflict-strategy.js +3 -6
  177. package/build/sync/device-identity.js +4 -9
  178. package/build/sync/local-mutation-log.js +9 -14
  179. package/build/sync/offline-grant.js +4 -7
  180. package/build/sync/peer-mutation-bundle.js +2 -4
  181. package/build/sync/server-change-feed.js +32 -34
  182. package/build/sync/sync-api-client.js +1 -2
  183. package/build/sync/sync-envelope-replay-service.js +17 -19
  184. package/build/sync/sync-resource-base.js +1 -2
  185. package/build/sync/sync-scope-store.js +9 -10
  186. package/build/testing/test-filter-parser.js +10 -11
  187. package/build/testing/test-runner.js +116 -108
  188. package/build/testing/test.js +8 -9
  189. package/build/tsconfig.tsbuildinfo +1 -1
  190. package/build/utils/backtrace-cleaner.js +8 -9
  191. package/build/utils/model-scope.js +3 -4
  192. package/build/utils/ransack.js +27 -34
  193. package/package.json +3 -1
  194. package/scripts/eslint-rules/typedefs-first.js +67 -0
  195. package/scripts/prewarm-chromedriver.js +26 -0
  196. package/src/background-jobs/cron-expression.js +12 -13
  197. package/src/background-jobs/main.js +6 -6
  198. package/src/background-jobs/runner-graceful-shutdown.js +2 -3
  199. package/src/background-jobs/scheduler.js +3 -3
  200. package/src/background-jobs/worker.js +8 -9
  201. package/src/beacon/client.js +3 -4
  202. package/src/configuration-types.js +1 -0
  203. package/src/configuration.js +44 -3
  204. package/src/database/drivers/sqlite/web-persistence.js +2 -5
  205. package/src/database/pool/async-tracked-multi-connection.js +65 -15
  206. package/src/database/pool/base.js +23 -7
  207. package/src/database/query/index.js +21 -22
  208. package/src/database/query/model-class-query.js +5 -6
  209. package/src/database/record/attachments/normalize-input.js +9 -10
  210. package/src/database/record/attachments/store.js +2 -2
  211. package/src/database/record/auditing.js +7 -8
  212. package/src/database/record/index.js +4 -5
  213. package/src/environment-handlers/node/cli/commands/generate/frontend-models.js +1 -2
  214. package/src/frontend-model-controller.js +49 -56
  215. package/src/frontend-models/base.js +17 -19
  216. package/src/frontend-models/outgoing-event-buffer.js +3 -4
  217. package/src/frontend-models/query.js +40 -44
  218. package/src/frontend-models/resource-definition.js +7 -8
  219. package/src/frontend-models/transport-serialization.js +10 -12
  220. package/src/frontend-models/websocket-channel.js +12 -13
  221. package/src/http-server/client/websocket-session.js +7 -8
  222. package/src/http-server/client-delivery-queue.js +167 -0
  223. package/src/http-server/server-client.js +9 -0
  224. package/src/http-server/websocket-event-log-store.js +4 -6
  225. package/src/http-server/websocket-events-host.js +42 -12
  226. package/src/http-server/worker-handler/in-process.js +53 -14
  227. package/src/http-server/worker-handler/index.js +88 -18
  228. package/src/http-server/worker-handler/worker-thread.js +2 -2
  229. package/src/plugins/sqljs-wasm-route.js +3 -5
  230. package/src/sync/conflict-strategy.js +3 -6
  231. package/src/sync/device-identity.js +4 -9
  232. package/src/sync/local-mutation-log.js +9 -14
  233. package/src/sync/offline-grant.js +4 -7
  234. package/src/sync/peer-mutation-bundle.js +2 -4
  235. package/src/sync/server-change-feed.js +32 -34
  236. package/src/sync/sync-api-client.js +1 -2
  237. package/src/sync/sync-envelope-replay-service.js +17 -19
  238. package/src/sync/sync-resource-base.js +1 -2
  239. package/src/sync/sync-scope-store.js +9 -10
  240. package/src/testing/test-filter-parser.js +10 -11
  241. package/src/testing/test-runner.js +116 -108
  242. package/src/testing/test.js +8 -9
  243. package/src/utils/backtrace-cleaner.js +8 -9
  244. package/src/utils/model-scope.js +3 -4
  245. package/src/utils/ransack.js +27 -34
@@ -1,3 +1,11 @@
1
+ /**
2
+ * ParsedStackFrame type.
3
+ * @typedef {object} ParsedStackFrame
4
+ * @property {string | undefined} methodName - Method/function name from the stack frame.
5
+ * @property {string} sourcePath - File or URL path from the stack frame.
6
+ * @property {number} lineNumber - Source line number.
7
+ * @property {number | undefined} columnNumber - Source column number.
8
+ */
1
9
  // @ts-check
2
10
 
3
11
  /**
@@ -9,15 +17,6 @@ function escapeRegExp(value) {
9
17
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")
10
18
  }
11
19
 
12
- /**
13
- * ParsedStackFrame type.
14
- * @typedef {object} ParsedStackFrame
15
- * @property {string | undefined} methodName - Method/function name from the stack frame.
16
- * @property {string} sourcePath - File or URL path from the stack frame.
17
- * @property {number} lineNumber - Source line number.
18
- * @property {number | undefined} columnNumber - Source column number.
19
- */
20
-
21
20
  /**
22
21
  * Runs normalize path.
23
22
  * @param {string | undefined} value - Path or file URL.
@@ -1,7 +1,3 @@
1
- // @ts-check
2
-
3
- const MODEL_SCOPE_DESCRIPTOR_MARKER = "velociousModelScopeDescriptor"
4
-
5
1
  /**
6
2
  * ModelScopeDescriptor type.
7
3
  * @typedef {object} ModelScopeDescriptor
@@ -10,6 +6,9 @@ const MODEL_SCOPE_DESCRIPTOR_MARKER = "velociousModelScopeDescriptor"
10
6
  * @property {typeof import("../database/record/index.js").default | import("../frontend-models/base.js").FrontendModelClass} modelClass - Owning model class.
11
7
  * @property {Array<?>} scopeArgs - Scope arguments.
12
8
  */
9
+ // @ts-check
10
+
11
+ const MODEL_SCOPE_DESCRIPTOR_MARKER = "velociousModelScopeDescriptor"
13
12
 
14
13
  /**
15
14
  * Runs the defineModelScope helper.
@@ -4,50 +4,24 @@ import * as inflection from "inflection"
4
4
  import {isPlainObject} from "is-plain-object"
5
5
  import {resolveFrontendModelClass} from "../frontend-models/model-registry.js"
6
6
 
7
- /** Error raised when a Ransack descriptor is malformed. */
8
- export class RansackQueryError extends Error {
9
- /**
10
- * Creates a Ransack query error.
11
- * @param {string} message - Error message.
12
- */
13
- constructor(message) {
14
- super(message)
15
-
16
- this.name = "RansackQueryError"
17
- }
18
- }
19
-
20
- /**
21
- * Builds a Ransack query error.
22
- * @param {string} message - Error message.
23
- * @returns {RansackQueryError} - Ransack query error.
24
- */
25
- function ransackQueryError(message) {
26
- return new RansackQueryError(message)
27
- }
28
-
29
7
  /**
30
8
  * RansackPredicate type.
31
9
  * @typedef {"cont" | "end" | "eq" | "gt" | "gteq" | "in" | "lt" | "lteq" | "not_eq" | "not_in" | "null" | "start"} RansackPredicate
32
10
  */
33
-
34
11
  /**
35
12
  * RansackCombinator type.
36
13
  * @typedef {"and" | "or"} RansackCombinator
37
14
  */
38
-
39
15
  /**
40
16
  * RansackModelClass type.
41
17
  * @typedef {typeof import("../database/record/index.js").default | import("../frontend-models/base.js").FrontendModelClass} RansackModelClass
42
18
  */
43
-
44
19
  /**
45
20
  * RansackAttribute type.
46
21
  * @typedef {object} RansackAttribute
47
22
  * @property {string} attributeName - Resolved attribute name.
48
23
  * @property {string[]} path - Resolved relationship path.
49
24
  */
50
-
51
25
  /**
52
26
  * RansackCondition type.
53
27
  * @typedef {object} RansackCondition
@@ -56,7 +30,6 @@ function ransackQueryError(message) {
56
30
  * @property {RansackPredicate} predicate - Parsed Ransack predicate.
57
31
  * @property {?} value - Normalized value.
58
32
  */
59
-
60
33
  /**
61
34
  * RansackGroup type.
62
35
  * @typedef {object} RansackGroup
@@ -64,6 +37,33 @@ function ransackQueryError(message) {
64
37
  * @property {RansackCondition[]} conditions - Conditions in this group.
65
38
  * @property {RansackGroup[]} groupings - Nested groups.
66
39
  */
40
+ /**
41
+ * RansackSort type.
42
+ * @typedef {object} RansackSort
43
+ * @property {string} attribute - Resolved attribute name.
44
+ * @property {"asc" | "desc"} direction - Sort direction.
45
+ */
46
+ /** Error raised when a Ransack descriptor is malformed. */
47
+ export class RansackQueryError extends Error {
48
+ /**
49
+ * Creates a Ransack query error.
50
+ * @param {string} message - Error message.
51
+ */
52
+ constructor(message) {
53
+ super(message)
54
+
55
+ this.name = "RansackQueryError"
56
+ }
57
+ }
58
+
59
+ /**
60
+ * Builds a Ransack query error.
61
+ * @param {string} message - Error message.
62
+ * @returns {RansackQueryError} - Ransack query error.
63
+ */
64
+ function ransackQueryError(message) {
65
+ return new RansackQueryError(message)
66
+ }
67
67
 
68
68
  const supportedPredicates = [
69
69
  "not_in",
@@ -803,13 +803,6 @@ function normalizeRansackArray(value) {
803
803
  return [value]
804
804
  }
805
805
 
806
- /**
807
- * RansackSort type.
808
- * @typedef {object} RansackSort
809
- * @property {string} attribute - Resolved attribute name.
810
- * @property {"asc" | "desc"} direction - Sort direction.
811
- */
812
-
813
806
  /**
814
807
  * Parses a ransack `s` sort string against model attributes.
815
808
  * @param {RansackModelClass} modelClass - Model class for attribute lookup.
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "velocious": "build/bin/velocious.js"
4
4
  },
5
5
  "name": "velocious",
6
- "version": "1.0.562",
6
+ "version": "1.0.564",
7
7
  "main": "build/index.js",
8
8
  "types": "build/index.d.ts",
9
9
  "files": [
@@ -20,6 +20,7 @@
20
20
  "benchmark:preloader-id-dedup": "node benchmark/preloader-id-dedup.js",
21
21
  "benchmark:mysql-result-row-materialization": "node benchmark/mysql-result-row-materialization.js",
22
22
  "benchmark:query-roundtrip-batching": "node benchmark/query-roundtrip-batching.js",
23
+ "benchmark:websocket-outbound-queue": "node benchmark/websocket-outbound-queue.js",
23
24
  "benchmark:websocket-frame-buffering": "node benchmark/websocket-frame-buffering.js",
24
25
  "build": "node scripts/clean-build.js && npm run compile",
25
26
  "compile": "tsc -b && npm run copy:js && npm run copy:ejs && npm run copy:templates && node scripts/ensure-bin-executable.js",
@@ -117,6 +118,7 @@
117
118
  "react": "^19.2.0",
118
119
  "react-dom": "^19.2.0",
119
120
  "release-patch": "^1.0.0",
121
+ "selenium-webdriver": "^4.39.0",
120
122
  "sqlite": "^5.1.1",
121
123
  "sqlite3": "^6.0.1",
122
124
  "system-testing": "^1.0.108",
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Reports top-level JSDoc typedef declarations placed after runtime declarations.
3
+ */
4
+ export default {
5
+ meta: {
6
+ docs: {
7
+ description: "Require top-level JSDoc typedefs before runtime declarations"
8
+ },
9
+ messages: {
10
+ typedefsFirst: "Move top-level JSDoc typedef declarations before runtime declarations."
11
+ },
12
+ schema: [],
13
+ type: "suggestion",
14
+ fixable: "code"
15
+ },
16
+ create(context) {
17
+ const sourceCode = context.sourceCode
18
+
19
+ return {
20
+ "Program:exit"(program) {
21
+ const runtimeDeclarations = program.body.filter((node) => {
22
+ return node.type != "ImportDeclaration"
23
+ })
24
+ const firstRuntimeDeclaration = runtimeDeclarations[0]
25
+
26
+ if (!firstRuntimeDeclaration) return
27
+
28
+ const misplacedTypedefs = sourceCode.getAllComments().filter((comment) => {
29
+ if (!/@typedef(?:\s|\{)/u.test(comment.value)) return false
30
+ if (comment.range[0] < firstRuntimeDeclaration.range[0]) return false
31
+
32
+ return !runtimeDeclarations.some((node) => {
33
+ return node.range[0] < comment.range[0] && node.range[1] > comment.range[1]
34
+ })
35
+ })
36
+
37
+ if (misplacedTypedefs.length == 0) return
38
+
39
+ context.report({
40
+ loc: misplacedTypedefs[0].loc,
41
+ messageId: "typedefsFirst",
42
+ fix(fixer) {
43
+ const leadingComments = sourceCode.getCommentsBefore(firstRuntimeDeclaration)
44
+ const firstOrdinaryComment = leadingComments.find((comment) => comment.type != "Shebang")
45
+ const insertionPoint = firstOrdinaryComment?.range[0] ?? firstRuntimeDeclaration.range[0]
46
+ const movedComments = misplacedTypedefs.map((comment) => sourceCode.getText(comment)).join("\n")
47
+ const fixes = [fixer.insertTextBeforeRange([insertionPoint, insertionPoint], `${movedComments}\n`)]
48
+
49
+ for (const comment of misplacedTypedefs) {
50
+ let removalEnd = comment.range[1]
51
+
52
+ if (sourceCode.text[removalEnd] == "\r" && sourceCode.text[removalEnd + 1] == "\n") {
53
+ removalEnd += 2
54
+ } else if (sourceCode.text[removalEnd] == "\n") {
55
+ removalEnd++
56
+ }
57
+
58
+ fixes.push(fixer.removeRange([comment.range[0], removalEnd]))
59
+ }
60
+
61
+ return fixes
62
+ }
63
+ })
64
+ }
65
+ }
66
+ }
67
+ }
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env node
2
+
3
+ import fs from "node:fs"
4
+ import { createRequire } from "node:module"
5
+
6
+ const require = createRequire(import.meta.url)
7
+ const { binaryPaths } = require("selenium-webdriver/common/seleniumManager.js")
8
+ const { browserPath, driverPath } = binaryPaths([
9
+ "--browser",
10
+ "chrome",
11
+ "--language-binding",
12
+ "javascript",
13
+ "--output",
14
+ "json",
15
+ "--avoid-browser-download"
16
+ ])
17
+
18
+ if (!browserPath || !fs.existsSync(browserPath)) {
19
+ throw new Error(`Selenium Manager did not find installed Chrome at ${browserPath || "<missing path>"}`)
20
+ }
21
+
22
+ if (!driverPath || !fs.existsSync(driverPath)) {
23
+ throw new Error(`Selenium Manager did not provision ChromeDriver at ${driverPath || "<missing path>"}`)
24
+ }
25
+
26
+ console.log(`Prewarmed ChromeDriver at ${driverPath} for Chrome at ${browserPath}`)
@@ -1,3 +1,15 @@
1
+ /**
2
+ * ParsedCron type.
3
+ * @typedef {object} ParsedCron
4
+ * @property {Set<number>} minute - Allowed minute values (0-59).
5
+ * @property {Set<number>} hour - Allowed hour values (0-23).
6
+ * @property {Set<number>} dayOfMonth - Allowed day-of-month values (1-31).
7
+ * @property {Set<number>} month - Allowed month values (1-12).
8
+ * @property {Set<number>} dayOfWeek - Allowed day-of-week values (0-6, 0=Sun).
9
+ * @property {boolean} dayOfMonthRestricted - True when the dayOfMonth field is not `?`.
10
+ * @property {boolean} dayOfWeekRestricted - True when the dayOfWeek field is not `?`.
11
+ * @property {string} expression - Original expression for diagnostics.
12
+ */
1
13
  // @ts-check
2
14
 
3
15
  /**
@@ -36,19 +48,6 @@ const FIELDS = [
36
48
  {name: "dayOfWeek", min: 0, max: 7, names: DAY_NAMES}
37
49
  ]
38
50
 
39
- /**
40
- * ParsedCron type.
41
- * @typedef {object} ParsedCron
42
- * @property {Set<number>} minute - Allowed minute values (0-59).
43
- * @property {Set<number>} hour - Allowed hour values (0-23).
44
- * @property {Set<number>} dayOfMonth - Allowed day-of-month values (1-31).
45
- * @property {Set<number>} month - Allowed month values (1-12).
46
- * @property {Set<number>} dayOfWeek - Allowed day-of-week values (0-6, 0=Sun).
47
- * @property {boolean} dayOfMonthRestricted - True when the dayOfMonth field is not `?`.
48
- * @property {boolean} dayOfWeekRestricted - True when the dayOfWeek field is not `?`.
49
- * @property {string} expression - Original expression for diagnostics.
50
- */
51
-
52
51
  /**
53
52
  * Runs the parseCronExpression helper.
54
53
  * @param {string} expression - Cron expression or shortcut.
@@ -9,6 +9,12 @@ import PruneTerminalBackgroundJobsJob from "../jobs/prune-terminal-background-jo
9
9
  import VelociousError from "../velocious-error.js"
10
10
  import shutdownLifecycle from "../utils/shutdown-lifecycle.js"
11
11
 
12
+ /**
13
+ * WorkerExecutionModeCapability type.
14
+ * @typedef {object} WorkerExecutionModeCapability
15
+ * @property {import("./types.js").BackgroundJobExecutionMode} executionMode - Execution mode.
16
+ * @property {(worker: JsonSocket) => boolean} accepts - Whether the worker accepts this mode.
17
+ */
12
18
  /**
13
19
  * Channel used by `background-jobs-main` to coordinate dispatch wake-ups
14
20
  * across processes via Beacon. Workers do NOT subscribe to this channel
@@ -28,12 +34,6 @@ const MAX_TIMER_MS = 2_147_483_647 // ~24.8 days
28
34
  const WORKER_STALE_TIMEOUT_MS = 60000
29
35
  /** How often the main scans workers for staleness. */
30
36
  const WORKER_LIVENESS_SWEEP_MS = 15000
31
- /**
32
- * WorkerExecutionModeCapability type.
33
- * @typedef {object} WorkerExecutionModeCapability
34
- * @property {import("./types.js").BackgroundJobExecutionMode} executionMode - Execution mode.
35
- * @property {(worker: JsonSocket) => boolean} accepts - Whether the worker accepts this mode.
36
- */
37
37
  /**
38
38
  * Worker execution mode capabilities.
39
39
  * @type {WorkerExecutionModeCapability[]} */
@@ -4,15 +4,14 @@ import timeout from "awaitery/build/timeout.js"
4
4
 
5
5
  import Configuration, {CurrentConfigurationNotSetError} from "../configuration.js"
6
6
 
7
- /** Bounded grace for closing framework connections on shutdown before forcing exit. */
8
- const SHUTDOWN_CLOSE_TIMEOUT_MS = 5000
9
-
10
7
  /**
11
8
  * The subset of a configuration a runner closes on shutdown. Typed structurally so
12
9
  * the shutdown path stays typechecked without a broad cast, and a future signature
13
10
  * drift surfaces at the call sites (and in tests) instead of hiding behind `any`.
14
11
  * @typedef {{disconnectBeacon: () => Promise<void>, closeDatabaseConnections: () => Promise<void>}} RunnerCloseableConfiguration
15
12
  */
13
+ /** Bounded grace for closing framework connections on shutdown before forcing exit. */
14
+ const SHUTDOWN_CLOSE_TIMEOUT_MS = 5000
16
15
 
17
16
  /**
18
17
  * Gracefully closes a background-job runner's framework connections (beacon +
@@ -3,6 +3,9 @@
3
3
  import Logger from "../logger.js"
4
4
  import {nextCronFireDate, parseCronExpression} from "./cron-expression.js"
5
5
 
6
+ /**
7
+ * DurationUnit type.
8
+ * @typedef {keyof typeof DURATION_MULTIPLIERS} DurationUnit */
6
9
  const DURATION_MULTIPLIERS = {
7
10
  d: 24 * 60 * 60 * 1000,
8
11
  day: 24 * 60 * 60 * 1000,
@@ -21,9 +24,6 @@ const DURATION_MULTIPLIERS = {
21
24
  week: 7 * 24 * 60 * 60 * 1000,
22
25
  weeks: 7 * 24 * 60 * 60 * 1000
23
26
  }
24
- /**
25
- * DurationUnit type.
26
- * @typedef {keyof typeof DURATION_MULTIPLIERS} DurationUnit */
27
27
 
28
28
  /**
29
29
  * Runs the parseScheduledDuration helper.
@@ -10,6 +10,14 @@ import {randomUUID} from "crypto"
10
10
  import {fileURLToPath} from "node:url"
11
11
  import shutdownLifecycle from "../utils/shutdown-lifecycle.js"
12
12
 
13
+ /**
14
+ * Per-forked-child timeout bookkeeping.
15
+ * @typedef {object} ForkedJobTimeoutState
16
+ * @property {boolean} timedOut - Whether the timeout fired and the child was terminated.
17
+ * @property {number | null} timeoutMs - The armed timeout in ms, or null when disabled.
18
+ * @property {ReturnType<typeof setTimeout> | null} timer - The pending timeout timer, cleared on exit.
19
+ * @property {ReturnType<typeof setTimeout> | null} sigkillTimer - The pending SIGKILL grace timer, cleared on exit.
20
+ */
13
21
  /** Grace period after SIGTERM before a lingering process runner is SIGKILLed. */
14
22
  const FORKED_CHILD_SIGKILL_GRACE_MS = 5000
15
23
  /**
@@ -48,15 +56,6 @@ function positiveNumber(value) {
48
56
  return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : undefined
49
57
  }
50
58
 
51
- /**
52
- * Per-forked-child timeout bookkeeping.
53
- * @typedef {object} ForkedJobTimeoutState
54
- * @property {boolean} timedOut - Whether the timeout fired and the child was terminated.
55
- * @property {number | null} timeoutMs - The armed timeout in ms, or null when disabled.
56
- * @property {ReturnType<typeof setTimeout> | null} timer - The pending timeout timer, cleared on exit.
57
- * @property {ReturnType<typeof setTimeout> | null} sigkillTimer - The pending SIGKILL grace timer, cleared on exit.
58
- */
59
-
60
59
  export default class BackgroundJobsWorker {
61
60
  /**
62
61
  * Runs constructor.
@@ -7,14 +7,13 @@ import timeout from "awaitery/build/timeout.js"
7
7
  import JsonSocket from "../background-jobs/json-socket.js"
8
8
  import EventEmitter from "../utils/event-emitter.js"
9
9
 
10
- const DEFAULT_RECONNECT_DELAY_MS = 1000
11
- const MAX_RECONNECT_DELAY_MS = 30_000
12
- const DEFAULT_CLOSE_TIMEOUT_MS = 1000
13
-
14
10
  /**
15
11
  * BeaconBroadcastHandler type.
16
12
  * @typedef {function(import("./types.js").BeaconBroadcastMessage): void} BeaconBroadcastHandler
17
13
  */
14
+ const DEFAULT_RECONNECT_DELAY_MS = 1000
15
+ const MAX_RECONNECT_DELAY_MS = 30_000
16
+ const DEFAULT_CLOSE_TIMEOUT_MS = 1000
18
17
 
19
18
  /**
20
19
  * BeaconClient connects to a `velocious beacon` daemon and exchanges
@@ -255,6 +255,7 @@
255
255
  * @property {boolean} [inProcess] - Run HTTP handlers in the main thread instead of worker threads.
256
256
  * @property {number} [maxWorkers] - Backward-compatible alias for workers.
257
257
  * @property {number} [port] - Port to bind the HTTP server to.
258
+ * @property {{maxPendingBytes?: number, maxPendingFrames?: number}} [websocketOutboundQueue] - Per-client retained outbound WebSocket frame limits.
258
259
  * @property {number} [workers] - Worker handlers to start for the HTTP server.
259
260
  */
260
261
 
@@ -114,6 +114,25 @@ function resolveBeaconUnreachableReportMs(value) {
114
114
  return 30_000
115
115
  }
116
116
 
117
+ const DEFAULT_WEBSOCKET_OUTBOUND_MAX_PENDING_BYTES = 16 * 1024 * 1024
118
+ const DEFAULT_WEBSOCKET_OUTBOUND_MAX_PENDING_FRAMES = 256
119
+
120
+ /**
121
+ * Validates a positive safe integer configuration value.
122
+ * @param {?} value - Configured positive safe integer.
123
+ * @param {string} name - Configuration key.
124
+ * @param {number} defaultValue - Default value.
125
+ * @returns {number} - Validated configured or default value.
126
+ */
127
+ function positiveSafeInteger(value, name, defaultValue) {
128
+ if (value === undefined) return defaultValue
129
+ if (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0) {
130
+ throw new TypeError(`${name} must be a positive safe integer`)
131
+ }
132
+
133
+ return value
134
+ }
135
+
117
136
  export default class VelociousConfiguration {
118
137
  /**
119
138
  * Close database connections promise.
@@ -209,7 +228,15 @@ export default class VelociousConfiguration {
209
228
  * @type {Promise<void> | undefined}
210
229
  */
211
230
  this._initializePromise = undefined
212
- this.httpServer = httpServer || {}
231
+ const websocketOutboundQueue = httpServer?.websocketOutboundQueue
232
+
233
+ this.httpServer = {
234
+ ...(httpServer || {}),
235
+ websocketOutboundQueue: {
236
+ maxPendingBytes: positiveSafeInteger(websocketOutboundQueue?.maxPendingBytes, "httpServer.websocketOutboundQueue.maxPendingBytes", DEFAULT_WEBSOCKET_OUTBOUND_MAX_PENDING_BYTES),
237
+ maxPendingFrames: positiveSafeInteger(websocketOutboundQueue?.maxPendingFrames, "httpServer.websocketOutboundQueue.maxPendingFrames", DEFAULT_WEBSOCKET_OUTBOUND_MAX_PENDING_FRAMES)
238
+ }
239
+ }
213
240
  /**
214
241
  * Stores the http server instance value.
215
242
  * @type {{getDebugSnapshot: () => Promise<Record<string, ?>>} | undefined} */
@@ -1693,7 +1720,8 @@ export default class VelociousConfiguration {
1693
1720
  websocketEvents.broadcastV2({
1694
1721
  channel: message.channel,
1695
1722
  broadcastParams: message.broadcastParams,
1696
- body: message.body
1723
+ body: message.body,
1724
+ configuration: this
1697
1725
  })
1698
1726
  return
1699
1727
  }
@@ -2342,6 +2370,19 @@ export default class VelociousConfiguration {
2342
2370
  */
2343
2371
  getWebsocketSessionHeartbeatSeconds() { return this._websocketSessionHeartbeatSeconds }
2344
2372
 
2373
+ /**
2374
+ * Gets per-client WebSocket outbound queue limits.
2375
+ * @returns {{maxBytes: number, maxFrames: number}} - Per-client outbound queue high-water marks.
2376
+ */
2377
+ getWebsocketOutboundQueueLimits() {
2378
+ const queue = this.httpServer.websocketOutboundQueue
2379
+
2380
+ return {
2381
+ maxBytes: queue.maxPendingBytes,
2382
+ maxFrames: queue.maxPendingFrames
2383
+ }
2384
+ }
2385
+
2345
2386
  /**
2346
2387
  * Registers a wrapper invoked around every WS-borne request /
2347
2388
  * connection message / channel dispatch. The wrapper receives the
@@ -2537,7 +2578,7 @@ export default class VelociousConfiguration {
2537
2578
  const websocketEvents = this._websocketEvents
2538
2579
 
2539
2580
  if (websocketEvents && typeof websocketEvents.broadcastV2 === "function") {
2540
- websocketEvents.broadcastV2({channel: name, broadcastParams, body})
2581
+ websocketEvents.broadcastV2({channel: name, broadcastParams, body, configuration: this})
2541
2582
  return
2542
2583
  }
2543
2584
 
@@ -2,9 +2,6 @@
2
2
 
3
3
  import BetterLocalStorage from "better-localstorage"
4
4
 
5
- const SUPPORT_CHECK_FILE = ".velocious-opfs-support-check"
6
- const SUPPORT_CHECK_BYTES = new Uint8Array([118, 101, 108, 111, 99, 105, 111, 117, 115])
7
-
8
5
  /**
9
6
  * SQLite web persistence adapter.
10
7
  * @typedef {object} SqliteWebPersistence
@@ -13,13 +10,14 @@ const SUPPORT_CHECK_BYTES = new Uint8Array([118, 101, 108, 111, 99, 105, 111, 11
13
10
  * @property {() => Promise<Uint8Array | undefined>} load - Loads persisted database bytes.
14
11
  * @property {(content: Uint8Array) => Promise<void>} save - Saves persisted database bytes.
15
12
  */
16
-
17
13
  /**
18
14
  * Browser-like environment used for web persistence detection.
19
15
  * @typedef {object} SqliteWebPersistenceEnvironment
20
16
  * @property {unknown} [indexedDB] - IndexedDB global.
21
17
  * @property {unknown} [navigator] - Navigator global.
22
18
  */
19
+ const SUPPORT_CHECK_FILE = ".velocious-opfs-support-check"
20
+ const SUPPORT_CHECK_BYTES = new Uint8Array([118, 101, 108, 111, 99, 105, 111, 117, 115])
23
21
 
24
22
  /**
25
23
  * Creates the best SQLite web persistence adapter supported by the current browser.
@@ -297,7 +295,6 @@ class LocalStoragePersistence {
297
295
  }
298
296
  }
299
297
 
300
-
301
298
  /**
302
299
  * Selects the preferred available SQLite web persistence backend.
303
300
  * @param {object} args - Arguments.