-
Notifications
You must be signed in to change notification settings - Fork 21
/
types.ts
65 lines (58 loc) · 1.74 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import type { CronType, TextPosition } from '@/types'
// https://stackoverflow.com/a/53276873/3140799
export type PartialRecord<K extends keyof any, T> = Partial<Record<K, T>>
export type PositionedLocalization = PartialRecord<TextPosition, string>
export type CronLocalization = PartialRecord<CronType | '*', PositionedLocalization>
export interface FieldLocalization {
// Allow custom field ids
[fieldId: string]: unknown
/** `*` is used as a wildcard and matches any field id */
'*'?: CronLocalization
second?: CronLocalization
minute?: CronLocalization
hour?: CronLocalization
day?: CronLocalization
month?: CronLocalization
dayOfWeek?: CronLocalization
}
export type PeriodLocalization = PositionedLocalization | FieldLocalization
/**
* Interface to define localizations for vue-js-cron
* The localization strings are accessed by {periodId}.{fieldId}.{cronType}.{position}
*
* See {@link https://github.com/abichinger/vue-js-cron/blob/main/core/src/locale/en.ts | src/locale/en.ts} for the english localization object.
*
* @example
* Here is an incomplete example
* ```
* const myLocale: Localization = {
* '*': {
* prefix: 'Every',
* '*': {
* empty: { text: 'any {field.id}' },
* // ...
* },
* hour: {
* empty: { text: 'every' },
* // ...
* },
* },
* month: {
* prefix: 'EVERY',
* },
* // ...
* }
* ```
*/
export interface Localization {
/** Allows custom period ids */
[periodId: string]: unknown
/** `*` is used as a wildcard and matches any period id */
'*'?: PeriodLocalization
minute?: PeriodLocalization
hour?: PeriodLocalization
day?: PeriodLocalization
week?: PeriodLocalization
month?: PeriodLocalization
year?: PeriodLocalization
}