@lunora/scheduler 1.0.0-alpha.127 → 1.0.0-alpha.129

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
@@ -1,4 +1,5 @@
1
1
  import { SchedulerHost } from '@lunora/platform';
2
+ export { a as assertValidCronExpression, i as isValidCronExpression, w as warnIfSecondsLeading } from "./packem_shared/validate-cron-full.d-Bemx45E8.mjs";
2
3
  /**
3
4
  * The generated function-reference type, shared by every package that needs to
4
5
  * infer a call's args or return from `api.<file>.<fn>`.
@@ -656,7 +657,7 @@ declare const compileCronSchedule: (kind: CronScheduleKind, schedule: DailySched
656
657
  */
657
658
  interface CronJobsBuilder {
658
659
  /**
659
- * Raw cron expression escape hatch (5- or 6-field, full cron-parser grammar).
660
+ * Raw cron expression escape hatch (5- or 6-field, full `@visulima/cron-parser` Cloudflare grammar).
660
661
  * The target may be a function (`internal.file.fn`) or a durable workflow
661
662
  * (`workflows.<name>`); a workflow's `args` are inferred from its `params`.
662
663
  */
@@ -1380,33 +1381,6 @@ interface SchedulerHostOptions {
1380
1381
  * The returned host has no `cron` member — see the module docstring.
1381
1382
  */
1382
1383
  declare const createSchedulerHost: (options: SchedulerHostOptions) => SchedulerHost;
1383
- /** Standard cron expression (5- or 6-field) or a supported `@macro`. */
1384
- declare const isValidCronExpression: (schedule: string) => boolean;
1385
- /**
1386
- * A 6-field (seconds-leading) cron expression is legal generic cron grammar
1387
- * but not a Cloudflare Cron Trigger — the platform only understands the
1388
- * 5-field, minute-granularity form and rejects the rest at `wrangler deploy`
1389
- * with a message naming neither the job nor the file. Warn here instead of
1390
- * staying silent, without throwing: unlike the ergonomic `.interval()` form,
1391
- * the raw `.cron()` escape hatch is meant to accept cron grammar this module
1392
- * doesn't otherwise second-guess.
1393
- *
1394
- * Exported (not module-private) because it is the ONE place this advisory is
1395
- * written: the runtime `cronJobs()` builder reaches it via
1396
- * {@link assertValidCronExpression}, and `@lunora/codegen`'s static
1397
- * `discover/crons.ts` calls it directly after its own `isValidCronExpression`
1398
- * check — so a hand-authored 6-field `.cron()` warns whether it's discovered
1399
- * from source at build time or registered at runtime, with one shared message.
1400
- */
1401
- declare const warnIfSecondsLeading: (schedule: string, context: string) => void;
1402
- /**
1403
- * Assert a raw cron expression is well-formed, throwing the same shaped error
1404
- * both cron surfaces use. The `context` prefix lets callers name the offending
1405
- * job (`cron job "send digest"`) vs. the bare trigger. Well-formed but
1406
- * Cloudflare-incompatible (6-field) expressions pass but log a warning — see
1407
- * {@link warnIfSecondsLeading}.
1408
- */
1409
- declare const assertValidCronExpression: (schedule: string, context?: string) => void;
1410
1384
  /**
1411
1385
  * Reject a `delayMs` a scheduler cannot act on, before it reaches the
1412
1386
  * SchedulerDO.
@@ -1452,4 +1426,4 @@ declare const assertScheduleDelay: (delayMs: number, surface: string, argument?:
1452
1426
  * @param surface what to name in the message — the call the instant was passed to (e.g. `"ctx.scheduler.runAt"`)
1453
1427
  */
1454
1428
  declare const assertScheduleInstant: (timestampMs: number, nowMs: number, surface: string) => void;
1455
- 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 FunctionKind, type FunctionReference, type HourlySchedule, type HttpDispatcherOptions, type IntervalSchedule, type LunoraSchedulerOptions, MAX_RETRY_ATTEMPTS, type MessageBatchLike, type MonthlySchedule, type QueueConsumerOptions, type QueueDispatch, type QueueEnqueueOptions, type QueueJob, type QueueLike, type QueueMessageLike, type QueueSendOptionsLike, type QueueSendRequestLike, type QueueWorkpool, type QueueWorkpoolOptions, RETRY_BASE_DELAY_MS, type RetryPolicy, type RunOptions, type ScheduleRecord, type Scheduler, SchedulerDO, type SchedulerDOState, type SchedulerEnv, type SchedulerHostOptions, type SchedulerPoolStatus, type SchedulerStatus, type WeeklySchedule, type WorkflowReference, type Workpool, type WorkpoolOptions, assertScheduleDelay, assertScheduleInstant, assertValidCronExpression, compileCronSchedule, createCronTrigger, createQueueConsumer, createQueueWorkpool, createScheduler, createSchedulerHost, createWorkpool, cronJobs, httpDispatcher, isValidCronExpression, isWorkflowReference, resolveScheduleId, warnIfSecondsLeading };
1429
+ 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 FunctionKind, type FunctionReference, type HourlySchedule, type HttpDispatcherOptions, type IntervalSchedule, type LunoraSchedulerOptions, MAX_RETRY_ATTEMPTS, type MessageBatchLike, type MonthlySchedule, type QueueConsumerOptions, type QueueDispatch, type QueueEnqueueOptions, type QueueJob, type QueueLike, type QueueMessageLike, type QueueSendOptionsLike, type QueueSendRequestLike, type QueueWorkpool, type QueueWorkpoolOptions, RETRY_BASE_DELAY_MS, type RetryPolicy, type RunOptions, type ScheduleRecord, type Scheduler, SchedulerDO, type SchedulerDOState, type SchedulerEnv, type SchedulerHostOptions, type SchedulerPoolStatus, type SchedulerStatus, type WeeklySchedule, type WorkflowReference, type Workpool, type WorkpoolOptions, assertScheduleDelay, assertScheduleInstant, compileCronSchedule, createCronTrigger, createQueueConsumer, createQueueWorkpool, createScheduler, createSchedulerHost, createWorkpool, cronJobs, httpDispatcher, isWorkflowReference, resolveScheduleId };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { SchedulerHost } from '@lunora/platform';
2
+ export { a as assertValidCronExpression, i as isValidCronExpression, w as warnIfSecondsLeading } from "./packem_shared/validate-cron-full.d-Bemx45E8.js";
2
3
  /**
3
4
  * The generated function-reference type, shared by every package that needs to
4
5
  * infer a call's args or return from `api.<file>.<fn>`.
@@ -656,7 +657,7 @@ declare const compileCronSchedule: (kind: CronScheduleKind, schedule: DailySched
656
657
  */
