@lunora/scheduler 1.0.0-alpha.111 → 1.0.0-alpha.112
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.mjs +1 -1
- package/dist/packem_shared/{createQueueConsumer-qxMgxXfE.mjs → createQueueConsumer-B-2nHgJ1.mjs} +2 -2
- package/dist/packem_shared/{createScheduler-hNO7z8dj.mjs → createScheduler-CL46fdGy.mjs} +1 -1
- package/dist/packem_shared/{createSchedulerHost-BO1Wbcvr.mjs → createSchedulerHost-PFABEAa3.mjs} +1 -1
- package/dist/packem_shared/{createWorkpool-Bi5eQkLO.mjs → createWorkpool-DRPzIlo3.mjs} +1 -1
- package/dist/packem_shared/wire-codec-BqRJjIKh.mjs +1 -0
- package/package.json +2 -2
- package/dist/packem_shared/wire-codec-DtqZBjRy.mjs +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as o}from"./packem_shared/createScheduler-
|
|
1
|
+
import{default as o}from"./packem_shared/createScheduler-CL46fdGy.mjs";import{default as a}from"./packem_shared/createWorkpool-DRPzIlo3.mjs";import{createCronTrigger as f}from"./packem_shared/createCronTrigger-DSuDZtqj.mjs";import{CRON_SCHEDULE_KINDS as p,compileCronSchedule as c,cronJobs as d}from"./packem_shared/CRON_SCHEDULE_KINDS-xyFk800s.mjs";import{createQueueConsumer as m,createQueueWorkpool as n,httpDispatcher as x}from"./packem_shared/createQueueConsumer-B-2nHgJ1.mjs";import{default as i}from"./packem_shared/resolveScheduleId-DuLCFI_l.mjs";import{MAX_RETRY_ATTEMPTS as E,RETRY_BASE_DELAY_MS as C,SchedulerDO as _}from"./packem_shared/MAX_RETRY_ATTEMPTS-Q3JXDtb1.mjs";import{createSchedulerHost as R}from"./packem_shared/createSchedulerHost-PFABEAa3.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-DnBtukpq.mjs";import{default as W}from"./packem_shared/assertScheduleDelay-Cz5e-UVl.mjs";import{default as w}from"./packem_shared/assertScheduleInstant-CMN9XCFm.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};
|
package/dist/packem_shared/{createQueueConsumer-qxMgxXfE.mjs → createQueueConsumer-B-2nHgJ1.mjs}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{LunoraError as d,isLunoraError as k}from"@lunora/errors";import{a as B}from"./wire-codec-
|
|
1
|
+
import{LunoraError as d,isLunoraError as k}from"@lunora/errors";import{a as B}from"./wire-codec-BqRJjIKh.mjs";const Q=9e5,F="DISPATCH_IN_PROGRESS",H="x-lunora-dispatch-declined",W=(e,t,a)=>{if(t===void 0)return{dispose:()=>{},signal:e};const o=new AbortController,r=setTimeout(()=>{o.abort(a())},t);return{dispose:()=>{clearTimeout(r)},signal:o.signal}},G=e=>{let t="";for(let a=0;a<e.length;a+=32768)t+=String.fromCharCode(...e.subarray(a,a+32768));return btoa(t)},V=e=>{const t=atob(e),a=new Uint8Array(t.length);for(let o=0;o<t.length;o+=1)a[o]=t.codePointAt(o)??0;return a},h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",q=e=>{let t="",a=0;const o=e.length-2;for(;a<o;a+=3){const n=e[a]<<16|e[a+1]<<8|e[a+2];t+=h.charAt(n>>18&63)+h.charAt(n>>12&63)+h.charAt(n>>6&63)+h.charAt(n&63)}const r=e.length-a;if(r===1){const n=e[a]<<16;t+=h.charAt(n>>18&63)+h.charAt(n>>12&63)}else if(r===2){const n=e[a]<<16|e[a+1]<<8;t+=h.charAt(n>>18&63)+h.charAt(n>>12&63)+h.charAt(n>>6&63)}return t};new TextDecoder;const U=new TextEncoder,N="=",X=e=>{for(let t=0;t<e.length;t+=1)if(e.charCodeAt(t)>255)return!1;return!0},z=e=>q(U.encode(JSON.stringify(e))),Y=e=>!e.startsWith(N)&&X(e)?e:`${N}${q(U.encode(e))}`,Z="$lunora.wire$",R=64,$=1024,v="__proto__",I={BigInt64Array,BigUint64Array,Float32Array,Float64Array,Int8Array,Int16Array,Int32Array,Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array},O={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError},l=(e,t=0)=>{if(t>R)throw new RangeError(`wire-codec: value nesting exceeds the ${R}-level limit`);if(e===null||typeof e!="object")return e;if(Array.isArray(e)){if(e[0]===Z)switch(e[1]){case"-inf":return-1/0;case"arr":return e[2].map(r=>l(r,t+1));case"bigint":{const r=e[2];if(typeof r!="string"||r.length>$||!/^-?\d+$/.test(r))throw new RangeError(`wire-codec: invalid or over-long bigint (max ${$} digits)`);return BigInt(r)}case"date":{const r=l(e[2],t+1);if(typeof r!="number")throw new TypeError("wire-codec: malformed date — epoch must be a number");return new Date(r)}case"map":{const r=e[2];return new Map(r.map(n=>{if(!Array.isArray(n)||n.length!==2)throw new TypeError("wire-codec: malformed map entry — expected a [key, value] pair");return[l(n[0],t+1),l(n[1],t+1)]}))}case"set":return new Set(e[2].map(r=>l(r,t+1)));case"url":{const r=e[2];if(typeof r!="string")throw new TypeError("wire-codec: malformed url — href must be a string");return new URL(r)}case"error":{const r=e[2],n=e[3];if(typeof r!="string"||typeof n!="string")throw new TypeError("wire-codec: malformed error — name and message must be strings");const s=(Object.hasOwn(O,r)?O[r]:void 0)??Error,c=new s(n);c.name!==r&&Object.defineProperty(c,"name",{configurable:!0,value:r,writable:!0});const i=l(e[4],t+1);if(i===null||typeof i!="object"||Array.isArray(i))throw new TypeError("wire-codec: malformed error — props must be an object");for(const u of Object.keys(i))u===v?Object.defineProperty(c,u,{configurable:!0,enumerable:!0,value:i[u],writable:!0}):c[u]=i[u];return e.length>5&&Object.defineProperty(c,"cause",{configurable:!0,value:l(e[5],t+1),writable:!0}),c}case"bytes":{const r=e[2];if(typeof r!="string")throw new TypeError("wire-codec: malformed bytes — payload must be a base64 string");const n=V(r);if(G(n)!==r)throw new TypeError("wire-codec: malformed bytes — payload must be canonical padded base64");const s=e[3]??"Uint8Array";if(s==="ArrayBuffer")return n.buffer.byteLength===n.byteLength?n.buffer:n.slice().buffer;const c=Object.hasOwn(I,s)?I[s]:void 0;return c?new c(n.slice().buffer):n}case"inf":return 1/0;case"nan":return Number.NaN;case"undefined":return;default:return e.map(r=>l(r,t+1))}return e.map(r=>l(r,t+1))}const a=e,o={};for(const r of Object.keys(a)){const n=l(a[r],t+1);r===v?Object.defineProperty(o,r,{configurable:!0,enumerable:!0,value:n,writable:!0}):o[r]=n}return o},ee="/_lunora/scheduler/dispatch",te=3e4,re=e=>{let t=e.length;for(;t>0&&e[t-1]==="/";)t-=1;return e.slice(0,t)},L=Symbol("lunoraDispatchFailure"),P=Symbol("lunoraDispatchDecline"),ne=Symbol("lunoraDispatchMessageId"),x=(e,t)=>(t!==void 0&&Object.defineProperty(e,ne,{value:t}),e),ae=(e,t)=>(Object.defineProperty(e,L,{value:!0}),x(e,t)),oe=(e,t,a,o)=>{const{status:r}=t;try{const n=JSON.parse(a)?.error;if(typeof n=="object"&&n!==null&&typeof n.code=="string"){const{code:s,data:c,message:i}=n,u=ae(new d(s,typeof i=="string"?i:void 0,{data:c,status:r}),o);return t.headers.get(H)==="1"&&Object.defineProperty(u,P,{value:!0}),u}}catch{}return x(new d("INTERNAL",`${e}: function dispatch failed (${String(r)}): ${a}`,{status:r}),o)},se=e=>k(e)&&e[L]===!0,ce=e=>se(e)&&e[P]===!0,_=Q/1e3,ie=3,ue=async(e,t)=>{const a=t.maxRetries??ie,o=typeof e.attempts=="number"&&e.attempts>a;let r="";if(o&&t.requeue!==void 0)try{return await t.requeue(_),e.ack(),"requeued"}catch(n){r=` Re-enqueueing a delayed copy failed (${n instanceof Error?n.message:String(n)}).`}return e.retry({delaySeconds:_}),o&&console.error(`${t.where}: message ${e.id} was declined (${F}) on its last delivery (attempt ${String(e.attempts)} of ${String(a+1)}) — its earlier delivery is still running the call.${r} It is retried anyway, but its retries are exhausted, so it will be dead-lettered if the queue has a deadLetterQueue and dropped if not. Raise max_retries so a slow call cannot exhaust it.`),"retried"},le=(e,t,a)=>new d("INTERNAL",`${e}: function dispatch to "${t}" timed out after ${String(a)}ms`,{status:503}),de=e=>{const{label:t}=e,a=globalThis.fetch,o=e.fetchImpl??(typeof a=="function"?a.bind(globalThis):void 0);return async(r,n,s={})=>{if(typeof o!="function")throw new TypeError(`${t}: no fetch implementation available — pass fetchImpl or run on a platform with global fetch`);const c=()=>n??{},i=e.env.LUNORA_ORIGIN_URL;if(typeof i!="string"||i.length===0)throw new d("INTERNAL",`${t}: \`LUNORA_ORIGIN_URL\` must be set on the Worker env so a handler can call back into Lunora functions`);const u=e.env.LUNORA_ADMIN_TOKEN;if(typeof u!="string"||u.length===0)throw new d("INTERNAL",`${t}: \`LUNORA_ADMIN_TOKEN\` must be set on the Worker env to authenticate function dispatch`);const w=`${re(i)}${ee}`,m={authorization:`Bearer ${u}`,"content-type":"application/json"};e.traceparent!==void 0&&e.traceparent.length>0&&(m.traceparent=e.traceparent),e.identity?.userId!==void 0&&(m["x-lunora-userid"]=Y(e.identity.userId)),e.identity?.claims!==void 0&&(m["x-lunora-identity"]=z(e.identity.claims));const b=s.timeoutMs??te,E=W(void 0,b,()=>new DOMException(`dispatch timed out after ${String(b)}ms`,"TimeoutError")),A=y=>{throw y instanceof Error&&y.name==="TimeoutError"?le(t,r.__lunoraRef,b):y};let f;try{try{f=await o(w,{body:JSON.stringify({args:c(),functionPath:r.__lunoraRef,id:s.dedupId,shardKey:s.shardKey}),headers:m,method:"POST",signal:E.signal})}catch(g){return A(g)}if(!f.ok){let g;try{g=await f.text()}catch(J){return A(J)}throw oe(t,f,g,s.messageId)}let y;try{y=await f.text()}catch(g){return A(g)}if(y.length===0)return;let p;try{p=JSON.parse(y)}catch{throw new d("INTERNAL",`${t}: function dispatch returned a non-JSON body (${String(f.status)}): ${y}`,{status:f.status})}if(p===null||typeof p!="object"||Array.isArray(p)||!("result"in p))throw new d("INTERNAL",`${t}: function dispatch returned a JSON body that is not a { result } envelope (${String(f.status)}): ${y}`,{status:f.status});return l(p.result)}finally{E.dispose()}}},fe="lunora.requeue.v1",M=new TextEncoder,j=async(e,t)=>crypto.subtle.importKey("raw",M.encode(e),{hash:"SHA-256",name:"HMAC"},!1,[t]),D=(e,t,a)=>M.encode(`${fe}
|
|
2
2
|
${e}
|
|
3
3
|
${t}
|
|
4
|
-
${a}`),ye=e=>[...new Uint8Array(e)].map(t=>t.toString(16).padStart(2,"0")).join(""),he=/^[\da-f]{64}$/u,pe=async(e,t,a,o)=>ye(await crypto.subtle.sign("HMAC",await j(e,"sign"),D(t,a,o))),ge=async(e,t,a,o,r)=>{if(typeof r!="string"||!he.test(r))return!1;const n=Uint8Array.from({length:r.length/2},(s,c)=>Number.parseInt(r.slice(c*2,c*2+2),16));return crypto.subtle.verify("HMAC",await j(e,"verify"),n,D(t,a,o))},S=100,me=3e5,T=e=>e===void 0?void 0:B(e),Ne=e=>{if(!e.queue)throw new d("INTERNAL","@lunora/scheduler: `queue` (a Cloudflare Queue binding) is required");return{enqueue:async(o,r,n={})=>{const s={args:T(r),functionPath:o.__lunoraRef,shardKey:n.shardKey},c=n.delaySeconds===void 0?void 0:{delaySeconds:n.delaySeconds};await e.queue.send(s,c)},enqueueBatch:async(o,r)=>{if(o.length>S)throw new d("VALIDATION_ERROR",`@lunora/scheduler: enqueueBatch exceeds ${String(S)} (got ${String(o.length)}) — split across calls`);const n=o.map(s=>({body:{args:T(s.args),functionPath:s.ref.__lunoraRef,shardKey:s.shardKey}}));await e.queue.sendBatch(n,r)}}},we=e=>typeof e=="object"&&e!==null&&typeof e.functionPath=="string",K="scheduler",C=e=>JSON.stringify({args:e.args,functionPath:e.functionPath,shardKey:e.shardKey}),be=async(e,t,a)=>{const{requeuedFrom:o,requeueMac:r,...n}=e;return typeof o=="string"&&a!==void 0&&await ge(a,K,o,C(n),r).catch(()=>!1)?{id:o,job:n,requeued:!0}:{id:t,job:n,requeued:!1}},Re=e=>async t=>{await Promise.all(t.messages.map(async a=>{let o;try{if(!we(a.body))throw new d("INTERNAL","@lunora/scheduler: queue message body is not a QueueJob (missing functionPath)");o=await be(a.body,a.id,e.requeue?.secret),await e.dispatch(o.job,o.id),a.ack()}catch(r){if(ce(r)&&o!==void 0){const{requeue:n}=e,{id:s,job:c,requeued:i}=o;await ue(a,{maxRetries:e.maxRetries,requeue:n===void 0||i?void 0:async u=>{const w=await pe(n.secret,K,s,C(c));await n.queue.send({...c,requeuedFrom:s,requeueMac:w},{delaySeconds:u})},where:`@lunora/scheduler: queue "${t.queue}"`});return}a.retry()}}))}
|
|
4
|
+
${a}`),ye=e=>[...new Uint8Array(e)].map(t=>t.toString(16).padStart(2,"0")).join(""),he=/^[\da-f]{64}$/u,pe=async(e,t,a,o)=>ye(await crypto.subtle.sign("HMAC",await j(e,"sign"),D(t,a,o))),ge=async(e,t,a,o,r)=>{if(typeof r!="string"||!he.test(r))return!1;const n=Uint8Array.from({length:r.length/2},(s,c)=>Number.parseInt(r.slice(c*2,c*2+2),16));return crypto.subtle.verify("HMAC",await j(e,"verify"),n,D(t,a,o))},S=100,me=3e5,T=e=>e===void 0?void 0:B(e),Ne=e=>{if(!e.queue)throw new d("INTERNAL","@lunora/scheduler: `queue` (a Cloudflare Queue binding) is required");return{enqueue:async(o,r,n={})=>{const s={args:T(r),functionPath:o.__lunoraRef,shardKey:n.shardKey},c=n.delaySeconds===void 0?void 0:{delaySeconds:n.delaySeconds};await e.queue.send(s,c)},enqueueBatch:async(o,r)=>{if(o.length>S)throw new d("VALIDATION_ERROR",`@lunora/scheduler: enqueueBatch exceeds ${String(S)} (got ${String(o.length)}) — split across calls`);const n=o.map(s=>({body:{args:T(s.args),functionPath:s.ref.__lunoraRef,shardKey:s.shardKey}}));await e.queue.sendBatch(n,r)}}},we=e=>typeof e=="object"&&e!==null&&typeof e.functionPath=="string",K="scheduler",C=e=>JSON.stringify({args:e.args,functionPath:e.functionPath,shardKey:e.shardKey}),be=async(e,t,a)=>{const{requeuedFrom:o,requeueMac:r,...n}=e;return typeof o=="string"&&a!==void 0&&await ge(a,K,o,C(n),r).catch(()=>!1)?{id:o,job:n,requeued:!0}:{id:t,job:n,requeued:!1}},Re=e=>async t=>{await Promise.all(t.messages.map(async a=>{let o;try{if(!we(a.body))throw new d("INTERNAL","@lunora/scheduler: queue message body is not a QueueJob (missing functionPath)");o=await be(a.body,a.id,e.requeue?.secret),await e.dispatch(o.job,o.id),a.ack()}catch(r){if(ce(r)&&o!==void 0){const{requeue:n}=e,{id:s,job:c,requeued:i}=o;await ue(a,{maxRetries:e.maxRetries,requeue:n===void 0||i?void 0:async u=>{const w=await pe(n.secret,K,s,C(c));await n.queue.send({...c,requeuedFrom:s,requeueMac:w},{delaySeconds:u})},where:`@lunora/scheduler: queue "${t.queue}"`});return}a.retry()}}))},$e=e=>{const t=de({env:{LUNORA_ADMIN_TOKEN:e.adminToken,LUNORA_ORIGIN_URL:e.originUrl},fetchImpl:e.fetchImpl,label:"@lunora/scheduler"}),a=e.timeoutMs??me;return async(o,r)=>{await t({__lunoraRef:o.functionPath},o.args,{dedupId:r,messageId:r,shardKey:o.shardKey,timeoutMs:a})}};export{Re as createQueueConsumer,Ne as createQueueWorkpool,$e as httpDispatcher};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LunoraError as w}from"@lunora/errors";import{e as g,d as A}from"./wire-codec-
|
|
1
|
+
import{LunoraError as w}from"@lunora/errors";import{e as g,d as A}from"./wire-codec-BqRJjIKh.mjs";import{a as p,c as d,g as f}from"./do-client-XQayNStI.mjs";import{isWorkflowReference as h}from"./isWorkflowReference-CT3tdefh.mjs";import N from"./assertScheduleDelay-Cz5e-UVl.mjs";import R from"./assertScheduleInstant-CMN9XCFm.mjs";const v=async e=>{const a=[];let o;for(;;){const c=await e(o);if(a.push(...Array.isArray(c.records)?c.records:[]),c.truncated!==!0||typeof c.cursor!="string"||c.cursor.length===0)return a;if(c.cursor===o)throw new Error("collectPages: the list did not advance its cursor — refusing to page forever");o=c.cursor}},x=e=>typeof e=="string"?e:(h(e)?e.className:e.__lunoraRef)??"<unknown>",m=e=>({...e,args:A(e.args)}),K=e=>{p(e);const a=async(s,r,n,t={})=>{const u=Math.ceil(s instanceof Date?s.getTime():s);R(u,Date.now(),"ctx.scheduler.runAt");const i={args:g("ctx.scheduler.runAt",x(r),n),id:t.id,instanceName:e.instanceName??"default",maxConcurrency:t.pool===void 0?void 0:t.maxConcurrency,pool:t.pool,retry:t.retry,scheduledFor:u,shardKey:t.shardKey};if(h(r)){if(typeof r.className!="string"||r.className.length===0)throw new w("INTERNAL","@lunora/scheduler: workflow/agent schedule target is missing its `className` — pass the generated `workflows.<name>` / `agents.<name>` reference");return(await d(e,"/schedule",{...i,workflow:r.className})).id}const y=typeof r=="string"?r:r.__lunoraRef;return(await d(e,"/schedule",{...i,functionPath:y})).id},o=async(s,r,n,t={})=>(N(s,"ctx.scheduler.runAfter"),a(Date.now()+s,r,n,t)),c=async s=>d(e,"/cancel",{id:s}),l=async s=>(await v(async n=>f(e,n===void 0?s:`${s}?cursor=${encodeURIComponent(n)}`))).map(n=>m(n));return{cancel:c,dead:async()=>l("/dead"),deadRetry:async s=>{const{retried:r}=await d(e,"/dead/retry",{id:s});return r===!0},get:async s=>{const r=await f(e,`/get?id=${encodeURIComponent(s)}`);return r.record===void 0?null:m(r.record)},list:async()=>l("/list"),runAfter:o,runAt:a}};export{K as default};
|
package/dist/packem_shared/{createSchedulerHost-BO1Wbcvr.mjs → createSchedulerHost-PFABEAa3.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import u from"./createScheduler-
|
|
1
|
+
import u from"./createScheduler-CL46fdGy.mjs";const i=t=>t?.at!==void 0?typeof t.at=="number"?t.at:t.at.getTime():Date.now()+(t?.delayMs??0),m=t=>{const r=u({instanceName:t.instanceName,jurisdiction:t.jurisdiction,namespace:t.namespace}),n=e=>({attempts:e.attempts??0,functionPath:e.functionPath??e.workflow??"",id:e.id,scheduledFor:e.scheduledFor});return{cancel:async e=>{const{cancelled:a}=await r.cancel(e);return a},deadLetter:{list:async()=>(await r.dead()).map(a=>n(a)),requeue:async e=>r.deadRetry(e)},list:async()=>(await r.list()).map(a=>n(a)),schedule:async(e,a,c)=>{const d=r.runAt,s=i(c);return{id:await d(s,e,a,{retry:c?.retry,shardKey:c?.shardKey}),scheduledFor:s}}}};export{m as createSchedulerHost};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LunoraError as l}from"@lunora/errors";import{e as s}from"./wire-codec-
|
|
1
|
+
import{LunoraError as l}from"@lunora/errors";import{e as s}from"./wire-codec-BqRJjIKh.mjs";import{a as o,g as m,c as u}from"./do-client-XQayNStI.mjs";import y from"./assertScheduleDelay-Cz5e-UVl.mjs";const N=e=>{if(o(e),!Number.isInteger(e.maxConcurrency)||e.maxConcurrency<=0)throw new l("INTERNAL","@lunora/scheduler: `maxConcurrency` must be a positive integer");const a=typeof e.name=="string"&&e.name.length>0?e.name:"default";return{cancel:async r=>u(e,"/cancel",{id:r}),enqueue:async(r,t,n={})=>{const c=n.delayMs??0;return y(c,"workpool.enqueue"),u(e,"/schedule",{args:s("workpool.enqueue",r.__lunoraRef,t),functionPath:r.__lunoraRef,instanceName:e.instanceName??"default",maxConcurrency:e.maxConcurrency,pool:a,retry:n.retry,scheduledFor:Math.ceil(Date.now()+c),shardKey:n.shardKey})},name:a,status:async()=>m(e,`/pool?name=${encodeURIComponent(a)}`)}};export{N as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as d,f as E}from"./base64-junLSktH.mjs";const o="$lunora.wire$",w=64,g=1024,p="__proto__",A={BigInt64Array,BigUint64Array,Float32Array,Float64Array,Int8Array,Int16Array,Int32Array,Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array},l={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError},O=e=>{if(e===null||typeof e!="object")return!1;const n=Object.getPrototypeOf(e);return n===null||n===Object.prototype},y=(e,n=0)=>{if(n>w)throw new RangeError(`wire-codec: value nesting exceeds the ${w}-level limit`);if(e===void 0)return[o,"undefined"];if(e===null)return null;const u=typeof e;if(u==="bigint"){const r=e.toString();if(r.length>g)throw new RangeError(`wire-codec: over-long bigint (max ${g} digits)`);return[o,"bigint",r]}if(u==="number"){const r=e;return Number.isNaN(r)?[o,"nan"]:r===1/0?[o,"inf"]:r===-1/0?[o,"-inf"]:r}if(u!=="object")return e;if(e instanceof Date)return[o,"date",y(e.getTime(),n+1)];if(e instanceof Error){const r=e,t=y(Object.fromEntries(Object.keys(r).map(c=>[c,r[c]])),n+1),i=[o,"error",String(r.name),String(r.message),t];return r.cause!==void 0&&i.push(y(r.cause,n+1)),i}if(e instanceof URL)return[o,"url",e.href];if(e instanceof Map)return[o,"map",[...e.entries()].map(([r,t])=>[y(r,n+1),y(t,n+1)])];if(e instanceof Set)return[o,"set",[...e].map(r=>y(r,n+1))];if(e instanceof ArrayBuffer)return[o,"bytes",d(new Uint8Array(e)),"ArrayBuffer"];if(ArrayBuffer.isView(e)){const r=e,t=r.constructor.name,i=new Uint8Array(r.buffer,r.byteOffset,r.byteLength);return t==="Uint8Array"?[o,"bytes",d(i)]:[o,"bytes",d(i),t]}if(Array.isArray(e)){const r=e.map(t=>y(t,n+1));return r.length>0&&r[0]===o?[o,"arr",r]:r}if(!O(e)){const r=e.constructor?.name??"value";throw new TypeError(`wire-codec: cannot encode a ${r} over the Lunora wire — only plain objects, arrays, and the supported built-ins (Date, Error, URL, Map, Set, ArrayBuffer/typed arrays, bigint) round-trip`)}const s=e,a={};for(const r of Object.keys(s)){const t=s[r];if(t===void 0)continue;const i=y(t,n+1);r===p?Object.defineProperty(a,r,{configurable:!0,enumerable:!0,value:i,writable:!0}):a[r]=i}return a},f=(e,n=0)=>{if(n>w)throw new RangeError(`wire-codec: value nesting exceeds the ${w}-level limit`);if(e===null||typeof e!="object")return e;if(Array.isArray(e)){if(e[0]===o)switch(e[1]){case"-inf":return-1/0;case"arr":return e[2].map(r=>f(r,n+1));case"bigint":{const r=e[2];if(typeof r!="string"||r.length>g||!/^-?\d+$/.test(r))throw new RangeError(`wire-codec: invalid or over-long bigint (max ${g} digits)`);return BigInt(r)}case"date":{const r=f(e[2],n+1);if(typeof r!="number")throw new TypeError("wire-codec: malformed date — epoch must be a number");return new Date(r)}case"map":{const r=e[2];return new Map(r.map(t=>{if(!Array.isArray(t)||t.length!==2)throw new TypeError("wire-codec: malformed map entry — expected a [key, value] pair");return[f(t[0],n+1),f(t[1],n+1)]}))}case"set":return new Set(e[2].map(r=>f(r,n+1)));case"url":{const r=e[2];if(typeof r!="string")throw new TypeError("wire-codec: malformed url — href must be a string");return new URL(r)}case"error":{const r=e[2],t=e[3];if(typeof r!="string"||typeof t!="string")throw new TypeError("wire-codec: malformed error — name and message must be strings");const i=(Object.hasOwn(l,r)?l[r]:void 0)??Error,c=new i(t);c.name!==r&&Object.defineProperty(c,"name",{configurable:!0,value:r,writable:!0});const b=f(e[4],n+1);if(b===null||typeof b!="object"||Array.isArray(b))throw new TypeError("wire-codec: malformed error — props must be an object");for(const m of Object.keys(b))m===p?Object.defineProperty(c,m,{configurable:!0,enumerable:!0,value:b[m],writable:!0}):c[m]=b[m];return e.length>5&&Object.defineProperty(c,"cause",{configurable:!0,value:f(e[5],n+1),writable:!0}),c}case"bytes":{const r=e[2];if(typeof r!="string")throw new TypeError("wire-codec: malformed bytes — payload must be a base64 string");const t=E(r);if(d(t)!==r)throw new TypeError("wire-codec: malformed bytes — payload must be canonical padded base64");const i=e[3]??"Uint8Array";if(i==="ArrayBuffer")return t.buffer.byteLength===t.byteLength?t.buffer:t.slice().buffer;const c=Object.hasOwn(A,i)?A[i]:void 0;return c?new c(t.slice().buffer):t}case"inf":return 1/0;case"nan":return Number.NaN;case"undefined":return;default:return e.map(r=>f(r,n+1))}return e.map(a=>f(a,n+1))}const u=e,s={};for(const a of Object.keys(u)){const r=f(u[a],n+1);a===p?Object.defineProperty(s,a,{configurable:!0,enumerable:!0,value:r,writable:!0}):s[a]=r}return s},T=(e,n,u)=>{try{return y(u)}catch(s){throw new TypeError(`${e}: cannot encode args for '${n}' — ${s instanceof Error?s.message:String(s)}`,s instanceof Error?{cause:s}:void 0)}};export{y as a,f as d,T as e};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/scheduler",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.112",
|
|
4
4
|
"description": "Scheduling for Lunora: runAfter / runAt and Cron Triggers via SchedulerDO",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@lunora/errors": "1.0.0-alpha.50",
|
|
50
|
-
"@lunora/platform": "1.0.0-alpha.
|
|
50
|
+
"@lunora/platform": "1.0.0-alpha.57",
|
|
51
51
|
"cron-parser": "5.10.1"
|
|
52
52
|
},
|
|
53
53
|
"engines": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as d,f as E}from"./base64-junLSktH.mjs";const o="$lunora.wire$",w=64,p=1024,g="__proto__",l={BigInt64Array,BigUint64Array,Float32Array,Float64Array,Int8Array,Int16Array,Int32Array,Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array},A={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError},O=e=>{if(e===null||typeof e!="object")return!1;const n=Object.getPrototypeOf(e);return n===null||n===Object.prototype},u=(e,n=0)=>{if(n>w)throw new RangeError(`wire-codec: value nesting exceeds the ${w}-level limit`);if(e===void 0)return[o,"undefined"];if(e===null)return null;const b=typeof e;if(b==="bigint")return[o,"bigint",e.toString()];if(b==="number"){const r=e;return Number.isNaN(r)?[o,"nan"]:r===1/0?[o,"inf"]:r===-1/0?[o,"-inf"]:r}if(b!=="object")return e;if(e instanceof Date)return[o,"date",u(e.getTime(),n+1)];if(e instanceof Error){const r=e,t={};for(const i of Object.keys(r)){if(r[i]===void 0)continue;const y=u(r[i],n+1);i===g?Object.defineProperty(t,i,{configurable:!0,enumerable:!0,value:y,writable:!0}):t[i]=y}const s=[o,"error",String(r.name),String(r.message),t];return r.cause!==void 0&&s.push(u(r.cause,n+1)),s}if(e instanceof URL)return[o,"url",e.href];if(e instanceof Map)return[o,"map",[...e.entries()].map(([r,t])=>[u(r,n+1),u(t,n+1)])];if(e instanceof Set)return[o,"set",[...e].map(r=>u(r,n+1))];if(e instanceof ArrayBuffer)return[o,"bytes",d(new Uint8Array(e)),"ArrayBuffer"];if(ArrayBuffer.isView(e)){const r=e,t=r.constructor.name,s=new Uint8Array(r.buffer,r.byteOffset,r.byteLength);return t==="Uint8Array"?[o,"bytes",d(s)]:[o,"bytes",d(s),t]}if(Array.isArray(e)){const r=e.map(t=>u(t,n+1));return r.length>0&&r[0]===o?[o,"arr",r]:r}if(!O(e)){const r=e.constructor?.name??"value";throw new TypeError(`wire-codec: cannot encode a ${r} over the Lunora wire — only plain objects, arrays, and the supported built-ins (Date, Error, URL, Map, Set, ArrayBuffer/typed arrays, bigint) round-trip`)}const c=e,a={};for(const r of Object.keys(c)){const t=c[r];if(t===void 0)continue;const s=u(t,n+1);r===g?Object.defineProperty(a,r,{configurable:!0,enumerable:!0,value:s,writable:!0}):a[r]=s}return a},f=(e,n=0)=>{if(n>w)throw new RangeError(`wire-codec: value nesting exceeds the ${w}-level limit`);if(e===null||typeof e!="object")return e;if(Array.isArray(e)){if(e[0]===o)switch(e[1]){case"-inf":return-1/0;case"arr":return e[2].map(r=>f(r,n+1));case"bigint":{const r=e[2];if(typeof r!="string"||r.length>p||!/^-?\d+$/.test(r))throw new RangeError(`wire-codec: invalid or over-long bigint (max ${p} digits)`);return BigInt(r)}case"date":{const r=f(e[2],n+1);if(typeof r!="number")throw new TypeError("wire-codec: malformed date — epoch must be a number");return new Date(r)}case"map":{const r=e[2];return new Map(r.map(t=>{if(!Array.isArray(t)||t.length!==2)throw new TypeError("wire-codec: malformed map entry — expected a [key, value] pair");return[f(t[0],n+1),f(t[1],n+1)]}))}case"set":return new Set(e[2].map(r=>f(r,n+1)));case"url":{const r=e[2];if(typeof r!="string")throw new TypeError("wire-codec: malformed url — href must be a string");return new URL(r)}case"error":{const r=e[2],t=e[3];if(typeof r!="string"||typeof t!="string")throw new TypeError("wire-codec: malformed error — name and message must be strings");const s=(Object.hasOwn(A,r)?A[r]:void 0)??Error,i=new s(t);i.name!==r&&Object.defineProperty(i,"name",{configurable:!0,value:r,writable:!0});const y=f(e[4],n+1);if(y===null||typeof y!="object"||Array.isArray(y))throw new TypeError("wire-codec: malformed error — props must be an object");for(const m of Object.keys(y))m===g?Object.defineProperty(i,m,{configurable:!0,enumerable:!0,value:y[m],writable:!0}):i[m]=y[m];return e.length>5&&Object.defineProperty(i,"cause",{configurable:!0,value:f(e[5],n+1),writable:!0}),i}case"bytes":{const r=e[2];if(typeof r!="string")throw new TypeError("wire-codec: malformed bytes — payload must be a base64 string");const t=E(r);if(d(t)!==r)throw new TypeError("wire-codec: malformed bytes — payload must be canonical padded base64");const s=e[3]??"Uint8Array";if(s==="ArrayBuffer")return t.buffer.byteLength===t.byteLength?t.buffer:t.slice().buffer;const i=Object.hasOwn(l,s)?l[s]:void 0;return i?new i(t.slice().buffer):t}case"inf":return 1/0;case"nan":return Number.NaN;case"undefined":return;default:return e.map(r=>f(r,n+1))}return e.map(a=>f(a,n+1))}const b=e,c={};for(const a of Object.keys(b)){const r=f(b[a],n+1);a===g?Object.defineProperty(c,a,{configurable:!0,enumerable:!0,value:r,writable:!0}):c[a]=r}return c},T=(e,n,b)=>{try{return u(b)}catch(c){throw new TypeError(`${e}: cannot encode args for '${n}' — ${c instanceof Error?c.message:String(c)}`,c instanceof Error?{cause:c}:void 0)}};export{u as a,f as d,T as e};
|