@rexezuge/runtime 1.10.0 → 1.12.0

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 (50) hide show
  1. package/README.md +87 -8
  2. package/dist/base/AbstractDurableObjectWorker.d.ts +5 -0
  3. package/dist/base/AbstractDurableObjectWorker.d.ts.map +1 -1
  4. package/dist/base/AbstractDurableObjectWorker.js.map +2 -2
  5. package/dist/base/AbstractEntrypointWorker.d.ts +26 -1
  6. package/dist/base/AbstractEntrypointWorker.d.ts.map +1 -1
  7. package/dist/base/AbstractEntrypointWorker.js +1 -1
  8. package/dist/base/AbstractEntrypointWorker.js.map +3 -3
  9. package/dist/base/AbstractQueueWorker.d.ts +5 -0
  10. package/dist/base/AbstractQueueWorker.d.ts.map +1 -1
  11. package/dist/base/AbstractQueueWorker.js.map +2 -2
  12. package/dist/base/AbstractWorkflowWorker.d.ts +5 -0
  13. package/dist/base/AbstractWorkflowWorker.d.ts.map +1 -1
  14. package/dist/base/AbstractWorkflowWorker.js.map +2 -2
  15. package/dist/base/finalMembers.d.ts +22 -0
  16. package/dist/base/finalMembers.d.ts.map +1 -0
  17. package/dist/base/finalMembers.js +1 -0
  18. package/dist/base/finalMembers.js.map +7 -0
  19. package/dist/cron/CronTasksDurableObject.d.ts +113 -0
  20. package/dist/cron/CronTasksDurableObject.d.ts.map +1 -0
  21. package/dist/cron/CronTasksDurableObject.js +1 -0
  22. package/dist/cron/CronTasksDurableObject.js.map +7 -0
  23. package/dist/cron/cronContract.d.ts +61 -0
  24. package/dist/cron/cronContract.d.ts.map +1 -0
  25. package/dist/cron/cronContract.js +1 -0
  26. package/dist/cron/cronContract.js.map +7 -0
  27. package/dist/cron/dispatchCronToDurableObject.d.ts +62 -0
  28. package/dist/cron/dispatchCronToDurableObject.d.ts.map +1 -0
  29. package/dist/cron/dispatchCronToDurableObject.js +1 -0
  30. package/dist/cron/dispatchCronToDurableObject.js.map +7 -0
  31. package/dist/cron/index.d.ts +6 -0
  32. package/dist/cron/index.d.ts.map +1 -0
  33. package/dist/cron/index.js +1 -0
  34. package/dist/cron/index.js.map +7 -0
  35. package/dist/email/EmailEventsDispatcher.d.ts +106 -0
  36. package/dist/email/EmailEventsDispatcher.d.ts.map +1 -0
  37. package/dist/email/EmailEventsDispatcher.js +1 -0
  38. package/dist/email/EmailEventsDispatcher.js.map +7 -0
  39. package/dist/index.d.ts +7 -1
  40. package/dist/index.d.ts.map +1 -1
  41. package/dist/index.js +1 -1
  42. package/dist/index.js.map +3 -3
  43. package/dist/scheduled/AbstractPruningTask.d.ts +115 -0
  44. package/dist/scheduled/AbstractPruningTask.d.ts.map +1 -0
  45. package/dist/scheduled/AbstractPruningTask.js +1 -0
  46. package/dist/scheduled/AbstractPruningTask.js.map +7 -0
  47. package/dist/scheduled/index.d.ts +2 -0
  48. package/dist/scheduled/index.d.ts.map +1 -1
  49. package/dist/scheduled/index.js.map +2 -2
  50. package/package.json +1 -1
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/cron/cronContract.ts"],
4
+ "sourcesContent": ["/**\n * The wire contract between the entry worker's `scheduled()` and the cron\n * Durable Object — one definition, so the two sides cannot drift.\n *\n * Converged from the `DURABLE_OBJECT_CRON_TASKS_RUN_URL` /\n * `DURABLE_OBJECT_NAMESPACE_GLOBAL` constants in the consumers'\n * `backend-runtime/src/constants/do/*.ts`.\n */\n\n/**\nThe path the cron Durable Object answers.\n*/\nconst CRON_TASKS_RUN_PATH = '/run';\n\n/**\n * The URL the dispatcher posts to. The host is never resolved — a Durable\n * Object stub routes on the object, not the hostname — so it is a reserved\n * `.invalid` name that cannot accidentally reach the network.\n */\nconst CRON_TASKS_RUN_URL = `https://cron-tasks.invalid${CRON_TASKS_RUN_PATH}`;\n\n/**\nThe single instance name: one object serialises every tick.\n*/\nconst CRON_TASKS_INSTANCE_NAME = 'global';\n\n/**\n * How long a live run holds the `already_running` guard by default.\n *\n * Fifteen minutes, AWS-AccessBridge's value: generous against the family's\n * 10-minute crons, so only a run that outlived more than one full tick is\n * treated as wedged.\n */\nconst DEFAULT_MAX_RUN_AGE_MS = 15 * 60 * 1000;\n\n/**\nThe body the dispatcher posts.\n*/\ninterface CronRunRequestBody {\n cron: string;\n scheduledTime: number;\n}\n\n/**\nThe `status` field of every `/run` answer.\n*/\ntype CronRunStatus = 'completed' | 'already_running' | 'failed';\n\n/**\nWhat a run's hooks are told about the run.\n*/\ninterface CronRunContext {\n /**\n The cron expression that fired, or `''` when the trigger did not send one.\n */\n readonly cron: string;\n /**\n The platform's scheduled time, epoch ms; the start time when absent.\n */\n readonly scheduledTime: number;\n /**\n When this object accepted the run, epoch ms.\n */\n readonly startedAt: number;\n}\n\nexport { CRON_TASKS_INSTANCE_NAME, CRON_TASKS_RUN_PATH, CRON_TASKS_RUN_URL, DEFAULT_MAX_RUN_AGE_MS };\nexport type { CronRunContext, CronRunRequestBody, CronRunStatus };\n"],
5
+ "mappings": "AAYA,MAAMA,EAAsB,OAOtBC,EAAqB,6BAA6BD,CAAmB,GAKrEE,EAA2B,SAS3BC,EAAyB,IAAU",
6
+ "names": ["CRON_TASKS_RUN_PATH", "CRON_TASKS_RUN_URL", "CRON_TASKS_INSTANCE_NAME", "DEFAULT_MAX_RUN_AGE_MS"]
7
+ }
@@ -0,0 +1,62 @@
1
+ import type { Logger } from '../logger.ts';
2
+ import type { CronRunRequestBody } from './cronContract.ts';
3
+ /**
4
+ * The slice of a Durable Object stub the dispatcher calls. A real
5
+ * `DurableObjectStub` satisfies it.
6
+ */
7
+ interface DurableObjectStubLike {
8
+ fetch(request: Request): Promise<Response>;
9
+ }
10
+ /**
11
+ * The slice of a `DurableObjectNamespace` the dispatcher calls. Generic over
12
+ * the id so the platform's `DurableObjectId` flows through untouched.
13
+ */
14
+ interface DurableObjectNamespaceLike<TId = unknown> {
15
+ idFromName(name: string): TId;
16
+ get(id: TId): DurableObjectStubLike;
17
+ }
18
+ /**
19
+ What one dispatch observed. Never a rejection: see the function note.
20
+ */
21
+ interface CronDispatchResult {
22
+ /**
23
+ `completed` (2xx), `already_running` (202), `failed` (any other answer), or `unreachable` (the stub rejected).
24
+ */
25
+ readonly outcome: 'completed' | 'already_running' | 'failed' | 'unreachable';
26
+ /**
27
+ The HTTP status, or `null` when the stub rejected and there was no answer.
28
+ */
29
+ readonly httpStatus: number | null;
30
+ }
31
+ interface CronDispatchOptions {
32
+ /**
33
+ The instance name. Default `'global'` — one object serialises every tick.
34
+ */
35
+ instanceName?: string;
36
+ /**
37
+ The URL posted to. Default `https://cron-tasks.invalid/run`.
38
+ */
39
+ url?: string;
40
+ /**
41
+ The log port. Lines are static messages with the status only.
42
+ */
43
+ logger?: Logger;
44
+ }
45
+ /**
46
+ * Forward a cron tick to the cron Durable Object — the entry-worker half of the
47
+ * `scheduled → CronTasksDurableObject → TaskRegistry` pattern.
48
+ *
49
+ * Converged from the `onScheduled` bodies in AWS-AccessBridge, Agent-Router,
50
+ * CalDAV-Bridge, ChordDHT-Tracker, Mail-Meow (and their siblings): resolve
51
+ * `idFromName('global')`, `POST /run` with `{ cron, scheduledTime }`, and make a
52
+ * skipped tick (202) visible as a warning — a guard stuck on `already_running`
53
+ * for many ticks is how a wedged run shows itself.
54
+ *
55
+ * **Never rejects.** It runs inside `ctx.waitUntil` (or a `scheduled()` the
56
+ * platform would retry), and a dispatch failure is reported, not thrown, so
57
+ * the outcome is the return value. Pass the result to a test or ignore it.
58
+ */
59
+ declare function dispatchCronToDurableObject<TId>(namespace: DurableObjectNamespaceLike<TId>, controller: CronRunRequestBody, options?: CronDispatchOptions): Promise<CronDispatchResult>;
60
+ export { dispatchCronToDurableObject };
61
+ export type { CronDispatchOptions, CronDispatchResult, DurableObjectNamespaceLike, DurableObjectStubLike };
62
+ //# sourceMappingURL=dispatchCronToDurableObject.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispatchCronToDurableObject.d.ts","sourceRoot":"","sources":["../../src/cron/dispatchCronToDurableObject.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAE5D;;;GAGG;AACH,UAAU,qBAAqB;IAC7B,KAAK,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;CAC5C;AAED;;;GAGG;AACH,UAAU,0BAA0B,CAAC,GAAG,GAAG,OAAO;IAChD,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC;IAC9B,GAAG,CAAC,EAAE,EAAE,GAAG,GAAG,qBAAqB,CAAC;CACrC;AAED;;EAEE;AACF,UAAU,kBAAkB;IAC1B;;MAEE;IACF,QAAQ,CAAC,OAAO,EAAE,WAAW,GAAG,iBAAiB,GAAG,QAAQ,GAAG,aAAa,CAAC;IAC7E;;MAEE;IACF,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CACpC;AAED,UAAU,mBAAmB;IAC3B;;MAEE;IACF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;MAEE;IACF,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;MAEE;IACF,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;GAaG;AACH,iBAAe,2BAA2B,CAAC,GAAG,EAC5C,SAAS,EAAE,0BAA0B,CAAC,GAAG,CAAC,EAC1C,UAAU,EAAE,kBAAkB,EAC9B,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,kBAAkB,CAAC,CA0B7B;AAED,OAAO,EAAE,2BAA2B,EAAE,CAAC;AACvC,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,CAAC"}
@@ -0,0 +1 @@
1
+ var n=Object.defineProperty;var a=(e,r)=>n(e,"name",{value:r,configurable:!0});import{createLogger as c}from"../logger.js";import{CRON_TASKS_INSTANCE_NAME as i,CRON_TASKS_RUN_URL as d}from"./cronContract.js";async function l(e,r,o={}){const s=o.logger??c("CronDispatch"),u={cron:r.cron,scheduledTime:r.scheduledTime};let t;try{t=await e.get(e.idFromName(o.instanceName??i)).fetch(new Request(o.url??d,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)}))}catch{return s.error("Failed to invoke the cron Durable Object"),{outcome:"unreachable",httpStatus:null}}return t.status===202?(s.warn("Cron Durable Object skipped this tick (already running)",{status:t.status}),{outcome:"already_running",httpStatus:t.status}):t.ok?{outcome:"completed",httpStatus:t.status}:(s.error("Cron Durable Object returned an error response",{status:t.status}),{outcome:"failed",httpStatus:t.status})}a(l,"dispatchCronToDurableObject");export{l as dispatchCronToDurableObject};
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/cron/dispatchCronToDurableObject.ts"],
4
+ "sourcesContent": ["import { createLogger } from '../logger.ts';\nimport type { Logger } from '../logger.ts';\nimport { CRON_TASKS_INSTANCE_NAME, CRON_TASKS_RUN_URL } from './cronContract.ts';\nimport type { CronRunRequestBody } from './cronContract.ts';\n\n/**\n * The slice of a Durable Object stub the dispatcher calls. A real\n * `DurableObjectStub` satisfies it.\n */\ninterface DurableObjectStubLike {\n fetch(request: Request): Promise<Response>;\n}\n\n/**\n * The slice of a `DurableObjectNamespace` the dispatcher calls. Generic over\n * the id so the platform's `DurableObjectId` flows through untouched.\n */\ninterface DurableObjectNamespaceLike<TId = unknown> {\n idFromName(name: string): TId;\n get(id: TId): DurableObjectStubLike;\n}\n\n/**\nWhat one dispatch observed. Never a rejection: see the function note.\n*/\ninterface CronDispatchResult {\n /**\n `completed` (2xx), `already_running` (202), `failed` (any other answer), or `unreachable` (the stub rejected).\n */\n readonly outcome: 'completed' | 'already_running' | 'failed' | 'unreachable';\n /**\n The HTTP status, or `null` when the stub rejected and there was no answer.\n */\n readonly httpStatus: number | null;\n}\n\ninterface CronDispatchOptions {\n /**\n The instance name. Default `'global'` — one object serialises every tick.\n */\n instanceName?: string;\n /**\n The URL posted to. Default `https://cron-tasks.invalid/run`.\n */\n url?: string;\n /**\n The log port. Lines are static messages with the status only.\n */\n logger?: Logger;\n}\n\n/**\n * Forward a cron tick to the cron Durable Object — the entry-worker half of the\n * `scheduled → CronTasksDurableObject → TaskRegistry` pattern.\n *\n * Converged from the `onScheduled` bodies in AWS-AccessBridge, Agent-Router,\n * CalDAV-Bridge, ChordDHT-Tracker, Mail-Meow (and their siblings): resolve\n * `idFromName('global')`, `POST /run` with `{ cron, scheduledTime }`, and make a\n * skipped tick (202) visible as a warning — a guard stuck on `already_running`\n * for many ticks is how a wedged run shows itself.\n *\n * **Never rejects.** It runs inside `ctx.waitUntil` (or a `scheduled()` the\n * platform would retry), and a dispatch failure is reported, not thrown, so\n * the outcome is the return value. Pass the result to a test or ignore it.\n */\nasync function dispatchCronToDurableObject<TId>(\n namespace: DurableObjectNamespaceLike<TId>,\n controller: CronRunRequestBody,\n options: CronDispatchOptions = {},\n): Promise<CronDispatchResult> {\n const logger = options.logger ?? createLogger('CronDispatch');\n const body: CronRunRequestBody = { cron: controller.cron, scheduledTime: controller.scheduledTime };\n let response: Response;\n try {\n const stub = namespace.get(namespace.idFromName(options.instanceName ?? CRON_TASKS_INSTANCE_NAME));\n response = await stub.fetch(\n new Request(options.url ?? CRON_TASKS_RUN_URL, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(body),\n }),\n );\n } catch {\n logger.error('Failed to invoke the cron Durable Object');\n return { outcome: 'unreachable', httpStatus: null };\n }\n if (response.status === 202) {\n logger.warn('Cron Durable Object skipped this tick (already running)', { status: response.status });\n return { outcome: 'already_running', httpStatus: response.status };\n }\n if (!response.ok) {\n logger.error('Cron Durable Object returned an error response', { status: response.status });\n return { outcome: 'failed', httpStatus: response.status };\n }\n return { outcome: 'completed', httpStatus: response.status };\n}\n\nexport { dispatchCronToDurableObject };\nexport type { CronDispatchOptions, CronDispatchResult, DurableObjectNamespaceLike, DurableObjectStubLike };\n"],
5
+ "mappings": "+EAAA,OAAS,gBAAAA,MAAoB,eAE7B,OAAS,4BAAAC,EAA0B,sBAAAC,MAA0B,oBA+D7D,eAAeC,EACbC,EACAC,EACAC,EAA+B,CAAA,EAAE,CAEjC,MAAMC,EAASD,EAAQ,QAAUN,EAAa,cAAc,EACtDQ,EAA2B,CAAE,KAAMH,EAAW,KAAM,cAAeA,EAAW,aAAa,EACjG,IAAII,EACJ,GAAI,CAEFA,EAAW,MADEL,EAAU,IAAIA,EAAU,WAAWE,EAAQ,cAAgBL,CAAwB,CAAC,EAC3E,MACpB,IAAI,QAAQK,EAAQ,KAAOJ,EAAoB,CAC7C,OAAQ,OACR,QAAS,CAAE,eAAgB,kBAAkB,EAC7C,KAAM,KAAK,UAAUM,CAAI,EAC1B,CAAC,CAEN,MAAQ,CACN,OAAAD,EAAO,MAAM,0CAA0C,EAChD,CAAE,QAAS,cAAe,WAAY,IAAI,CACnD,CACA,OAAIE,EAAS,SAAW,KACtBF,EAAO,KAAK,0DAA2D,CAAE,OAAQE,EAAS,MAAM,CAAE,EAC3F,CAAE,QAAS,kBAAmB,WAAYA,EAAS,MAAM,GAE7DA,EAAS,GAIP,CAAE,QAAS,YAAa,WAAYA,EAAS,MAAM,GAHxDF,EAAO,MAAM,iDAAkD,CAAE,OAAQE,EAAS,MAAM,CAAE,EACnF,CAAE,QAAS,SAAU,WAAYA,EAAS,MAAM,EAG3D,CA9BeC,EAAAP,EAAA",
6
+ "names": ["createLogger", "CRON_TASKS_INSTANCE_NAME", "CRON_TASKS_RUN_URL", "dispatchCronToDurableObject", "namespace", "controller", "options", "logger", "body", "response", "__name"]
7
+ }
@@ -0,0 +1,6 @@
1
+ export { CronRunError, CronTasksDurableObject } from './CronTasksDurableObject.ts';
2
+ export { CRON_TASKS_INSTANCE_NAME, CRON_TASKS_RUN_PATH, CRON_TASKS_RUN_URL, DEFAULT_MAX_RUN_AGE_MS } from './cronContract.ts';
3
+ export type { CronRunContext, CronRunRequestBody, CronRunStatus } from './cronContract.ts';
4
+ export { dispatchCronToDurableObject } from './dispatchCronToDurableObject.ts';
5
+ export type { CronDispatchOptions, CronDispatchResult, DurableObjectNamespaceLike, DurableObjectStubLike, } from './dispatchCronToDurableObject.ts';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cron/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACnF,OAAO,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC9H,YAAY,EAAE,cAAc,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC3F,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,YAAY,EACV,mBAAmB,EACnB,kBAAkB,EAClB,0BAA0B,EAC1B,qBAAqB,GACtB,MAAM,kCAAkC,CAAC"}
@@ -0,0 +1 @@
1
+ import{CronRunError as o,CronTasksDurableObject as A}from"./CronTasksDurableObject.js";import{CRON_TASKS_INSTANCE_NAME as R,CRON_TASKS_RUN_PATH as S,CRON_TASKS_RUN_URL as T,DEFAULT_MAX_RUN_AGE_MS as e}from"./cronContract.js";import{dispatchCronToDurableObject as t}from"./dispatchCronToDurableObject.js";export{R as CRON_TASKS_INSTANCE_NAME,S as CRON_TASKS_RUN_PATH,T as CRON_TASKS_RUN_URL,o as CronRunError,A as CronTasksDurableObject,e as DEFAULT_MAX_RUN_AGE_MS,t as dispatchCronToDurableObject};
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/cron/index.ts"],
4
+ "sourcesContent": ["export { CronRunError, CronTasksDurableObject } from './CronTasksDurableObject.ts';\nexport { CRON_TASKS_INSTANCE_NAME, CRON_TASKS_RUN_PATH, CRON_TASKS_RUN_URL, DEFAULT_MAX_RUN_AGE_MS } from './cronContract.ts';\nexport type { CronRunContext, CronRunRequestBody, CronRunStatus } from './cronContract.ts';\nexport { dispatchCronToDurableObject } from './dispatchCronToDurableObject.ts';\nexport type {\n CronDispatchOptions,\n CronDispatchResult,\n DurableObjectNamespaceLike,\n DurableObjectStubLike,\n} from './dispatchCronToDurableObject.ts';\n"],
5
+ "mappings": "AAAA,OAAS,gBAAAA,EAAc,0BAAAC,MAA8B,8BACrD,OAAS,4BAAAC,EAA0B,uBAAAC,EAAqB,sBAAAC,EAAoB,0BAAAC,MAA8B,oBAE1G,OAAS,+BAAAC,MAAmC",
6
+ "names": ["CronRunError", "CronTasksDurableObject", "CRON_TASKS_INSTANCE_NAME", "CRON_TASKS_RUN_PATH", "CRON_TASKS_RUN_URL", "DEFAULT_MAX_RUN_AGE_MS", "dispatchCronToDurableObject"]
7
+ }
@@ -0,0 +1,106 @@
1
+ import { AbstractQueueWorker } from '../base/AbstractQueueWorker.ts';
2
+ import type { WorkerExecutionContext } from '../base/AbstractEntrypointWorker.ts';
3
+ import type { Logger } from '../logger.ts';
4
+ /**
5
+ The slice of a platform `Message<Body>` the dispatcher touches.
6
+ */
7
+ interface QueueMessageLike<TBody> {
8
+ readonly id: string;
9
+ readonly body: TBody;
10
+ ack(): void;
11
+ retry(): void;
12
+ }
13
+ /**
14
+ The slice of a platform `MessageBatch<Body>` the dispatcher touches.
15
+ */
16
+ interface QueueBatchLike<TBody> {
17
+ readonly queue: string;
18
+ readonly messages: readonly QueueMessageLike<TBody>[];
19
+ }
20
+ /**
21
+ One workflow instance to create.
22
+ */
23
+ interface WorkflowCreateOptionsLike<TParams> {
24
+ id?: string;
25
+ params?: TParams;
26
+ }
27
+ /**
28
+ * The slice of a platform `Workflow` binding the dispatcher calls.
29
+ * `createBatch` is optional so an older binding (or a test double) still works
30
+ * through the per-message path.
31
+ */
32
+ interface WorkflowBindingLike<TParams> {
33
+ create(options?: WorkflowCreateOptionsLike<TParams>): Promise<unknown>;
34
+ createBatch?(batch: WorkflowCreateOptionsLike<TParams>[]): Promise<unknown>;
35
+ }
36
+ /**
37
+ The platform's instance-id ceiling.
38
+ */
39
+ declare const WORKFLOW_INSTANCE_ID_MAX_LENGTH = 64;
40
+ /**
41
+ * Queue → Workflow fan-out for inbound email events.
42
+ *
43
+ * Converged from `apps/background/src/EmailEventsDispatcherWorker.ts` in
44
+ * Mail-Bee and Mail-Otter (identical but for the duplicate matcher; Mail-Bee's
45
+ * stricter one is kept — a bare "exists" also matches "queue does not exist",
46
+ * and acking that would silently drop the notification). Nothing here is
47
+ * email-specific, so any queue that starts one workflow per message can use it.
48
+ *
49
+ * ## The contract (strict — owned here)
50
+ *
51
+ * - Every message gets a **deterministic** instance id,
52
+ * `prefix + sha256(queue:messageId)`, so a redelivered message cannot start a
53
+ * second workflow.
54
+ * - One `createBatch` for the whole batch; on failure, one `create` per message.
55
+ * A message is acked when its instance exists (created now, or a duplicate),
56
+ * and retried otherwise.
57
+ * - Nothing caught is ever logged: a message body *is* an email, so an error
58
+ * raised after decoding can carry headers or content. Log lines are static.
59
+ *
60
+ * `queue` and `onQueue` are `@final`: a subclass that redeclares either is
61
+ * refused at construction.
62
+ *
63
+ * ## Extending (flexible)
64
+ *
65
+ * - {@link workflowFor} — required: the binding (`env.EMAIL_PROCESSING_WORKFLOW`).
66
+ * - {@link paramsFor}, {@link instanceIdPrefix}, {@link isDuplicateInstanceError},
67
+ * {@link logger} — optional.
68
+ */
69
+ declare abstract class EmailEventsDispatcher<TBody, TParams = TBody> extends AbstractQueueWorker<QueueBatchLike<TBody>> {
70
+ constructor();
71
+ /**
72
+ * @final The dispatch. Not an extension point — see the class note.
73
+ */
74
+ protected onQueue(batch: QueueBatchLike<TBody>, env: Env, _ctx: WorkerExecutionContext): Promise<void>;
75
+ /**
76
+ The workflow binding the messages start instances of.
77
+ */
78
+ protected abstract workflowFor(env: Env): WorkflowBindingLike<TParams>;
79
+ /**
80
+ The instance params for one message. Default: the body itself.
81
+ */
82
+ protected paramsFor(message: QueueMessageLike<TBody>): TParams;
83
+ /**
84
+ The instance-id prefix. Default `emw_`, the family's existing ids.
85
+ */
86
+ protected instanceIdPrefix(): string;
87
+ /**
88
+ * Whether a `create` rejection means the instance already exists — the only
89
+ * failure that is safe to ack. Anchored on *workflow/instance … already
90
+ * exists* so "queue does not exist" and friends are retried.
91
+ */
92
+ protected isDuplicateInstanceError(error: unknown): boolean;
93
+ /**
94
+ The log port. Every line is a static message.
95
+ */
96
+ protected logger(): Logger;
97
+ /**
98
+ * The base's unhandled-rejection sink, narrowed to the static message: the
99
+ * caught value can carry message content, so it is dropped by default.
100
+ */
101
+ protected reportUnhandled(message: string, _error: unknown): void;
102
+ private instanceIdFor;
103
+ }
104
+ export { EmailEventsDispatcher, WORKFLOW_INSTANCE_ID_MAX_LENGTH };
105
+ export type { QueueBatchLike, QueueMessageLike, WorkflowBindingLike, WorkflowCreateOptionsLike };
106
+ //# sourceMappingURL=EmailEventsDispatcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmailEventsDispatcher.d.ts","sourceRoot":"","sources":["../../src/email/EmailEventsDispatcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAGlF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C;;EAEE;AACF,UAAU,gBAAgB,CAAC,KAAK;IAC9B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,GAAG,IAAI,IAAI,CAAC;IACZ,KAAK,IAAI,IAAI,CAAC;CACf;AAED;;EAEE;AACF,UAAU,cAAc,CAAC,KAAK;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EA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AAM,EAAE,OAAO,GAAG,IAAI;YAI5D,aAAa;CAM5B;AAED,OAAO,EAAE,qBAAqB,EAAE,+BAA+B,EAAE,CAAC;AAClE,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,CAAC"}
@@ -0,0 +1 @@
1
+ var m=Object.defineProperty;var i=(l,e)=>m(l,"name",{value:e,configurable:!0});import{AbstractQueueWorker as p}from"../base/AbstractQueueWorker.js";import{assertFinalMembers as w}from"../base/finalMembers.js";import{createLogger as f}from"../logger.js";const c=64;class n extends p{static{i(this,"EmailEventsDispatcher")}constructor(){super(),w(this,n,["queue","onQueue"])}async onQueue(e,t,o){const s=this.workflowFor(t),a=await Promise.all(e.messages.map(async r=>({id:await this.instanceIdFor(e.queue,r.id),params:this.paramsFor(r)})));if(s.createBatch!==void 0&&a.length>0)try{await s.createBatch(a);for(const r of e.messages)r.ack();return}catch{this.logger().warn("Batch workflow dispatch failed; falling back to per-message dispatch")}await Promise.all(e.messages.map(async(r,u)=>{try{await s.create(a[u]),r.ack()}catch(d){if(this.isDuplicateInstanceError(d)){r.ack();return}this.logger().error("Failed to dispatch email event workflow"),r.retry()}}))}paramsFor(e){return e.body}instanceIdPrefix(){return"emw_"}isDuplicateInstanceError(e){const t=e instanceof Error?e.message:String(e);return/\b(?:workflow|instance)\b[^\n]+\balready exists\b/i.test(t)}logger(){return f("EmailEventsDispatcher")}reportUnhandled(e,t){console.error(e)}async instanceIdFor(e,t){const o=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(`${e}:${t}`)),s=[...new Uint8Array(o)].map(r=>r.toString(16).padStart(2,"0")).join(""),a=this.instanceIdPrefix();return`${a}${s.slice(0,Math.max(0,c-a.length))}`}}export{n as EmailEventsDispatcher,c as WORKFLOW_INSTANCE_ID_MAX_LENGTH};
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/email/EmailEventsDispatcher.ts"],
4
+ "sourcesContent": ["import { AbstractQueueWorker } from '../base/AbstractQueueWorker.ts';\nimport type { WorkerExecutionContext } from '../base/AbstractEntrypointWorker.ts';\nimport { assertFinalMembers } from '../base/finalMembers.ts';\nimport { createLogger } from '../logger.ts';\nimport type { Logger } from '../logger.ts';\n\n/**\nThe slice of a platform `Message<Body>` the dispatcher touches.\n*/\ninterface QueueMessageLike<TBody> {\n readonly id: string;\n readonly body: TBody;\n ack(): void;\n retry(): void;\n}\n\n/**\nThe slice of a platform `MessageBatch<Body>` the dispatcher touches.\n*/\ninterface QueueBatchLike<TBody> {\n readonly queue: string;\n readonly messages: readonly QueueMessageLike<TBody>[];\n}\n\n/**\nOne workflow instance to create.\n*/\ninterface WorkflowCreateOptionsLike<TParams> {\n id?: string;\n params?: TParams;\n}\n\n/**\n * The slice of a platform `Workflow` binding the dispatcher calls.\n * `createBatch` is optional so an older binding (or a test double) still works\n * through the per-message path.\n */\ninterface WorkflowBindingLike<TParams> {\n create(options?: WorkflowCreateOptionsLike<TParams>): Promise<unknown>;\n createBatch?(batch: WorkflowCreateOptionsLike<TParams>[]): Promise<unknown>;\n}\n\n/**\nThe platform's instance-id ceiling.\n*/\nconst WORKFLOW_INSTANCE_ID_MAX_LENGTH = 64;\n\n/**\n * Queue → Workflow fan-out for inbound email events.\n *\n * Converged from `apps/background/src/EmailEventsDispatcherWorker.ts` in\n * Mail-Bee and Mail-Otter (identical but for the duplicate matcher; Mail-Bee's\n * stricter one is kept — a bare \"exists\" also matches \"queue does not exist\",\n * and acking that would silently drop the notification). Nothing here is\n * email-specific, so any queue that starts one workflow per message can use it.\n *\n * ## The contract (strict — owned here)\n *\n * - Every message gets a **deterministic** instance id,\n * `prefix + sha256(queue:messageId)`, so a redelivered message cannot start a\n * second workflow.\n * - One `createBatch` for the whole batch; on failure, one `create` per message.\n * A message is acked when its instance exists (created now, or a duplicate),\n * and retried otherwise.\n * - Nothing caught is ever logged: a message body *is* an email, so an error\n * raised after decoding can carry headers or content. Log lines are static.\n *\n * `queue` and `onQueue` are `@final`: a subclass that redeclares either is\n * refused at construction.\n *\n * ## Extending (flexible)\n *\n * - {@link workflowFor} — required: the binding (`env.EMAIL_PROCESSING_WORKFLOW`).\n * - {@link paramsFor}, {@link instanceIdPrefix}, {@link isDuplicateInstanceError},\n * {@link logger} — optional.\n */\nabstract class EmailEventsDispatcher<TBody, TParams = TBody> extends AbstractQueueWorker<QueueBatchLike<TBody>> {\n public constructor() {\n super();\n assertFinalMembers(this, EmailEventsDispatcher, ['queue', 'onQueue']);\n }\n\n /**\n * @final The dispatch. Not an extension point — see the class note.\n */\n protected async onQueue(batch: QueueBatchLike<TBody>, env: Env, _ctx: WorkerExecutionContext): Promise<void> {\n const workflow = this.workflowFor(env);\n const inputs: WorkflowCreateOptionsLike<TParams>[] = await Promise.all(\n batch.messages.map(async (message): Promise<WorkflowCreateOptionsLike<TParams>> => ({\n id: await this.instanceIdFor(batch.queue, message.id),\n params: this.paramsFor(message),\n })),\n );\n\n if (workflow.createBatch !== undefined && inputs.length > 0) {\n try {\n await workflow.createBatch(inputs);\n for (const message of batch.messages) message.ack();\n return;\n } catch {\n this.logger().warn('Batch workflow dispatch failed; falling back to per-message dispatch');\n }\n }\n\n await Promise.all(\n batch.messages.map(async (message, index): Promise<void> => {\n try {\n await workflow.create(inputs[index]);\n message.ack();\n } catch (error: unknown) {\n if (this.isDuplicateInstanceError(error)) {\n message.ack();\n return;\n }\n this.logger().error('Failed to dispatch email event workflow');\n message.retry();\n }\n }),\n );\n }\n\n /**\n The workflow binding the messages start instances of.\n */\n protected abstract workflowFor(env: Env): WorkflowBindingLike<TParams>;\n\n /**\n The instance params for one message. Default: the body itself.\n */\n protected paramsFor(message: QueueMessageLike<TBody>): TParams {\n return message.body as unknown as TParams;\n }\n\n /**\n The instance-id prefix. Default `emw_`, the family's existing ids.\n */\n protected instanceIdPrefix(): string {\n return 'emw_';\n }\n\n /**\n * Whether a `create` rejection means the instance already exists — the only\n * failure that is safe to ack. Anchored on *workflow/instance … already\n * exists* so \"queue does not exist\" and friends are retried.\n */\n protected isDuplicateInstanceError(error: unknown): boolean {\n const message = error instanceof Error ? error.message : String(error);\n return /\\b(?:workflow|instance)\\b[^\\n]+\\balready exists\\b/i.test(message);\n }\n\n /**\n The log port. Every line is a static message.\n */\n protected logger(): Logger {\n return createLogger('EmailEventsDispatcher');\n }\n\n /**\n * The base's unhandled-rejection sink, narrowed to the static message: the\n * caught value can carry message content, so it is dropped by default.\n */\n protected override reportUnhandled(message: string, _error: unknown): void {\n console.error(message);\n }\n\n private async instanceIdFor(queue: string, messageId: string): Promise<string> {\n const digest = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(`${queue}:${messageId}`));\n const hex = [...new Uint8Array(digest)].map((byte) => byte.toString(16).padStart(2, '0')).join('');\n const prefix = this.instanceIdPrefix();\n return `${prefix}${hex.slice(0, Math.max(0, WORKFLOW_INSTANCE_ID_MAX_LENGTH - prefix.length))}`;\n }\n}\n\nexport { EmailEventsDispatcher, WORKFLOW_INSTANCE_ID_MAX_LENGTH };\nexport type { QueueBatchLike, QueueMessageLike, WorkflowBindingLike, WorkflowCreateOptionsLike };\n"],
5
+ "mappings": "+EAAA,OAAS,uBAAAA,MAA2B,iCAEpC,OAAS,sBAAAC,MAA0B,0BACnC,OAAS,gBAAAC,MAAoB,eA0C7B,MAAMC,EAAkC,GA+BxC,MAAeC,UAAsDJ,CAA0C,CA5E/G,MA4E+G,CAAAK,EAAA,8BAC7G,aAAA,CACE,MAAK,EACLJ,EAAmB,KAAMG,EAAuB,CAAC,QAAS,SAAS,CAAC,CACtE,CAKU,MAAM,QAAQE,EAA8BC,EAAUC,EAA4B,CAC1F,MAAMC,EAAW,KAAK,YAAYF,CAAG,EAC/BG,EAA+C,MAAM,QAAQ,IACjEJ,EAAM,SAAS,IAAI,MAAOK,IAA0D,CAClF,GAAI,MAAM,KAAK,cAAcL,EAAM,MAAOK,EAAQ,EAAE,EACpD,OAAQ,KAAK,UAAUA,CAAO,GAC9B,CAAC,E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C,CAAC,EAC/F",
6
+ "names": ["AbstractQueueWorker", "assertFinalMembers", "createLogger", "WORKFLOW_INSTANCE_ID_MAX_LENGTH", "EmailEventsDispatcher", "__name", "batch", "env", "_ctx", "workflow", "inputs", "message", "index", "error", "_error", "queue", "messageId", "digest", "hex", "byte", "prefix"]
7
+ }
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * `@rexezuge/runtime` — the platform foundation layer: DI, configuration,
3
- * worker bases, logger, KV cache. Zero dependencies (the one platform import
3
+ * worker bases, the cron Durable Object, logger, KV cache. Zero dependencies (the one platform import
4
4
  * is type-only, resolved through each consumer's generated wrangler types).
5
5
  */
6
6
  import { resetBreakerForTests as resetBreakerForTestsSeam, resetLogLevelForTests as resetLogLevelForTestsSeam } from './testing.ts';
@@ -23,6 +23,12 @@ export type { LogLevel, Logger, LogSink } from './logger.ts';
23
23
  export { COOLDOWN_MS, FAILURE_THRESHOLD, KV_DOMAINS, KV_KEY_VERSION, KV_MAX_KEY_LENGTH, KV_MIN_TTL_SECONDS, KvCache, PURGE_LIST_LIMIT, PURGE_MAX_PAGES, UNMETERED, buildKvKey, clampTtl, digest128, sanitizeSegment, utf8ByteLength, } from './kv/index.ts';
24
24
  export type { KvDomainDef, KvDomainName, KvDomains, KvNamespaceLike, KvPutOptions, SubrequestMeterLike } from './kv/index.ts';
25
25
  export { AbstractScheduledTask, TaskRegistry } from './scheduled/index.ts';
26
+ export { AbstractPruningTask, DEFAULT_PRUNE_BATCH_SIZE, DEFAULT_PRUNE_MAX_BATCHES } from './scheduled/AbstractPruningTask.ts';
27
+ export type { PruningBudget, PruningDetails, PruningStopReason, PruningTarget } from './scheduled/AbstractPruningTask.ts';
28
+ export { CRON_TASKS_INSTANCE_NAME, CRON_TASKS_RUN_PATH, CRON_TASKS_RUN_URL, CronRunError, CronTasksDurableObject, DEFAULT_MAX_RUN_AGE_MS, dispatchCronToDurableObject, } from './cron/index.ts';
29
+ export type { CronDispatchOptions, CronDispatchResult, CronRunContext, CronRunRequestBody, CronRunStatus, DurableObjectNamespaceLike, DurableObjectStubLike, } from './cron/index.ts';
30
+ export { EmailEventsDispatcher, WORKFLOW_INSTANCE_ID_MAX_LENGTH } from './email/EmailEventsDispatcher.ts';
31
+ export type { QueueBatchLike, QueueMessageLike, WorkflowBindingLike, WorkflowCreateOptionsLike } from './email/EmailEventsDispatcher.ts';
26
32
  export type { ApplicationRunHandle, ExecutionContextLike, ScheduledControllerLike, ScheduledTaskEnv, TaskLogger, TaskRunRecorder, TaskRunSummary, } from './scheduled/index.ts';
27
33
  /**
28
34
  * @deprecated Import from '@rexezuge/runtime/testing'. Removed in 2.0.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,oBAAoB,IAAI,wBAAwB,EAAE,qBAAqB,IAAI,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAEpI,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,YAAY,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,kBAAkB,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AACpI,YAAY,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AAC9E,YAAY,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAC5G,OAAO,EAAE,2BAA2B,EAAE,MAAM,uCAAuC,CAAC;AACpF,OAAO,EAAE,mBAA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E,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAC9H,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAC9H,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAC1H,OAAO,EACL,wBAAwB,EACxB,mBAAmB,EACnB,kBAAkB,EAClB,YAAY,EACZ,sBAAsB,EACtB,sBAAsB,EACtB,2BAA2B,GAC5B,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,0BAA0B,EAC1B,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,qBAAqB,EAAE,+BAA+B,EAAE,MAAM,kCAAkC,CAAC;AAC1G,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AACzI,YAAY,EACV,oBAAoB,EACpB,oBAAoB,EACpB,uBAAuB,EACvB,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,cAAc,GACf,MAAM,sBAAsB,CAAC;AAK9B;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,OAAO,wBAAmD,CAAC;AAC9F;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,OAAO,yBAAqD,CAAC"}
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{resetBreakerForTests as e,resetLogLevelForTests as r}from"./testing.js";import{Container as E}from"./di/Container.js";import{asScopedContext as L,getRequestScope as _,tryGetRequestScope as m,setRequestScope as T,SCOPE_MISSING_MESSAGE as c}from"./di/RequestScope.js";import{AppConfiguration as x}from"./config/AppConfiguration.js";import{EnvParser as A}from"./config/EnvParser.js";import{DEFAULT_SITE_URL as l}from"./config/ConfigurationDefaults.js";import{AbstractEntrypointWorker as i}from"./base/AbstractEntrypointWorker.js";import{AbstractDurableObjectWorker as u}from"./base/AbstractDurableObjectWorker.js";import{AbstractQueueWorker as I}from"./base/AbstractQueueWorker.js";import{AbstractWorkflowWorker as M}from"./base/AbstractWorkflowWorker.js";import{BASE_WORKER_MESSAGES as b}from"./base/baseWorkerError.js";import{consoleSink as G,createLogger as N,isLogLevel as C,resolveLogLevel as D,setLogLevel as W}from"./logger.js";import{COOLDOWN_MS as d,FAILURE_THRESHOLD as y,KV_DOMAINS as B,KV_KEY_VERSION as P,KV_MAX_KEY_LENGTH as V,KV_MIN_TTL_SECONDS as h,KvCache as q,PURGE_LIST_LIMIT as H,PURGE_MAX_PAGES as X,UNMETERED as Y,buildKvKey as j,clampTtl as w,digest128 as z,sanitizeSegment as Q,utf8ByteLength as J}from"./kv/index.js";import{AbstractScheduledTask as $,TaskRegistry as ee}from"./scheduled/index.js";const o=e,s=r;export{u as AbstractDurableObjectWorker,i as AbstractEntrypointWorker,I as AbstractQueueWorker,$ as AbstractScheduledTask,M as AbstractWorkflowWorker,x as AppConfiguration,b as BASE_WORKER_MESSAGES,d as COOLDOWN_MS,E as Container,l as DEFAULT_SITE_URL,A as EnvParser,y as FAILURE_THRESHOLD,B as KV_DOMAINS,P as KV_KEY_VERSION,V as KV_MAX_KEY_LENGTH,h as KV_MIN_TTL_SECONDS,q as KvCache,H as PURGE_LIST_LIMIT,X as PURGE_MAX_PAGES,c as SCOPE_MISSING_MESSAGE,ee as TaskRegistry,Y as UNMETERED,L as asScopedContext,j as buildKvKey,w as clampTtl,G as consoleSink,N as createLogger,z as digest128,_ as getRequestScope,C as isLogLevel,o as resetBreakerForTests,s as resetLogLevelForTests,D as resolveLogLevel,Q as sanitizeSegment,W as setLogLevel,T as setRequestScope,m as tryGetRequestScope,J as utf8ByteLength};
1
+ import{resetBreakerForTests as e,resetLogLevelForTests as r}from"./testing.js";import{Container as S}from"./di/Container.js";import{asScopedContext as A,getRequestScope as a,tryGetRequestScope as p,setRequestScope as L,SCOPE_MISSING_MESSAGE as R}from"./di/RequestScope.js";import{AppConfiguration as c}from"./config/AppConfiguration.js";import{EnvParser as N}from"./config/EnvParser.js";import{DEFAULT_SITE_URL as x}from"./config/ConfigurationDefaults.js";import{AbstractEntrypointWorker as C}from"./base/AbstractEntrypointWorker.js";import{AbstractDurableObjectWorker as i}from"./base/AbstractDurableObjectWorker.js";import{AbstractQueueWorker as M}from"./base/AbstractQueueWorker.js";import{AbstractWorkflowWorker as u}from"./base/AbstractWorkflowWorker.js";import{BASE_WORKER_MESSAGES as I}from"./base/baseWorkerError.js";import{consoleSink as b,createLogger as k,isLogLevel as F,resolveLogLevel as v,setLogLevel as G}from"./logger.js";import{COOLDOWN_MS as W,FAILURE_THRESHOLD as B,KV_DOMAINS as H,KV_KEY_VERSION as d,KV_MAX_KEY_LENGTH as h,KV_MIN_TTL_SECONDS as y,KvCache as V,PURGE_LIST_LIMIT as X,PURGE_MAX_PAGES as j,UNMETERED as q,buildKvKey as Y,clampTtl as w,digest128 as z,sanitizeSegment as Q,utf8ByteLength as Z}from"./kv/index.js";import{AbstractScheduledTask as $,TaskRegistry as ee}from"./scheduled/index.js";import{AbstractPruningTask as oe,DEFAULT_PRUNE_BATCH_SIZE as te,DEFAULT_PRUNE_MAX_BATCHES as se}from"./scheduled/AbstractPruningTask.js";import{CRON_TASKS_INSTANCE_NAME as Ee,CRON_TASKS_RUN_PATH as Se,CRON_TASKS_RUN_URL as Te,CronRunError as Ae,CronTasksDurableObject as ae,DEFAULT_MAX_RUN_AGE_MS as pe,dispatchCronToDurableObject as Le}from"./cron/index.js";import{EmailEventsDispatcher as me,WORKFLOW_INSTANCE_ID_MAX_LENGTH as ce}from"./email/EmailEventsDispatcher.js";const t=e,s=r;export{i as AbstractDurableObjectWorker,C as AbstractEntrypointWorker,oe as AbstractPruningTask,M as AbstractQueueWorker,$ as AbstractScheduledTask,u as AbstractWorkflowWorker,c as AppConfiguration,I as BASE_WORKER_MESSAGES,W as COOLDOWN_MS,Ee as CRON_TASKS_INSTANCE_NAME,Se as CRON_TASKS_RUN_PATH,Te as CRON_TASKS_RUN_URL,S as Container,Ae as CronRunError,ae as CronTasksDurableObject,pe as DEFAULT_MAX_RUN_AGE_MS,te as DEFAULT_PRUNE_BATCH_SIZE,se as DEFAULT_PRUNE_MAX_BATCHES,x as DEFAULT_SITE_URL,me as EmailEventsDispatcher,N as EnvParser,B as FAILURE_THRESHOLD,H as KV_DOMAINS,d as KV_KEY_VERSION,h as KV_MAX_KEY_LENGTH,y as KV_MIN_TTL_SECONDS,V as KvCache,X as PURGE_LIST_LIMIT,j as PURGE_MAX_PAGES,R as SCOPE_MISSING_MESSAGE,ee as TaskRegistry,q as UNMETERED,ce as WORKFLOW_INSTANCE_ID_MAX_LENGTH,A as asScopedContext,Y as buildKvKey,w as clampTtl,b as consoleSink,k as createLogger,z as digest128,Le as dispatchCronToDurableObject,a as getRequestScope,F as isLogLevel,t as resetBreakerForTests,s as resetLogLevelForTests,v as resolveLogLevel,Q as sanitizeSegment,G as setLogLevel,L as setRequestScope,p as tryGetRequestScope,Z as utf8ByteLength};
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts"],
4
- "sourcesContent": ["/**\n * `@rexezuge/runtime` — the platform foundation layer: DI, configuration,\n * worker bases, logger, KV cache. Zero dependencies (the one platform import\n * is type-only, resolved through each consumer's generated wrangler types).\n */\n\nimport { resetBreakerForTests as resetBreakerForTestsSeam, resetLogLevelForTests as resetLogLevelForTestsSeam } from './testing.ts';\n\nexport { Container } from './di/Container.ts';\nexport type { Factory, Token } from './di/Container.ts';\nexport { asScopedContext, getRequestScope, tryGetRequestScope, setRequestScope, SCOPE_MISSING_MESSAGE } from './di/RequestScope.ts';\nexport type { ScopedContext } from './di/RequestScope.ts';\nexport { AppConfiguration } from './config/AppConfiguration.ts';\nexport { EnvParser } from './config/EnvParser.ts';\nexport { DEFAULT_SITE_URL } from './config/ConfigurationDefaults.ts';\nexport { AbstractEntrypointWorker } from './base/AbstractEntrypointWorker.ts';\nexport type { WorkerExecutionContext, WorkerScheduledController } from './base/AbstractEntrypointWorker.ts';\nexport { AbstractDurableObjectWorker } from './base/AbstractDurableObjectWorker.ts';\nexport { AbstractQueueWorker } from './base/AbstractQueueWorker.ts';\nexport { AbstractWorkflowWorker } from './base/AbstractWorkflowWorker.ts';\nexport { BASE_WORKER_MESSAGES } from './base/baseWorkerError.ts';\nexport type { BaseWorkerOperation } from './base/baseWorkerError.ts';\nexport { consoleSink, createLogger, isLogLevel, resolveLogLevel, setLogLevel } from './logger.ts';\nexport type { LogLevel, Logger, LogSink } from './logger.ts';\nexport {\n COOLDOWN_MS,\n FAILURE_THRESHOLD,\n KV_DOMAINS,\n KV_KEY_VERSION,\n KV_MAX_KEY_LENGTH,\n KV_MIN_TTL_SECONDS,\n KvCache,\n PURGE_LIST_LIMIT,\n PURGE_MAX_PAGES,\n UNMETERED,\n buildKvKey,\n clampTtl,\n digest128,\n sanitizeSegment,\n utf8ByteLength,\n} from './kv/index.ts';\nexport type { KvDomainDef, KvDomainName, KvDomains, KvNamespaceLike, KvPutOptions, SubrequestMeterLike } from './kv/index.ts';\nexport { AbstractScheduledTask, TaskRegistry } from './scheduled/index.ts';\nexport type {\n ApplicationRunHandle,\n ExecutionContextLike,\n ScheduledControllerLike,\n ScheduledTaskEnv,\n TaskLogger,\n TaskRunRecorder,\n TaskRunSummary,\n} from './scheduled/index.ts';\n\n// Test seams, re-exported from the root barrel only for compatibility. Bound as\n// consts rather than re-export specifiers so the @deprecated tag reaches callers.\n\n/**\n * @deprecated Import from '@rexezuge/runtime/testing'. Removed in 2.0.\n */\nexport const resetBreakerForTests: typeof resetBreakerForTestsSeam = resetBreakerForTestsSeam;\n/**\n * @deprecated Import from '@rexezuge/runtime/testing'. Removed in 2.0.\n */\nexport const resetLogLevelForTests: typeof resetLogLevelForTestsSeam = resetLogLevelForTestsSeam;\n"],
5
- "mappings": "AAMA,OAAS,wBAAwBA,EAA0B,yBAAyBC,MAAiC,eAErH,OAAS,aAAAC,MAAiB,oBAE1B,OAAS,mBAAAC,EAAiB,mBAAAC,EAAiB,sBAAAC,EAAoB,mBAAAC,EAAiB,yBAAAC,MAA6B,uBAE7G,OAAS,oBAAAC,MAAwB,+BACjC,OAAS,aAAAC,MAAiB,wBAC1B,OAAS,oBAAAC,MAAwB,oCACjC,OAAS,4BAAAC,MAAgC,qCAEzC,OAAS,+BAAAC,MAAmC,wCAC5C,OAAS,uBAAAC,MAA2B,gCACpC,OAAS,0BAAAC,MAA8B,mCACvC,OAAS,wBAAAC,MAA4B,4BAErC,OAAS,eAAAC,EAAa,gBAAAC,EAAc,cAAAC,EAAY,mBAAAC,EAAiB,eAAAC,MAAmB,cAEpF,OACE,eAAAC,EACA,qBAAAC,EACA,cAAAC,EACA,kBAAAC,EACA,qBAAAC,EACA,sBAAAC,EACA,WAAAC,EACA,oBAAAC,EACA,mBAAAC,EACA,aAAAC,EACA,cAAAC,EACA,YAAAC,EACA,aAAAC,EACA,mBAAAC,EACA,kBAAAC,MACK,gBAEP,OAAS,yBAAAC,EAAuB,gBAAAC,OAAoB,uBAiB7C,MAAMC,EAAwDtC,EAIxDuC,EAA0DtC",
6
- "names": ["resetBreakerForTestsSeam", "resetLogLevelForTestsSeam", "Container", "asScopedContext", "getRequestScope", "tryGetRequestScope", "setRequestScope", "SCOPE_MISSING_MESSAGE", "AppConfiguration", "EnvParser", "DEFAULT_SITE_URL", "AbstractEntrypointWorker", "AbstractDurableObjectWorker", "AbstractQueueWorker", "AbstractWorkflowWorker", "BASE_WORKER_MESSAGES", "consoleSink", "createLogger", "isLogLevel", "resolveLogLevel", "setLogLevel", "COOLDOWN_MS", "FAILURE_THRESHOLD", "KV_DOMAINS", "KV_KEY_VERSION", "KV_MAX_KEY_LENGTH", "KV_MIN_TTL_SECONDS", "KvCache", "PURGE_LIST_LIMIT", "PURGE_MAX_PAGES", "UNMETERED", "buildKvKey", "clampTtl", "digest128", "sanitizeSegment", "utf8ByteLength", "AbstractScheduledTask", "TaskRegistry", "resetBreakerForTests", "resetLogLevelForTests"]
4
+ "sourcesContent": ["/**\n * `@rexezuge/runtime` — the platform foundation layer: DI, configuration,\n * worker bases, the cron Durable Object, logger, KV cache. Zero dependencies (the one platform import\n * is type-only, resolved through each consumer's generated wrangler types).\n */\n\nimport { resetBreakerForTests as resetBreakerForTestsSeam, resetLogLevelForTests as resetLogLevelForTestsSeam } from './testing.ts';\n\nexport { Container } from './di/Container.ts';\nexport type { Factory, Token } from './di/Container.ts';\nexport { asScopedContext, getRequestScope, tryGetRequestScope, setRequestScope, SCOPE_MISSING_MESSAGE } from './di/RequestScope.ts';\nexport type { ScopedContext } from './di/RequestScope.ts';\nexport { AppConfiguration } from './config/AppConfiguration.ts';\nexport { EnvParser } from './config/EnvParser.ts';\nexport { DEFAULT_SITE_URL } from './config/ConfigurationDefaults.ts';\nexport { AbstractEntrypointWorker } from './base/AbstractEntrypointWorker.ts';\nexport type { WorkerExecutionContext, WorkerScheduledController } from './base/AbstractEntrypointWorker.ts';\nexport { AbstractDurableObjectWorker } from './base/AbstractDurableObjectWorker.ts';\nexport { AbstractQueueWorker } from './base/AbstractQueueWorker.ts';\nexport { AbstractWorkflowWorker } from './base/AbstractWorkflowWorker.ts';\nexport { BASE_WORKER_MESSAGES } from './base/baseWorkerError.ts';\nexport type { BaseWorkerOperation } from './base/baseWorkerError.ts';\nexport { consoleSink, createLogger, isLogLevel, resolveLogLevel, setLogLevel } from './logger.ts';\nexport type { LogLevel, Logger, LogSink } from './logger.ts';\nexport {\n COOLDOWN_MS,\n FAILURE_THRESHOLD,\n KV_DOMAINS,\n KV_KEY_VERSION,\n KV_MAX_KEY_LENGTH,\n KV_MIN_TTL_SECONDS,\n KvCache,\n PURGE_LIST_LIMIT,\n PURGE_MAX_PAGES,\n UNMETERED,\n buildKvKey,\n clampTtl,\n digest128,\n sanitizeSegment,\n utf8ByteLength,\n} from './kv/index.ts';\nexport type { KvDomainDef, KvDomainName, KvDomains, KvNamespaceLike, KvPutOptions, SubrequestMeterLike } from './kv/index.ts';\nexport { AbstractScheduledTask, TaskRegistry } from './scheduled/index.ts';\nexport { AbstractPruningTask, DEFAULT_PRUNE_BATCH_SIZE, DEFAULT_PRUNE_MAX_BATCHES } from './scheduled/AbstractPruningTask.ts';\nexport type { PruningBudget, PruningDetails, PruningStopReason, PruningTarget } from './scheduled/AbstractPruningTask.ts';\nexport {\n CRON_TASKS_INSTANCE_NAME,\n CRON_TASKS_RUN_PATH,\n CRON_TASKS_RUN_URL,\n CronRunError,\n CronTasksDurableObject,\n DEFAULT_MAX_RUN_AGE_MS,\n dispatchCronToDurableObject,\n} from './cron/index.ts';\nexport type {\n CronDispatchOptions,\n CronDispatchResult,\n CronRunContext,\n CronRunRequestBody,\n CronRunStatus,\n DurableObjectNamespaceLike,\n DurableObjectStubLike,\n} from './cron/index.ts';\nexport { EmailEventsDispatcher, WORKFLOW_INSTANCE_ID_MAX_LENGTH } from './email/EmailEventsDispatcher.ts';\nexport type { QueueBatchLike, QueueMessageLike, WorkflowBindingLike, WorkflowCreateOptionsLike } from './email/EmailEventsDispatcher.ts';\nexport type {\n ApplicationRunHandle,\n ExecutionContextLike,\n ScheduledControllerLike,\n ScheduledTaskEnv,\n TaskLogger,\n TaskRunRecorder,\n TaskRunSummary,\n} from './scheduled/index.ts';\n\n// Test seams, re-exported from the root barrel only for compatibility. Bound as\n// consts rather than re-export specifiers so the @deprecated tag reaches callers.\n\n/**\n * @deprecated Import from '@rexezuge/runtime/testing'. Removed in 2.0.\n */\nexport const resetBreakerForTests: typeof resetBreakerForTestsSeam = resetBreakerForTestsSeam;\n/**\n * @deprecated Import from '@rexezuge/runtime/testing'. Removed in 2.0.\n */\nexport const resetLogLevelForTests: typeof resetLogLevelForTestsSeam = resetLogLevelForTestsSeam;\n"],
5
+ "mappings": "AAMA,OAAS,wBAAwBA,EAA0B,yBAAyBC,MAAiC,eAErH,OAAS,aAAAC,MAAiB,oBAE1B,OAAS,mBAAAC,EAAiB,mBAAAC,EAAiB,sBAAAC,EAAoB,mBAAAC,EAAiB,yBAAAC,MAA6B,uBAE7G,OAAS,oBAAAC,MAAwB,+BACjC,OAAS,aAAAC,MAAiB,wBAC1B,OAAS,oBAAAC,MAAwB,oCACjC,OAAS,4BAAAC,MAAgC,qCAEzC,OAAS,+BAAAC,MAAmC,wCAC5C,OAAS,uBAAAC,MAA2B,gCACpC,OAAS,0BAAAC,MAA8B,mCACvC,OAAS,wBAAAC,MAA4B,4BAErC,OAAS,eAAAC,EAAa,gBAAAC,EAAc,cAAAC,EAAY,mBAAAC,EAAiB,eAAAC,MAAmB,cAEpF,OACE,eAAAC,EACA,qBAAAC,EACA,cAAAC,EACA,kBAAAC,EACA,qBAAAC,EACA,sBAAAC,EACA,WAAAC,EACA,oBAAAC,EACA,mBAAAC,EACA,aAAAC,EACA,cAAAC,EACA,YAAAC,EACA,aAAAC,EACA,mBAAAC,EACA,kBAAAC,MACK,gBAEP,OAAS,yBAAAC,EAAuB,gBAAAC,OAAoB,uBACpD,OAAS,uBAAAC,GAAqB,4BAAAC,GAA0B,6BAAAC,OAAiC,qCAEzF,OACE,4BAAAC,GACA,uBAAAC,GACA,sBAAAC,GACA,gBAAAC,GACA,0BAAAC,GACA,0BAAAC,GACA,+BAAAC,OACK,kBAUP,OAAS,yBAAAC,GAAuB,mCAAAC,OAAuC,mCAkBhE,MAAMC,EAAwDlD,EAIxDmD,EAA0DlD",
6
+ "names": ["resetBreakerForTestsSeam", "resetLogLevelForTestsSeam", "Container", "asScopedContext", "getRequestScope", "tryGetRequestScope", "setRequestScope", "SCOPE_MISSING_MESSAGE", "AppConfiguration", "EnvParser", "DEFAULT_SITE_URL", "AbstractEntrypointWorker", "AbstractDurableObjectWorker", "AbstractQueueWorker", "AbstractWorkflowWorker", "BASE_WORKER_MESSAGES", "consoleSink", "createLogger", "isLogLevel", "resolveLogLevel", "setLogLevel", "COOLDOWN_MS", "FAILURE_THRESHOLD", "KV_DOMAINS", "KV_KEY_VERSION", "KV_MAX_KEY_LENGTH", "KV_MIN_TTL_SECONDS", "KvCache", "PURGE_LIST_LIMIT", "PURGE_MAX_PAGES", "UNMETERED", "buildKvKey", "clampTtl", "digest128", "sanitizeSegment", "utf8ByteLength", "AbstractScheduledTask", "TaskRegistry", "AbstractPruningTask", "DEFAULT_PRUNE_BATCH_SIZE", "DEFAULT_PRUNE_MAX_BATCHES", "CRON_TASKS_INSTANCE_NAME", "CRON_TASKS_RUN_PATH", "CRON_TASKS_RUN_URL", "CronRunError", "CronTasksDurableObject", "DEFAULT_MAX_RUN_AGE_MS", "dispatchCronToDurableObject", "EmailEventsDispatcher", "WORKFLOW_INSTANCE_ID_MAX_LENGTH", "resetBreakerForTests", "resetLogLevelForTests"]
7
7
  }
@@ -0,0 +1,115 @@
1
+ import { AbstractScheduledTask } from './index.ts';
2
+ import type { ExecutionContextLike, ScheduledControllerLike, ScheduledTaskEnv, TaskRunSummary } from './index.ts';
3
+ /**
4
+ * The DAO port a pruning task deletes through.
5
+ *
6
+ * One bounded batch per call: delete at most `limit` rows older than `cutoff`
7
+ * (exclusive) and answer how many went. `@rexezuge/d1`'s
8
+ * `BackgroundTaskRunDAO.deleteOlderThan` satisfies it, and any `BaseDAO`
9
+ * subclass can in one line through its `deleteRowsOlderThan` helper.
10
+ *
11
+ * The cutoff is a number in whatever unit the table stores; the default
12
+ * {@link AbstractPruningTask.cutoffFor} produces unix **seconds**, the unit
13
+ * every family table uses. Override it for a millisecond or ISO column.
14
+ */
15
+ interface PruningTarget {
16
+ deleteOlderThan(cutoff: number, limit: number): Promise<number>;
17
+ }
18
+ /**
19
+ * The budget a pruning run stops against. A `SubrequestMeter` from
20
+ * `@rexezuge/shared` satisfies it.
21
+ *
22
+ * The task only **asks**; it never charges. The DAO behind the
23
+ * {@link PruningTarget} charges each statement (every `BaseDAO` statement
24
+ * does), so a charge here would count each batch twice.
25
+ */
26
+ interface PruningBudget {
27
+ canAfford(count?: number): boolean;
28
+ }
29
+ /**
30
+ Why a run stopped.
31
+ */
32
+ type PruningStopReason = 'drained' | 'batch_cap' | 'budget' | 'disabled';
33
+ /**
34
+ The `details` recorded on every pruning run.
35
+ */
36
+ interface PruningDetails {
37
+ readonly retentionDays: number | null;
38
+ readonly cutoff: number | null;
39
+ readonly batches: number;
40
+ readonly stoppedBy: PruningStopReason;
41
+ }
42
+ declare const DEFAULT_PRUNE_BATCH_SIZE = 500;
43
+ /**
44
+ * Upper bound on batches per run.
45
+ *
46
+ * Pruning runs inside a Durable Object request, so an unbounded loop over a
47
+ * large backlog issues thousands of sequential D1 round trips and exhausts the
48
+ * CPU budget partway through (Cloudflare error 1102), leaving the work half done
49
+ * and the run reported as a failure. The next tick continues from where this one
50
+ * stopped.
51
+ */
52
+ declare const DEFAULT_PRUNE_MAX_BATCHES = 20;
53
+ /**
54
+ * Template Method for retention-based pruning.
55
+ *
56
+ * Converged from `apps/background/src/scheduled/AbstractPruningTask.ts` in
57
+ * AWS-AccessBridge, Mail-Bee, Mail-Meow and Mail-Otter: the cutoff, the
58
+ * bounded batch loop (Mail-Meow's `pruneInBatches`, with its batch cap and the
59
+ * "remaining rows are pruned on the next run" summary), and the run summary.
60
+ * Added in convergence: a {@link PruningBudget} check before every batch, and a
61
+ * retention that is validated rather than trusted — a misparsed env var
62
+ * (`NaN`, a negative number) must fail the run, not delete the table.
63
+ *
64
+ * `handle` and `handleScheduledTask` are `@final`: a subclass that redeclares
65
+ * either is refused at construction.
66
+ *
67
+ * ## Extending
68
+ *
69
+ * - {@link retentionDays} and {@link createTarget} — required.
70
+ * - {@link batchSize}, {@link maxBatches}, {@link budget}, {@link now},
71
+ * {@link cutoffFor} — optional, with documented defaults.
72
+ * - Everything on `AbstractScheduledTask` — `getTaskType`, `createRunRecorder`,
73
+ * `describeFailure`, `logger`.
74
+ */
75
+ declare abstract class AbstractPruningTask<TEnv extends ScheduledTaskEnv = ScheduledTaskEnv> extends AbstractScheduledTask<TEnv> {
76
+ constructor();
77
+ /**
78
+ * The retention window, in days. Must be a positive finite number; `null`
79
+ * disables pruning for this run (recorded as `stoppedBy: 'disabled'`).
80
+ */
81
+ protected abstract retentionDays(env: TEnv): number | null;
82
+ /**
83
+ The DAO the batches delete through.
84
+ */
85
+ protected abstract createTarget(env: TEnv): PruningTarget;
86
+ /**
87
+ Rows per batch. Default 500.
88
+ */
89
+ protected batchSize(_env: TEnv): number;
90
+ /**
91
+ Batches per run. Default 20.
92
+ */
93
+ protected maxBatches(_env: TEnv): number;
94
+ /**
95
+ The subrequest budget to stop against, or `null` (the default) for none.
96
+ */
97
+ protected budget(_env: TEnv): PruningBudget | null;
98
+ /**
99
+ The clock, epoch milliseconds.
100
+ */
101
+ protected now(): number;
102
+ /**
103
+ The exclusive cutoff passed to the target. Default: unix seconds.
104
+ */
105
+ protected cutoffFor(retentionDays: number, nowMs: number): number;
106
+ /**
107
+ * @final The batch loop. Not an extension point.
108
+ */
109
+ protected handleScheduledTask(_event: ScheduledControllerLike, env: TEnv, _ctx: ExecutionContextLike): Promise<TaskRunSummary>;
110
+ private static summarize;
111
+ private static positiveInteger;
112
+ }
113
+ export { AbstractPruningTask, DEFAULT_PRUNE_BATCH_SIZE, DEFAULT_PRUNE_MAX_BATCHES };
114
+ export type { PruningBudget, PruningDetails, PruningStopReason, PruningTarget };
115
+ //# sourceMappingURL=AbstractPruningTask.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AbstractPruningTask.d.ts","sourceRoot":"","sources":["../../src/scheduled/AbstractPruningTask.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAElH;;;;;;;;;;;GAWG;AACH,UAAU,aAAa;IACrB,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;;MAEE;IACF,SAAS,CAAC,SAAS,CAAC,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;IAIjE;;OAEG;cACa,mBAAmB,CAAC,MAAM,EAAE,uBAAuB,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,cAAc,CAAC;IAiCpI,OAAO,CAAC,MAAM,CAAC,SAAS;IAUxB,OAAO,CAAC,MAAM,CAAC,eAAe;CAG/B;AAED,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,CAAC;AACpF,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,iBAAiB,EAAE,aAAa,EAAE,CAAC"}
@@ -0,0 +1 @@
1
+ var S=Object.defineProperty;var m=(b,e)=>S(b,"name",{value:e,configurable:!0});import{assertFinalMembers as _}from"../base/finalMembers.js";import{AbstractScheduledTask as w}from"./index.js";const i=500,o=20,y=86400;class r extends w{static{m(this,"AbstractPruningTask")}constructor(){super(),_(this,r,["handle","handleScheduledTask"])}batchSize(e){return i}maxBatches(e){return o}budget(e){return null}now(){return Date.now()}cutoffFor(e,t){return Math.floor(t/1e3)-e*y}async handleScheduledTask(e,t,p){const n=this.retentionDays(t);if(n===null)return r.summarize(0,{retentionDays:null,cutoff:null,batches:0,stoppedBy:"disabled"});if(!Number.isFinite(n)||n<=0)throw new RangeError(`${this.constructor.name}: retention must be a positive number of days, got ${String(n)}`);const c=r.positiveInteger(this.batchSize(t),i),f=r.positiveInteger(this.maxBatches(t),o),d=this.cutoffFor(n,this.now()),g=this.createTarget(t),u=this.budget(t);let h=0,s=0,a="batch_cap";for(;s<f;){if(u!==null&&!u.canAfford(1)){a="budget";break}const l=await g.deleteOlderThan(d,c);if(s+=1,h+=l,l<c){a="drained";break}}return r.summarize(h,{retentionDays:n,cutoff:d,batches:s,stoppedBy:a})}static summarize(e,t){return{itemsProcessed:e,itemsFailed:0,summary:`Deleted ${e} rows${{drained:"",disabled:"; pruning is disabled",batch_cap:"; batch cap reached, remaining rows are pruned on the next run",budget:"; subrequest budget reached, remaining rows are pruned on the next run"}[t.stoppedBy]}`,details:t}}static positiveInteger(e,t){return Number.isInteger(e)&&e>0?e:t}}export{r as AbstractPruningTask,i as DEFAULT_PRUNE_BATCH_SIZE,o as DEFAULT_PRUNE_MAX_BATCHES};
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/scheduled/AbstractPruningTask.ts"],
4
+ "sourcesContent": ["import { assertFinalMembers } from '../base/finalMembers.ts';\nimport { AbstractScheduledTask } from './index.ts';\nimport type { ExecutionContextLike, ScheduledControllerLike, ScheduledTaskEnv, TaskRunSummary } from './index.ts';\n\n/**\n * The DAO port a pruning task deletes through.\n *\n * One bounded batch per call: delete at most `limit` rows older than `cutoff`\n * (exclusive) and answer how many went. `@rexezuge/d1`'s\n * `BackgroundTaskRunDAO.deleteOlderThan` satisfies it, and any `BaseDAO`\n * subclass can in one line through its `deleteRowsOlderThan` helper.\n *\n * The cutoff is a number in whatever unit the table stores; the default\n * {@link AbstractPruningTask.cutoffFor} produces unix **seconds**, the unit\n * every family table uses. Override it for a millisecond or ISO column.\n */\ninterface PruningTarget {\n deleteOlderThan(cutoff: number, limit: number): Promise<number>;\n}\n\n/**\n * The budget a pruning run stops against. A `SubrequestMeter` from\n * `@rexezuge/shared` satisfies it.\n *\n * The task only **asks**; it never charges. The DAO behind the\n * {@link PruningTarget} charges each statement (every `BaseDAO` statement\n * does), so a charge here would count each batch twice.\n */\ninterface PruningBudget {\n canAfford(count?: number): boolean;\n}\n\n/**\nWhy a run stopped.\n*/\ntype PruningStopReason = 'drained' | 'batch_cap' | 'budget' | 'disabled';\n\n/**\nThe `details` recorded on every pruning run.\n*/\ninterface PruningDetails {\n readonly retentionDays: number | null;\n readonly cutoff: number | null;\n readonly batches: number;\n readonly stoppedBy: PruningStopReason;\n}\n\nconst DEFAULT_PRUNE_BATCH_SIZE = 500;\n\n/**\n * Upper bound on batches per run.\n *\n * Pruning runs inside a Durable Object request, so an unbounded loop over a\n * large backlog issues thousands of sequential D1 round trips and exhausts the\n * CPU budget partway through (Cloudflare error 1102), leaving the work half done\n * and the run reported as a failure. The next tick continues from where this one\n * stopped.\n */\nconst DEFAULT_PRUNE_MAX_BATCHES = 20;\n\nconst SECONDS_PER_DAY = 86_400;\n\n/**\n * Template Method for retention-based pruning.\n *\n * Converged from `apps/background/src/scheduled/AbstractPruningTask.ts` in\n * AWS-AccessBridge, Mail-Bee, Mail-Meow and Mail-Otter: the cutoff, the\n * bounded batch loop (Mail-Meow's `pruneInBatches`, with its batch cap and the\n * \"remaining rows are pruned on the next run\" summary), and the run summary.\n * Added in convergence: a {@link PruningBudget} check before every batch, and a\n * retention that is validated rather than trusted — a misparsed env var\n * (`NaN`, a negative number) must fail the run, not delete the table.\n *\n * `handle` and `handleScheduledTask` are `@final`: a subclass that redeclares\n * either is refused at construction.\n *\n * ## Extending\n *\n * - {@link retentionDays} and {@link createTarget} — required.\n * - {@link batchSize}, {@link maxBatches}, {@link budget}, {@link now},\n * {@link cutoffFor} — optional, with documented defaults.\n * - Everything on `AbstractScheduledTask` — `getTaskType`, `createRunRecorder`,\n * `describeFailure`, `logger`.\n */\nabstract class AbstractPruningTask<TEnv extends ScheduledTaskEnv = ScheduledTaskEnv> extends AbstractScheduledTask<TEnv> {\n public constructor() {\n super();\n assertFinalMembers(this, AbstractPruningTask, ['handle', 'handleScheduledTask']);\n }\n\n /**\n * The retention window, in days. Must be a positive finite number; `null`\n * disables pruning for this run (recorded as `stoppedBy: 'disabled'`).\n */\n protected abstract retentionDays(env: TEnv): number | null;\n\n /**\n The DAO the batches delete through.\n */\n protected abstract createTarget(env: TEnv): PruningTarget;\n\n /**\n Rows per batch. Default 500.\n */\n protected batchSize(_env: TEnv): number {\n return DEFAULT_PRUNE_BATCH_SIZE;\n }\n\n /**\n Batches per run. Default 20.\n */\n protected maxBatches(_env: TEnv): number {\n return DEFAULT_PRUNE_MAX_BATCHES;\n }\n\n /**\n The subrequest budget to stop against, or `null` (the default) for none.\n */\n protected budget(_env: TEnv): PruningBudget | null {\n return null;\n }\n\n /**\n The clock, epoch milliseconds.\n */\n protected now(): number {\n return Date.now();\n }\n\n /**\n The exclusive cutoff passed to the target. Default: unix seconds.\n */\n protected cutoffFor(retentionDays: number, nowMs: number): number {\n return Math.floor(nowMs / 1000) - retentionDays * SECONDS_PER_DAY;\n }\n\n /**\n * @final The batch loop. Not an extension point.\n */\n protected async handleScheduledTask(_event: ScheduledControllerLike, env: TEnv, _ctx: ExecutionContextLike): Promise<TaskRunSummary> {\n const retentionDays = this.retentionDays(env);\n if (retentionDays === null) {\n return AbstractPruningTask.summarize(0, { retentionDays: null, cutoff: null, batches: 0, stoppedBy: 'disabled' });\n }\n if (!Number.isFinite(retentionDays) || retentionDays <= 0) {\n throw new RangeError(`${this.constructor.name}: retention must be a positive number of days, got ${String(retentionDays)}`);\n }\n const batchSize = AbstractPruningTask.positiveInteger(this.batchSize(env), DEFAULT_PRUNE_BATCH_SIZE);\n const maxBatches = AbstractPruningTask.positiveInteger(this.maxBatches(env), DEFAULT_PRUNE_MAX_BATCHES);\n const cutoff = this.cutoffFor(retentionDays, this.now());\n const target = this.createTarget(env);\n const budget = this.budget(env);\n\n let deleted = 0;\n let batches = 0;\n let stoppedBy: PruningStopReason = 'batch_cap';\n while (batches < maxBatches) {\n if (budget !== null && !budget.canAfford(1)) {\n stoppedBy = 'budget';\n break;\n }\n const removed = await target.deleteOlderThan(cutoff, batchSize);\n batches += 1;\n deleted += removed;\n if (removed < batchSize) {\n stoppedBy = 'drained';\n break;\n }\n }\n return AbstractPruningTask.summarize(deleted, { retentionDays, cutoff, batches, stoppedBy });\n }\n\n private static summarize(deleted: number, details: PruningDetails): TaskRunSummary {\n const tail: Record<PruningStopReason, string> = {\n drained: '',\n disabled: '; pruning is disabled',\n batch_cap: '; batch cap reached, remaining rows are pruned on the next run',\n budget: '; subrequest budget reached, remaining rows are pruned on the next run',\n };\n return { itemsProcessed: deleted, itemsFailed: 0, summary: `Deleted ${deleted} rows${tail[details.stoppedBy]}`, details };\n }\n\n private static positiveInteger(value: number, fallback: number): number {\n return Number.isInteger(value) && value > 0 ? value : fallback;\n }\n}\n\nexport { AbstractPruningTask, DEFAULT_PRUNE_BATCH_SIZE, DEFAULT_PRUNE_MAX_BATCHES };\nexport type { PruningBudget, PruningDetails, PruningStopReason, PruningTarget };\n"],
5
+ "mappings": "+EAAA,OAAS,sBAAAA,MAA0B,0BACnC,OAAS,yBAAAC,MAA6B,aA8CtC,MAAMC,EAA2B,IAW3BC,EAA4B,GAE5BC,EAAkB,MAwBxB,MAAeC,UAA8EJ,CAA2B,CApFxH,MAoFwH,CAAAK,EAAA,4BACtH,aAAA,CACE,MAAK,EACLN,EAAmB,KAAMK,EAAqB,CAAC,SAAU,qBAAqB,CAAC,CACjF,CAgBU,UAAUE,EAAU,CAC5B,OAAOL,CACT,CAKU,WAAWK,EAAU,CAC7B,OAAOJ,CACT,CAKU,OAAOI,EAAU,CACzB,OAAO,IACT,CAKU,KAAG,CACX,OAAO,KAAK,IAAG,CACjB,CAKU,UAAUC,EAAuBC,EAAa,CACtD,OAAO,KAAK,MAAMA,EAAQ,GAAI,EAAID,EAAgBJ,CACpD,CAKU,MAAM,oBAAoBM,EAAiCC,EAAWC,EAA0B,CACxG,MAAMJ,EAAgB,KAAK,cAAcG,CAAG,EAC5C,GAAIH,IAAkB,KACpB,OAAOH,EAAoB,UAAU,EAAG,CAAE,cAAe,KAAM,OAAQ,KAAM,QAAS,EAAG,UAAW,UAAU,CAAE,EAElH,GAAI,CAAC,OAAO,SAASG,CAAa,GAAKA,GAAiB,EACtD,MAAM,IAAI,WAAW,GAAG,KAAK,YAAY,IAAI,sDAAsD,OAAOA,CAAa,CAAC,EAAE,EAE5H,MAAMK,EAAYR,EAAoB,gBAAgB,KAAK,UAAUM,CAAG,EAAGT,CAAwB,EAC7FY,EAAaT,EAAoB,gBAAgB,KAAK,WAAWM,CAAG,EAAGR,CAAyB,EAChGY,EAAS,KAAK,UAAUP,EAAe,KAAK,IAAG,CAAE,EACjDQ,EAAS,KAAK,aAAaL,CAAG,EAC9BM,EAAS,KAAK,OAAON,CAAG,EAE9B,IAAIO,EAAU,EACVC,EAAU,EACVC,EAA+B,YACnC,KAAOD,EAAUL,GAAY,CAC3B,GAAIG,IAAW,MAAQ,CAACA,EAAO,UAAU,CAAC,EAAG,CAC3CG,EAAY,SACZ,KACF,CACA,MAAMC,EAAU,MAAML,EAAO,gBAAgBD,EAAQF,CAAS,EAG9D,GAFAM,GAAW,EACXD,GAAWG,EACPA,EAAUR,EAAW,CACvBO,EAAY,UACZ,KACF,CACF,CACA,OAAOf,EAAoB,UAAUa,EAAS,CAAE,cAAAV,EAAe,OAAAO,EAAQ,QAAAI,EAAS,UAAAC,CAAS,CAAE,CAC7F,CAEQ,OAAO,UAAUF,EAAiBI,EAAuB,CAO/D,MAAO,CAAE,eAAgBJ,EAAS,YAAa,EAAG,QAAS,WAAWA,CAAO,QAN7B,CAC9C,QAAS,GACT,SAAU,wBACV,UAAW,iEACX,OAAQ,0EAEgFI,EAAQ,SAAS,CAAC,GAAI,QAAAA,CAAO,CACzH,CAEQ,OAAO,gBAAgBC,EAAeC,EAAgB,CAC5D,OAAO,OAAO,UAAUD,CAAK,GAAKA,EAAQ,EAAIA,EAAQC,CACxD",
6
+ "names": ["assertFinalMembers", "AbstractScheduledTask", "DEFAULT_PRUNE_BATCH_SIZE", "DEFAULT_PRUNE_MAX_BATCHES", "SECONDS_PER_DAY", "AbstractPruningTask", "__name", "_env", "retentionDays", "nowMs", "_event", "env", "_ctx", "batchSize", "maxBatches", "cutoff", "target", "budget", "deleted", "batches", "stoppedBy", "removed", "details", "value", "fallback"]
7
+ }
@@ -157,6 +157,8 @@ declare abstract class AbstractScheduledTask<TEnv extends ScheduledTaskEnv = Sch
157
157
  * uncaught is retried by the platform with no record of why. So the record is
158
158
  * written **before** the error is re-raised — that ordering is the point of
159
159
  * this method, and a subclass that overrides `handle` loses it.
160
+ *
161
+ * @final Extend through {@link handleScheduledTask} and the hooks above.
160
162
  */
161
163
  handle(event: ScheduledControllerLike, env: TEnv, ctx: ExecutionContextLike): Promise<void>;
162
164
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/scheduled/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH;;EAEE;AACF,UAAU,cAAc;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;GAKG;AACH,UAAU,eAAe;IACvB,QAAQ,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAChF,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjE,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/F,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACxD;AAED;;;;;;;GAOG;AACH,UAAU,oBAAoB;IAC5B,OAAO,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/C,IAAI,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7E,IAAI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