657
658
  interface CronJobsBuilder {
658
659
  /**
659
- * Raw cron expression escape hatch (5- or 6-field, full cron-parser grammar).
660
+ * Raw cron expression escape hatch (5- or 6-field, full `@visulima/cron-parser` Cloudflare grammar).
660
661
  * The target may be a function (`internal.file.fn`) or a durable workflow
661
662
  * (`workflows.<name>`); a workflow's `args` are inferred from its `params`.
662
663
  */
@@ -1380,33 +1381,6 @@ interface SchedulerHostOptions {
1380
1381
  * The returned host has no `cron` member — see the module docstring.
1381
1382
  */
1382
1383
  declare const createSchedulerHost: (options: SchedulerHostOptions) => SchedulerHost;
1383
- /** Standard cron expression (5- or 6-field) or a supported `@macro`. */
1384
- declare const isValidCronExpression: (schedule: string) => boolean;
1385
- /**
1386
- * A 6-field (seconds-leading) cron expression is legal generic cron grammar
1387
- * but not a Cloudflare Cron Trigger — the platform only understands the
1388
- * 5-field, minute-granularity form and rejects the rest at `wrangler deploy`
1389
- * with a message naming neither the job nor the file. Warn here instead of
1390
- * staying silent, without throwing: unlike the ergonomic `.interval()` form,
1391
- * the raw `.cron()` escape hatch is meant to accept cron grammar this module
1392
- * doesn't otherwise second-guess.
1393
- *
1394
- * Exported (not module-private) because it is the ONE place this advisory is
1395
- * written: the runtime `cronJobs()` builder reaches it via
1396
- * {@link assertValidCronExpression}, and `@lunora/codegen`'s static
1397
- * `discover/crons.ts` calls it directly after its own `isValidCronExpression`
1398
- * check — so a hand-authored 6-field `.cron()` warns whether it's discovered
1399
- * from source at build time or registered at runtime, with one shared message.
1400
- */
1401
- declare const warnIfSecondsLeading: (schedule: string, context: string) => void;
1402
- /**
1403
- * Assert a raw cron expression is well-formed, throwing the same shaped error
1404
- * both cron surfaces use. The `context` prefix lets callers name the offending
1405
- * job (`cron job "send digest"`) vs. the bare trigger. Well-formed but
1406
- * Cloudflare-incompatible (6-field) expressions pass but log a warning — see
1407
- * {@link warnIfSecondsLeading}.
1408
- */
1409
- declare const assertValidCronExpression: (schedule: string, context?: string) => void;
1410
1384
  /**
1411
1385
  * Reject a `delayMs` a scheduler cannot act on, before it reaches the
1412
1386
  * SchedulerDO.
@@ -1452,4 +1426,4 @@ declare const assertScheduleDelay: (delayMs: number, surface: string, argument?:
1452
1426
  * @param surface what to name in the message — the call the instant was passed to (e.g. `"ctx.scheduler.runAt"`)
1453
1427
  */
1454
1428
  declare const assertScheduleInstant: (timestampMs: number, nowMs: number, surface: string) => void;
1455
- 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 FunctionKind, type FunctionReference, type HourlySchedule, type HttpDispatcherOptions, type IntervalSchedule, type LunoraSchedulerOptions, MAX_RETRY_ATTEMPTS, type MessageBatchLike, type MonthlySchedule, type QueueConsumerOptions, type QueueDispatch, type QueueEnqueueOptions, type QueueJob, type QueueLike, type QueueMessageLike, type QueueSendOptionsLike, type QueueSendRequestLike, type QueueWorkpool, type QueueWorkpoolOptions, RETRY_BASE_DELAY_MS, type RetryPolicy, type RunOptions, type ScheduleRecord, type Scheduler, SchedulerDO, type SchedulerDOState, type SchedulerEnv, type SchedulerHostOptions, type SchedulerPoolStatus, type SchedulerStatus, type WeeklySchedule, type WorkflowReference, type Workpool, type WorkpoolOptions, assertScheduleDelay, assertScheduleInstant, assertValidCronExpression, compileCronSchedule, createCronTrigger, createQueueConsumer, createQueueWorkpool, createScheduler, createSchedulerHost, createWorkpool, cronJobs, httpDispatcher, isValidCronExpression, isWorkflowReference, resolveScheduleId, warnIfSecondsLeading };
1429
+ 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 FunctionKind, type FunctionReference, type HourlySchedule, type HttpDispatcherOptions, type IntervalSchedule, type LunoraSchedulerOptions, MAX_RETRY_ATTEMPTS, type MessageBatchLike, type MonthlySchedule, type QueueConsumerOptions, type QueueDispatch, type QueueEnqueueOptions, type QueueJob, type QueueLike, type QueueMessageLike, type QueueSendOptionsLike, type QueueSendRequestLike, type QueueWorkpool, type QueueWorkpoolOptions, RETRY_BASE_DELAY_MS, type RetryPolicy, type RunOptions, type ScheduleRecord, type Scheduler, SchedulerDO, type SchedulerDOState, type SchedulerEnv, type SchedulerHostOptions, type SchedulerPoolStatus, type SchedulerStatus, type WeeklySchedule, type WorkflowReference, type Workpool, type WorkpoolOptions, assertScheduleDelay, assertScheduleInstant, compileCronSchedule, createCronTrigger, createQueueConsumer, createQueueWorkpool, createScheduler, createSchedulerHost, createWorkpool, cronJobs, httpDispatcher, isWorkflowReference, resolveScheduleId };
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{default as o}from"./packem_shared/createScheduler-3p6oGhSi.mjs";import{default as a}from"./packem_shared/createWorkpool-Bo9avoNF.mjs";import{createCronTrigger as f}from"./packem_shared/createCronTrigger-Ci0xpx1L.mjs";import{CRON_SCHEDULE_KINDS as p,compileCronSchedule as c,cronJobs as d}from"./packem_shared/CRON_SCHEDULE_KINDS-On2YWczq.mjs";import{createQueueConsumer as m,createQueueWorkpool as n,httpDispatcher as x}from"./packem_shared/createQueueConsumer-B2s3Xod5.mjs";import{r as i}from"./packem_shared/resolve-schedule-id-B2ghxgFm.mjs";import{MAX_RETRY_ATTEMPTS as E,RETRY_BASE_DELAY_MS as C,SchedulerDO as _}from"./packem_shared/MAX_RETRY_ATTEMPTS-C7-WenJ5.mjs";import{createSchedulerHost as R}from"./packem_shared/createSchedulerHost-Cjqd9wDF.mjs";import{isWorkflowReference as A}from"./packem_shared/isWorkflowReference-CT3tdefh.mjs";import{assertValidCronExpression as g,isValidCronExpression as k,warnIfSecondsLeading as L}from"./packem_shared/assertValidCronExpression-BSVKB5wG.mjs";import{default as W}from"./packem_shared/assertScheduleDelay-CVFZanKn.mjs";import{default as w}from"./packem_shared/assertScheduleInstant-DcEKtg0c.mjs";export{p as CRON_SCHEDULE_KINDS,E as MAX_RETRY_ATTEMPTS,C as RETRY_BASE_DELAY_MS,_ as SchedulerDO,W as assertScheduleDelay,w as assertScheduleInstant,g as assertValidCronExpression,c as compileCronSchedule,f as createCronTrigger,m as createQueueConsumer,n as createQueueWorkpool,o as createScheduler,R as createSchedulerHost,a as createWorkpool,d as cronJobs,x as httpDispatcher,k as isValidCronExpression,A as isWorkflowReference,i as resolveScheduleId,L as warnIfSecondsLeading};
1
+ import{default as o}from"./packem_shared/createScheduler-3p6oGhSi.mjs";import{default as a}from"./packem_shared/createWorkpool-Bo9avoNF.mjs";import{createCronTrigger as f}from"./packem_shared/createCronTrigger-cg32QNgj.mjs";import{CRON_SCHEDULE_KINDS as p,compileCronSchedule as c,cronJobs as d}from"./packem_shared/CRON_SCHEDULE_KINDS-v0tEYoxJ.mjs";import{createQueueConsumer as m,createQueueWorkpool as n,httpDispatcher as x}from"./packem_shared/createQueueConsumer-B2s3Xod5.mjs";import{r as i}from"./packem_shared/resolve-schedule-id-B2ghxgFm.mjs";import{MAX_RETRY_ATTEMPTS as E,RETRY_BASE_DELAY_MS as C,SchedulerDO as _}from"./packem_shared/MAX_RETRY_ATTEMPTS-C7-WenJ5.mjs";import{createSchedulerHost as R}from"./packem_shared/createSchedulerHost-Cjqd9wDF.mjs";import{isWorkflowReference as A}from"./packem_shared/isWorkflowReference-CT3tdefh.mjs";import{assertValidCronExpression as g,isValidCronExpression as k,warnIfSecondsLeading as L}from"./packem_shared/assertValidCronExpression-fiNfNiWf.mjs";import{default as W}from"./packem_shared/assertScheduleDelay-CVFZanKn.mjs";import{default as w}from"./packem_shared/assertScheduleInstant-DcEKtg0c.mjs";export{p as CRON_SCHEDULE_KINDS,E as MAX_RETRY_ATTEMPTS,C as RETRY_BASE_DELAY_MS,_ as SchedulerDO,W as assertScheduleDelay,w as assertScheduleInstant,g as assertValidCronExpression,c as compileCronSchedule,f as createCronTrigger,m as createQueueConsumer,n as createQueueWorkpool,o as createScheduler,R as createSchedulerHost,a as createWorkpool,d as cronJobs,x as httpDispatcher,k as isValidCronExpression,A as isWorkflowReference,i as resolveScheduleId,L as warnIfSecondsLeading};
@@ -1 +1 @@
1
- import{LunoraError as l}from"@lunora/errors";import{isWorkflowReference as m}from"./isWorkflowReference-CT3tdefh.mjs";import{assertValidCronExpression as f}from"./assertValidCronExpression-BSVKB5wG.mjs";const w={friday:5,monday:1,saturday:6,sunday:0,thursday:4,tuesday:2,wednesday:3},T=24,h=" For a daily or longer schedule use crons.daily(name, { hourUTC, minuteUTC }, …), crons.weekly(name, { dayOfWeek, hourUTC, minuteUTC }, …) or crons.monthly(name, { day, hourUTC, minuteUTC }, …).",a=(e,o,r,i)=>{if(!Number.isInteger(e)||e<r||e>i)throw new l("INTERNAL",`@lunora/scheduler: cronJobs ${o} must be an integer in [${r.toFixed(0)}, ${i.toFixed(0)}], got ${String(e)}`);return e.toFixed(0)},y=(e,o,r)=>{const i=a(e,o,1,r-1);if(r%e!==0)throw new l("INTERNAL",`@lunora/scheduler: ${o} must evenly divide ${r.toFixed(0)} for a fixed "every ${e.toFixed(0)}" interval — cron "*/${e.toFixed(0)}" means "at values divisible by ${e.toFixed(0)}", which wraps unevenly; pick a divisor of ${r.toFixed(0)}`);return i},$=(e,o)=>{const r=["seconds","minutes","hours"].filter(s=>e[s]!==void 0);if(r.length!==1){const s=Object.entries(e).filter(([,t])=>t!==void 0).map(([t])=>t);throw new l("INTERNAL",`@lunora/scheduler: interval schedule must specify exactly one of { seconds, minutes, hours }, got { ${s.join(", ")} }.${h}`)}const i=r[0],n=e[i];if(i==="hours"&&n>=T)throw new l("INTERNAL",`@lunora/scheduler: interval.hours is capped at 23, got ${String(n)} — an interval repeats WITHIN a day rather than spanning one.${h}`);if(i==="seconds")throw new l("INTERNAL",`@lunora/scheduler: cron job${o?` "${o}"`:""} uses interval.seconds (${String(n)}) — Cloudflare Cron Triggers have a one-minute floor and cannot run sub-minute schedules; \`wrangler deploy\` would reject the resulting 6-field cron expression. Use ctx.scheduler.runAfter/runAt (optionally via a workpool for bounded concurrency) for sub-minute recurrence, or crons.interval(name, { minutes: 1 }, …) for the fastest cron-native cadence.`);return i==="minutes"?`*/${y(n,"interval.minutes",60)} * * * *`:`0 */${y(n,"interval.hours",24)} * * *`},p=e=>`${a(e.minuteUTC,"hourly.minuteUTC",0,59)} * * * *`,C=e=>{const o=a(e.minuteUTC,"daily.minuteUTC",0,59),r=a(e.hourUTC,"daily.hourUTC",0,23);return`${o} ${r} * * *`},N=e=>{const o=w[e.dayOfWeek];if(o===void 0)throw new l("INTERNAL",`@lunora/scheduler: weekly schedule has invalid dayOfWeek "${e.dayOfWeek}"`);const r=a(e.minuteUTC,"weekly.minuteUTC",0,59),i=a(e.hourUTC,"weekly.hourUTC",0,23);return`${r} ${i} * * ${o.toFixed(0)}`},U=e=>{const o=a(e.day,"monthly.day",1,31),r=a(e.minuteUTC,"monthly.minuteUTC",0,59),i=a(e.hourUTC,"monthly.hourUTC",0,23);return`${r} ${i} ${o} * *`},b=new Set(["daily","hourly","interval","monthly","weekly"]),c=(e,o,r)=>{switch(e){case"daily":return C(o);case"hourly":return p(o);case"interval":return $(o,r);case"monthly":return U(o);case"weekly":return N(o);default:throw new l("INTERNAL",`@lunora/scheduler: unknown cron schedule kind "${String(e)}"`)}},k=()=>{const e=[],o=new Set,r=(n,s,t,u)=>{if(typeof n!="string"||n.trim()==="")throw new l("INTERNAL","@lunora/scheduler: cron job name must be a non-empty string");if(o.has(n))throw new l("INTERNAL",`@lunora/scheduler: duplicate cron job name "${n}" — names must be unique within one cronJobs()`);let d;if(m(t))d={workflow:typeof t.name=="string"?t.name:""};else if(t&&typeof t.__lunoraRef=="string")d={functionPath:t.__lunoraRef};else throw new l("INTERNAL",`@lunora/scheduler: cron job "${n}" requires a function reference (e.g. internal.email.digest) or a workflow reference`);f(s,`cron expression for job "${n}"`),o.add(n),e.push({args:u??{},cron:s,name:n,...d})},i={cron(n,s,t,u){return r(n,s,t,u),i},daily(n,s,t,u){return r(n,c("daily",s),t,u),i},hourly(n,s,t,u){return r(n,c("hourly",s),t,u),i},interval(n,s,t,u){return r(n,c("interval",s,n),t,u),i},jobs:()=>[...e],monthly(n,s,t,u){return r(n,c("monthly",s),t,u),i},weekly(n,s,t,u){return r(n,c("weekly",s),t,u),i}};return i};export{b as CRON_SCHEDULE_KINDS,c as compileCronSchedule,k as cronJobs};
1
+ import{LunoraError as l}from"@lunora/errors";import{isWorkflowReference as m}from"./isWorkflowReference-CT3tdefh.mjs";import{assertValidCronExpression as f}from"./assertValidCronExpression-fiNfNiWf.mjs";const w={friday:6,monday:2,saturday:7,sunday:1,thursday:5,tuesday:3,wednesday:4},T=24,h=" For a daily or longer schedule use crons.daily(name, { hourUTC, minuteUTC }, …), crons.weekly(name, { dayOfWeek, hourUTC, minuteUTC }, …) or crons.monthly(name, { day, hourUTC, minuteUTC }, …).",a=(e,o,r,i)=>{if(!Number.isInteger(e)||e<r||e>i)throw new l("INTERNAL",`@lunora/scheduler: cronJobs ${o} must be an integer in [${r.toFixed(0)}, ${i.toFixed(0)}], got ${String(e)}`);return e.toFixed(0)},y=(e,o,r)=>{const i=a(e,o,1,r-1);if(r%e!==0)throw new l("INTERNAL",`@lunora/scheduler: ${o} must evenly divide ${r.toFixed(0)} for a fixed "every ${e.toFixed(0)}" interval — cron "*/${e.toFixed(0)}" means "at values divisible by ${e.toFixed(0)}", which wraps unevenly; pick a divisor of ${r.toFixed(0)}`);return i},$=(e,o)=>{const r=["seconds","minutes","hours"].filter(s=>e[s]!==void 0);if(r.length!==1){const s=Object.entries(e).filter(([,t])=>t!==void 0).map(([t])=>t);throw new l("INTERNAL",`@lunora/scheduler: interval schedule must specify exactly one of { seconds, minutes, hours }, got { ${s.join(", ")} }.${h}`)}const i=r[0],n=e[i];if(i==="hours"&&n>=T)throw new l("INTERNAL",`@lunora/scheduler: interval.hours is capped at 23, got ${String(n)} — an interval repeats WITHIN a day rather than spanning one.${h}`);if(i==="seconds")throw new l("INTERNAL",`@lunora/scheduler: cron job${o?` "${o}"`:""} uses interval.seconds (${String(n)}) — Cloudflare Cron Triggers have a one-minute floor and cannot run sub-minute schedules; \`wrangler deploy\` would reject the resulting 6-field cron expression. Use ctx.scheduler.runAfter/runAt (optionally via a workpool for bounded concurrency) for sub-minute recurrence, or crons.interval(name, { minutes: 1 }, …) for the fastest cron-native cadence.`);return i==="minutes"?`*/${y(n,"interval.minutes",60)} * * * *`:`0 */${y(n,"interval.hours",24)} * * *`},p=e=>`${a(e.minuteUTC,"hourly.minuteUTC",0,59)} * * * *`,C=e=>{const o=a(e.minuteUTC,"daily.minuteUTC",0,59),r=a(e.hourUTC,"daily.hourUTC",0,23);return`${o} ${r} * * *`},N=e=>{const o=w[e.dayOfWeek];if(o===void 0)throw new l("INTERNAL",`@lunora/scheduler: weekly schedule has invalid dayOfWeek "${e.dayOfWeek}"`);const r=a(e.minuteUTC,"weekly.minuteUTC",0,59),i=a(e.hourUTC,"weekly.hourUTC",0,23);return`${r} ${i} * * ${o.toFixed(0)}`},U=e=>{const o=a(e.day,"monthly.day",1,31),r=a(e.minuteUTC,"monthly.minuteUTC",0,59),i=a(e.hourUTC,"monthly.hourUTC",0,23);return`${r} ${i} ${o} * *`},b=new Set(["daily","hourly","interval","monthly","weekly"]),c=(e,o,r)=>{switch(e){case"daily":return C(o);case"hourly":return p(o);case"interval":return $(o,r);case"monthly":return U(o);case"weekly":return N(o);default:throw new l("INTERNAL",`@lunora/scheduler: unknown cron schedule kind "${String(e)}"`)}},k=()=>{const e=[],o=new Set,r=(n,s,t,u)=>{if(typeof n!="string"||n.trim()==="")throw new l("INTERNAL","@lunora/scheduler: cron job name must be a non-empty string");if(o.has(n))throw new l("INTERNAL",`@lunora/scheduler: duplicate cron job name "${n}" — names must be unique within one cronJobs()`);let d;if(m(t))d={workflow:typeof t.name=="string"?t.name:""};else if(t&&typeof t.__lunoraRef=="string")d={functionPath:t.__lunoraRef};else throw new l("INTERNAL",`@lunora/scheduler: cron job "${n}" requires a function reference (e.g. internal.email.digest) or a workflow reference`);f(s,`cron expression for job "${n}"`),o.add(n),e.push({args:u??{},cron:s,name:n,...d})},i={cron(n,s,t,u){return r(n,s,t,u),i},daily(n,s,t,u){return r(n,c("daily",s),t,u),i},hourly(n,s,t,u){return r(n,c("hourly",s),t,u),i},interval(n,s,t,u){return r(n,c("interval",s,n),t,u),i},jobs:()=>[...e],monthly(n,s,t,u){return r(n,c("monthly",s),t,u),i},weekly(n,s,t,u){return r(n,c("weekly",s),t,u),i}};return i};export{b as CRON_SCHEDULE_KINDS,c as compileCronSchedule,k as cronJobs};
@@ -0,0 +1 @@
1
+ import{LunoraError as o}from"@lunora/errors";import{parse as s}from"@visulima/cron-parser/cloudflare";const n=/\s+/u,t={seconds:"optional"},i=r=>{if(typeof r!="string")return!1;const e=r.trim().split(n);if(e.length!==5&&e.length!==6)return!1;try{return s(e.join(" "),t),!0}catch{return!1}},a=(r,e)=>{r.trim().split(n).length===6&&console.warn(`@lunora/scheduler: ${e} "${r}" is a 6-field (seconds-leading) cron expression — Cloudflare Cron Triggers only support the standard 5-field form and will reject this at \`wrangler deploy\`. Drop the seconds field, or use ctx.scheduler.runAfter/runAt for sub-minute work.`)},f=(r,e="cron expression")=>{if(!i(r))throw new o("INTERNAL",`@lunora/scheduler: invalid ${e} "${r}" — expected a standard 5- or 6-field cron expression (e.g. "0 * * * *")`);a(r,e)};export{f as assertValidCronExpression,i as isValidCronExpression,a as warnIfSecondsLeading};
@@ -1 +1 @@
1
- import{LunoraError as n}from"@lunora/errors";import{assertValidCronExpression as s}from"./assertValidCronExpression-BSVKB5wG.mjs";const u=r=>{if(!r.schedule||!r.fn)throw new n("INTERNAL","@lunora/scheduler: createCronTrigger() requires `schedule` and `fn`");s(r.schedule);const e=JSON.stringify({triggers:{crons:[r.schedule]}},void 0,2);return{crons:[r.schedule],dispatcher:{args:r.args??{},functionPath:r.fn.__lunoraRef},wranglerJsonc:e}};export{u as createCronTrigger};
1
+ import{LunoraError as n}from"@lunora/errors";import{assertValidCronExpression as s}from"./assertValidCronExpression-fiNfNiWf.mjs";const u=r=>{if(!r.schedule||!r.fn)throw new n("INTERNAL","@lunora/scheduler: createCronTrigger() requires `schedule` and `fn`");s(r.schedule);const e=JSON.stringify({triggers:{crons:[r.schedule]}},void 0,2);return{crons:[r.schedule],dispatcher:{args:r.args??{},functionPath:r.fn.__lunoraRef},wranglerJsonc:e}};export{u as createCronTrigger};
@@ -0,0 +1,28 @@
1
+ /** True when `schedule` is a Cloudflare Cron Trigger expression (or a 6-field escape-hatch one). */
2
+ declare const isValidCronExpression: (schedule: string) => boolean;
3
+ /**
4
+ * A 6-field (seconds-leading) cron expression is legal generic cron grammar but
5
+ * not a Cloudflare Cron Trigger — the platform only understands the 5-field,
6
+ * minute-granularity form and rejects the rest at `wrangler deploy` with a
7
+ * message naming neither the job nor the file. Warn here instead of staying
8
+ * silent, without throwing: unlike the ergonomic `.interval()` form, the raw
9
+ * `.cron()` escape hatch is meant to accept cron grammar this module doesn't
10
+ * otherwise second-guess.
11
+ *
12
+ * Exported (not module-private) because it is the ONE place this advisory is
13
+ * written: the runtime `cronJobs()` builder reaches it via
14
+ * {@link assertValidCronExpression}, and `@lunora/codegen`'s static
15
+ * `discover/crons.ts` calls it directly after its own `isValidCronExpression`
16
+ * check — so a hand-authored 6-field `.cron()` warns whether it's discovered
17
+ * from source at build time or registered at runtime, with one shared message.
18
+ */
19
+ declare const warnIfSecondsLeading: (schedule: string, context: string) => void;
20
+ /**
21
+ * Assert a raw cron expression is well-formed, throwing the same shaped error
22
+ * both cron surfaces use. The `context` prefix lets callers name the offending
23
+ * job (`cron job "send digest"`) vs. the bare trigger. Well-formed but
24
+ * Cloudflare-incompatible (6-field) expressions pass but log a warning — see
25
+ * {@link warnIfSecondsLeading}.
26
+ */
27
+ declare const assertValidCronExpression: (schedule: string, context?: string) => void;
28
+ export { assertValidCronExpression as a, isValidCronExpression as i, warnIfSecondsLeading as w };
@@ -0,0 +1,28 @@
1
+ /** True when `schedule` is a Cloudflare Cron Trigger expression (or a 6-field escape-hatch one). */
2
+ declare const isValidCronExpression: (schedule: string) => boolean;
3
+ /**
4
+ * A 6-field (seconds-leading) cron expression is legal generic cron grammar but
5
+ * not a Cloudflare Cron Trigger — the platform only understands the 5-field,
6
+ * minute-granularity form and rejects the rest at `wrangler deploy` with a
7
+ * message naming neither the job nor the file. Warn here instead of staying
8
+ * silent, without throwing: unlike the ergonomic `.interval()` form, the raw
9
+ * `.cron()` escape hatch is meant to accept cron grammar this module doesn't
10
+ * otherwise second-guess.
11
+ *
12
+ * Exported (not module-private) because it is the ONE place this advisory is
13
+ * written: the runtime `cronJobs()` builder reaches it via
14
+ * {@link assertValidCronExpression}, and `@lunora/codegen`'s static
15
+ * `discover/crons.ts` calls it directly after its own `isValidCronExpression`
16
+ * check — so a hand-authored 6-field `.cron()` warns whether it's discovered
17
+ * from source at build time or registered at runtime, with one shared message.
18
+ */
19
+ declare const warnIfSecondsLeading: (schedule: string, context: string) => void;
20
+ /**
21
+ * Assert a raw cron expression is well-formed, throwing the same shaped error
22
+ * both cron surfaces use. The `context` prefix lets callers name the offending
23
+ * job (`cron job "send digest"`) vs. the bare trigger. Well-formed but
24
+ * Cloudflare-incompatible (6-field) expressions pass but log a warning — see
25
+ * {@link warnIfSecondsLeading}.
26
+ */
27
+ declare const assertValidCronExpression: (schedule: string, context?: string) => void;
28
+ export { assertValidCronExpression as a, isValidCronExpression as i, warnIfSecondsLeading as w };
@@ -1,3 +1 @@
1
- /** Standard cron expression (5- or 6-field) or a supported `@macro`, per `cron-parser`. */
2
- declare const isValidCronExpression: (schedule: string) => boolean;
3
- export { isValidCronExpression as default };
1
+ export { i as default } from "./packem_shared/validate-cron-full.d-Bemx45E8.mjs";
@@ -1,3 +1 @@
1
- /** Standard cron expression (5- or 6-field) or a supported `@macro`, per `cron-parser`. */
2
- declare const isValidCronExpression: (schedule: string) => boolean;
3
- export { isValidCronExpression as default };
1
+ export { i as default } from "./packem_shared/validate-cron-full.d-Bemx45E8.js";
@@ -1 +1 @@
1
- import{CronExpressionParser as t}from"cron-parser";const e=r=>{if(typeof r!="string"||r.trim()==="")return!1;try{return t.parse(r.trim()),!0}catch{return!1}};export{e as default};
1
+ import{isValidCronExpression as s}from"./packem_shared/assertValidCronExpression-fiNfNiWf.mjs";export{s as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/scheduler",
3
- "version": "1.0.0-alpha.127",
3
+ "version": "1.0.0-alpha.129",
4
4
  "description": "Scheduling for Lunora: runAfter / runAt and Cron Triggers via SchedulerDO",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -53,7 +53,7 @@
53
53
  "@lunora/errors": ">=1.0.0-alpha.51 <2.0.0-0",
54
54
  "@lunora/platform": "1.0.0-alpha.64",
55
55
  "@lunora/wire": "1.0.0-alpha.1",
56
- "cron-parser": "5.10.1"
56
+ "@visulima/cron-parser": "2.0.0"
57
57
  },
