@lunora/scheduler 1.0.0-alpha.1 → 1.0.0-alpha.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.mts CHANGED
@@ -131,10 +131,21 @@ interface Scheduler {
131
131
  scheduledFor: number;
132
132
  }>;
133
133
  }
134
+ /**
135
+ * Cloudflare Durable Object data-residency jurisdiction. Widening union —
136
+ * Cloudflare adds values over time.
137
+ * @see https://developers.cloudflare.com/durable-objects/reference/data-location/
138
+ */
139
+ type DurableObjectJurisdiction = "eu" | "fedramp" | "us";
134
140
  /** Subset of `DurableObjectNamespace` the package consumes. */
135
141
  interface DurableObjectNamespaceLike {
136
142
  get: (id: DurableObjectIdLike) => DurableObjectStubLike;
137
143
  idFromName: (name: string) => DurableObjectIdLike;
144
+ /**
145
+ * Derive a jurisdiction-restricted subnamespace. Optional because older
146
+ * workers-types releases (and test doubles) may not expose it.
147
+ */
148
+ jurisdiction?: (jurisdiction: DurableObjectJurisdiction) => DurableObjectNamespaceLike;
138
149
  }
139
150
  interface DurableObjectIdLike {
140
151
  toString: () => string;
@@ -145,6 +156,13 @@ interface DurableObjectStubLike {
145
156
  interface LunoraSchedulerOptions {
146
157
  /** Optional named instance — useful for tenant isolation. Default `default`. */
147
158
  instanceName?: string;
159
+ /**
160
+ * Pin the SchedulerDO (durable timers + cron state) to a Cloudflare
161
+ * data-residency jurisdiction. Pass the same value as the worker's
162
+ * `jurisdiction` so scheduled state co-resides with app data. Omit for the
163
+ * un-pinned global namespace.
164
+ */
165
+ jurisdiction?: DurableObjectJurisdiction;
148
166
  /** Binding to the `SchedulerDO` durable object namespace. */
149
167
  namespace: DurableObjectNamespaceLike;
150
168
  /**
@@ -782,4 +800,4 @@ declare const isValidCronExpression: (schedule: string) => boolean;
782
800
  * job (`cron job "send digest"`) vs. the bare trigger.
783
801
  */
784
802
  declare const assertValidCronExpression: (schedule: string, context?: string) => void;
785
- export { type ArgsOf, CRON_SCHEDULE_KINDS, type CronJob, type CronJobsBuilder, type CronScheduleKind, type CronTarget, type CronTriggerOptions, type CronTriggerSnippet, type DailySchedule, type DurableObjectIdLike, type DurableObjectNamespaceLike, type DurableObjectStubLike, type EnqueueOptions, type FunctionReference, type HttpDispatcherOptions, type IntervalSchedule, type LunoraSchedulerOptions, type MessageBatchLike, type MonthlySchedule, type QueueConsumerOptions, type QueueDispatch, type QueueEnqueueOptions, type QueueJob, type QueueLike, type QueueMessageLike, type QueueSendOptionsLike, type QueueSendRequestLike, type QueueWorkpool, type QueueWorkpoolOptions, type RetryPolicy, type RunOptions, type ScheduleRecord, type Scheduler, SchedulerDO, type SchedulerDOState, type SchedulerEnv, type SchedulerPoolStatus, type SchedulerStatus, type WeeklySchedule, type WorkflowReference, type Workpool, type WorkpoolOptions, assertValidCronExpression, compileCronSchedule, createCronTrigger, createQueueConsumer, createQueueWorkpool, createScheduler, createWorkpool, cronJobs, httpDispatcher, isValidCronExpression, isWorkflowReference };
803
+ export { type ArgsOf, CRON_SCHEDULE_KINDS, type CronJob, type CronJobsBuilder, type CronScheduleKind, type CronTarget, type CronTriggerOptions, type CronTriggerSnippet, type DailySchedule, type DurableObjectIdLike, type DurableObjectJurisdiction, type DurableObjectNamespaceLike, type DurableObjectStubLike, type EnqueueOptions, type FunctionReference, type HttpDispatcherOptions, type IntervalSchedule, type LunoraSchedulerOptions, type MessageBatchLike, type MonthlySchedule, type QueueConsumerOptions, type QueueDispatch, type QueueEnqueueOptions, type QueueJob, type QueueLike, type QueueMessageLike, type QueueSendOptionsLike, type QueueSendRequestLike, type QueueWorkpool, type QueueWorkpoolOptions, type RetryPolicy, type RunOptions, type ScheduleRecord, type Scheduler, SchedulerDO, type SchedulerDOState, type SchedulerEnv, type SchedulerPoolStatus, type SchedulerStatus, type WeeklySchedule, type WorkflowReference, type Workpool, type WorkpoolOptions, assertValidCronExpression, compileCronSchedule, createCronTrigger, createQueueConsumer, createQueueWorkpool, createScheduler, createWorkpool, cronJobs, httpDispatcher, isValidCronExpression, isWorkflowReference };
package/dist/index.d.ts CHANGED
@@ -131,10 +131,21 @@ interface Scheduler {
131
131
  scheduledFor: number;
132
132
  }>;
133
133
  }
134
+ /**
135
+ * Cloudflare Durable Object data-residency jurisdiction. Widening union —
136
+ * Cloudflare adds values over time.
137
+ * @see https://developers.cloudflare.com/durable-objects/reference/data-location/
138
+ */
139
+ type DurableObjectJurisdiction = "eu" | "fedramp" | "us";
134
140
  /** Subset of `DurableObjectNamespace` the package consumes. */
135
141
  interface DurableObjectNamespaceLike {
136
142
  get: (id: DurableObjectIdLike) => DurableObjectStubLike;
137
143
  idFromName: (name: string) => DurableObjectIdLike;
144
+ /**
145
+ * Derive a jurisdiction-restricted subnamespace. Optional because older
146
+ * workers-types releases (and test doubles) may not expose it.
147
+ */
148
+ jurisdiction?: (jurisdiction: DurableObjectJurisdiction) => DurableObjectNamespaceLike;
138
149
  }
139
150
  interface DurableObjectIdLike {
140
151
  toString: () => string;
@@ -145,6 +156,13 @@ interface DurableObjectStubLike {
145
156
  interface LunoraSchedulerOptions {
146
157
  /** Optional named instance — useful for tenant isolation. Default `default`. */
147
158
  instanceName?: string;
159
+ /**
160
+ * Pin the SchedulerDO (durable timers + cron state) to a Cloudflare
161
+ * data-residency jurisdiction. Pass the same value as the worker's
162
+ * `jurisdiction` so scheduled state co-resides with app data. Omit for the
163
+ * un-pinned global namespace.
164
+ */
165
+ jurisdiction?: DurableObjectJurisdiction;
148
166
  /** Binding to the `SchedulerDO` durable object namespace. */
149
167
  namespace: DurableObjectNamespaceLike;
150
168
  /**
@@ -782,4 +800,4 @@ declare const isValidCronExpression: (schedule: string) => boolean;
782
800
  * job (`cron job "send digest"`) vs. the bare trigger.
783
801
  */
784
802
  declare const assertValidCronExpression: (schedule: string, context?: string) => void;
785
- export { type ArgsOf, CRON_SCHEDULE_KINDS, type CronJob, type CronJobsBuilder, type CronScheduleKind, type CronTarget, type CronTriggerOptions, type CronTriggerSnippet, type DailySchedule, type DurableObjectIdLike, type DurableObjectNamespaceLike, type DurableObjectStubLike, type EnqueueOptions, type FunctionReference, type HttpDispatcherOptions, type IntervalSchedule, type LunoraSchedulerOptions, type MessageBatchLike, type MonthlySchedule, type QueueConsumerOptions, type QueueDispatch, type QueueEnqueueOptions, type QueueJob, type QueueLike, type QueueMessageLike, type QueueSendOptionsLike, type QueueSendRequestLike, type QueueWorkpool, type QueueWorkpoolOptions, type RetryPolicy, type RunOptions, type ScheduleRecord, type Scheduler, SchedulerDO, type SchedulerDOState, type SchedulerEnv, type SchedulerPoolStatus, type SchedulerStatus, type WeeklySchedule, type WorkflowReference, type Workpool, type WorkpoolOptions, assertValidCronExpression, compileCronSchedule, createCronTrigger, createQueueConsumer, createQueueWorkpool, createScheduler, createWorkpool, cronJobs, httpDispatcher, isValidCronExpression, isWorkflowReference };
803
+ export { type ArgsOf, CRON_SCHEDULE_KINDS, type CronJob, type CronJobsBuilder, type CronScheduleKind, type CronTarget, type CronTriggerOptions, type CronTriggerSnippet, type DailySchedule, type DurableObjectIdLike, type DurableObjectJurisdiction, type DurableObjectNamespaceLike, type DurableObjectStubLike, type EnqueueOptions, type FunctionReference, type HttpDispatcherOptions, type IntervalSchedule, type LunoraSchedulerOptions, type MessageBatchLike, type MonthlySchedule, type QueueConsumerOptions, type QueueDispatch, type QueueEnqueueOptions, type QueueJob, type QueueLike, type QueueMessageLike, type QueueSendOptionsLike, type QueueSendRequestLike, type QueueWorkpool, type QueueWorkpoolOptions, type RetryPolicy, type RunOptions, type ScheduleRecord, type Scheduler, SchedulerDO, type SchedulerDOState, type SchedulerEnv, type SchedulerPoolStatus, type SchedulerStatus, type WeeklySchedule, type WorkflowReference, type Workpool, type WorkpoolOptions, assertValidCronExpression, compileCronSchedule, createCronTrigger, createQueueConsumer, createQueueWorkpool, createScheduler, createWorkpool, cronJobs, httpDispatcher, isValidCronExpression, isWorkflowReference };
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
- export { default as createScheduler } from './packem_shared/createScheduler-KCso4_at.mjs';
2
- export { default as createWorkpool } from './packem_shared/createWorkpool-D5cWPQmH.mjs';
1
+ export { default as createScheduler } from './packem_shared/createScheduler-CWMn70nv.mjs';
2
+ export { default as createWorkpool } from './packem_shared/createWorkpool-CEnqCafM.mjs';
3
3
  export { createCronTrigger } from './packem_shared/createCronTrigger-Cq9IBcWQ.mjs';
4
- export { CRON_SCHEDULE_KINDS, compileCronSchedule, cronJobs } from './packem_shared/compileCronSchedule-BaLlXJiN.mjs';
4
+ export { CRON_SCHEDULE_KINDS, compileCronSchedule, cronJobs } from './packem_shared/CRON_SCHEDULE_KINDS-BaLlXJiN.mjs';
5
5
  export { createQueueConsumer, createQueueWorkpool, httpDispatcher } from './packem_shared/createQueueConsumer-DWahNPfz.mjs';
6
6
  export { SchedulerDO } from './packem_shared/SchedulerDO-BNzXNnS4.mjs';
7
7
  export { isWorkflowReference } from './packem_shared/isWorkflowReference-C9mQkMXt.mjs';
@@ -1,5 +1,11 @@
1
+ import { a as applyJurisdiction } from './jurisdiction-CR2zC3Et.mjs';
2
+
3
+ const schedulerStub = (options) => {
4
+ const namespace = applyJurisdiction(options.namespace, options.jurisdiction);
5
+ return namespace.get(namespace.idFromName(options.instanceName ?? "default"));
6
+ };
1
7
  const callDO = async (options, path, body) => {
2
- const stub = options.namespace.get(options.namespace.idFromName(options.instanceName ?? "default"));
8
+ const stub = schedulerStub(options);
3
9
  const response = await stub.fetch(`https://scheduler.internal${path}`, {
4
10
  body: JSON.stringify(body),
5
11
  headers: { "content-type": "application/json" },
@@ -12,7 +18,7 @@ const callDO = async (options, path, body) => {
12
18
  return await response.json();
13
19
  };
14
20
  const getDO = async (options, path) => {
15
- const stub = options.namespace.get(options.namespace.idFromName(options.instanceName ?? "default"));
21
+ const stub = schedulerStub(options);
16
22
  const response = await stub.fetch(`https://scheduler.internal${path}`, { method: "GET" });
17
23
  if (!response.ok) {
18
24
  const text = await response.text();
@@ -1,5 +1,11 @@
1
+ import { a as applyJurisdiction } from './jurisdiction-CR2zC3Et.mjs';
2
+
3
+ const workpoolStub = (options) => {
4
+ const namespace = applyJurisdiction(options.namespace, options.jurisdiction);
5
+ return namespace.get(namespace.idFromName(options.instanceName ?? "default"));
6
+ };
1
7
  const callDO = async (options, path, body) => {
2
- const stub = options.namespace.get(options.namespace.idFromName(options.instanceName ?? "default"));
8
+ const stub = workpoolStub(options);
3
9
  const response = await stub.fetch(`https://scheduler.internal${path}`, {
4
10
  body: JSON.stringify(body),
5
11
  headers: { "content-type": "application/json" },
@@ -12,7 +18,7 @@ const callDO = async (options, path, body) => {
12
18
  return await response.json();
13
19
  };
14
20
  const getDO = async (options, path) => {
15
- const stub = options.namespace.get(options.namespace.idFromName(options.instanceName ?? "default"));
21
+ const stub = workpoolStub(options);
16
22
  const response = await stub.fetch(`https://scheduler.internal${path}`, { method: "GET" });
17
23
  if (!response.ok) {
18
24
  const text = await response.text();
@@ -0,0 +1,13 @@
1
+ const applyJurisdiction = (namespace, jurisdiction) => {
2
+ if (jurisdiction === void 0) {
3
+ return namespace;
4
+ }
5
+ if (typeof namespace.jurisdiction !== "function") {
6
+ throw new TypeError(
7
+ `@lunora/scheduler: Durable Object namespace does not support jurisdiction("${jurisdiction}") — update @cloudflare/workers-types or remove the jurisdiction option`
8
+ );
9
+ }
10
+ return namespace.jurisdiction(jurisdiction);
11
+ };
12
+
13
+ export { applyJurisdiction as a };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/scheduler",
3
- "version": "1.0.0-alpha.1",
3
+ "version": "1.0.0-alpha.3",
4
4
  "description": "Scheduling for Lunora: runAfter / runAt and Cron Triggers via SchedulerDO",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -25,7 +25,7 @@
25
25
  "directory": "packages/scheduler"
26
26
  },
27
27
  "files": [
28
- "dist",
28
+ "./dist",
29
29
  "__assets__",
30
30
  "README.md",
31
31
  "LICENSE.md"