skedyul 1.7.5 → 1.7.6
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/.build-stamp +1 -1
- package/dist/esm/index.mjs +21 -10
- package/dist/index.js +21 -10
- package/dist/scheduling/calculateWaitTime.d.ts +4 -2
- package/dist/scheduling/index.js +12 -9
- package/dist/scheduling/index.mjs +12 -9
- package/dist/scheduling/types-workflow.d.ts +7 -0
- package/dist/scheduling/types.d.ts +2 -0
- package/package.json +1 -1
package/dist/.build-stamp
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
1785913911217
|
package/dist/esm/index.mjs
CHANGED
|
@@ -8027,7 +8027,15 @@ var WaitInputRelativeSchema = z15.object({
|
|
|
8027
8027
|
mode: z15.literal("relative"),
|
|
8028
8028
|
amount: z15.number(),
|
|
8029
8029
|
unit: WaitUnitSchema,
|
|
8030
|
-
windows: z15.array(TimeWindowSlotSchema).optional()
|
|
8030
|
+
windows: z15.array(TimeWindowSlotSchema).optional(),
|
|
8031
|
+
/**
|
|
8032
|
+
* Optional ISO datetime to use as the base for the relative delay instead of
|
|
8033
|
+
* wall-clock `now`. Used for cadence chaining (schedule relative to a prior
|
|
8034
|
+
* message's scheduledAt). `waitTime` is still measured from wall-clock `now`.
|
|
8035
|
+
*/
|
|
8036
|
+
from: z15.union([z15.string(), z15.date()]).optional().describe(
|
|
8037
|
+
"ISO datetime base for the relative delay (e.g. previous message scheduledAt)"
|
|
8038
|
+
)
|
|
8031
8039
|
});
|
|
8032
8040
|
var WaitInputAbsoluteSchema = z15.object({
|
|
8033
8041
|
mode: z15.literal("absolute"),
|
|
@@ -8140,10 +8148,12 @@ function calculateWaitTime(step, now) {
|
|
|
8140
8148
|
};
|
|
8141
8149
|
}
|
|
8142
8150
|
case "relative": {
|
|
8151
|
+
const baseTime = step.from != null ? new Date(step.from).getTime() : nowTime;
|
|
8152
|
+
const baseDate = new Date(baseTime);
|
|
8143
8153
|
if (!step.amount && (!step.windows || step.windows.length === 0)) {
|
|
8144
8154
|
return {
|
|
8145
|
-
waitTime: 0,
|
|
8146
|
-
scheduledAt:
|
|
8155
|
+
waitTime: Math.max(0, baseTime - nowTime),
|
|
8156
|
+
scheduledAt: baseDate
|
|
8147
8157
|
};
|
|
8148
8158
|
}
|
|
8149
8159
|
let relativeDelay = 0;
|
|
@@ -8182,17 +8192,18 @@ function calculateWaitTime(step, now) {
|
|
|
8182
8192
|
}
|
|
8183
8193
|
}
|
|
8184
8194
|
if (!step.windows || step.windows.length === 0) {
|
|
8195
|
+
const scheduledAt = new Date(baseTime + relativeDelay);
|
|
8185
8196
|
return {
|
|
8186
|
-
waitTime:
|
|
8187
|
-
scheduledAt
|
|
8197
|
+
waitTime: Math.max(0, scheduledAt.getTime() - nowTime),
|
|
8198
|
+
scheduledAt
|
|
8188
8199
|
};
|
|
8189
8200
|
}
|
|
8190
|
-
const targetDate = new Date(
|
|
8201
|
+
const targetDate = new Date(baseTime + relativeDelay);
|
|
8191
8202
|
for (const window of step.windows) {
|
|
8192
8203
|
if (isTimeInWindowSlot(targetDate, window)) {
|
|
8193
8204
|
return {
|
|
8194
|
-
waitTime:
|
|
8195
|
-
scheduledAt:
|
|
8205
|
+
waitTime: Math.max(0, targetDate.getTime() - nowTime),
|
|
8206
|
+
scheduledAt: targetDate
|
|
8196
8207
|
};
|
|
8197
8208
|
}
|
|
8198
8209
|
}
|
|
@@ -8237,8 +8248,8 @@ function calculateWaitTime(step, now) {
|
|
|
8237
8248
|
msUntilWindowStart = daysMs + hoursAdjustment + minutesAdjustment;
|
|
8238
8249
|
}
|
|
8239
8250
|
const windowStartTimeMs = targetDate.getTime() + msUntilWindowStart;
|
|
8240
|
-
const
|
|
8241
|
-
const windowScheduledTime =
|
|
8251
|
+
const sameLocalDayAsBase = getLocalDateKey(baseDate, tz) === getLocalDateKey(targetDate, tz);
|
|
8252
|
+
const windowScheduledTime = sameLocalDayAsBase ? new Date(windowStartTimeMs + relativeDelay) : new Date(windowStartTimeMs);
|
|
8242
8253
|
const waitFromNow = windowScheduledTime.getTime() - nowTime;
|
|
8243
8254
|
if (waitFromNow < earliestWaitFromNow) {
|
|
8244
8255
|
earliestWaitFromNow = waitFromNow;
|
package/dist/index.js
CHANGED
|
@@ -8401,7 +8401,15 @@ var WaitInputRelativeSchema = import_v413.z.object({
|
|
|
8401
8401
|
mode: import_v413.z.literal("relative"),
|
|
8402
8402
|
amount: import_v413.z.number(),
|
|
8403
8403
|
unit: WaitUnitSchema,
|
|
8404
|
-
windows: import_v413.z.array(TimeWindowSlotSchema).optional()
|
|
8404
|
+
windows: import_v413.z.array(TimeWindowSlotSchema).optional(),
|
|
8405
|
+
/**
|
|
8406
|
+
* Optional ISO datetime to use as the base for the relative delay instead of
|
|
8407
|
+
* wall-clock `now`. Used for cadence chaining (schedule relative to a prior
|
|
8408
|
+
* message's scheduledAt). `waitTime` is still measured from wall-clock `now`.
|
|
8409
|
+
*/
|
|
8410
|
+
from: import_v413.z.union([import_v413.z.string(), import_v413.z.date()]).optional().describe(
|
|
8411
|
+
"ISO datetime base for the relative delay (e.g. previous message scheduledAt)"
|
|
8412
|
+
)
|
|
8405
8413
|
});
|
|
8406
8414
|
var WaitInputAbsoluteSchema = import_v413.z.object({
|
|
8407
8415
|
mode: import_v413.z.literal("absolute"),
|
|
@@ -8514,10 +8522,12 @@ function calculateWaitTime(step, now) {
|
|
|
8514
8522
|
};
|
|
8515
8523
|
}
|
|
8516
8524
|
case "relative": {
|
|
8525
|
+
const baseTime = step.from != null ? new Date(step.from).getTime() : nowTime;
|
|
8526
|
+
const baseDate = new Date(baseTime);
|
|
8517
8527
|
if (!step.amount && (!step.windows || step.windows.length === 0)) {
|
|
8518
8528
|
return {
|
|
8519
|
-
waitTime: 0,
|
|
8520
|
-
scheduledAt:
|
|
8529
|
+
waitTime: Math.max(0, baseTime - nowTime),
|
|
8530
|
+
scheduledAt: baseDate
|
|
8521
8531
|
};
|
|
8522
8532
|
}
|
|
8523
8533
|
let relativeDelay = 0;
|
|
@@ -8556,17 +8566,18 @@ function calculateWaitTime(step, now) {
|
|
|
8556
8566
|
}
|
|
8557
8567
|
}
|
|
8558
8568
|
if (!step.windows || step.windows.length === 0) {
|
|
8569
|
+
const scheduledAt = new Date(baseTime + relativeDelay);
|
|
8559
8570
|
return {
|
|
8560
|
-
waitTime:
|
|
8561
|
-
scheduledAt
|
|
8571
|
+
waitTime: Math.max(0, scheduledAt.getTime() - nowTime),
|
|
8572
|
+
scheduledAt
|
|
8562
8573
|
};
|
|
8563
8574
|
}
|
|
8564
|
-
const targetDate = new Date(
|
|
8575
|
+
const targetDate = new Date(baseTime + relativeDelay);
|
|
8565
8576
|
for (const window of step.windows) {
|
|
8566
8577
|
if (isTimeInWindowSlot(targetDate, window)) {
|
|
8567
8578
|
return {
|
|
8568
|
-
waitTime:
|
|
8569
|
-
scheduledAt:
|
|
8579
|
+
waitTime: Math.max(0, targetDate.getTime() - nowTime),
|
|
8580
|
+
scheduledAt: targetDate
|
|
8570
8581
|
};
|
|
8571
8582
|
}
|
|
8572
8583
|
}
|
|
@@ -8611,8 +8622,8 @@ function calculateWaitTime(step, now) {
|
|
|
8611
8622
|
msUntilWindowStart = daysMs + hoursAdjustment + minutesAdjustment;
|
|
8612
8623
|
}
|
|
8613
8624
|
const windowStartTimeMs = targetDate.getTime() + msUntilWindowStart;
|
|
8614
|
-
const
|
|
8615
|
-
const windowScheduledTime =
|
|
8625
|
+
const sameLocalDayAsBase = getLocalDateKey(baseDate, tz) === getLocalDateKey(targetDate, tz);
|
|
8626
|
+
const windowScheduledTime = sameLocalDayAsBase ? new Date(windowStartTimeMs + relativeDelay) : new Date(windowStartTimeMs);
|
|
8616
8627
|
const waitFromNow = windowScheduledTime.getTime() - nowTime;
|
|
8617
8628
|
if (waitFromNow < earliestWaitFromNow) {
|
|
8618
8629
|
earliestWaitFromNow = waitFromNow;
|
|
@@ -9,8 +9,10 @@
|
|
|
9
9
|
import type { WaitInputType, CalculateWaitTimeResult } from './types-workflow';
|
|
10
10
|
/**
|
|
11
11
|
* Calculate the wait time for a wait step
|
|
12
|
-
* @param step The input parameters for the wait step
|
|
13
|
-
*
|
|
12
|
+
* @param step The input parameters for the wait step. Relative mode may include
|
|
13
|
+
* optional `from` (ISO datetime / Date) as the base for the delay instead of `now`.
|
|
14
|
+
* @param now Wall-clock current date/time. Used as the default relative base and
|
|
15
|
+
* always used to compute `waitTime` (ms until `scheduledAt`).
|
|
14
16
|
* @returns The time to wait in milliseconds and the scheduled date
|
|
15
17
|
*/
|
|
16
18
|
export declare function calculateWaitTime(step: WaitInputType, now: Date): CalculateWaitTimeResult;
|
package/dist/scheduling/index.js
CHANGED
|
@@ -128,10 +128,12 @@ function calculateWaitTime(step, now) {
|
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
130
|
case "relative": {
|
|
131
|
+
const baseTime = step.from != null ? new Date(step.from).getTime() : nowTime;
|
|
132
|
+
const baseDate = new Date(baseTime);
|
|
131
133
|
if (!step.amount && (!step.windows || step.windows.length === 0)) {
|
|
132
134
|
return {
|
|
133
|
-
waitTime: 0,
|
|
134
|
-
scheduledAt:
|
|
135
|
+
waitTime: Math.max(0, baseTime - nowTime),
|
|
136
|
+
scheduledAt: baseDate
|
|
135
137
|
};
|
|
136
138
|
}
|
|
137
139
|
let relativeDelay = 0;
|
|
@@ -170,17 +172,18 @@ function calculateWaitTime(step, now) {
|
|
|
170
172
|
}
|
|
171
173
|
}
|
|
172
174
|
if (!step.windows || step.windows.length === 0) {
|
|
175
|
+
const scheduledAt = new Date(baseTime + relativeDelay);
|
|
173
176
|
return {
|
|
174
|
-
waitTime:
|
|
175
|
-
scheduledAt
|
|
177
|
+
waitTime: Math.max(0, scheduledAt.getTime() - nowTime),
|
|
178
|
+
scheduledAt
|
|
176
179
|
};
|
|
177
180
|
}
|
|
178
|
-
const targetDate = new Date(
|
|
181
|
+
const targetDate = new Date(baseTime + relativeDelay);
|
|
179
182
|
for (const window of step.windows) {
|
|
180
183
|
if (isTimeInWindowSlot(targetDate, window)) {
|
|
181
184
|
return {
|
|
182
|
-
waitTime:
|
|
183
|
-
scheduledAt:
|
|
185
|
+
waitTime: Math.max(0, targetDate.getTime() - nowTime),
|
|
186
|
+
scheduledAt: targetDate
|
|
184
187
|
};
|
|
185
188
|
}
|
|
186
189
|
}
|
|
@@ -225,8 +228,8 @@ function calculateWaitTime(step, now) {
|
|
|
225
228
|
msUntilWindowStart = daysMs + hoursAdjustment + minutesAdjustment;
|
|
226
229
|
}
|
|
227
230
|
const windowStartTimeMs = targetDate.getTime() + msUntilWindowStart;
|
|
228
|
-
const
|
|
229
|
-
const windowScheduledTime =
|
|
231
|
+
const sameLocalDayAsBase = getLocalDateKey(baseDate, tz) === getLocalDateKey(targetDate, tz);
|
|
232
|
+
const windowScheduledTime = sameLocalDayAsBase ? new Date(windowStartTimeMs + relativeDelay) : new Date(windowStartTimeMs);
|
|
230
233
|
const waitFromNow = windowScheduledTime.getTime() - nowTime;
|
|
231
234
|
if (waitFromNow < earliestWaitFromNow) {
|
|
232
235
|
earliestWaitFromNow = waitFromNow;
|
|
@@ -100,10 +100,12 @@ function calculateWaitTime(step, now) {
|
|
|
100
100
|
};
|
|
101
101
|
}
|
|
102
102
|
case "relative": {
|
|
103
|
+
const baseTime = step.from != null ? new Date(step.from).getTime() : nowTime;
|
|
104
|
+
const baseDate = new Date(baseTime);
|
|
103
105
|
if (!step.amount && (!step.windows || step.windows.length === 0)) {
|
|
104
106
|
return {
|
|
105
|
-
waitTime: 0,
|
|
106
|
-
scheduledAt:
|
|
107
|
+
waitTime: Math.max(0, baseTime - nowTime),
|
|
108
|
+
scheduledAt: baseDate
|
|
107
109
|
};
|
|
108
110
|
}
|
|
109
111
|
let relativeDelay = 0;
|
|
@@ -142,17 +144,18 @@ function calculateWaitTime(step, now) {
|
|
|
142
144
|
}
|
|
143
145
|
}
|
|
144
146
|
if (!step.windows || step.windows.length === 0) {
|
|
147
|
+
const scheduledAt = new Date(baseTime + relativeDelay);
|
|
145
148
|
return {
|
|
146
|
-
waitTime:
|
|
147
|
-
scheduledAt
|
|
149
|
+
waitTime: Math.max(0, scheduledAt.getTime() - nowTime),
|
|
150
|
+
scheduledAt
|
|
148
151
|
};
|
|
149
152
|
}
|
|
150
|
-
const targetDate = new Date(
|
|
153
|
+
const targetDate = new Date(baseTime + relativeDelay);
|
|
151
154
|
for (const window of step.windows) {
|
|
152
155
|
if (isTimeInWindowSlot(targetDate, window)) {
|
|
153
156
|
return {
|
|
154
|
-
waitTime:
|
|
155
|
-
scheduledAt:
|
|
157
|
+
waitTime: Math.max(0, targetDate.getTime() - nowTime),
|
|
158
|
+
scheduledAt: targetDate
|
|
156
159
|
};
|
|
157
160
|
}
|
|
158
161
|
}
|
|
@@ -197,8 +200,8 @@ function calculateWaitTime(step, now) {
|
|
|
197
200
|
msUntilWindowStart = daysMs + hoursAdjustment + minutesAdjustment;
|
|
198
201
|
}
|
|
199
202
|
const windowStartTimeMs = targetDate.getTime() + msUntilWindowStart;
|
|
200
|
-
const
|
|
201
|
-
const windowScheduledTime =
|
|
203
|
+
const sameLocalDayAsBase = getLocalDateKey(baseDate, tz) === getLocalDateKey(targetDate, tz);
|
|
204
|
+
const windowScheduledTime = sameLocalDayAsBase ? new Date(windowStartTimeMs + relativeDelay) : new Date(windowStartTimeMs);
|
|
202
205
|
const waitFromNow = windowScheduledTime.getTime() - nowTime;
|
|
203
206
|
if (waitFromNow < earliestWaitFromNow) {
|
|
204
207
|
earliestWaitFromNow = waitFromNow;
|
|
@@ -33,6 +33,13 @@ export interface WaitInputRelative {
|
|
|
33
33
|
amount: number;
|
|
34
34
|
unit: WaitUnit;
|
|
35
35
|
windows?: TimeWindowSlot[];
|
|
36
|
+
/**
|
|
37
|
+
* Optional ISO datetime (or Date) to use as the base for the relative delay
|
|
38
|
+
* instead of wall-clock `now`. Used for cadence chaining: schedule message N
|
|
39
|
+
* relative to message N-1's `scheduledAt`.
|
|
40
|
+
* `waitTime` in the result is still measured from wall-clock `now`.
|
|
41
|
+
*/
|
|
42
|
+
from?: string | Date;
|
|
36
43
|
}
|
|
37
44
|
export interface WaitInputAbsolute {
|
|
38
45
|
mode: 'absolute';
|
|
@@ -107,6 +107,7 @@ export declare const WaitInputRelativeSchema: z.ZodObject<{
|
|
|
107
107
|
}>>;
|
|
108
108
|
timezone: z.ZodOptional<z.ZodString>;
|
|
109
109
|
}, z.core.$strip>>>;
|
|
110
|
+
from: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodDate]>>;
|
|
110
111
|
}, z.core.$strip>;
|
|
111
112
|
export declare const WaitInputAbsoluteSchema: z.ZodObject<{
|
|
112
113
|
mode: z.ZodLiteral<"absolute">;
|
|
@@ -153,6 +154,7 @@ export declare const WaitInputSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
153
154
|
}>>;
|
|
154
155
|
timezone: z.ZodOptional<z.ZodString>;
|
|
155
156
|
}, z.core.$strip>>>;
|
|
157
|
+
from: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodDate]>>;
|
|
156
158
|
}, z.core.$strip>, z.ZodObject<{
|
|
157
159
|
mode: z.ZodLiteral<"absolute">;
|
|
158
160
|
scheduleAt: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|