@teammy/server 0.2.20 → 0.2.21

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 (94) hide show
  1. package/dist/main.js +4030 -3035
  2. package/dist/web/assets/{Assistant-By7rPMl2.js → Assistant-3mdmSDTD.js} +1 -1
  3. package/dist/web/assets/Computers-6l6HpFis.js +13 -0
  4. package/dist/web/assets/{Conversation-BjRCD81A.js → Conversation-C5pZE7z5.js} +1 -1
  5. package/dist/web/assets/{Dashboard-DmtWx-WI.js → Dashboard-yaqwUqGh.js} +1 -1
  6. package/dist/web/assets/{Files-4IxSFpqk.js → Files-1vHzvDD3.js} +1 -1
  7. package/dist/web/assets/{Help-BeJ09zt7.js → Help-6fa7XqA5.js} +61 -22
  8. package/dist/web/assets/Markdown-nuwEQZ64.js +29 -0
  9. package/dist/web/assets/{ResourceLibrary-rlrdDWGo.js → ResourceLibrary-Cs01blNf.js} +1 -1
  10. package/dist/web/assets/{TerminalPane-CEaXud0k.js → TerminalPane-B0w1stXs.js} +1 -1
  11. package/dist/web/assets/{WorkspaceTree-CwGvdfr0.js → WorkspaceTree-DmSApj8i.js} +1 -1
  12. package/dist/web/assets/{index-Cr9kdjwc.js → index-Rry2cw7w.js} +2 -2
  13. package/dist/web/assets/{task-links-B7fExlHK.js → task-links-BJwIQ3SE.js} +1 -1
  14. package/dist/web/downloads/teammy-inbox-skill.zip +0 -0
  15. package/dist/web/downloads/teammy-skill.zip +0 -0
  16. package/dist/web/index.html +1 -1
  17. package/node_modules/cron-parser/LICENSE +21 -0
  18. package/node_modules/cron-parser/README.md +437 -0
  19. package/node_modules/cron-parser/dist/CronDate.js +558 -0
  20. package/node_modules/cron-parser/dist/CronExpression.js +531 -0
  21. package/node_modules/cron-parser/dist/CronExpressionParser.js +482 -0
  22. package/node_modules/cron-parser/dist/CronFieldCollection.js +380 -0
  23. package/node_modules/cron-parser/dist/CronFileParser.js +92 -0
  24. package/node_modules/cron-parser/dist/fields/CronDayOfMonth.js +60 -0
  25. package/node_modules/cron-parser/dist/fields/CronDayOfWeek.js +57 -0
  26. package/node_modules/cron-parser/dist/fields/CronField.js +222 -0
  27. package/node_modules/cron-parser/dist/fields/CronHour.js +40 -0
  28. package/node_modules/cron-parser/dist/fields/CronMinute.js +40 -0
  29. package/node_modules/cron-parser/dist/fields/CronMonth.js +44 -0
  30. package/node_modules/cron-parser/dist/fields/CronSecond.js +40 -0
  31. package/node_modules/cron-parser/dist/fields/index.js +24 -0
  32. package/node_modules/cron-parser/dist/fields/types.js +2 -0
  33. package/node_modules/cron-parser/dist/index.js +31 -0
  34. package/node_modules/cron-parser/dist/types/CronDate.d.ts +293 -0
  35. package/node_modules/cron-parser/dist/types/CronExpression.d.ts +118 -0
  36. package/node_modules/cron-parser/dist/types/CronExpressionParser.d.ts +65 -0
  37. package/node_modules/cron-parser/dist/types/CronFieldCollection.d.ts +153 -0
  38. package/node_modules/cron-parser/dist/types/CronFileParser.d.ts +30 -0
  39. package/node_modules/cron-parser/dist/types/fields/CronDayOfMonth.d.ts +33 -0
  40. package/node_modules/cron-parser/dist/types/fields/CronDayOfWeek.d.ts +31 -0
  41. package/node_modules/cron-parser/dist/types/fields/CronField.d.ts +136 -0
  42. package/node_modules/cron-parser/dist/types/fields/CronHour.d.ts +23 -0
  43. package/node_modules/cron-parser/dist/types/fields/CronMinute.d.ts +23 -0
  44. package/node_modules/cron-parser/dist/types/fields/CronMonth.d.ts +24 -0
  45. package/node_modules/cron-parser/dist/types/fields/CronSecond.d.ts +23 -0
  46. package/node_modules/cron-parser/dist/types/fields/index.d.ts +8 -0
  47. package/node_modules/cron-parser/dist/types/fields/types.d.ts +18 -0
  48. package/node_modules/cron-parser/dist/types/index.d.ts +8 -0
  49. package/node_modules/cron-parser/dist/types/utils/random.d.ts +10 -0
  50. package/node_modules/cron-parser/dist/utils/random.js +38 -0
  51. package/node_modules/cron-parser/package.json +117 -0
  52. package/node_modules/luxon/LICENSE.md +7 -0
  53. package/node_modules/luxon/README.md +55 -0
  54. package/node_modules/luxon/build/amd/luxon.js +8741 -0
  55. package/node_modules/luxon/build/amd/luxon.js.map +1 -0
  56. package/node_modules/luxon/build/cjs-browser/luxon.js +8739 -0
  57. package/node_modules/luxon/build/cjs-browser/luxon.js.map +1 -0
  58. package/node_modules/luxon/build/es6/luxon.mjs +8133 -0
  59. package/node_modules/luxon/build/es6/luxon.mjs.map +1 -0
  60. package/node_modules/luxon/build/global/luxon.js +8744 -0
  61. package/node_modules/luxon/build/global/luxon.js.map +1 -0
  62. package/node_modules/luxon/build/global/luxon.min.js +1 -0
  63. package/node_modules/luxon/build/global/luxon.min.js.map +1 -0
  64. package/node_modules/luxon/build/node/luxon.js +7792 -0
  65. package/node_modules/luxon/build/node/luxon.js.map +1 -0
  66. package/node_modules/luxon/package.json +87 -0
  67. package/node_modules/luxon/src/datetime.js +2603 -0
  68. package/node_modules/luxon/src/duration.js +1009 -0
  69. package/node_modules/luxon/src/errors.js +61 -0
  70. package/node_modules/luxon/src/impl/conversions.js +206 -0
  71. package/node_modules/luxon/src/impl/diff.js +95 -0
  72. package/node_modules/luxon/src/impl/digits.js +94 -0
  73. package/node_modules/luxon/src/impl/english.js +233 -0
  74. package/node_modules/luxon/src/impl/formats.js +176 -0
  75. package/node_modules/luxon/src/impl/formatter.js +434 -0
  76. package/node_modules/luxon/src/impl/invalid.js +14 -0
  77. package/node_modules/luxon/src/impl/locale.js +569 -0
  78. package/node_modules/luxon/src/impl/regexParser.js +335 -0
  79. package/node_modules/luxon/src/impl/tokenParser.js +505 -0
  80. package/node_modules/luxon/src/impl/util.js +330 -0
  81. package/node_modules/luxon/src/impl/zoneUtil.js +34 -0
  82. package/node_modules/luxon/src/info.js +205 -0
  83. package/node_modules/luxon/src/interval.js +669 -0
  84. package/node_modules/luxon/src/luxon.js +26 -0
  85. package/node_modules/luxon/src/package.json +4 -0
  86. package/node_modules/luxon/src/settings.js +180 -0
  87. package/node_modules/luxon/src/zone.js +97 -0
  88. package/node_modules/luxon/src/zones/IANAZone.js +235 -0
  89. package/node_modules/luxon/src/zones/fixedOffsetZone.js +150 -0
  90. package/node_modules/luxon/src/zones/invalidZone.js +53 -0
  91. package/node_modules/luxon/src/zones/systemZone.js +61 -0
  92. package/package.json +3 -1
  93. package/dist/web/assets/Computers-B4ZMJ8tu.js +0 -13
  94. package/dist/web/assets/Markdown-DGF8VSqv.js +0 -29
