@sonamu-kit/tasks 0.1.3 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.oxlintrc.json +3 -0
- package/AGENTS.md +21 -0
- package/dist/backend.d.ts +126 -103
- package/dist/backend.d.ts.map +1 -1
- package/dist/backend.js +4 -1
- package/dist/backend.js.map +1 -1
- package/dist/client.d.ts +145 -132
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +220 -212
- package/dist/client.js.map +1 -1
- package/dist/config.d.ts +15 -8
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +22 -17
- package/dist/config.js.map +1 -1
- package/dist/core/duration.d.ts +5 -4
- package/dist/core/duration.d.ts.map +1 -1
- package/dist/core/duration.js +54 -59
- package/dist/core/duration.js.map +1 -1
- package/dist/core/error.d.ts +10 -7
- package/dist/core/error.d.ts.map +1 -1
- package/dist/core/error.js +21 -21
- package/dist/core/error.js.map +1 -1
- package/dist/core/json.d.ts +8 -3
- package/dist/core/json.d.ts.map +1 -1
- package/dist/core/result.d.ts +10 -14
- package/dist/core/result.d.ts.map +1 -1
- package/dist/core/result.js +21 -16
- package/dist/core/result.js.map +1 -1
- package/dist/core/retry.d.ts +42 -20
- package/dist/core/retry.d.ts.map +1 -1
- package/dist/core/retry.js +49 -20
- package/dist/core/retry.js.map +1 -1
- package/dist/core/schema.d.ts +57 -53
- package/dist/core/schema.d.ts.map +1 -1
- package/dist/core/step.d.ts +28 -78
- package/dist/core/step.d.ts.map +1 -1
- package/dist/core/step.js +53 -63
- package/dist/core/step.js.map +1 -1
- package/dist/core/workflow.d.ts +33 -61
- package/dist/core/workflow.d.ts.map +1 -1
- package/dist/core/workflow.js +31 -41
- package/dist/core/workflow.js.map +1 -1
- package/dist/database/backend.d.ts +53 -46
- package/dist/database/backend.d.ts.map +1 -1
- package/dist/database/backend.js +544 -545
- package/dist/database/backend.js.map +1 -1
- package/dist/database/base.js +48 -25
- package/dist/database/base.js.map +1 -1
- package/dist/database/migrations/20251212000000_0_init.d.ts +10 -0
- package/dist/database/migrations/20251212000000_0_init.d.ts.map +1 -0
- package/dist/database/migrations/20251212000000_0_init.js +8 -4
- package/dist/database/migrations/20251212000000_0_init.js.map +1 -1
- package/dist/database/migrations/20251212000000_1_tables.d.ts +10 -0
- package/dist/database/migrations/20251212000000_1_tables.d.ts.map +1 -0
- package/dist/database/migrations/20251212000000_1_tables.js +81 -83
- package/dist/database/migrations/20251212000000_1_tables.js.map +1 -1
- package/dist/database/migrations/20251212000000_2_fk.d.ts +10 -0
- package/dist/database/migrations/20251212000000_2_fk.d.ts.map +1 -0
- package/dist/database/migrations/20251212000000_2_fk.js +20 -43
- package/dist/database/migrations/20251212000000_2_fk.js.map +1 -1
- package/dist/database/migrations/20251212000000_3_indexes.d.ts +10 -0
- package/dist/database/migrations/20251212000000_3_indexes.d.ts.map +1 -0
- package/dist/database/migrations/20251212000000_3_indexes.js +88 -102
- package/dist/database/migrations/20251212000000_3_indexes.js.map +1 -1
- package/dist/database/pubsub.d.ts +7 -16
- package/dist/database/pubsub.d.ts.map +1 -1
- package/dist/database/pubsub.js +75 -73
- package/dist/database/pubsub.js.map +1 -1
- package/dist/execution.d.ts +20 -57
- package/dist/execution.d.ts.map +1 -1
- package/dist/execution.js +175 -174
- package/dist/execution.js.map +1 -1
- package/dist/index.d.ts +5 -8
- package/dist/index.js +5 -5
- package/dist/internal.d.ts +12 -12
- package/dist/internal.js +4 -4
- package/dist/registry.d.ts +33 -27
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +58 -49
- package/dist/registry.js.map +1 -1
- package/dist/worker.d.ts +57 -50
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +194 -198
- package/dist/worker.js.map +1 -1
- package/dist/workflow.d.ts +26 -27
- package/dist/workflow.d.ts.map +1 -1
- package/dist/workflow.js +20 -15
- package/dist/workflow.js.map +1 -1
- package/nodemon.json +1 -1
- package/package.json +18 -20
- package/src/backend.ts +28 -8
- package/src/chaos.test.ts +3 -1
- package/src/client.test.ts +2 -0
- package/src/client.ts +32 -8
- package/src/config.test.ts +1 -0
- package/src/config.ts +3 -2
- package/src/core/duration.test.ts +2 -1
- package/src/core/duration.ts +1 -1
- package/src/core/error.test.ts +1 -0
- package/src/core/error.ts +1 -1
- package/src/core/result.test.ts +1 -0
- package/src/core/retry.test.ts +181 -11
- package/src/core/retry.ts +95 -19
- package/src/core/schema.ts +2 -2
- package/src/core/step.test.ts +2 -1
- package/src/core/step.ts +4 -3
- package/src/core/workflow.test.ts +2 -1
- package/src/core/workflow.ts +4 -3
- package/src/database/backend.test.ts +1 -0
- package/src/database/backend.testsuite.ts +162 -39
- package/src/database/backend.ts +271 -35
- package/src/database/base.test.ts +41 -0
- package/src/database/base.ts +51 -2
- package/src/database/migrations/20251212000000_0_init.ts +2 -1
- package/src/database/migrations/20251212000000_1_tables.ts +2 -1
- package/src/database/migrations/20251212000000_2_fk.ts +2 -1
- package/src/database/migrations/20251212000000_3_indexes.ts +2 -1
- package/src/database/pubsub.test.ts +6 -3
- package/src/database/pubsub.ts +55 -33
- package/src/execution.test.ts +117 -0
- package/src/execution.ts +65 -10
- package/src/internal.ts +21 -1
- package/src/practices/01-remote-workflow.ts +1 -0
- package/src/registry.test.ts +1 -0
- package/src/registry.ts +1 -1
- package/src/testing/connection.ts +3 -1
- package/src/worker.test.ts +2 -0
- package/src/worker.ts +31 -9
- package/src/workflow.test.ts +1 -0
- package/src/workflow.ts +5 -2
- package/templates/openworkflow.config.ts +2 -1
- package/tsdown.config.ts +31 -0
- package/.swcrc +0 -17
- package/dist/chaos.test.d.ts +0 -2
- package/dist/chaos.test.d.ts.map +0 -1
- package/dist/chaos.test.js +0 -92
- package/dist/chaos.test.js.map +0 -1
- package/dist/client.test.d.ts +0 -2
- package/dist/client.test.d.ts.map +0 -1
- package/dist/client.test.js +0 -340
- package/dist/client.test.js.map +0 -1
- package/dist/config.test.d.ts +0 -2
- package/dist/config.test.d.ts.map +0 -1
- package/dist/config.test.js +0 -24
- package/dist/config.test.js.map +0 -1
- package/dist/core/duration.test.d.ts +0 -2
- package/dist/core/duration.test.d.ts.map +0 -1
- package/dist/core/duration.test.js +0 -265
- package/dist/core/duration.test.js.map +0 -1
- package/dist/core/error.test.d.ts +0 -2
- package/dist/core/error.test.d.ts.map +0 -1
- package/dist/core/error.test.js +0 -63
- package/dist/core/error.test.js.map +0 -1
- package/dist/core/json.js +0 -3
- package/dist/core/json.js.map +0 -1
- package/dist/core/result.test.d.ts +0 -2
- package/dist/core/result.test.d.ts.map +0 -1
- package/dist/core/result.test.js +0 -19
- package/dist/core/result.test.js.map +0 -1
- package/dist/core/retry.test.d.ts +0 -2
- package/dist/core/retry.test.d.ts.map +0 -1
- package/dist/core/retry.test.js +0 -37
- package/dist/core/retry.test.js.map +0 -1
- package/dist/core/schema.js +0 -4
- package/dist/core/schema.js.map +0 -1
- package/dist/core/step.test.d.ts +0 -2
- package/dist/core/step.test.d.ts.map +0 -1
- package/dist/core/step.test.js +0 -356
- package/dist/core/step.test.js.map +0 -1
- package/dist/core/workflow.test.d.ts +0 -2
- package/dist/core/workflow.test.d.ts.map +0 -1
- package/dist/core/workflow.test.js +0 -172
- package/dist/core/workflow.test.js.map +0 -1
- package/dist/database/backend.test.d.ts +0 -2
- package/dist/database/backend.test.d.ts.map +0 -1
- package/dist/database/backend.test.js +0 -19
- package/dist/database/backend.test.js.map +0 -1
- package/dist/database/backend.testsuite.d.ts +0 -20
- package/dist/database/backend.testsuite.d.ts.map +0 -1
- package/dist/database/backend.testsuite.js +0 -1174
- package/dist/database/backend.testsuite.js.map +0 -1
- package/dist/database/base.d.ts +0 -12
- package/dist/database/base.d.ts.map +0 -1
- package/dist/database/pubsub.test.d.ts +0 -2
- package/dist/database/pubsub.test.d.ts.map +0 -1
- package/dist/database/pubsub.test.js +0 -86
- package/dist/database/pubsub.test.js.map +0 -1
- package/dist/execution.test.d.ts +0 -2
- package/dist/execution.test.d.ts.map +0 -1
- package/dist/execution.test.js +0 -558
- package/dist/execution.test.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/internal.d.ts.map +0 -1
- package/dist/internal.js.map +0 -1
- package/dist/practices/01-remote-workflow.d.ts +0 -2
- package/dist/practices/01-remote-workflow.d.ts.map +0 -1
- package/dist/practices/01-remote-workflow.js +0 -70
- package/dist/practices/01-remote-workflow.js.map +0 -1
- package/dist/registry.test.d.ts +0 -2
- package/dist/registry.test.d.ts.map +0 -1
- package/dist/registry.test.js +0 -95
- package/dist/registry.test.js.map +0 -1
- package/dist/testing/connection.d.ts +0 -7
- package/dist/testing/connection.d.ts.map +0 -1
- package/dist/testing/connection.js +0 -39
- package/dist/testing/connection.js.map +0 -1
- package/dist/worker.test.d.ts +0 -2
- package/dist/worker.test.d.ts.map +0 -1
- package/dist/worker.test.js +0 -1164
- package/dist/worker.test.js.map +0 -1
- package/dist/workflow.test.d.ts +0 -2
- package/dist/workflow.test.d.ts.map +0 -1
- package/dist/workflow.test.js +0 -73
- package/dist/workflow.test.js.map +0 -1
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "vitest";
|
|
2
|
-
import { parseDuration } from "./duration.js";
|
|
3
|
-
import { err, ok } from "./result.js";
|
|
4
|
-
describe("parseDuration", ()=>{
|
|
5
|
-
describe("milliseconds", ()=>{
|
|
6
|
-
test("parses integer milliseconds", ()=>{
|
|
7
|
-
expect(parseDuration("100ms")).toEqual(ok(100));
|
|
8
|
-
expect(parseDuration("1ms")).toEqual(ok(1));
|
|
9
|
-
expect(parseDuration("5000ms")).toEqual(ok(5000));
|
|
10
|
-
});
|
|
11
|
-
test("parses decimal milliseconds", ()=>{
|
|
12
|
-
expect(parseDuration("1.5ms")).toEqual(ok(1.5));
|
|
13
|
-
expect(parseDuration("10.25ms")).toEqual(ok(10.25));
|
|
14
|
-
});
|
|
15
|
-
test("parses milliseconds with long format", ()=>{
|
|
16
|
-
expect(parseDuration("53 milliseconds")).toEqual(ok(53));
|
|
17
|
-
expect(parseDuration("17 msecs")).toEqual(ok(17));
|
|
18
|
-
expect(parseDuration("100 millisecond")).toEqual(ok(100));
|
|
19
|
-
});
|
|
20
|
-
test("parses numbers without unit as milliseconds", ()=>{
|
|
21
|
-
expect(parseDuration("100")).toEqual(ok(100));
|
|
22
|
-
expect(parseDuration("1000")).toEqual(ok(1000));
|
|
23
|
-
});
|
|
24
|
-
test("parses negative milliseconds", ()=>{
|
|
25
|
-
expect(parseDuration("-100ms")).toEqual(ok(-100));
|
|
26
|
-
expect(parseDuration("-100 milliseconds")).toEqual(ok(-100));
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
describe("seconds", ()=>{
|
|
30
|
-
test("parses integer seconds", ()=>{
|
|
31
|
-
expect(parseDuration("1s")).toEqual(ok(1000));
|
|
32
|
-
expect(parseDuration("5s")).toEqual(ok(5000));
|
|
33
|
-
expect(parseDuration("60s")).toEqual(ok(60_000));
|
|
34
|
-
});
|
|
35
|
-
test("parses decimal seconds", ()=>{
|
|
36
|
-
expect(parseDuration("1.5s")).toEqual(ok(1500));
|
|
37
|
-
expect(parseDuration("0.1s")).toEqual(ok(100));
|
|
38
|
-
expect(parseDuration("2.5s")).toEqual(ok(2500));
|
|
39
|
-
expect(parseDuration("0.001s")).toEqual(ok(1));
|
|
40
|
-
});
|
|
41
|
-
test("parses seconds with long format", ()=>{
|
|
42
|
-
expect(parseDuration("1 sec")).toEqual(ok(1000));
|
|
43
|
-
expect(parseDuration("5 seconds")).toEqual(ok(5000));
|
|
44
|
-
expect(parseDuration("10 secs")).toEqual(ok(10_000));
|
|
45
|
-
});
|
|
46
|
-
test("parses seconds with leading decimal", ()=>{
|
|
47
|
-
expect(parseDuration(".5s")).toEqual(ok(500));
|
|
48
|
-
expect(parseDuration(".5ms")).toEqual(ok(0.5));
|
|
49
|
-
});
|
|
50
|
-
test("parses negative seconds", ()=>{
|
|
51
|
-
expect(parseDuration("-5s")).toEqual(ok(-5000));
|
|
52
|
-
expect(parseDuration("-.5s")).toEqual(ok(-500));
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
describe("minutes", ()=>{
|
|
56
|
-
test("parses integer minutes", ()=>{
|
|
57
|
-
expect(parseDuration("1m")).toEqual(ok(60 * 1000));
|
|
58
|
-
expect(parseDuration("5m")).toEqual(ok(5 * 60 * 1000));
|
|
59
|
-
expect(parseDuration("30m")).toEqual(ok(30 * 60 * 1000));
|
|
60
|
-
});
|
|
61
|
-
test("parses decimal minutes", ()=>{
|
|
62
|
-
expect(parseDuration("1.5m")).toEqual(ok(1.5 * 60 * 1000));
|
|
63
|
-
expect(parseDuration("0.5m")).toEqual(ok(30 * 1000));
|
|
64
|
-
});
|
|
65
|
-
test("parses minutes with long format", ()=>{
|
|
66
|
-
expect(parseDuration("1 min")).toEqual(ok(60_000));
|
|
67
|
-
expect(parseDuration("5 minutes")).toEqual(ok(5 * 60 * 1000));
|
|
68
|
-
expect(parseDuration("10 mins")).toEqual(ok(10 * 60 * 1000));
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
describe("hours", ()=>{
|
|
72
|
-
test("parses integer hours", ()=>{
|
|
73
|
-
expect(parseDuration("1h")).toEqual(ok(60 * 60 * 1000));
|
|
74
|
-
expect(parseDuration("2h")).toEqual(ok(2 * 60 * 60 * 1000));
|
|
75
|
-
expect(parseDuration("24h")).toEqual(ok(24 * 60 * 60 * 1000));
|
|
76
|
-
});
|
|
77
|
-
test("parses decimal hours", ()=>{
|
|
78
|
-
expect(parseDuration("1.5h")).toEqual(ok(1.5 * 60 * 60 * 1000));
|
|
79
|
-
expect(parseDuration("0.25h")).toEqual(ok(15 * 60 * 1000));
|
|
80
|
-
});
|
|
81
|
-
test("parses hours with long format", ()=>{
|
|
82
|
-
expect(parseDuration("1 hr")).toEqual(ok(3_600_000));
|
|
83
|
-
expect(parseDuration("2 hours")).toEqual(ok(2 * 60 * 60 * 1000));
|
|
84
|
-
expect(parseDuration("3 hrs")).toEqual(ok(3 * 60 * 60 * 1000));
|
|
85
|
-
expect(parseDuration("1.5 hours")).toEqual(ok(5_400_000));
|
|
86
|
-
});
|
|
87
|
-
test("parses negative hours", ()=>{
|
|
88
|
-
expect(parseDuration("-1.5h")).toEqual(ok(-5_400_000));
|
|
89
|
-
expect(parseDuration("-10.5h")).toEqual(ok(-37_800_000));
|
|
90
|
-
expect(parseDuration("-.5h")).toEqual(ok(-1_800_000));
|
|
91
|
-
expect(parseDuration("-1.5 hours")).toEqual(ok(-5_400_000));
|
|
92
|
-
expect(parseDuration("-.5 hr")).toEqual(ok(-1_800_000));
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
describe("days", ()=>{
|
|
96
|
-
test("parses integer days", ()=>{
|
|
97
|
-
expect(parseDuration("1d")).toEqual(ok(24 * 60 * 60 * 1000));
|
|
98
|
-
expect(parseDuration("7d")).toEqual(ok(7 * 24 * 60 * 60 * 1000));
|
|
99
|
-
expect(parseDuration("30d")).toEqual(ok(30 * 24 * 60 * 60 * 1000));
|
|
100
|
-
});
|
|
101
|
-
test("parses decimal days", ()=>{
|
|
102
|
-
expect(parseDuration("1.5d")).toEqual(ok(1.5 * 24 * 60 * 60 * 1000));
|
|
103
|
-
expect(parseDuration("0.5d")).toEqual(ok(12 * 60 * 60 * 1000));
|
|
104
|
-
});
|
|
105
|
-
test("parses days with long format", ()=>{
|
|
106
|
-
expect(parseDuration("2 days")).toEqual(ok(172_800_000));
|
|
107
|
-
expect(parseDuration("1 day")).toEqual(ok(24 * 60 * 60 * 1000));
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
describe("weeks", ()=>{
|
|
111
|
-
test("parses integer weeks", ()=>{
|
|
112
|
-
expect(parseDuration("1w")).toEqual(ok(7 * 24 * 60 * 60 * 1000));
|
|
113
|
-
expect(parseDuration("2w")).toEqual(ok(2 * 7 * 24 * 60 * 60 * 1000));
|
|
114
|
-
expect(parseDuration("3w")).toEqual(ok(1_814_400_000));
|
|
115
|
-
});
|
|
116
|
-
test("parses decimal weeks", ()=>{
|
|
117
|
-
expect(parseDuration("1.5w")).toEqual(ok(1.5 * 7 * 24 * 60 * 60 * 1000));
|
|
118
|
-
expect(parseDuration("0.5w")).toEqual(ok(3.5 * 24 * 60 * 60 * 1000));
|
|
119
|
-
});
|
|
120
|
-
test("parses weeks with long format", ()=>{
|
|
121
|
-
expect(parseDuration("1 week")).toEqual(ok(604_800_000));
|
|
122
|
-
expect(parseDuration("2 weeks")).toEqual(ok(2 * 7 * 24 * 60 * 60 * 1000));
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
describe("months", ()=>{
|
|
126
|
-
test("parses integer months", ()=>{
|
|
127
|
-
expect(parseDuration("1mo")).toEqual(ok(2_629_800_000));
|
|
128
|
-
expect(parseDuration("2mo")).toEqual(ok(2 * 2_629_800_000));
|
|
129
|
-
expect(parseDuration("6mo")).toEqual(ok(6 * 2_629_800_000));
|
|
130
|
-
});
|
|
131
|
-
test("parses decimal months", ()=>{
|
|
132
|
-
expect(parseDuration("1.5mo")).toEqual(ok(1.5 * 2_629_800_000));
|
|
133
|
-
expect(parseDuration("0.5mo")).toEqual(ok(0.5 * 2_629_800_000));
|
|
134
|
-
});
|
|
135
|
-
test("parses months with long format", ()=>{
|
|
136
|
-
expect(parseDuration("1 month")).toEqual(ok(2_629_800_000));
|
|
137
|
-
expect(parseDuration("2 months")).toEqual(ok(2 * 2_629_800_000));
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
describe("years", ()=>{
|
|
141
|
-
test("parses integer years", ()=>{
|
|
142
|
-
expect(parseDuration("1y")).toEqual(ok(31_557_600_000));
|
|
143
|
-
expect(parseDuration("2y")).toEqual(ok(2 * 31_557_600_000));
|
|
144
|
-
expect(parseDuration("5y")).toEqual(ok(5 * 31_557_600_000));
|
|
145
|
-
});
|
|
146
|
-
test("parses decimal years", ()=>{
|
|
147
|
-
expect(parseDuration("1.5y")).toEqual(ok(1.5 * 31_557_600_000));
|
|
148
|
-
expect(parseDuration("0.5y")).toEqual(ok(0.5 * 31_557_600_000));
|
|
149
|
-
});
|
|
150
|
-
test("parses years with long format", ()=>{
|
|
151
|
-
expect(parseDuration("1 year")).toEqual(ok(31_557_600_000));
|
|
152
|
-
expect(parseDuration("2 years")).toEqual(ok(2 * 31_557_600_000));
|
|
153
|
-
expect(parseDuration("1 yr")).toEqual(ok(31_557_600_000));
|
|
154
|
-
expect(parseDuration("2 yrs")).toEqual(ok(2 * 31_557_600_000));
|
|
155
|
-
});
|
|
156
|
-
});
|
|
157
|
-
describe("case insensitivity", ()=>{
|
|
158
|
-
test("parses case-insensitive units", ()=>{
|
|
159
|
-
expect(parseDuration("5S")).toEqual(ok(5000));
|
|
160
|
-
expect(parseDuration("5M")).toEqual(ok(5 * 60 * 1000));
|
|
161
|
-
expect(parseDuration("5H")).toEqual(ok(5 * 60 * 60 * 1000));
|
|
162
|
-
expect(parseDuration("5D")).toEqual(ok(5 * 24 * 60 * 60 * 1000));
|
|
163
|
-
expect(parseDuration("5W")).toEqual(ok(5 * 7 * 24 * 60 * 60 * 1000));
|
|
164
|
-
});
|
|
165
|
-
test("parses case-insensitive long format", ()=>{
|
|
166
|
-
// @ts-expect-error - mixed-case (not in type but accepted at runtime)
|
|
167
|
-
expect(parseDuration("53 YeArS")).toEqual(ok(1_672_552_800_000));
|
|
168
|
-
// @ts-expect-error - mixed-case (not in type but accepted at runtime)
|
|
169
|
-
expect(parseDuration("53 WeEkS")).toEqual(ok(32_054_400_000));
|
|
170
|
-
// @ts-expect-error - mixed-case (not in type but accepted at runtime)
|
|
171
|
-
expect(parseDuration("53 DaYS")).toEqual(ok(4_579_200_000));
|
|
172
|
-
// @ts-expect-error - mixed-case (not in type but accepted at runtime)
|
|
173
|
-
expect(parseDuration("53 HoUrs")).toEqual(ok(190_800_000));
|
|
174
|
-
// @ts-expect-error - mixed-case (not in type but accepted at runtime)
|
|
175
|
-
expect(parseDuration("53 MiLliSeCondS")).toEqual(ok(53));
|
|
176
|
-
});
|
|
177
|
-
});
|
|
178
|
-
describe("whitespace handling", ()=>{
|
|
179
|
-
test("parses with single space", ()=>{
|
|
180
|
-
expect(parseDuration("1 s")).toEqual(ok(1000));
|
|
181
|
-
expect(parseDuration("5 m")).toEqual(ok(5 * 60 * 1000));
|
|
182
|
-
expect(parseDuration("2 h")).toEqual(ok(2 * 60 * 60 * 1000));
|
|
183
|
-
});
|
|
184
|
-
test("parses with multiple spaces", ()=>{
|
|
185
|
-
expect(parseDuration("1 s")).toEqual(ok(1000));
|
|
186
|
-
expect(parseDuration("5 m")).toEqual(ok(5 * 60 * 1000));
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
describe("edge cases", ()=>{
|
|
190
|
-
test("parses zero values", ()=>{
|
|
191
|
-
expect(parseDuration("0ms")).toEqual(ok(0));
|
|
192
|
-
expect(parseDuration("0s")).toEqual(ok(0));
|
|
193
|
-
expect(parseDuration("0m")).toEqual(ok(0));
|
|
194
|
-
expect(parseDuration("0h")).toEqual(ok(0));
|
|
195
|
-
expect(parseDuration("0d")).toEqual(ok(0));
|
|
196
|
-
expect(parseDuration("0")).toEqual(ok(0));
|
|
197
|
-
});
|
|
198
|
-
test("parses very small decimals", ()=>{
|
|
199
|
-
expect(parseDuration("0.001s")).toEqual(ok(1));
|
|
200
|
-
expect(parseDuration("0.1ms")).toEqual(ok(0.1));
|
|
201
|
-
});
|
|
202
|
-
test("parses large numbers", ()=>{
|
|
203
|
-
expect(parseDuration("999999ms")).toEqual(ok(999_999));
|
|
204
|
-
expect(parseDuration("1000s")).toEqual(ok(1_000_000));
|
|
205
|
-
});
|
|
206
|
-
});
|
|
207
|
-
describe("error cases", ()=>{
|
|
208
|
-
test("returns error on invalid format", ()=>{
|
|
209
|
-
// @ts-expect-error - invalid format
|
|
210
|
-
expect(parseDuration("invalid")).toEqual(err(new Error('Invalid duration format: "invalid"')));
|
|
211
|
-
// @ts-expect-error - invalid format
|
|
212
|
-
expect(parseDuration("10-.5")).toEqual(err(new Error('Invalid duration format: "10-.5"')));
|
|
213
|
-
// @ts-expect-error - invalid format
|
|
214
|
-
expect(parseDuration("foo")).toEqual(err(new Error('Invalid duration format: "foo"')));
|
|
215
|
-
});
|
|
216
|
-
test("returns error on empty string", ()=>{
|
|
217
|
-
// @ts-expect-error - empty string
|
|
218
|
-
expect(parseDuration("")).toEqual(err(new Error('Invalid duration format: ""')));
|
|
219
|
-
});
|
|
220
|
-
test("returns error on missing number", ()=>{
|
|
221
|
-
// @ts-expect-error - unit without number
|
|
222
|
-
expect(parseDuration("ms")).toEqual(err(new Error('Invalid duration format: "ms"')));
|
|
223
|
-
// @ts-expect-error - unit without number
|
|
224
|
-
expect(parseDuration("s")).toEqual(err(new Error('Invalid duration format: "s"')));
|
|
225
|
-
// @ts-expect-error - unit without number
|
|
226
|
-
expect(parseDuration("m")).toEqual(err(new Error('Invalid duration format: "m"')));
|
|
227
|
-
// @ts-expect-error - unit without number
|
|
228
|
-
expect(parseDuration("h")).toEqual(err(new Error('Invalid duration format: "h"')));
|
|
229
|
-
});
|
|
230
|
-
test("returns error on unknown unit", ()=>{
|
|
231
|
-
// @ts-expect-error - unknown unit
|
|
232
|
-
expect(parseDuration("100x")).toEqual(err(new Error('Invalid duration format: "100x"')));
|
|
233
|
-
// @ts-expect-error - unknown unit
|
|
234
|
-
expect(parseDuration("5z")).toEqual(err(new Error('Invalid duration format: "5z"')));
|
|
235
|
-
});
|
|
236
|
-
test("returns error on multiple units", ()=>{
|
|
237
|
-
// @ts-expect-error - multiple units
|
|
238
|
-
expect(parseDuration("1h30m")).toEqual(err(new Error('Invalid duration format: "1h30m"')));
|
|
239
|
-
// @ts-expect-error - multiple units
|
|
240
|
-
expect(parseDuration("5s100ms")).toEqual(err(new Error('Invalid duration format: "5s100ms"')));
|
|
241
|
-
});
|
|
242
|
-
test("returns error on leading/trailing spaces", ()=>{
|
|
243
|
-
expect(parseDuration(" 5s")).toEqual(err(new Error('Invalid duration format: " 5s"')));
|
|
244
|
-
// @ts-expect-error - trailing space
|
|
245
|
-
expect(parseDuration("5s ")).toEqual(err(new Error('Invalid duration format: "5s "')));
|
|
246
|
-
});
|
|
247
|
-
test("returns error on special characters", ()=>{
|
|
248
|
-
// @ts-expect-error - special characters
|
|
249
|
-
expect(parseDuration("5s!")).toEqual(err(new Error('Invalid duration format: "5s!"')));
|
|
250
|
-
// @ts-expect-error - special characters
|
|
251
|
-
expect(parseDuration("@5s")).toEqual(err(new Error('Invalid duration format: "@5s"')));
|
|
252
|
-
});
|
|
253
|
-
test("returns error on non-string types", ()=>{
|
|
254
|
-
expect(parseDuration(undefined)).toEqual(err(new TypeError("Invalid duration format: expected a string but received undefined")));
|
|
255
|
-
expect(parseDuration(null)).toEqual(err(new TypeError("Invalid duration format: expected a string but received object")));
|
|
256
|
-
expect(parseDuration([])).toEqual(err(new TypeError("Invalid duration format: expected a string but received object")));
|
|
257
|
-
expect(parseDuration({})).toEqual(err(new TypeError("Invalid duration format: expected a string but received object")));
|
|
258
|
-
expect(parseDuration(Number.NaN)).toEqual(err(new TypeError("Invalid duration format: expected a string but received number")));
|
|
259
|
-
expect(parseDuration(Number.POSITIVE_INFINITY)).toEqual(err(new TypeError("Invalid duration format: expected a string but received number")));
|
|
260
|
-
expect(parseDuration(Number.NEGATIVE_INFINITY)).toEqual(err(new TypeError("Invalid duration format: expected a string but received number")));
|
|
261
|
-
});
|
|
262
|
-
});
|
|
263
|
-
});
|
|
264
|
-
|
|
265
|
-
//# sourceMappingURL=duration.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/duration.test.ts"],"sourcesContent":["import { describe, expect, test } from \"vitest\";\nimport type { DurationString } from \"./duration\";\nimport { parseDuration } from \"./duration\";\nimport { err, ok } from \"./result\";\n\ndescribe(\"parseDuration\", () => {\n describe(\"milliseconds\", () => {\n test(\"parses integer milliseconds\", () => {\n expect(parseDuration(\"100ms\")).toEqual(ok(100));\n expect(parseDuration(\"1ms\")).toEqual(ok(1));\n expect(parseDuration(\"5000ms\")).toEqual(ok(5000));\n });\n\n test(\"parses decimal milliseconds\", () => {\n expect(parseDuration(\"1.5ms\")).toEqual(ok(1.5));\n expect(parseDuration(\"10.25ms\")).toEqual(ok(10.25));\n });\n\n test(\"parses milliseconds with long format\", () => {\n expect(parseDuration(\"53 milliseconds\")).toEqual(ok(53));\n expect(parseDuration(\"17 msecs\")).toEqual(ok(17));\n expect(parseDuration(\"100 millisecond\")).toEqual(ok(100));\n });\n\n test(\"parses numbers without unit as milliseconds\", () => {\n expect(parseDuration(\"100\")).toEqual(ok(100));\n expect(parseDuration(\"1000\")).toEqual(ok(1000));\n });\n\n test(\"parses negative milliseconds\", () => {\n expect(parseDuration(\"-100ms\")).toEqual(ok(-100));\n expect(parseDuration(\"-100 milliseconds\")).toEqual(ok(-100));\n });\n });\n\n describe(\"seconds\", () => {\n test(\"parses integer seconds\", () => {\n expect(parseDuration(\"1s\")).toEqual(ok(1000));\n expect(parseDuration(\"5s\")).toEqual(ok(5000));\n expect(parseDuration(\"60s\")).toEqual(ok(60_000));\n });\n\n test(\"parses decimal seconds\", () => {\n expect(parseDuration(\"1.5s\")).toEqual(ok(1500));\n expect(parseDuration(\"0.1s\")).toEqual(ok(100));\n expect(parseDuration(\"2.5s\")).toEqual(ok(2500));\n expect(parseDuration(\"0.001s\")).toEqual(ok(1));\n });\n\n test(\"parses seconds with long format\", () => {\n expect(parseDuration(\"1 sec\")).toEqual(ok(1000));\n expect(parseDuration(\"5 seconds\")).toEqual(ok(5000));\n expect(parseDuration(\"10 secs\")).toEqual(ok(10_000));\n });\n\n test(\"parses seconds with leading decimal\", () => {\n expect(parseDuration(\".5s\")).toEqual(ok(500));\n expect(parseDuration(\".5ms\")).toEqual(ok(0.5));\n });\n\n test(\"parses negative seconds\", () => {\n expect(parseDuration(\"-5s\")).toEqual(ok(-5000));\n expect(parseDuration(\"-.5s\")).toEqual(ok(-500));\n });\n });\n\n describe(\"minutes\", () => {\n test(\"parses integer minutes\", () => {\n expect(parseDuration(\"1m\")).toEqual(ok(60 * 1000));\n expect(parseDuration(\"5m\")).toEqual(ok(5 * 60 * 1000));\n expect(parseDuration(\"30m\")).toEqual(ok(30 * 60 * 1000));\n });\n\n test(\"parses decimal minutes\", () => {\n expect(parseDuration(\"1.5m\")).toEqual(ok(1.5 * 60 * 1000));\n expect(parseDuration(\"0.5m\")).toEqual(ok(30 * 1000));\n });\n\n test(\"parses minutes with long format\", () => {\n expect(parseDuration(\"1 min\")).toEqual(ok(60_000));\n expect(parseDuration(\"5 minutes\")).toEqual(ok(5 * 60 * 1000));\n expect(parseDuration(\"10 mins\")).toEqual(ok(10 * 60 * 1000));\n });\n });\n\n describe(\"hours\", () => {\n test(\"parses integer hours\", () => {\n expect(parseDuration(\"1h\")).toEqual(ok(60 * 60 * 1000));\n expect(parseDuration(\"2h\")).toEqual(ok(2 * 60 * 60 * 1000));\n expect(parseDuration(\"24h\")).toEqual(ok(24 * 60 * 60 * 1000));\n });\n\n test(\"parses decimal hours\", () => {\n expect(parseDuration(\"1.5h\")).toEqual(ok(1.5 * 60 * 60 * 1000));\n expect(parseDuration(\"0.25h\")).toEqual(ok(15 * 60 * 1000));\n });\n\n test(\"parses hours with long format\", () => {\n expect(parseDuration(\"1 hr\")).toEqual(ok(3_600_000));\n expect(parseDuration(\"2 hours\")).toEqual(ok(2 * 60 * 60 * 1000));\n expect(parseDuration(\"3 hrs\")).toEqual(ok(3 * 60 * 60 * 1000));\n expect(parseDuration(\"1.5 hours\")).toEqual(ok(5_400_000));\n });\n\n test(\"parses negative hours\", () => {\n expect(parseDuration(\"-1.5h\")).toEqual(ok(-5_400_000));\n expect(parseDuration(\"-10.5h\")).toEqual(ok(-37_800_000));\n expect(parseDuration(\"-.5h\")).toEqual(ok(-1_800_000));\n expect(parseDuration(\"-1.5 hours\")).toEqual(ok(-5_400_000));\n expect(parseDuration(\"-.5 hr\")).toEqual(ok(-1_800_000));\n });\n });\n\n describe(\"days\", () => {\n test(\"parses integer days\", () => {\n expect(parseDuration(\"1d\")).toEqual(ok(24 * 60 * 60 * 1000));\n expect(parseDuration(\"7d\")).toEqual(ok(7 * 24 * 60 * 60 * 1000));\n expect(parseDuration(\"30d\")).toEqual(ok(30 * 24 * 60 * 60 * 1000));\n });\n\n test(\"parses decimal days\", () => {\n expect(parseDuration(\"1.5d\")).toEqual(ok(1.5 * 24 * 60 * 60 * 1000));\n expect(parseDuration(\"0.5d\")).toEqual(ok(12 * 60 * 60 * 1000));\n });\n\n test(\"parses days with long format\", () => {\n expect(parseDuration(\"2 days\")).toEqual(ok(172_800_000));\n expect(parseDuration(\"1 day\")).toEqual(ok(24 * 60 * 60 * 1000));\n });\n });\n\n describe(\"weeks\", () => {\n test(\"parses integer weeks\", () => {\n expect(parseDuration(\"1w\")).toEqual(ok(7 * 24 * 60 * 60 * 1000));\n expect(parseDuration(\"2w\")).toEqual(ok(2 * 7 * 24 * 60 * 60 * 1000));\n expect(parseDuration(\"3w\")).toEqual(ok(1_814_400_000));\n });\n\n test(\"parses decimal weeks\", () => {\n expect(parseDuration(\"1.5w\")).toEqual(ok(1.5 * 7 * 24 * 60 * 60 * 1000));\n expect(parseDuration(\"0.5w\")).toEqual(ok(3.5 * 24 * 60 * 60 * 1000));\n });\n\n test(\"parses weeks with long format\", () => {\n expect(parseDuration(\"1 week\")).toEqual(ok(604_800_000));\n expect(parseDuration(\"2 weeks\")).toEqual(ok(2 * 7 * 24 * 60 * 60 * 1000));\n });\n });\n\n describe(\"months\", () => {\n test(\"parses integer months\", () => {\n expect(parseDuration(\"1mo\")).toEqual(ok(2_629_800_000));\n expect(parseDuration(\"2mo\")).toEqual(ok(2 * 2_629_800_000));\n expect(parseDuration(\"6mo\")).toEqual(ok(6 * 2_629_800_000));\n });\n\n test(\"parses decimal months\", () => {\n expect(parseDuration(\"1.5mo\")).toEqual(ok(1.5 * 2_629_800_000));\n expect(parseDuration(\"0.5mo\")).toEqual(ok(0.5 * 2_629_800_000));\n });\n\n test(\"parses months with long format\", () => {\n expect(parseDuration(\"1 month\")).toEqual(ok(2_629_800_000));\n expect(parseDuration(\"2 months\")).toEqual(ok(2 * 2_629_800_000));\n });\n });\n\n describe(\"years\", () => {\n test(\"parses integer years\", () => {\n expect(parseDuration(\"1y\")).toEqual(ok(31_557_600_000));\n expect(parseDuration(\"2y\")).toEqual(ok(2 * 31_557_600_000));\n expect(parseDuration(\"5y\")).toEqual(ok(5 * 31_557_600_000));\n });\n\n test(\"parses decimal years\", () => {\n expect(parseDuration(\"1.5y\")).toEqual(ok(1.5 * 31_557_600_000));\n expect(parseDuration(\"0.5y\")).toEqual(ok(0.5 * 31_557_600_000));\n });\n\n test(\"parses years with long format\", () => {\n expect(parseDuration(\"1 year\")).toEqual(ok(31_557_600_000));\n expect(parseDuration(\"2 years\")).toEqual(ok(2 * 31_557_600_000));\n expect(parseDuration(\"1 yr\")).toEqual(ok(31_557_600_000));\n expect(parseDuration(\"2 yrs\")).toEqual(ok(2 * 31_557_600_000));\n });\n });\n\n describe(\"case insensitivity\", () => {\n test(\"parses case-insensitive units\", () => {\n expect(parseDuration(\"5S\")).toEqual(ok(5000));\n expect(parseDuration(\"5M\")).toEqual(ok(5 * 60 * 1000));\n expect(parseDuration(\"5H\")).toEqual(ok(5 * 60 * 60 * 1000));\n expect(parseDuration(\"5D\")).toEqual(ok(5 * 24 * 60 * 60 * 1000));\n expect(parseDuration(\"5W\")).toEqual(ok(5 * 7 * 24 * 60 * 60 * 1000));\n });\n\n test(\"parses case-insensitive long format\", () => {\n // @ts-expect-error - mixed-case (not in type but accepted at runtime)\n expect(parseDuration(\"53 YeArS\")).toEqual(ok(1_672_552_800_000));\n // @ts-expect-error - mixed-case (not in type but accepted at runtime)\n expect(parseDuration(\"53 WeEkS\")).toEqual(ok(32_054_400_000));\n // @ts-expect-error - mixed-case (not in type but accepted at runtime)\n expect(parseDuration(\"53 DaYS\")).toEqual(ok(4_579_200_000));\n // @ts-expect-error - mixed-case (not in type but accepted at runtime)\n expect(parseDuration(\"53 HoUrs\")).toEqual(ok(190_800_000));\n // @ts-expect-error - mixed-case (not in type but accepted at runtime)\n expect(parseDuration(\"53 MiLliSeCondS\")).toEqual(ok(53));\n });\n });\n\n describe(\"whitespace handling\", () => {\n test(\"parses with single space\", () => {\n expect(parseDuration(\"1 s\")).toEqual(ok(1000));\n expect(parseDuration(\"5 m\")).toEqual(ok(5 * 60 * 1000));\n expect(parseDuration(\"2 h\")).toEqual(ok(2 * 60 * 60 * 1000));\n });\n\n test(\"parses with multiple spaces\", () => {\n expect(parseDuration(\"1 s\")).toEqual(ok(1000));\n expect(parseDuration(\"5 m\")).toEqual(ok(5 * 60 * 1000));\n });\n });\n\n describe(\"edge cases\", () => {\n test(\"parses zero values\", () => {\n expect(parseDuration(\"0ms\")).toEqual(ok(0));\n expect(parseDuration(\"0s\")).toEqual(ok(0));\n expect(parseDuration(\"0m\")).toEqual(ok(0));\n expect(parseDuration(\"0h\")).toEqual(ok(0));\n expect(parseDuration(\"0d\")).toEqual(ok(0));\n expect(parseDuration(\"0\")).toEqual(ok(0));\n });\n\n test(\"parses very small decimals\", () => {\n expect(parseDuration(\"0.001s\")).toEqual(ok(1));\n expect(parseDuration(\"0.1ms\")).toEqual(ok(0.1));\n });\n\n test(\"parses large numbers\", () => {\n expect(parseDuration(\"999999ms\")).toEqual(ok(999_999));\n expect(parseDuration(\"1000s\")).toEqual(ok(1_000_000));\n });\n });\n\n describe(\"error cases\", () => {\n test(\"returns error on invalid format\", () => {\n // @ts-expect-error - invalid format\n expect(parseDuration(\"invalid\")).toEqual(\n err(new Error('Invalid duration format: \"invalid\"')),\n );\n // @ts-expect-error - invalid format\n expect(parseDuration(\"10-.5\")).toEqual(err(new Error('Invalid duration format: \"10-.5\"')));\n // @ts-expect-error - invalid format\n expect(parseDuration(\"foo\")).toEqual(err(new Error('Invalid duration format: \"foo\"')));\n });\n\n test(\"returns error on empty string\", () => {\n // @ts-expect-error - empty string\n expect(parseDuration(\"\")).toEqual(err(new Error('Invalid duration format: \"\"')));\n });\n\n test(\"returns error on missing number\", () => {\n // @ts-expect-error - unit without number\n expect(parseDuration(\"ms\")).toEqual(err(new Error('Invalid duration format: \"ms\"')));\n // @ts-expect-error - unit without number\n expect(parseDuration(\"s\")).toEqual(err(new Error('Invalid duration format: \"s\"')));\n // @ts-expect-error - unit without number\n expect(parseDuration(\"m\")).toEqual(err(new Error('Invalid duration format: \"m\"')));\n // @ts-expect-error - unit without number\n expect(parseDuration(\"h\")).toEqual(err(new Error('Invalid duration format: \"h\"')));\n });\n\n test(\"returns error on unknown unit\", () => {\n // @ts-expect-error - unknown unit\n expect(parseDuration(\"100x\")).toEqual(err(new Error('Invalid duration format: \"100x\"')));\n // @ts-expect-error - unknown unit\n expect(parseDuration(\"5z\")).toEqual(err(new Error('Invalid duration format: \"5z\"')));\n });\n\n test(\"returns error on multiple units\", () => {\n // @ts-expect-error - multiple units\n expect(parseDuration(\"1h30m\")).toEqual(err(new Error('Invalid duration format: \"1h30m\"')));\n // @ts-expect-error - multiple units\n expect(parseDuration(\"5s100ms\")).toEqual(\n err(new Error('Invalid duration format: \"5s100ms\"')),\n );\n });\n\n test(\"returns error on leading/trailing spaces\", () => {\n expect(parseDuration(\" 5s\")).toEqual(err(new Error('Invalid duration format: \" 5s\"')));\n // @ts-expect-error - trailing space\n expect(parseDuration(\"5s \")).toEqual(err(new Error('Invalid duration format: \"5s \"')));\n });\n\n test(\"returns error on special characters\", () => {\n // @ts-expect-error - special characters\n expect(parseDuration(\"5s!\")).toEqual(err(new Error('Invalid duration format: \"5s!\"')));\n // @ts-expect-error - special characters\n expect(parseDuration(\"@5s\")).toEqual(err(new Error('Invalid duration format: \"@5s\"')));\n });\n\n test(\"returns error on non-string types\", () => {\n expect(parseDuration(undefined as unknown as DurationString)).toEqual(\n err(new TypeError(\"Invalid duration format: expected a string but received undefined\")),\n );\n expect(parseDuration(null as unknown as DurationString)).toEqual(\n err(new TypeError(\"Invalid duration format: expected a string but received object\")),\n );\n expect(parseDuration([] as unknown as DurationString)).toEqual(\n err(new TypeError(\"Invalid duration format: expected a string but received object\")),\n );\n expect(parseDuration({} as unknown as DurationString)).toEqual(\n err(new TypeError(\"Invalid duration format: expected a string but received object\")),\n );\n expect(parseDuration(Number.NaN as unknown as DurationString)).toEqual(\n err(new TypeError(\"Invalid duration format: expected a string but received number\")),\n );\n expect(parseDuration(Number.POSITIVE_INFINITY as unknown as DurationString)).toEqual(\n err(new TypeError(\"Invalid duration format: expected a string but received number\")),\n );\n expect(parseDuration(Number.NEGATIVE_INFINITY as unknown as DurationString)).toEqual(\n err(new TypeError(\"Invalid duration format: expected a string but received number\")),\n );\n });\n });\n});\n"],"names":["describe","expect","test","parseDuration","err","ok","toEqual","Error","undefined","TypeError","Number","NaN","POSITIVE_INFINITY","NEGATIVE_INFINITY"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,IAAI,QAAQ,SAAS;AAEhD,SAASC,aAAa,QAAQ,gBAAa;AAC3C,SAASC,GAAG,EAAEC,EAAE,QAAQ,cAAW;AAEnCL,SAAS,iBAAiB;IACxBA,SAAS,gBAAgB;QACvBE,KAAK,+BAA+B;YAClCD,OAAOE,cAAc,UAAUG,OAAO,CAACD,GAAG;YAC1CJ,OAAOE,cAAc,QAAQG,OAAO,CAACD,GAAG;YACxCJ,OAAOE,cAAc,WAAWG,OAAO,CAACD,GAAG;QAC7C;QAEAH,KAAK,+BAA+B;YAClCD,OAAOE,cAAc,UAAUG,OAAO,CAACD,GAAG;YAC1CJ,OAAOE,cAAc,YAAYG,OAAO,CAACD,GAAG;QAC9C;QAEAH,KAAK,wCAAwC;YAC3CD,OAAOE,cAAc,oBAAoBG,OAAO,CAACD,GAAG;YACpDJ,OAAOE,cAAc,aAAaG,OAAO,CAACD,GAAG;YAC7CJ,OAAOE,cAAc,oBAAoBG,OAAO,CAACD,GAAG;QACtD;QAEAH,KAAK,+CAA+C;YAClDD,OAAOE,cAA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IAAIG,MAAM;QAElB;QAEAL,KAAK,4CAA4C;YAC/CD,OAAOE,cAAc,QAAQG,OAAO,CAACF,IAAI,IAAIG,MAAM;YACnD,oCAAoC;YACpCN,OAAOE,cAAc,QAAQG,OAAO,CAACF,IAAI,IAAIG,MAAM;QACrD;QAEAL,KAAK,uCAAuC;YAC1C,wCAAwC;YACxCD,OAAOE,cAAc,QAAQG,OAAO,CAACF,IAAI,IAAIG,MAAM;YACnD,wCAAwC;YACxCN,OAAOE,cAAc,QAAQG,OAAO,CAACF,IAAI,IAAIG,MAAM;QACrD;QAEAL,KAAK,qCAAqC;YACxCD,OAAOE,cAAcK,YAAyCF,OAAO,CACnEF,IAAI,IAAIK,UAAU;YAEpBR,OAAOE,cAAc,OAAoCG,OAAO,CAC9DF,IAAI,IAAIK,UAAU;YAEpBR,OAAOE,cAAc,EAAE,GAAgCG,OAAO,CAC5DF,IAAI,IAAIK,UAAU;YAEpBR,OAAOE,cAAc,CAAC,IAAiCG,OAAO,CAC5DF,IAAI,IAAIK,UAAU;YAEpBR,OAAOE,cAAcO,OAAOC,GAAG,GAAgCL,OAAO,CACpEF,IAAI,IAAIK,UAAU;YAEpBR,OAAOE,cAAcO,OAAOE,iBAAiB,GAAgCN,OAAO,CAClFF,IAAI,IAAIK,UAAU;YAEpBR,OAAOE,cAAcO,OAAOG,iBAAiB,GAAgCP,OAAO,CAClFF,IAAI,IAAIK,UAAU;QAEtB;IACF;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"error.test.d.ts","sourceRoot":"","sources":["../../src/core/error.test.ts"],"names":[],"mappings":""}
|
package/dist/core/error.test.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "vitest";
|
|
2
|
-
import { serializeError } from "./error.js";
|
|
3
|
-
describe("serializeError", ()=>{
|
|
4
|
-
test("serializes Error instance with name, message, and stack", ()=>{
|
|
5
|
-
const error = new Error("Something went wrong");
|
|
6
|
-
const result = serializeError(error);
|
|
7
|
-
expect(result.name).toBe("Error");
|
|
8
|
-
expect(result.message).toBe("Something went wrong");
|
|
9
|
-
expect(result.stack).toBeDefined();
|
|
10
|
-
expect(typeof result.stack).toBe("string");
|
|
11
|
-
});
|
|
12
|
-
test("serializes TypeError with correct name", ()=>{
|
|
13
|
-
const error = new TypeError("Invalid type");
|
|
14
|
-
const result = serializeError(error);
|
|
15
|
-
expect(result.name).toBe("TypeError");
|
|
16
|
-
expect(result.message).toBe("Invalid type");
|
|
17
|
-
});
|
|
18
|
-
test("serializes custom Error subclass", ()=>{
|
|
19
|
-
class CustomError extends Error {
|
|
20
|
-
constructor(message){
|
|
21
|
-
super(message);
|
|
22
|
-
this.name = "CustomError";
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
const error = new CustomError("Custom error message");
|
|
26
|
-
const result = serializeError(error);
|
|
27
|
-
expect(result.name).toBe("CustomError");
|
|
28
|
-
expect(result.message).toBe("Custom error message");
|
|
29
|
-
});
|
|
30
|
-
test("serializes Error without stack as undefined", ()=>{
|
|
31
|
-
const error = new Error("No stack");
|
|
32
|
-
error.stack = undefined;
|
|
33
|
-
const result = serializeError(error);
|
|
34
|
-
expect(result.stack).toBeUndefined();
|
|
35
|
-
});
|
|
36
|
-
test("serializes string to message", ()=>{
|
|
37
|
-
const result = serializeError("string error");
|
|
38
|
-
expect(result.message).toBe("string error");
|
|
39
|
-
expect(result.name).toBeUndefined();
|
|
40
|
-
expect(result.stack).toBeUndefined();
|
|
41
|
-
});
|
|
42
|
-
test("serializes number to message", ()=>{
|
|
43
|
-
const result = serializeError(42);
|
|
44
|
-
expect(result.message).toBe("42");
|
|
45
|
-
});
|
|
46
|
-
test("serializes null to message", ()=>{
|
|
47
|
-
const result = serializeError(null);
|
|
48
|
-
expect(result.message).toBe("null");
|
|
49
|
-
});
|
|
50
|
-
test("serializes undefined to message", ()=>{
|
|
51
|
-
// eslint-disable-next-line unicorn/no-useless-undefined
|
|
52
|
-
const result = serializeError(undefined);
|
|
53
|
-
expect(result.message).toBe("undefined");
|
|
54
|
-
});
|
|
55
|
-
test("serializes object to message using String()", ()=>{
|
|
56
|
-
const result = serializeError({
|
|
57
|
-
foo: "bar"
|
|
58
|
-
});
|
|
59
|
-
expect(result.message).toBe("[object Object]");
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
//# sourceMappingURL=error.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/error.test.ts"],"sourcesContent":["import { describe, expect, test } from \"vitest\";\nimport { serializeError } from \"./error\";\n\ndescribe(\"serializeError\", () => {\n test(\"serializes Error instance with name, message, and stack\", () => {\n const error = new Error(\"Something went wrong\");\n const result = serializeError(error);\n\n expect(result.name).toBe(\"Error\");\n expect(result.message).toBe(\"Something went wrong\");\n expect(result.stack).toBeDefined();\n expect(typeof result.stack).toBe(\"string\");\n });\n\n test(\"serializes TypeError with correct name\", () => {\n const error = new TypeError(\"Invalid type\");\n const result = serializeError(error);\n\n expect(result.name).toBe(\"TypeError\");\n expect(result.message).toBe(\"Invalid type\");\n });\n\n test(\"serializes custom Error subclass\", () => {\n class CustomError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"CustomError\";\n }\n }\n const error = new CustomError(\"Custom error message\");\n const result = serializeError(error);\n\n expect(result.name).toBe(\"CustomError\");\n expect(result.message).toBe(\"Custom error message\");\n });\n\n test(\"serializes Error without stack as undefined\", () => {\n const error = new Error(\"No stack\");\n error.stack = undefined;\n const result = serializeError(error);\n\n expect(result.stack).toBeUndefined();\n });\n\n test(\"serializes string to message\", () => {\n const result = serializeError(\"string error\");\n\n expect(result.message).toBe(\"string error\");\n expect(result.name).toBeUndefined();\n expect(result.stack).toBeUndefined();\n });\n\n test(\"serializes number to message\", () => {\n const result = serializeError(42);\n\n expect(result.message).toBe(\"42\");\n });\n\n test(\"serializes null to message\", () => {\n const result = serializeError(null);\n\n expect(result.message).toBe(\"null\");\n });\n\n test(\"serializes undefined to message\", () => {\n // eslint-disable-next-line unicorn/no-useless-undefined\n const result = serializeError(undefined);\n\n expect(result.message).toBe(\"undefined\");\n });\n\n test(\"serializes object to message using String()\", () => {\n const result = serializeError({ foo: \"bar\" });\n\n expect(result.message).toBe(\"[object Object]\");\n });\n});\n"],"names":["describe","expect","test","serializeError","error","Error","result","name","toBe","message","stack","toBeDefined","TypeError","CustomError","undefined","toBeUndefined","foo"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,IAAI,QAAQ,SAAS;AAChD,SAASC,cAAc,QAAQ,aAAU;AAEzCH,SAAS,kBAAkB;IACzBE,KAAK,2DAA2D;QAC9D,MAAME,QAAQ,IAAIC,MAAM;QACxB,MAAMC,SAASH,eAAeC;QAE9BH,OAAOK,OAAOC,IAAI,EAAEC,IAAI,CAAC;QACzBP,OAAOK,OAAOG,OAAO,EAAED,IAAI,CAAC;QAC5BP,OAAOK,OAAOI,KAAK,EAAEC,WAAW;QAChCV,OAAO,OAAOK,OAAOI,KAAK,EAAEF,IAAI,CAAC;IACnC;IAEAN,KAAK,0CAA0C;QAC7C,MAAME,QAAQ,IAAIQ,UAAU;QAC5B,MAAMN,SAASH,eAAeC;QAE9BH,OAAOK,OAAOC,IAAI,EAAEC,IAAI,CAAC;QACzBP,OAAOK,OAAOG,OAAO,EAAED,IAAI,CAAC;IAC9B;IAEAN,KAAK,oCAAoC;QACvC,MAAMW,oBAAoBR;YACxB,YAAYI,OAAe,CAAE;gBAC3B,KAAK,CAACA;gBACN,IAAI,CAACF,IAAI,GAAG;YACd;QACF;QACA,MAAMH,QAAQ,IAAIS,YAAY;QAC9B,MAAMP,SAASH,eAAeC;QAE9BH,OAAOK,OAAOC,IAAI,EAAEC,IAAI,CAAC;QACzBP,OAAOK,OAAOG,OAAO,EAAED,IAAI,CAAC;IAC9B;IAEAN,KAAK,+CAA+C;QAClD,MAAME,QAAQ,IAAIC,MAAM;QACxBD,MAAMM,KAAK,GAAGI;QACd,MAAMR,SAASH,eAAeC;QAE9BH,OAAOK,OAAOI,KAAK,EAAEK,aAAa;IACpC;IAEAb,KAAK,gCAAgC;QACnC,MAAMI,SAASH,eAAe;QAE9BF,OAAOK,OAAOG,OAAO,EAAED,IAAI,CAAC;QAC5BP,OAAOK,OAAOC,IAAI,EAAEQ,aAAa;QACjCd,OAAOK,OAAOI,KAAK,EAAEK,aAAa;IACpC;IAEAb,KAAK,gCAAgC;QACnC,MAAMI,SAASH,eAAe;QAE9BF,OAAOK,OAAOG,OAAO,EAAED,IAAI,CAAC;IAC9B;IAEAN,KAAK,8BAA8B;QACjC,MAAMI,SAASH,eAAe;QAE9BF,OAAOK,OAAOG,OAAO,EAAED,IAAI,CAAC;IAC9B;IAEAN,KAAK,mCAAmC;QACtC,wDAAwD;QACxD,MAAMI,SAASH,eAAeW;QAE9Bb,OAAOK,OAAOG,OAAO,EAAED,IAAI,CAAC;IAC9B;IAEAN,KAAK,+CAA+C;QAClD,MAAMI,SAASH,eAAe;YAAEa,KAAK;QAAM;QAE3Cf,OAAOK,OAAOG,OAAO,EAAED,IAAI,CAAC;IAC9B;AACF"}
|
package/dist/core/json.js
DELETED
package/dist/core/json.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/json.ts"],"sourcesContent":["export type JsonPrimitive = string | number | boolean | null;\nexport type JsonValue = JsonPrimitive | JsonValue[] | { [key: string]: JsonValue };\n"],"names":[],"mappings":"AACA,WAAmF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"result.test.d.ts","sourceRoot":"","sources":["../../src/core/result.test.ts"],"names":[],"mappings":""}
|
package/dist/core/result.test.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "vitest";
|
|
2
|
-
import { err, ok } from "./result.js";
|
|
3
|
-
describe("Result helpers", ()=>{
|
|
4
|
-
test("ok creates success result", ()=>{
|
|
5
|
-
expect(ok(123)).toEqual({
|
|
6
|
-
ok: true,
|
|
7
|
-
value: 123
|
|
8
|
-
});
|
|
9
|
-
});
|
|
10
|
-
test("err creates error result", ()=>{
|
|
11
|
-
const error = new Error("oops");
|
|
12
|
-
expect(err(error)).toEqual({
|
|
13
|
-
ok: false,
|
|
14
|
-
error
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
//# sourceMappingURL=result.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/result.test.ts"],"sourcesContent":["import { describe, expect, test } from \"vitest\";\nimport { err, ok } from \"./result\";\n\ndescribe(\"Result helpers\", () => {\n test(\"ok creates success result\", () => {\n expect(ok(123)).toEqual({ ok: true, value: 123 });\n });\n\n test(\"err creates error result\", () => {\n const error = new Error(\"oops\");\n expect(err(error)).toEqual({ ok: false, error });\n });\n});\n"],"names":["describe","expect","test","err","ok","toEqual","value","error","Error"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,IAAI,QAAQ,SAAS;AAChD,SAASC,GAAG,EAAEC,EAAE,QAAQ,cAAW;AAEnCJ,SAAS,kBAAkB;IACzBE,KAAK,6BAA6B;QAChCD,OAAOG,GAAG,MAAMC,OAAO,CAAC;YAAED,IAAI;YAAME,OAAO;QAAI;IACjD;IAEAJ,KAAK,4BAA4B;QAC/B,MAAMK,QAAQ,IAAIC,MAAM;QACxBP,OAAOE,IAAII,QAAQF,OAAO,CAAC;YAAED,IAAI;YAAOG;QAAM;IAChD;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"retry.test.d.ts","sourceRoot":"","sources":["../../src/core/retry.test.ts"],"names":[],"mappings":""}
|
package/dist/core/retry.test.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "vitest";
|
|
2
|
-
import { calculateRetryDelayMs, DEFAULT_RETRY_POLICY, shouldRetry } from "./retry.js";
|
|
3
|
-
describe("calculateRetryDelayMs", ()=>{
|
|
4
|
-
test("calculates exponential backoff correctly", ()=>{
|
|
5
|
-
expect(calculateRetryDelayMs(1)).toBe(1000);
|
|
6
|
-
expect(calculateRetryDelayMs(2)).toBe(2000);
|
|
7
|
-
expect(calculateRetryDelayMs(3)).toBe(4000);
|
|
8
|
-
expect(calculateRetryDelayMs(4)).toBe(8000);
|
|
9
|
-
expect(calculateRetryDelayMs(5)).toBe(16_000);
|
|
10
|
-
expect(calculateRetryDelayMs(6)).toBe(32_000);
|
|
11
|
-
expect(calculateRetryDelayMs(7)).toBe(64_000);
|
|
12
|
-
});
|
|
13
|
-
test("caps delay at maximum interval", ()=>{
|
|
14
|
-
const { maximumIntervalMs } = DEFAULT_RETRY_POLICY;
|
|
15
|
-
// attempt 8: 1s * 2^7 = 128s = 128000ms, but capped at 100000ms (max)
|
|
16
|
-
expect(calculateRetryDelayMs(8)).toBe(maximumIntervalMs);
|
|
17
|
-
// attempts 10 & 100: should still be capped
|
|
18
|
-
expect(calculateRetryDelayMs(10)).toBe(maximumIntervalMs);
|
|
19
|
-
expect(calculateRetryDelayMs(100)).toBe(maximumIntervalMs);
|
|
20
|
-
});
|
|
21
|
-
test("handles edge cases", ()=>{
|
|
22
|
-
// attempt 0: 1s * 2^-1 = 0.5s = 500ms
|
|
23
|
-
expect(calculateRetryDelayMs(0)).toBe(500);
|
|
24
|
-
expect(calculateRetryDelayMs(Infinity)).toBe(100_000);
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
describe("shouldRetry", ()=>{
|
|
28
|
-
test("always returns true with default policy (infinite retries)", ()=>{
|
|
29
|
-
const retryPolicy = DEFAULT_RETRY_POLICY;
|
|
30
|
-
expect(shouldRetry(retryPolicy, 1)).toBe(true);
|
|
31
|
-
expect(shouldRetry(retryPolicy, 10)).toBe(true);
|
|
32
|
-
expect(shouldRetry(retryPolicy, 100)).toBe(true);
|
|
33
|
-
expect(shouldRetry(retryPolicy, 1000)).toBe(true);
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
//# sourceMappingURL=retry.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/retry.test.ts"],"sourcesContent":["import { describe, expect, test } from \"vitest\";\nimport { calculateRetryDelayMs, DEFAULT_RETRY_POLICY, shouldRetry } from \"./retry\";\n\ndescribe(\"calculateRetryDelayMs\", () => {\n test(\"calculates exponential backoff correctly\", () => {\n expect(calculateRetryDelayMs(1)).toBe(1000);\n expect(calculateRetryDelayMs(2)).toBe(2000);\n expect(calculateRetryDelayMs(3)).toBe(4000);\n expect(calculateRetryDelayMs(4)).toBe(8000);\n expect(calculateRetryDelayMs(5)).toBe(16_000);\n expect(calculateRetryDelayMs(6)).toBe(32_000);\n expect(calculateRetryDelayMs(7)).toBe(64_000);\n });\n\n test(\"caps delay at maximum interval\", () => {\n const { maximumIntervalMs } = DEFAULT_RETRY_POLICY;\n\n // attempt 8: 1s * 2^7 = 128s = 128000ms, but capped at 100000ms (max)\n expect(calculateRetryDelayMs(8)).toBe(maximumIntervalMs);\n\n // attempts 10 & 100: should still be capped\n expect(calculateRetryDelayMs(10)).toBe(maximumIntervalMs);\n expect(calculateRetryDelayMs(100)).toBe(maximumIntervalMs);\n });\n\n test(\"handles edge cases\", () => {\n // attempt 0: 1s * 2^-1 = 0.5s = 500ms\n expect(calculateRetryDelayMs(0)).toBe(500);\n expect(calculateRetryDelayMs(Infinity)).toBe(100_000);\n });\n});\n\ndescribe(\"shouldRetry\", () => {\n test(\"always returns true with default policy (infinite retries)\", () => {\n const retryPolicy = DEFAULT_RETRY_POLICY;\n expect(shouldRetry(retryPolicy, 1)).toBe(true);\n expect(shouldRetry(retryPolicy, 10)).toBe(true);\n expect(shouldRetry(retryPolicy, 100)).toBe(true);\n expect(shouldRetry(retryPolicy, 1000)).toBe(true);\n });\n});\n"],"names":["describe","expect","test","calculateRetryDelayMs","DEFAULT_RETRY_POLICY","shouldRetry","toBe","maximumIntervalMs","Infinity","retryPolicy"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,IAAI,QAAQ,SAAS;AAChD,SAASC,qBAAqB,EAAEC,oBAAoB,EAAEC,WAAW,QAAQ,aAAU;AAEnFL,SAAS,yBAAyB;IAChCE,KAAK,4CAA4C;QAC/CD,OAAOE,sBAAsB,IAAIG,IAAI,CAAC;QACtCL,OAAOE,sBAAsB,IAAIG,IAAI,CAAC;QACtCL,OAAOE,sBAAsB,IAAIG,IAAI,CAAC;QACtCL,OAAOE,sBAAsB,IAAIG,IAAI,CAAC;QACtCL,OAAOE,sBAAsB,IAAIG,IAAI,CAAC;QACtCL,OAAOE,sBAAsB,IAAIG,IAAI,CAAC;QACtCL,OAAOE,sBAAsB,IAAIG,IAAI,CAAC;IACxC;IAEAJ,KAAK,kCAAkC;QACrC,MAAM,EAAEK,iBAAiB,EAAE,GAAGH;QAE9B,sEAAsE;QACtEH,OAAOE,sBAAsB,IAAIG,IAAI,CAACC;QAEtC,4CAA4C;QAC5CN,OAAOE,sBAAsB,KAAKG,IAAI,CAACC;QACvCN,OAAOE,sBAAsB,MAAMG,IAAI,CAACC;IAC1C;IAEAL,KAAK,sBAAsB;QACzB,sCAAsC;QACtCD,OAAOE,sBAAsB,IAAIG,IAAI,CAAC;QACtCL,OAAOE,sBAAsBK,WAAWF,IAAI,CAAC;IAC/C;AACF;AAEAN,SAAS,eAAe;IACtBE,KAAK,8DAA8D;QACjE,MAAMO,cAAcL;QACpBH,OAAOI,YAAYI,aAAa,IAAIH,IAAI,CAAC;QACzCL,OAAOI,YAAYI,aAAa,KAAKH,IAAI,CAAC;QAC1CL,OAAOI,YAAYI,aAAa,MAAMH,IAAI,CAAC;QAC3CL,OAAOI,YAAYI,aAAa,OAAOH,IAAI,CAAC;IAC9C;AACF"}
|
package/dist/core/schema.js
DELETED
package/dist/core/schema.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/schema.ts"],"sourcesContent":["/** The Standard Schema interface. https://standardschema.dev */\nexport interface StandardSchemaV1<Input = unknown, Output = Input> {\n /** The Standard Schema properties. */\n readonly \"~standard\": StandardSchemaV1.Props<Input, Output>;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport declare namespace StandardSchemaV1 {\n /** The Standard Schema properties interface. */\n // eslint-disable-next-line functional/no-mixed-types\n export interface Props<Input = unknown, Output = Input> {\n /** The version number of the standard. */\n readonly version: 1;\n /** The vendor name of the schema library. */\n readonly vendor: string;\n /** Validates unknown input values. */\n readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;\n /** Inferred types associated with the schema. */\n readonly types?: Types<Input, Output> | undefined;\n }\n\n /** The result interface of the validate function. */\n export type Result<Output> = SuccessResult<Output> | FailureResult;\n\n /** The result interface if validation succeeds. */\n export interface SuccessResult<Output> {\n /** The typed output value. */\n readonly value: Output;\n /** The non-existent issues. */\n readonly issues?: undefined;\n }\n\n /** The result interface if validation fails. */\n export interface FailureResult {\n /** The issues of failed validation. */\n readonly issues: readonly Issue[];\n }\n\n /** The issue interface of the failure output. */\n export interface Issue {\n /** The error message of the issue. */\n readonly message: string;\n /** The path of the issue, if any. */\n readonly path?: readonly (PropertyKey | PathSegment)[] | undefined;\n }\n\n /** The path segment interface of the issue. */\n export interface PathSegment {\n /** The key representing a path segment. */\n readonly key: PropertyKey;\n }\n\n /** The Standard Schema types interface. */\n export interface Types<Input = unknown, Output = Input> {\n /** The input type of the schema. */\n readonly input: Input;\n /** The output type of the schema. */\n readonly output: Output;\n }\n\n /** Infers the input type of a Standard Schema. */\n export type InferInput<Schema extends StandardSchemaV1> = NonNullable<\n Schema[\"~standard\"][\"types\"]\n >[\"input\"];\n\n /** Infers the output type of a Standard Schema. */\n export type InferOutput<Schema extends StandardSchemaV1> = NonNullable<\n Schema[\"~standard\"][\"types\"]\n >[\"output\"];\n\n // eslint-disable-next-line unicorn/require-module-specifiers\n // biome-ignore lint/complexity/noUselessEmptyExport: needed for granular visibility control of TS namespace\n export {};\n}\n"],"names":[],"mappings":"AAAA,8DAA8D,GAM9D,2DAA2D;AAC3D,WAkEC"}
|
package/dist/core/step.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"step.test.d.ts","sourceRoot":"","sources":["../../src/core/step.test.ts"],"names":[],"mappings":""}
|