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,12 +1,82 @@
1
1
  // @ts-check
2
2
 
3
- import timeout, {TimeoutError} from "awaitery/build/timeout.js"
3
+ import timeout, { TimeoutError } from "awaitery/build/timeout.js"
4
4
  import configurationResolver from "../configuration-resolver.js"
5
+ import isPlainObject from "../utils/plain-object.js"
5
6
  import BackgroundJobEnqueueAcknowledgementTimeoutError from "./enqueue-acknowledgement-timeout-error.js"
6
7
  import BackgroundJobsSocketRequest from "./socket-request.js"
7
8
  import { DEFAULT_GENERATION_HANDSHAKE_TIMEOUT_MS, validateGenerationHandshakeTimeoutMs } from "./generation-handshake-timeout-error.js"
9
+ import { BACKGROUND_JOB_ACTIVE_STATUSES, BACKGROUND_JOB_EXECUTION_MODES, BACKGROUND_JOB_STATUSES, BACKGROUND_JOB_TERMINAL_STATUSES } from "./job-semantics.js"
8
10
 
9
11
  const DEFAULT_ENQUEUE_TIMEOUT_MS = 5000
12
+ const BACKGROUND_JOB_WAKE_OUTCOMES = ["woken", "already_due", "handed_off", "not_found"]
13
+ const BACKGROUND_JOB_NULLABLE_NUMBER_FIELDS = [
14
+ "attempts",
15
+ "childPid",
16
+ "childReceivedAtMs",
17
+ "childStartedAtMs",
18
+ "completedAtMs",
19
+ "createdAtMs",
20
+ "failedAtMs",
21
+ "handedOffAtMs",
22
+ "maxConcurrency",
23
+ "maxRetries",
24
+ "orphanedAtMs",
25
+ "scheduleOrder",
26
+ "scheduledAtMs",
27
+ "timeoutMs"
28
+ ]
29
+ const BACKGROUND_JOB_NULLABLE_STRING_FIELDS = ["childInstanceId", "concurrencyKey", "handoffId", "lastError", "scheduleKey", "workerId"]
30
+
31
+ /**
32
+ * Checks a required nullable number from a normalized wire row.
33
+ * @param {ReturnType<typeof JSON.parse>} value - Field value.
34
+ * @returns {boolean} - Whether the field is null or a finite number.
35
+ */
36
+ function isNullableBackgroundJobNumber(value) {
37
+ return value === null || (typeof value === "number" && Number.isFinite(value))
38
+ }
39
+
40
+ /**
41
+ * Checks a required nullable string from a normalized wire row.
42
+ * @param {ReturnType<typeof JSON.parse>} value - Field value.
43
+ * @returns {boolean} - Whether the field is null or a string.
44
+ */
45
+ function isNullableBackgroundJobString(value) {
46
+ return value === null || typeof value === "string"
47
+ }
48
+
49
+ /**
50
+ * Checks that a transport job uses the normalized public camel-case shape.
51
+ * @param {ReturnType<typeof JSON.parse>} value - Transport value.
52
+ * @returns {value is import("./types.js").BackgroundJobRow} - Whether normalized.
53
+ */
54
+ function isNormalizedBackgroundJob(value) {
55
+ if (!isPlainObject(value)) return false
56
+
57
+ const job = value
58
+
59
+ return typeof job.id === "string"
60
+ && typeof job.jobName === "string"
61
+ && Array.isArray(job.args)
62
+ && BACKGROUND_JOB_EXECUTION_MODES.some((executionMode) => executionMode === job.executionMode)
63
+ && typeof job.queue === "string"
64
+ && BACKGROUND_JOB_STATUSES.some((status) => status === job.status)
65
+ && BACKGROUND_JOB_NULLABLE_NUMBER_FIELDS.every((field) => isNullableBackgroundJobNumber(job[field]))
66
+ && BACKGROUND_JOB_NULLABLE_STRING_FIELDS.every((field) => isNullableBackgroundJobString(job[field]))
67
+ }
68
+
69
+ /**
70
+ * Describes an unexpected protocol response without echoing its payload.
71
+ * @param {string} operation - Public operation name.
72
+ * @param {import("./types.js").BackgroundJobSocketMessage} message - Response.
73
+ * @returns {Error} - Protocol error.
74
+ */
75
+ function unexpectedResponseError(operation, message) {
76
+ const responseType = message && typeof message.type === "string" ? message.type : "missing type"
77
+
78
+ return new Error(`Unexpected ${operation} response: ${responseType}`)
79
+ }
10
80
 