58
58
  "engines": {
59
59
  "node": "^22.15.0 || >=24.11.0"
@@ -1 +0,0 @@
1
- import{LunoraError as f}from"@lunora/errors";const E=new Set(["@annually","@daily","@hourly","@monthly","@weekly","@yearly"]),N=["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"],T=["SUN","MON","TUE","WED","THU","FRI","SAT"],d={max:59,min:0},A={max:23,min:0},_={allowL:!0,max:31,min:1},h={max:12,min:1,nameBase:1,names:N},x={allowL:!0,allowNth:!0,max:7,min:0,nameBase:0,names:T},c=[d,A,_,h,x],L=[d,...c],w=/\s+/u,S=/^\d{1,3}$/u,R=/^[1-9]\d{0,2}$/u,v=/^(\d{1,3})#([1-5])$/u,O=/^(\d{1,3})L$/u,o=(n,t)=>{if(S.test(n)){const e=Number(n);return e>=t.min&&e<=t.max?e:void 0}const r=t.names?.indexOf(n.toUpperCase())??-1;return r===-1?void 0:r+(t.nameBase??0)},g=(n,t)=>{if(o(n,t)!==void 0)return!0;if(n==="L")return t.allowL===!0&&t.allowNth!==!0;const r=O.exec(n);if(t.allowL===!0&&r!==null)return o(r[1],t)!==void 0;const e=v.exec(n);return t.allowNth===!0&&e!==null&&o(e[1],t)!==void 0},I=(n,t)=>{if(n==="?")return!0;const[r="",e,...i]=n.split("/");if(i.length>0||e!==void 0&&!R.test(e))return!1;if(r==="*")return!0;const[s="",l,...m]=r.split("-");if(m.length>0)return!1;if(l===void 0)return g(s,t);const a=o(s,t),u=o(l,t);return a!==void 0&&u!==void 0&&a<=u},y=(n,t)=>n.split(",").every(r=>I(r,t)),C=n=>{if(typeof n!="string")return!1;const t=n.trim();if(E.has(t))return!0;const r=t.split(w),e=r.length===6?L:c;return(r.length===5||r.length===6)&&r.every((i,s)=>y(i,e[s]))},D=n=>C(n),F=/\s+/u,M=(n,t)=>{n.trim().split(F).length===6&&console.warn(`@lunora/scheduler: ${t} "${n}" is a 6-field (seconds-leading) cron expression — Cloudflare Cron Triggers only support the standard 5-field form and will reject this at \`wrangler deploy\`. Drop the seconds field, or use ctx.scheduler.runAfter/runAt for sub-minute work.`)},p=(n,t="cron expression")=>{if(!D(n))throw new f("INTERNAL",`@lunora/scheduler: invalid ${t} "${n}" — expected a standard 5- or 6-field cron expression (e.g. "0 * * * *")`);M(n,t)};export{p as assertValidCronExpression,D as isValidCronExpression,M as warnIfSecondsLeading};