@mirta/globals 0.2.2 → 0.2.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/eslint/index.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  declare interface GlobalsMirta {
2
+ readonly '__DEV__': false
3
+ readonly '__TEST__': false
2
4
  readonly 'log': false
3
5
  readonly 'dev': false
6
+ readonly 'cron': false
4
7
  readonly 'timers': false
5
8
  readonly 'defineRule': false
6
9
  readonly 'defineAlias': false
package/eslint/index.js CHANGED
@@ -1,6 +1,9 @@
1
1
  export default {
2
+ '__DEV__': 'readonly',
3
+ '__TEST__': 'readonly',
2
4
  'log': 'readonly',
3
5
  'dev': 'readonly',
6
+ 'cron': 'readonly',
4
7
  'timers': 'readonly',
5
8
  'defineRule': 'readonly',
6
9
  'defineAlias': 'readonly',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mirta/globals",
3
3
  "description": "Complete set of types for wb-rule development in TypeScript",
4
- "version": "0.2.2",
4
+ "version": "0.2.4",
5
5
  "license": "Unlicense",
6
6
  "keywords": [
7
7
  "mirta",
@@ -66,6 +66,10 @@ declare namespace WbRules {
66
66
  error(message: string | undefined, ...args: (string | number | boolean)[]): void
67
67
  }
68
68
 
69
+ interface CronEntry {
70
+ spec: string
71
+ }
72
+
69
73
  interface Timer {
70
74
  firing: boolean
71
75
 
@@ -99,9 +103,12 @@ declare namespace WbRules {
99
103
  asSoonAs?(): boolean
100
104
 
101
105
  /**
102
- * Функция, которая сигнализирует, что правило должно отработать
103
- */
104
- when?(): number | boolean
106
+ * Функция или экземпляр {@link CronEntry}, возвращаемый функцией {@link cron}.
107
+ *
108
+ * Сигнализирует, когда правило должно отработать.
109
+ *
110
+ **/
111
+ when?: CronEntry | (() => number | boolean)
105
112
 
106
113
  /**
107
114
  * Функция, которая вызывается при срабатывании правила
@@ -460,6 +467,23 @@ declare var dev: WbRules.Dev
460
467
  /** Объект доступа к именованным таймера. */
461
468
  declare var timers: WbRules.TimerCollection
462
469
 
470
+ /**
471
+ * Используется для ввода спецификации cron-правила.
472
+ *
473
+ * Подробное описание формата выражений используемой cron-библиотеки:
474
+
475
+ * https://pkg.go.dev/github.com/robfig/cron/v3#hdr-CRON_Expression_Format
476
+ *
477
+ * @example
478
+ * ```ts
479
+ * defineRule('cron_hourly', {
480
+ * when: cron('@hourly'),
481
+ * then: () => log('@hourly rule raised')
482
+ * })
483
+ * ```
484
+ **/
485
+ declare function cron(spec: string): WbRules.CronEntry
486
+
463
487
  /**
464
488
  * Создаёт правило обработки.
465
489
  * @param ruleName Название правила.