@keystrokehq/keystroke 0.0.62 → 0.0.66

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.
Files changed (43) hide show
  1. package/dist/action.cjs +1 -1
  2. package/dist/action.mjs +1 -1
  3. package/dist/agent.cjs +3 -3
  4. package/dist/agent.mjs +3 -3
  5. package/dist/config.d.cts.map +1 -1
  6. package/dist/config.d.mts.map +1 -1
  7. package/dist/credentials.cjs +1 -1
  8. package/dist/credentials.mjs +1 -1
  9. package/dist/{dist-BkXl9gQF.cjs → dist-Bism_aBn.cjs} +3 -3
  10. package/dist/{dist-BkXl9gQF.cjs.map → dist-Bism_aBn.cjs.map} +1 -1
  11. package/dist/{dist-BcS5RYgX.cjs → dist-D1jOLmXW.cjs} +21 -3
  12. package/dist/{dist-BcS5RYgX.cjs.map → dist-D1jOLmXW.cjs.map} +1 -1
  13. package/dist/{dist-BPbk55m-.cjs → dist-D5Grf4qu.cjs} +65 -7
  14. package/dist/dist-D5Grf4qu.cjs.map +1 -0
  15. package/dist/{dist-SRdmqD5M.mjs → dist-D8tPcFYP.mjs} +3 -3
  16. package/dist/{dist-SRdmqD5M.mjs.map → dist-D8tPcFYP.mjs.map} +1 -1
  17. package/dist/{dist-Bt-d5yhn.mjs → dist-DRPUD4yJ.mjs} +21 -3
  18. package/dist/{dist-Bt-d5yhn.mjs.map → dist-DRPUD4yJ.mjs.map} +1 -1
  19. package/dist/{dist-BxHP5hXz.mjs → dist-D_ZSj4pO.mjs} +65 -7
  20. package/dist/dist-D_ZSj4pO.mjs.map +1 -0
  21. package/dist/index-BeEymXir.d.cts.map +1 -1
  22. package/dist/index-BeEymXir.d.mts.map +1 -1
  23. package/dist/{mistral-DZaYJXpM.cjs → mistral-BGGYz0IH.cjs} +2 -2
  24. package/dist/{mistral-DZaYJXpM.cjs.map → mistral-BGGYz0IH.cjs.map} +1 -1
  25. package/dist/{mistral-DAR1MPzS.mjs → mistral-R2FX6jgL.mjs} +2 -2
  26. package/dist/{mistral-DAR1MPzS.mjs.map → mistral-R2FX6jgL.mjs.map} +1 -1
  27. package/dist/{sse-BjtIZJyR.mjs → sse-CKh7BzLf.mjs} +2 -2
  28. package/dist/{sse-BjtIZJyR.mjs.map → sse-CKh7BzLf.mjs.map} +1 -1
  29. package/dist/{sse-Cd5tB78r.cjs → sse-WhoZVnd2.cjs} +2 -2
  30. package/dist/{sse-Cd5tB78r.cjs.map → sse-WhoZVnd2.cjs.map} +1 -1
  31. package/dist/trigger.cjs +12 -11
  32. package/dist/trigger.cjs.map +1 -1
  33. package/dist/trigger.d.cts +7 -11
  34. package/dist/trigger.d.cts.map +1 -1
  35. package/dist/trigger.d.mts +7 -11
  36. package/dist/trigger.d.mts.map +1 -1
  37. package/dist/trigger.mjs +12 -12
  38. package/dist/trigger.mjs.map +1 -1
  39. package/dist/workflow.cjs +1 -1
  40. package/dist/workflow.mjs +1 -1
  41. package/package.json +6 -6
  42. package/dist/dist-BPbk55m-.cjs.map +0 -1
  43. package/dist/dist-BxHP5hXz.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"trigger.cjs","names":["z","isWorkflow"],"sources":["../../../node_modules/.pnpm/cron-schedule@6.0.0/node_modules/cron-schedule/dist/utils.js","../../../node_modules/.pnpm/cron-schedule@6.0.0/node_modules/cron-schedule/dist/cron.js","../../../node_modules/.pnpm/cron-schedule@6.0.0/node_modules/cron-schedule/dist/cron-parser.js","../../trigger/dist/index.mjs"],"sourcesContent":["export const TIMEOUT_MAX = 2147483647; // 2^31-1\n/**\n * Creates a new timeout, which can exceed the max timeout limit of 2^31-1.\n * Since multiple timeouts are used internally, the timeoutId used to clear the timeout\n * is returned as a handle (object) and changes whenever the max timeout limit is exceeded.\n * The handle parameter can be ignored, it is used internally for updating the timeoutId\n * in the handle after creating the next timeout.\n */\nexport function longTimeout(fn, timeout, previousHandle) {\n let nextTimeout = timeout;\n let remainingTimeout = 0;\n if (nextTimeout > TIMEOUT_MAX) {\n remainingTimeout = nextTimeout - TIMEOUT_MAX;\n nextTimeout = TIMEOUT_MAX;\n }\n const handle = previousHandle !== null && previousHandle !== void 0 ? previousHandle : {\n timeoutId: undefined,\n };\n handle.timeoutId = setTimeout(() => {\n if (remainingTimeout > 0) {\n longTimeout(fn, remainingTimeout, previousHandle);\n }\n else {\n fn();\n }\n }, nextTimeout);\n return handle;\n}\n/* Extracts second, minute, hour, date, month and the weekday from a date. */\nexport function extractDateElements(date) {\n return {\n second: date.getSeconds(),\n minute: date.getMinutes(),\n hour: date.getHours(),\n day: date.getDate(),\n month: date.getMonth(),\n weekday: date.getDay(),\n year: date.getFullYear(),\n };\n}\n/* Gets the amount of days in the given month (indexed by 0) of the given year. */\nexport function getDaysInMonth(year, month) {\n return new Date(year, month + 1, 0).getDate();\n}\n/* Gets the amount of days from weekday1 to weekday2. */\nexport function getDaysBetweenWeekdays(weekday1, weekday2) {\n if (weekday1 <= weekday2) {\n return weekday2 - weekday1;\n }\n return 6 - weekday1 + weekday2 + 1;\n}\nexport function wrapFunction(fn, errorHandler) {\n return () => {\n try {\n const res = fn();\n if (res instanceof Promise) {\n res.catch((err) => {\n if (errorHandler) {\n errorHandler(err);\n }\n });\n }\n }\n catch (err) {\n if (errorHandler) {\n errorHandler(err);\n }\n }\n };\n}\n//# sourceMappingURL=utils.js.map","import { extractDateElements, getDaysBetweenWeekdays, getDaysInMonth, } from './utils.js';\nexport class Cron {\n constructor({ seconds, minutes, hours, days, months, weekdays, }) {\n // Validate that there are values provided.\n if (!seconds || seconds.size === 0)\n throw new Error('There must be at least one allowed second.');\n if (!minutes || minutes.size === 0)\n throw new Error('There must be at least one allowed minute.');\n if (!hours || hours.size === 0)\n throw new Error('There must be at least one allowed hour.');\n if (!months || months.size === 0)\n throw new Error('There must be at least one allowed month.');\n if ((!weekdays || weekdays.size === 0) && (!days || days.size === 0))\n throw new Error('There must be at least one allowed day or weekday.');\n // Convert set to array and sort in ascending order.\n this.seconds = Array.from(seconds).sort((a, b) => a - b);\n this.minutes = Array.from(minutes).sort((a, b) => a - b);\n this.hours = Array.from(hours).sort((a, b) => a - b);\n this.days = Array.from(days).sort((a, b) => a - b);\n this.months = Array.from(months).sort((a, b) => a - b);\n this.weekdays = Array.from(weekdays).sort((a, b) => a - b);\n // Validate that all values are integers within the constraint.\n const validateData = (name, data, constraint) => {\n if (data.some((x) => typeof x !== 'number' ||\n x % 1 !== 0 ||\n x < constraint.min ||\n x > constraint.max)) {\n throw new Error(`${name} must only consist of integers which are within the range of ${constraint.min} and ${constraint.max}`);\n }\n };\n validateData('seconds', this.seconds, { min: 0, max: 59 });\n validateData('minutes', this.minutes, { min: 0, max: 59 });\n validateData('hours', this.hours, { min: 0, max: 23 });\n validateData('days', this.days, { min: 1, max: 31 });\n validateData('months', this.months, { min: 0, max: 11 });\n validateData('weekdays', this.weekdays, { min: 0, max: 6 });\n // For each element, store a reversed copy in the reversed attribute for finding prev dates.\n this.reversed = {\n seconds: this.seconds.map((x) => x).reverse(),\n minutes: this.minutes.map((x) => x).reverse(),\n hours: this.hours.map((x) => x).reverse(),\n days: this.days.map((x) => x).reverse(),\n months: this.months.map((x) => x).reverse(),\n weekdays: this.weekdays.map((x) => x).reverse(),\n };\n }\n /**\n * Find the next or previous hour, starting from the given start hour that matches the hour constraint.\n * startHour itself might also be allowed.\n */\n findAllowedHour(dir, startHour) {\n return dir === 'next'\n ? this.hours.find((x) => x >= startHour)\n : this.reversed.hours.find((x) => x <= startHour);\n }\n /**\n * Find the next or previous minute, starting from the given start minute that matches the minute constraint.\n * startMinute itself might also be allowed.\n */\n findAllowedMinute(dir, startMinute) {\n return dir === 'next'\n ? this.minutes.find((x) => x >= startMinute)\n : this.reversed.minutes.find((x) => x <= startMinute);\n }\n /**\n * Find the next or previous second, starting from the given start second that matches the second constraint.\n * startSecond itself IS NOT allowed.\n */\n findAllowedSecond(dir, startSecond) {\n return dir === 'next'\n ? this.seconds.find((x) => x > startSecond)\n : this.reversed.seconds.find((x) => x < startSecond);\n }\n /**\n * Find the next or previous time, starting from the given start time that matches the hour, minute\n * and second constraints. startTime itself might also be allowed.\n */\n findAllowedTime(dir, startTime) {\n // Try to find an allowed hour.\n let hour = this.findAllowedHour(dir, startTime.hour);\n if (hour !== undefined) {\n if (hour === startTime.hour) {\n // We found an hour that is the start hour. Try to find an allowed minute.\n let minute = this.findAllowedMinute(dir, startTime.minute);\n if (minute !== undefined) {\n if (minute === startTime.minute) {\n // We found a minute that is the start minute. Try to find an allowed second.\n const second = this.findAllowedSecond(dir, startTime.second);\n if (second !== undefined) {\n // We found a second within the start hour and minute.\n return { hour, minute, second };\n }\n // We did not find a valid second within the start minute. Try to find another minute.\n minute = this.findAllowedMinute(dir, dir === 'next' ? startTime.minute + 1 : startTime.minute - 1);\n if (minute !== undefined) {\n // We found a minute which is not the start minute. Return that minute together with the hour and the first / last allowed second.\n return {\n hour,\n minute,\n second: dir === 'next' ? this.seconds[0] : this.reversed.seconds[0],\n };\n }\n }\n else {\n // We found a minute which is not the start minute. Return that minute together with the hour and the first / last allowed second.\n return {\n hour,\n minute,\n second: dir === 'next' ? this.seconds[0] : this.reversed.seconds[0],\n };\n }\n }\n // We did not find an allowed minute / second combination inside the start hour. Try to find the next / previous allowed hour.\n hour = this.findAllowedHour(dir, dir === 'next' ? startTime.hour + 1 : startTime.hour - 1);\n if (hour !== undefined) {\n // We found an allowed hour which is not the start hour. Return that hour together with the first / last allowed minutes / seconds.\n return {\n hour,\n minute: dir === 'next' ? this.minutes[0] : this.reversed.minutes[0],\n second: dir === 'next' ? this.seconds[0] : this.reversed.seconds[0],\n };\n }\n }\n else {\n // We found an allowed hour which is not the start hour. Return that hour together with the first / last allowed minutes / seconds.\n return {\n hour,\n minute: dir === 'next' ? this.minutes[0] : this.reversed.minutes[0],\n second: dir === 'next' ? this.seconds[0] : this.reversed.seconds[0],\n };\n }\n }\n // No allowed time found.\n return undefined;\n }\n /**\n * Find the next or previous day in the given month, starting from the given startDay\n * that matches either the day or the weekday constraint. startDay itself might also be allowed.\n */\n findAllowedDayInMonth(dir, year, month, startDay) {\n var _a, _b;\n if (startDay < 1)\n throw new Error('startDay must not be smaller than 1.');\n // If only days are restricted: allow day based on day constraint only.\n // If only weekdays are restricted: allow day based on weekday constraint only.\n // If both are restricted: allow day based on both day and weekday constraint. pick day that is closer to startDay.\n // If none are restricted: return the day closest to startDay (respecting dir) that is allowed (or startDay itself).\n const daysInMonth = getDaysInMonth(year, month);\n const daysRestricted = this.days.length !== 31;\n const weekdaysRestricted = this.weekdays.length !== 7;\n if (!daysRestricted && !weekdaysRestricted) {\n if (startDay > daysInMonth) {\n return dir === 'next' ? undefined : daysInMonth;\n }\n return startDay;\n }\n // Try to find a day based on the days constraint.\n let allowedDayByDays;\n if (daysRestricted) {\n allowedDayByDays =\n dir === 'next'\n ? this.days.find((x) => x >= startDay)\n : this.reversed.days.find((x) => x <= startDay);\n // Make sure the day does not exceed the amount of days in month.\n if (allowedDayByDays !== undefined && allowedDayByDays > daysInMonth) {\n allowedDayByDays = undefined;\n }\n }\n // Try to find a day based on the weekday constraint.\n let allowedDayByWeekdays;\n if (weekdaysRestricted) {\n const startWeekday = new Date(year, month, startDay).getDay();\n const nearestAllowedWeekday = dir === 'next'\n ? ((_a = this.weekdays.find((x) => x >= startWeekday)) !== null && _a !== void 0 ? _a : this.weekdays[0])\n : ((_b = this.reversed.weekdays.find((x) => x <= startWeekday)) !== null && _b !== void 0 ? _b : this.reversed.weekdays[0]);\n if (nearestAllowedWeekday !== undefined) {\n const daysBetweenWeekdays = dir === 'next'\n ? getDaysBetweenWeekdays(startWeekday, nearestAllowedWeekday)\n : getDaysBetweenWeekdays(nearestAllowedWeekday, startWeekday);\n allowedDayByWeekdays =\n dir === 'next'\n ? startDay + daysBetweenWeekdays\n : startDay - daysBetweenWeekdays;\n // Make sure the day does not exceed the month boundaries.\n if (allowedDayByWeekdays > daysInMonth || allowedDayByWeekdays < 1) {\n allowedDayByWeekdays = undefined;\n }\n }\n }\n if (allowedDayByDays !== undefined && allowedDayByWeekdays !== undefined) {\n // If a day is found both via the days and the weekdays constraint, pick the day\n // that is closer to start date.\n return dir === 'next'\n ? Math.min(allowedDayByDays, allowedDayByWeekdays)\n : Math.max(allowedDayByDays, allowedDayByWeekdays);\n }\n if (allowedDayByDays !== undefined) {\n return allowedDayByDays;\n }\n if (allowedDayByWeekdays !== undefined) {\n return allowedDayByWeekdays;\n }\n return undefined;\n }\n /** Gets the next date starting from the given start date or now. */\n getNextDate(startDate = new Date()) {\n const startDateElements = extractDateElements(startDate);\n let minYear = startDateElements.year;\n let startIndexMonth = this.months.findIndex((x) => x >= startDateElements.month);\n if (startIndexMonth === -1) {\n startIndexMonth = 0;\n minYear++;\n }\n // We try every month within the next 5 years to make sure that we tried to\n // find a matching date insidde a whole leap year.\n const maxIterations = this.months.length * 5;\n for (let i = 0; i < maxIterations; i++) {\n // Get the next year and month.\n const year = minYear + Math.floor((startIndexMonth + i) / this.months.length);\n const month = this.months[(startIndexMonth + i) % this.months.length];\n const isStartMonth = year === startDateElements.year && month === startDateElements.month;\n // Find the next day.\n let day = this.findAllowedDayInMonth('next', year, month, isStartMonth ? startDateElements.day : 1);\n let isStartDay = isStartMonth && day === startDateElements.day;\n // If we found a day and it is the start day, try to find a valid time beginning from the start date time.\n if (day !== undefined && isStartDay) {\n const nextTime = this.findAllowedTime('next', startDateElements);\n if (nextTime !== undefined) {\n return new Date(year, month, day, nextTime.hour, nextTime.minute, nextTime.second);\n }\n // If no valid time has been found for the start date, try the next day.\n day = this.findAllowedDayInMonth('next', year, month, day + 1);\n isStartDay = false;\n }\n // If we found a next day and it is not the start day, just use the next day with the first allowed values\n // for hours, minutes and seconds.\n if (day !== undefined && !isStartDay) {\n return new Date(year, month, day, this.hours[0], this.minutes[0], this.seconds[0]);\n }\n // No allowed day has been found for this month. Continue to search in next month.\n }\n throw new Error('No valid next date was found.');\n }\n /** Gets the specified amount of future dates starting from the given start date or now. */\n getNextDates(amount, startDate) {\n const dates = [];\n let nextDate;\n for (let i = 0; i < amount; i++) {\n nextDate = this.getNextDate(nextDate !== null && nextDate !== void 0 ? nextDate : startDate);\n dates.push(nextDate);\n }\n return dates;\n }\n /**\n * Get an ES6 compatible iterator which iterates over the next dates starting from startDate or now.\n * The iterator runs until the optional endDate is reached or forever.\n */\n *getNextDatesIterator(startDate, endDate) {\n let nextDate;\n while (true) {\n nextDate = this.getNextDate(nextDate !== null && nextDate !== void 0 ? nextDate : startDate);\n if (endDate && endDate.getTime() < nextDate.getTime()) {\n return;\n }\n yield nextDate;\n }\n }\n /** Gets the previous date starting from the given start date or now. */\n getPrevDate(startDate = new Date()) {\n const startDateElements = extractDateElements(startDate);\n let maxYear = startDateElements.year;\n let startIndexMonth = this.reversed.months.findIndex((x) => x <= startDateElements.month);\n if (startIndexMonth === -1) {\n startIndexMonth = 0;\n maxYear--;\n }\n // We try every month within the past 5 years to make sure that we tried to\n // find a matching date inside a whole leap year.\n const maxIterations = this.reversed.months.length * 5;\n for (let i = 0; i < maxIterations; i++) {\n // Get the next year and month.\n const year = maxYear -\n Math.floor((startIndexMonth + i) / this.reversed.months.length);\n const month = this.reversed.months[(startIndexMonth + i) % this.reversed.months.length];\n const isStartMonth = year === startDateElements.year && month === startDateElements.month;\n // Find the previous day.\n let day = this.findAllowedDayInMonth('prev', year, month, isStartMonth\n ? startDateElements.day\n : // Start searching from the last day of the month.\n getDaysInMonth(year, month));\n let isStartDay = isStartMonth && day === startDateElements.day;\n // If we found a day and it is the start day, try to find a valid time beginning from the start date time.\n if (day !== undefined && isStartDay) {\n const prevTime = this.findAllowedTime('prev', startDateElements);\n if (prevTime !== undefined) {\n return new Date(year, month, day, prevTime.hour, prevTime.minute, prevTime.second);\n }\n // If no valid time has been found for the start date, try the previous day.\n if (day > 1) {\n day = this.findAllowedDayInMonth('prev', year, month, day - 1);\n isStartDay = false;\n }\n }\n // If we found a previous day and it is not the start day, just use the previous day with the first allowed values\n // for hours, minutes and seconds (which will be the latest time due to using the reversed array).\n if (day !== undefined && !isStartDay) {\n return new Date(year, month, day, this.reversed.hours[0], this.reversed.minutes[0], this.reversed.seconds[0]);\n }\n // No allowed day has been found for this month. Continue to search in previous month.\n }\n throw new Error('No valid previous date was found.');\n }\n /** Gets the specified amount of previous dates starting from the given start date or now. */\n getPrevDates(amount, startDate) {\n const dates = [];\n let prevDate;\n for (let i = 0; i < amount; i++) {\n prevDate = this.getPrevDate(prevDate !== null && prevDate !== void 0 ? prevDate : startDate);\n dates.push(prevDate);\n }\n return dates;\n }\n /**\n * Get an ES6 compatible iterator which iterates over the previous dates starting from startDate or now.\n * The iterator runs until the optional endDate is reached or forever.\n */\n *getPrevDatesIterator(startDate, endDate) {\n let prevDate;\n while (true) {\n prevDate = this.getPrevDate(prevDate !== null && prevDate !== void 0 ? prevDate : startDate);\n if (endDate && endDate.getTime() > prevDate.getTime()) {\n return;\n }\n yield prevDate;\n }\n }\n /** Returns true when there is a cron date at the given date. */\n matchDate(date) {\n const { second, minute, hour, day, month, weekday } = extractDateElements(date);\n if (this.seconds.indexOf(second) === -1 ||\n this.minutes.indexOf(minute) === -1 ||\n this.hours.indexOf(hour) === -1 ||\n this.months.indexOf(month) === -1) {\n return false;\n }\n if (this.days.length !== 31 && this.weekdays.length !== 7) {\n return (this.days.indexOf(day) !== -1 || this.weekdays.indexOf(weekday) !== -1);\n }\n return (this.days.indexOf(day) !== -1 && this.weekdays.indexOf(weekday) !== -1);\n }\n}\n//# sourceMappingURL=cron.js.map","import { Cron } from './cron.js';\nconst secondConstraint = {\n min: 0,\n max: 59,\n};\nconst minuteConstraint = {\n min: 0,\n max: 59,\n};\nconst hourConstraint = {\n min: 0,\n max: 23,\n};\nconst dayConstraint = {\n min: 1,\n max: 31,\n};\nconst monthConstraint = {\n min: 1,\n max: 12,\n aliases: {\n jan: '1',\n feb: '2',\n mar: '3',\n apr: '4',\n may: '5',\n jun: '6',\n jul: '7',\n aug: '8',\n sep: '9',\n oct: '10',\n nov: '11',\n dec: '12',\n },\n};\nconst weekdayConstraint = {\n min: 0,\n max: 7,\n aliases: {\n mon: '1',\n tue: '2',\n wed: '3',\n thu: '4',\n fri: '5',\n sat: '6',\n sun: '7',\n },\n};\nconst timeNicknames = {\n '@yearly': '0 0 1 1 *',\n '@annually': '0 0 1 1 *',\n '@monthly': '0 0 1 * *',\n '@weekly': '0 0 * * 0',\n '@daily': '0 0 * * *',\n '@hourly': '0 * * * *',\n '@minutely': '* * * * *',\n};\nfunction parseElement(element, constraint) {\n const result = new Set();\n // If returned set of numbers is empty, the scheduler class interpretes the emtpy set of numbers as all valid values of the constraint\n if (element === '*') {\n for (let i = constraint.min; i <= constraint.max; i = i + 1) {\n result.add(i);\n }\n return result;\n }\n // If the element is a list, parse each element in the list.\n const listElements = element.split(',');\n if (listElements.length > 1) {\n for (const listElement of listElements) {\n const parsedListElement = parseElement(listElement, constraint);\n for (const x of parsedListElement) {\n result.add(x);\n }\n }\n return result;\n }\n // Helper function to parse a single element, which includes checking for alias, valid number and constraint min and max.\n const parseSingleElement = (singleElement) => {\n var _a, _b;\n singleElement =\n (_b = (_a = constraint.aliases) === null || _a === void 0 ? void 0 : _a[singleElement.toLowerCase()]) !== null && _b !== void 0 ? _b : singleElement;\n const parsedElement = Number.parseInt(singleElement, 10);\n if (Number.isNaN(parsedElement)) {\n throw new Error(`Failed to parse ${element}: ${singleElement} is NaN.`);\n }\n if (parsedElement < constraint.min || parsedElement > constraint.max) {\n throw new Error(`Failed to parse ${element}: ${singleElement} is outside of constraint range of ${constraint.min} - ${constraint.max}.`);\n }\n return parsedElement;\n };\n // Detect if the element is a range.\n // Possible range formats: 'start-end', 'start-end/step', '*', '*/step'.\n // Where start and end can be numbers or aliases.\n // Capture groups: 1: start-end, 2: start, 3: end, 4: /step, 5: step.\n const rangeSegments = /^(([0-9a-zA-Z]+)-([0-9a-zA-Z]+)|\\*)(\\/([0-9]+))?$/.exec(element);\n // If not, it must be a single element.\n if (rangeSegments === null) {\n result.add(parseSingleElement(element));\n return result;\n }\n // If it is a range, get start and end of the range.\n let parsedStart = rangeSegments[1] === '*'\n ? constraint.min\n : parseSingleElement(rangeSegments[2]);\n const parsedEnd = rangeSegments[1] === '*'\n ? constraint.max\n : parseSingleElement(rangeSegments[3]);\n // need to catch Sunday, which gets parsed here as 7, but is also legitimate at the start of a range as 0, to avoid the out of order error\n if (constraint === weekdayConstraint &&\n parsedStart === 7 &&\n // this check ensures that sun-sun is not incorrectly parsed as [0,1,2,3,4,5,6]\n parsedEnd !== 7) {\n parsedStart = 0;\n }\n if (parsedStart > parsedEnd) {\n throw new Error(`Failed to parse ${element}: Invalid range (start: ${parsedStart}, end: ${parsedEnd}).`);\n }\n // Check whether there is a custom step defined for the range, defaulting to 1.\n const step = rangeSegments[5];\n let parsedStep = 1;\n if (step !== undefined) {\n parsedStep = Number.parseInt(step, 10);\n if (Number.isNaN(parsedStep)) {\n throw new Error(`Failed to parse step: ${step} is NaN.`);\n }\n if (parsedStep < 1) {\n throw new Error(`Failed to parse step: Expected ${step} to be greater than 0.`);\n }\n }\n // Go from start to end of the range by the given steps.\n for (let i = parsedStart; i <= parsedEnd; i = i + parsedStep) {\n result.add(i);\n }\n return result;\n}\n/** Parses a cron expression into a Cron instance. */\nexport function parseCronExpression(cronExpression) {\n var _a;\n if (typeof cronExpression !== 'string') {\n throw new TypeError('Invalid cron expression: must be of type string.');\n }\n // Convert time nicknames.\n cronExpression = (_a = timeNicknames[cronExpression.toLowerCase()]) !== null && _a !== void 0 ? _a : cronExpression;\n // Split the cron expression into its elements, removing empty elements (extra whitespaces).\n const elements = cronExpression.split(' ').filter((elem) => elem.length > 0);\n if (elements.length < 5 || elements.length > 6) {\n throw new Error('Invalid cron expression: expected 5 or 6 elements.');\n }\n const rawSeconds = elements.length === 6 ? elements[0] : '0';\n const rawMinutes = elements.length === 6 ? elements[1] : elements[0];\n const rawHours = elements.length === 6 ? elements[2] : elements[1];\n const rawDays = elements.length === 6 ? elements[3] : elements[2];\n const rawMonths = elements.length === 6 ? elements[4] : elements[3];\n const rawWeekdays = elements.length === 6 ? elements[5] : elements[4];\n return new Cron({\n seconds: parseElement(rawSeconds, secondConstraint),\n minutes: parseElement(rawMinutes, minuteConstraint),\n hours: parseElement(rawHours, hourConstraint),\n days: parseElement(rawDays, dayConstraint),\n // months in cron are indexed by 1, but Cron expects indexes by 0, so we need to reduce all set values by one.\n months: new Set(Array.from(parseElement(rawMonths, monthConstraint)).map((x) => x - 1)),\n weekdays: new Set(Array.from(parseElement(rawWeekdays, weekdayConstraint)).map((x) => x % 7)),\n });\n}\n//# sourceMappingURL=cron-parser.js.map","import { parseCronExpression } from \"cron-schedule\";\nimport { z } from \"zod\";\nimport { isWorkflow } from \"@keystrokehq/workflow\";\n//#region src/cron/cron-schedule.ts\n/**\n* Validates and brands a cron expression. Accepts anything the `cron-schedule`\n* engine accepts (5/6 fields, named months/weekdays, `@daily`-style nicknames)\n* so authoring validation never rejects a schedule the scheduler can run. The\n* `.brand()` makes `CronSchedule` nominally distinct from a plain `string`, so\n* a raw string can't be passed where a validated schedule is expected.\n*/\nconst cronScheduleSchema = z.string().trim().min(1, \"cron schedule must be a non-empty string\").refine(isParseableCron, \"must be a valid cron expression\").brand();\n/** Parse/validate an arbitrary value into a branded `CronSchedule` (throws on failure). */\nfunction parseCronSchedule(value) {\n\treturn cronScheduleSchema.parse(value);\n}\n/**\n* Resolves the effective schedule for an attachment, applying overrides by\n* precedence: per-attachment override → global override → the authored\n* schedule. Pure string precedence — no cron parsing.\n*/\nfunction resolveCronSchedule(attachmentId, schedule, options) {\n\treturn options.attachmentScheduleOverrides?.[attachmentId] ?? options.cronScheduleOverride ?? schedule;\n}\n/** Parse a schedule into a `cron-schedule` `Cron` instance (throws on invalid input). */\nfunction parseTriggerSchedule(schedule) {\n\treturn toCron(schedule);\n}\n/** The next time the schedule fires at or after `from`. */\nfunction nextTriggerRunAt(schedule, from = /* @__PURE__ */ new Date()) {\n\treturn toCron(schedule).getNextDate(from);\n}\n/**\n* Single touchpoint for the `cron-schedule` library — every parse, validation,\n* and next-run calculation in this package goes through here.\n*/\nfunction toCron(schedule) {\n\treturn parseCronExpression(schedule);\n}\nfunction isParseableCron(value) {\n\ttry {\n\t\ttoCron(value);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n//#endregion\n//#region src/attachment-key.ts\nfunction workflowKeyFromDefinition(workflow) {\n\tconst key = workflow.key?.trim();\n\tif (!key) throw new Error(\"Workflow definition requires a non-empty key\");\n\treturn key;\n}\nfunction attachmentKeyFrom(triggerKey, workflowKey) {\n\treturn `${triggerKey}:${workflowKey}`;\n}\n//#endregion\n//#region src/attachment-definition.ts\nconst zodSchema = z.custom((v) => v instanceof z.ZodType, \"must be a Zod schema\");\nconst workflowSchema = z.custom((v) => isWorkflow(v), \"must be defineWorkflow(...)\");\nconst baseSourceShape = {\n\tkey: z.string().trim().min(1),\n\tattach: z.function()\n};\nconst webhookSourceSchema = z.object({\n\tkind: z.literal(\"webhook\"),\n\t...baseSourceShape,\n\tpath: z.string().min(1),\n\trequest: zodSchema,\n\tfilters: z.array(z.function()),\n\tpasses: z.function()\n});\nconst cronSourceSchema = z.object({\n\tkind: z.literal(\"cron\"),\n\t...baseSourceShape,\n\tschedule: cronScheduleSchema\n});\nconst pollSourceSchema = z.object({\n\tkind: z.literal(\"poll\"),\n\t...baseSourceShape,\n\tid: z.string().optional(),\n\tschedule: cronScheduleSchema,\n\trun: z.function(),\n\tfilters: z.array(z.function()),\n\tpasses: z.function()\n});\n/** Runtime validation for a trigger source (webhook | cron | poll). */\nconst triggerSourceSchema = z.discriminatedUnion(\"kind\", [\n\twebhookSourceSchema,\n\tcronSourceSchema,\n\tpollSourceSchema\n]);\n/** Runtime validation for an unbranded trigger attachment. */\nconst triggerAttachmentCoreSchema = z.object({\n\tkey: z.string().trim().min(1),\n\tsource: triggerSourceSchema,\n\tworkflow: workflowSchema,\n\ttransform: z.function().optional()\n});\nconst TRIGGER_ATTACHMENT = Symbol.for(\"keystroke.triggerAttachment\");\n/**\n* Validates brand + shape via `triggerAttachmentCoreSchema` so server discovery\n* rejects unbranded or malformed attachments (including those whose nested\n* workflow is not the result of `defineWorkflow`).\n*/\nfunction isTriggerAttachment(value) {\n\tif (typeof value !== \"object\" || value === null) return false;\n\tif (!(TRIGGER_ATTACHMENT in value) || value[TRIGGER_ATTACHMENT] !== true) return false;\n\treturn triggerAttachmentCoreSchema.safeParse(value).success;\n}\n//#endregion\n//#region src/define-trigger-attachment.ts\n/**\n* Internal helper used by source `.attach()` factories. Validates the\n* attachment shape against `triggerAttachmentCoreSchema` and applies the\n* `TRIGGER_ATTACHMENT` brand.\n*/\nfunction defineTriggerAttachment(input) {\n\tconst result = triggerAttachmentCoreSchema.safeParse(input);\n\tif (!result.success) throw new Error(`Invalid trigger attachment: ${formatIssues(result.error.issues)}`);\n\treturn {\n\t\t...input,\n\t\t[TRIGGER_ATTACHMENT]: true\n\t};\n}\nfunction formatIssues(issues) {\n\treturn issues.map((issue) => {\n\t\treturn `${issue.path.length > 0 ? `${issue.path.join(\".\")}: ` : \"\"}${issue.message}`;\n\t}).join(\"; \");\n}\n//#endregion\n//#region src/sources/webhook-source.ts\n/**\n* Defines a webhook trigger source — fires its attached workflow when a request\n* hits `path`, satisfies the `request` schema, and passes any `.filter(...)`.\n*\n* @param options.key - Stable trigger key; the attachment id is `{key}:{workflowKey}`.\n* @param options.path - Route the webhook is mounted at (e.g. `\"incoming-message\"`).\n* @param options.request - Zod schema the incoming payload must satisfy; also types `filter`/`transform`.\n* @param options.filter - Source-level predicate over the parsed payload.\n* @example\n* defineWebhookSource({ key: \"msg\", path: \"msg\", request: z.object({ text: z.string() }) })\n* .attach({ workflow });\n*/\nfunction defineWebhookSource(options) {\n\tconst triggerKey = options.key.trim();\n\tif (!triggerKey) throw new Error(\"defineWebhookSource requires a non-empty key\");\n\tconst filters = [];\n\tif (options.filter) filters.push(options.filter);\n\tconst source = {\n\t\tkind: \"webhook\",\n\t\tkey: triggerKey,\n\t\tpath: options.path,\n\t\trequest: options.request,\n\t\tfilters,\n\t\tpasses(payload) {\n\t\t\tconst parsed = options.request.safeParse(payload);\n\t\t\tif (!parsed.success) return false;\n\t\t\treturn source.filters.every((candidate) => candidate(parsed.data));\n\t\t},\n\t\tattach(attachOptions) {\n\t\t\treturn defineTriggerAttachment({\n\t\t\t\tkey: attachmentKeyFrom(triggerKey, workflowKeyFromDefinition(attachOptions.workflow)),\n\t\t\t\tsource,\n\t\t\t\tworkflow: attachOptions.workflow,\n\t\t\t\ttransform: attachOptions.transform\n\t\t\t});\n\t\t}\n\t};\n\tconst chain = source;\n\tchain.filter = (fn) => {\n\t\tsource.filters.push(fn);\n\t\treturn chain;\n\t};\n\treturn chain;\n}\n//#endregion\n//#region src/sources/cron-source.ts\n/**\n* Defines a cron trigger source — fires its attached workflow on a schedule.\n*\n* @param options.key - Stable trigger key; the attachment id is `{key}:{workflowKey}`.\n* @param options.schedule - A cron expression. Pass a 5-field literal (e.g.\n* `\"0 9 * * *\"`) for compile-time shape checking, or wrap with\n* `parseCronSchedule(...)` for 6-field, named (`MON`), or `@daily`-style\n* schedules. Validated at runtime; throws if the expression is invalid.\n* @example\n* defineCronSource({ key: \"morning\", schedule: \"0 9 * * *\" }).attach({ workflow });\n*/\nfunction defineCronSource(options) {\n\tconst triggerKey = options.key.trim();\n\tif (!triggerKey) throw new Error(\"defineCronSource requires a non-empty key\");\n\tconst source = {\n\t\tkind: \"cron\",\n\t\tkey: triggerKey,\n\t\tschedule: parseCronSchedule(options.schedule),\n\t\tattach(attachOptions) {\n\t\t\treturn defineTriggerAttachment({\n\t\t\t\tkey: attachmentKeyFrom(triggerKey, workflowKeyFromDefinition(attachOptions.workflow)),\n\t\t\t\tsource,\n\t\t\t\tworkflow: attachOptions.workflow\n\t\t\t});\n\t\t}\n\t};\n\treturn source;\n}\n//#endregion\n//#region src/sources/poll-source.ts\n/**\n* Defines a poll trigger source — runs `run` on a schedule and, when the result\n* passes any `.filter(...)`, fires the attached workflow with it.\n*\n* @param options.key - Stable trigger key; the attachment id is `{key}:{workflowKey}`.\n* @param options.id - Optional group id; poll sources sharing an id poll together.\n* @param options.schedule - Cron expression for the poll cadence (see `defineCronSource`).\n* @param options.run - Produces the payload checked by `filter` and passed to the workflow.\n* @param options.filter - Source-level predicate; the workflow only fires when it returns true.\n* @example\n* definePollSource({ key: \"inbox\", schedule: \"0 * * * *\", run: fetchInbox })\n* .filter((r) => r.length > 0)\n* .attach({ workflow });\n*/\nfunction definePollSource(options) {\n\tconst triggerKey = options.key.trim();\n\tif (!triggerKey) throw new Error(\"definePollSource requires a non-empty key\");\n\tconst schedule = parseCronSchedule(options.schedule);\n\tconst filters = [];\n\tif (options.filter) filters.push(options.filter);\n\tconst source = {\n\t\tkind: \"poll\",\n\t\tkey: triggerKey,\n\t\tid: options.id,\n\t\tschedule,\n\t\trun: options.run,\n\t\tfilters,\n\t\tpasses(payload) {\n\t\t\treturn source.filters.every((candidate) => candidate(payload));\n\t\t},\n\t\tattach(attachOptions) {\n\t\t\treturn defineTriggerAttachment({\n\t\t\t\tkey: attachmentKeyFrom(triggerKey, workflowKeyFromDefinition(attachOptions.workflow)),\n\t\t\t\tsource,\n\t\t\t\tworkflow: attachOptions.workflow,\n\t\t\t\ttransform: attachOptions.transform\n\t\t\t});\n\t\t}\n\t};\n\tconst chain = source;\n\tchain.filter = (fn) => {\n\t\tsource.filters.push(fn);\n\t\treturn chain;\n\t};\n\treturn chain;\n}\n//#endregion\n//#region src/resolve-attachment-input.ts\n/**\n* Applies the source-level filter (`passes`) and the attachment-level\n* `transform` to a raw payload. Returns `undefined` when the source rejects\n* the payload so callers can skip running the workflow.\n*/\nfunction resolveAttachmentInput(attachment, payload) {\n\tconst source = attachment.source;\n\tif ((source.kind === \"webhook\" || source.kind === \"poll\") && !source.passes(payload)) return;\n\treturn attachment.transform ? attachment.transform(payload) : payload;\n}\n//#endregion\nexport { TRIGGER_ATTACHMENT, cronScheduleSchema, defineCronSource, definePollSource, defineWebhookSource, isTriggerAttachment, nextTriggerRunAt, parseCronSchedule, parseTriggerSchedule, resolveAttachmentInput, resolveCronSchedule };\n\n//# sourceMappingURL=index.mjs.map"],"x_google_ignoreList":[0,1,2],"mappings":";;;;AA6BA,SAAgB,oBAAoB,MAAM;CACtC,OAAO;EACH,QAAQ,KAAK,WAAW;EACxB,QAAQ,KAAK,WAAW;EACxB,MAAM,KAAK,SAAS;EACpB,KAAK,KAAK,QAAQ;EAClB,OAAO,KAAK,SAAS;EACrB,SAAS,KAAK,OAAO;EACrB,MAAM,KAAK,YAAY;CAC3B;AACJ;AAEA,SAAgB,eAAe,MAAM,OAAO;CACxC,OAAO,IAAI,KAAK,MAAM,QAAQ,GAAG,CAAC,EAAE,QAAQ;AAChD;AAEA,SAAgB,uBAAuB,UAAU,UAAU;CACvD,IAAI,YAAY,UACZ,OAAO,WAAW;CAEtB,OAAO,IAAI,WAAW,WAAW;AACrC;;;ACjDA,IAAa,OAAb,MAAkB;CACd,YAAY,EAAE,SAAS,SAAS,OAAO,MAAM,QAAQ,YAAa;EAE9D,IAAI,CAAC,WAAW,QAAQ,SAAS,GAC7B,MAAM,IAAI,MAAM,4CAA4C;EAChE,IAAI,CAAC,WAAW,QAAQ,SAAS,GAC7B,MAAM,IAAI,MAAM,4CAA4C;EAChE,IAAI,CAAC,SAAS,MAAM,SAAS,GACzB,MAAM,IAAI,MAAM,0CAA0C;EAC9D,IAAI,CAAC,UAAU,OAAO,SAAS,GAC3B,MAAM,IAAI,MAAM,2CAA2C;EAC/D,KAAK,CAAC,YAAY,SAAS,SAAS,OAAO,CAAC,QAAQ,KAAK,SAAS,IAC9D,MAAM,IAAI,MAAM,oDAAoD;EAExE,KAAK,UAAU,MAAM,KAAK,OAAO,EAAE,MAAM,GAAG,MAAM,IAAI,CAAC;EACvD,KAAK,UAAU,MAAM,KAAK,OAAO,EAAE,MAAM,GAAG,MAAM,IAAI,CAAC;EACvD,KAAK,QAAQ,MAAM,KAAK,KAAK,EAAE,MAAM,GA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AAC,YAAY,MAAM,IAAI,MAAM,2CAA2C;CAC5E,MAAM,WAAW,kBAAkB,QAAQ,QAAQ;CACnD,MAAM,UAAU,CAAC;CACjB,IAAI,QAAQ,QAAQ,QAAQ,KAAK,QAAQ,MAAM;CAC/C,MAAM,SAAS;EACd,MAAM;EACN,KAAK;EACL,IAAI,QAAQ;EACZ;EACA,KAAK,QAAQ;EACb;EACA,OAAO,SAAS;GACf,OAAO,OAAO,QAAQ,OAAO,cAAc,UAAU,OAAO,CAAC;EAC9D;EACA,OAAO,eAAe;GACrB,OAAO,wBAAwB;IAC9B,KAAK,kBAAkB,YAAY,0BAA0B,cAAc,QAAQ,CAAC;IACpF;IACA,UAAU,cAAc;IACxB,WAAW,cAAc;GAC1B,CAAC;EACF;CACD;CACA,MAAM,QAAQ;CACd,MAAM,UAAU,OAAO;EACtB,OAAO,QAAQ,KAAK,EAAE;EACtB,OAAO;CACR;CACA,OAAO;AACR;;;;;;AAQA,SAAS,uBAAuB,YAAY,SAAS;CACpD,MAAM,SAAS,WAAW;CAC1B,KAAK,OAAO,SAAS,aAAa,OAAO,SAAS,WAAW,CAAC,OAAO,OAAO,OAAO,GAAG;CACtF,OAAO,WAAW,YAAY,WAAW,UAAU,OAAO,IAAI;AAC/D"}
