@molecule/api-scheduler-cloudflare 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -10,34 +10,31 @@
10
10
  * change — only the bond wired in `bonds/`.
11
11
  *
12
12
  * @example
13
- * ```ts
14
- * // bonds/scheduler-cloudflare.ts
15
- * import { bond } from '@molecule/api-bond'
13
+ * ```typescript
14
+ * import { schedule, setProvider, start } from '@molecule/api-scheduler'
16
15
  * import { createProvider } from '@molecule/api-scheduler-cloudflare'
17
16
  *
18
- * export const scheduler = createProvider()
19
- * export function setupSchedulerCloudflare(): void {
20
- * bond('scheduler', scheduler)
21
- * }
22
- * ```
23
- *
24
- * ```ts
25
- * // worker.ts — the Cron Trigger entry point
26
- * import { scheduler } from './bonds/scheduler-cloudflare.js'
27
- * import { setupBonds } from './bonds/index.js'
17
+ * const scheduler = createProvider()
18
+ * setProvider(scheduler)
28
19
  *
29
- * export default {
30
- * async scheduled(_event, _env, ctx) {
31
- * await setupBonds() // registers tasks via schedule() + start()
32
- * ctx.waitUntil(scheduler.runDueTasks())
20
+ * schedule({
21
+ * name: 'monitor-sweep',
22
+ * intervalMs: 60000,
23
+ * async handler() {
24
+ * // ...
33
25
  * },
34
- * }
35
- * ```
26
+ * })
27
+ *
28
+ * // REQUIRED, same as the default provider: nothing runs until start().
29
+ * // Unlike it, start() begins no timers — a Worker has no process to hold one.
30
+ * start()
36
31
  *
37
- * ```toml
38
- * # wrangler.toml
39
- * [triggers]
40
- * crons = ["*/1 * * * *"] # the trigger schedule IS the schedule
32
+ * // Then, from the Worker's scheduled() handler, wrapped in ctx.waitUntil():
33
+ * // export default { async scheduled(event, env, ctx) {
34
+ * // ctx.waitUntil(scheduler.runDueTasks())
35
+ * // } }
36
+ * // and in wrangler.toml: [triggers] crons = ["* * * * *"]
37
+ * void scheduler.runDueTasks()
41
38
  * ```
42
39
  *
43
40
  * @remarks
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiEG;AAEH,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AAEH,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA"}
package/dist/index.js CHANGED
@@ -10,34 +10,31 @@
10
10
  * change — only the bond wired in `bonds/`.
11
11
  *
12
12
  * @example
13
- * ```ts
14
- * // bonds/scheduler-cloudflare.ts
15
- * import { bond } from '@molecule/api-bond'
13
+ * ```typescript
14
+ * import { schedule, setProvider, start } from '@molecule/api-scheduler'
16
15
  * import { createProvider } from '@molecule/api-scheduler-cloudflare'
17
16
  *
18
- * export const scheduler = createProvider()
19
- * export function setupSchedulerCloudflare(): void {
20
- * bond('scheduler', scheduler)
21
- * }
22
- * ```
23
- *
24
- * ```ts
25
- * // worker.ts — the Cron Trigger entry point
26
- * import { scheduler } from './bonds/scheduler-cloudflare.js'
27
- * import { setupBonds } from './bonds/index.js'
17
+ * const scheduler = createProvider()
18
+ * setProvider(scheduler)
28
19
  *
29
- * export default {
30
- * async scheduled(_event, _env, ctx) {
31
- * await setupBonds() // registers tasks via schedule() + start()
32
- * ctx.waitUntil(scheduler.runDueTasks())
20
+ * schedule({
21
+ * name: 'monitor-sweep',
22
+ * intervalMs: 60000,
23
+ * async handler() {
24
+ * // ...
33
25
  * },
34
- * }
35
- * ```
26
+ * })
27
+ *
28
+ * // REQUIRED, same as the default provider: nothing runs until start().
29
+ * // Unlike it, start() begins no timers — a Worker has no process to hold one.
30
+ * start()
36
31
  *
37
- * ```toml
38
- * # wrangler.toml
39
- * [triggers]
40
- * crons = ["*/1 * * * *"] # the trigger schedule IS the schedule
32
+ * // Then, from the Worker's scheduled() handler, wrapped in ctx.waitUntil():
33
+ * // export default { async scheduled(event, env, ctx) {
34
+ * // ctx.waitUntil(scheduler.runDueTasks())
35
+ * // } }
36
+ * // and in wrangler.toml: [triggers] crons = ["* * * * *"]
37
+ * void scheduler.runDueTasks()
41
38
  * ```
42
39
  *
43
40
  * @remarks
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@molecule/api-scheduler-cloudflare",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Scheduler provider for Cloudflare Workers Cron Triggers — the platform owns the clock, so tasks run from the scheduled() handler instead of an in-process timer.",
5
+ "homepage": "https://www.molecule.dev/packages/api-scheduler-cloudflare",
5
6
  "type": "module",
6
7
  "main": "dist/index.js",
7
8
  "types": "dist/index.d.ts",
@@ -32,11 +33,11 @@
32
33
  "directory": "packages/api/bonds/scheduler/cloudflare"
33
34
  },
34
35
  "devDependencies": {
35
- "@molecule/api-bond": "1.0.1",
36
- "@molecule/api-scheduler": "1.0.1",
36
+ "@molecule/api-bond": "1.0.2",
37
+ "@molecule/api-scheduler": "1.0.2",
37
38
  "@types/node": "26.1.2",
38
39
  "typescript": "6.0.3",
39
- "vitest": "4.1.10"
40
+ "vitest": "4.1.11"
40
41
  },
41
42
  "peerDependencies": {
42
43
  "@molecule/api-scheduler": "^1.0.1",