semola 0.5.0 → 0.5.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.
- package/README.md +75 -20
- package/dist/api/core/index.cjs +206 -0
- package/dist/api/core/index.d.cts +21 -0
- package/dist/api/core/index.d.cts.map +1 -0
- package/dist/api/core/index.d.mts +21 -0
- package/dist/api/core/index.d.mts.map +1 -0
- package/dist/api/core/index.mjs +208 -0
- package/dist/api/core/index.mjs.map +1 -0
- package/dist/api/core/types.d.cts +107 -0
- package/dist/api/core/types.d.cts.map +1 -0
- package/dist/api/core/types.d.mts +107 -0
- package/dist/api/core/types.d.mts.map +1 -0
- package/dist/api/middleware/index.cjs +8 -0
- package/dist/api/middleware/index.d.cts +11 -0
- package/dist/api/middleware/index.d.cts.map +1 -0
- package/dist/api/middleware/index.d.mts +11 -0
- package/dist/api/middleware/index.d.mts.map +1 -0
- package/dist/api/middleware/index.mjs +10 -0
- package/dist/api/middleware/index.mjs.map +1 -0
- package/dist/api/middleware/types.d.cts +16 -0
- package/dist/api/middleware/types.d.cts.map +1 -0
- package/dist/api/middleware/types.d.mts +16 -0
- package/dist/api/middleware/types.d.mts.map +1 -0
- package/dist/api/openapi/index.cjs +254 -0
- package/dist/api/openapi/index.mjs +256 -0
- package/dist/api/openapi/index.mjs.map +1 -0
- package/dist/api/openapi/types.d.cts +60 -0
- package/dist/api/openapi/types.d.cts.map +1 -0
- package/dist/api/openapi/types.d.mts +60 -0
- package/dist/api/openapi/types.d.mts.map +1 -0
- package/dist/api/validation/index.cjs +64 -0
- package/dist/api/validation/index.mjs +61 -0
- package/dist/api/validation/index.mjs.map +1 -0
- package/dist/cache/types.d.cts +17 -0
- package/dist/cache/types.d.cts.map +1 -0
- package/dist/cache/types.d.mts +17 -0
- package/dist/cache/types.d.mts.map +1 -0
- package/dist/cron/scanner.cjs +237 -0
- package/dist/cron/scanner.mjs +238 -0
- package/dist/cron/scanner.mjs.map +1 -0
- package/dist/cron/types.d.cts +11 -0
- package/dist/cron/types.d.cts.map +1 -0
- package/dist/cron/types.d.mts +11 -0
- package/dist/cron/types.d.mts.map +1 -0
- package/dist/errors/types.d.cts +5 -0
- package/dist/errors/types.d.cts.map +1 -0
- package/dist/errors/types.d.mts +5 -0
- package/dist/errors/types.d.mts.map +1 -0
- package/dist/i18n/types.d.cts +13 -0
- package/dist/i18n/types.d.cts.map +1 -0
- package/dist/i18n/types.d.mts +13 -0
- package/dist/i18n/types.d.mts.map +1 -0
- package/dist/lib/api/index.cjs +5 -0
- package/dist/lib/api/index.d.cts +5 -0
- package/dist/lib/api/index.d.mts +5 -0
- package/dist/lib/api/index.mjs +3 -0
- package/dist/lib/cache/index.cjs +74 -0
- package/dist/lib/cache/index.d.cts +36 -0
- package/dist/lib/cache/index.d.cts.map +1 -0
- package/dist/lib/cache/index.d.mts +36 -0
- package/dist/lib/cache/index.d.mts.map +1 -0
- package/dist/lib/cache/index.mjs +75 -0
- package/dist/lib/cache/index.mjs.map +1 -0
- package/dist/lib/cron/index.cjs +276 -0
- package/dist/lib/cron/index.d.cts +39 -0
- package/dist/lib/cron/index.d.cts.map +1 -0
- package/dist/lib/cron/index.d.mts +39 -0
- package/dist/lib/cron/index.d.mts.map +1 -0
- package/dist/lib/cron/index.mjs +277 -0
- package/dist/lib/cron/index.mjs.map +1 -0
- package/dist/lib/errors/index.cjs +30 -0
- package/dist/lib/errors/index.d.cts +13 -0
- package/dist/lib/errors/index.d.cts.map +1 -0
- package/dist/lib/errors/index.d.mts +13 -0
- package/dist/lib/errors/index.d.mts.map +1 -0
- package/dist/lib/errors/index.mjs +28 -0
- package/dist/lib/errors/index.mjs.map +1 -0
- package/dist/lib/i18n/index.cjs +37 -0
- package/dist/lib/i18n/index.d.cts +20 -0
- package/dist/lib/i18n/index.d.cts.map +1 -0
- package/dist/lib/i18n/index.d.mts +20 -0
- package/dist/lib/i18n/index.d.mts.map +1 -0
- package/dist/lib/i18n/index.mjs +38 -0
- package/dist/lib/i18n/index.mjs.map +1 -0
- package/dist/lib/policy/index.cjs +99 -0
- package/dist/lib/policy/index.d.cts +21 -0
- package/dist/lib/policy/index.d.cts.map +1 -0
- package/dist/lib/policy/index.d.mts +21 -0
- package/dist/lib/policy/index.d.mts.map +1 -0
- package/dist/lib/policy/index.mjs +81 -0
- package/dist/lib/policy/index.mjs.map +1 -0
- package/dist/lib/prompts/index.cjs +409 -0
- package/dist/lib/prompts/index.d.cts +31 -0
- package/dist/lib/prompts/index.d.cts.map +1 -0
- package/dist/lib/prompts/index.d.mts +31 -0
- package/dist/lib/prompts/index.d.mts.map +1 -0
- package/dist/lib/prompts/index.mjs +405 -0
- package/dist/lib/prompts/index.mjs.map +1 -0
- package/dist/lib/pubsub/index.cjs +48 -0
- package/dist/lib/pubsub/index.d.cts +27 -0
- package/dist/lib/pubsub/index.d.cts.map +1 -0
- package/dist/lib/pubsub/index.d.mts +27 -0
- package/dist/lib/pubsub/index.d.mts.map +1 -0
- package/dist/lib/pubsub/index.mjs +49 -0
- package/dist/lib/pubsub/index.mjs.map +1 -0
- package/dist/lib/queue/index.cjs +182 -0
- package/dist/lib/queue/index.d.cts +32 -0
- package/dist/lib/queue/index.d.cts.map +1 -0
- package/dist/lib/queue/index.d.mts +32 -0
- package/dist/lib/queue/index.d.mts.map +1 -0
- package/dist/lib/queue/index.mjs +183 -0
- package/dist/lib/queue/index.mjs.map +1 -0
- package/dist/node_modules/@standard-schema/spec/dist/index.d.cts +80 -0
- package/dist/node_modules/@standard-schema/spec/dist/index.d.cts.map +1 -0
- package/dist/node_modules/@standard-schema/spec/dist/index.d.mts +80 -0
- package/dist/node_modules/@standard-schema/spec/dist/index.d.mts.map +1 -0
- package/dist/policy/helpers.cjs +206 -0
- package/dist/policy/helpers.d.cts +50 -0
- package/dist/policy/helpers.d.cts.map +1 -0
- package/dist/policy/helpers.d.mts +50 -0
- package/dist/policy/helpers.d.mts.map +1 -0
- package/dist/policy/helpers.mjs +190 -0
- package/dist/policy/helpers.mjs.map +1 -0
- package/dist/policy/types.d.cts +16 -0
- package/dist/policy/types.d.cts.map +1 -0
- package/dist/policy/types.d.mts +16 -0
- package/dist/policy/types.d.mts.map +1 -0
- package/dist/prompts/core/keys.cjs +165 -0
- package/dist/prompts/core/keys.mjs +167 -0
- package/dist/prompts/core/keys.mjs.map +1 -0
- package/dist/prompts/core/runtime.cjs +104 -0
- package/dist/prompts/core/runtime.mjs +106 -0
- package/dist/prompts/core/runtime.mjs.map +1 -0
- package/dist/prompts/core/session.cjs +98 -0
- package/dist/prompts/core/session.mjs +100 -0
- package/dist/prompts/core/session.mjs.map +1 -0
- package/dist/prompts/core/types.d.cts +21 -0
- package/dist/prompts/core/types.d.cts.map +1 -0
- package/dist/prompts/core/types.d.mts +21 -0
- package/dist/prompts/core/types.d.mts.map +1 -0
- package/dist/prompts/types.d.cts +52 -0
- package/dist/prompts/types.d.cts.map +1 -0
- package/dist/prompts/types.d.mts +52 -0
- package/dist/prompts/types.d.mts.map +1 -0
- package/dist/pubsub/types.d.cts +10 -0
- package/dist/pubsub/types.d.cts.map +1 -0
- package/dist/pubsub/types.d.mts +10 -0
- package/dist/pubsub/types.d.mts.map +1 -0
- package/dist/queue/types.d.cts +47 -0
- package/dist/queue/types.d.cts.map +1 -0
- package/dist/queue/types.d.mts +47 -0
- package/dist/queue/types.d.mts.map +1 -0
- package/package.json +86 -16
- package/dist/lib/api/core/index.d.ts +0 -15
- package/dist/lib/api/core/index.d.ts.map +0 -1
- package/dist/lib/api/core/index.js +0 -166
- package/dist/lib/api/core/index.js.map +0 -1
- package/dist/lib/api/core/index.test.d.ts +0 -2
- package/dist/lib/api/core/index.test.d.ts.map +0 -1
- package/dist/lib/api/core/index.test.js +0 -219
- package/dist/lib/api/core/index.test.js.map +0 -1
- package/dist/lib/api/core/types.d.ts +0 -102
- package/dist/lib/api/core/types.d.ts.map +0 -1
- package/dist/lib/api/core/types.js +0 -2
- package/dist/lib/api/core/types.js.map +0 -1
- package/dist/lib/api/index.d.ts +0 -5
- package/dist/lib/api/index.d.ts.map +0 -1
- package/dist/lib/api/index.js +0 -3
- package/dist/lib/api/index.js.map +0 -1
- package/dist/lib/api/middleware/index.d.ts +0 -7
- package/dist/lib/api/middleware/index.d.ts.map +0 -1
- package/dist/lib/api/middleware/index.js +0 -7
- package/dist/lib/api/middleware/index.js.map +0 -1
- package/dist/lib/api/middleware/index.test.d.ts +0 -2
- package/dist/lib/api/middleware/index.test.d.ts.map +0 -1
- package/dist/lib/api/middleware/index.test.js +0 -67
- package/dist/lib/api/middleware/index.test.js.map +0 -1
- package/dist/lib/api/middleware/types.d.ts +0 -12
- package/dist/lib/api/middleware/types.d.ts.map +0 -1
- package/dist/lib/api/middleware/types.js +0 -2
- package/dist/lib/api/middleware/types.js.map +0 -1
- package/dist/lib/api/openapi/index.d.ts +0 -31
- package/dist/lib/api/openapi/index.d.ts.map +0 -1
- package/dist/lib/api/openapi/index.js +0 -328
- package/dist/lib/api/openapi/index.js.map +0 -1
- package/dist/lib/api/openapi/index.test.d.ts +0 -2
- package/dist/lib/api/openapi/index.test.d.ts.map +0 -1
- package/dist/lib/api/openapi/index.test.js +0 -359
- package/dist/lib/api/openapi/index.test.js.map +0 -1
- package/dist/lib/api/openapi/types.d.ts +0 -57
- package/dist/lib/api/openapi/types.d.ts.map +0 -1
- package/dist/lib/api/openapi/types.js +0 -5
- package/dist/lib/api/openapi/types.js.map +0 -1
- package/dist/lib/api/validation/index.d.ts +0 -33
- package/dist/lib/api/validation/index.d.ts.map +0 -1
- package/dist/lib/api/validation/index.js +0 -81
- package/dist/lib/api/validation/index.js.map +0 -1
- package/dist/lib/api/validation/index.test.d.ts +0 -2
- package/dist/lib/api/validation/index.test.d.ts.map +0 -1
- package/dist/lib/api/validation/index.test.js +0 -135
- package/dist/lib/api/validation/index.test.js.map +0 -1
- package/dist/lib/cache/index.d.ts +0 -25
- package/dist/lib/cache/index.d.ts.map +0 -1
- package/dist/lib/cache/index.js +0 -62
- package/dist/lib/cache/index.js.map +0 -1
- package/dist/lib/cache/index.test.d.ts +0 -2
- package/dist/lib/cache/index.test.d.ts.map +0 -1
- package/dist/lib/cache/index.test.js +0 -314
- package/dist/lib/cache/index.test.js.map +0 -1
- package/dist/lib/cache/types.d.ts +0 -5
- package/dist/lib/cache/types.d.ts.map +0 -1
- package/dist/lib/cache/types.js +0 -2
- package/dist/lib/cache/types.js.map +0 -1
- package/dist/lib/errors/index.d.ts +0 -9
- package/dist/lib/errors/index.d.ts.map +0 -1
- package/dist/lib/errors/index.js +0 -25
- package/dist/lib/errors/index.js.map +0 -1
- package/dist/lib/errors/index.test.d.ts +0 -2
- package/dist/lib/errors/index.test.d.ts.map +0 -1
- package/dist/lib/errors/index.test.js +0 -197
- package/dist/lib/errors/index.test.js.map +0 -1
- package/dist/lib/errors/types.d.ts +0 -2
- package/dist/lib/errors/types.d.ts.map +0 -1
- package/dist/lib/errors/types.js +0 -2
- package/dist/lib/errors/types.js.map +0 -1
- package/dist/lib/i18n/index.d.ts +0 -18
- package/dist/lib/i18n/index.d.ts.map +0 -1
- package/dist/lib/i18n/index.js +0 -38
- package/dist/lib/i18n/index.js.map +0 -1
- package/dist/lib/i18n/index.test.d.ts +0 -2
- package/dist/lib/i18n/index.test.d.ts.map +0 -1
- package/dist/lib/i18n/index.test.js +0 -402
- package/dist/lib/i18n/index.test.js.map +0 -1
- package/dist/lib/i18n/types.d.ts +0 -15
- package/dist/lib/i18n/types.d.ts.map +0 -1
- package/dist/lib/i18n/types.js +0 -2
- package/dist/lib/i18n/types.js.map +0 -1
- package/dist/lib/policy/index.d.ts +0 -9
- package/dist/lib/policy/index.d.ts.map +0 -1
- package/dist/lib/policy/index.js +0 -51
- package/dist/lib/policy/index.js.map +0 -1
- package/dist/lib/policy/index.test.d.ts +0 -2
- package/dist/lib/policy/index.test.d.ts.map +0 -1
- package/dist/lib/policy/index.test.js +0 -328
- package/dist/lib/policy/index.test.js.map +0 -1
- package/dist/lib/policy/types.d.ts +0 -27
- package/dist/lib/policy/types.d.ts.map +0 -1
- package/dist/lib/policy/types.js +0 -2
- package/dist/lib/policy/types.js.map +0 -1
- package/dist/lib/pubsub/index.d.ts +0 -23
- package/dist/lib/pubsub/index.d.ts.map +0 -1
- package/dist/lib/pubsub/index.js +0 -55
- package/dist/lib/pubsub/index.js.map +0 -1
- package/dist/lib/pubsub/index.test.d.ts +0 -2
- package/dist/lib/pubsub/index.test.d.ts.map +0 -1
- package/dist/lib/pubsub/index.test.js +0 -550
- package/dist/lib/pubsub/index.test.js.map +0 -1
- package/dist/lib/pubsub/types.d.ts +0 -7
- package/dist/lib/pubsub/types.d.ts.map +0 -1
- package/dist/lib/pubsub/types.js +0 -2
- package/dist/lib/pubsub/types.js.map +0 -1
- package/dist/lib/queue/index.d.ts +0 -28
- package/dist/lib/queue/index.d.ts.map +0 -1
- package/dist/lib/queue/index.js +0 -211
- package/dist/lib/queue/index.js.map +0 -1
- package/dist/lib/queue/index.test.d.ts +0 -2
- package/dist/lib/queue/index.test.d.ts.map +0 -1
- package/dist/lib/queue/index.test.js +0 -740
- package/dist/lib/queue/index.test.js.map +0 -1
- package/dist/lib/queue/types.d.ts +0 -52
- package/dist/lib/queue/types.d.ts.map +0 -1
- package/dist/lib/queue/types.js +0 -2
- package/dist/lib/queue/types.js.map +0 -1
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
const require_lib_errors_index = require("../lib/errors/index.cjs");
|
|
2
|
+
//#region src/lib/cron/scanner.ts
|
|
3
|
+
const FieldAmount = {
|
|
4
|
+
min: 5,
|
|
5
|
+
max: 6
|
|
6
|
+
};
|
|
7
|
+
var Token = class {
|
|
8
|
+
type;
|
|
9
|
+
component;
|
|
10
|
+
value;
|
|
11
|
+
field;
|
|
12
|
+
constructor(component, type, value, field) {
|
|
13
|
+
this.component = component;
|
|
14
|
+
this.type = type;
|
|
15
|
+
this.value = value;
|
|
16
|
+
this.field = field;
|
|
17
|
+
}
|
|
18
|
+
getComponent() {
|
|
19
|
+
return this.component;
|
|
20
|
+
}
|
|
21
|
+
getTokenType() {
|
|
22
|
+
return this.type;
|
|
23
|
+
}
|
|
24
|
+
getTokenValue() {
|
|
25
|
+
return this.value;
|
|
26
|
+
}
|
|
27
|
+
getField() {
|
|
28
|
+
return this.field;
|
|
29
|
+
}
|
|
30
|
+
toString() {
|
|
31
|
+
return `Token{${`component="${this.component}", type=${this.type}`}, ${`field="${this.field}", value=${this.value}`}}`;
|
|
32
|
+
}
|
|
33
|
+
equals(other) {
|
|
34
|
+
if (!other) return false;
|
|
35
|
+
const isComponentEqual = this.component === other.getComponent();
|
|
36
|
+
const isTokenTypeEqual = this.type === other.getTokenType();
|
|
37
|
+
const isTokenValueEqual = this.value === other.getTokenValue();
|
|
38
|
+
const isFieldEqual = this.field === other.getField();
|
|
39
|
+
return isComponentEqual && isTokenTypeEqual && isTokenValueEqual && isFieldEqual;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var Scanner = class {
|
|
43
|
+
expression;
|
|
44
|
+
current;
|
|
45
|
+
start;
|
|
46
|
+
tokens;
|
|
47
|
+
constructor(expression) {
|
|
48
|
+
this.expression = expression;
|
|
49
|
+
this.current = 0;
|
|
50
|
+
this.start = 0;
|
|
51
|
+
this.tokens = [];
|
|
52
|
+
}
|
|
53
|
+
scan() {
|
|
54
|
+
if (this.expression.length === 0) return require_lib_errors_index.err("EmptyCronExpressionError", "Cron expression have zero length");
|
|
55
|
+
const fields = this.expression.trim().split(/\s+/);
|
|
56
|
+
const hasMinLen = fields.length === FieldAmount.min;
|
|
57
|
+
const hasMaxLen = fields.length === FieldAmount.max;
|
|
58
|
+
if (!hasMinLen && !hasMaxLen) return require_lib_errors_index.err("CronLengthError", `Invalid number of fields for '${this.expression}'. Expected 5 or 6 fields but got ${fields.length} field(s)`);
|
|
59
|
+
const components = this.createComponent(fields);
|
|
60
|
+
for (let idx = 0; idx < components.length; idx++) {
|
|
61
|
+
const component = components[idx];
|
|
62
|
+
if (!component) return require_lib_errors_index.err("CronExpressionError", `Invalid cron expression: ${this.expression}`);
|
|
63
|
+
this.current = 0;
|
|
64
|
+
this.start = 0;
|
|
65
|
+
const [error, _] = this.scanComponent(component);
|
|
66
|
+
if (error) return require_lib_errors_index.err(error.type, error.message);
|
|
67
|
+
}
|
|
68
|
+
return require_lib_errors_index.ok(this.tokens);
|
|
69
|
+
}
|
|
70
|
+
scanComponent(component) {
|
|
71
|
+
const { field, content } = component;
|
|
72
|
+
while (this.current < content.length) {
|
|
73
|
+
let currentCh = this.advance(content);
|
|
74
|
+
switch (currentCh) {
|
|
75
|
+
case "*": {
|
|
76
|
+
const ch = this.peek(content);
|
|
77
|
+
if (this.match(content, "/")) {
|
|
78
|
+
const [error, _] = this.handleStep(component);
|
|
79
|
+
if (error) return require_lib_errors_index.err(error.type, error.message);
|
|
80
|
+
} else if (!ch || ch === ",") this.addToken("*", "any", "*", field);
|
|
81
|
+
else return require_lib_errors_index.err("CronExpressionError", `Invalid any expression '${content}' for field '${field}'`);
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
case "-":
|
|
85
|
+
currentCh = this.advance(content);
|
|
86
|
+
if (this.isDigit(currentCh)) {
|
|
87
|
+
const [error, _] = this.handleRangeWithStep(component);
|
|
88
|
+
if (error) return require_lib_errors_index.err(error.type, error.message);
|
|
89
|
+
} else return require_lib_errors_index.err("CronExpressionError", `Invalid range expression '${content}' for field '${field}'`);
|
|
90
|
+
break;
|
|
91
|
+
case ",": {
|
|
92
|
+
if (this.current === 1 && this.start === 0) return require_lib_errors_index.err("CronExpressionError", `Invalid list expression '${content}' for field '${field}'`);
|
|
93
|
+
const next = this.peek(content);
|
|
94
|
+
if (!next || next === ",") return require_lib_errors_index.err("CronExpressionError", `Invalid list expression '${content}' for field '${field}'`);
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
default:
|
|
98
|
+
if (this.isDigit(currentCh)) {
|
|
99
|
+
const [error, _] = this.handleNumber(component);
|
|
100
|
+
if (error) return require_lib_errors_index.err(error.type, error.message);
|
|
101
|
+
} else return require_lib_errors_index.err("CronExpressionError", `Invalid cron expression '${this.expression}' in field '${field}'`);
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
this.start = this.current;
|
|
105
|
+
}
|
|
106
|
+
return require_lib_errors_index.ok(true);
|
|
107
|
+
}
|
|
108
|
+
addToken(component, type, value, field) {
|
|
109
|
+
const token = new Token(component, type, value, field);
|
|
110
|
+
this.tokens.push(token);
|
|
111
|
+
}
|
|
112
|
+
advance(content) {
|
|
113
|
+
const currentCh = content.charAt(this.current);
|
|
114
|
+
this.current += 1;
|
|
115
|
+
return currentCh;
|
|
116
|
+
}
|
|
117
|
+
match(content, expected) {
|
|
118
|
+
if (this.current >= content.length) return false;
|
|
119
|
+
if (content.charAt(this.current) !== expected) return false;
|
|
120
|
+
this.current += 1;
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
peek(content) {
|
|
124
|
+
if (this.current >= content.length) return void 0;
|
|
125
|
+
return content.charAt(this.current);
|
|
126
|
+
}
|
|
127
|
+
handleStep(component) {
|
|
128
|
+
const { field, content } = component;
|
|
129
|
+
let ch = this.peek(content);
|
|
130
|
+
const slashIdx = this.current - 1;
|
|
131
|
+
while (ch && this.isDigit(ch)) {
|
|
132
|
+
this.advance(content);
|
|
133
|
+
ch = this.peek(content);
|
|
134
|
+
}
|
|
135
|
+
if (ch && ch !== ",") return require_lib_errors_index.err("CronExpressionError", `Invalid step expression '${content}' for field '${field}'`);
|
|
136
|
+
const tokenContent = content.substring(this.start, this.current);
|
|
137
|
+
const value = content.slice(slashIdx + 1, this.current);
|
|
138
|
+
if (value.length === 0) return require_lib_errors_index.err("CronExpressionError", `Invalid step expression '${content}' for field '${field}'`);
|
|
139
|
+
this.addToken(tokenContent, "step", Number(value), field);
|
|
140
|
+
return require_lib_errors_index.ok(true);
|
|
141
|
+
}
|
|
142
|
+
handleRangeWithStep(component) {
|
|
143
|
+
const { field, content } = component;
|
|
144
|
+
let ch = this.peek(content);
|
|
145
|
+
while (ch && this.isDigit(ch)) {
|
|
146
|
+
this.advance(content);
|
|
147
|
+
ch = this.peek(content);
|
|
148
|
+
}
|
|
149
|
+
if (!ch) return require_lib_errors_index.err("CronExpressionError", `Invalid range expression '${content}' for field '${field}'`);
|
|
150
|
+
if (this.match(content, "/")) {
|
|
151
|
+
const [error, _] = this.handleStep(component);
|
|
152
|
+
if (error) return require_lib_errors_index.err(error.type, error.message);
|
|
153
|
+
return require_lib_errors_index.ok(true);
|
|
154
|
+
}
|
|
155
|
+
return require_lib_errors_index.err("CronExpressionError", `Invalid range expression '${content}' for field '${field}'`);
|
|
156
|
+
}
|
|
157
|
+
handleNumber(component) {
|
|
158
|
+
const { field, content } = component;
|
|
159
|
+
let ch = this.peek(content);
|
|
160
|
+
this.start = this.current - 1;
|
|
161
|
+
while (ch && this.isDigit(ch)) {
|
|
162
|
+
this.advance(content);
|
|
163
|
+
ch = this.peek(content);
|
|
164
|
+
}
|
|
165
|
+
if (!ch) {
|
|
166
|
+
const item = content.substring(this.start);
|
|
167
|
+
this.addToken(item, "number", Number(item), field);
|
|
168
|
+
return require_lib_errors_index.ok(true);
|
|
169
|
+
}
|
|
170
|
+
if (this.match(content, "-")) {
|
|
171
|
+
const [error, _] = this.handleRange(component);
|
|
172
|
+
if (error) return require_lib_errors_index.err(error.type, error.message);
|
|
173
|
+
return require_lib_errors_index.ok(true);
|
|
174
|
+
}
|
|
175
|
+
if (this.match(content, "/")) {
|
|
176
|
+
const [error, _] = this.handleStep(component);
|
|
177
|
+
if (error) return require_lib_errors_index.err(error.type, error.message);
|
|
178
|
+
return require_lib_errors_index.ok(true);
|
|
179
|
+
}
|
|
180
|
+
if (!this.isDigit(ch) && ch !== ",") return require_lib_errors_index.err("CronExpressionError", `Invalid number '${content}' for field '${field}'`);
|
|
181
|
+
const item = content.substring(this.start, this.current);
|
|
182
|
+
this.addToken(item, "number", Number(item), field);
|
|
183
|
+
return require_lib_errors_index.ok(true);
|
|
184
|
+
}
|
|
185
|
+
handleRange(component) {
|
|
186
|
+
const { field, content } = component;
|
|
187
|
+
let ch = this.peek(content);
|
|
188
|
+
if (!ch) return require_lib_errors_index.err("CronExpressionError", `Invalid range expression '${content}' for field '${field}'`);
|
|
189
|
+
while (ch && this.isDigit(ch)) {
|
|
190
|
+
this.advance(content);
|
|
191
|
+
ch = this.peek(content);
|
|
192
|
+
}
|
|
193
|
+
if (!ch) {
|
|
194
|
+
const tokenContent = content.substring(this.start);
|
|
195
|
+
this.addToken(tokenContent, "range", tokenContent, field);
|
|
196
|
+
return require_lib_errors_index.ok(true);
|
|
197
|
+
}
|
|
198
|
+
if (this.match(content, "/")) {
|
|
199
|
+
const [error, _] = this.handleStep(component);
|
|
200
|
+
if (error) return require_lib_errors_index.err(error.type, error.message);
|
|
201
|
+
return require_lib_errors_index.ok(true);
|
|
202
|
+
}
|
|
203
|
+
if (ch && ch !== ",") return require_lib_errors_index.err("CronExpressionError", `Invalid range expression '${content}' for field '${field}'`);
|
|
204
|
+
const tokenContent = content.substring(this.start, this.current);
|
|
205
|
+
this.addToken(tokenContent, "range", tokenContent, field);
|
|
206
|
+
return require_lib_errors_index.ok(true);
|
|
207
|
+
}
|
|
208
|
+
isDigit(ch) {
|
|
209
|
+
return ch >= "0" && ch <= "9";
|
|
210
|
+
}
|
|
211
|
+
createComponent(fields) {
|
|
212
|
+
const fieldNames = [
|
|
213
|
+
"second",
|
|
214
|
+
"minute",
|
|
215
|
+
"hour",
|
|
216
|
+
"day",
|
|
217
|
+
"month",
|
|
218
|
+
"weekday"
|
|
219
|
+
];
|
|
220
|
+
const components = [];
|
|
221
|
+
let offset = 1;
|
|
222
|
+
if (fields.length === FieldAmount.max) offset = 0;
|
|
223
|
+
for (let idx = 0; idx < fields.length; idx++) {
|
|
224
|
+
const fieldName = fieldNames[idx + offset];
|
|
225
|
+
const content = fields[idx];
|
|
226
|
+
if (!fieldName || !content) break;
|
|
227
|
+
components.push({
|
|
228
|
+
content,
|
|
229
|
+
field: fieldName
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
return components;
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
//#endregion
|
|
236
|
+
exports.FieldAmount = FieldAmount;
|
|
237
|
+
exports.Scanner = Scanner;
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { err, ok } from "../lib/errors/index.mjs";
|
|
2
|
+
//#region src/lib/cron/scanner.ts
|
|
3
|
+
const FieldAmount = {
|
|
4
|
+
min: 5,
|
|
5
|
+
max: 6
|
|
6
|
+
};
|
|
7
|
+
var Token = class {
|
|
8
|
+
type;
|
|
9
|
+
component;
|
|
10
|
+
value;
|
|
11
|
+
field;
|
|
12
|
+
constructor(component, type, value, field) {
|
|
13
|
+
this.component = component;
|
|
14
|
+
this.type = type;
|
|
15
|
+
this.value = value;
|
|
16
|
+
this.field = field;
|
|
17
|
+
}
|
|
18
|
+
getComponent() {
|
|
19
|
+
return this.component;
|
|
20
|
+
}
|
|
21
|
+
getTokenType() {
|
|
22
|
+
return this.type;
|
|
23
|
+
}
|
|
24
|
+
getTokenValue() {
|
|
25
|
+
return this.value;
|
|
26
|
+
}
|
|
27
|
+
getField() {
|
|
28
|
+
return this.field;
|
|
29
|
+
}
|
|
30
|
+
toString() {
|
|
31
|
+
return `Token{${`component="${this.component}", type=${this.type}`}, ${`field="${this.field}", value=${this.value}`}}`;
|
|
32
|
+
}
|
|
33
|
+
equals(other) {
|
|
34
|
+
if (!other) return false;
|
|
35
|
+
const isComponentEqual = this.component === other.getComponent();
|
|
36
|
+
const isTokenTypeEqual = this.type === other.getTokenType();
|
|
37
|
+
const isTokenValueEqual = this.value === other.getTokenValue();
|
|
38
|
+
const isFieldEqual = this.field === other.getField();
|
|
39
|
+
return isComponentEqual && isTokenTypeEqual && isTokenValueEqual && isFieldEqual;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var Scanner = class {
|
|
43
|
+
expression;
|
|
44
|
+
current;
|
|
45
|
+
start;
|
|
46
|
+
tokens;
|
|
47
|
+
constructor(expression) {
|
|
48
|
+
this.expression = expression;
|
|
49
|
+
this.current = 0;
|
|
50
|
+
this.start = 0;
|
|
51
|
+
this.tokens = [];
|
|
52
|
+
}
|
|
53
|
+
scan() {
|
|
54
|
+
if (this.expression.length === 0) return err("EmptyCronExpressionError", "Cron expression have zero length");
|
|
55
|
+
const fields = this.expression.trim().split(/\s+/);
|
|
56
|
+
const hasMinLen = fields.length === FieldAmount.min;
|
|
57
|
+
const hasMaxLen = fields.length === FieldAmount.max;
|
|
58
|
+
if (!hasMinLen && !hasMaxLen) return err("CronLengthError", `Invalid number of fields for '${this.expression}'. Expected 5 or 6 fields but got ${fields.length} field(s)`);
|
|
59
|
+
const components = this.createComponent(fields);
|
|
60
|
+
for (let idx = 0; idx < components.length; idx++) {
|
|
61
|
+
const component = components[idx];
|
|
62
|
+
if (!component) return err("CronExpressionError", `Invalid cron expression: ${this.expression}`);
|
|
63
|
+
this.current = 0;
|
|
64
|
+
this.start = 0;
|
|
65
|
+
const [error, _] = this.scanComponent(component);
|
|
66
|
+
if (error) return err(error.type, error.message);
|
|
67
|
+
}
|
|
68
|
+
return ok(this.tokens);
|
|
69
|
+
}
|
|
70
|
+
scanComponent(component) {
|
|
71
|
+
const { field, content } = component;
|
|
72
|
+
while (this.current < content.length) {
|
|
73
|
+
let currentCh = this.advance(content);
|
|
74
|
+
switch (currentCh) {
|
|
75
|
+
case "*": {
|
|
76
|
+
const ch = this.peek(content);
|
|
77
|
+
if (this.match(content, "/")) {
|
|
78
|
+
const [error, _] = this.handleStep(component);
|
|
79
|
+
if (error) return err(error.type, error.message);
|
|
80
|
+
} else if (!ch || ch === ",") this.addToken("*", "any", "*", field);
|
|
81
|
+
else return err("CronExpressionError", `Invalid any expression '${content}' for field '${field}'`);
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
case "-":
|
|
85
|
+
currentCh = this.advance(content);
|
|
86
|
+
if (this.isDigit(currentCh)) {
|
|
87
|
+
const [error, _] = this.handleRangeWithStep(component);
|
|
88
|
+
if (error) return err(error.type, error.message);
|
|
89
|
+
} else return err("CronExpressionError", `Invalid range expression '${content}' for field '${field}'`);
|
|
90
|
+
break;
|
|
91
|
+
case ",": {
|
|
92
|
+
if (this.current === 1 && this.start === 0) return err("CronExpressionError", `Invalid list expression '${content}' for field '${field}'`);
|
|
93
|
+
const next = this.peek(content);
|
|
94
|
+
if (!next || next === ",") return err("CronExpressionError", `Invalid list expression '${content}' for field '${field}'`);
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
default:
|
|
98
|
+
if (this.isDigit(currentCh)) {
|
|
99
|
+
const [error, _] = this.handleNumber(component);
|
|
100
|
+
if (error) return err(error.type, error.message);
|
|
101
|
+
} else return err("CronExpressionError", `Invalid cron expression '${this.expression}' in field '${field}'`);
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
this.start = this.current;
|
|
105
|
+
}
|
|
106
|
+
return ok(true);
|
|
107
|
+
}
|
|
108
|
+
addToken(component, type, value, field) {
|
|
109
|
+
const token = new Token(component, type, value, field);
|
|
110
|
+
this.tokens.push(token);
|
|
111
|
+
}
|
|
112
|
+
advance(content) {
|
|
113
|
+
const currentCh = content.charAt(this.current);
|
|
114
|
+
this.current += 1;
|
|
115
|
+
return currentCh;
|
|
116
|
+
}
|
|
117
|
+
match(content, expected) {
|
|
118
|
+
if (this.current >= content.length) return false;
|
|
119
|
+
if (content.charAt(this.current) !== expected) return false;
|
|
120
|
+
this.current += 1;
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
peek(content) {
|
|
124
|
+
if (this.current >= content.length) return void 0;
|
|
125
|
+
return content.charAt(this.current);
|
|
126
|
+
}
|
|
127
|
+
handleStep(component) {
|
|
128
|
+
const { field, content } = component;
|
|
129
|
+
let ch = this.peek(content);
|
|
130
|
+
const slashIdx = this.current - 1;
|
|
131
|
+
while (ch && this.isDigit(ch)) {
|
|
132
|
+
this.advance(content);
|
|
133
|
+
ch = this.peek(content);
|
|
134
|
+
}
|
|
135
|
+
if (ch && ch !== ",") return err("CronExpressionError", `Invalid step expression '${content}' for field '${field}'`);
|
|
136
|
+
const tokenContent = content.substring(this.start, this.current);
|
|
137
|
+
const value = content.slice(slashIdx + 1, this.current);
|
|
138
|
+
if (value.length === 0) return err("CronExpressionError", `Invalid step expression '${content}' for field '${field}'`);
|
|
139
|
+
this.addToken(tokenContent, "step", Number(value), field);
|
|
140
|
+
return ok(true);
|
|
141
|
+
}
|
|
142
|
+
handleRangeWithStep(component) {
|
|
143
|
+
const { field, content } = component;
|
|
144
|
+
let ch = this.peek(content);
|
|
145
|
+
while (ch && this.isDigit(ch)) {
|
|
146
|
+
this.advance(content);
|
|
147
|
+
ch = this.peek(content);
|
|
148
|
+
}
|
|
149
|
+
if (!ch) return err("CronExpressionError", `Invalid range expression '${content}' for field '${field}'`);
|
|
150
|
+
if (this.match(content, "/")) {
|
|
151
|
+
const [error, _] = this.handleStep(component);
|
|
152
|
+
if (error) return err(error.type, error.message);
|
|
153
|
+
return ok(true);
|
|
154
|
+
}
|
|
155
|
+
return err("CronExpressionError", `Invalid range expression '${content}' for field '${field}'`);
|
|
156
|
+
}
|
|
157
|
+
handleNumber(component) {
|
|
158
|
+
const { field, content } = component;
|
|
159
|
+
let ch = this.peek(content);
|
|
160
|
+
this.start = this.current - 1;
|
|
161
|
+
while (ch && this.isDigit(ch)) {
|
|
162
|
+
this.advance(content);
|
|
163
|
+
ch = this.peek(content);
|
|
164
|
+
}
|
|
165
|
+
if (!ch) {
|
|
166
|
+
const item = content.substring(this.start);
|
|
167
|
+
this.addToken(item, "number", Number(item), field);
|
|
168
|
+
return ok(true);
|
|
169
|
+
}
|
|
170
|
+
if (this.match(content, "-")) {
|
|
171
|
+
const [error, _] = this.handleRange(component);
|
|
172
|
+
if (error) return err(error.type, error.message);
|
|
173
|
+
return ok(true);
|
|
174
|
+
}
|
|
175
|
+
if (this.match(content, "/")) {
|
|
176
|
+
const [error, _] = this.handleStep(component);
|
|
177
|
+
if (error) return err(error.type, error.message);
|
|
178
|
+
return ok(true);
|
|
179
|
+
}
|
|
180
|
+
if (!this.isDigit(ch) && ch !== ",") return err("CronExpressionError", `Invalid number '${content}' for field '${field}'`);
|
|
181
|
+
const item = content.substring(this.start, this.current);
|
|
182
|
+
this.addToken(item, "number", Number(item), field);
|
|
183
|
+
return ok(true);
|
|
184
|
+
}
|
|
185
|
+
handleRange(component) {
|
|
186
|
+
const { field, content } = component;
|
|
187
|
+
let ch = this.peek(content);
|
|
188
|
+
if (!ch) return err("CronExpressionError", `Invalid range expression '${content}' for field '${field}'`);
|
|
189
|
+
while (ch && this.isDigit(ch)) {
|
|
190
|
+
this.advance(content);
|
|
191
|
+
ch = this.peek(content);
|
|
192
|
+
}
|
|
193
|
+
if (!ch) {
|
|
194
|
+
const tokenContent = content.substring(this.start);
|
|
195
|
+
this.addToken(tokenContent, "range", tokenContent, field);
|
|
196
|
+
return ok(true);
|
|
197
|
+
}
|
|
198
|
+
if (this.match(content, "/")) {
|
|
199
|
+
const [error, _] = this.handleStep(component);
|
|
200
|
+
if (error) return err(error.type, error.message);
|
|
201
|
+
return ok(true);
|
|
202
|
+
}
|
|
203
|
+
if (ch && ch !== ",") return err("CronExpressionError", `Invalid range expression '${content}' for field '${field}'`);
|
|
204
|
+
const tokenContent = content.substring(this.start, this.current);
|
|
205
|
+
this.addToken(tokenContent, "range", tokenContent, field);
|
|
206
|
+
return ok(true);
|
|
207
|
+
}
|
|
208
|
+
isDigit(ch) {
|
|
209
|
+
return ch >= "0" && ch <= "9";
|
|
210
|
+
}
|
|
211
|
+
createComponent(fields) {
|
|
212
|
+
const fieldNames = [
|
|
213
|
+
"second",
|
|
214
|
+
"minute",
|
|
215
|
+
"hour",
|
|
216
|
+
"day",
|
|
217
|
+
"month",
|
|
218
|
+
"weekday"
|
|
219
|
+
];
|
|
220
|
+
const components = [];
|
|
221
|
+
let offset = 1;
|
|
222
|
+
if (fields.length === FieldAmount.max) offset = 0;
|
|
223
|
+
for (let idx = 0; idx < fields.length; idx++) {
|
|
224
|
+
const fieldName = fieldNames[idx + offset];
|
|
225
|
+
const content = fields[idx];
|
|
226
|
+
if (!fieldName || !content) break;
|
|
227
|
+
components.push({
|
|
228
|
+
content,
|
|
229
|
+
field: fieldName
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
return components;
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
//#endregion
|
|
236
|
+
export { FieldAmount, Scanner };
|
|
237
|
+
|
|
238
|
+
//# sourceMappingURL=scanner.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scanner.mjs","names":[],"sources":["../../src/lib/cron/scanner.ts"],"sourcesContent":["import { err, ok } from \"../errors/index.js\";\nimport type { CronScannerError } from \"./types.js\";\n\nexport const FieldAmount = {\n min: 5,\n max: 6,\n} as const;\n\ntype TokenValueType = string | number;\ntype CronFieldType = \"second\" | \"minute\" | \"hour\" | \"day\" | \"month\" | \"weekday\";\ntype ComponentType = {\n content: string;\n field: CronFieldType;\n};\n\ntype TokenType = \"any\" | \"range\" | \"step\" | \"number\";\n\nexport class Token {\n private readonly type: TokenType;\n private readonly component: string;\n private readonly value: TokenValueType;\n\n private readonly field: CronFieldType;\n\n public constructor(\n component: string,\n type: TokenType,\n value: TokenValueType,\n field: CronFieldType,\n ) {\n this.component = component;\n this.type = type;\n this.value = value;\n this.field = field;\n }\n\n public getComponent() {\n return this.component;\n }\n\n public getTokenType() {\n return this.type;\n }\n\n public getTokenValue() {\n return this.value;\n }\n\n public getField() {\n return this.field;\n }\n\n public toString() {\n const header = `component=\"${this.component}\", type=${this.type}`;\n const body = `field=\"${this.field}\", value=${this.value}`;\n\n return `Token{${header}, ${body}}`;\n }\n\n public equals(other: Token) {\n if (!other) return false;\n\n const isComponentEqual = this.component === other.getComponent();\n const isTokenTypeEqual = this.type === other.getTokenType();\n const isTokenValueEqual = this.value === other.getTokenValue();\n const isFieldEqual = this.field === other.getField();\n\n return (\n isComponentEqual && isTokenTypeEqual && isTokenValueEqual && isFieldEqual\n );\n }\n}\n\nexport class Scanner {\n private expression: string;\n private current: number;\n private start: number;\n private tokens: Token[];\n\n public constructor(expression: string) {\n this.expression = expression;\n this.current = 0;\n this.start = 0;\n this.tokens = [];\n }\n\n public scan() {\n if (this.expression.length === 0) {\n return err<CronScannerError>(\n \"EmptyCronExpressionError\",\n \"Cron expression have zero length\",\n );\n }\n\n const fields = this.expression.trim().split(/\\s+/);\n const hasMinLen = fields.length === FieldAmount.min;\n const hasMaxLen = fields.length === FieldAmount.max;\n\n if (!hasMinLen && !hasMaxLen) {\n return err<CronScannerError>(\n \"CronLengthError\",\n `Invalid number of fields for '${this.expression}'. Expected 5 or 6 fields but got ${fields.length} field(s)`,\n );\n }\n\n const components = this.createComponent(fields);\n\n for (let idx = 0; idx < components.length; idx++) {\n const component = components[idx];\n if (!component) {\n return err<CronScannerError>(\n \"CronExpressionError\",\n `Invalid cron expression: ${this.expression}`,\n );\n }\n\n this.current = 0;\n this.start = 0;\n const [error, _] = this.scanComponent(component);\n if (error) return err<CronScannerError>(error.type, error.message);\n }\n\n return ok(this.tokens);\n }\n\n private scanComponent(component: ComponentType) {\n const { field, content } = component;\n while (this.current < content.length) {\n let currentCh = this.advance(content);\n\n switch (currentCh) {\n case \"*\": {\n const ch = this.peek(content);\n if (this.match(content, \"/\")) {\n const [error, _] = this.handleStep(component);\n if (error) return err<CronScannerError>(error.type, error.message);\n } else if (!ch || ch === \",\") {\n this.addToken(\"*\", \"any\", \"*\", field);\n } else {\n return err<CronScannerError>(\n \"CronExpressionError\",\n `Invalid any expression '${content}' for field '${field}'`,\n );\n }\n\n break;\n }\n case \"-\": {\n currentCh = this.advance(content);\n if (this.isDigit(currentCh)) {\n const [error, _] = this.handleRangeWithStep(component);\n if (error) return err<CronScannerError>(error.type, error.message);\n } else {\n return err<CronScannerError>(\n \"CronExpressionError\",\n `Invalid range expression '${content}' for field '${field}'`,\n );\n }\n break;\n }\n case \",\": {\n if (this.current === 1 && this.start === 0) {\n return err<CronScannerError>(\n \"CronExpressionError\",\n `Invalid list expression '${content}' for field '${field}'`,\n );\n }\n\n const next = this.peek(content);\n if (!next || next === \",\") {\n return err<CronScannerError>(\n \"CronExpressionError\",\n `Invalid list expression '${content}' for field '${field}'`,\n );\n }\n\n break;\n }\n default: {\n if (this.isDigit(currentCh)) {\n const [error, _] = this.handleNumber(component);\n if (error) return err<CronScannerError>(error.type, error.message);\n } else {\n return err<CronScannerError>(\n \"CronExpressionError\",\n `Invalid cron expression '${this.expression}' in field '${field}'`,\n );\n }\n\n break;\n }\n }\n\n this.start = this.current;\n }\n\n return ok(true);\n }\n\n private addToken(\n component: string,\n type: TokenType,\n value: TokenValueType,\n field: CronFieldType,\n ) {\n const token = new Token(component, type, value, field);\n this.tokens.push(token);\n }\n\n private advance(content: string) {\n const currentCh = content.charAt(this.current);\n this.current += 1;\n\n return currentCh;\n }\n\n private match(content: string, expected: string) {\n if (this.current >= content.length) return false;\n if (content.charAt(this.current) !== expected) return false;\n\n this.current += 1;\n return true;\n }\n\n private peek(content: string) {\n if (this.current >= content.length) return undefined;\n\n return content.charAt(this.current);\n }\n\n private handleStep(component: ComponentType) {\n const { field, content } = component;\n let ch = this.peek(content);\n const slashIdx = this.current - 1;\n\n while (ch && this.isDigit(ch)) {\n this.advance(content);\n ch = this.peek(content);\n }\n\n if (ch && ch !== \",\") {\n return err<CronScannerError>(\n \"CronExpressionError\",\n `Invalid step expression '${content}' for field '${field}'`,\n );\n }\n\n const tokenContent = content.substring(this.start, this.current);\n const value = content.slice(slashIdx + 1, this.current);\n\n if (value.length === 0) {\n return err<CronScannerError>(\n \"CronExpressionError\",\n `Invalid step expression '${content}' for field '${field}'`,\n );\n }\n\n this.addToken(tokenContent, \"step\", Number(value), field);\n return ok(true);\n }\n\n private handleRangeWithStep(component: ComponentType) {\n const { field, content } = component;\n let ch = this.peek(content);\n\n while (ch && this.isDigit(ch)) {\n this.advance(content);\n ch = this.peek(content);\n }\n\n if (!ch) {\n return err<CronScannerError>(\n \"CronExpressionError\",\n `Invalid range expression '${content}' for field '${field}'`,\n );\n }\n\n if (this.match(content, \"/\")) {\n const [error, _] = this.handleStep(component);\n if (error) return err<CronScannerError>(error.type, error.message);\n\n return ok(true);\n }\n\n return err<CronScannerError>(\n \"CronExpressionError\",\n `Invalid range expression '${content}' for field '${field}'`,\n );\n }\n\n private handleNumber(component: ComponentType) {\n const { field, content } = component;\n let ch = this.peek(content);\n this.start = this.current - 1;\n\n while (ch && this.isDigit(ch)) {\n this.advance(content);\n ch = this.peek(content);\n }\n\n if (!ch) {\n // Reached the end of the component\n const item = content.substring(this.start);\n this.addToken(item, \"number\", Number(item), field);\n return ok(true);\n }\n\n if (this.match(content, \"-\")) {\n const [error, _] = this.handleRange(component);\n if (error) return err<CronScannerError>(error.type, error.message);\n\n return ok(true);\n }\n\n if (this.match(content, \"/\")) {\n const [error, _] = this.handleStep(component);\n if (error) return err<CronScannerError>(error.type, error.message);\n\n return ok(true);\n }\n\n if (!this.isDigit(ch) && ch !== \",\") {\n return err<CronScannerError>(\n \"CronExpressionError\",\n `Invalid number '${content}' for field '${field}'`,\n );\n }\n\n const item = content.substring(this.start, this.current);\n this.addToken(item, \"number\", Number(item), field);\n return ok(true);\n }\n\n private handleRange(component: ComponentType) {\n const { field, content } = component;\n let ch = this.peek(content);\n\n if (!ch) {\n return err<CronScannerError>(\n \"CronExpressionError\",\n `Invalid range expression '${content}' for field '${field}'`,\n );\n }\n\n while (ch && this.isDigit(ch)) {\n this.advance(content);\n ch = this.peek(content);\n }\n\n if (!ch) {\n // Reached the end of the component\n const tokenContent = content.substring(this.start);\n this.addToken(tokenContent, \"range\", tokenContent, field);\n\n return ok(true);\n }\n\n if (this.match(content, \"/\")) {\n const [error, _] = this.handleStep(component);\n if (error) return err<CronScannerError>(error.type, error.message);\n\n return ok(true);\n }\n\n if (ch && ch !== \",\") {\n return err<CronScannerError>(\n \"CronExpressionError\",\n `Invalid range expression '${content}' for field '${field}'`,\n );\n }\n\n const tokenContent = content.substring(this.start, this.current);\n this.addToken(tokenContent, \"range\", tokenContent, field);\n return ok(true);\n }\n\n private isDigit(ch: string) {\n return ch >= \"0\" && ch <= \"9\";\n }\n\n private createComponent(fields: string[]) {\n const fieldNames = [\n \"second\",\n \"minute\",\n \"hour\",\n \"day\",\n \"month\",\n \"weekday\",\n ] as const;\n const components = [];\n let offset = 1;\n if (fields.length === FieldAmount.max) offset = 0;\n\n for (let idx = 0; idx < fields.length; idx++) {\n const fieldName = fieldNames[idx + offset];\n const content = fields[idx];\n if (!fieldName || !content) break;\n\n components.push({ content, field: fieldName });\n }\n\n return components;\n }\n}\n"],"mappings":";;AAGA,MAAa,cAAc;CACzB,KAAK;CACL,KAAK;CACN;AAWD,IAAa,QAAb,MAAmB;CACjB;CACA;CACA;CAEA;CAEA,YACE,WACA,MACA,OACA,OACA;AACA,OAAK,YAAY;AACjB,OAAK,OAAO;AACZ,OAAK,QAAQ;AACb,OAAK,QAAQ;;CAGf,eAAsB;AACpB,SAAO,KAAK;;CAGd,eAAsB;AACpB,SAAO,KAAK;;CAGd,gBAAuB;AACrB,SAAO,KAAK;;CAGd,WAAkB;AAChB,SAAO,KAAK;;CAGd,WAAkB;AAIhB,SAAO,SAHQ,cAAc,KAAK,UAAU,UAAU,KAAK,OAGpC,IAFV,UAAU,KAAK,MAAM,WAAW,KAAK,QAElB;;CAGlC,OAAc,OAAc;AAC1B,MAAI,CAAC,MAAO,QAAO;EAEnB,MAAM,mBAAmB,KAAK,cAAc,MAAM,cAAc;EAChE,MAAM,mBAAmB,KAAK,SAAS,MAAM,cAAc;EAC3D,MAAM,oBAAoB,KAAK,UAAU,MAAM,eAAe;EAC9D,MAAM,eAAe,KAAK,UAAU,MAAM,UAAU;AAEpD,SACE,oBAAoB,oBAAoB,qBAAqB;;;AAKnE,IAAa,UAAb,MAAqB;CACnB;CACA;CACA;CACA;CAEA,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c,SAAS,cAAc,MAAM;AAEzD,UAAO,GAAG,KAAK;;AAGjB,MAAI,KAAK,MAAM,SAAS,IAAI,EAAE;GAC5B,MAAM,CAAC,OAAO,KAAK,KAAK,WAAW,UAAU;AAC7C,OAAI,MAAO,QAAO,IAAsB,MAAM,MAAM,MAAM,QAAQ;AAElE,UAAO,GAAG,KAAK;;AAGjB,MAAI,MAAM,OAAO,IACf,QAAO,IACL,uBACA,6BAA6B,QAAQ,eAAe,MAAM,GAC3D;EAGH,MAAM,eAAe,QAAQ,UAAU,KAAK,OAAO,KAAK,QAAQ;AAChE,OAAK,SAAS,cAAc,SAAS,cAAc,MAAM;AACzD,SAAO,GAAG,KAAK;;CAGjB,QAAgB,IAAY;AAC1B,SAAO,MAAM,OAAO,MAAM;;CAG5B,gBAAwB,QAAkB;EACxC,MAAM,aAAa;GACjB;GACA;GACA;GACA;GACA;GACA;GACD;EACD,MAAM,aAAa,EAAE;EACrB,IAAI,SAAS;AACb,MAAI,OAAO,WAAW,YAAY,IAAK,UAAS;AAEhD,OAAK,IAAI,MAAM,GAAG,MAAM,OAAO,QAAQ,OAAO;GAC5C,MAAM,YAAY,WAAW,MAAM;GACnC,MAAM,UAAU,OAAO;AACvB,OAAI,CAAC,aAAa,CAAC,QAAS;AAE5B,cAAW,KAAK;IAAE;IAAS,OAAO;IAAW,CAAC;;AAGhD,SAAO"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/lib/cron/types.d.ts
|
|
2
|
+
type CronAlias = "@yearly" | "@monthly" | "@weekly" | "@daily" | "@hourly" | "@minutely";
|
|
3
|
+
type CronStatus = "idle" | "running" | "paused";
|
|
4
|
+
type CronOptions = {
|
|
5
|
+
name: string;
|
|
6
|
+
schedule: CronAlias | (string & {});
|
|
7
|
+
handler: () => void | Promise<void>;
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
export { CronOptions, CronStatus };
|
|
11
|
+
//# sourceMappingURL=types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":[],"sources":["../../src/lib/cron/types.ts"],"mappings":";KAAY,SAAA;AAAA,KAQA,UAAA;AAAA,KASA,WAAA;EACV,IAAA;EACA,QAAA,EAAU,SAAA;EACV,OAAA,eAAsB,OAAA;AAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/lib/cron/types.d.ts
|
|
2
|
+
type CronAlias = "@yearly" | "@monthly" | "@weekly" | "@daily" | "@hourly" | "@minutely";
|
|
3
|
+
type CronStatus = "idle" | "running" | "paused";
|
|
4
|
+
type CronOptions = {
|
|
5
|
+
name: string;
|
|
6
|
+
schedule: CronAlias | (string & {});
|
|
7
|
+
handler: () => void | Promise<void>;
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
export { CronOptions, CronStatus };
|
|
11
|
+
//# sourceMappingURL=types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.mts","names":[],"sources":["../../src/lib/cron/types.ts"],"mappings":";KAAY,SAAA;AAAA,KAQA,UAAA;AAAA,KASA,WAAA;EACV,IAAA;EACA,QAAA,EAAU,SAAA;EACV,OAAA,eAAsB,OAAA;AAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":[],"sources":["../../src/lib/errors/types.ts"],"mappings":";KAAY,WAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.mts","names":[],"sources":["../../src/lib/errors/types.ts"],"mappings":";KAAY,WAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/lib/i18n/types.d.ts
|
|
2
|
+
type ExtractParamType<T extends string> = T extends "string" ? string : T extends "number" ? number : T extends "boolean" ? boolean : never;
|
|
3
|
+
type BuildParamObject<T extends string, Acc = {}> = T extends `${infer _Start}{${infer Name}:${infer Type}}${infer Rest}` ? BuildParamObject<Rest, Acc & Record<Name, ExtractParamType<Type>>> : Acc;
|
|
4
|
+
type IsString<T> = T extends string ? true : false;
|
|
5
|
+
type IsArray<T> = T extends readonly unknown[] ? true : false;
|
|
6
|
+
type IsObject<T> = T extends object ? T extends readonly unknown[] ? false : true : false;
|
|
7
|
+
type ArrayKeys<T extends readonly unknown[]> = { [K in keyof T & `${number}`]: `${K}` }[keyof T & `${number}`];
|
|
8
|
+
type ObjectPropertyKeys<K extends string, V> = IsString<V> extends true ? K : IsArray<V> extends true ? V extends readonly unknown[] ? `${K}.${NestedKeyOf<V>}` : never : IsObject<V> extends true ? `${K}.${NestedKeyOf<V>}` : never;
|
|
9
|
+
type NestedKeyOf<T> = IsArray<T> extends true ? T extends readonly unknown[] ? ArrayKeys<T> : never : IsObject<T> extends true ? { [K in keyof T & string]: ObjectPropertyKeys<K, T[K]> }[keyof T & string] : never;
|
|
10
|
+
type GetNestedValue<T, K extends string> = K extends `${infer First}.${infer Rest}` ? First extends keyof T ? GetNestedValue<T[First], Rest> : never : K extends keyof T ? T[K] : never;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { BuildParamObject, GetNestedValue, NestedKeyOf };
|
|
13
|
+
//# sourceMappingURL=types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":[],"sources":["../../src/lib/i18n/types.ts"],"mappings":";KACY,gBAAA,qBAAqC,CAAA,6BAE7C,CAAA,6BAEE,CAAA;AAAA,KAIM,gBAAA,+BAGR,CAAA,uEACA,gBAAA,CAAiB,IAAA,EAAM,GAAA,GAAM,MAAA,CAAO,IAAA,EAAM,gBAAA,CAAiB,IAAA,MAC3D,GAAA;AAAA,KAGC,QAAA,MAAc,CAAA;AAAA,KACd,OAAA,MAAa,CAAA;AAAA,KACb,QAAA,MAAc,CAAA,kBACf,CAAA;AAAA,KAMC,SAAA,+CACS,CAAA,oBAAqB,CAAA,WAC3B,CAAA;AAAA,KAGH,kBAAA,wBAA0C,QAAA,CAAS,CAAA,iBACpD,CAAA,GACA,OAAA,CAAQ,CAAA,iBACN,CAAA,iCACK,CAAA,IAAK,WAAA,CAAY,CAAA,cAEtB,QAAA,CAAS,CAAA,oBACJ,CAAA,IAAK,WAAA,CAAY,CAAA;AAAA,KAIhB,WAAA,MACV,OAAA,CAAQ,CAAA,iBACJ,CAAA,8BACE,SAAA,CAAU,CAAA,YAEZ,QAAA,CAAS,CAAA,+BAEO,CAAA,YAAa,kBAAA,CAAmB,CAAA,EAAG,CAAA,CAAE,CAAA,WAC3C,CAAA;AAAA,KAIJ,cAAA,wBAGR,CAAA,0CACA,KAAA,eAAoB,CAAA,GAClB,cAAA,CAAe,CAAA,CAAE,KAAA,GAAQ,IAAA,YAE3B,CAAA,eAAgB,CAAA,GACd,CAAA,CAAE,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/lib/i18n/types.d.ts
|
|
2
|
+
type ExtractParamType<T extends string> = T extends "string" ? string : T extends "number" ? number : T extends "boolean" ? boolean : never;
|
|
3
|
+
type BuildParamObject<T extends string, Acc = {}> = T extends `${infer _Start}{${infer Name}:${infer Type}}${infer Rest}` ? BuildParamObject<Rest, Acc & Record<Name, ExtractParamType<Type>>> : Acc;
|
|
4
|
+
type IsString<T> = T extends string ? true : false;
|
|
5
|
+
type IsArray<T> = T extends readonly unknown[] ? true : false;
|
|
6
|
+
type IsObject<T> = T extends object ? T extends readonly unknown[] ? false : true : false;
|
|
7
|
+
type ArrayKeys<T extends readonly unknown[]> = { [K in keyof T & `${number}`]: `${K}` }[keyof T & `${number}`];
|
|
8
|
+
type ObjectPropertyKeys<K extends string, V> = IsString<V> extends true ? K : IsArray<V> extends true ? V extends readonly unknown[] ? `${K}.${NestedKeyOf<V>}` : never : IsObject<V> extends true ? `${K}.${NestedKeyOf<V>}` : never;
|
|
9
|
+
type NestedKeyOf<T> = IsArray<T> extends true ? T extends readonly unknown[] ? ArrayKeys<T> : never : IsObject<T> extends true ? { [K in keyof T & string]: ObjectPropertyKeys<K, T[K]> }[keyof T & string] : never;
|
|
10
|
+
type GetNestedValue<T, K extends string> = K extends `${infer First}.${infer Rest}` ? First extends keyof T ? GetNestedValue<T[First], Rest> : never : K extends keyof T ? T[K] : never;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { BuildParamObject, GetNestedValue, NestedKeyOf };
|
|
13
|
+
//# sourceMappingURL=types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.mts","names":[],"sources":["../../src/lib/i18n/types.ts"],"mappings":";KACY,gBAAA,qBAAqC,CAAA,6BAE7C,CAAA,6BAEE,CAAA;AAAA,KAIM,gBAAA,+BAGR,CAAA,uEACA,gBAAA,CAAiB,IAAA,EAAM,GAAA,GAAM,MAAA,CAAO,IAAA,EAAM,gBAAA,CAAiB,IAAA,MAC3D,GAAA;AAAA,KAGC,QAAA,MAAc,CAAA;AAAA,KACd,OAAA,MAAa,CAAA;AAAA,KACb,QAAA,MAAc,CAAA,kBACf,CAAA;AAAA,KAMC,SAAA,+CACS,CAAA,oBAAqB,CAAA,WAC3B,CAAA;AAAA,KAGH,kBAAA,wBAA0C,QAAA,CAAS,CAAA,iBACpD,CAAA,GACA,OAAA,CAAQ,CAAA,iBACN,CAAA,iCACK,CAAA,IAAK,WAAA,CAAY,CAAA,cAEtB,QAAA,CAAS,CAAA,oBACJ,CAAA,IAAK,WAAA,CAAY,CAAA;AAAA,KAIhB,WAAA,MACV,OAAA,CAAQ,CAAA,iBACJ,CAAA,8BACE,SAAA,CAAU,CAAA,YAEZ,QAAA,CAAS,CAAA,+BAEO,CAAA,YAAa,kBAAA,CAAmB,CAAA,EAAG,CAAA,CAAE,CAAA,WAC3C,CAAA;AAAA,KAIJ,cAAA,wBAGR,CAAA,0CACA,KAAA,eAAoB,CAAA,GAClB,cAAA,CAAe,CAAA,CAAE,KAAA,GAAQ,IAAA,YAE3B,CAAA,eAAgB,CAAA,GACd,CAAA,CAAE,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_index = require("../../api/core/index.cjs");
|
|
3
|
+
const require_index$1 = require("../../api/middleware/index.cjs");
|
|
4
|
+
exports.Api = require_index.Api;
|
|
5
|
+
exports.Middleware = require_index$1.Middleware;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { InferMiddlewareExtension, MergeMiddlewareExtensions, MiddlewareHandler, MiddlewareOptions } from "../../api/middleware/types.cjs";
|
|
2
|
+
import { ApiOptions, Context, ExtractStatusCodes, InferInput, InferOutput, OpenApiOptions, RequestSchema, ResponseSchema, RouteConfig, RouteHandler, SecurityScheme, SecuritySchemeApiKey, SecuritySchemeHttp, SecuritySchemeOAuth2, SecuritySchemeOAuth2Flow, SecuritySchemeOpenIdConnect } from "../../api/core/types.cjs";
|
|
3
|
+
import { Middleware } from "../../api/middleware/index.cjs";
|
|
4
|
+
import { Api } from "../../api/core/index.cjs";
|
|
5
|
+
export { Api, type ApiOptions, type Context, type ExtractStatusCodes, type InferInput, type InferMiddlewareExtension, type InferOutput, type MergeMiddlewareExtensions, Middleware, type MiddlewareHandler, type MiddlewareOptions, type OpenApiOptions, type RequestSchema, type ResponseSchema, type RouteConfig, type RouteHandler, type SecurityScheme, type SecuritySchemeApiKey, type SecuritySchemeHttp, type SecuritySchemeOAuth2, type SecuritySchemeOAuth2Flow, type SecuritySchemeOpenIdConnect };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { InferMiddlewareExtension, MergeMiddlewareExtensions, MiddlewareHandler, MiddlewareOptions } from "../../api/middleware/types.mjs";
|
|
2
|
+
import { ApiOptions, Context, ExtractStatusCodes, InferInput, InferOutput, OpenApiOptions, RequestSchema, ResponseSchema, RouteConfig, RouteHandler, SecurityScheme, SecuritySchemeApiKey, SecuritySchemeHttp, SecuritySchemeOAuth2, SecuritySchemeOAuth2Flow, SecuritySchemeOpenIdConnect } from "../../api/core/types.mjs";
|
|
3
|
+
import { Middleware } from "../../api/middleware/index.mjs";
|
|
4
|
+
import { Api } from "../../api/core/index.mjs";
|
|
5
|
+
export { Api, type ApiOptions, type Context, type ExtractStatusCodes, type InferInput, type InferMiddlewareExtension, type InferOutput, type MergeMiddlewareExtensions, Middleware, type MiddlewareHandler, type MiddlewareOptions, type OpenApiOptions, type RequestSchema, type ResponseSchema, type RouteConfig, type RouteHandler, type SecurityScheme, type SecuritySchemeApiKey, type SecuritySchemeHttp, type SecuritySchemeOAuth2, type SecuritySchemeOAuth2Flow, type SecuritySchemeOpenIdConnect };
|