11
81
  export default class BackgroundJobsClient {
12
82
  /**
@@ -236,4 +306,80 @@ export default class BackgroundJobsClient {
236
306
  }
237
307
  })
238
308
  }
309
+
310
+ /**
311
+ * Reads current stable ownership and optional terminal history.
312
+ * @param {{scheduleKey: string, includeLatestTerminal?: boolean}} args - Lookup request.
313
+ * @returns {Promise<import("./types.js").BackgroundJobScheduledLookupResult>} - Normalized stable schedule jobs.
314
+ */
315
+ async getScheduledJob({scheduleKey, includeLatestTerminal}) {
316
+ const request = await this._request()
317
+
318
+ return await request.run({
319
+ onConnect: (jsonSocket) => {
320
+ jsonSocket.send({type: "get-scheduled-job", scheduleKey, includeLatestTerminal})
321
+ },
322
+ onMessage: ({message, resolve, reject}) => {
323
+ if (message?.type === "scheduled-job") {
324
+ const {currentJob, latestTerminalJob} = message
325
+ const currentJobValid = currentJob === null
326
+ || (isNormalizedBackgroundJob(currentJob) && BACKGROUND_JOB_ACTIVE_STATUSES.some((status) => status === currentJob.status))
327
+ const latestTerminalJobValid = latestTerminalJob === null
328
+ || (isNormalizedBackgroundJob(latestTerminalJob) && BACKGROUND_JOB_TERMINAL_STATUSES.some((status) => status === latestTerminalJob.status))
329
+
330
+ if (!currentJobValid || !latestTerminalJobValid) {
331
+ reject(new Error("Invalid getScheduledJob response: expected normalized public job values"))
332
+ return
333
+ }
334
+
335
+ resolve({currentJob, latestTerminalJob})
336
+ return
337
+ }
338
+
339
+ if (message?.type === "get-scheduled-job-error") {
340
+ reject(new Error(message.error || "Failed to read scheduled job"))
341
+ return
342
+ }
343
+
344
+ reject(unexpectedResponseError("getScheduledJob", message))
345
+ }
346
+ })
347
+ }
348
+
349
+ /**
350
+ * Expedites a future queued stable owner without changing job identity.
351
+ * @param {{scheduleKey: string}} args - Wake request.
352
+ * @returns {Promise<import("./types.js").BackgroundJobWakeResult>} - Wake result.
353
+ */
354
+ async wakeScheduled({scheduleKey}) {
355
+ const request = await this._request()
356
+
357
+ return await request.run({
358
+ onConnect: (jsonSocket) => {
359
+ jsonSocket.send({type: "wake-scheduled", scheduleKey})
360
+ },
361
+ onMessage: ({message, resolve, reject}) => {
362
+ if (message?.type === "schedule-woken") {
363
+ const outcome = message.outcome
364
+ const knownOutcome = BACKGROUND_JOB_WAKE_OUTCOMES.includes(outcome)
365
+ const validJobId = outcome === "not_found" ? message.jobId === null : typeof message.jobId === "string" && message.jobId.length > 0
366
+
367
+ if (!knownOutcome || !validJobId) {
368
+ reject(new Error("Invalid wakeScheduled response"))
369
+ return
370
+ }
371
+
372
+ resolve({jobId: message.jobId, outcome})
373
+ return
374
+ }
375
+
376
+ if (message?.type === "wake-scheduled-error") {
377
+ reject(new Error(message.error || "Failed to wake scheduled job"))
378
+ return
379
+ }
380
+
381
+ reject(unexpectedResponseError("wakeScheduled", message))
382
+ }
383
+ })
384
+ }
239
385
  }
