cronli5 0.2.1 → 0.3.4
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/CHANGELOG.md +109 -0
- package/README.md +4 -4
- package/cronli5.min.js +2 -2
- package/dist/cronli5.cjs +471 -383
- package/dist/cronli5.js +471 -383
- package/dist/lang/de.cjs +286 -215
- package/dist/lang/de.js +286 -215
- package/dist/lang/en.cjs +413 -327
- package/dist/lang/en.js +413 -327
- package/dist/lang/es.cjs +303 -265
- package/dist/lang/es.js +303 -265
- package/dist/lang/fi.cjs +311 -266
- package/dist/lang/fi.js +311 -266
- package/dist/lang/zh.cjs +320 -240
- package/dist/lang/zh.js +320 -240
- package/package.json +6 -6
- package/src/core/analyze.ts +12 -12
- package/src/core/cadence.ts +164 -0
- package/src/core/index.ts +3 -1
- package/src/core/normalize.ts +3 -3
- package/src/core/parse.ts +1 -1
- package/src/core/{ir.ts → schedule.ts} +17 -18
- package/src/core/specs.ts +1 -1
- package/src/core/util.ts +3 -165
- package/src/core/validate.ts +1 -1
- package/src/core/weekday.ts +54 -0
- package/src/cronli5.ts +5 -5
- package/src/lang/de/index.ts +329 -219
- package/src/lang/en/dialects.ts +1 -1
- package/src/lang/en/index.ts +521 -372
- package/src/lang/es/index.ts +338 -286
- package/src/lang/es/notes.md +1 -1
- package/src/lang/fi/dialects.ts +1 -1
- package/src/lang/fi/index.ts +365 -299
- package/src/lang/fi/notes.md +23 -8
- package/src/lang/fi/status.json +1 -1
- package/src/lang/zh/index.ts +386 -245
- package/src/types.ts +6 -6
- package/types/core/analyze.d.ts +3 -3
- package/types/core/cadence.d.ts +33 -0
- package/types/core/index.d.ts +3 -1
- package/types/core/normalize.d.ts +1 -1
- package/types/core/parse.d.ts +1 -1
- package/types/core/{ir.d.ts → schedule.d.ts} +11 -16
- package/types/core/specs.d.ts +1 -1
- package/types/core/util.d.ts +1 -30
- package/types/core/weekday.d.ts +10 -0
- package/types/lang/de/index.d.ts +1 -1
- package/types/lang/en/dialects.d.ts +1 -1
- package/types/lang/en/index.d.ts +1 -1
- package/types/lang/es/index.d.ts +1 -1
- package/types/lang/fi/dialects.d.ts +1 -1
- package/types/lang/fi/index.d.ts +1 -1
- package/types/lang/zh/index.d.ts +1 -1
- package/types/types.d.ts +5 -5
package/src/types.ts
CHANGED
|
@@ -46,22 +46,22 @@ export interface Cronli5Dialect {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
|
-
* A language module is a renderer over the semantic
|
|
49
|
+
* A language module is a renderer over the semantic Schedule plus the
|
|
50
50
|
* language-owned strings and option normalization. The `describe`/`options`
|
|
51
|
-
* payloads are the module's internal `
|
|
52
|
-
* `core/
|
|
51
|
+
* payloads are the module's internal `Schedule`/options shapes (see
|
|
52
|
+
* `core/schedule.ts`). They are intentionally opaque at this public boundary,
|
|
53
53
|
* which a caller passes to `cronli5` via the `lang` option but never invokes
|
|
54
54
|
* directly.
|
|
55
55
|
*/
|
|
56
56
|
export interface Cronli5Language {
|
|
57
|
-
describe(
|
|
57
|
+
describe(schedule: any, opts: any): string;
|
|
58
58
|
fallback: string;
|
|
59
59
|
options(options?: Cronli5Options): any;
|
|
60
60
|
reboot: string;
|
|
61
61
|
sentence(description: string): string;
|
|
62
|
-
// Optional plan override (see `core/
|
|
62
|
+
// Optional plan override (see `core/schedule.ts` `Language.plan`). Opaque
|
|
63
63
|
// at this public boundary, like `describe`/`options`.
|
|
64
|
-
plan?(
|
|
64
|
+
plan?(facts: any, base: any): any;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
/**
|
package/types/core/analyze.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Pattern, PlanNode, Schedule, ScheduleFacts } from './schedule.js';
|
|
2
2
|
declare function getOccurrences(start: number, interval: number, max: number): number[];
|
|
3
3
|
declare function enumerateStep(field: string, min: number, max: number, numberMap?: {
|
|
4
4
|
[name: string]: number;
|
|
@@ -8,6 +8,6 @@ declare function enumerateValues(field: string): number[];
|
|
|
8
8
|
declare function minuteSpan(minuteField: string): [number, number] | null;
|
|
9
9
|
declare function lastMinuteFire(minuteField: string): number;
|
|
10
10
|
declare function clockSecond(secondField: string): number | undefined;
|
|
11
|
-
declare function analyze(pattern: Pattern):
|
|
12
|
-
declare function selectPlan(
|
|
11
|
+
declare function analyze(pattern: Pattern): Schedule;
|
|
12
|
+
declare function selectPlan(facts: ScheduleFacts): PlanNode;
|
|
13
13
|
export { analyze, clockSecond, enumerateFires, enumerateStep, enumerateValues, getOccurrences, lastMinuteFire, minuteSpan, selectPlan };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Field, Schedule, Segment } from './schedule.js';
|
|
2
|
+
type StepSegment = Extract<Segment, {
|
|
3
|
+
kind: 'step';
|
|
4
|
+
}>;
|
|
5
|
+
declare function arithmeticStep(values: number[]): {
|
|
6
|
+
start: number;
|
|
7
|
+
interval: number;
|
|
8
|
+
last: number;
|
|
9
|
+
} | null;
|
|
10
|
+
declare function segmentsOf(schedule: Schedule, field: Field): Segment[];
|
|
11
|
+
declare function stepSegment(schedule: Schedule, field: Field): StepSegment;
|
|
12
|
+
declare function singleValues(segments: Segment[]): number[] | null;
|
|
13
|
+
declare function offsetCleanStride(stride: {
|
|
14
|
+
start: number;
|
|
15
|
+
interval: number;
|
|
16
|
+
}): boolean;
|
|
17
|
+
interface StrideParts {
|
|
18
|
+
bare(): string;
|
|
19
|
+
offset(): string;
|
|
20
|
+
bounded(): string;
|
|
21
|
+
}
|
|
22
|
+
declare function renderStride(spec: {
|
|
23
|
+
start: number;
|
|
24
|
+
interval: number;
|
|
25
|
+
cycle: number;
|
|
26
|
+
}, parts: StrideParts): string;
|
|
27
|
+
declare function hourListStride(values: number[]): {
|
|
28
|
+
start: number;
|
|
29
|
+
interval: number;
|
|
30
|
+
last: number;
|
|
31
|
+
} | null;
|
|
32
|
+
export { arithmeticStep, hourListStride, offsetCleanStride, renderStride, segmentsOf, singleValues, stepSegment };
|
|
33
|
+
export type { StrideParts };
|
package/types/core/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import type { NormalizedOptions, Pattern } from './
|
|
1
|
+
import type { NormalizedOptions, Pattern } from './schedule.js';
|
|
2
2
|
import type { CronPattern } from '../types.js';
|
|
3
3
|
declare function prepare(cronPattern: CronPattern, opts: NormalizedOptions): Pattern;
|
|
4
4
|
export { prepare };
|
|
5
5
|
export * from './specs.js';
|
|
6
6
|
export * from './util.js';
|
|
7
|
+
export * from './weekday.js';
|
|
8
|
+
export * from './cadence.js';
|
|
7
9
|
export * from './shapes.js';
|
|
8
10
|
export * from './analyze.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CronLike } from './specs.js';
|
|
2
|
-
import type { Pattern } from './
|
|
2
|
+
import type { Pattern } from './schedule.js';
|
|
3
3
|
declare function applyQuartzAliases(cronPattern: CronLike): void;
|
|
4
4
|
declare function normalizeCronPattern(cronPattern: CronLike): Pattern;
|
|
5
5
|
export { applyQuartzAliases, normalizeCronPattern };
|
package/types/core/parse.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CronLike } from './specs.js';
|
|
2
|
-
import type { NormalizedOptions } from './
|
|
2
|
+
import type { NormalizedOptions } from './schedule.js';
|
|
3
3
|
import type { CronPattern } from '../types.js';
|
|
4
4
|
declare function parseCronPattern(cronPattern: CronPattern, opts: NormalizedOptions): CronLike;
|
|
5
5
|
export { parseCronPattern };
|
|
@@ -43,11 +43,6 @@ export type HoursPlan = {
|
|
|
43
43
|
} | {
|
|
44
44
|
kind: 'during';
|
|
45
45
|
times: HourTimesPlan;
|
|
46
|
-
} | {
|
|
47
|
-
kind: 'single';
|
|
48
|
-
from: number;
|
|
49
|
-
to: number;
|
|
50
|
-
last: number;
|
|
51
46
|
};
|
|
52
47
|
/** Hour times: enumerated fires, or deferred to per-segment rendering. */
|
|
53
48
|
export type HourTimesPlan = {
|
|
@@ -121,25 +116,25 @@ export interface Analyses {
|
|
|
121
116
|
segments: Record<Field, Segment[] | null>;
|
|
122
117
|
}
|
|
123
118
|
/**
|
|
124
|
-
* The neutral
|
|
119
|
+
* The neutral schedule facts: the language-independent facts about a pattern,
|
|
125
120
|
* carrying no phrasing decision. `analyze` produces this; `selectPlan`
|
|
126
121
|
* reads it to suggest a `plan`. The phrasing plan is deliberately *not*
|
|
127
|
-
* part of the neutral
|
|
122
|
+
* part of the neutral facts (docs/i18n-design.md §2.2).
|
|
128
123
|
*/
|
|
129
|
-
export interface
|
|
124
|
+
export interface ScheduleFacts {
|
|
130
125
|
pattern: Pattern;
|
|
131
126
|
shapes: Shapes;
|
|
132
127
|
analyses: Analyses;
|
|
133
128
|
}
|
|
134
129
|
/**
|
|
135
|
-
* The semantic
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
130
|
+
* The semantic schedule a language renders: the neutral `ScheduleFacts`
|
|
131
|
+
* plus the selected `plan`. A language may widen `plan` with its own
|
|
132
|
+
* `Extra` plan kinds via `Language.plan`; by default there are none, so
|
|
133
|
+
* `Schedule` is the neutral facts with a core `PlanNode`.
|
|
139
134
|
*/
|
|
140
|
-
export interface
|
|
135
|
+
export interface Schedule<Extra extends {
|
|
141
136
|
kind: string;
|
|
142
|
-
} = never> extends
|
|
137
|
+
} = never> extends ScheduleFacts {
|
|
143
138
|
plan: PlanNode | Extra;
|
|
144
139
|
}
|
|
145
140
|
/** A resolved style table. */
|
|
@@ -178,10 +173,10 @@ export interface NormalizedOptions<Style = DialectStyle> {
|
|
|
178
173
|
export interface Language<Style = DialectStyle, Extra extends {
|
|
179
174
|
kind: string;
|
|
180
175
|
} = never> {
|
|
181
|
-
describe(
|
|
176
|
+
describe(schedule: Schedule<Extra>, opts: NormalizedOptions<Style>): string;
|
|
182
177
|
fallback: string;
|
|
183
178
|
options(options?: Cronli5Options): NormalizedOptions<Style>;
|
|
184
179
|
reboot: string;
|
|
185
180
|
sentence(description: string): string;
|
|
186
|
-
plan?(
|
|
181
|
+
plan?(facts: ScheduleFacts, base: PlanNode): PlanNode | Extra;
|
|
187
182
|
}
|
package/types/core/specs.d.ts
CHANGED
package/types/core/util.d.ts
CHANGED
|
@@ -1,36 +1,7 @@
|
|
|
1
|
-
import type { Field, IR, Segment } from './ir.js';
|
|
2
|
-
type StepSegment = Extract<Segment, {
|
|
3
|
-
kind: 'step';
|
|
4
|
-
}>;
|
|
5
1
|
declare function includes(str: string | number, sub: string): boolean;
|
|
6
2
|
declare function unique<T>(items: T[]): T[];
|
|
7
3
|
declare function isNonNegativeInteger(value: string): boolean;
|
|
8
|
-
declare function arithmeticStep(values: number[]): {
|
|
9
|
-
start: number;
|
|
10
|
-
interval: number;
|
|
11
|
-
last: number;
|
|
12
|
-
} | null;
|
|
13
|
-
type WeekdaySegment = {
|
|
14
|
-
kind: 'single';
|
|
15
|
-
value: string;
|
|
16
|
-
} | {
|
|
17
|
-
kind: 'range';
|
|
18
|
-
bounds: [string, string];
|
|
19
|
-
};
|
|
20
|
-
declare function orderWeekdaysForDisplay(segments: Segment[]): WeekdaySegment[];
|
|
21
4
|
declare function toFieldNumber(token: string, numberMap?: {
|
|
22
5
|
[name: string]: number;
|
|
23
6
|
}): number;
|
|
24
|
-
|
|
25
|
-
declare function stepSegment(ir: IR, field: Field): StepSegment;
|
|
26
|
-
declare function singleValues(segments: Segment[]): number[] | null;
|
|
27
|
-
declare function offsetCleanStride(stride: {
|
|
28
|
-
start: number;
|
|
29
|
-
interval: number;
|
|
30
|
-
}): boolean;
|
|
31
|
-
declare function hourListStride(values: number[]): {
|
|
32
|
-
start: number;
|
|
33
|
-
interval: number;
|
|
34
|
-
last: number;
|
|
35
|
-
} | null;
|
|
36
|
-
export { arithmeticStep, hourListStride, includes, isNonNegativeInteger, offsetCleanStride, orderWeekdaysForDisplay, segmentsOf, singleValues, stepSegment, toFieldNumber, unique };
|
|
7
|
+
export { includes, isNonNegativeInteger, toFieldNumber, unique };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Segment } from './schedule.js';
|
|
2
|
+
type WeekdaySegment = {
|
|
3
|
+
kind: 'single';
|
|
4
|
+
value: string;
|
|
5
|
+
} | {
|
|
6
|
+
kind: 'range';
|
|
7
|
+
bounds: [string, string];
|
|
8
|
+
};
|
|
9
|
+
declare function orderWeekdaysForDisplay(segments: Segment[]): WeekdaySegment[];
|
|
10
|
+
export { orderWeekdaysForDisplay };
|
package/types/lang/de/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Cronli5Options } from '../../types.js';
|
|
2
|
-
import type { DialectStyle } from '../../core/
|
|
2
|
+
import type { DialectStyle } from '../../core/schedule.js';
|
|
3
3
|
declare function resolveDialect(dialect?: Cronli5Options['dialect']): DialectStyle;
|
|
4
4
|
export { resolveDialect };
|
package/types/lang/en/index.d.ts
CHANGED
package/types/lang/es/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DialectStyle } from '../../core/
|
|
1
|
+
import type { DialectStyle } from '../../core/schedule.js';
|
|
2
2
|
import type { Cronli5Options } from '../../types.js';
|
|
3
3
|
declare function resolveDialect(dialect?: Cronli5Options['dialect']): DialectStyle;
|
|
4
4
|
export { resolveDialect };
|
package/types/lang/fi/index.d.ts
CHANGED
package/types/lang/zh/index.d.ts
CHANGED
package/types/types.d.ts
CHANGED
|
@@ -30,20 +30,20 @@ export interface Cronli5Dialect {
|
|
|
30
30
|
through?: string;
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
|
-
* A language module is a renderer over the semantic
|
|
33
|
+
* A language module is a renderer over the semantic Schedule plus the
|
|
34
34
|
* language-owned strings and option normalization. The `describe`/`options`
|
|
35
|
-
* payloads are the module's internal `
|
|
36
|
-
* `core/
|
|
35
|
+
* payloads are the module's internal `Schedule`/options shapes (see
|
|
36
|
+
* `core/schedule.ts`). They are intentionally opaque at this public boundary,
|
|
37
37
|
* which a caller passes to `cronli5` via the `lang` option but never invokes
|
|
38
38
|
* directly.
|
|
39
39
|
*/
|
|
40
40
|
export interface Cronli5Language {
|
|
41
|
-
describe(
|
|
41
|
+
describe(schedule: any, opts: any): string;
|
|
42
42
|
fallback: string;
|
|
43
43
|
options(options?: Cronli5Options): any;
|
|
44
44
|
reboot: string;
|
|
45
45
|
sentence(description: string): string;
|
|
46
|
-
plan?(
|
|
46
|
+
plan?(facts: any, base: any): any;
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
49
|
* Option flags accepted as the second argument to `cronli5`.
|