@ms-cloudpack/api-server 0.60.0 → 0.60.2

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 (64) hide show
  1. package/lib/apis/addPackageOverride.d.ts +3 -38
  2. package/lib/apis/addPackageOverride.d.ts.map +1 -1
  3. package/lib/apis/addPackageOverride.js +2 -13
  4. package/lib/apis/addPackageOverride.js.map +1 -1
  5. package/lib/apis/openConfigEditor.d.ts.map +1 -1
  6. package/lib/apis/openConfigEditor.js +5 -2
  7. package/lib/apis/openConfigEditor.js.map +1 -1
  8. package/lib/apis/validatePackageOverride.d.ts +6 -31
  9. package/lib/apis/validatePackageOverride.d.ts.map +1 -1
  10. package/lib/apis/validatePackageOverride.js +3 -2
  11. package/lib/apis/validatePackageOverride.js.map +1 -1
  12. package/lib/data/busSources.d.ts +18 -292
  13. package/lib/data/busSources.d.ts.map +1 -1
  14. package/lib/index.d.ts +2 -2
  15. package/lib/index.d.ts.map +1 -1
  16. package/lib/index.js +1 -1
  17. package/lib/index.js.map +1 -1
  18. package/lib/types/TaskDescription.d.ts +14 -224
  19. package/lib/types/TaskDescription.d.ts.map +1 -1
  20. package/lib/types/TaskDescription.js +2 -2
  21. package/lib/types/TaskDescription.js.map +1 -1
  22. package/lib/types/TaskEndDescription.d.ts +14 -224
  23. package/lib/types/TaskEndDescription.d.ts.map +1 -1
  24. package/lib/types/TaskList.d.ts +18 -292
  25. package/lib/types/TaskList.d.ts.map +1 -1
  26. package/lib/types/TaskMessage.d.ts +11 -108
  27. package/lib/types/TaskMessage.d.ts.map +1 -1
  28. package/lib/types/TaskMessage.js +3 -2
  29. package/lib/types/TaskMessage.js.map +1 -1
  30. package/lib/types/TaskMessageLocation.d.ts +6 -13
  31. package/lib/types/TaskMessageLocation.d.ts.map +1 -1
  32. package/lib/types/TaskMessageLocation.js +2 -1
  33. package/lib/types/TaskMessageLocation.js.map +1 -1
  34. package/lib/utilities/TaskRunner.d.ts.map +1 -1
  35. package/lib/utilities/TaskRunner.js +7 -1
  36. package/lib/utilities/TaskRunner.js.map +1 -1
  37. package/lib/utilities/matchingZodObject.d.ts +4 -0
  38. package/lib/utilities/matchingZodObject.d.ts.map +1 -1
  39. package/lib/utilities/matchingZodObject.js +4 -0
  40. package/lib/utilities/matchingZodObject.js.map +1 -1
  41. package/lib/utilities/writeStubForDensityEntries.d.ts.map +1 -1
  42. package/lib/utilities/writeStubForDensityEntries.js +2 -1
  43. package/lib/utilities/writeStubForDensityEntries.js.map +1 -1
  44. package/package.json +1 -1
  45. package/lib/types/TaskResponse.d.ts +0 -337
  46. package/lib/types/TaskResponse.d.ts.map +0 -1
  47. package/lib/types/TaskResponse.js +0 -8
  48. package/lib/types/TaskResponse.js.map +0 -1
  49. package/lib/types/TaskResult.d.ts +0 -233
  50. package/lib/types/TaskResult.d.ts.map +0 -1
  51. package/lib/types/TaskResult.js +0 -7
  52. package/lib/types/TaskResult.js.map +0 -1
  53. package/lib/types/Timings.d.ts +0 -20
  54. package/lib/types/Timings.d.ts.map +0 -1
  55. package/lib/types/Timings.js +0 -5
  56. package/lib/types/Timings.js.map +0 -1
  57. package/lib/utilities/editCloudpackConfig.d.ts +0 -5
  58. package/lib/utilities/editCloudpackConfig.d.ts.map +0 -1
  59. package/lib/utilities/editCloudpackConfig.js +0 -10
  60. package/lib/utilities/editCloudpackConfig.js.map +0 -1
  61. package/lib/utilities/getDefaultTaskStats.d.ts +0 -3
  62. package/lib/utilities/getDefaultTaskStats.d.ts.map +0 -1
  63. package/lib/utilities/getDefaultTaskStats.js +0 -8
  64. package/lib/utilities/getDefaultTaskStats.js.map +0 -1