@@ -8,6 +8,36 @@ export const DEFAULT_BACKGROUND_JOB_QUEUE = "default"
8
8
  export const QUEUE_CONCURRENCY_KEY_PREFIX = "queue:"
9
9
  /** @type {import("./types.js").BackgroundJobExecutionMode[]} */
10
10
  export const BACKGROUND_JOB_EXECUTION_MODES = ["inline", "forked", "pooled", "spawned"]
11
+ /** @type {import("./types.js").BackgroundJobActiveStatus[]} */
12
+ export const BACKGROUND_JOB_ACTIVE_STATUSES = ["queued", "handed_off"]
13
+ /** @type {import("./types.js").BackgroundJobTerminalStatus[]} */
14
+ export const BACKGROUND_JOB_TERMINAL_STATUSES = ["cancelled", "completed", "failed", "orphaned"]
15
+ /** @type {import("./types.js").BackgroundJobStatus[]} */
16
+ export const BACKGROUND_JOB_STATUSES = [...BACKGROUND_JOB_ACTIVE_STATUSES, ...BACKGROUND_JOB_TERMINAL_STATUSES]
17
+
18
+ /**
19
+ * Normalizes persisted or transported job status vocabulary.
20
+ * @param {string} value - Candidate status.
21
+ * @returns {import("./types.js").BackgroundJobStatus} - Known status.
22
+ */
23
+ export function normalizeBackgroundJobStatus(value) {
24
+ const status = BACKGROUND_JOB_STATUSES.find((candidate) => candidate === value)
25
+
26
+ if (status) return status
27
+
28
+ throw new Error(`Unknown background job status: ${value}`)
29
+ }
30
+
31
+ /**
32
+ * Validates a stable logical schedule key at every persistence boundary.
33
+ * @param {string} scheduleKey - Stable schedule key.
34
+ * @returns {string} - Validated key.
35
+ */
36
+ export function normalizeBackgroundJobScheduleKey(scheduleKey) {
37
+ if (typeof scheduleKey === "string" && scheduleKey.length > 0 && scheduleKey.length <= 255) return scheduleKey
38
+
39
+ throw VelociousError.safe("background job scheduleKey must be a non-empty string of at most 255 characters")
40
+ }
11
41
 
12
42
  /**
13
43
  * Normalizes a job queue.
@@ -8,7 +8,9 @@ import PlatformVelociousJob from "./platform-job.js"
8
8
  import {
9
9
  cancelScheduledBackgroundJobForConfiguration,
10
10
  enqueueBackgroundJobForConfiguration,
11
- replaceScheduledBackgroundJobForConfiguration
11
+ getScheduledBackgroundJobForConfiguration,
12
+ replaceScheduledBackgroundJobForConfiguration,
13
+ wakeScheduledBackgroundJobForConfiguration
12
14
  } from "./runtime.js"
13
15
 
14
16
  /**
@@ -84,4 +86,27 @@ export default class VelociousJob extends PlatformVelociousJob {
84
86
 
85
87
  return await cancelScheduledBackgroundJobForConfiguration({configuration, scheduleKey})
86
88
  }
89
+
90
+ /**
91
+ * Reads current ownership and optional terminal history for a stable key.
92
+ * @param {string} scheduleKey - Stable logical schedule key.
93
+ * @param {{includeLatestTerminal?: boolean}} [options] - Lookup options.
94
+ * @returns {Promise<import("./types.js").BackgroundJobScheduledLookupResult>} - Normalized stable schedule jobs.
95
+ */
96
+ static async getScheduledJob(scheduleKey, options = {}) {
97
+ const configuration = await configurationResolver()
98
+
99
+ return await getScheduledBackgroundJobForConfiguration({configuration, scheduleKey, ...options})
100
+ }
101
+
102
+ /**
103
+ * Expedites a future queued owner without creating another job.
104
+ * @param {string} scheduleKey - Stable logical schedule key.
105
+ * @returns {Promise<import("./types.js").BackgroundJobWakeResult>} - Wake result.
106
+ */
107
+ static async wakeScheduled(scheduleKey) {
108
+ const configuration = await configurationResolver()
109
+
110
+ return await wakeScheduledBackgroundJobForConfiguration({configuration, scheduleKey})
111
+ }
87
112
  }