1
+ {"version":3,"file":"trigger.cjs","names":["z","isWorkflow"],"sources":["../../../node_modules/.pnpm/cron-schedule@6.0.0/node_modules/cron-schedule/dist/utils.js","../../../node_modules/.pnpm/cron-schedule@6.0.0/node_modules/cron-schedule/dist/cron.js","../../../node_modules/.pnpm/cron-schedule@6.0.0/node_modules/cron-schedule/dist/cron-parser.js","../../trigger/dist/index.mjs"],"sourcesContent":["export const TIMEOUT_MAX = 2147483647; // 2^31-1\n/**\n * Creates a new timeout, which can exceed the max timeout limit of 2^31-1.\n * Since multiple timeouts are used internally, the timeoutId used to clear the timeout\n * is returned as a handle (object) and changes whenever the max timeout limit is exceeded.\n * The handle parameter can be ignored, it is used internally for updating the timeoutId\n * in the handle after creating the next timeout.\n */\nexport function longTimeout(fn, timeout, previousHandle) {\n let nextTimeout = timeout;\n let remainingTimeout = 0;\n if (nextTimeout > TIMEOUT_MAX) {\n remainingTimeout = nextTimeout - TIMEOUT_MAX;\n nextTimeout = TIMEOUT_MAX;\n }\n const handle = previousHandle !== null && previousHandle !== void 0 ? previousHandle : {\n timeoutId: undefined,\n };\n handle.timeoutId = setTimeout(() => {\n if (remainingTimeout > 0) {\n longTimeout(fn, remainingTimeout, previousHandle);\n }\n else {\n fn();\n }\n }, nextTimeout);\n return handle;\n}\n/* Extracts second, minute, hour, date, month and the weekday from a date. */\nexport function extractDateElements(date) {\n return {\n second: date.getSeconds(),\n minute: date.getMinutes(),\n hour: date.getHours(),\n day: date.getDate(),\n month: date.getMonth(),\n weekday: date.getDay(),\n year: date.getFullYear(),\n };\n}\n/* Gets the amount of days in the given month (indexed by 0) of the given year. */\nexport function getDaysInMonth(year, month) {\n return new Date(year, month + 1, 0).getDate();\n}\n/* Gets the amount of days from weekday1 to weekday2. */\nexport function getDaysBetweenWeekdays(weekday1, weekday2) {\n if (weekday1 <= weekday2) {\n return weekday2 - weekday1;\n }\n return 6 - weekday1 + weekday2 + 1;\n}\nexport function wrapFunction(fn, errorHandler) {\n return () => {\n try {\n const res = fn();\n if (res instanceof Promise) {\n res.catch((err) => {\n if (errorHandler) {\n errorHandler(err);\n }\n });\n }\n }\n catch (err) {\n if (errorHandler) {\n errorHandler(err);\n }\n }\n };\n}\n//# sourceMappingURL=utils.js.map","import { extractDateElements, getDaysBetweenWeekdays, getDaysInMonth, } from './utils.js';\nexport class Cron {\n constructor({ seconds, minutes, hours, days, months, weekdays, }) {\n // Validate that there are values provided.\n if (!seconds || seconds.size === 0)\n throw new Error('There must be at least one allowed second.');\n if (!minutes || minutes.size === 0)\n throw new Error('There must be at least one allowed minute.');\n if (!hours || hours.size === 0)\n throw new Error('There must be at least one allowed hour.');\n if (!months || months.size === 0)\n throw new Error('There must be at least one allowed month.');\n if ((!weekdays || weekdays.size === 0) && (!days || days.size === 0))\n throw new Error('There must be at least one allowed day or weekday.');\n // Convert set to array and sort in ascending order.\n this.seconds = Array.from(seconds).sort((a, b) => a - b);\n this.minutes = Array.from(minutes).sort((a, b) => a - b);\n this.hours = Array.from(hours).sort((a, b) => a - b);\n this.days = Array.from(days).sort((a, b) => a - b);\n this.months = Array.from(months).sort((a, b) => a - b);\n this.weekdays = Array.from(weekdays).sort((a, b) => a - b);\n // Validate that all values are integers within the constraint.\n const validateData = (name, data, constraint) => {\n if (data.some((x) => typeof x !== 'number' ||\n x % 1 !== 0 ||\n x < constraint.min ||\n x > constraint.max)) {\n throw new Error(`${name} must only consist of integers which are within the range of ${constraint.min} and ${constraint.max}`);\n }\n };\n validateData('seconds', this.seconds, { min: 0, max: 59 });\n validateData('minutes', this.minutes, { min: 0, max: 59 });\n validateData('hours', this.hours, { min: 0, max: 23 });\n validateData('days', this.days, { min: 1, max: 31 });\n validateData('months', this.months, { min: 0, max: 11 });\n validateData('weekdays', this.weekdays, { min: 0, max: 6 });\n // For each element, store a reversed copy in the reversed attribute for finding prev dates.\n this.reversed = {\n seconds: this.seconds.map((x) => x).reverse(),\n minutes: this.minutes.map((x) => x).reverse(),\n hours: this.hours.map((x) => x).reverse(),\n days: this.days.map((x) => x).reverse(),\n months: this.months.map((x) => x).reverse(),\n weekdays: this.weekdays.map((x) => x).reverse(),\n };\n }\n /**\n * Find the next or previous hour, starting from the given start hour that matches the hour constraint.\n * startHour itself might also be allowed.\n */\n findAllowedHour(dir, startHour) {\n return dir === 'next'\n ? this.hours.find((x) => x >= startHour)\n : this.reversed.hours.find((x) => x <= startHour);\n }\n /**\n * Find the next or previous minute, starting from the given start minute that matches the minute constraint.\n * startMinute itself might also be allowed.\n */\n findAllowedMinute(dir, startMinute) {\n return dir === 'next'\n ? this.minutes.find((x) => x >= startMinute)\n : this.reversed.minutes.find((x) => x <= startMinute);\n }\n /**\n * Find the next or previous second, starting from the given start second that matches the second constraint.\n * startSecond itself IS NOT allowed.\n */\n findAllowedSecond(dir, startSecond) {\n return dir === 'next'\n ? this.seconds.find((x) => x > startSecond)\n : this.reversed.seconds.find((x) => x < startSecond);\n }\n /**\n * Find the next or previous time, starting from the given start time that matches the hour, minute\n * and second constraints. startTime itself might also be allowed.\n */\n findAllowedTime(dir, startTime) {\n // Try to find an allowed hour.\n let hour = this.findAllowedHour(dir, startTime.hour);\n if (hour !== undefined) {\n if (hour === startTime.hour) {\n // We found an hour that is the start hour. Try to find an allowed minute.\n let minute = this.findAllowedMinute(dir, startTime.minute);\n if (minute !== undefined) {\n if (minute === startTime.minute) {\n // We found a minute that is the start minute. Try to find an allowed second.\n const second = this.findAllowedSecond(dir, startTime.second);\n if (second !== undefined) {\n // We found a second within the start hour and minute.\n return { hour, minute, second };\n }\n // We did not find a valid second within the start minute. Try to find another minute.\n minute = this.findAllowedMinute(dir, dir === 'next' ? startTime.minute + 1 : startTime.minute - 1);\n if (minute !== undefined) {\n // We found a minute which is not the start minute. Return that minute together with the hour and the first / last allowed second.\n return {\n hour,\n minute,\n second: dir === 'next' ? this.seconds[0] : this.reversed.seconds[0],\n };\n }\n }\n else {\n // We found a minute which is not the start minute. Return that minute together with the hour and the first / last allowed second.\n return {\n hour,\n minute,\n second: dir === 'next' ? this.seconds[0] : this.reversed.seconds[0],\n };\n }\n }\n // We did not find an allowed minute / second combination inside the start hour. Try to find the next / previous allowed hour.\n hour = this.findAllowedHour(dir, dir === 'next' ? startTime.hour + 1 : startTime.hour - 1);\n if (hour !== undefined) {\n // We found an allowed hour which is not the start hour. Return that hour together with the first / last allowed minutes / seconds.\n return {\n hour,\n minute: dir === 'next' ? this.minutes[0] : this.reversed.minutes[0],\n second: dir === 'next' ? this.seconds[0] : this.reversed.seconds[0],\n };\n }\n }\n else {\n // We found an allowed hour which is not the start hour. Return that hour together with the first / last allowed minutes / seconds.\n return {\n hour,\n minute: dir === 'next' ? this.minutes[0] : this.reversed.minutes[0],\n second: dir === 'next' ? this.seconds[0] : this.reversed.seconds[0],\n };\n }\n }\n // No allowed time found.\n return undefined;\n }\n /**\n * Find the next or previous day in the given month, starting from the given startDay\n * that matches either the day or the weekday constraint. startDay itself might also be allowed.\n */\n findAllowedDayInMonth(dir, year, month, startDay) {\n var _a, _b;\n if (startDay < 1)\n throw new Error('startDay must not be smaller than 1.');\n // If only days are restricted: allow day based on day constraint only.\n // If only weekdays are restricted: allow day based on weekday constraint only.\n // If both are restricted: allow day based on both day and weekday constraint. pick day that is closer to startDay.\n // If none are restricted: return the day closest to startDay (respecting dir) that is allowed (or startDay itself).\n const daysInMonth = getDaysInMonth(year, month);\n const daysRestricted = this.days.length !== 31;\n const weekdaysRestricted = this.weekdays.length !== 7;\n if (!daysRestricted && !weekdaysRestricted) {\n if (startDay > daysInMonth) {\n return dir === 'next' ? undefined : daysInMonth;\n }\n return startDay;\n }\n // Try to find a day based on the days constraint.\n let allowedDayByDays;\n if (daysRestricted) {\n allowedDayByDays =\n dir === 'next'\n ? this.days.find((x) => x >= startDay)\n : this.reversed.days.find((x) => x <= startDay);\n // Make sure the day does not exceed the amount of days in month.\n if (allowedDayByDays !== undefined && allowedDayByDays > daysInMonth) {\n allowedDayByDays = undefined;\n }\n }\n // Try to find a day based on the weekday constraint.\n let allowedDayByWeekdays;\n if (weekdaysRestricted) {\n const startWeekday = new Date(year, month, startDay).getDay();\n const nearestAllowedWeekday = dir === 'next'\n ? ((_a = this.weekdays.find((x) => x >= startWeekday)) !== null && _a !== void 0 ? _a : this.weekdays[0])\n : ((_b = this.reversed.weekdays.find((x) => x <= startWeekday)) !== null && _b !== void 0 ? _b : this.reversed.weekdays[0]);\n if (nearestAllowedWeekday !== undefined) {\n const daysBetweenWeekdays = dir === 'next'\n ? getDaysBetweenWeekdays(startWeekday, nearestAllowedWeekday)\n : getDaysBetweenWeekdays(nearestAllowedWeekday, startWeekday);\n allowedDayByWeekdays =\n dir === 'next'\n ? startDay + daysBetweenWeekdays\n : startDay - daysBetweenWeekdays;\n // Make sure the day does not exceed the month boundaries.\n if (allowedDayByWeekdays > daysInMonth || allowedDayByWeekdays < 1) {\n allowedDayByWeekdays = undefined;\n }\n }\n }\n if (allowedDayByDays !== undefined && allowedDayByWeekdays !== undefined) {\n // If a day is found both via the days and the weekdays constraint, pick the day\n // that is closer to start date.\n return dir === 'next'\n ? Math.min(allowedDayByDays, allowedDayByWeekdays)\n : Math.max(allowedDayByDays, allowedDayByWeekdays);\n }\n if (allowedDayByDays !== undefined) {\n return allowedDayByDays;\n }\n if (allowedDayByWeekdays !== undefined) {\n return allowedDayByWeekdays;\n }\n return undefined;\n }\n /** Gets the next date starting from the given start date or now. */\n getNextDate(startDate = new Date()) {\n const startDateElements = extractDateElements(startDate);\n let minYear = startDateElements.year;\n let startIndexMonth = this.months.findIndex((x) => x >= startDateElements.month);\n if (startIndexMonth === -1) {\n startIndexMonth = 0;\n minYear++;\n }\n // We try every month within the next 5 years to make sure that we tried to\n // find a matching date insidde a whole leap year.\n const maxIterations = this.months.length * 5;\n for (let i = 0; i < maxIterations; i++) {\n // Get the next year and month.\n const year = minYear + Math.floor((startIndexMonth + i) / this.months.length);\n const month = this.months[(startIndexMonth + i) % this.months.length];\n const isStartMonth = year === startDateElements.year && month === startDateElements.month;\n // Find the next day.\n let day = this.findAllowedDayInMonth('next', year, month, isStartMonth ? startDateElements.day : 1);\n let isStartDay = isStartMonth && day === startDateElements.day;\n // If we found a day and it is the start day, try to find a valid time beginning from the start date time.\n if (day !== undefined && isStartDay) {\n const nextTime = this.findAllowedTime('next', startDateElements);\n if (nextTime !== undefined) {\n return new Date(year, month, day, nextTime.hour, nextTime.minute, nextTime.second);\n }\n // If no valid time has been found for the start date, try the next day.\n day = this.findAllowedDayInMonth('next', year, month, day + 1);\n isStartDay = false;\n }\n // If we found a next day and it is not the start day, just use the next day with the first allowed values\n // for hours, minutes and seconds.\n if (day !== undefined && !isStartDay) {\n return new Date(year, month, day, this.hours[0], this.minutes[0], this.seconds[0]);\n }\n // No allowed day has been found for this month. Continue to search in next month.\n }\n throw new Error('No valid next date was found.');\n }\n /** Gets the specified amount of future dates starting from the given start date or now. */\n getNextDates(amount, startDate) {\n const dates = [];\n let nextDate;\n for (let i = 0; i < amount; i++) {\n nextDate = this.getNextDate(nextDate !== null && nextDate !== void 0 ? nextDate : startDate);\n dates.push(nextDate);\n }\n return dates;\n }\n /**\n * Get an ES6 compatible iterator which iterates over the next dates starting from startDate or now.\n * The iterator runs until the optional endDate is reached or forever.\n */\n *getNextDatesIterator(startDate, endDate) {\n let nextDate;\n while (true) {\n nextDate = this.getNextDate(nextDate !== null && nextDate !== void 0 ? nextDate : startDate);\n if (endDate && endDate.getTime() < nextDate.getTime()) {\n return;\n }\n yield nextDate;\n }\n }\n /** Gets the previous date starting from the given start date or now. */\n getPrevDate(startDate = new Date()) {\n const startDateElements = extractDateElements(startDate);\n let maxYear = startDateElements.year;\n let startIndexMonth = this.reversed.months.findIndex((x) => x <= startDateElements.month);\n if (startIndexMonth === -1) {\n startIndexMonth = 0;\n maxYear--;\n }\n // We try every month within the past 5 years to make sure that we tried to\n // find a matching date inside a whole leap year.\n const maxIterations = this.reversed.months.length * 5;\n for (let i = 0; i < maxIterations; i++) {\n // Get the next year and month.\n const year = maxYear -\n Math.floor((startIndexMonth + i) / this.reversed.months.length);\n const month = this.reversed.months[(startIndexMonth + i) % this.reversed.months.length];\n const isStartMonth = year === startDateElements.year && month === startDateElements.month;\n // Find the previous day.\n let day = this.findAllowedDayInMonth('prev', year, month, isStartMonth\n ? startDateElements.day\n : // Start searching from the last day of the month.\n getDaysInMonth(year, month));\n let isStartDay = isStartMonth && day === startDateElements.day;\n // If we found a day and it is the start day, try to find a valid time beginning from the start date time.\n if (day !== undefined && isStartDay) {\n const prevTime = this.findAllowedTime('prev', startDateElements);\n if (prevTime !== undefined) {\n return new Date(year, month, day, prevTime.hour, prevTime.minute, prevTime.second);\n }\n // If no valid time has been found for the start date, try the previous day.\n if (day > 1) {\n day = this.findAllowedDayInMonth('prev', year, month, day - 1);\n isStartDay = false;\n }\n }\n // If we found a previous day and it is not the start day, just use the previous day with the first allowed values\n // for hours, minutes and seconds (which will be the latest time due to using the reversed array).\n if (day !== undefined && !isStartDay) {\n return new Date(year, month, day, this.reversed.hours[0], this.reversed.minutes[0], this.reversed.seconds[0]);\n }\n // No allowed day has been found for this month. Continue to search in previous month.\n }\n throw new Error('No valid previous date was found.');\n }\n /** Gets the specified amount of previous dates starting from the given start date or now. */\n getPrevDates(amount, startDate) {\n const dates = [];\n let prevDate;\n for (let i = 0; i < amount; i++) {\n prevDate = this.getPrevDate(prevDate !== null && prevDate !== void 0 ? prevDate : startDate);\n dates.push(prevDate);\n }\n return dates;\n }\n /**\n * Get an ES6 compatible iterator which iterates over the previous dates starting from startDate or now.\n * The iterator runs until the optional endDate is reached or forever.\n */\n *getPrevDatesIterator(startDate, endDate) {\n let prevDate;\n while (true) {\n prevDate = this.getPrevDate(prevDate !== null && prevDate !== void 0 ? prevDate : startDate);\n if (endDate && endDate.getTime() > prevDate.getTime()) {\n return;\n }\n yield prevDate;\n }\n }\n /** Returns true when there is a cron date at the given date. */\n matchDate(date) {\n const { second, minute, hour, day, month, weekday } = extractDateElements(date);\n if (this.seconds.indexOf(second) === -1 ||\n this.minutes.indexOf(minute) === -1 ||\n this.hours.indexOf(hour) === -1 ||\n this.months.indexOf(month) === -1) {\n return false;\n }\n if (this.days.length !== 31 && this.weekdays.length !== 7) {\n return (this.days.indexOf(day) !== -1 || this.weekdays.indexOf(weekday) !== -1);\n }\n return (this.days.indexOf(day) !== -1 && this.weekdays.indexOf(weekday) !== -1);\n }\n}\n//# sourceMappingURL=cron.js.map","import { Cron } from './cron.js';\nconst secondConstraint = {\n min: 0,\n max: 59,\n};\nconst minuteConstraint = {\n min: 0,\n max: 59,\n};\nconst hourConstraint = {\n min: 0,\n max: 23,\n};\nconst dayConstraint = {\n min: 1,\n max: 31,\n};\nconst monthConstraint = {\n min: 1,\n max: 12,\n aliases: {\n jan: '1',\n feb: '2',\n mar: '3',\n apr: '4',\n may: '5',\n jun: '6',\n jul: '7',\n aug: '8',\n sep: '9',\n oct: '10',\n nov: '11',\n dec: '12',\n },\n};\nconst weekdayConstraint = {\n min: 0,\n max: 7,\n aliases: {\n mon: '1',\n tue: '2',\n wed: '3',\n thu: '4',\n fri: '5',\n sat: '6',\n sun: '7',\n },\n};\nconst timeNicknames = {\n '@yearly': '0 0 1 1 *',\n '@annually': '0 0 1 1 *',\n '@monthly': '0 0 1 * *',\n '@weekly': '0 0 * * 0',\n '@daily': '0 0 * * *',\n '@hourly': '0 * * * *',\n '@minutely': '* * * * *',\n};\nfunction parseElement(element, constraint) {\n const result = new Set();\n // If returned set of numbers is empty, the scheduler class interpretes the emtpy set of numbers as all valid values of the constraint\n if (element === '*') {\n for (let i = constraint.min; i <= constraint.max; i = i + 1) {\n result.add(i);\n }\n return result;\n }\n // If the element is a list, parse each element in the list.\n const listElements = element.split(',');\n if (listElements.length > 1) {\n for (const listElement of listElements) {\n const parsedListElement = parseElement(listElement, constraint);\n for (const x of parsedListElement) {\n result.add(x);\n }\n }\n return result;\n }\n // Helper function to parse a single element, which includes checking for alias, valid number and constraint min and max.\n const parseSingleElement = (singleElement) => {\n var _a, _b;\n singleElement =\n (_b = (_a = constraint.aliases) === null || _a === void 0 ? void 0 : _a[singleElement.toLowerCase()]) !== null && _b !== void 0 ? _b : singleElement;\n const parsedElement = Number.parseInt(singleElement, 10);\n if (Number.isNaN(parsedElement)) {\n throw new Error(`Failed to parse ${element}: ${singleElement} is NaN.`);\n }\n if (parsedElement < constraint.min || parsedElement > constraint.max) {\n throw new Error(`Failed to parse ${element}: ${singleElement} is outside of constraint range of ${constraint.min} - ${constraint.max}.`);\n }\n return parsedElement;\n };\n // Detect if the element is a range.\n // Possible range formats: 'start-end', 'start-end/step', '*', '*/step'.\n // Where start and end can be numbers or aliases.\n // Capture groups: 1: start-end, 2: start, 3: end, 4: /step, 5: step.\n const rangeSegments = /^(([0-9a-zA-Z]+)-([0-9a-zA-Z]+)|\\*)(\\/([0-9]+))?$/.exec(element);\n // If not, it must be a single element.\n if (rangeSegments === null) {\n result.add(parseSingleElement(element));\n return result;\n }\n // If it is a range, get start and end of the range.\n let parsedStart = rangeSegments[1] === '*'\n ? constraint.min\n : parseSingleElement(rangeSegments[2]);\n const parsedEnd = rangeSegments[1] === '*'\n ? constraint.max\n : parseSingleElement(rangeSegments[3]);\n // need to catch Sunday, which gets parsed here as 7, but is also legitimate at the start of a range as 0, to avoid the out of order error\n if (constraint === weekdayConstraint &&\n parsedStart === 7 &&\n // this check ensures that sun-sun is not incorrectly parsed as [0,1,2,3,4,5,6]\n parsedEnd !== 7) {\n parsedStart = 0;\n }\n if (parsedStart > parsedEnd) {\n throw new Error(`Failed to parse ${element}: Invalid range (start: ${parsedStart}, end: ${parsedEnd}).`);\n }\n // Check whether there is a custom step defined for the range, defaulting to 1.\n const step = rangeSegments[5];\n let parsedStep = 1;\n if (step !== undefined) {\n parsedStep = Number.parseInt(step, 10);\n if (Number.isNaN(parsedStep)) {\n throw new Error(`Failed to parse step: ${step} is NaN.`);\n }\n if (parsedStep < 1) {\n throw new Error(`Failed to parse step: Expected ${step} to be greater than 0.`);\n }\n }\n // Go from start to end of the range by the given steps.\n for (let i = parsedStart; i <= parsedEnd; i = i + parsedStep) {\n result.add(i);\n }\n return result;\n}\n/** Parses a cron expression into a Cron instance. */\nexport function parseCronExpression(cronExpression) {\n var _a;\n if (typeof cronExpression !== 'string') {\n throw new TypeError('Invalid cron expression: must be of type string.');\n }\n // Convert time nicknames.\n cronExpression = (_a = timeNicknames[cronExpression.toLowerCase()]) !== null && _a !== void 0 ? _a : cronExpression;\n // Split the cron expression into its elements, removing empty elements (extra whitespaces).\n const elements = cronExpression.split(' ').filter((elem) => elem.length > 0);\n if (elements.length < 5 || elements.length > 6) {\n throw new Error('Invalid cron expression: expected 5 or 6 elements.');\n }\n const rawSeconds = elements.length === 6 ? elements[0] : '0';\n const rawMinutes = elements.length === 6 ? elements[1] : elements[0];\n const rawHours = elements.length === 6 ? elements[2] : elements[1];\n const rawDays = elements.length === 6 ? elements[3] : elements[2];\n const rawMonths = elements.length === 6 ? elements[4] : elements[3];\n const rawWeekdays = elements.length === 6 ? elements[5] : elements[4];\n return new Cron({\n seconds: parseElement(rawSeconds, secondConstraint),\n minutes: parseElement(rawMinutes, minuteConstraint),\n hours: parseElement(rawHours, hourConstraint),\n days: parseElement(rawDays, dayConstraint),\n // months in cron are indexed by 1, but Cron expects indexes by 0, so we need to reduce all set values by one.\n months: new Set(Array.from(parseElement(rawMonths, monthConstraint)).map((x) => x - 1)),\n weekdays: new Set(Array.from(parseElement(rawWeekdays, weekdayConstraint)).map((x) => x % 7)),\n });\n}\n//# sourceMappingURL=cron-parser.js.map","import { parseCronExpression } from \"cron-schedule\";\nimport { z } from \"zod\";\nimport { isWorkflow } from \"@keystrokehq/workflow\";\n//#region src/cron/cron-schedule.ts\n/**\n* Validates and brands a cron expression. Accepts anything the `cron-schedule`\n* engine accepts (5/6 fields, named months/weekdays, `@daily`-style nicknames)\n* so authoring validation never rejects a schedule the scheduler can run. The\n* `.brand()` makes `CronSchedule` nominally distinct from a plain `string`, so\n* a raw string can't be passed where a validated schedule is expected.\n*/\nconst cronScheduleSchema = z.string().trim().min(1, \"cron schedule must be a non-empty string\").refine(isParseableCron, \"must be a valid cron expression\").brand();\n/** Parse/validate an arbitrary value into a branded `CronSchedule` (throws on failure). */\nfunction parseCronSchedule(value) {\n\treturn cronScheduleSchema.parse(value);\n}\n/**\n* Resolves the effective schedule for an attachment, applying overrides by\n* precedence: per-attachment override → global override → the authored\n* schedule. Pure string precedence — no cron parsing.\n*/\nfunction resolveCronSchedule(attachmentId, schedule, options) {\n\treturn options.attachmentScheduleOverrides?.[attachmentId] ?? options.cronScheduleOverride ?? schedule;\n}\n/** Parse a schedule into a `cron-schedule` `Cron` instance (throws on invalid input). */\nfunction parseTriggerSchedule(schedule) {\n\treturn toCron(schedule);\n}\n/** The next time the schedule fires at or after `from`. */\nfunction nextTriggerRunAt(schedule, from = /* @__PURE__ */ new Date()) {\n\treturn toCron(schedule).getNextDate(from);\n}\n/**\n* Single touchpoint for the `cron-schedule` library — every parse, validation,\n* and next-run calculation in this package goes through here.\n*/\nfunction toCron(schedule) {\n\treturn parseCronExpression(schedule);\n}\nfunction isParseableCron(value) {\n\ttry {\n\t\ttoCron(value);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n//#endregion\n//#region src/attachment-key.ts\nfunction workflowKeyFromDefinition(workflow) {\n\tconst key = workflow.key?.trim();\n\tif (!key) throw new Error(\"Workflow definition requires a non-empty key\");\n\treturn key;\n}\nfunction attachmentKeyFrom(triggerKey, workflowKey) {\n\treturn `${triggerKey}:${workflowKey}`;\n}\n//#endregion\n//#region src/attachment-definition.ts\nconst zodSchema = z.custom((v) => v instanceof z.ZodType, \"must be a Zod schema\");\nconst workflowSchema = z.custom((v) => isWorkflow(v), \"must be defineWorkflow(...)\");\nconst baseSourceShape = {\n\tkey: z.string().trim().min(1),\n\tattach: z.function()\n};\nconst webhookSourceSchema = z.object({\n\tkind: z.literal(\"webhook\"),\n\t...baseSourceShape,\n\tendpoint: z.string().min(1),\n\trequest: zodSchema,\n\tfilters: z.array(z.function()),\n\tpasses: z.function()\n});\nconst cronSourceSchema = z.object({\n\tkind: z.literal(\"cron\"),\n\t...baseSourceShape,\n\tschedule: cronScheduleSchema\n});\nconst pollSourceSchema = z.object({\n\tkind: z.literal(\"poll\"),\n\t...baseSourceShape,\n\tid: z.string().optional(),\n\tschedule: cronScheduleSchema,\n\trun: z.function(),\n\tfilters: z.array(z.function()),\n\tpasses: z.function()\n});\n/** Runtime validation for a trigger source (webhook | cron | poll). */\nconst triggerSourceSchema = z.discriminatedUnion(\"kind\", [\n\twebhookSourceSchema,\n\tcronSourceSchema,\n\tpollSourceSchema\n]);\n/** Runtime validation for an unbranded trigger attachment. */\nconst triggerAttachmentCoreSchema = z.object({\n\tkey: z.string().trim().min(1),\n\tsource: triggerSourceSchema,\n\tworkflow: workflowSchema,\n\ttransform: z.function().optional()\n});\nconst TRIGGER_ATTACHMENT = Symbol.for(\"keystroke.triggerAttachment\");\n/**\n* Validates brand + shape via `triggerAttachmentCoreSchema` so server discovery\n* rejects unbranded or malformed attachments (including those whose nested\n* workflow is not the result of `defineWorkflow`).\n*/\nfunction isTriggerAttachment(value) {\n\tif (typeof value !== \"object\" || value === null) return false;\n\tif (!(TRIGGER_ATTACHMENT in value) || value[TRIGGER_ATTACHMENT] !== true) return false;\n\treturn triggerAttachmentCoreSchema.safeParse(value).success;\n}\n//#endregion\n//#region src/define-trigger-attachment.ts\n/**\n* Internal helper used by source `.attach()` factories. Validates the\n* attachment shape against `triggerAttachmentCoreSchema` and applies the\n* `TRIGGER_ATTACHMENT` brand.\n*/\nfunction defineTriggerAttachment(input) {\n\tconst result = triggerAttachmentCoreSchema.safeParse(input);\n\tif (!result.success) throw new Error(`Invalid trigger attachment: ${formatIssues(result.error.issues)}`);\n\treturn {\n\t\t...input,\n\t\t[TRIGGER_ATTACHMENT]: true\n\t};\n}\nfunction formatIssues(issues) {\n\treturn issues.map((issue) => {\n\t\treturn `${issue.path.length > 0 ? `${issue.path.join(\".\")}: ` : \"\"}${issue.message}`;\n\t}).join(\"; \");\n}\n//#endregion\n//#region src/sources/webhook-source.ts\nfunction normalizeWebhookEndpoint(endpoint) {\n\treturn endpoint.replace(/^\\/+|\\/+$/g, \"\").replace(/^triggers\\/?/, \"\");\n}\n/**\n* Defines a webhook trigger source — fires its attached workflow when a request\n* hits `/triggers/{endpoint}`, satisfies the `request` schema, and passes any `.filter(...)`.\n*\n* @param options.key - Stable trigger key; attachment id is `{key}:{workflowKey}`.\n* @param options.endpoint - Shared route suffix under `/triggers/` (e.g. `\"stripe\"`).\n*/\nfunction defineWebhookSource(options) {\n\tconst triggerKey = options.key.trim();\n\tif (!triggerKey) throw new Error(\"defineWebhookSource requires a non-empty key\");\n\tconst endpoint = normalizeWebhookEndpoint(options.endpoint);\n\tif (!endpoint) throw new Error(\"defineWebhookSource requires a non-empty endpoint\");\n\tconst filters = [];\n\tif (options.filter) filters.push(options.filter);\n\tconst source = {\n\t\tkind: \"webhook\",\n\t\tkey: triggerKey,\n\t\tendpoint,\n\t\trequest: options.request,\n\t\tfilters,\n\t\tpasses(payload) {\n\t\t\tconst parsed = options.request.safeParse(payload);\n\t\t\tif (!parsed.success) return false;\n\t\t\treturn source.filters.every((candidate) => candidate(parsed.data));\n\t\t},\n\t\tattach(attachOptions) {\n\t\t\treturn defineTriggerAttachment({\n\t\t\t\tkey: attachmentKeyFrom(triggerKey, workflowKeyFromDefinition(attachOptions.workflow)),\n\t\t\t\tsource,\n\t\t\t\tworkflow: attachOptions.workflow,\n\t\t\t\ttransform: attachOptions.transform\n\t\t\t});\n\t\t}\n\t};\n\tconst chain = source;\n\tchain.filter = (fn) => {\n\t\tsource.filters.push(fn);\n\t\treturn chain;\n\t};\n\treturn chain;\n}\n//#endregion\n//#region src/sources/cron-source.ts\n/**\n* Defines a cron trigger source — fires its attached workflow on a schedule.\n*\n* @param options.key - Stable trigger key; the attachment id is `{key}:{workflowKey}`.\n* @param options.schedule - A cron expression. Pass a 5-field literal (e.g.\n* `\"0 9 * * *\"`) for compile-time shape checking, or wrap with\n* `parseCronSchedule(...)` for 6-field, named (`MON`), or `@daily`-style\n* schedules. Validated at runtime; throws if the expression is invalid.\n* @example\n* defineCronSource({ key: \"morning\", schedule: \"0 9 * * *\" }).attach({ workflow });\n*/\nfunction defineCronSource(options) {\n\tconst triggerKey = options.key.trim();\n\tif (!triggerKey) throw new Error(\"defineCronSource requires a non-empty key\");\n\tconst source = {\n\t\tkind: \"cron\",\n\t\tkey: triggerKey,\n\t\tschedule: parseCronSchedule(options.schedule),\n\t\tattach(attachOptions) {\n\t\t\treturn defineTriggerAttachment({\n\t\t\t\tkey: attachmentKeyFrom(triggerKey, workflowKeyFromDefinition(attachOptions.workflow)),\n\t\t\t\tsource,\n\t\t\t\tworkflow: attachOptions.workflow\n\t\t\t});\n\t\t}\n\t};\n\treturn source;\n}\n//#endregion\n//#region src/sources/poll-source.ts\n/**\n* Defines a poll trigger source — runs `run` on a schedule and, when the result\n* passes any `.filter(...)`, fires the attached workflow with it.\n*\n* @param options.key - Stable trigger key; the attachment id is `{key}:{workflowKey}`.\n* @param options.id - Optional group id; poll sources sharing an id poll together.\n* @param options.schedule - Cron expression for the poll cadence (see `defineCronSource`).\n* @param options.run - Produces the payload checked by `filter` and passed to the workflow.\n* @param options.filter - Source-level predicate; the workflow only fires when it returns true.\n* @example\n* definePollSource({ key: \"inbox\", schedule: \"0 * * * *\", run: fetchInbox })\n* .filter((r) => r.length > 0)\n* .attach({ workflow });\n*/\nfunction definePollSource(options) {\n\tconst triggerKey = options.key.trim();\n\tif (!triggerKey) throw new Error(\"definePollSource requires a non-empty key\");\n\tconst schedule = parseCronSchedule(options.schedule);\n\tconst filters = [];\n\tif (options.filter) filters.push(options.filter);\n\tconst source = {\n\t\tkind: \"poll\",\n\t\tkey: triggerKey,\n\t\tid: options.id,\n\t\tschedule,\n\t\trun: options.run,\n\t\tfilters,\n\t\tpasses(payload) {\n\t\t\treturn source.filters.every((candidate) => candidate(payload));\n\t\t},\n\t\tattach(attachOptions) {\n\t\t\treturn defineTriggerAttachment({\n\t\t\t\tkey: attachmentKeyFrom(triggerKey, workflowKeyFromDefinition(attachOptions.workflow)),\n\t\t\t\tsource,\n\t\t\t\tworkflow: attachOptions.workflow,\n\t\t\t\ttransform: attachOptions.transform\n\t\t\t});\n\t\t}\n\t};\n\tconst chain = source;\n\tchain.filter = (fn) => {\n\t\tsource.filters.push(fn);\n\t\treturn chain;\n\t};\n\treturn chain;\n}\n//#endregion\n//#region src/resolve-attachment-input.ts\n/**\n* Applies the source-level filter (`passes`) and the attachment-level\n* `transform` to a raw payload. Returns `undefined` when the source rejects\n* the payload so callers can skip running the workflow.\n*/\nfunction resolveAttachmentInput(attachment, payload) {\n\tconst source = attachment.source;\n\tif ((source.kind === \"webhook\" || source.kind === \"poll\") && !source.passes(payload)) return;\n\treturn attachment.transform ? attachment.transform(payload) : payload;\n}\n//#endregion\nexport { TRIGGER_ATTACHMENT, cronScheduleSchema, defineCronSource, definePollSource, defineWebhookSource, isTriggerAttachment, nextTriggerRunAt, normalizeWebhookEndpoint, parseCronSchedule, parseTriggerSchedule, resolveAttachmentInput, resolveCronSchedule };\n\n//# sourceMappingURL=index.mjs.map"],"x_google_ignoreList":[0,1,2],"mappings":";;;;AA6BA,SAAgB,oBAAoB,MAAM;CACtC,OAAO;EACH,QAAQ,KAAK,WAAW;EACxB,QAAQ,KAAK,WAAW;EACxB,MAAM,KAAK,SAAS;EACpB,KAAK,KAAK,QAAQ;EAClB,OAAO,KAAK,SAAS;EACrB,SAAS,KAAK,OAAO;EACrB,MAAM,KAAK,YAAY;CAC3B;AACJ;AAEA,SAAgB,eAAe,MAAM,OAAO;CACxC,OAAO,IAAI,KAAK,MAAM,QAAQ,GAAG,CAAC,EAAE,QAAQ;AAChD;AAEA,SAAgB,uBAAuB,UAAU,UAAU;CACvD,IAAI,YAAY,UACZ,OAAO,WAAW;CAEtB,OAAO,IAAI,WAAW,WAAW;AACrC;;;ACjDA,IAAa,OAAb,MAAkB;CACd,YAAY,EAAE,SAAS,SAAS,OAAO,MAAM,QAAQ,YAAa;EAE9D,IAAI,CAAC,WAAW,QAAQ,SAAS,GAC7B,MAAM,IAAI,MAAM,4CAA4C;EAChE,IAAI,CAAC,WAAW,QAAQ,SAAS,GAC7B,MAAM,IAAI,MAAM,4CAA4C;EAChE,IAAI,CAAC,SAAS,MAAM,SAAS,GACzB,MAAM,IAAI,MAAM,0CAA0C;EAC9D,IAAI,CAAC,UAAU,OAAO,SAAS,GAC3B,MAAM,IAAI,MAAM,2CAA2C;EAC/D,KAAK,CAAC,YAAY,SAAS,SAAS,OAAO,CAAC,QAAQ,KAAK,SAAS,IAC9D,MAAM,IAAI,MAAM,oDAAoD;EAExE,KAAK,UAAU,MAAM,K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AAI,MAAM,2CAA2C;CAC5E,MAAM,SAAS;EACd,MAAM;EACN,KAAK;EACL,UAAU,kBAAkB,QAAQ,QAAQ;EAC5C,OAAO,eAAe;GACrB,OAAO,wBAAwB;IAC9B,KAAK,kBAAkB,YAAY,0BAA0B,cAAc,QAAQ,CAAC;IACpF;IACA,UAAU,cAAc;GACzB,CAAC;EACF;CACD;CACA,OAAO;AACR;;;;;;;;;;;;;;;AAiBA,SAAS,iBAAiB,SAAS;CAClC,MAAM,aAAa,QAAQ,IAAI,KAAK;CACpC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,2CAA2C;CAC5E,MAAM,WAAW,kBAAkB,QAAQ,QAAQ;CACnD,MAAM,UAAU,CAAC;CACjB,IAAI,QAAQ,QAAQ,QAAQ,KAAK,QAAQ,MAAM;CAC/C,MAAM,SAAS;EACd,MAAM;EACN,KAAK;EACL,IAAI,QAAQ;EACZ;EACA,KAAK,QAAQ;EACb;EACA,OAAO,SAAS;GACf,OAAO,OAAO,QAAQ,OAAO,cAAc,UAAU,OAAO,CAAC;EAC9D;EACA,OAAO,eAAe;GACrB,OAAO,wBAAwB;IAC9B,KAAK,kBAAkB,YAAY,0BAA0B,cAAc,QAAQ,CAAC;IACpF;IACA,UAAU,cAAc;IACxB,WAAW,cAAc;GAC1B,CAAC;EACF;CACD;CACA,MAAM,QAAQ;CACd,MAAM,UAAU,OAAO;EACtB,OAAO,QAAQ,KAAK,EAAE;EACtB,OAAO;CACR;CACA,OAAO;AACR;;;;;;AAQA,SAAS,uBAAuB,YAAY,SAAS;CACpD,MAAM,SAAS,WAAW;CAC1B,KAAK,OAAO,SAAS,aAAa,OAAO,SAAS,WAAW,CAAC,OAAO,OAAO,OAAO,GAAG;CACtF,OAAO,WAAW,YAAY,WAAW,UAAU,OAAO,IAAI;AAC/D"}
@@ -219,10 +219,11 @@ type TriggerAttachment = {
219
219
  */
220
220
  declare function isTriggerAttachment(value: unknown): value is TriggerAttachment; //#endregion
221
221
  //#region src/sources/webhook-source.d.ts
222
+ declare function normalizeWebhookEndpoint(endpoint: string): string;
222
223
  type WebhookSource<TSchema extends z.ZodType = z.ZodType> = {
223
224
  kind: "webhook";
224
225
  key: string;
225
- path: string;
226
+ endpoint: string;
226
227
  request: TSchema;
227
228
  filters: Array<(payload: z.infer<TSchema>) => boolean>;
228
229
  passes: (payload: unknown) => boolean;
@@ -236,19 +237,14 @@ type WebhookSourceChain<TSchema extends z.ZodType> = WebhookSource<TSchema> & {
236
237
  };
237
238
  /**
238
239
  * Defines a webhook trigger source — fires its attached workflow when a request
239
- * hits `path`, satisfies the `request` schema, and passes any `.filter(...)`.
240
+ * hits `/triggers/{endpoint}`, satisfies the `request` schema, and passes any `.filter(...)`.
240
241
  *
241
- * @param options.key - Stable trigger key; the attachment id is `{key}:{workflowKey}`.
242
- * @param options.path - Route the webhook is mounted at (e.g. `"incoming-message"`).
243
- * @param options.request - Zod schema the incoming payload must satisfy; also types `filter`/`transform`.
244
- * @param options.filter - Source-level predicate over the parsed payload.
245
- * @example
246
- * defineWebhookSource({ key: "msg", path: "msg", request: z.object({ text: z.string() }) })
247
- * .attach({ workflow });
242
+ * @param options.key - Stable trigger key; attachment id is `{key}:{workflowKey}`.
243
+ * @param options.endpoint - Shared route suffix under `/triggers/` (e.g. `"stripe"`).
248
244
  */
249
245
  declare function defineWebhookSource<TSchema extends z.ZodType>(options: {
250
246
  key: string;
251
- path: string;
247
+ endpoint: string;
252
248
  request: TSchema;
253
249
  filter?: (payload: z.infer<TSchema>) => boolean;
254
250
  }): WebhookSourceChain<TSchema>; //#endregion
@@ -275,5 +271,5 @@ type PollSkipResponse = {
275
271
  skipped: true;
276
272
  }; //#endregion
277
273
  //#endregion
278
- export { type CronExpression, type CronSchedule, type CronScheduleInput, type CronSource, type PollSkipResponse, type PollSource, type RunContext, TRIGGER_ATTACHMENT, type TriggerAttachment, type TriggerSource, type WebhookSkipResponse, type WebhookSource, cronScheduleSchema, defineCronSource, definePollSource, defineWebhookSource, isTriggerAttachment, nextTriggerRunAt, parseCronSchedule, parseTriggerSchedule, resolveAttachmentInput, resolveCronSchedule };
274
+ export { type CronExpression, type CronSchedule, type CronScheduleInput, type CronSource, type PollSkipResponse, type PollSource, type RunContext, TRIGGER_ATTACHMENT, type TriggerAttachment, type TriggerSource, type WebhookSkipResponse, type WebhookSource, type WebhookSourceChain, cronScheduleSchema, defineCronSource, definePollSource, defineWebhookSource, isTriggerAttachment, nextTriggerRunAt, normalizeWebhookEndpoint, parseCronSchedule, parseTriggerSchedule, resolveAttachmentInput, resolveCronSchedule };
279
275
  //# sourceMappingURL=trigger.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"trigger.d.cts","names":["ICronDefinition","Set","seconds","minutes","hours","days","months","weekdays","Cron","ReadonlyArray","Date","Generator","reversed","constructor","findAllowedHour","findAllowedMinute","findAllowedSecond","findAllowedTime","findAllowedDayInMonth","getNextDate","startDate","getNextDates","amount","getNextDatesIterator","endDate","getPrevDate","getPrevDates","getPrevDatesIterator","matchDate","date","Cron","z","WorkflowDefinition","CredentialRunContext","CronField","CronExpression","cronScheduleSchema","ZodString","core","$ZodBranded","CronSchedule","infer","CronScheduleInput","parseCronSchedule","value","resolveCronSchedule","Record","attachmentId","schedule","cronScheduleOverride","attachmentScheduleOverrides","options","parseTriggerSchedule","nextTriggerRunAt","Date","from","CronSource","TInput","TOutput","TriggerAttachment","kind","key","attach","workflow","defineCronSource","PollSource","TResult","Promise","Array","id","run","filters","payload","passes","transform","PollSourceChain","filter","fn","definePollSource","TRIGGER_ATTACHMENT","TriggerSource","WebhookSource","source","isTriggerAttachment","TSchema","ZodType","path","request","WebhookSourceChain","defineWebhookSource","resolveAttachmentInput","attachment","RunContext","trigger","triggeredAt","credentials","WebhookSkipResponse","ok","skipped","PollSkipResponse"],"sources":["../../../node_modules/.pnpm/cron-schedule@6.0.0/node_modules/cron-schedule/dist/cron.d.ts","../../trigger/dist/index.d.mts"],"x_google_ignoreList":[0],"mappings":";;;;;;;;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+ {"version":3,"file":"trigger.d.cts","names":["ICronDefinition","Set","seconds","minutes","hours","days","months","weekdays","Cron","ReadonlyArray","Date","Generator","reversed","constructor","findAllowedHour","findAllowedMinute","findAllowedSecond","findAllowedTime","findAllowedDayInMonth","getNextDate","startDate","getNextDates","amount","getNextDatesIterator","endDate","getPrevDate","getPrevDates","getPrevDatesIterator","matchDate","date","Cron","z","WorkflowDefinition","CredentialRunContext","CronField","CronExpression","cronScheduleSchema","ZodString","core","$ZodBranded","CronSchedule","infer","CronScheduleInput","parseCronSchedule","value","resolveCronSchedule","Record","attachmentId","schedule","cronScheduleOverride","attachmentScheduleOverrides","options","parseTriggerSchedule","nextTriggerRunAt","Date","from","CronSource","TInput","TOutput","TriggerAttachment","kind","key","attach","workflow","defineCronSource","PollSource","TResult","Promise","Array","id","run","filters","payload","passes","transform","PollSourceChain","filter","fn","definePollSource","TRIGGER_ATTACHMENT","TriggerSource","WebhookSource","source","isTriggerAttachment","normalizeWebhookEndpoint","endpoint","TSchema","ZodType","request","WebhookSourceChain","defineWebhookSource","resolveAttachmentInput","attachment","RunContext","trigger","triggeredAt","credentials","WebhookSkipResponse","ok","skipped","PollSkipResponse"],"sources":["../../../node_modules/.pnpm/cron-schedule@6.0.0/node_modules/cron-schedule/dist/cron.d.ts","../../trigger/dist/index.d.mts"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;UAIiBA,eAAAA;EAAAA,SACJE,OAAAA,EAASD,GAAAA;EAAAA,SACTE,OAAAA,EAASF,GAAAA;EAAAA,SACTG,KAAAA,EAAOH,GAAAA;EAAAA,SACPI,IAAAA,EAAMJ,GAAAA;EAAAA,SACNK,MAAAA,EAAQL,GAAAA;EAAAA,SACRM,QAAAA,EAAUN,GAAAA;AAAAA;AAAAA,cAEFO,IAAAA;EAAAA,SACRN,OAAAA,EAASO,aAAAA;EAAAA,SACTN,OAAAA,EAASM,aAAAA;EAAAA,SACTL,KAAAA,EAAOK,aAAAA;EAAAA,SACPJ,IAAAA,EAA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CAAAA,CAAEU,KAAAA,CAAM6C,OAAAA;EAAAA,IAC5B3B,iBAAAA;AAAAA;AAAAA,KAED8B,kBAAAA,iBAAmC1D,CAAAA,CAAEwD,OAAAA,IAAWN,aAAAA,CAAcK,OAAAA;EACjEV,MAAAA,GAASC,EAAAA,GAAKL,OAAAA,EAASzC,CAAAA,CAAEU,KAAAA,CAAM6C,OAAAA,kBAAyBG,kBAAAA,CAAmBH,OAAAA;AAAAA;;;AA9I/D;AAAA;;;;iBAuJGI,mBAAAA,iBAAoC3D,CAAAA,CAAEwD,OAAAA,CAAAA,CAASpC,OAAAA;EAC9DU,GAAAA;EACAwB,QAAAA;EACAG,OAAAA,EAASF,OAAAA;EACTV,MAAAA,IAAUJ,OAAAA,EAASzC,CAAAA,CAAEU,KAAAA,CAAM6C,OAAAA;AAAAA,IACzBG,kBAAAA,CAAmBH,OAAAA;AAAAA;;;;;AAlJ+D;iBA0JrEK,sBAAAA,CAAuBC,UAAAA,EAAYjC,iBAAiB,EAAEa,OAAAA;AAAAA;AAAAA,KAGlEqB,UAAAA;EACHC,OAAAA;EACAtB,OAAAA;EACAuB,WAAAA,EAAazC,IAAAA;EACb0C,WAAAA,GAAc/D,oBAAoB;AAAA;AAAA,KAE/BgE,mBAAAA;EACHC,EAAAA;EACAC,OAAO;AAAA;AAAA,KAEJC,gBAAAA;EACHF,EAAAA;EACAC,OAAO;AAAA"}
@@ -219,10 +219,11 @@ type TriggerAttachment = {
219
219
  */
220
220
  declare function isTriggerAttachment(value: unknown): value is TriggerAttachment; //#endregion
221
221
  //#region src/sources/webhook-source.d.ts
222
+ declare function normalizeWebhookEndpoint(endpoint: string): string;
222
223
  type WebhookSource<TSchema extends z.ZodType = z.ZodType> = {
223
224
  kind: "webhook";
224
225
  key: string;
225
- path: string;
226
+ endpoint: string;
226
227
  request: TSchema;
227
228
  filters: Array<(payload: z.infer<TSchema>) => boolean>;
228
229
  passes: (payload: unknown) => boolean;
@@ -236,19 +237,14 @@ type WebhookSourceChain<TSchema extends z.ZodType> = WebhookSource<TSchema> & {
236
237
  };
237
238
  /**
238
239
  * Defines a webhook trigger source — fires its attached workflow when a request
239
- * hits `path`, satisfies the `request` schema, and passes any `.filter(...)`.
240
+ * hits `/triggers/{endpoint}`, satisfies the `request` schema, and passes any `.filter(...)`.
240
241
  *
241
- * @param options.key - Stable trigger key; the attachment id is `{key}:{workflowKey}`.
242
- * @param options.path - Route the webhook is mounted at (e.g. `"incoming-message"`).
243
- * @param options.request - Zod schema the incoming payload must satisfy; also types `filter`/`transform`.
244
- * @param options.filter - Source-level predicate over the parsed payload.
245
- * @example
246
- * defineWebhookSource({ key: "msg", path: "msg", request: z.object({ text: z.string() }) })
247
- * .attach({ workflow });
242
+ * @param options.key - Stable trigger key; attachment id is `{key}:{workflowKey}`.
243
+ * @param options.endpoint - Shared route suffix under `/triggers/` (e.g. `"stripe"`).
248
244
  */
249
245
  declare function defineWebhookSource<TSchema extends z.ZodType>(options: {
250
246
  key: string;
251
- path: string;
247
+ endpoint: string;
252
248
  request: TSchema;
253
249
  filter?: (payload: z.infer<TSchema>) => boolean;
254
250
  }): WebhookSourceChain<TSchema>; //#endregion
@@ -275,5 +271,5 @@ type PollSkipResponse = {
275
271
  skipped: true;
276
272
  }; //#endregion
277
273
  //#endregion
278
- export { type CronExpression, type CronSchedule, type CronScheduleInput, type CronSource, type PollSkipResponse, type PollSource, type RunContext, TRIGGER_ATTACHMENT, type TriggerAttachment, type TriggerSource, type WebhookSkipResponse, type WebhookSource, cronScheduleSchema, defineCronSource, definePollSource, defineWebhookSource, isTriggerAttachment, nextTriggerRunAt, parseCronSchedule, parseTriggerSchedule, resolveAttachmentInput, resolveCronSchedule };
274
+ export { type CronExpression, type CronSchedule, type CronScheduleInput, type CronSource, type PollSkipResponse, type PollSource, type RunContext, TRIGGER_ATTACHMENT, type TriggerAttachment, type TriggerSource, type WebhookSkipResponse, type WebhookSource, type WebhookSourceChain, cronScheduleSchema, defineCronSource, definePollSource, defineWebhookSource, isTriggerAttachment, nextTriggerRunAt, normalizeWebhookEndpoint, parseCronSchedule, parseTriggerSchedule, resolveAttachmentInput, resolveCronSchedule };
279
275
  //# sourceMappingURL=trigger.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"trigger.d.mts","names":["ICronDefinition","Set","seconds","minutes","hours","days","months","weekdays","Cron","ReadonlyArray","Date","Generator","reversed","constructor","findAllowedHour","findAllowedMinute","findAllowedSecond","findAllowedTime","findAllowedDayInMonth","getNextDate","startDate","getNextDates","amount","getNextDatesIterator","endDate","getPrevDate","getPrevDates","getPrevDatesIterator","matchDate","date","Cron","z","WorkflowDefinition","CredentialRunContext","CronField","CronExpression","cronScheduleSchema","ZodString","core","$ZodBranded","CronSchedule","infer","CronScheduleInput","parseCronSchedule","value","resolveCronSchedule","Record","attachmentId","schedule","cronScheduleOverride","attachmentScheduleOverrides","options","parseTriggerSchedule","nextTriggerRunAt","Date","from","CronSource","TInput","TOutput","TriggerAttachment","kind","key","attach","workflow","defineCronSource","PollSource","TResult","Promise","Array","id","run","filters","payload","passes","transform","PollSourceChain","filter","fn","definePollSource","TRIGGER_ATTACHMENT","TriggerSource","WebhookSource","source","isTriggerAttachment","TSchema","ZodType","path","request","WebhookSourceChain","defineWebhookSource","resolveAttachmentInput","attachment","RunContext","trigger","triggeredAt","credentials","WebhookSkipResponse","ok","skipped","PollSkipResponse"],"sources":["../../../node_modules/.pnpm/cron-schedule@6.0.0/node_modules/cron-schedule/dist/cron.d.ts","../../trigger/dist/index.d.mts"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;UAIiBA,eAAAA;EAAAA,SACJE,OAAAA,EAASD,GAAAA;EAAAA,SACTE,OAAAA,EAASF,GAAAA;EAAAA,SACTG,KAAAA,EAAOH,GAAAA;EAAAA,SACPI,IAAAA,EAAMJ,GAAAA;EAAAA,SACNK,MAAAA,EAAQL,GAAAA;EAAAA,SACRM,QAAAA,EAAUN,GAAAA;AAAAA;AAAAA,cAEFO,IAAAA;EAAA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AAU/B,kBAAAA,CAAmByB,MAAAA,EAAQC,OAAAA;IACrCgB,SAAAA,IAAaF,OAAAA,EAASzC,CAAAA,CAAEU,KAAAA,CAAM2C,OAAAA;EAAAA,IAC5BzB,iBAAAA;AAAAA;AAAAA,KAED6B,kBAAAA,iBAAmCzD,CAAAA,CAAEsD,OAAAA,IAAWJ,aAAAA,CAAcG,OAAAA;EACjER,MAAAA,GAASC,EAAAA,GAAKL,OAAAA,EAASzC,CAAAA,CAAEU,KAAAA,CAAM2C,OAAAA,kBAAyBI,kBAAAA,CAAmBJ,OAAAA;AAAAA;;;;AA7I/D;AAAA;;;;;;;;iBA2JGK,mBAAAA,iBAAoC1D,CAAAA,CAAEsD,OAAAA,CAAAA,CAASlC,OAAAA;EAC9DU,GAAAA;EACAyB,IAAAA;EACAC,OAAAA,EAASH,OAAAA;EACTR,MAAAA,IAAUJ,OAAAA,EAASzC,CAAAA,CAAEU,KAAAA,CAAM2C,OAAAA;AAAAA,IACzBI,kBAAAA,CAAmBJ,OAAAA;AAAAA;AAtJ+D;AAAA;;;;AAAA,iBA8JrEM,sBAAAA,CAAuBC,UAAAA,EAAYhC,iBAAiB,EAAEa,OAAAA;AAAAA;AAAAA,KAGlEoB,UAAAA;EACHC,OAAAA;EACArB,OAAAA;EACAsB,WAAAA,EAAaxC,IAAAA;EACbyC,WAAAA,GAAc9D,oBAAoB;AAAA;AAAA,KAE/B+D,mBAAAA;EACHC,EAAAA;EACAC,OAAO;AAAA;AAAA,KAEJC,gBAAAA;EACHF,EAAAA;EACAC,OAAO;AAAA"}
1
+ {"version":3,"file":"trigger.d.mts","names":["ICronDefinition","Set","seconds","minutes","hours","days","months","weekdays","Cron","ReadonlyArray","Date","Generator","reversed","constructor","findAllowedHour","findAllowedMinute","findAllowedSecond","findAllowedTime","findAllowedDayInMonth","getNextDate","startDate","getNextDates","amount","getNextDatesIterator","endDate","getPrevDate","getPrevDates","getPrevDatesIterator","matchDate","date","Cron","z","WorkflowDefinition","CredentialRunContext","CronField","CronExpression","cronScheduleSchema","ZodString","core","$ZodBranded","CronSchedule","infer","CronScheduleInput","parseCronSchedule","value","resolveCronSchedule","Record","attachmentId","schedule","cronScheduleOverride","attachmentScheduleOverrides","options","parseTriggerSchedule","nextTriggerRunAt","Date","from","CronSource","TInput","TOutput","TriggerAttachment","kind","key","attach","workflow","defineCronSource","PollSource","TResult","Promise","Array","id","run","filters","payload","passes","transform","PollSourceChain","filter","fn","definePollSource","TRIGGER_ATTACHMENT","TriggerSource","WebhookSource","source","isTriggerAttachment","normalizeWebhookEndpoint","endpoint","TSchema","ZodType","request","WebhookSourceChain","defineWebhookSource","resolveAttachmentInput","attachment","RunContext","trigger","triggeredAt","credentials","WebhookSkipResponse","ok","skipped","PollSkipResponse"],"sources":["../../../node_modules/.pnpm/cron-schedule@6.0.0/node_modules/cron-schedule/dist/cron.d.ts","../../trigger/dist/index.d.mts"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;UAIiBA,eAAAA;EAAAA,SACJE,OAAAA,EAASD,GAAAA;EAAAA,SACTE,OAAAA,EAASF,GAAAA;EAAAA,SACTG,KAAAA,EAAOH,GAAAA;EAAAA,SACPI,IAAAA,EAAMJ,GAAAA;EAAAA,SACNK,MAAAA,EAAQL,GAAAA;EAAAA,SACRM,QAAAA,EAAUN,GAAAA;AAAAA;AAAAA,cAEFO,IAAAA;EAAAA,SACRN,OAAAA,EAASO,aAAAA;EAAAA,SACTN,OAAAA,EAASM,aAAAA;EAAAA,SACTL,KAAAA,EAAOK,aAAAA;EAAAA,SACPJ,IAAAA,EAAMI,aAAAA;EAAAA,SACNH,MAAAA,EAAQG,aAAAA;EAAAA,SACRF,QAAAA,EAAUE,aAAAA;EAAAA,SACVG,QAAAA;IACLV,OAAAA,EAASO,aAAAA;IACTN,OAAAA,EAASM,aAAAA;IACTL,KAAAA,EAAOK,aAAAA;IACPJ,IAAAA,EAAMI,aAAAA;IACNH,MAAAA,EAAQG,aAAAA;IACRF,QAAAA,EAAUE,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,CAAmBH,OAAAA;AAAAA;;;AA9I/D;AAAA;;;;iBAuJGI,mBAAAA,iBAAoC3D,CAAAA,CAAEwD,OAAAA,CAAAA,CAASpC,OAAAA;EAC9DU,GAAAA;EACAwB,QAAAA;EACAG,OAAAA,EAASF,OAAAA;EACTV,MAAAA,IAAUJ,OAAAA,EAASzC,CAAAA,CAAEU,KAAAA,CAAM6C,OAAAA;AAAAA,IACzBG,kBAAAA,CAAmBH,OAAAA;AAAAA;;;;;AAlJ+D;iBA0JrEK,sBAAAA,CAAuBC,UAAAA,EAAYjC,iBAAiB,EAAEa,OAAAA;AAAAA;AAAAA,KAGlEqB,UAAAA;EACHC,OAAAA;EACAtB,OAAAA;EACAuB,WAAAA,EAAazC,IAAAA;EACb0C,WAAAA,GAAc/D,oBAAoB;AAAA;AAAA,KAE/BgE,mBAAAA;EACHC,EAAAA;EACAC,OAAO;AAAA;AAAA,KAEJC,gBAAAA;EACHF,EAAAA;EACAC,OAAO;AAAA"}
package/dist/trigger.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { i as isWorkflow } from "./dist-SRdmqD5M.mjs";
1
+ import { i as isWorkflow } from "./dist-D8tPcFYP.mjs";
2
2
  import { z } from "zod";
3
3
  //#region ../../node_modules/.pnpm/cron-schedule@6.0.0/node_modules/cron-schedule/dist/utils.js
4
4
  function extractDateElements(date) {
@@ -451,7 +451,7 @@ const baseSourceShape = {
451
451
  const webhookSourceSchema = z.object({
452
452
  kind: z.literal("webhook"),
453
453
  ...baseSourceShape,
454
- path: z.string().min(1),
454
+ endpoint: z.string().min(1),
455
455
  request: zodSchema,
456
456
  filters: z.array(z.function()),
457
457
  passes: z.function()
@@ -512,27 +512,27 @@ function formatIssues(issues) {
512
512
  return `${issue.path.length > 0 ? `${issue.path.join(".")}: ` : ""}${issue.message}`;
513
513
  }).join("; ");
514
514
  }
515
+ function normalizeWebhookEndpoint(endpoint) {
516
+ return endpoint.replace(/^\/+|\/+$/g, "").replace(/^triggers\/?/, "");
517
+ }
515
518
  /**
516
519
  * Defines a webhook trigger source — fires its attached workflow when a request
517
- * hits `path`, satisfies the `request` schema, and passes any `.filter(...)`.
520
+ * hits `/triggers/{endpoint}`, satisfies the `request` schema, and passes any `.filter(...)`.
518
521
  *
519
- * @param options.key - Stable trigger key; the attachment id is `{key}:{workflowKey}`.
520
- * @param options.path - Route the webhook is mounted at (e.g. `"incoming-message"`).
521
- * @param options.request - Zod schema the incoming payload must satisfy; also types `filter`/`transform`.
522
- * @param options.filter - Source-level predicate over the parsed payload.
523
- * @example
524
- * defineWebhookSource({ key: "msg", path: "msg", request: z.object({ text: z.string() }) })
525
- * .attach({ workflow });
522
+ * @param options.key - Stable trigger key; attachment id is `{key}:{workflowKey}`.
523
+ * @param options.endpoint - Shared route suffix under `/triggers/` (e.g. `"stripe"`).
526
524
  */
527
525
  function defineWebhookSource(options) {
528
526
  const triggerKey = options.key.trim();
529
527
  if (!triggerKey) throw new Error("defineWebhookSource requires a non-empty key");
528
+ const endpoint = normalizeWebhookEndpoint(options.endpoint);
529
+ if (!endpoint) throw new Error("defineWebhookSource requires a non-empty endpoint");
530
530
  const filters = [];
531
531
  if (options.filter) filters.push(options.filter);
532
532
  const source = {
533
533
  kind: "webhook",
534
534
  key: triggerKey,
535
- path: options.path,
535
+ endpoint,
536
536
  request: options.request,
537
537
  filters,
538
538
  passes(payload) {
@@ -641,6 +641,6 @@ function resolveAttachmentInput(attachment, payload) {
641
641
  return attachment.transform ? attachment.transform(payload) : payload;
642
642
  }
643
643
  //#endregion
644
- export { TRIGGER_ATTACHMENT, cronScheduleSchema, defineCronSource, definePollSource, defineWebhookSource, isTriggerAttachment, nextTriggerRunAt, parseCronSchedule, parseTriggerSchedule, resolveAttachmentInput, resolveCronSchedule };
644
+ export { TRIGGER_ATTACHMENT, cronScheduleSchema, defineCronSource, definePollSource, defineWebhookSource, isTriggerAttachment, nextTriggerRunAt, normalizeWebhookEndpoint, parseCronSchedule, parseTriggerSchedule, resolveAttachmentInput, resolveCronSchedule };
645
645
 
646
646
  //# sourceMappingURL=trigger.mjs.map