cronli5 0.2.1 → 0.3.1

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 (54) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/cronli5.min.js +2 -2
  3. package/dist/cronli5.cjs +471 -383
  4. package/dist/cronli5.js +471 -383
  5. package/dist/lang/de.cjs +286 -215
  6. package/dist/lang/de.js +286 -215
  7. package/dist/lang/en.cjs +413 -327
  8. package/dist/lang/en.js +413 -327
  9. package/dist/lang/es.cjs +303 -265
  10. package/dist/lang/es.js +303 -265
  11. package/dist/lang/fi.cjs +311 -266
  12. package/dist/lang/fi.js +311 -266
  13. package/dist/lang/zh.cjs +308 -236
  14. package/dist/lang/zh.js +308 -236
  15. package/package.json +1 -1
  16. package/src/core/analyze.ts +12 -12
  17. package/src/core/cadence.ts +164 -0
  18. package/src/core/index.ts +3 -1
  19. package/src/core/normalize.ts +3 -3
  20. package/src/core/parse.ts +1 -1
  21. package/src/core/{ir.ts → schedule.ts} +17 -18
  22. package/src/core/specs.ts +1 -1
  23. package/src/core/util.ts +3 -165
  24. package/src/core/validate.ts +1 -1
  25. package/src/core/weekday.ts +54 -0
  26. package/src/cronli5.ts +5 -5
  27. package/src/lang/de/index.ts +329 -219
  28. package/src/lang/en/dialects.ts +1 -1
  29. package/src/lang/en/index.ts +521 -372
  30. package/src/lang/es/index.ts +338 -286
  31. package/src/lang/es/notes.md +1 -1
  32. package/src/lang/fi/dialects.ts +1 -1
  33. package/src/lang/fi/index.ts +365 -299
  34. package/src/lang/fi/notes.md +23 -8
  35. package/src/lang/fi/status.json +1 -1
  36. package/src/lang/zh/index.ts +344 -237
  37. package/src/types.ts +6 -6
  38. package/types/core/analyze.d.ts +3 -3
  39. package/types/core/cadence.d.ts +33 -0
  40. package/types/core/index.d.ts +3 -1
  41. package/types/core/normalize.d.ts +1 -1
  42. package/types/core/parse.d.ts +1 -1
  43. package/types/core/{ir.d.ts → schedule.d.ts} +11 -16
  44. package/types/core/specs.d.ts +1 -1
  45. package/types/core/util.d.ts +1 -30
  46. package/types/core/weekday.d.ts +10 -0
  47. package/types/lang/de/index.d.ts +1 -1
  48. package/types/lang/en/dialects.d.ts +1 -1
  49. package/types/lang/en/index.d.ts +1 -1
  50. package/types/lang/es/index.d.ts +1 -1
  51. package/types/lang/fi/dialects.d.ts +1 -1
  52. package/types/lang/fi/index.d.ts +1 -1
  53. package/types/lang/zh/index.d.ts +1 -1
  54. 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 IR plus the
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 `IR`/options shapes (see
52
- * `core/ir.ts`). They are intentionally opaque at this public boundary,
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(ir: any, opts: any): string;
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/ir.ts` `Language.plan`). Opaque
62
+ // Optional plan override (see `core/schedule.ts` `Language.plan`). Opaque
63
63
  // at this public boundary, like `describe`/`options`.
64
- plan?(content: any, base: any): any;
64
+ plan?(facts: any, base: any): any;
65
65
  }
66
66
 
67
67
  /**
@@ -1,4 +1,4 @@
1
- import type { Content, IR, Pattern, PlanNode } from './ir.js';
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): IR;
12
- declare function selectPlan(content: Content): PlanNode;
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 };
@@ -1,8 +1,10 @@
1
- import type { NormalizedOptions, Pattern } from './ir.js';
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 './ir.js';
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 };
@@ -1,5 +1,5 @@
1
1
  import type { CronLike } from './specs.js';
2
- import type { NormalizedOptions } from './ir.js';
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 content plan: the language-independent facts about a pattern,
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 content (docs/i18n-design.md §2.2).
122
+ * part of the neutral facts (docs/i18n-design.md §2.2).
128
123
  */
129
- export interface Content {
124
+ export interface ScheduleFacts {
130
125
  pattern: Pattern;
131
126
  shapes: Shapes;
132
127
  analyses: Analyses;
133
128
  }
134
129
  /**
135
- * The semantic intermediate representation a language renders: the neutral
136
- * `Content` plus the selected `plan`. A language may widen `plan` with its
137
- * own `Extra` plan kinds via `Language.plan`; by default there are
138
- * none, so `IR` is the neutral content with a core `PlanNode`.
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 IR<Extra extends {
135
+ export interface Schedule<Extra extends {
141
136
  kind: string;
142
- } = never> extends Content {
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(ir: IR<Extra>, opts: NormalizedOptions<Style>): string;
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?(content: Content, base: PlanNode): PlanNode | Extra;
181
+ plan?(facts: ScheduleFacts, base: PlanNode): PlanNode | Extra;
187
182
  }
@@ -1,4 +1,4 @@
1
- import type { Field } from './ir.js';
1
+ import type { Field } from './schedule.js';
2
2
  /**
3
3
  * A parsed but not-yet-canonical cron pattern: every field present, values
4
4
  * still as the caller gave them (string or number) until normalization
@@ -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
- declare function segmentsOf(ir: IR, field: Field): Segment[];
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 };
@@ -1,4 +1,4 @@
1
- import type { Language } from '../../core/ir.js';
1
+ import type { Language } from '../../core/schedule.js';
2
2
  import { type GermanStyle } from './dialects.js';
3
3
  declare const de: Language<GermanStyle>;
4
4
  export default de;
@@ -1,4 +1,4 @@
1
1
  import type { Cronli5Options } from '../../types.js';
2
- import type { DialectStyle } from '../../core/ir.js';
2
+ import type { DialectStyle } from '../../core/schedule.js';
3
3
  declare function resolveDialect(dialect?: Cronli5Options['dialect']): DialectStyle;
4
4
  export { resolveDialect };
@@ -1,3 +1,3 @@
1
- import type { Language } from '../../core/ir.js';
1
+ import type { Language } from '../../core/schedule.js';
2
2
  declare const en: Language;
3
3
  export default en;
@@ -1,4 +1,4 @@
1
- import type { Language } from '../../core/ir.js';
1
+ import type { Language } from '../../core/schedule.js';
2
2
  import { type SpanishStyle } from './dialects.js';
3
3
  declare const es: Language<SpanishStyle>;
4
4
  export default es;
@@ -1,4 +1,4 @@
1
- import type { DialectStyle } from '../../core/ir.js';
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 };
@@ -1,3 +1,3 @@
1
- import type { Language } from '../../core/ir.js';
1
+ import type { Language } from '../../core/schedule.js';
2
2
  declare const fi: Language;
3
3
  export default fi;
@@ -1,4 +1,4 @@
1
- import type { Language } from '../../core/ir.js';
1
+ import type { Language } from '../../core/schedule.js';
2
2
  import { type ChineseStyle } from './dialects.js';
3
3
  declare const zh: Language<ChineseStyle>;
4
4
  export default zh;
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 IR plus the
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 `IR`/options shapes (see
36
- * `core/ir.ts`). They are intentionally opaque at this public boundary,
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(ir: any, opts: any): string;
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?(content: any, base: any): any;
46
+ plan?(facts: any, base: any): any;
47
47
  }
48
48
  /**
49
49
  * Option flags accepted as the second argument to `cronli5`.