@@ -67,18 +67,46 @@ export default class LocalBackgroundJobsAdapter extends BackgroundJobsAdapter {
67
67
  }
68
68
 
69
69
  /**
70
- * Rejects stable-key cancellation, which is outside the local adapter contract.
71
- * @param {string} _scheduleKey - Unsupported stable key.
72
- * @returns {Promise<import("./types.js").BackgroundJobCancellationResult>} - Never resolves.
70
+ * Cancels or detaches the current owner of a stable schedule key.
71
+ * @param {string} scheduleKey - Stable schedule key.
72
+ * @returns {Promise<import("./types.js").BackgroundJobCancellationResult>} - Cancellation result.
73
73
  */
74
- async cancelScheduled(_scheduleKey) { throw new Error("cancelScheduled is not supported by the local background-jobs adapter") }
74
+ async cancelScheduled(scheduleKey) {
75
+ await this.ensureReady()
76
+ return await this.store.cancelScheduled(scheduleKey)
77
+ }
78
+
79
+ /**
80
+ * Replaces the current owner of a stable schedule key.
81
+ * @param {{scheduleKey: string, jobName: string, args: Array<ReturnType<typeof JSON.parse>>, options?: import("./types.js").BackgroundJobOptions}} args - Replacement request.
82
+ * @returns {Promise<import("./types.js").BackgroundJobReplacementResult>} - Replacement result.
83
+ */
84
+ async replaceScheduled(args) {
85
+ await this.ensureReady()
86
+ this.registry.resolve(args.jobName)
87
+ return await this.store.replaceScheduled(args)
88
+ }
75
89
 
76
90
  /**
77
- * Rejects stable-key replacement, which is outside the local adapter contract.
78
- * @param {{scheduleKey: string, jobName: string, args: Array<ReturnType<typeof JSON.parse>>, options?: import("./types.js").BackgroundJobOptions}} _args - Unsupported request.
79
- * @returns {Promise<import("./types.js").BackgroundJobReplacementResult>} - Never resolves.
91
+ * Reads stable ownership and optional terminal history.
92
+ * @param {string} scheduleKey - Stable schedule key.
93
+ * @param {{includeLatestTerminal?: boolean}} [options] - Lookup options.
94
+ * @returns {Promise<import("./types.js").BackgroundJobScheduledLookupResult>} - Normalized local jobs.
80
95
  */
81
- async replaceScheduled(_args) { throw new Error("replaceScheduled is not supported by the local background-jobs adapter") }
96
+ async getScheduledJob(scheduleKey, options) {
97
+ await this.ensureReady()
98
+ return await this.store.getScheduledJob(scheduleKey, options)
99
+ }
100
+
101
+ /**
102
+ * Makes a future queued stable owner due without replacing it.
103
+ * @param {string} scheduleKey - Stable schedule key.
104
+ * @returns {Promise<import("./types.js").BackgroundJobWakeResult>} - Exact wake result.
105
+ */
106
+ async wakeScheduled(scheduleKey) {
107
+ await this.ensureReady()
108
+ return await this.store.wakeScheduled(scheduleKey)
109
+ }
82
110
 
83
111
  /**
84
112
  * Finds the next eligible local job.