@@ -1 +1 @@
1
- import{At as e,D as t,Mt as n,R as r,k as i,kt as a}from"./Dropdown-DXEtBxVr.js";import{U as o,W as s}from"./index-Cr9kdjwc.js";function c(e){return/^(?:\/[^/?#]+)*\/(?:projects\/[^/?#]+\/(?:dashboard|assistant|messages|channels|computers|files|materials|help|memory|sessions|members|settings)(?:[?#]|$)|api\/v1\/projects\/|downloads\/teammy(?:-inbox)?-skill\.zip(?:[?#]|$))/.test(e)}function l(e,t,n){return`/projects/${encodeURIComponent(e)}/files?${new URLSearchParams({owner:t,path:n})}`}function u(e,t){return`/projects/${encodeURIComponent(e)}/dashboard?${new URLSearchParams({task:t})}`}function d(e,t,n,r={}){let i=new URLSearchParams({owner:t,sessionKey:n});return r.revision!==void 0&&i.set(`revision`,String(r.revision)),r.source===`handoff`?i.set(`source`,`handoff`):r.messageId&&i.set(`messageId`,r.messageId),`/projects/${encodeURIComponent(e)}/sessions?${i}`}var f=a();function p(t){if(!t.startsWith(`/`)&&!/^https?:\/\//i.test(t))return;let r=URL.parse(e(t),location.origin);if(!r||r.origin!==location.origin||r.username||r.password)return;let i=n();if(!r.pathname.startsWith(i+`/projects/`))return;let a=/^\/projects\/([a-z][a-z0-9_-]{0,63})\/dashboard$/.exec(r.pathname.slice(i.length)),s=o.shape.id.safeParse(r.searchParams.get(`task`));if(a&&s.success)return{project:a[1],id:s.data}}function m(e,n,a=!1){let o=(0,f.useCallback)(t=>r(`projects/${encodeURIComponent(e)}/tasks/${encodeURIComponent(n)}`,s,{signal:t}),[e,n]);return t(o,a?3e3:!1,i(e,`task`,n))}export{d as a,c as i,m as n,u as o,l as r,p as t};
1
+ import{At as e,D as t,Mt as n,R as r,k as i,kt as a}from"./Dropdown-DXEtBxVr.js";import{U as o,W as s}from"./index-Rry2cw7w.js";function c(e){return/^(?:\/[^/?#]+)*\/(?:projects\/[^/?#]+\/(?:dashboard|assistant|messages|channels|computers|files|materials|help|memory|sessions|members|settings)(?:[?#]|$)|api\/v1\/projects\/|downloads\/teammy(?:-inbox)?-skill\.zip(?:[?#]|$))/.test(e)}function l(e,t,n){return`/projects/${encodeURIComponent(e)}/files?${new URLSearchParams({owner:t,path:n})}`}function u(e,t){return`/projects/${encodeURIComponent(e)}/dashboard?${new URLSearchParams({task:t})}`}function d(e,t,n,r={}){let i=new URLSearchParams({owner:t,sessionKey:n});return r.revision!==void 0&&i.set(`revision`,String(r.revision)),r.source===`handoff`?i.set(`source`,`handoff`):r.messageId&&i.set(`messageId`,r.messageId),`/projects/${encodeURIComponent(e)}/sessions?${i}`}var f=a();function p(t){if(!t.startsWith(`/`)&&!/^https?:\/\//i.test(t))return;let r=URL.parse(e(t),location.origin);if(!r||r.origin!==location.origin||r.username||r.password)return;let i=n();if(!r.pathname.startsWith(i+`/projects/`))return;let a=/^\/projects\/([a-z][a-z0-9_-]{0,63})\/dashboard$/.exec(r.pathname.slice(i.length)),s=o.shape.id.safeParse(r.searchParams.get(`task`));if(a&&s.success)return{project:a[1],id:s.data}}function m(e,n,a=!1){let o=(0,f.useCallback)(t=>r(`projects/${encodeURIComponent(e)}/tasks/${encodeURIComponent(n)}`,s,{signal:t}),[e,n]);return t(o,a?3e3:!1,i(e,`task`,n))}export{d as a,c as i,m as n,u as o,l as r,p as t};
Binary file
@@ -12,7 +12,7 @@
12
12
  href="./assets/teammy-y-standard-dark-C4LRaRpE.svg"
13
13
  media="(prefers-color-scheme: dark)"
14
14
  />
15
- <script type="module" crossorigin src="./assets/index-Cr9kdjwc.js"></script>
15
+ <script type="module" crossorigin src="./assets/index-Rry2cw7w.js"></script>
16
16
  <link rel="modulepreload" crossorigin href="./assets/Dropdown-DXEtBxVr.js">
17
17
  <link rel="stylesheet" crossorigin href="./assets/Dropdown-ktgqMqAD.css">
18
18
  <link rel="stylesheet" crossorigin href="./assets/index-CeKzFsxV.css">
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014-2023 Harri Siirak
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,437 @@
1
+ # cron-parser
2
+
3
+ [![Build Status](https://github.com/harrisiirak/cron-parser/actions/workflows/push.yml/badge.svg?branch=master)](https://github.com/harrisiirak/cron-parser/actions/workflows/push.yml)
4
+ [![NPM version](https://badge.fury.io/js/cron-parser.png)](http://badge.fury.io/js/cron-parser)
5
+ ![Statements](https://harrisiirak.github.io/cron-parser/badge-statements.svg)
6
+
7
+ A JavaScript library for parsing and manipulating cron expressions. Features timezone support, DST handling, and iterator capabilities.
8
+
9
+ [API documentation](https://harrisiirak.github.io/cron-parser/)
10
+
11
+ ## Requirements
12
+
13
+ - Node.js >= 18
14
+ - TypeScript >= 5
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ npm install cron-parser
20
+ ```
21
+
22
+ ## Cron Format
23
+
24
+ ```
25
+ * * * * * *
26
+ ┬ ┬ ┬ ┬ ┬ ┬
27
+ │ │ │ │ │ │
28
+ │ │ │ │ │ └─ day of week (0-7, 1L-7L) (0 or 7 is Sun)
29
+ │ │ │ │ └────── month (1-12, JAN-DEC)
30
+ │ │ │ └─────────── day of month (1-31, L)
31
+ │ │ └──────────────── hour (0-23)
32
+ │ └───────────────────── minute (0-59)
33
+ └────────────────────────── second (0-59, optional)
34
+ ```
35
+
36
+ ### Special Characters
37
+
38
+ | Character | Description | Example |
39
+ | --------- | ------------------------- | ---------------------------------------------------------------------- |
40
+ | `*` | Any value | `* * * * *` (every minute) |
41
+ | `?` | Any value (alias for `*`) | `? * * * *` (every minute) |
42
+ | `,` | Value list separator | `1,2,3 * * * *` (1st, 2nd, and 3rd minute) |
43
+ | `-` | Range of values | `1-5 * * * *` (every minute from 1 through 5) |
44
+ | `/` | Step values | `*/5 * * * *` (every 5th minute) |
45
+ | `L` | Last day of month/week | `0 0 L * *` (midnight on last day of month) |
46
+ | `#` | Nth day of month | `0 0 * * 1#1` (first Monday of month) |
47
+ | `H` | Randomized value | `H * * * *` (every n minute where n is randomly picked within [0, 59]) |
48
+
49
+ ### Predefined Expressions
50
+
51
+ | Expression | Description | Equivalent |
52
+ | ----------- | ----------------------------------------- | --------------- |
53
+ | `@yearly` | Once a year at midnight of January 1 | `0 0 0 1 1 *` |
54
+ | `@monthly` | Once a month at midnight of first day | `0 0 0 1 * *` |
55
+ | `@weekly` | Once a week at midnight on Sunday | `0 0 0 * * 0` |
56
+ | `@daily` | Once a day at midnight | `0 0 0 * * *` |
57
+ | `@hourly` | Once an hour at the beginning of the hour | `0 0 * * * *` |
58
+ | `@minutely` | Once a minute | `0 * * * * *` |
59
+ | `@secondly` | Once a second | `* * * * * *` |
60
+ | `@weekdays` | Every weekday at midnight | `0 0 0 * * 1-5` |
61
+ | `@weekends` | Every weekend at midnight | `0 0 0 * * 0,6` |
62
+
63
+ ### Field Values
64
+
65
+ | Field | Values | Special Characters | Aliases |
66
+ | ------------ | ------ | ------------------------------- | ------------------------------ |
67
+ | second | 0-59 | `*` `?` `,` `-` `/` `H` | |
68
+ | minute | 0-59 | `*` `?` `,` `-` `/` `H` | |
69
+ | hour | 0-23 | `*` `?` `,` `-` `/` `H` | |
70
+ | day of month | 1-31 | `*` `?` `,` `-` `/` `H` `L` | |
71
+ | month | 1-12 | `*` `?` `,` `-` `/` `H` | `JAN`-`DEC` |
72
+ | day of week | 0-7 | `*` `?` `,` `-` `/` `H` `L` `#` | `SUN`-`SAT` (0 or 7 is Sunday) |
73
+
74
+ ## Options
75
+
76
+ | Option | Type | Description |
77
+ | ----------- | ------------------------ | --------------------------------------------------------------------------------------------------------------------------- |
78
+ | currentDate | Date \| string \| number | Current date. Defaults to current local time in UTC. If not provided but startDate is set, startDate is used as currentDate |
79
+ | endDate | Date \| string \| number | End date of iteration range. Sets iteration range end point |
80
+ | startDate | Date \| string \| number | Start date of iteration range. Set iteration range start point |
81
+ | tz | string | Timezone (e.g., 'Europe/London') |
82
+ | hashSeed | string | A seed to be used in conjunction with the `H` special character |
83
+ | strict | boolean | Enable strict mode validation |
84
+
85
+ When using string dates, the following formats are supported:
86
+
87
+ - ISO8601
88
+ - HTTP and RFC2822
89
+ - SQL
90
+
91
+ ## Basic Usage
92
+
93
+ ### Expression Parsing
94
+
95
+ ```typescript
96
+ import { CronExpressionParser } from 'cron-parser';
97
+
98
+ try {
99
+ const interval = CronExpressionParser.parse('*/2 * * * *');
100
+
101
+ // Get next date
102
+ console.log('Next:', interval.next().toString());
103
+ // Get next 3 dates
104
+ console.log(
105
+ 'Next 3:',
106
+ interval.take(3).map((date) => date.toString()),
107
+ );
108
+
109
+ // Get previous date
110
+ console.log('Previous:', interval.prev().toString());
111
+ } catch (err) {
112
+ console.log('Error:', err.message);
113
+ }
114
+ ```
115
+
116
+ ### With Options
117
+
118
+ ```typescript
119
+ import { CronExpressionParser } from 'cron-parser';
120
+
121
+ const options = {
122
+ currentDate: '2023-01-01T00:00:00Z',
123
+ endDate: '2024-01-01T00:00:00Z',
124
+ tz: 'Europe/London',
125
+ };
126
+
127
+ try {
128
+ const interval = CronExpressionParser.parse('0 0 * * *', options);
129
+ console.log('Next:', interval.next().toString());
130
+ } catch (err) {
131
+ console.log('Error:', err.message);
132
+ }
133
+ ```
134
+
135
+ ### Date Range Handling
136
+
137
+ The library provides handling of date ranges with automatic adjustment of the `currentDate`:
138
+
139
+ **startDate as fallback**: If `currentDate` is not provided but `startDate` is, the `startDate` will be used as the `currentDate`.
140
+
141
+ ```typescript
142
+ const options = {
143
+ startDate: '2023-01-01T00:00:00Z', // No currentDate provided
144
+ };
145
+ // currentDate will be set to 2023-01-01T00:00:00Z automatically
146
+ const interval = CronExpressionParser.parse('0 0 * * *', options);
147
+ ```
148
+
149
+ **Automatic clamping**: If `currentDate` is outside the bounds defined by `startDate` and `endDate`, it will be automatically adjusted:
150
+
151
+ ```typescript
152
+ const options = {
153
+ currentDate: '2022-01-01T00:00:00Z', // Before startDate
154
+ startDate: '2023-01-01T00:00:00Z',
155
+ endDate: '2024-01-01T00:00:00Z',
156
+ };
157
+ // currentDate will be clamped to startDate (2023-01-01T00:00:00Z)
158
+ const interval = CronExpressionParser.parse('0 0 * * *', options);
159
+ ```
160
+
161
+ **Validation during iteration**: While the initial `currentDate` is automatically adjusted, the library still validates date bounds during iteration:
162
+
163
+ ```typescript
164
+ const options = {
165
+ currentDate: '2023-12-31T00:00:00Z',
166
+ endDate: '2024-01-01T00:00:00Z', // Very close end date
167
+ };
168
+
169
+ const interval = CronExpressionParser.parse('0 0 * * *', options);
170
+ console.log('Next:', interval.next().toString()); // Works fine
171
+
172
+ // This will throw an error because it would exceed endDate
173
+ try {
174
+ console.log('Next:', interval.next().toString());
175
+ } catch (err) {
176
+ console.log('Error:', err.message); // "Out of the time span range"
177
+ }
178
+ ```
179
+
180
+ This behavior simplifies working with date ranges by removing the need to manually ensure that `currentDate` is within bounds, reducing confusion and making the API more intuitive.
181
+
182
+ ### Crontab File Operations
183
+
184
+ For working with crontab files, use the CronFileParser:
185
+
186
+ ```typescript
187
+ import { CronFileParser } from 'cron-parser';
188
+
189
+ // Async file parsing
190
+ try {
191
+ const result = await CronFileParser.parseFile('/path/to/crontab');
192
+ console.log('Variables:', result.variables);
193
+ console.log('Expressions:', result.expressions);
194
+ console.log('Errors:', result.errors);
195
+ } catch (err) {
196
+ console.log('Error:', err.message);
197
+ }
198
+
199
+ // Sync file parsing
200
+ try {
201
+ const result = CronFileParser.parseFileSync('/path/to/crontab');
202
+ console.log('Variables:', result.variables);
203
+ console.log('Expressions:', result.expressions);
204
+ console.log('Errors:', result.errors);
205
+ } catch (err) {
206
+ console.log('Error:', err.message);
207
+ }
208
+ ```
209
+
210
+ ## Advanced Features
211
+
212
+ ### Strict Mode
213
+
214
+ In several implementations of CRON, it's ambiguous to specify both the Day Of Month and Day Of Week parameters simultaneously, as it's unclear which one should take precedence. Despite this ambiguity, this library allows both parameters to be set by default, although the resultant behavior might not align with your expectations.
215
+
216
+ To resolve this ambiguity, you can activate the strict mode of the library. When strict mode is enabled, the library enforces several validation rules:
217
+
218
+ 1. **Day Of Month and Day Of Week**: Prevents the simultaneous setting of both Day Of Month and Day Of Week fields
219
+ 2. **Complete Expression**: Requires all 6 fields to be present in the expression (second, minute, hour, day of month, month, day of week)
220
+ 3. **Non-empty Expression**: Rejects empty expressions that would otherwise default to '0 \* \* \* \* \*'
221
+ 4. **Usable Hashed Range and Step**: Rejects a hash the field cannot satisfy - a range reaching outside the field, such as `H(0-5)` in day of month, or a step wider than the range it applies to, such as `H(1-5)/10` (see [Hash support](#hash-support))
222
+
223
+ These validations help ensure that your cron expressions are unambiguous and correctly formatted.
224
+
225
+ ```typescript
226
+ import { CronExpressionParser } from 'cron-parser';
227
+
228
+ // This will throw an error in strict mode because it uses both dayOfMonth and dayOfWeek
229
+ const options = {
230
+ currentDate: new Date('Mon, 12 Sep 2022 14:00:00'),
231
+ strict: true,
232
+ };
233
+
234
+ try {
235
+ // This will throw an error in strict mode
236
+ CronExpressionParser.parse('0 0 12 1-31 * 1', options);
237
+ } catch (err) {
238
+ console.log('Error:', err.message);
239
+ // Error: Cannot use both dayOfMonth and dayOfWeek together in strict mode!
240
+ }
241
+
242
+ // This will also throw an error in strict mode because it has fewer than 6 fields
243
+ try {
244
+ CronExpressionParser.parse('0 20 15 * *', { strict: true });
245
+ } catch (err) {
246
+ console.log('Error:', err.message);
247
+ // Error: Invalid cron expression, expected 6 fields
248
+ }
249
+
250
+ // This will also throw an error in strict mode because a step of 10 cannot fit the range 1-5
251
+ try {
252
+ CronExpressionParser.parse('0 H(1-5)/10 * * * *', { strict: true });
253
+ } catch (err) {
254
+ console.log('Error:', err.message);
255
+ // Error: Invalid step: 10, wider than the 1-5 range of the minute field
256
+ }
257
+ ```
258
+
259
+ ### Last Day of Month/Week Support
260
+
261
+ The library supports parsing the range `0L - 7L` in the `weekday` position of the cron expression, where the `L` means "last occurrence of this weekday for the month in progress".
262
+
263
+ For example, the following expression will run on the last Monday of the month at midnight:
264
+
265
+ ```typescript
266
+ import { CronExpressionParser } from 'cron-parser';
267
+
268
+ // Last Monday of every month at midnight
269
+ const lastMonday = CronExpressionParser.parse('0 0 0 * * 1L');
270
+
271
+ // You can also combine L expressions with other weekday expressions
272
+ // This will run every Monday and the last Wednesday of the month
273
+ const mixedWeekdays = CronExpressionParser.parse('0 0 0 * * 1,3L');
274
+
275
+ // Last day of every month
276
+ const lastDay = CronExpressionParser.parse('0 0 L * *');
277
+ ```
278
+
279
+ ### Using Iterator
280
+
281
+ ```typescript
282
+ import { CronExpressionParser } from 'cron-parser';
283
+
284
+ const interval = CronExpressionParser.parse('0 */2 * * *');
285
+
286
+ // Using for...of
287
+ for (const date of interval) {
288
+ console.log('Iterator value:', date.toString());
289
+ if (someCondition) break;
290
+ }
291
+
292
+ // Using take() for a specific number of iterations
293
+ const nextFiveDates = interval.take(5);
294
+ console.log(
295
+ 'Next 5 dates:',
296
+ nextFiveDates.map((date) => date.toString()),
297
+ );
298
+ ```
299
+
300
+ ### Timezone Support
301
+
302
+ The library provides robust timezone support using Luxon, handling DST transitions correctly:
303
+
304
+ ```typescript
305
+ import { CronExpressionParser } from 'cron-parser';
306
+
307
+ const options = {
308
+ currentDate: '2023-03-26T01:00:00',
309
+ tz: 'Europe/London',
310
+ };
311
+
312
+ const interval = CronExpressionParser.parse('0 * * * *', options);
313
+
314
+ // Will correctly handle DST transition
315
+ console.log('Next dates during DST transition:');
316
+ console.log(interval.next().toString());
317
+ console.log(interval.next().toString());
318
+ console.log(interval.next().toString());
319
+ ```
320
+
321
+ ### Field Manipulation
322
+
323
+ You can modify cron fields programmatically using `CronFieldCollection.from` and construct a new expression:
324
+
325
+ ```typescript
326
+ import { CronExpressionParser, CronFieldCollection, CronHour, CronMinute } from 'cron-parser';
327
+
328
+ // Parse original expression
329
+ const interval = CronExpressionParser.parse('0 7 * * 1-5');
330
+
331
+ // Create new collection with modified fields using raw values
332
+ const modified = CronFieldCollection.from(interval.fields, {
333
+ hour: [8],
334
+ minute: [30],
335
+ dayOfWeek: [1, 3, 5],
336
+ });
337
+
338
+ console.log(modified.stringify()); // "30 8 * * 1,3,5"
339
+
340
+ // You can also use CronField instances
341
+ const modified2 = CronFieldCollection.from(interval.fields, {
342
+ hour: new CronHour([15]),
343
+ minute: new CronMinute([30]),
344
+ });
345
+
346
+ console.log(modified2.stringify()); // "30 15 * * 1-5"
347
+ ```
348
+
349
+ The `CronFieldCollection.from` method accepts either CronField instances or raw values that would be valid for creating new CronField instances. This is particularly useful when you need to modify only specific fields while keeping others unchanged.
350
+
351
+ ### Hash support
352
+
353
+ The library supports adding [jitter](https://en.wikipedia.org/wiki/Jitter) to the returned intervals using the `H` special character in a field. When `H` is specified instead of `*`, a random value is used (`H` is replaced by `23`, where 23 is picked randomly, within the valid range of the field).
354
+
355
+ This jitter allows to spread the load when it comes to job scheduling. This feature is inspired by Jenkins's cron syntax.
356
+
357
+ ```typescript
358
+ import { CronExpressionParser } from 'cron-parser';
359
+
360
+ // At 23:<randomized> on every day-of-week from Monday through Friday.
361
+ const interval = CronExpressionParser.parse('H 23 * * 1-5');
362
+
363
+ // At <randomized>:30 everyday.
364
+ const interval = CronExpressionParser.parse('30 H * * *');
365
+
366
+ // At every minutes of <randomized> hour at <randomized> second everyday.
367
+ const interval = CronExpressionParser.parse('H * H * * *');
368
+
369
+ // At every 5th minute starting from a random offset.
370
+ // For example, if the random offset is 3, it will run at minutes 3, 8, 13, 18, etc.
371
+ const interval = CronExpressionParser.parse('H/5 * * * *');
372
+
373
+ // At a random minute within the range 0-10 everyday.
374
+ const interval = CronExpressionParser.parse('H(0-10) * * * *');
375
+
376
+ // At every 5th minute starting from a random offset within the range 0-4.
377
+ // For example, if the random offset is 2, it will run at minutes 2, 7, 12, 17, etc.
378
+ // The random offset is constrained to be less than the step value.
379
+ const interval = CronExpressionParser.parse('H(0-29)/5 * * * *');
380
+
381
+ // At every minute of the third <randomized> day of the month
382
+ const interval = CronExpressionParser.parse('* * * * H#3');
383
+ ```
384
+
385
+ A step only produces several occurrences while it is narrow enough to fit the range more than once. When the step is wider than the range - as in `H(1-5)/10`, or `H/60` in a field whose constraints are narrower than 60 - no step-aligned value is guaranteed to land inside the range, so the field falls back to a single random occurrence within it, exactly as `H(1-5)` would give:
386
+
387
+ ```typescript
388
+ import { CronExpressionParser } from 'cron-parser';
389
+
390
+ // A step of 10 cannot fit the range 1-5, so this behaves like 'H(1-5)':
391
+ // one random minute between 1 and 5.
392
+ const interval = CronExpressionParser.parse('H(1-5)/10 * * * *');
393
+ ```
394
+
395
+ A range is first narrowed to what the field can hold, so `H(0-5)` in day of month picks a day between 1 and 5, and `H(50-100)/60` in the minute field steps across 50-59 rather than the 50-100 that was written. A range with nothing left after narrowing, such as `H(0-0)/40` in day of month, is rejected.
396
+
397
+ Whether such an expression is a mistake is up to you: enable [strict mode](#strict-mode) to have it rejected instead of falling back.
398
+
399
+ The randomness is seed-able using the `hashSeed` option of `CronExpressionOptions`:
400
+
401
+ ```typescript
402
+ import { CronExpressionParser } from 'cron-parser';
403
+
404
+ const options = {
405
+ currentDate: '2023-03-26T01:00:00',
406
+ hashSeed: 'main-backup', // Generally, hashSeed would be a job name for example
407
+ };
408
+
409
+ const interval = CronExpressionParser.parse('H * * * H', options);
410
+
411
+ console.log(interval.stringify()); // "12 * * * 4"
412
+
413
+ const otherInterval = CronExpressionParser.parse('H * * * H', options);
414
+
415
+ // Using the same seed will always return the same jitter
416
+ console.log(otherInterval.stringify()); // "12 * * * 4"
417
+ ```
418
+
419
+ ## Contributing
420
+
421
+ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details on:
422
+
423
+ - Setting up the development environment
424
+ - Code style and standards
425
+ - Testing requirements
426
+ - Pull request process
427
+ - Reporting bugs and requesting features
428
+
429
+ Participation is governed by the [Code of Conduct](CODE_OF_CONDUCT.md).
430
+
431
+ ## Security
432
+
433
+ To report a security vulnerability, please follow the [Security Policy](SECURITY.md) rather than opening a public issue.
434
+
435
+ ## License
436
+
437
+ MIT