@@ -29,163 +29,17 @@ export declare const ZodTaskList: z.ZodObject<{
29
29
  }>, {
30
30
  id: z.ZodString;
31
31
  errors: z.ZodOptional<z.ZodArray<z.ZodObject<{
32
- text: z.ZodString;
33
- source: z.ZodString;
34
- location: z.ZodOptional<z.ZodObject<{
35
- file: z.ZodString;
36
- line: z.ZodOptional<z.ZodNumber>;
37
- column: z.ZodOptional<z.ZodNumber>;
38
- }, "strip", z.ZodTypeAny, {
39
- file: string;
40
- line?: number | undefined;
41
- column?: number | undefined;
42
- }, {
43
- file: string;
44
- line?: number | undefined;
45
- column?: number | undefined;
46
- }>>;
47
- notes: z.ZodOptional<z.ZodArray<z.ZodObject<{
48
- text: z.ZodString;
49
- location: z.ZodOptional<z.ZodObject<{
50
- file: z.ZodString;
51
- line: z.ZodOptional<z.ZodNumber>;
52
- column: z.ZodOptional<z.ZodNumber>;
53
- }, "strip", z.ZodTypeAny, {
54
- file: string;
55
- line?: number | undefined;
56
- column?: number | undefined;
57
- }, {
58
- file: string;
59
- line?: number | undefined;
60
- column?: number | undefined;
61
- }>>;
62
- }, "strip", z.ZodTypeAny, {
63
- text: string;
64
- location?: {
65
- file: string;
66
- line?: number | undefined;
67
- column?: number | undefined;
68
- } | undefined;
69
- }, {
70
- text: string;
71
- location?: {
72
- file: string;
73
- line?: number | undefined;
74
- column?: number | undefined;
75
- } | undefined;
76
- }>, "many">>;
77
- }, "strip", z.ZodTypeAny, {
78
- text: string;
79
- source: string;
80
- location?: {
81
- file: string;
82
- line?: number | undefined;
83
- column?: number | undefined;
84
- } | undefined;
85
- notes?: {
86
- text: string;
87
- location?: {
88
- file: string;
89
- line?: number | undefined;
90
- column?: number | undefined;
91
- } | undefined;
92
- }[] | undefined;
93
- }, {
94
- text: string;
95
- source: string;
96
- location?: {
97
- file: string;
98
- line?: number | undefined;
99
- column?: number | undefined;
100
- } | undefined;
101
- notes?: {
102
- text: string;
103
- location?: {
104
- file: string;
105
- line?: number | undefined;
106
- column?: number | undefined;
107
- } | undefined;
108
- }[] | undefined;
109
- }>, "many">>;
32
+ text: z.ZodType<string, z.ZodTypeDef, string>;
33
+ source: z.ZodType<string, z.ZodTypeDef, string>;
34
+ location: z.ZodType<import("@ms-cloudpack/common-types").BundleMessageLocation | undefined, z.ZodTypeDef, import("@ms-cloudpack/common-types").BundleMessageLocation | undefined>;
35
+ notes: z.ZodType<import("@ms-cloudpack/common-types").BundleMessageNote[] | undefined, z.ZodTypeDef, import("@ms-cloudpack/common-types").BundleMessageNote[] | undefined>;
36
+ }, "strict", z.ZodTypeAny, import("@ms-cloudpack/common-types").BundleMessage, import("@ms-cloudpack/common-types").BundleMessage>, "many">>;
110
37
  warnings: z.ZodOptional<z.ZodArray<z.ZodObject<{
111
- text: z.ZodString;
112
- source: z.ZodString;
113
- location: z.ZodOptional<z.ZodObject<{
114
- file: z.ZodString;
115
- line: z.ZodOptional<z.ZodNumber>;
116
- column: z.ZodOptional<z.ZodNumber>;
117
- }, "strip", z.ZodTypeAny, {
118
- file: string;
119
- line?: number | undefined;
120
- column?: number | undefined;
121
- }, {
122
- file: string;
123
- line?: number | undefined;
124
- column?: number | undefined;
125
- }>>;
126
- notes: z.ZodOptional<z.ZodArray<z.ZodObject<{
127
- text: z.ZodString;
128
- location: z.ZodOptional<z.ZodObject<{
129
- file: z.ZodString;
130
- line: z.ZodOptional<z.ZodNumber>;
131
- column: z.ZodOptional<z.ZodNumber>;
132
- }, "strip", z.ZodTypeAny, {
133
- file: string;
134
- line?: number | undefined;
135
- column?: number | undefined;
136
- }, {
137
- file: string;
138
- line?: number | undefined;
139
- column?: number | undefined;
140
- }>>;
141
- }, "strip", z.ZodTypeAny, {
142
- text: string;
143
- location?: {
144
- file: string;
145
- line?: number | undefined;
146
- column?: number | undefined;
147
- } | undefined;
148
- }, {
149
- text: string;
150
- location?: {
151
- file: string;
152
- line?: number | undefined;
153
- column?: number | undefined;
154
- } | undefined;
155
- }>, "many">>;
156
- }, "strip", z.ZodTypeAny, {
157
- text: string;
158
- source: string;
159
- location?: {
160
- file: string;
161
- line?: number | undefined;
162
- column?: number | undefined;
163
- } | undefined;
164
- notes?: {
165
- text: string;
166
- location?: {
167
- file: string;
168
- line?: number | undefined;
169
- column?: number | undefined;
170
- } | undefined;
171
- }[] | undefined;
172
- }, {
173
- text: string;
174
- source: string;
175
- location?: {
176
- file: string;
177
- line?: number | undefined;
178
- column?: number | undefined;
179
- } | undefined;
180
- notes?: {
181
- text: string;
182
- location?: {
183
- file: string;
184
- line?: number | undefined;
185
- column?: number | undefined;
186
- } | undefined;
187
- }[] | undefined;
188
- }>, "many">>;
38
+ text: z.ZodType<string, z.ZodTypeDef, string>;
39
+ source: z.ZodType<string, z.ZodTypeDef, string>;
40
+ location: z.ZodType<import("@ms-cloudpack/common-types").BundleMessageLocation | undefined, z.ZodTypeDef, import("@ms-cloudpack/common-types").BundleMessageLocation | undefined>;
41
+ notes: z.ZodType<import("@ms-cloudpack/common-types").BundleMessageNote[] | undefined, z.ZodTypeDef, import("@ms-cloudpack/common-types").BundleMessageNote[] | undefined>;
42
+ }, "strict", z.ZodTypeAny, import("@ms-cloudpack/common-types").BundleMessage, import("@ms-cloudpack/common-types").BundleMessage>, "many">>;
189
43
  }>, "strip", z.ZodTypeAny, {
190
44
  id: string;
191
45
  startTime: number;
@@ -193,40 +47,8 @@ export declare const ZodTaskList: z.ZodObject<{
193
47
  name?: string | undefined;
194
48
  inputPath?: string | undefined;
195
49
  outputPath?: string | undefined;
196
- errors?: {
197
- text: string;
198
- source: string;
199
- location?: {
200
- file: string;
201
- line?: number | undefined;
202
- column?: number | undefined;
203
- } | undefined;
204
- notes?: {
205
- text: string;
206
- location?: {
207
- file: string;
208
- line?: number | undefined;
209
- column?: number | undefined;
210
- } | undefined;
211
- }[] | undefined;
212
- }[] | undefined;
213
- warnings?: {
214
- text: string;
215
- source: string;
216
- location?: {
217
- file: string;
218
- line?: number | undefined;
219
- column?: number | undefined;
220
- } | undefined;
221
- notes?: {
222
- text: string;
223
- location?: {
224
- file: string;
225
- line?: number | undefined;
226
- column?: number | undefined;
227
- } | undefined;
228
- }[] | undefined;
229
- }[] | undefined;
50
+ errors?: import("@ms-cloudpack/common-types").BundleMessage[] | undefined;
51
+ warnings?: import("@ms-cloudpack/common-types").BundleMessage[] | undefined;
230
52
  timings?: {
231
53
  name: string;
232
54
  start: number;
@@ -242,40 +64,8 @@ export declare const ZodTaskList: z.ZodObject<{
242
64
  name?: string | undefined;
243
65
  inputPath?: string | undefined;
244
66
  outputPath?: string | undefined;
245
- errors?: {
246
- text: string;
247
- source: string;
248
- location?: {
249
- file: string;
250
- line?: number | undefined;
251
- column?: number | undefined;
252
- } | undefined;
253
- notes?: {
254
- text: string;
255
- location?: {
256
- file: string;
257
- line?: number | undefined;
258
- column?: number | undefined;
259
- } | undefined;
260
- }[] | undefined;
261
- }[] | undefined;
262
- warnings?: {
263
- text: string;
264
- source: string;
265
- location?: {
266
- file: string;
267
- line?: number | undefined;
268
- column?: number | undefined;
269
- } | undefined;
270
- notes?: {
271
- text: string;
272
- location?: {
273
- file: string;
274
- line?: number | undefined;
275
- column?: number | undefined;
276
- } | undefined;
277
- }[] | undefined;
278
- }[] | undefined;
67
+ errors?: import("@ms-cloudpack/common-types").BundleMessage[] | undefined;
68
+ warnings?: import("@ms-cloudpack/common-types").BundleMessage[] | undefined;
279
69
  timings?: {
280
70
  name: string;
281
71
  start: number;
@@ -293,40 +83,8 @@ export declare const ZodTaskList: z.ZodObject<{
293
83
  name?: string | undefined;
294
84
  inputPath?: string | undefined;
295
85
  outputPath?: string | undefined;
296
- errors?: {
297
- text: string;
298
- source: string;
299
- location?: {
300
- file: string;
301
- line?: number | undefined;
302
- column?: number | undefined;
303
- } | undefined;
304
- notes?: {
305
- text: string;
306
- location?: {
307
- file: string;
308
- line?: number | undefined;
309
- column?: number | undefined;
310
- } | undefined;
311
- }[] | undefined;
312
- }[] | undefined;
313
- warnings?: {
314
- text: string;
315
- source: string;
316
- location?: {
317
- file: string;
318
- line?: number | undefined;
319
- column?: number | undefined;
320
- } | undefined;
321
- notes?: {
322
- text: string;
323
- location?: {
324
- file: string;
325
- line?: number | undefined;
326
- column?: number | undefined;
327
- } | undefined;
328
- }[] | undefined;
329
- }[] | undefined;
86
+ errors?: import("@ms-cloudpack/common-types").BundleMessage[] | undefined;
87
+ warnings?: import("@ms-cloudpack/common-types").BundleMessage[] | undefined;
330
88
  timings?: {
331
89
  name: string;
332
90
  start: number;
@@ -344,40 +102,8 @@ export declare const ZodTaskList: z.ZodObject<{
344
102
  name?: string | undefined;
345
103
  inputPath?: string | undefined;
346
104
  outputPath?: string | undefined;
347
- errors?: {
348
- text: string;
349
- source: string;
350
- location?: {
351
- file: string;
352
- line?: number | undefined;
353
- column?: number | undefined;
354
- } | undefined;
355
- notes?: {
356
- text: string;
357
- location?: {
358
- file: string;
359
- line?: number | undefined;
360
- column?: number | undefined;
361
- } | undefined;
362
- }[] | undefined;
363
- }[] | undefined;
364
- warnings?: {
365
- text: string;
366
- source: string;
367
- location?: {
368
- file: string;
369
- line?: number | undefined;
370
- column?: number | undefined;
371
- } | undefined;
372
- notes?: {
373
- text: string;
374
- location?: {
375
- file: string;
376
- line?: number | undefined;
377
- column?: number | undefined;
378
- } | undefined;
379
- }[] | undefined;
380
- }[] | undefined;
105
+ errors?: import("@ms-cloudpack/common-types").BundleMessage[] | undefined;
106
+ warnings?: import("@ms-cloudpack/common-types").BundleMessage[] | undefined;
381
107
  timings?: {
382
108
  name: string;
383
109
  start: number;
@@ -1 +1 @@
1
- {"version":3,"file":"TaskList.d.ts","sourceRoot":"","sources":["../../src/types/TaskList.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEtB,CAAC;AAEH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC"}
1
+ {"version":3,"file":"TaskList.d.ts","sourceRoot":"","sources":["../../src/types/TaskList.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEtB,CAAC;AAEH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC"}
@@ -1,112 +1,15 @@
1
1
  import z from 'zod';
2
+ import type { BundleMessage, BundleMessageNote } from '@ms-cloudpack/common-types';
3
+ export type TaskNote = BundleMessageNote;
2
4
  export declare const ZodTaskNote: z.ZodObject<{
3
- text: z.ZodString;
4
- location: z.ZodOptional<z.ZodObject<{
5
- file: z.ZodString;
6
- line: z.ZodOptional<z.ZodNumber>;
7
- column: z.ZodOptional<z.ZodNumber>;
8
- }, "strip", z.ZodTypeAny, {
9
- file: string;
10
- line?: number | undefined;
11
- column?: number | undefined;
12
- }, {
13
- file: string;
14
- line?: number | undefined;
15
- column?: number | undefined;
16
- }>>;
17
- }, "strip", z.ZodTypeAny, {
18
- text: string;
19
- location?: {
20
- file: string;
21
- line?: number | undefined;
22
- column?: number | undefined;
23
- } | undefined;
24
- }, {
25
- text: string;
26
- location?: {
27
- file: string;
28
- line?: number | undefined;
29
- column?: number | undefined;
30
- } | undefined;
31
- }>;
5
+ text: z.ZodType<string, z.ZodTypeDef, string>;
6
+ location: z.ZodType<import("@ms-cloudpack/common-types").BundleMessageLocation | undefined, z.ZodTypeDef, import("@ms-cloudpack/common-types").BundleMessageLocation | undefined>;
7
+ }, "strict", z.ZodTypeAny, BundleMessageNote, BundleMessageNote>;
8
+ export type TaskMessage = BundleMessage;
32
9
  export declare const ZodTaskMessage: z.ZodObject<{
33
- text: z.ZodString;
34
- source: z.ZodString;
35
- location: z.ZodOptional<z.ZodObject<{
36
- file: z.ZodString;
37
- line: z.ZodOptional<z.ZodNumber>;
38
- column: z.ZodOptional<z.ZodNumber>;
39
- }, "strip", z.ZodTypeAny, {
40
- file: string;
41
- line?: number | undefined;
42
- column?: number | undefined;
43
- }, {
44
- file: string;
45
- line?: number | undefined;
46
- column?: number | undefined;
47
- }>>;
48
- notes: z.ZodOptional<z.ZodArray<z.ZodObject<{
49
- text: z.ZodString;
50
- location: z.ZodOptional<z.ZodObject<{
51
- file: z.ZodString;
52
- line: z.ZodOptional<z.ZodNumber>;
53
- column: z.ZodOptional<z.ZodNumber>;
54
- }, "strip", z.ZodTypeAny, {
55
- file: string;
56
- line?: number | undefined;
57
- column?: number | undefined;
58
- }, {
59
- file: string;
60
- line?: number | undefined;
61
- column?: number | undefined;
62
- }>>;
63
- }, "strip", z.ZodTypeAny, {
64
- text: string;
65
- location?: {
66
- file: string;
67
- line?: number | undefined;
68
- column?: number | undefined;
69
- } | undefined;
70
- }, {
71
- text: string;
72
- location?: {
73
- file: string;
74
- line?: number | undefined;
75
- column?: number | undefined;
76
- } | undefined;
77
- }>, "many">>;
78
- }, "strip", z.ZodTypeAny, {
79
- text: string;
80
- source: string;
81
- location?: {
82
- file: string;
83
- line?: number | undefined;
84
- column?: number | undefined;
85
- } | undefined;
86
- notes?: {
87
- text: string;
88
- location?: {
89
- file: string;
90
- line?: number | undefined;
91
- column?: number | undefined;
92
- } | undefined;
93
- }[] | undefined;
94
- }, {
95
- text: string;
96
- source: string;
97
- location?: {
98
- file: string;
99
- line?: number | undefined;
100
- column?: number | undefined;
101
- } | undefined;
102
- notes?: {
103
- text: string;
104
- location?: {
105
- file: string;
106
- line?: number | undefined;
107
- column?: number | undefined;
108
- } | undefined;
109
- }[] | undefined;
110
- }>;
111
- export type TaskMessage = z.infer<typeof ZodTaskMessage>;
10
+ text: z.ZodType<string, z.ZodTypeDef, string>;
11
+ source: z.ZodType<string, z.ZodTypeDef, string>;
12
+ location: z.ZodType<import("@ms-cloudpack/common-types").BundleMessageLocation | undefined, z.ZodTypeDef, import("@ms-cloudpack/common-types").BundleMessageLocation | undefined>;
13
+ notes: z.ZodType<BundleMessageNote[] | undefined, z.ZodTypeDef, BundleMessageNote[] | undefined>;
14
+ }, "strict", z.ZodTypeAny, BundleMessage, BundleMessage>;
112
15
  //# sourceMappingURL=TaskMessage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TaskMessage.d.ts","sourceRoot":"","sources":["../../src/types/TaskMessage.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAGpB,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGtB,CAAC;AAEH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKzB,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC"}
1
+ {"version":3,"file":"TaskMessage.d.ts","sourceRoot":"","sources":["../../src/types/TaskMessage.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AACpB,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAInF,MAAM,MAAM,QAAQ,GAAG,iBAAiB,CAAC;AAEzC,eAAO,MAAM,WAAW;;;gEAGtB,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,aAAa,CAAC;AAExC,eAAO,MAAM,cAAc;;;;;wDAKzB,CAAC"}
@@ -1,10 +1,11 @@
1
1
  import z from 'zod';
2
2
  import { ZodTaskMessageLocation } from './TaskMessageLocation.js';
3
- export const ZodTaskNote = z.object({
3
+ import { matchingZodObject } from '../utilities/matchingZodObject.js';
4
+ export const ZodTaskNote = matchingZodObject({
4
5
  text: z.string(),
5
6
  location: ZodTaskMessageLocation.optional(),
6
7
  });
7
- export const ZodTaskMessage = z.object({
8
+ export const ZodTaskMessage = matchingZodObject({
8
9
  text: z.string(),
9
10
  source: z.string(),
10
11
  location: ZodTaskMessageLocation.optional(),
@@ -1 +1 @@
1
- {"version":3,"file":"TaskMessage.js","sourceRoot":"","sources":["../../src/types/TaskMessage.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AACpB,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,QAAQ,EAAE,sBAAsB,CAAC,QAAQ,EAAE;CAC5C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAClB,QAAQ,EAAE,sBAAsB,CAAC,QAAQ,EAAE;IAC3C,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,QAAQ,EAAE;CACvC,CAAC,CAAC","sourcesContent":["import z from 'zod';\nimport { ZodTaskMessageLocation } from './TaskMessageLocation.js';\n\nexport const ZodTaskNote = z.object({\n text: z.string(),\n location: ZodTaskMessageLocation.optional(),\n});\n\nexport const ZodTaskMessage = z.object({\n text: z.string(),\n source: z.string(),\n location: ZodTaskMessageLocation.optional(),\n notes: z.array(ZodTaskNote).optional(),\n});\n\nexport type TaskMessage = z.infer<typeof ZodTaskMessage>;\n"]}
1
+ {"version":3,"file":"TaskMessage.js","sourceRoot":"","sources":["../../src/types/TaskMessage.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAItE,MAAM,CAAC,MAAM,WAAW,GAAG,iBAAiB,CAAW;IACrD,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,QAAQ,EAAE,sBAAsB,CAAC,QAAQ,EAAE;CAC5C,CAAC,CAAC;AAIH,MAAM,CAAC,MAAM,cAAc,GAAG,iBAAiB,CAAc;IAC3D,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAClB,QAAQ,EAAE,sBAAsB,CAAC,QAAQ,EAAE;IAC3C,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,QAAQ,EAAE;CACvC,CAAC,CAAC","sourcesContent":["import z from 'zod';\nimport type { BundleMessage, BundleMessageNote } from '@ms-cloudpack/common-types';\nimport { ZodTaskMessageLocation } from './TaskMessageLocation.js';\nimport { matchingZodObject } from '../utilities/matchingZodObject.js';\n\nexport type TaskNote = BundleMessageNote;\n\nexport const ZodTaskNote = matchingZodObject<TaskNote>({\n text: z.string(),\n location: ZodTaskMessageLocation.optional(),\n});\n\nexport type TaskMessage = BundleMessage;\n\nexport const ZodTaskMessage = matchingZodObject<TaskMessage>({\n text: z.string(),\n source: z.string(),\n location: ZodTaskMessageLocation.optional(),\n notes: z.array(ZodTaskNote).optional(),\n});\n"]}
@@ -1,16 +1,9 @@
1
1
  import z from 'zod';
2
+ import type { BundleMessageLocation } from '@ms-cloudpack/common-types';
3
+ export type TaskMessageLocation = BundleMessageLocation;
2
4
  export declare const ZodTaskMessageLocation: z.ZodObject<{
3
- file: z.ZodString;
4
- line: z.ZodOptional<z.ZodNumber>;
5
- column: z.ZodOptional<z.ZodNumber>;
6
- }, "strip", z.ZodTypeAny, {
7
- file: string;
8
- line?: number | undefined;
9
- column?: number | undefined;
10
- }, {
11
- file: string;
12
- line?: number | undefined;
13
- column?: number | undefined;
14
- }>;
15
- export type TaskMessageLocation = z.infer<typeof ZodTaskMessageLocation>;
5
+ file: z.ZodType<string, z.ZodTypeDef, string>;
6
+ line: z.ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
7
+ column: z.ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
8
+ }, "strict", z.ZodTypeAny, BundleMessageLocation, BundleMessageLocation>;
16
9
  //# sourceMappingURL=TaskMessageLocation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TaskMessageLocation.d.ts","sourceRoot":"","sources":["../../src/types/TaskMessageLocation.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,eAAO,MAAM,sBAAsB;;;;;;;;;;;;EAIjC,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC"}
1
+ {"version":3,"file":"TaskMessageLocation.d.ts","sourceRoot":"","sources":["../../src/types/TaskMessageLocation.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AACpB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAGxE,MAAM,MAAM,mBAAmB,GAAG,qBAAqB,CAAC;AAExD,eAAO,MAAM,sBAAsB;;;;wEAIjC,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import z from 'zod';
2
- export const ZodTaskMessageLocation = z.object({
2
+ import { matchingZodObject } from '../utilities/matchingZodObject.js';
3
+ export const ZodTaskMessageLocation = matchingZodObject({
3
4
  file: z.string(),
4
5
  line: z.number().optional(),
5
6
  column: z.number().optional(),
@@ -1 +1 @@
1
- {"version":3,"file":"TaskMessageLocation.js","sourceRoot":"","sources":["../../src/types/TaskMessageLocation.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7C,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC9B,CAAC,CAAC","sourcesContent":["import z from 'zod';\n\nexport const ZodTaskMessageLocation = z.object({\n file: z.string(),\n line: z.number().optional(),\n column: z.number().optional(),\n});\n\nexport type TaskMessageLocation = z.infer<typeof ZodTaskMessageLocation>;\n"]}
1
+ {"version":3,"file":"TaskMessageLocation.js","sourceRoot":"","sources":["../../src/types/TaskMessageLocation.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAItE,MAAM,CAAC,MAAM,sBAAsB,GAAG,iBAAiB,CAAsB;IAC3E,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC9B,CAAC,CAAC","sourcesContent":["import z from 'zod';\nimport type { BundleMessageLocation } from '@ms-cloudpack/common-types';\nimport { matchingZodObject } from '../utilities/matchingZodObject.js';\n\nexport type TaskMessageLocation = BundleMessageLocation;\n\nexport const ZodTaskMessageLocation = matchingZodObject<TaskMessageLocation>({\n file: z.string(),\n line: z.number().optional(),\n column: z.number().optional(),\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"TaskRunner.d.ts","sourceRoot":"","sources":["../../src/utilities/TaskRunner.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE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,CAAC,aAAa,CAAgC;IACrD,OAAO,CAAC,eAAe,CAAuB;IAC9C,OAAO,CAAC,cAAc,CAAc;IAEpC,OAAO,CAAC,UAAU,CAAyB;;IAW3C;;;;OAIG;IACI,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI;IAIvC;;;;;OAKG;IACH,GAAG,CAAC,OAAO,EACT,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,EACnB,OAAO,CAAC,EAAE;QACR,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,GACA,OAAO,CAAC,OAAO,CAAC;IAiEnB;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAgBxB;;OAEG;IACH,KAAK,IAAI,IAAI;IASb,2CAA2C;IAC3C,MAAM,IAAI,IAAI;IAId,sDAAsD;IACtD,MAAM,IAAI,IAAI;IAId;;OAEG;IACH,OAAO,CAAC,YAAY;IAoCpB;;OAEG;IACH,OAAO,CAAC,UAAU;CA8BnB"}
@@ -1,5 +1,4 @@
1
1
  import PQueue from 'p-queue';
2
- import { getDefaultTaskStats } from './getDefaultTaskStats.js';
3
2
  import { taskListSource, taskStatsSource } from '../index.browser.js';
4
3
  /**
5
4
  * TaskRunner tracks the status of tasks, manages concurrency, allows reusing task results,
@@ -188,4 +187,11 @@ export class TaskRunner {
188
187
  }
189
188
  }
190
189
  }
190
+ const getDefaultTaskStats = () => ({
191
+ status: 'idle',
192
+ remainingTasks: 0,
193
+ totalTasks: 0,
194
+ totalErrors: 0,
195
+ totalWarnings: 0,
196
+ });
191
197
  //# sourceMappingURL=TaskRunner.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TaskRunner.js","sourceRoot":"","sources":["../../src/utilities/TaskRunner.ts"],"names":[],"mappings":"AAKA,OAAO,MAAM,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,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E,KAAK,CAAC,KAAK,CAAC,GAAG;gBACb,GAAG,mBAAmB;gBACtB,GAAG,WAAW;gBACd,MAAM,EAAE,UAAU;gBAClB,oBAAoB,EAAE,GAAG,GAAG,mBAAmB,CAAC,SAAS;gBACzD,WAAW,EAAE,GAAG;aACjB,CAAC;YAEF,IAAI,IAAI,CAAC,UAAU,CAAC,cAAc,KAAK,CAAC,EAAE,CAAC;gBACzC,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,MAAM,CAAC;YAClC,CAAC;YAED,GAAG,CAAC,OAAO,CAAC,eAAe,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;YAC9C,GAAG,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;CACF","sourcesContent":["import type { TaskStartDescription } from '../types/TaskStartDescription.js';\nimport type { TaskEndDescription } from '../types/TaskEndDescription.js';\nimport type { Task } from '../types/Task.js';\nimport type { TaskStats } from '../types/TaskStats.js';\nimport type { TaskList } from '../types/TaskList.js';\nimport PQueue from 'p-queue';\nimport { getDefaultTaskStats } from './getDefaultTaskStats.js';\nimport { taskListSource, taskStatsSource, type TaskDescription } from '../index.browser.js';\nimport type { DataBus } from '@ms-cloudpack/data-bus';\n\n/**\n * TaskRunner tracks the status of tasks, manages concurrency, allows reusing task results,\n * and sends notifications about task status to the data bus (currently just used for `start`).\n *\n * NOTE: To enable data bus notifications, you must call `connectToBus()`.\n * `createApiContext` does this with the `taskRunner` passed in.\n */\nexport class TaskRunner {\n private _bus: DataBus | undefined;\n private _queue: PQueue;\n private _taskStats: TaskStats;\n private _pendingTasks: Map<string, Promise<unknown>>;\n private _completedTasks: Map<string, unknown>;\n private _requiresRerun: Set<string>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private _prevTasks: Map<string, Task<any>>;\n\n constructor() {\n this._queue = new PQueue({ concurrency: 10 });\n this._taskStats = getDefaultTaskStats();\n this._pendingTasks = new Map();\n this._completedTasks = new Map();\n this._requiresRerun = new Set();\n this._prevTasks = new Map();\n }\n\n /**\n * Connects the TaskRunner to the data bus. Tasks will still run without this, but they won't\n * send any notifications to a client (which only matters if a client is listening, e.g.\n * the browser while running `start`).\n */\n public connectToBus(bus: DataBus): void {\n this._bus = bus;\n }\n\n /**\n * Enqueue a task and return its result promise.\n *\n * If a task with the same `id` was already added, it returns either the previous result\n * (if completed) or the promise (if pending). Pass `options.rerun` to force re-running.\n */\n add<TReturn>(\n task: Task<TReturn>,\n options?: {\n rerun?: boolean;\n priority?: number;\n },\n ): Promise<TReturn> {\n const { name, id, execute } = task;\n const { rerun, priority } = options || {};\n\n if (!this._prevTasks.get(id)) {\n this._prevTasks.set(id, task);\n }\n\n // Check if we are already completed the task with that id.\n const action = this._completedTasks.get(id) as TReturn | undefined;\n if (action !== undefined && !rerun) {\n return Promise.resolve(action);\n }\n\n // Check if we are already running the task with that id.\n const pending = this._pendingTasks.get(id) as Promise<TReturn> | undefined;\n if (pending !== undefined) {\n if (rerun) {\n this._requiresRerun.add(id);\n }\n return pending;\n }\n\n const resultPromise: Promise<TReturn> = (async () => {\n let taskResult: TReturn | undefined;\n\n do {\n // Delete from rerun list (if present).\n this._requiresRerun.delete(id);\n\n taskResult = await this._queue.add(\n execute,\n // Removes void from return type.\n // Read more on: https://github.com/sindresorhus/p-queue/issues/175\n { throwOnTimeout: true, priority },\n );\n } while (this._requiresRerun.has(id));\n\n // Delete from pending list.\n this._pendingTasks.delete(id);\n if (task.getEndDescription) {\n this._reportEnd(id, task.getEndDescription(taskResult));\n }\n\n // Extra check to ensure that the task returned a value.\n // It should never throw, if it does we have a bug.\n if (taskResult === undefined) {\n throw new Error(`Task \"${name}:${id}\" returned undefined, without throwing an error, which was unexpected.`);\n }\n\n // Update finished Tasks.\n this._completedTasks.set(id, taskResult);\n\n return taskResult;\n })();\n\n this._pendingTasks.set(id, resultPromise);\n this._completedTasks.delete(id);\n if (task.getStartDescription) {\n this._reportStart(id, task.getStartDescription());\n }\n\n return resultPromise;\n }\n\n /**\n * The remove method disposes a task if available\n * and then removes it from the TaskRunner.\n *\n * This is useful when the state of a task needs to be cleared.\n *\n * It is intended to be used by the api server\n * to clear the TaskRunner's state before reloading the page.\n */\n remove(id: string): void {\n this._prevTasks\n .get(id)\n ?.dispose?.()\n .catch(() => {\n console.debug(`Error disposing task: ${id}`);\n });\n this._prevTasks.get(id)?.onDispose?.();\n this._prevTasks.delete(id);\n this._requiresRerun.delete(id);\n if (this._pendingTasks.has(id)) {\n this._pendingTasks.delete(id);\n this._taskStats.remainingTasks = this._pendingTasks.size;\n }\n this._completedTasks.delete(id);\n }\n /**\n * The clear method disposes all tasks and clears the TaskRunner.\n */\n clear(): void {\n this._taskStats = getDefaultTaskStats();\n this._bus?.publish(taskListSource, { tasks: [] });\n\n for (const id of this._prevTasks.keys()) {\n this.remove(id);\n }\n }\n\n /** Pauses the TaskRunner (for testing). */\n _pause(): void {\n this._queue.pause();\n }\n\n /** Starts or resumes the TaskRunner (for testing). */\n _start(): void {\n this._queue.start();\n }\n\n /**\n * Internal method to report the start of a task to the bus.\n */\n private _reportStart(id: string, description: TaskStartDescription): void {\n if (!this._bus) return;\n\n const bus = this._bus;\n const { tasks } = bus.getData<TaskList>(taskListSource.path) || { tasks: [] };\n const index = tasks.findIndex((t) => t.id === id);\n const previousDescription = tasks[index];\n const now = new Date().getTime();\n\n if (!previousDescription) {\n this._taskStats.totalTasks++;\n }\n\n if (previousDescription?.status === 'complete') {\n this._taskStats.totalErrors -= previousDescription.errors?.length || 0;\n this._taskStats.totalWarnings -= previousDescription.warnings?.length || 0;\n }\n\n this._taskStats.remainingTasks = this._pendingTasks.size;\n this._taskStats.status = 'pending';\n\n const task: TaskDescription = {\n ...description,\n status: 'pending',\n startTime: now,\n };\n if (index === -1) {\n tasks.push(task);\n } else {\n tasks[index] = task;\n }\n\n bus.publish(taskStatsSource, this._taskStats);\n bus.publish(taskListSource, { tasks });\n }\n\n /**\n * Internal method to report the end of a task to the bus.\n */\n private _reportEnd(id: string, description: TaskEndDescription): void {\n if (!this._bus) return;\n\n const bus = this._bus;\n const { tasks } = bus.getData<TaskList>(taskListSource.path) || { tasks: [] };\n const index = tasks.findIndex((t) => t.id === id);\n const previousDescription = tasks[index];\n const now = new Date().getTime();\n\n if (previousDescription) {\n this._taskStats.remainingTasks = this._pendingTasks.size;\n this._taskStats.totalErrors += description?.errors?.length || 0;\n this._taskStats.totalWarnings += description?.warnings?.length || 0;\n\n tasks[index] = {\n ...previousDescription,\n ...description,\n status: 'complete',\n durationMilliseconds: now - previousDescription.startTime,\n lastUpdated: now,\n };\n\n if (this._taskStats.remainingTasks === 0) {\n this._taskStats.status = 'idle';\n }\n\n bus.publish(taskStatsSource, this._taskStats);\n bus.publish(taskListSource, { tasks });\n }\n }\n}\n"]}
1
+ {"version":3,"file":"TaskRunner.js","sourceRoot":"","sources":["../../src/utilities/TaskRunner.ts"],"names":[],"mappings":"AAKA,OAAO,MAAM,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,eAAe,EAAwB,MAAM,qBAAqB,CAAC;AAG5F;;;;;;GAMG;AACH,MAAM,OAAO,UAAU;IAUrB;QACE,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,CAAC;QAC9C,IAAI,CAAC,UAAU,GAAG,mBAAmB,EAAE,CAAC;QACxC,IAAI,CAAC,aAAa,GAAG,IAAI,GAAG,EAAE,CAAC;QAC/B,IAAI,CAAC,eAAe,GAAG,IAAI,GAAG,EAAE,CAAC;QACjC,IAAI,CAAC,cAAc,GAAG,IAAI,GAAG,EAAE,CAAC;QAChC,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,EAAE,CAAC;IAC9B,CAAC;IAED;;;;OAIG;IACI,YAAY,CAAC,GAAY;QAC9B,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;IAClB,CAAC;IAED;;;;;OAKG;IACH,GAAG,CAC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U,EAAE,CAAC;IACb,WAAW,EAAE,CAAC;IACd,aAAa,EAAE,CAAC;CACjB,CAAC,CAAC","sourcesContent":["import type { TaskStartDescription } from '../types/TaskStartDescription.js';\nimport type { TaskEndDescription } from '../types/TaskEndDescription.js';\nimport type { Task } from '../types/Task.js';\nimport type { TaskStats } from '../types/TaskStats.js';\nimport type { TaskList } from '../types/TaskList.js';\nimport PQueue from 'p-queue';\nimport { taskListSource, taskStatsSource, type TaskDescription } from '../index.browser.js';\nimport type { DataBus } from '@ms-cloudpack/data-bus';\n\n/**\n * TaskRunner tracks the status of tasks, manages concurrency, allows reusing task results,\n * and sends notifications about task status to the data bus (currently just used for `start`).\n *\n * NOTE: To enable data bus notifications, you must call `connectToBus()`.\n * `createApiContext` does this with the `taskRunner` passed in.\n */\nexport class TaskRunner {\n private _bus: DataBus | undefined;\n private _queue: PQueue;\n private _taskStats: TaskStats;\n private _pendingTasks: Map<string, Promise<unknown>>;\n private _completedTasks: Map<string, unknown>;\n private _requiresRerun: Set<string>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private _prevTasks: Map<string, Task<any>>;\n\n constructor() {\n this._queue = new PQueue({ concurrency: 10 });\n this._taskStats = getDefaultTaskStats();\n this._pendingTasks = new Map();\n this._completedTasks = new Map();\n this._requiresRerun = new Set();\n this._prevTasks = new Map();\n }\n\n /**\n * Connects the TaskRunner to the data bus. Tasks will still run without this, but they won't\n * send any notifications to a client (which only matters if a client is listening, e.g.\n * the browser while running `start`).\n */\n public connectToBus(bus: DataBus): void {\n this._bus = bus;\n }\n\n /**\n * Enqueue a task and return its result promise.\n *\n * If a task with the same `id` was already added, it returns either the previous result\n * (if completed) or the promise (if pending). Pass `options.rerun` to force re-running.\n */\n add<TReturn>(\n task: Task<TReturn>,\n options?: {\n rerun?: boolean;\n priority?: number;\n },\n ): Promise<TReturn> {\n const { name, id, execute } = task;\n const { rerun, priority } = options || {};\n\n if (!this._prevTasks.get(id)) {\n this._prevTasks.set(id, task);\n }\n\n // Check if we are already completed the task with that id.\n const action = this._completedTasks.get(id) as TReturn | undefined;\n if (action !== undefined && !rerun) {\n return Promise.resolve(action);\n }\n\n // Check if we are already running the task with that id.\n const pending = this._pendingTasks.get(id) as Promise<TReturn> | undefined;\n if (pending !== undefined) {\n if (rerun) {\n this._requiresRerun.add(id);\n }\n return pending;\n }\n\n const resultPromise: Promise<TReturn> = (async () => {\n let taskResult: TReturn | undefined;\n\n do {\n // Delete from rerun list (if present).\n this._requiresRerun.delete(id);\n\n taskResult = await this._queue.add(\n execute,\n // Removes void from return type.\n // Read more on: https://github.com/sindresorhus/p-queue/issues/175\n { throwOnTimeout: true, priority },\n );\n } while (this._requiresRerun.has(id));\n\n // Delete from pending list.\n this._pendingTasks.delete(id);\n if (task.getEndDescription) {\n this._reportEnd(id, task.getEndDescription(taskResult));\n }\n\n // Extra check to ensure that the task returned a value.\n // It should never throw, if it does we have a bug.\n if (taskResult === undefined) {\n throw new Error(`Task \"${name}:${id}\" returned undefined, without throwing an error, which was unexpected.`);\n }\n\n // Update finished Tasks.\n this._completedTasks.set(id, taskResult);\n\n return taskResult;\n })();\n\n this._pendingTasks.set(id, resultPromise);\n this._completedTasks.delete(id);\n if (task.getStartDescription) {\n this._reportStart(id, task.getStartDescription());\n }\n\n return resultPromise;\n }\n\n /**\n * The remove method disposes a task if available\n * and then removes it from the TaskRunner.\n *\n * This is useful when the state of a task needs to be cleared.\n *\n * It is intended to be used by the api server\n * to clear the TaskRunner's state before reloading the page.\n */\n remove(id: string): void {\n this._prevTasks\n .get(id)\n ?.dispose?.()\n .catch(() => {\n console.debug(`Error disposing task: ${id}`);\n });\n this._prevTasks.get(id)?.onDispose?.();\n this._prevTasks.delete(id);\n this._requiresRerun.delete(id);\n if (this._pendingTasks.has(id)) {\n this._pendingTasks.delete(id);\n this._taskStats.remainingTasks = this._pendingTasks.size;\n }\n this._completedTasks.delete(id);\n }\n /**\n * The clear method disposes all tasks and clears the TaskRunner.\n */\n clear(): void {\n this._taskStats = getDefaultTaskStats();\n this._bus?.publish(taskListSource, { tasks: [] });\n\n for (const id of this._prevTasks.keys()) {\n this.remove(id);\n }\n }\n\n /** Pauses the TaskRunner (for testing). */\n _pause(): void {\n this._queue.pause();\n }\n\n /** Starts or resumes the TaskRunner (for testing). */\n _start(): void {\n this._queue.start();\n }\n\n /**\n * Internal method to report the start of a task to the bus.\n */\n private _reportStart(id: string, description: TaskStartDescription): void {\n if (!this._bus) return;\n\n const bus = this._bus;\n const { tasks } = bus.getData<TaskList>(taskListSource.path) || { tasks: [] };\n const index = tasks.findIndex((t) => t.id === id);\n const previousDescription = tasks[index];\n const now = new Date().getTime();\n\n if (!previousDescription) {\n this._taskStats.totalTasks++;\n }\n\n if (previousDescription?.status === 'complete') {\n this._taskStats.totalErrors -= previousDescription.errors?.length || 0;\n this._taskStats.totalWarnings -= previousDescription.warnings?.length || 0;\n }\n\n this._taskStats.remainingTasks = this._pendingTasks.size;\n this._taskStats.status = 'pending';\n\n const task: TaskDescription = {\n ...description,\n status: 'pending',\n startTime: now,\n };\n if (index === -1) {\n tasks.push(task);\n } else {\n tasks[index] = task;\n }\n\n bus.publish(taskStatsSource, this._taskStats);\n bus.publish(taskListSource, { tasks });\n }\n\n /**\n * Internal method to report the end of a task to the bus.\n */\n private _reportEnd(id: string, description: TaskEndDescription): void {\n if (!this._bus) return;\n\n const bus = this._bus;\n const { tasks } = bus.getData<TaskList>(taskListSource.path) || { tasks: [] };\n const index = tasks.findIndex((t) => t.id === id);\n const previousDescription = tasks[index];\n const now = new Date().getTime();\n\n if (previousDescription) {\n this._taskStats.remainingTasks = this._pendingTasks.size;\n this._taskStats.totalErrors += description?.errors?.length || 0;\n this._taskStats.totalWarnings += description?.warnings?.length || 0;\n\n tasks[index] = {\n ...previousDescription,\n ...description,\n status: 'complete',\n durationMilliseconds: now - previousDescription.startTime,\n lastUpdated: now,\n };\n\n if (this._taskStats.remainingTasks === 0) {\n this._taskStats.status = 'idle';\n }\n\n bus.publish(taskStatsSource, this._taskStats);\n bus.publish(taskListSource, { tasks });\n }\n }\n}\n\nconst getDefaultTaskStats: () => TaskStats = () => ({\n status: 'idle',\n remainingTasks: 0,\n totalTasks: 0,\n totalErrors: 0,\n totalWarnings: 0,\n});\n"]}
@@ -9,6 +9,10 @@ type MatchingZodShape<T extends object> = {
9
9
  type MatchingZodObject<T extends object> = z.ZodObject<MatchingZodShape<T>, 'strict', z.ZodTypeAny, T, T>;
10
10
  /**
11
11
  * Get a Zod object that strictly matches the expected type, including any optional properties.
12
+ *
13
+ * Defining TS types first and using this helper to ensure matching zod objects (rather than
14
+ * defining the zod type first and using `infer`) helps reduce type explosion in intellisense
15
+ * and API reports, and allows reusing types that are already defined elsewhere.
12
16
  */
13
17
  export declare function matchingZodObject<Expected extends object>(shape: MatchingZodShape<Expected>): MatchingZodObject<Expected>;
14
18
  export {};