semola 0.5.4 → 0.6.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/README.md +18 -45
- package/dist/chunk-CKQMccvm.cjs +28 -0
- package/dist/lib/api/index.cjs +29 -15
- package/dist/lib/api/index.mjs +30 -16
- package/dist/lib/cache/index.cjs +47 -22
- package/dist/lib/cache/index.d.cts +3 -24
- package/dist/lib/cache/index.d.mts +3 -24
- package/dist/lib/cache/index.mjs +48 -23
- package/dist/lib/cron/index.cjs +117 -117
- package/dist/lib/cron/index.mjs +118 -118
- package/dist/lib/errors/index.d.cts +12 -1
- package/dist/lib/errors/index.d.mts +12 -1
- package/dist/lib/logging/index.cjs +1 -0
- package/dist/lib/orm/index.cjs +1642 -0
- package/dist/lib/orm/index.d.cts +402 -0
- package/dist/lib/orm/index.d.mts +402 -0
- package/dist/lib/orm/index.mjs +1630 -0
- package/dist/lib/prompts/index.cjs +89 -89
- package/dist/lib/prompts/index.d.cts +12 -33
- package/dist/lib/prompts/index.d.mts +12 -33
- package/dist/lib/prompts/index.mjs +89 -90
- package/dist/lib/pubsub/index.cjs +43 -19
- package/dist/lib/pubsub/index.d.cts +3 -18
- package/dist/lib/pubsub/index.d.mts +3 -18
- package/dist/lib/pubsub/index.mjs +44 -20
- package/dist/lib/queue/index.cjs +40 -10
- package/dist/lib/queue/index.d.cts +11 -4
- package/dist/lib/queue/index.d.mts +11 -4
- package/dist/lib/queue/index.mjs +39 -11
- package/dist/lib/workflow/index.cjs +285 -282
- package/dist/lib/workflow/index.d.cts +76 -11
- package/dist/lib/workflow/index.d.mts +76 -11
- package/dist/lib/workflow/index.mjs +278 -284
- package/package.json +11 -1
- package/dist/index-BhGNDjPq.d.mts +0 -13
- package/dist/index-DxSbeGP-.d.cts +0 -13
package/dist/lib/cron/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { mightThrow } from "../errors/index.mjs";
|
|
2
2
|
//#region src/lib/cron/builder/index.ts
|
|
3
3
|
const CRON_FIELD_ORDER = [
|
|
4
4
|
"second",
|
|
@@ -184,6 +184,38 @@ const Month = {
|
|
|
184
184
|
dec: 12
|
|
185
185
|
};
|
|
186
186
|
//#endregion
|
|
187
|
+
//#region src/lib/cron/errors.ts
|
|
188
|
+
var InvalidValueError = class extends Error {
|
|
189
|
+
constructor(message) {
|
|
190
|
+
super(message);
|
|
191
|
+
this.name = "InvalidValueError";
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
var OutOfBoundError = class extends Error {
|
|
195
|
+
constructor(message) {
|
|
196
|
+
super(message);
|
|
197
|
+
this.name = "OutOfBoundError";
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
var CronExpressionError = class extends Error {
|
|
201
|
+
constructor(message) {
|
|
202
|
+
super(message);
|
|
203
|
+
this.name = "CronExpressionError";
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
var EmptyCronExpressionError = class extends Error {
|
|
207
|
+
constructor(message) {
|
|
208
|
+
super(message);
|
|
209
|
+
this.name = "EmptyCronExpressionError";
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
var CronLengthError = class extends Error {
|
|
213
|
+
constructor(message) {
|
|
214
|
+
super(message);
|
|
215
|
+
this.name = "CronLengthError";
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
//#endregion
|
|
187
219
|
//#region src/lib/cron/core/scanner.ts
|
|
188
220
|
const FieldAmount = {
|
|
189
221
|
min: 5,
|
|
@@ -236,21 +268,20 @@ var Scanner = class {
|
|
|
236
268
|
this.tokens = [];
|
|
237
269
|
}
|
|
238
270
|
scan() {
|
|
239
|
-
if (this.expression.length === 0)
|
|
271
|
+
if (this.expression.length === 0) throw new EmptyCronExpressionError("Cron expression have zero length");
|
|
240
272
|
const fields = this.expression.trim().split(/\s+/);
|
|
241
273
|
const hasMinLen = fields.length === FieldAmount.min;
|
|
242
274
|
const hasMaxLen = fields.length === FieldAmount.max;
|
|
243
|
-
if (!hasMinLen && !hasMaxLen)
|
|
275
|
+
if (!hasMinLen && !hasMaxLen) throw new CronLengthError(`Invalid number of fields for '${this.expression}'. Expected 5 or 6 fields but got ${fields.length} field(s)`);
|
|
244
276
|
const components = this.createComponent(fields);
|
|
245
277
|
for (let idx = 0; idx < components.length; idx++) {
|
|
246
278
|
const component = components[idx];
|
|
247
|
-
if (!component)
|
|
279
|
+
if (!component) throw new CronExpressionError(`Invalid cron expression: ${this.expression}`);
|
|
248
280
|
this.current = 0;
|
|
249
281
|
this.start = 0;
|
|
250
|
-
|
|
251
|
-
if (error) return err(error.type, error.message);
|
|
282
|
+
this.scanComponent(component);
|
|
252
283
|
}
|
|
253
|
-
return
|
|
284
|
+
return this.tokens;
|
|
254
285
|
}
|
|
255
286
|
scanComponent(component) {
|
|
256
287
|
const { field, content } = component;
|
|
@@ -259,36 +290,30 @@ var Scanner = class {
|
|
|
259
290
|
switch (currentCh) {
|
|
260
291
|
case "*": {
|
|
261
292
|
const ch = this.peek(content);
|
|
262
|
-
if (this.match(content, "/"))
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
} else if (!ch || ch === ",") this.addToken("*", "any", "*", field);
|
|
266
|
-
else return err("CronExpressionError", `Invalid any expression '${content}' for field '${field}'`);
|
|
293
|
+
if (this.match(content, "/")) this.handleStep(component);
|
|
294
|
+
else if (!ch || ch === ",") this.addToken("*", "any", "*", field);
|
|
295
|
+
else throw new CronExpressionError(`Invalid any expression '${content}' for field '${field}'`);
|
|
267
296
|
break;
|
|
268
297
|
}
|
|
269
298
|
case "-":
|
|
270
299
|
currentCh = this.advance(content);
|
|
271
|
-
if (this.isDigit(currentCh))
|
|
272
|
-
|
|
273
|
-
if (error) return err(error.type, error.message);
|
|
274
|
-
} else return err("CronExpressionError", `Invalid range expression '${content}' for field '${field}'`);
|
|
300
|
+
if (this.isDigit(currentCh)) this.handleRangeWithStep(component);
|
|
301
|
+
else throw new CronExpressionError(`Invalid range expression '${content}' for field '${field}'`);
|
|
275
302
|
break;
|
|
276
303
|
case ",": {
|
|
277
|
-
if (this.current === 1 && this.start === 0)
|
|
304
|
+
if (this.current === 1 && this.start === 0) throw new CronExpressionError(`Invalid list expression '${content}' for field '${field}'`);
|
|
278
305
|
const next = this.peek(content);
|
|
279
|
-
if (!next || next === ",")
|
|
306
|
+
if (!next || next === ",") throw new CronExpressionError(`Invalid list expression '${content}' for field '${field}'`);
|
|
280
307
|
break;
|
|
281
308
|
}
|
|
282
309
|
default:
|
|
283
|
-
if (this.isDigit(currentCh))
|
|
284
|
-
|
|
285
|
-
if (error) return err(error.type, error.message);
|
|
286
|
-
} else return err("CronExpressionError", `Invalid cron expression '${this.expression}' in field '${field}'`);
|
|
310
|
+
if (this.isDigit(currentCh)) this.handleNumber(component);
|
|
311
|
+
else throw new CronExpressionError(`Invalid cron expression '${this.expression}' in field '${field}'`);
|
|
287
312
|
break;
|
|
288
313
|
}
|
|
289
314
|
this.start = this.current;
|
|
290
315
|
}
|
|
291
|
-
return
|
|
316
|
+
return true;
|
|
292
317
|
}
|
|
293
318
|
addToken(component, type, value, field) {
|
|
294
319
|
const token = new Token(component, type, value, field);
|
|
@@ -317,12 +342,12 @@ var Scanner = class {
|
|
|
317
342
|
this.advance(content);
|
|
318
343
|
ch = this.peek(content);
|
|
319
344
|
}
|
|
320
|
-
if (ch && ch !== ",")
|
|
345
|
+
if (ch && ch !== ",") throw new CronExpressionError(`Invalid step expression '${content}' for field '${field}'`);
|
|
321
346
|
const tokenContent = content.substring(this.start, this.current);
|
|
322
347
|
const value = content.slice(slashIdx + 1, this.current);
|
|
323
|
-
if (value.length === 0)
|
|
348
|
+
if (value.length === 0) throw new CronExpressionError(`Invalid step expression '${content}' for field '${field}'`);
|
|
324
349
|
this.addToken(tokenContent, "step", Number(value), field);
|
|
325
|
-
return
|
|
350
|
+
return true;
|
|
326
351
|
}
|
|
327
352
|
handleRangeWithStep(component) {
|
|
328
353
|
const { field, content } = component;
|
|
@@ -331,13 +356,12 @@ var Scanner = class {
|
|
|
331
356
|
this.advance(content);
|
|
332
357
|
ch = this.peek(content);
|
|
333
358
|
}
|
|
334
|
-
if (!ch)
|
|
359
|
+
if (!ch) throw new CronExpressionError(`Invalid range expression '${content}' for field '${field}'`);
|
|
335
360
|
if (this.match(content, "/")) {
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
return ok(true);
|
|
361
|
+
this.handleStep(component);
|
|
362
|
+
return true;
|
|
339
363
|
}
|
|
340
|
-
|
|
364
|
+
throw new CronExpressionError(`Invalid range expression '${content}' for field '${field}'`);
|
|
341
365
|
}
|
|
342
366
|
handleNumber(component) {
|
|
343
367
|
const { field, content } = component;
|
|
@@ -350,27 +374,25 @@ var Scanner = class {
|
|
|
350
374
|
if (!ch) {
|
|
351
375
|
const item = content.substring(this.start);
|
|
352
376
|
this.addToken(item, "number", Number(item), field);
|
|
353
|
-
return
|
|
377
|
+
return true;
|
|
354
378
|
}
|
|
355
379
|
if (this.match(content, "-")) {
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
return ok(true);
|
|
380
|
+
this.handleRange(component);
|
|
381
|
+
return true;
|
|
359
382
|
}
|
|
360
383
|
if (this.match(content, "/")) {
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
return ok(true);
|
|
384
|
+
this.handleStep(component);
|
|
385
|
+
return true;
|
|
364
386
|
}
|
|
365
|
-
if (!this.isDigit(ch) && ch !== ",")
|
|
387
|
+
if (!this.isDigit(ch) && ch !== ",") throw new CronExpressionError(`Invalid number '${content}' for field '${field}'`);
|
|
366
388
|
const item = content.substring(this.start, this.current);
|
|
367
389
|
this.addToken(item, "number", Number(item), field);
|
|
368
|
-
return
|
|
390
|
+
return true;
|
|
369
391
|
}
|
|
370
392
|
handleRange(component) {
|
|
371
393
|
const { field, content } = component;
|
|
372
394
|
let ch = this.peek(content);
|
|
373
|
-
if (!ch)
|
|
395
|
+
if (!ch) throw new CronExpressionError(`Invalid range expression '${content}' for field '${field}'`);
|
|
374
396
|
while (ch && this.isDigit(ch)) {
|
|
375
397
|
this.advance(content);
|
|
376
398
|
ch = this.peek(content);
|
|
@@ -378,17 +400,16 @@ var Scanner = class {
|
|
|
378
400
|
if (!ch) {
|
|
379
401
|
const tokenContent = content.substring(this.start);
|
|
380
402
|
this.addToken(tokenContent, "range", tokenContent, field);
|
|
381
|
-
return
|
|
403
|
+
return true;
|
|
382
404
|
}
|
|
383
405
|
if (this.match(content, "/")) {
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
return ok(true);
|
|
406
|
+
this.handleStep(component);
|
|
407
|
+
return true;
|
|
387
408
|
}
|
|
388
|
-
if (ch && ch !== ",")
|
|
409
|
+
if (ch && ch !== ",") throw new CronExpressionError(`Invalid range expression '${content}' for field '${field}'`);
|
|
389
410
|
const tokenContent = content.substring(this.start, this.current);
|
|
390
411
|
this.addToken(tokenContent, "range", tokenContent, field);
|
|
391
|
-
return
|
|
412
|
+
return true;
|
|
392
413
|
}
|
|
393
414
|
isDigit(ch) {
|
|
394
415
|
return ch >= "0" && ch <= "9";
|
|
@@ -471,70 +492,67 @@ var Cron = class {
|
|
|
471
492
|
}
|
|
472
493
|
handleStep(part, values, min, max) {
|
|
473
494
|
const [rangePart, stepStr] = part.split("/");
|
|
474
|
-
if (!rangePart)
|
|
475
|
-
if (!stepStr)
|
|
495
|
+
if (!rangePart) throw new InvalidValueError(`'${rangePart}' is empty`);
|
|
496
|
+
if (!stepStr) throw new InvalidValueError(`'${stepStr}' is empty`);
|
|
476
497
|
const step = Number(stepStr);
|
|
477
|
-
if (!Number.isInteger(step))
|
|
478
|
-
if (step <= 0)
|
|
498
|
+
if (!Number.isInteger(step)) throw new InvalidValueError(`'${step}' is not a valid number`);
|
|
499
|
+
if (step <= 0) throw new OutOfBoundError(`Expected ${step} > 0`);
|
|
479
500
|
if (rangePart === "*") {
|
|
480
501
|
for (let i = min; i <= max; i += step) values[i] = 1;
|
|
481
|
-
return
|
|
502
|
+
return;
|
|
482
503
|
}
|
|
483
|
-
if (rangePart.includes("-"))
|
|
484
|
-
|
|
504
|
+
if (rangePart.includes("-")) {
|
|
505
|
+
this.handleStepRange(rangePart, step, values, min, max);
|
|
506
|
+
return;
|
|
507
|
+
}
|
|
508
|
+
this.handleStepSingle(rangePart, step, values, min, max);
|
|
485
509
|
}
|
|
486
510
|
handleStepRange(range, step, values, min, max) {
|
|
487
511
|
const [startStr, endStr] = range.split("-");
|
|
488
|
-
if (!endStr)
|
|
512
|
+
if (!endStr) throw new InvalidValueError(`'${endStr}' is empty`);
|
|
489
513
|
let start = min;
|
|
490
514
|
if (startStr && startStr.length > 0) start = Number(startStr);
|
|
491
515
|
const end = Number(endStr);
|
|
492
|
-
if (!Number.isInteger(start))
|
|
493
|
-
if (!Number.isInteger(end))
|
|
494
|
-
if (start < min)
|
|
495
|
-
if (end > max)
|
|
496
|
-
if (start > end)
|
|
516
|
+
if (!Number.isInteger(start)) throw new InvalidValueError(`'${start}' is not a valid number`);
|
|
517
|
+
if (!Number.isInteger(end)) throw new InvalidValueError(`'${end}' is not a valid number`);
|
|
518
|
+
if (start < min) throw new OutOfBoundError(`Expected ${start} >= ${min}`);
|
|
519
|
+
if (end > max) throw new OutOfBoundError(`Expected ${end} <= ${max}`);
|
|
520
|
+
if (start > end) throw new OutOfBoundError(`Expected ${start} <= ${end}`);
|
|
497
521
|
for (let i = start; i <= end; i += step) values[i] = 1;
|
|
498
|
-
return ok(true);
|
|
499
522
|
}
|
|
500
523
|
handleStepSingle(value, step, values, min, max) {
|
|
501
524
|
const start = Number(value);
|
|
502
|
-
if (!Number.isInteger(start))
|
|
503
|
-
if (start < min)
|
|
504
|
-
if (start > max)
|
|
525
|
+
if (!Number.isInteger(start)) throw new InvalidValueError(`'${start}' is not a valid number`);
|
|
526
|
+
if (start < min) throw new OutOfBoundError(`Expected ${start} >= ${min}`);
|
|
527
|
+
if (start > max) throw new OutOfBoundError(`Expected ${start} <= ${max}`);
|
|
505
528
|
for (let i = start; i <= max; i += step) values[i] = 1;
|
|
506
|
-
return ok(true);
|
|
507
529
|
}
|
|
508
530
|
handleRange(part, values, min, max) {
|
|
509
531
|
const [startStr, endStr] = part.split("-");
|
|
510
|
-
if (!startStr)
|
|
511
|
-
if (!endStr)
|
|
532
|
+
if (!startStr) throw new InvalidValueError(`'${startStr}' is empty`);
|
|
533
|
+
if (!endStr) throw new InvalidValueError(`'${endStr}' is empty`);
|
|
512
534
|
const start = Number(startStr);
|
|
513
535
|
const end = Number(endStr);
|
|
514
|
-
if (!Number.isInteger(start))
|
|
515
|
-
if (!Number.isInteger(end))
|
|
516
|
-
if (start < min)
|
|
517
|
-
if (end > max)
|
|
518
|
-
if (start > end)
|
|
536
|
+
if (!Number.isInteger(start)) throw new InvalidValueError(`'${start}' is not a valid number`);
|
|
537
|
+
if (!Number.isInteger(end)) throw new InvalidValueError(`'${end}' is not a valid number`);
|
|
538
|
+
if (start < min) throw new OutOfBoundError(`Expected ${start} >= ${min}`);
|
|
539
|
+
if (end > max) throw new OutOfBoundError(`Expected ${end} <= ${max}`);
|
|
540
|
+
if (start > end) throw new OutOfBoundError(`Expected ${start} <= ${end}`);
|
|
519
541
|
for (let i = start; i <= end; i++) values[i] = 1;
|
|
520
|
-
return ok(true);
|
|
521
542
|
}
|
|
522
543
|
handleNumber(value, values, min, max) {
|
|
523
544
|
const n = Number(value);
|
|
524
|
-
if (!Number.isInteger(n))
|
|
525
|
-
if (n < min)
|
|
526
|
-
if (n > max)
|
|
545
|
+
if (!Number.isInteger(n)) throw new InvalidValueError(`'${value}' is not a valid number`);
|
|
546
|
+
if (n < min) throw new OutOfBoundError(`Expected ${n} >= ${min}`);
|
|
547
|
+
if (n > max) throw new OutOfBoundError(`Expected ${n} <= ${max}`);
|
|
527
548
|
values[n] = 1;
|
|
528
|
-
return ok(true);
|
|
529
549
|
}
|
|
530
550
|
constructor(options) {
|
|
531
551
|
this.options = options;
|
|
532
552
|
const expr = this.resolveAlias(options.schedule);
|
|
533
|
-
const
|
|
534
|
-
if (error) throw new Error(`${error.type}: ${error.message}`);
|
|
553
|
+
const tokens = new Scanner(expr).scan();
|
|
535
554
|
this.hasSeconds = expr.trim().split(/\s+/).length === FieldAmount.max;
|
|
536
|
-
|
|
537
|
-
if (parsingError) throw new Error(`${parsingError.type}: ${parsingError.message}`);
|
|
555
|
+
this.parse(tokens);
|
|
538
556
|
}
|
|
539
557
|
resolveAlias(schedule) {
|
|
540
558
|
return ALIASES[schedule] || schedule;
|
|
@@ -542,71 +560,53 @@ var Cron = class {
|
|
|
542
560
|
parse(tokens) {
|
|
543
561
|
for (let i = 0; i < tokens.length; i++) {
|
|
544
562
|
const token = tokens[i];
|
|
545
|
-
if (!token)
|
|
563
|
+
if (!token) throw new InvalidValueError("Undefined token");
|
|
546
564
|
const tokenType = token.getTokenType();
|
|
547
565
|
switch (token.getField()) {
|
|
548
|
-
case "second":
|
|
549
|
-
|
|
550
|
-
if (error) return err(error.type, `${error.message} in field '${token.getField()}'`);
|
|
566
|
+
case "second":
|
|
567
|
+
this.handleField(token, this.second, CronSecondRange.min, CronSecondRange.max);
|
|
551
568
|
break;
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
const [error, _] = this.handleField(token, this.minute, CronMinuteRange.min, CronMinuteRange.max);
|
|
555
|
-
if (error) return err(error.type, `${error.message} in field '${token.getField()}'`);
|
|
569
|
+
case "minute":
|
|
570
|
+
this.handleField(token, this.minute, CronMinuteRange.min, CronMinuteRange.max);
|
|
556
571
|
break;
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
const [error, _] = this.handleField(token, this.hour, CronHourRange.min, CronHourRange.max);
|
|
560
|
-
if (error) return err(error.type, `${error.message} in field '${token.getField()}'`);
|
|
572
|
+
case "hour":
|
|
573
|
+
this.handleField(token, this.hour, CronHourRange.min, CronHourRange.max);
|
|
561
574
|
break;
|
|
562
|
-
|
|
563
|
-
case "day": {
|
|
575
|
+
case "day":
|
|
564
576
|
if (tokenType === "any") this._dayWildcard = true;
|
|
565
|
-
|
|
566
|
-
if (error) return err(error.type, `${error.message} in field '${token.getField()}'`);
|
|
577
|
+
this.handleField(token, this.day, CronDayRange.min, CronDayRange.max);
|
|
567
578
|
break;
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
const [error, _] = this.handleField(token, this.month, CronMonthRange.min, CronMonthRange.max);
|
|
571
|
-
if (error) return err(error.type, `${error.message} in field '${token.getField()}'`);
|
|
579
|
+
case "month":
|
|
580
|
+
this.handleField(token, this.month, CronMonthRange.min, CronMonthRange.max);
|
|
572
581
|
break;
|
|
573
|
-
|
|
574
|
-
case "weekday": {
|
|
582
|
+
case "weekday":
|
|
575
583
|
if (tokenType === "any") this._dowWildcard = true;
|
|
576
|
-
|
|
577
|
-
if (error) return err(error.type, `${error.message} in field '${token.getField()}'`);
|
|
584
|
+
this.handleField(token, this.dayOfWeek, CronDayOfWeekRange.min, CronDayOfWeekRange.max);
|
|
578
585
|
break;
|
|
579
|
-
}
|
|
580
|
-
default: return err("InvalidValueError", `Invalid field '${token.getField()}'`);
|
|
586
|
+
default: throw new InvalidValueError(`Invalid field '${token.getField()}'`);
|
|
581
587
|
}
|
|
582
588
|
}
|
|
583
|
-
return ok(true);
|
|
584
589
|
}
|
|
585
590
|
handleField(token, field, min, max) {
|
|
586
591
|
switch (token.getTokenType()) {
|
|
587
592
|
case "any":
|
|
588
593
|
this.fillRange(field, min, max);
|
|
589
594
|
break;
|
|
590
|
-
case "number":
|
|
591
|
-
|
|
592
|
-
if (error) return err(error.type, error.message);
|
|
595
|
+
case "number":
|
|
596
|
+
this.handleNumber(token.getComponent(), field, min, max);
|
|
593
597
|
break;
|
|
594
|
-
}
|
|
595
598
|
case "range": {
|
|
596
599
|
const component = token.getComponent();
|
|
597
|
-
|
|
598
|
-
if (error) return err(error.type, error.message);
|
|
600
|
+
this.handleRange(component, field, min, max);
|
|
599
601
|
break;
|
|
600
602
|
}
|
|
601
603
|
case "step": {
|
|
602
604
|
const component = token.getComponent();
|
|
603
|
-
|
|
604
|
-
if (error) return err(error.type, error.message);
|
|
605
|
+
this.handleStep(component, field, min, max);
|
|
605
606
|
break;
|
|
606
607
|
}
|
|
607
|
-
default:
|
|
608
|
+
default: throw new InvalidValueError(`Invalid token type '${token.getTokenType()}'`);
|
|
608
609
|
}
|
|
609
|
-
return ok(true);
|
|
610
610
|
}
|
|
611
611
|
matches(date) {
|
|
612
612
|
const s = date.getSeconds();
|
|
@@ -1,2 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/lib/errors/types.d.ts
|
|
2
|
+
type CommonError = "NotFoundError" | "UnauthorizedError" | "InternalServerError" | "ValidationError" | "MigrationError" | "SchemaError" | (string & {});
|
|
3
|
+
//#endregion
|
|
4
|
+
//#region src/lib/errors/index.d.ts
|
|
5
|
+
declare const ok: <T>(data: T) => readonly [null, T];
|
|
6
|
+
declare const err: <T extends CommonError>(type: T, message: string) => readonly [{
|
|
7
|
+
readonly type: T;
|
|
8
|
+
readonly message: string;
|
|
9
|
+
}, null];
|
|
10
|
+
declare const mightThrowSync: <T, E = Error>(fn: () => T) => readonly [null, T] | readonly [E, null];
|
|
11
|
+
declare const mightThrow: <T, E = Error>(promise: Promise<T>) => Promise<readonly [null, T] | readonly [E, null]>;
|
|
12
|
+
//#endregion
|
|
2
13
|
export { err, mightThrow, mightThrowSync, ok };
|
|
@@ -1,2 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/lib/errors/types.d.ts
|
|
2
|
+
type CommonError = "NotFoundError" | "UnauthorizedError" | "InternalServerError" | "ValidationError" | "MigrationError" | "SchemaError" | (string & {});
|
|
3
|
+
//#endregion
|
|
4
|
+
//#region src/lib/errors/index.d.ts
|
|
5
|
+
declare const ok: <T>(data: T) => readonly [null, T];
|
|
6
|
+
declare const err: <T extends CommonError>(type: T, message: string) => readonly [{
|
|
7
|
+
readonly type: T;
|
|
8
|
+
readonly message: string;
|
|
9
|
+
}, null];
|
|
10
|
+
declare const mightThrowSync: <T, E = Error>(fn: () => T) => readonly [null, T] | readonly [E, null];
|
|
11
|
+
declare const mightThrow: <T, E = Error>(promise: Promise<T>) => Promise<readonly [null, T] | readonly [E, null]>;
|
|
12
|
+
//#endregion
|
|
2
13
|
export { err, mightThrow, mightThrowSync, ok };
|