@lighthouse/common 5.0.0-canary-11 → 5.0.0-canary-13

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 (91) hide show
  1. package/dist/helpers/build-fetch-url/index.js +2 -2
  2. package/dist/helpers/fetch-image/index.js +1 -1
  3. package/dist/helpers/fetch-image-for-pdf-generator-service/index.js +9 -9
  4. package/dist/helpers/fetch-image-for-web/index.js +3 -14
  5. package/dist/helpers/get-audit-entry-details/index.js +2 -0
  6. package/dist/helpers/get-issue-details/index.js +2 -0
  7. package/dist/helpers/get-task-entry-details/index.js +3 -1
  8. package/dist/pdf/helpers/fields/index.js +2 -2
  9. package/dist/scheduling/scheduling.types.js +9 -9
  10. package/dist/service-hours/schema.js +12 -12
  11. package/lib/errors/DomainError.js +7 -8
  12. package/lib/errors/DomainError.js.map +1 -1
  13. package/lib/errors/ValidationError.js +11 -9
  14. package/lib/errors/ValidationError.js.map +1 -1
  15. package/lib/helpers/build-fetch-url/index.js +2 -2
  16. package/lib/helpers/build-fetch-url/index.js.map +1 -1
  17. package/lib/helpers/fetch-image/index.js +1 -1
  18. package/lib/helpers/fetch-image/index.js.map +1 -1
  19. package/lib/helpers/fetch-image-for-pdf-generator-service/index.js +174 -180
  20. package/lib/helpers/fetch-image-for-pdf-generator-service/index.js.map +1 -1
  21. package/lib/helpers/fetch-image-for-web/index.js +60 -74
  22. package/lib/helpers/fetch-image-for-web/index.js.map +1 -1
  23. package/lib/helpers/fetch-lighthouse-logo/index.js +41 -43
  24. package/lib/helpers/fetch-lighthouse-logo/index.js.map +1 -1
  25. package/lib/helpers/get-audit-entry-details/index.js +2 -0
  26. package/lib/helpers/get-audit-entry-details/index.js.map +1 -1
  27. package/lib/helpers/get-audit-items-data/index.js +8 -8
  28. package/lib/helpers/get-audit-items-data/index.js.map +1 -1
  29. package/lib/helpers/get-issue-details/index.js +2 -0
  30. package/lib/helpers/get-issue-details/index.js.map +1 -1
  31. package/lib/helpers/get-job-details/index.js.map +1 -1
  32. package/lib/helpers/get-location-reference/index.js +6 -4
  33. package/lib/helpers/get-location-reference/index.js.map +1 -1
  34. package/lib/helpers/get-reference-details/index.js.map +1 -1
  35. package/lib/helpers/get-task-entry-details/index.js +3 -1
  36. package/lib/helpers/get-task-entry-details/index.js.map +1 -1
  37. package/lib/helpers/get-timezone-datetime/index.js.map +1 -1
  38. package/lib/pdf/activity-report/index.js +299 -311
  39. package/lib/pdf/activity-report/index.js.map +1 -1
  40. package/lib/pdf/audit/index.js.map +1 -1
  41. package/lib/pdf/helpers/build-audit-content/index.js.map +1 -1
  42. package/lib/pdf/helpers/build-audit-follow-ups/index.js.map +1 -1
  43. package/lib/pdf/helpers/build-location-scans-content/index.js.map +1 -1
  44. package/lib/pdf/helpers/build-template-content/index.js.map +1 -1
  45. package/lib/pdf/helpers/fields/index.js +14 -14
  46. package/lib/pdf/helpers/fields/index.js.map +1 -1
  47. package/lib/pdf/helpers/generate-definition/index.js.map +1 -1
  48. package/lib/pdf/helpers/horizontal-line/index.js.map +1 -1
  49. package/lib/pdf/helpers/html-transformer/index.js +1 -2
  50. package/lib/pdf/helpers/html-transformer/index.js.map +1 -1
  51. package/lib/pdf/helpers/table/index.js +63 -65
  52. package/lib/pdf/helpers/table/index.js.map +1 -1
  53. package/lib/pdf/issue/index.js.map +1 -1
  54. package/lib/pdf/job/index.js.map +1 -1
  55. package/lib/pdf/shift-report/index.js +275 -291
  56. package/lib/pdf/shift-report/index.js.map +1 -1
  57. package/lib/pdf/task/index.js.map +1 -1
  58. package/lib/scheduling/generators/occurrenceIntervalsGenerator.js +27 -30
  59. package/lib/scheduling/generators/occurrenceIntervalsGenerator.js.map +1 -1
  60. package/lib/scheduling/generators/scheduleIntervalsGenerator.js +19 -21
  61. package/lib/scheduling/generators/scheduleIntervalsGenerator.js.map +1 -1
  62. package/lib/scheduling/generators/serviceIntervalsGenerator.js +134 -136
  63. package/lib/scheduling/generators/serviceIntervalsGenerator.js.map +1 -1
  64. package/lib/scheduling/helpers/generateNonRepeatingSchedule.js +81 -83
  65. package/lib/scheduling/helpers/generateNonRepeatingSchedule.js.map +1 -1
  66. package/lib/scheduling/helpers/generateRepeatingSchedule.js +104 -106
  67. package/lib/scheduling/helpers/generateRepeatingSchedule.js.map +1 -1
  68. package/lib/scheduling/helpers/generateScheduleEnd.js.map +1 -1
  69. package/lib/scheduling/helpers/mergeIntervals.js.map +1 -1
  70. package/lib/scheduling/scheduling.types.js +9 -9
  71. package/lib/scheduling/scheduling.types.js.map +1 -1
  72. package/lib/scheduling/strategies/getNext.js +21 -17
  73. package/lib/scheduling/strategies/getNext.js.map +1 -1
  74. package/lib/scheduling/strategies/getNextExactDateOfMonth.js +21 -18
  75. package/lib/scheduling/strategies/getNextExactDateOfMonth.js.map +1 -1
  76. package/lib/scheduling/strategies/getNextLastDayOfMonth.js +20 -17
  77. package/lib/scheduling/strategies/getNextLastDayOfMonth.js.map +1 -1
  78. package/lib/scheduling/strategies/getNextLastWeekdayOfMonth.js +20 -17
  79. package/lib/scheduling/strategies/getNextLastWeekdayOfMonth.js.map +1 -1
  80. package/lib/scheduling/strategies/getNextNoRepeat.js +15 -14
  81. package/lib/scheduling/strategies/getNextNoRepeat.js.map +1 -1
  82. package/lib/scheduling/strategies/getNextWeekday.js +36 -33
  83. package/lib/scheduling/strategies/getNextWeekday.js.map +1 -1
  84. package/lib/scheduling/strategies/getNextXDayOfXWeekOfMonth.js +20 -17
  85. package/lib/scheduling/strategies/getNextXDayOfXWeekOfMonth.js.map +1 -1
  86. package/lib/schema/schema.js +21 -23
  87. package/lib/schema/schema.js.map +1 -1
  88. package/lib/service-hours/schema.js +15 -13
  89. package/lib/service-hours/schema.js.map +1 -1
  90. package/package.json +2 -2
  91. package/yarn-error.log +0 -13549
@@ -1,9 +1,9 @@
1
- import _regeneratorRuntime from "@babel/runtime/regenerator";
2
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
3
  var _marked = /*#__PURE__*/_regeneratorRuntime.mark(generateRepeatingSchedule);
4
4
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
5
5
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
6
- function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) { n[e] = r[e]; } return n; }
6
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
7
7
  import { includes } from 'lodash/fp';
8
8
  import { generateScheduleEnd, hasValidStartAndEnd } from '.';
9
9
  import { IntervalTypes, Unit } from '../scheduling.types';
@@ -14,113 +14,111 @@ export var complyingServiceIntervalUnits = [Unit.Second, Unit.Minute, Unit.Hour]
14
14
  * Generates repeating schedule service and occurrence intervals
15
15
  */
16
16
  export function generateRepeatingSchedule(props) {
17
- var serviceHours, start, strategy, end, isInitial, frequency, frequencyUnit, timezone, isStartAndEndValid, serviceIntervalSequence, complyToServiceHours, serviceIntervals, _iterator, _step, serviceInterval, occurrenceIntervalsSequence, _iterator2, _step2, occurrenceInterval;
18
- return _regeneratorRuntime.wrap(function generateRepeatingSchedule$(_context) {
19
- while (1) {
20
- switch (_context.prev = _context.next) {
21
- case 0:
22
- serviceHours = props.serviceHours, start = props.start, strategy = props.strategy;
23
- end = props.end, isInitial = props.isInitial; // NOTE support never ending repeating schedule where no end date defined by
24
- // setting a custom end date using the frequency unit and value
25
- frequency = strategy.options.frequency;
26
- frequencyUnit = frequency.unit;
27
- timezone = serviceHours.timezone;
28
- end = end || generateScheduleEnd({
29
- frequency: frequency,
30
- start: start,
31
- timezone: timezone
32
- });
33
- isStartAndEndValid = hasValidStartAndEnd({
34
- end: end,
35
- start: start
36
- });
37
- if (isStartAndEndValid) {
38
- _context.next = 9;
39
- break;
40
- }
41
- return _context.abrupt("return", []);
42
- case 9:
43
- serviceIntervalSequence = serviceIntervalsGenerator({
44
- end: end,
45
- serviceHours: serviceHours,
46
- start: start
47
- }); // NOTE: when repeating and is complying to service hours we iterate through
48
- // all service intervals otherwise service interval is from the start and end
49
- complyToServiceHours = includes(frequencyUnit, complyingServiceIntervalUnits);
50
- serviceIntervals = complyToServiceHours ? _toConsumableArray(serviceIntervalSequence) : [[start, end]];
51
- _iterator = _createForOfIteratorHelper(serviceIntervals);
52
- _context.prev = 13;
53
- _iterator.s();
54
- case 15:
55
- if ((_step = _iterator.n()).done) {
56
- _context.next = 40;
57
- break;
58
- }
59
- serviceInterval = _step.value;
60
- _context.next = 19;
61
- return {
62
- interval: serviceInterval,
63
- type: IntervalTypes.Service
64
- };
65
- case 19:
66
- occurrenceIntervalsSequence = occurrenceIntervalsGenerator({
67
- isInitial: isInitial,
68
- serviceInterval: serviceInterval,
69
- strategy: strategy,
70
- timezone: timezone
71
- });
72
- _iterator2 = _createForOfIteratorHelper(occurrenceIntervalsSequence);
73
- _context.prev = 21;
74
- _iterator2.s();
75
- case 23:
76
- if ((_step2 = _iterator2.n()).done) {
77
- _context.next = 29;
78
- break;
79
- }
80
- occurrenceInterval = _step2.value;
81
- _context.next = 27;
82
- return {
83
- interval: occurrenceInterval,
84
- type: IntervalTypes.Occurrence
85
- };
86
- case 27:
87
- _context.next = 23;
88
- break;
89
- case 29:
90
- _context.next = 34;
17
+ var serviceHours, start, strategy, end, isInitial, frequency, frequencyUnit, timezone, isStartAndEndValid, serviceIntervalSequence, complyToServiceHours, serviceIntervals, _iterator, _step, serviceInterval, occurrenceIntervalsSequence, _iterator2, _step2, occurrenceInterval, _t, _t2;
18
+ return _regeneratorRuntime.wrap(function (_context) {
19
+ while (1) switch (_context.prev = _context.next) {
20
+ case 0:
21
+ serviceHours = props.serviceHours, start = props.start, strategy = props.strategy;
22
+ end = props.end, isInitial = props.isInitial; // NOTE support never ending repeating schedule where no end date defined by
23
+ // setting a custom end date using the frequency unit and value
24
+ frequency = strategy.options.frequency;
25
+ frequencyUnit = frequency.unit;
26
+ timezone = serviceHours.timezone;
27
+ end = end || generateScheduleEnd({
28
+ frequency: frequency,
29
+ start: start,
30
+ timezone: timezone
31
+ });
32
+ isStartAndEndValid = hasValidStartAndEnd({
33
+ end: end,
34
+ start: start
35
+ });
36
+ if (isStartAndEndValid) {
37
+ _context.next = 1;
91
38
  break;
92
- case 31:
93
- _context.prev = 31;
94
- _context.t0 = _context["catch"](21);
95
- _iterator2.e(_context.t0);
96
- case 34:
97
- _context.prev = 34;
98
- _iterator2.f();
99
- return _context.finish(34);
100
- case 37:
101
- // NOTE: we must reset isInitial to true following the first service
102
- // interval otherwise the occurrence will not start exactly on the next
103
- // service interval start time
104
- isInitial = true;
105
- case 38:
106
- _context.next = 15;
39
+ }
40
+ return _context.abrupt("return", []);
41
+ case 1:
42
+ serviceIntervalSequence = serviceIntervalsGenerator({
43
+ end: end,
44
+ serviceHours: serviceHours,
45
+ start: start
46
+ }); // NOTE: when repeating and is complying to service hours we iterate through
47
+ // all service intervals otherwise service interval is from the start and end
48
+ complyToServiceHours = includes(frequencyUnit, complyingServiceIntervalUnits);
49
+ serviceIntervals = complyToServiceHours ? _toConsumableArray(serviceIntervalSequence) : [[start, end]];
50
+ _iterator = _createForOfIteratorHelper(serviceIntervals);
51
+ _context.prev = 2;
52
+ _iterator.s();
53
+ case 3:
54
+ if ((_step = _iterator.n()).done) {
55
+ _context.next = 13;
107
56
  break;
108
- case 40:
109
- _context.next = 45;
57
+ }
58
+ serviceInterval = _step.value;
59
+ _context.next = 4;
60
+ return {
61
+ interval: serviceInterval,
62
+ type: IntervalTypes.Service
63
+ };
64
+ case 4:
65
+ occurrenceIntervalsSequence = occurrenceIntervalsGenerator({
66
+ isInitial: isInitial,
67
+ serviceInterval: serviceInterval,
68
+ strategy: strategy,
69
+ timezone: timezone
70
+ });
71
+ _iterator2 = _createForOfIteratorHelper(occurrenceIntervalsSequence);
72
+ _context.prev = 5;
73
+ _iterator2.s();
74
+ case 6:
75
+ if ((_step2 = _iterator2.n()).done) {
76
+ _context.next = 8;
110
77
  break;
111
- case 42:
112
- _context.prev = 42;
113
- _context.t1 = _context["catch"](13);
114
- _iterator.e(_context.t1);
115
- case 45:
116
- _context.prev = 45;
117
- _iterator.f();
118
- return _context.finish(45);
119
- case 48:
120
- case "end":
121
- return _context.stop();
122
- }
78
+ }
79
+ occurrenceInterval = _step2.value;
80
+ _context.next = 7;
81
+ return {
82
+ interval: occurrenceInterval,
83
+ type: IntervalTypes.Occurrence
84
+ };
85
+ case 7:
86
+ _context.next = 6;
87
+ break;
88
+ case 8:
89
+ _context.next = 10;
90
+ break;
91
+ case 9:
92
+ _context.prev = 9;
93
+ _t = _context["catch"](5);
94
+ _iterator2.e(_t);
95
+ case 10:
96
+ _context.prev = 10;
97
+ _iterator2.f();
98
+ return _context.finish(10);
99
+ case 11:
100
+ // NOTE: we must reset isInitial to true following the first service
101
+ // interval otherwise the occurrence will not start exactly on the next
102
+ // service interval start time
103
+ isInitial = true;
104
+ case 12:
105
+ _context.next = 3;
106
+ break;
107
+ case 13:
108
+ _context.next = 15;
109
+ break;
110
+ case 14:
111
+ _context.prev = 14;
112
+ _t2 = _context["catch"](2);
113
+ _iterator.e(_t2);
114
+ case 15:
115
+ _context.prev = 15;
116
+ _iterator.f();
117
+ return _context.finish(15);
118
+ case 16:
119
+ case "end":
120
+ return _context.stop();
123
121
  }
124
- }, _marked, null, [[13, 42, 45, 48], [21, 31, 34, 37]]);
122
+ }, _marked, null, [[2, 14, 15, 16], [5, 9, 10, 11]]);
125
123
  }
126
124
  //# sourceMappingURL=generateRepeatingSchedule.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generateRepeatingSchedule.js","names":["generateRepeatingSchedule","_createForOfIteratorHelper","r","e","t","Symbol","iterator","Array","isArray","_unsupportedIterableToArray","length","_n","F","s","n","done","value","f","TypeError","o","a","u","call","next","return","_arrayLikeToArray","toString","slice","constructor","name","from","test","includes","generateScheduleEnd","hasValidStartAndEnd","IntervalTypes","Unit","occurrenceIntervalsGenerator","serviceIntervalsGenerator","complyingServiceIntervalUnits","Second","Minute","Hour","props","serviceHours","start","strategy","end","isInitial","frequency","frequencyUnit","timezone","isStartAndEndValid","serviceIntervalSequence","complyToServiceHours","serviceIntervals","_iterator","_step","serviceInterval","occurrenceIntervalsSequence","_iterator2","_step2","occurrenceInterval","_regeneratorRuntime","wrap","generateRepeatingSchedule$","_context","prev","options","unit","abrupt","_toConsumableArray","interval","type","Service","Occurrence","t0","finish","t1","stop","_marked"],"sources":["../../../src/scheduling/helpers/generateRepeatingSchedule.ts"],"sourcesContent":["import { includes } from 'lodash/fp'\n\nimport { generateScheduleEnd, hasValidStartAndEnd } from '.'\nimport {\n IntervalTypes,\n ScheduleIntervalsGenerator,\n Unit,\n} from '../scheduling.types'\nimport {\n occurrenceIntervalsGenerator,\n serviceIntervalsGenerator,\n} from '../generators'\n\nexport const complyingServiceIntervalUnits = [\n Unit.Second,\n Unit.Minute,\n Unit.Hour,\n]\n\n/**\n * Generates repeating schedule service and occurrence intervals\n */\nexport function* generateRepeatingSchedule(props: ScheduleIntervalsGenerator) {\n const { serviceHours, start, strategy } = props\n let { end, isInitial } = props\n\n // NOTE support never ending repeating schedule where no end date defined by\n // setting a custom end date using the frequency unit and value\n const {\n options: { frequency },\n } = strategy\n const { unit: frequencyUnit } = frequency\n const { timezone } = serviceHours\n\n end = end || generateScheduleEnd({ frequency, start, timezone })\n\n const isStartAndEndValid = hasValidStartAndEnd({ end, start })\n\n if (!isStartAndEndValid) return []\n\n const serviceIntervalSequence = serviceIntervalsGenerator({\n end,\n serviceHours,\n start,\n })\n\n // NOTE: when repeating and is complying to service hours we iterate through\n // all service intervals otherwise service interval is from the start and end\n const complyToServiceHours = includes(\n frequencyUnit,\n complyingServiceIntervalUnits\n )\n\n const serviceIntervals = complyToServiceHours\n ? [...serviceIntervalSequence]\n : [[start, end]]\n\n for (const serviceInterval of serviceIntervals) {\n yield { interval: serviceInterval, type: IntervalTypes.Service }\n\n const occurrenceIntervalsSequence = occurrenceIntervalsGenerator({\n isInitial,\n serviceInterval,\n strategy,\n timezone,\n })\n\n for (const occurrenceInterval of occurrenceIntervalsSequence) {\n yield { interval: occurrenceInterval, type: IntervalTypes.Occurrence }\n }\n\n // NOTE: we must reset isInitial to true following the first service\n // interval otherwise the occurrence will not start exactly on the next\n // service interval start time\n isInitial = true\n }\n}\n"],"mappings":";;oDAsBiBA,yBAAyB;AAAA,SAAAC,2BAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,yBAAAC,MAAA,IAAAH,CAAA,CAAAG,MAAA,CAAAC,QAAA,KAAAJ,CAAA,qBAAAE,CAAA,QAAAG,KAAA,CAAAC,OAAA,CAAAN,CAAA,MAAAE,CAAA,GAAAK,2BAAA,CAAAP,CAAA,MAAAC,CAAA,IAAAD,CAAA,uBAAAA,CAAA,CAAAQ,MAAA,IAAAN,CAAA,KAAAF,CAAA,GAAAE,CAAA,OAAAO,EAAA,MAAAC,CAAA,YAAAA,EAAA,eAAAC,C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createForOfIteratorHelper","r","e","t","Symbol","iterator","Array","isArray","_unsupportedIterableToArray","length","_n","F","s","n","done","value","f","TypeError","o","a","u","call","next","return","_arrayLikeToArray","toString","slice","constructor","name","from","test","includes","generateScheduleEnd","hasValidStartAndEnd","IntervalTypes","Unit","occurrenceIntervalsGenerator","serviceIntervalsGenerator","complyingServiceIntervalUnits","Second","Minute","Hour","props","serviceHours","start","strategy","end","isInitial","frequency","frequencyUnit","timezone","isStartAndEndValid","serviceIntervalSequence","complyToServiceHours","serviceIntervals","_iterator","_step","serviceInterval","occurrenceIntervalsSequence","_iterator2","_step2","occurrenceInterval","_t","_t2","_regeneratorRuntime","wrap","_context","prev","options","unit","abrupt","_toConsumableArray","interval","type","Service","Occurrence","finish","stop","_marked"],"sources":["../../../src/scheduling/helpers/generateRepeatingSchedule.ts"],"sourcesContent":["import { includes } from 'lodash/fp'\n\nimport { generateScheduleEnd, hasValidStartAndEnd } from '.'\nimport {\n IntervalTypes,\n ScheduleIntervalsGenerator,\n Unit,\n} from '../scheduling.types'\nimport {\n occurrenceIntervalsGenerator,\n serviceIntervalsGenerator,\n} from '../generators'\n\nexport const complyingServiceIntervalUnits = [\n Unit.Second,\n Unit.Minute,\n Unit.Hour,\n]\n\n/**\n * Generates repeating schedule service and occurrence intervals\n */\nexport function* generateRepeatingSchedule(props: ScheduleIntervalsGenerator) {\n const { serviceHours, start, strategy } = props\n let { end, isInitial } = props\n\n // NOTE support never ending repeating schedule where no end date defined by\n // setting a custom end date using the frequency unit and value\n const {\n options: { frequency },\n } = strategy\n const { unit: frequencyUnit } = frequency\n const { timezone } = serviceHours\n\n end = end || generateScheduleEnd({ frequency, start, timezone })\n\n const isStartAndEndValid = hasValidStartAndEnd({ end, start })\n\n if (!isStartAndEndValid) return []\n\n const serviceIntervalSequence = serviceIntervalsGenerator({\n end,\n serviceHours,\n start,\n })\n\n // NOTE: when repeating and is complying to service hours we iterate through\n // all service intervals otherwise service interval is from the start and end\n const complyToServiceHours = includes(\n frequencyUnit,\n complyingServiceIntervalUnits\n )\n\n const serviceIntervals = complyToServiceHours\n ? [...serviceIntervalSequence]\n : [[start, end]]\n\n for (const serviceInterval of serviceIntervals) {\n yield { interval: serviceInterval, type: IntervalTypes.Service }\n\n const occurrenceIntervalsSequence = occurrenceIntervalsGenerator({\n isInitial,\n serviceInterval,\n strategy,\n timezone,\n })\n\n for (const occurrenceInterval of occurrenceIntervalsSequence) {\n yield { interval: occurrenceInterval, type: IntervalTypes.Occurrence }\n }\n\n // NOTE: we must reset isInitial to true following the first service\n // interval otherwise the occurrence will not start exactly on the next\n // service interval start time\n isInitial = true\n }\n}\n"],"mappings":";;oDAsBiBA,yBAAyB;AAAA,SAAAC,2BAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,yBAAAC,MAAA,IAAAH,CAAA,CAAAG,MAAA,CAAAC,QAAA,KAAAJ,CAAA,qBAAAE,CAAA,QAAAG,KAAA,CAAAC,OAAA,CAAAN,CAAA,MAAAE,CAAA,GAAAK,2BAAA,CAAAP,CAAA,MAAAC,CAAA,IAAAD,CAAA,uBAAAA,CAAA,CAAAQ,MAAA,IAAAN,CAAA,KAAAF,CAAA,GAAAE,CAAA,OAAAO,EAAA,MAAAC,CAAA,YAAAA,EAAA,eAAAC,CAAA,EAAAD,CAAA,EAAAE,CAAA,WAAAA,EAAA,WAAAH,EAAA,IAAAT,CAAA,CAAAQ,MAAA,KAAAK,IAAA,WAAAA,IAAA,MAAAC,KAAA,EAAAd,CAAA,CAAAS,EAAA,UAAAR,CAAA,WAAAA,EAAAD,CAAA,UAAAA,CAAA,KAAAe,CAAA,EAAAL,CAAA,gBAAAM,SAAA,iJAAAC,CAAA,EAAAC,CAAA,OAAAC,CAAA,gBAAAR,CAAA,WAAAA,EAAA,IAAAT,CAAA,GAAAA,CAAA,CAAAkB,IAAA,CAAApB,CAAA,MAAAY,CAAA,WAAAA,EAAA,QAAAZ,CAAA,GAAAE,CAAA,CAAAmB,IAAA,WAAAH,CAAA,GA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C;MAAA;QAAAT,QAAA,CAAA5C,IAAA;QAAA;MAAA;QAAA4C,QAAA,CAAA5C,IAAA;QAAA;MAAA;QAAA4C,QAAA,CAAAC,IAAA;QAAAL,EAAA,GAAAI,QAAA;QAAAP,UAAA,CAAAzD,CAAA,CAAA4D,EAAA;MAAA;QAAAI,QAAA,CAAAC,IAAA;QAAAR,UAAA,CAAA3C,CAAA;QAAA,OAAAkD,QAAA,CAAAU,MAAA;MAAA;QAGxE;QACA;QACA;QACA7B,SAAS,GAAG,IAAI;MAAA;QAAAmB,QAAA,CAAA5C,IAAA;QAAA;MAAA;QAAA4C,QAAA,CAAA5C,IAAA;QAAA;MAAA;QAAA4C,QAAA,CAAAC,IAAA;QAAAJ,GAAA,GAAAG,QAAA;QAAAX,SAAA,CAAArD,CAAA,CAAA6D,GAAA;MAAA;QAAAG,QAAA,CAAAC,IAAA;QAAAZ,SAAA,CAAAvC,CAAA;QAAA,OAAAkD,QAAA,CAAAU,MAAA;MAAA;MAAA;QAAA,OAAAV,QAAA,CAAAW,IAAA;IAAA;EAAA,GAAAC,OAAA;AAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"generateScheduleEnd.js","names":["includes","moment","Unit","generateScheduleEnd","_ref","frequency","start","timezone","frequencyUnit","unit","frequencyValue","value","isFrequencyLessThanWeek","Millisecond","Second","Minute","Hour","Day","mStart","tz","end","add","Week","valueOf"],"sources":["../../../src/scheduling/helpers/generateScheduleEnd.ts"],"sourcesContent":["import { includes } from 'lodash/fp'\nimport moment from 'moment-timezone'\n\nimport { Period, Unit } from '../scheduling.types'\n\ninterface GenerateScheduleEnd {\n readonly frequency: Period\n readonly start: number\n readonly timezone: string\n}\n\n/**\n * Generates a schedule end datetime based on the start and frequency\n */\nexport function generateScheduleEnd({\n frequency,\n start,\n timezone,\n}: GenerateScheduleEnd): number {\n const { unit: frequencyUnit, value: frequencyValue } = frequency\n\n const isFrequencyLessThanWeek = includes(frequencyUnit, [\n Unit.Millisecond,\n Unit.Second,\n Unit.Minute,\n Unit.Hour,\n Unit.Day,\n ])\n\n const mStart = moment.tz(start, timezone)\n\n // NOTE: if frequency unit less than a week we must set end to jump a week\n // plus the interval length of the schedule frequency\n // so that we can ensure that we are within a service interval\n const end = isFrequencyLessThanWeek\n ? mStart.add(2, Unit.Week).valueOf()\n : mStart.add(frequencyValue * 2, frequencyUnit).valueOf()\n\n return end\n}\n"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,WAAW;AACpC,OAAOC,MAAM,MAAM,iBAAiB;AAEpC,SAAiBC,IAAI,QAAQ,qBAAqB;AAQlD;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CAAAC,IAAA,EAIH;EAAA,IAH9BC,SAAS,GAAAD,IAAA,CAATC,SAAS;IACTC,KAAK,GAAAF,IAAA,CAALE,KAAK;IACLC,QAAQ,GAAAH,IAAA,CAARG,QAAQ;EAAA,IAEMC,aAAa,GAA4BH,SAAS,CAAxDI,IAAI;IAAwBC,cAAc,GAAKL,SAAS,CAAnCM,KAAK;EAElC,IAAMC,uBAAuB,GAAGZ,QAAQ,CAACQ,aAAa,EAAE,CACtDN,IAAI,CAACW,WAAW,EAChBX,IAAI,CAACY,MAAM,EACXZ,IAAI,CAACa,MAAM,EACXb,IAAI,CAACc,IAAI,EACTd,IAAI,CAACe,GAAG,CACT,CAAC;EAEF,IAAMC,MAAM,GAAGjB,MAAM,CAACkB,EAAE,CAACb,KAAK,EAAEC,QAAQ,CAAC;;EAEzC;EACA;EACA;EACA,IAAMa,GAAG,GAAGR,uBAAuB,GAC/BM,MAAM,CAACG,GAAG,CAAC,CAAC,EAAEnB,IAAI,CAACoB,IAAI,CAAC,CAACC,OAAO,CAAC,CAAC,GAClCL,MAAM,CAACG,GAAG,CAACX,cAAc,GAAG,CAAC,EAAEF,aAAa,CAAC,CAACe,OAAO,CAAC,CAAC;EAE3D,OAAOH,GAAG;AACZ","ignoreList":[]}
1
+ {"version":3,"file":"generateScheduleEnd.js","names":["includes","moment","Unit","generateScheduleEnd","_ref","frequency","start","timezone","frequencyUnit","unit","frequencyValue","value","isFrequencyLessThanWeek","Millisecond","Second","Minute","Hour","Day","mStart","tz","end","add","Week","valueOf"],"sources":["../../../src/scheduling/helpers/generateScheduleEnd.ts"],"sourcesContent":["import { includes } from 'lodash/fp'\nimport moment from 'moment-timezone'\n\nimport { Period, Unit } from '../scheduling.types'\n\ninterface GenerateScheduleEnd {\n readonly frequency: Period\n readonly start: number\n readonly timezone: string\n}\n\n/**\n * Generates a schedule end datetime based on the start and frequency\n */\nexport function generateScheduleEnd({\n frequency,\n start,\n timezone,\n}: GenerateScheduleEnd): number {\n const { unit: frequencyUnit, value: frequencyValue } = frequency\n\n const isFrequencyLessThanWeek = includes(frequencyUnit, [\n Unit.Millisecond,\n Unit.Second,\n Unit.Minute,\n Unit.Hour,\n Unit.Day,\n ])\n\n const mStart = moment.tz(start, timezone)\n\n // NOTE: if frequency unit less than a week we must set end to jump a week\n // plus the interval length of the schedule frequency\n // so that we can ensure that we are within a service interval\n const end = isFrequencyLessThanWeek\n ? mStart.add(2, Unit.Week).valueOf()\n : mStart.add(frequencyValue * 2, frequencyUnit).valueOf()\n\n return end\n}\n"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,WAAW;AACpC,OAAOC,MAAM,MAAM,iBAAiB;AAEpC,SAAiBC,IAAI,QAAQ,qBAAqB;AAQlD;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CAAAC,IAAA,EAIH;EAAA,IAH9BC,SAAS,GAAAD,IAAA,CAATC,SAAS;IACTC,KAAK,GAAAF,IAAA,CAALE,KAAK;IACLC,QAAQ,GAAAH,IAAA,CAARG,QAAQ;EAER,IAAcC,aAAa,GAA4BH,SAAS,CAAxDI,IAAI;IAAwBC,cAAc,GAAKL,SAAS,CAAnCM,KAAK;EAElC,IAAMC,uBAAuB,GAAGZ,QAAQ,CAACQ,aAAa,EAAE,CACtDN,IAAI,CAACW,WAAW,EAChBX,IAAI,CAACY,MAAM,EACXZ,IAAI,CAACa,MAAM,EACXb,IAAI,CAACc,IAAI,EACTd,IAAI,CAACe,GAAG,CACT,CAAC;EAEF,IAAMC,MAAM,GAAGjB,MAAM,CAACkB,EAAE,CAACb,KAAK,EAAEC,QAAQ,CAAC;;EAEzC;EACA;EACA;EACA,IAAMa,GAAG,GAAGR,uBAAuB,GAC/BM,MAAM,CAACG,GAAG,CAAC,CAAC,EAAEnB,IAAI,CAACoB,IAAI,CAAC,CAACC,OAAO,CAAC,CAAC,GAClCL,MAAM,CAACG,GAAG,CAACX,cAAc,GAAG,CAAC,EAAEF,aAAa,CAAC,CAACe,OAAO,CAAC,CAAC;EAE3D,OAAOH,GAAG;AACZ","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"mergeIntervals.js","names":["first","isEmpty","reduce","mergeIntervals","intervals","sortedIntervals","sort","a","b","firstInterval","stack","accum","interval","top","length","topBeforeInterval","topOverlapsInterval","push","pop"],"sources":["../../../src/scheduling/helpers/mergeIntervals.ts"],"sourcesContent":["import { first, isEmpty, reduce } from 'lodash/fp'\n\nimport { Interval } from '../scheduling.types'\n\n/**\n * Merges overlapping intervals\n * Accepts arrays of intervals and returns a flattened result of overlapping intervals\n *\n * mergeIntervals([[1,15], [11,25], [21,29], [40,1000]])\n * returns [[1,29], [40,1000]]\n */\nexport function mergeIntervals(intervals: Array<Interval>): Array<Interval> {\n if (isEmpty(intervals)) return intervals\n\n const sortedIntervals = intervals.sort((a, b) => a[0] - b[0])\n const firstInterval = first(sortedIntervals)\n\n const stack = reduce(\n (accum, interval) => {\n const top = accum[accum.length - 1]\n const topBeforeInterval = top[1] < interval[0]\n const topOverlapsInterval = top[1] < interval[1]\n\n if (topBeforeInterval) {\n accum.push(interval)\n } else if (topOverlapsInterval) {\n accum.pop()\n accum.push([top[0], interval[1]])\n }\n\n return accum\n },\n [firstInterval],\n sortedIntervals\n )\n\n return stack\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,OAAO,EAAEC,MAAM,QAAQ,WAAW;AAIlD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAACC,SAA0B,EAAmB;EAC1E,IAAIH,OAAO,CAACG,SAAS,CAAC,EAAE,OAAOA,SAAS;EAExC,IAAMC,eAAe,GAAGD,SAAS,CAACE,IAAI,CAAC,UAACC,CAAC,EAAEC,CAAC;IAAA,OAAKD,CAAC,CAAC,CAAC,CAAC,GAAGC,CAAC,CAAC,CAAC,CAAC;EAAA,EAAC;EAC7D,IAAMC,aAAa,GAAGT,KAAK,CAACK,eAAe,CAAC;EAE5C,IAAMK,KAAK,GAAGR,MAAM,CAClB,UAACS,KAAK,EAAEC,QAAQ,EAAK;IACnB,IAAMC,GAAG,GAAGF,KAAK,CAACA,KAAK,CAACG,MAAM,GAAG,CAAC,CAAC;IACnC,IAAMC,iBAAiB,GAAGF,GAAG,CAAC,CAAC,CAAC,GAAGD,QAAQ,CAAC,CAAC,CAAC;IAC9C,IAAMI,mBAAmB,GAAGH,GAAG,CAAC,CAAC,CAAC,GAAGD,QAAQ,CAAC,CAAC,CAAC;IAEhD,IAAIG,iBAAiB,EAAE;MACrBJ,KAAK,CAACM,IAAI,CAACL,QAAQ,CAAC;IACtB,CAAC,MAAM,IAAII,mBAAmB,EAAE;MAC9BL,KAAK,CAACO,GAAG,CAAC,CAAC;MACXP,KAAK,CAACM,IAAI,CAAC,CAACJ,GAAG,CAAC,CAAC,CAAC,EAAED,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IACnC;IAEA,OAAOD,KAAK;EACd,CAAC,EACD,CAACF,aAAa,CAAC,EACfJ,eACF,CAAC;EAED,OAAOK,KAAK;AACd","ignoreList":[]}
1
+ {"version":3,"file":"mergeIntervals.js","names":["first","isEmpty","reduce","mergeIntervals","intervals","sortedIntervals","sort","a","b","firstInterval","stack","accum","interval","top","length","topBeforeInterval","topOverlapsInterval","push","pop"],"sources":["../../../src/scheduling/helpers/mergeIntervals.ts"],"sourcesContent":["import { first, isEmpty, reduce } from 'lodash/fp'\n\nimport { Interval } from '../scheduling.types'\n\n/**\n * Merges overlapping intervals\n * Accepts arrays of intervals and returns a flattened result of overlapping intervals\n *\n * mergeIntervals([[1,15], [11,25], [21,29], [40,1000]])\n * returns [[1,29], [40,1000]]\n */\nexport function mergeIntervals(intervals: Interval[]): Interval[] {\n if (isEmpty(intervals)) return intervals\n\n const sortedIntervals = intervals.sort((a, b) => a[0] - b[0])\n const firstInterval: Interval = first(sortedIntervals)\n\n const stack: Interval[] = reduce(\n (accum, interval: Interval) => {\n const top = accum[accum.length - 1]\n const topBeforeInterval = top[1] < interval[0]\n const topOverlapsInterval = top[1] < interval[1]\n\n if (topBeforeInterval) {\n accum.push(interval)\n } else if (topOverlapsInterval) {\n accum.pop()\n accum.push([top[0], interval[1]])\n }\n\n return accum\n },\n [firstInterval],\n sortedIntervals\n )\n\n return stack\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,OAAO,EAAEC,MAAM,QAAQ,WAAW;AAIlD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAACC,SAAqB,EAAc;EAChE,IAAIH,OAAO,CAACG,SAAS,CAAC,EAAE,OAAOA,SAAS;EAExC,IAAMC,eAAe,GAAGD,SAAS,CAACE,IAAI,CAAC,UAACC,CAAC,EAAEC,CAAC;IAAA,OAAKD,CAAC,CAAC,CAAC,CAAC,GAAGC,CAAC,CAAC,CAAC,CAAC;EAAA,EAAC;EAC7D,IAAMC,aAAuB,GAAGT,KAAK,CAACK,eAAe,CAAC;EAEtD,IAAMK,KAAiB,GAAGR,MAAM,CAC9B,UAACS,KAAK,EAAEC,QAAkB,EAAK;IAC7B,IAAMC,GAAG,GAAGF,KAAK,CAACA,KAAK,CAACG,MAAM,GAAG,CAAC,CAAC;IACnC,IAAMC,iBAAiB,GAAGF,GAAG,CAAC,CAAC,CAAC,GAAGD,QAAQ,CAAC,CAAC,CAAC;IAC9C,IAAMI,mBAAmB,GAAGH,GAAG,CAAC,CAAC,CAAC,GAAGD,QAAQ,CAAC,CAAC,CAAC;IAEhD,IAAIG,iBAAiB,EAAE;MACrBJ,KAAK,CAACM,IAAI,CAACL,QAAQ,CAAC;IACtB,CAAC,MAAM,IAAII,mBAAmB,EAAE;MAC9BL,KAAK,CAACO,GAAG,CAAC,CAAC;MACXP,KAAK,CAACM,IAAI,CAAC,CAACJ,GAAG,CAAC,CAAC,CAAC,EAAED,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IACnC;IAEA,OAAOD,KAAK;EACd,CAAC,EACD,CAACF,aAAa,CAAC,EACfJ,eACF,CAAC;EAED,OAAOK,KAAK;AACd","ignoreList":[]}
@@ -1,10 +1,9 @@
1
- export var IntervalTypes;
2
- (function (IntervalTypes) {
1
+ export var IntervalTypes = /*#__PURE__*/function (IntervalTypes) {
3
2
  IntervalTypes["Occurrence"] = "occurrence";
4
3
  IntervalTypes["Service"] = "service";
5
- })(IntervalTypes || (IntervalTypes = {}));
6
- export var Unit;
7
- (function (Unit) {
4
+ return IntervalTypes;
5
+ }({});
6
+ export var Unit = /*#__PURE__*/function (Unit) {
8
7
  Unit["Millisecond"] = "millisecond";
9
8
  Unit["Second"] = "second";
10
9
  Unit["Minute"] = "minute";
@@ -13,9 +12,9 @@ export var Unit;
13
12
  Unit["Week"] = "isoWeek";
14
13
  Unit["Month"] = "month";
15
14
  Unit["Year"] = "year";
16
- })(Unit || (Unit = {}));
17
- export var StrategyTypes;
18
- (function (StrategyTypes) {
15
+ return Unit;
16
+ }({});
17
+ export var StrategyTypes = /*#__PURE__*/function (StrategyTypes) {
19
18
  StrategyTypes["ExactDateOfMonth"] = "exactDateOfMonth";
20
19
  StrategyTypes["LastDayOfMonth"] = "lastDayOfMonth";
21
20
  StrategyTypes["LastWeekdayOfMonth"] = "lastWeekdayOfMonth";
@@ -24,5 +23,6 @@ export var StrategyTypes;
24
23
  StrategyTypes["Weekdays"] = "weekdays";
25
24
  StrategyTypes["Window"] = "window";
26
25
  StrategyTypes["XDayOfXWeekOfMonth"] = "xDayOfxWeekOfMonth";
27
- })(StrategyTypes || (StrategyTypes = {}));
26
+ return StrategyTypes;
27
+ }({});
28
28
  //# sourceMappingURL=scheduling.types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"scheduling.types.js","names":["IntervalTypes","Unit","StrategyTypes"],"sources":["../../src/scheduling/scheduling.types.ts"],"sourcesContent":["import { Schema as ServiceHoursSchema } from '../service-hours'\n\nexport enum IntervalTypes {\n Occurrence = 'occurrence',\n Service = 'service',\n}\n\nexport enum Unit {\n Millisecond = 'millisecond',\n Second = 'second',\n Minute = 'minute',\n Hour = 'hour',\n Day = 'day',\n Week = 'isoWeek',\n Month = 'month',\n Year = 'year',\n}\n\nexport enum StrategyTypes {\n ExactDateOfMonth = 'exactDateOfMonth',\n LastDayOfMonth = 'lastDayOfMonth',\n LastWeekdayOfMonth = 'lastWeekdayOfMonth',\n NoRepeat = 'noRepeat',\n Stopwatch = 'stopwatch',\n Weekdays = 'weekdays',\n Window = 'window',\n XDayOfXWeekOfMonth = 'xDayOfxWeekOfMonth',\n}\n\nexport interface Options {\n date?: number\n dayOfWeek?: number\n duration: Period\n frequency: Period\n weekday?: number\n weekdays?: number[]\n weekOfMonth?: number\n}\n\nexport interface GetNext {\n readonly end: number\n readonly isInitial?: boolean\n readonly options?: Options\n readonly start: number\n readonly timezone: string\n readonly type: StrategyTypes\n}\n\nexport interface Interval {\n readonly [index: number]: number\n}\n\nexport interface Period {\n readonly unit: Unit\n readonly value: number\n}\n\nexport interface ScheduleIntervalsGenerator {\n readonly end: number\n readonly isInitial: boolean\n readonly strategy: Strategy\n readonly serviceHours: ServiceHoursSchema\n readonly start: number\n}\n\nexport interface Strategy {\n readonly options: Options\n readonly type: StrategyTypes\n}\n"],"mappings":"AAEA,WAAYA,aAAa;AAGxB,WAHWA,aAAa;EAAbA,aAAa;EAAbA,aAAa;AAAA,GAAbA,aAAa,KAAbA,aAAa;AAKzB,WAAYC,IAAI;AASf,WATWA,IAAI;EAAJA,IAAI;EAAJA,IAAI;EAAJA,IAAI;EAAJA,IAAI;EAAJA,IAAI;EAAJA,IAAI;EAAJA,IAAI;EAAJA,IAAI;AAAA,GAAJA,IAAI,KAAJA,IAAI;AAWhB,WAAYC,aAAa;AASxB,WATWA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;AAAA,GAAbA,aAAa,KAAbA,aAAa","ignoreList":[]}
1
+ {"version":3,"file":"scheduling.types.js","names":["IntervalTypes","Unit","StrategyTypes"],"sources":["../../src/scheduling/scheduling.types.ts"],"sourcesContent":["import { Schema as ServiceHoursSchema } from '../service-hours'\n\nexport enum IntervalTypes {\n Occurrence = 'occurrence',\n Service = 'service',\n}\n\nexport enum Unit {\n Millisecond = 'millisecond',\n Second = 'second',\n Minute = 'minute',\n Hour = 'hour',\n Day = 'day',\n Week = 'isoWeek',\n Month = 'month',\n Year = 'year',\n}\n\nexport enum StrategyTypes {\n ExactDateOfMonth = 'exactDateOfMonth',\n LastDayOfMonth = 'lastDayOfMonth',\n LastWeekdayOfMonth = 'lastWeekdayOfMonth',\n NoRepeat = 'noRepeat',\n Stopwatch = 'stopwatch',\n Weekdays = 'weekdays',\n Window = 'window',\n XDayOfXWeekOfMonth = 'xDayOfxWeekOfMonth',\n}\n\nexport interface Options {\n date?: number\n dayOfWeek?: number\n duration: Period\n frequency: Period\n weekday?: number\n weekdays?: number[]\n weekOfMonth?: number\n}\n\nexport interface GetNext {\n readonly end: number\n readonly isInitial?: boolean\n readonly options?: Options\n readonly start: number\n readonly timezone: string\n readonly type: StrategyTypes\n}\n\nexport interface Interval {\n readonly [index: number]: number\n}\n\nexport interface Period {\n readonly unit: Unit\n readonly value: number\n}\n\nexport interface ScheduleIntervalsGenerator {\n readonly end: number\n readonly isInitial: boolean\n readonly strategy: Strategy\n readonly serviceHours: ServiceHoursSchema\n readonly start: number\n}\n\nexport interface Strategy {\n readonly options: Options\n readonly type: StrategyTypes\n}\n"],"mappings":"AAEA,WAAYA,aAAa,0BAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAA,OAAbA,aAAa;AAAA;AAKzB,WAAYC,IAAI,0BAAJA,IAAI;EAAJA,IAAI;EAAJA,IAAI;EAAJA,IAAI;EAAJA,IAAI;EAAJA,IAAI;EAAJA,IAAI;EAAJA,IAAI;EAAJA,IAAI;EAAA,OAAJA,IAAI;AAAA;AAWhB,WAAYC,aAAa,0BAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAA,OAAbA,aAAa;AAAA","ignoreList":[]}
@@ -1,5 +1,4 @@
1
1
  import _regeneratorRuntime from "@babel/runtime/regenerator";
2
- var _marked = /*#__PURE__*/_regeneratorRuntime.mark(getNext);
3
2
  import moment from 'moment-timezone';
4
3
  import { StrategyTypes, Unit } from '../scheduling.types';
5
4
 
@@ -7,20 +6,25 @@ import { StrategyTypes, Unit } from '../scheduling.types';
7
6
  * Generates next occurrence interval for stopwatch and window strategy
8
7
  */
9
8
  export function getNext(_ref) {
10
- var end, isInitial, options, start, timezone, type, duration, frequency, durationUnit, durationValue, frequencyUnit, frequencyValue, initial, dateCursor, nextOccurrenceStart, nextOccurrenceEnd, nextOccurrenceStartByBackCalculation, earliestNextOccurrenceStart, nextOccurrence;
11
- return _regeneratorRuntime.wrap(function getNext$(_context) {
12
- while (1) {
13
- switch (_context.prev = _context.next) {
9
+ var end = _ref.end,
10
+ isInitial = _ref.isInitial,
11
+ options = _ref.options,
12
+ start = _ref.start,
13
+ timezone = _ref.timezone,
14
+ type = _ref.type;
15
+ return /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
16
+ var duration, frequency, durationUnit, durationValue, frequencyUnit, frequencyValue, initial, dateCursor, nextOccurrenceStart, nextOccurrenceEnd, nextOccurrenceStartByBackCalculation, earliestNextOccurrenceStart, nextOccurrence;
17
+ return _regeneratorRuntime.wrap(function (_context) {
18
+ while (1) switch (_context.prev = _context.next) {
14
19
  case 0:
15
- end = _ref.end, isInitial = _ref.isInitial, options = _ref.options, start = _ref.start, timezone = _ref.timezone, type = _ref.type;
16
20
  duration = options.duration, frequency = options.frequency;
17
21
  durationUnit = duration.unit, durationValue = duration.value;
18
22
  frequencyUnit = frequency.unit, frequencyValue = frequency.value;
19
23
  initial = isInitial;
20
24
  dateCursor = initial ? moment.tz(start, timezone).valueOf() : moment.tz(start, timezone).add(1, Unit.Millisecond).valueOf();
21
- case 6:
25
+ case 1:
22
26
  if (!(dateCursor < end)) {
23
- _context.next = 19;
27
+ _context.next = 4;
24
28
  break;
25
29
  }
26
30
  nextOccurrenceStart = void 0;
@@ -37,27 +41,27 @@ export function getNext(_ref) {
37
41
  nextOccurrenceStart = moment.max(earliestNextOccurrenceStart, nextOccurrenceStartByBackCalculation).valueOf();
38
42
  }
39
43
  if (!(nextOccurrenceEnd <= nextOccurrenceStart || nextOccurrenceEnd > end)) {
40
- _context.next = 12;
44
+ _context.next = 2;
41
45
  break;
42
46
  }
43
47
  return _context.abrupt("return");
44
- case 12:
48
+ case 2:
45
49
  if (!(nextOccurrenceStart >= start)) {
46
- _context.next = 16;
50
+ _context.next = 3;
47
51
  break;
48
52
  }
49
53
  nextOccurrence = [nextOccurrenceStart, nextOccurrenceEnd - 1];
50
- _context.next = 16;
54
+ _context.next = 3;
51
55
  return nextOccurrence;
52
- case 16:
56
+ case 3:
53
57
  dateCursor = nextOccurrenceEnd;
54
- _context.next = 6;
58
+ _context.next = 1;
55
59
  break;
56
- case 19:
60
+ case 4:
57
61
  case "end":
58
62
  return _context.stop();
59
63
  }
60
- }
61
- }, _marked);
64
+ }, _callee);
65
+ })();
62
66
  }
63
67
  //# sourceMappingURL=getNext.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getNext.js","names":["getNext","moment","StrategyTypes","Unit","_ref","end","isInitial","options","start","timezone","type","duration","frequency","durationUnit","durationValue","frequencyUnit","frequencyValue","initial","dateCursor","nextOccurrenceStart","nextOccurrenceEnd","nextOccurrenceStartByBackCalculation","earliestNextOccurrenceStart","nextOccurrence","_regeneratorRuntime","wrap","getNext$","_context","prev","next","unit","value","tz","valueOf","add","Millisecond","Stopwatch","subtract","max","abrupt","stop","_marked"],"sources":["../../../src/scheduling/strategies/getNext.ts"],"sourcesContent":["import moment from 'moment-timezone'\n\nimport { GetNext, Interval, StrategyTypes, Unit } from '../scheduling.types'\n\n/**\n * Generates next occurrence interval for stopwatch and window strategy\n */\nexport function* getNext({\n end,\n isInitial,\n options,\n start,\n timezone,\n type,\n}: GetNext): IterableIterator<Interval> {\n const { duration, frequency } = options\n const { unit: durationUnit, value: durationValue } = duration\n const { unit: frequencyUnit, value: frequencyValue } = frequency\n\n let initial: boolean = isInitial\n\n let dateCursor: number = initial\n ? moment.tz(start, timezone).valueOf()\n : moment\n .tz(start, timezone)\n .add(1, Unit.Millisecond)\n .valueOf()\n\n while (dateCursor < end) {\n let nextOccurrenceStart: number\n let nextOccurrenceEnd: number\n\n if (type === StrategyTypes.Stopwatch) {\n nextOccurrenceStart = dateCursor\n nextOccurrenceEnd = moment\n .tz(dateCursor, timezone)\n .add(durationValue, durationUnit)\n .valueOf()\n\n } else {\n nextOccurrenceEnd = moment\n .tz(dateCursor, timezone)\n .add(frequencyValue, frequencyUnit)\n .valueOf()\n\n const nextOccurrenceStartByBackCalculation = moment\n .tz(nextOccurrenceEnd, timezone)\n .subtract(durationValue, durationUnit)\n\n const earliestNextOccurrenceStart = moment\n .tz(dateCursor, timezone)\n\n // NOTE: this is to ensure that the next occurrence start is always\n // greater than or equal to the date cursor. Moment js handles month addition and subtraction\n // with estimations (Dec 31st + 2 months gives Feb 28th/29th). This can lead to inaccurate start times when calculating forwards then backwards at the end of the month.\n nextOccurrenceStart =\n moment.max(\n earliestNextOccurrenceStart,\n nextOccurrenceStartByBackCalculation\n ).valueOf()\n }\n\n\n if (nextOccurrenceEnd <= nextOccurrenceStart || nextOccurrenceEnd > end) {\n return\n }\n\n if (nextOccurrenceStart >= start) {\n const nextOccurrence = [nextOccurrenceStart, nextOccurrenceEnd - 1]\n\n yield nextOccurrence\n }\n\n dateCursor = nextOccurrenceEnd\n }\n}\n"],"mappings":";oDAOiBA,OAAO;AAPxB,OAAOC,MAAM,MAAM,iBAAiB;AAEpC,SAA4BC,aAAa,EAAEC,IAAI,QAAQ,qBAAqB;;AAE5E;AACA;AACA;AACA,OAAO,SAAUH,OAAOA,CAAAI,IAAA;EAAA,IAAAC,GAAA,EAAAC,SAAA,EAAAC,OAAA,EAAAC,KAAA,EAAAC,QAAA,EAAAC,IAAA,EAAAC,QAAA,EAAAC,SAAA,EAAAC,YAAA,EAAAC,aAAA,EAAAC,aAAA,EAAAC,cAAA,EAAAC,OAAA,EAAAC,UAAA,EAAAC,mBAAA,EAAAC,iBAAA,EAAAC,oCAAA,EAAAC,2BAAA,EAAAC,cAAA;EAAA,OAAAC,mBAAA,CAAAC,IAAA,UAAAC,SAAAC,QAAA;IAAA;MAAA,QAAAA,QAAA,CAAAC,IAAA,GAAAD,QAAA,CAAAE,IAAA;QAAA;UACtBxB,GAAG,GAAAD,IAAA,CAAHC,GAAG,EACHC,SAAS,GAAAF,IAAA,CAATE,SAAS,EACTC,OAAO,GAAAH,IAAA,CAAPG,OAAO,EACPC,KAAK,GAAAJ,IAAA,CAALI,KAAK,EACLC,QAAQ,GAAAL,IAAA,CAARK,QAAQ,EACRC,IAAI,GAAAN,IAAA,CAAJM,IAAI;UAEIC,QAAQ,GAAgBJ,OAAO,CAA/BI,QAAQ,EAAEC,SAAS,GAAKL,OAAO,CAArBK,SAAS;UACbC,YAAY,GAA2BF,QAAQ,CAArDmB,IAAI,EAAuBhB,aAAa,GAAKH,QAAQ,CAAjCoB,KAAK;UACnBhB,aAAa,GAA4BH,SAAS,CAAxDkB,IAAI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G;YAAAsB,QAAA,CAAAE,IAAA;YAAA;UAAA;UAAA,OAAAF,QAAA,CAAAY,MAAA;QAAA;UAAA,MAInEpB,mBAAmB,IAAIX,KAAK;YAAAmB,QAAA,CAAAE,IAAA;YAAA;UAAA;UACxBN,cAAc,GAAG,CAACJ,mBAAmB,EAAEC,iBAAiB,GAAG,CAAC,CAAC;UAAAO,QAAA,CAAAE,IAAA;UAEnE,OAAMN,cAAc;QAAA;UAGtBL,UAAU,GAAGE,iBAAiB;UAAAO,QAAA,CAAAE,IAAA;UAAA;QAAA;QAAA;UAAA,OAAAF,QAAA,CAAAa,IAAA;MAAA;IAAA;EAAA,GAAAC,OAAA;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"getNext.js","names":["moment","StrategyTypes","Unit","getNext","_ref","end","isInitial","options","start","timezone","type","_regeneratorRuntime","mark","_callee","duration","frequency","durationUnit","durationValue","frequencyUnit","frequencyValue","initial","dateCursor","nextOccurrenceStart","nextOccurrenceEnd","nextOccurrenceStartByBackCalculation","earliestNextOccurrenceStart","nextOccurrence","wrap","_context","prev","next","unit","value","tz","valueOf","add","Millisecond","Stopwatch","subtract","max","abrupt","stop"],"sources":["../../../src/scheduling/strategies/getNext.ts"],"sourcesContent":["import moment from 'moment-timezone'\n\nimport { GetNext, Interval, StrategyTypes, Unit } from '../scheduling.types'\n\n/**\n * Generates next occurrence interval for stopwatch and window strategy\n */\nexport function* getNext({\n end,\n isInitial,\n options,\n start,\n timezone,\n type,\n}: GetNext): IterableIterator<Interval> {\n const { duration, frequency } = options\n const { unit: durationUnit, value: durationValue } = duration\n const { unit: frequencyUnit, value: frequencyValue } = frequency\n\n let initial: boolean = isInitial\n\n let dateCursor: number = initial\n ? moment.tz(start, timezone).valueOf()\n : moment\n .tz(start, timezone)\n .add(1, Unit.Millisecond)\n .valueOf()\n\n while (dateCursor < end) {\n let nextOccurrenceStart: number\n let nextOccurrenceEnd: number\n\n if (type === StrategyTypes.Stopwatch) {\n nextOccurrenceStart = dateCursor\n nextOccurrenceEnd = moment\n .tz(dateCursor, timezone)\n .add(durationValue, durationUnit)\n .valueOf()\n\n } else {\n nextOccurrenceEnd = moment\n .tz(dateCursor, timezone)\n .add(frequencyValue, frequencyUnit)\n .valueOf()\n\n const nextOccurrenceStartByBackCalculation = moment\n .tz(nextOccurrenceEnd, timezone)\n .subtract(durationValue, durationUnit)\n\n const earliestNextOccurrenceStart = moment\n .tz(dateCursor, timezone)\n\n // NOTE: this is to ensure that the next occurrence start is always\n // greater than or equal to the date cursor. Moment js handles month addition and subtraction\n // with estimations (Dec 31st + 2 months gives Feb 28th/29th). This can lead to inaccurate start times when calculating forwards then backwards at the end of the month.\n nextOccurrenceStart =\n moment.max(\n earliestNextOccurrenceStart,\n nextOccurrenceStartByBackCalculation\n ).valueOf()\n }\n\n\n if (nextOccurrenceEnd <= nextOccurrenceStart || nextOccurrenceEnd > end) {\n return\n }\n\n if (nextOccurrenceStart >= start) {\n const nextOccurrence = [nextOccurrenceStart, nextOccurrenceEnd - 1]\n\n yield nextOccurrence\n }\n\n dateCursor = nextOccurrenceEnd\n }\n}\n"],"mappings":";AAAA,OAAOA,MAAM,MAAM,iBAAiB;AAEpC,SAA4BC,aAAa,EAAEC,IAAI,QAAQ,qBAAqB;;AAE5E;AACA;AACA;AACA,OAAO,SAAUC,OAAOA,CAAAC,IAAA;EAAA,IACtBC,GAAG,GAAAD,IAAA,CAAHC,GAAG;IACHC,SAAS,GAAAF,IAAA,CAATE,SAAS;IACTC,OAAO,GAAAH,IAAA,CAAPG,OAAO;IACPC,KAAK,GAAAJ,IAAA,CAALI,KAAK;IACLC,QAAQ,GAAAL,IAAA,CAARK,QAAQ;IACRC,IAAI,GAAAN,IAAA,CAAJM,IAAI;EAAA,oBAAAC,mBAAA,CAAAC,IAAA,UAAAC,QAAA;IAAA,IAAAC,QAAA,EAAAC,SAAA,EAAAC,YAAA,EAAAC,aAAA,EAAAC,aAAA,EAAAC,cAAA,EAAAC,OAAA,EAAAC,UAA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CgB,OAAO,CAAC,CAAC;YAENV,oCAAoC,GAAGxB,MAAM,CAChDiC,EAAE,CAACV,iBAAiB,EAAEd,QAAQ,CAAC,CAC/B6B,QAAQ,CAACrB,aAAa,EAAED,YAAY,CAAC;YAElCS,2BAA2B,GAAGzB,MAAM,CACvCiC,EAAE,CAACZ,UAAU,EAAEZ,QAAQ,CAAC,EAEzB;YACA;YACA;YACFa,mBAAmB,GACjBtB,MAAM,CAACuC,GAAG,CACVd,2BAA2B,EAC3BD,oCACF,CAAC,CAACU,OAAO,CAAC,CAAC;UACb;UAAC,MAGGX,iBAAiB,IAAID,mBAAmB,IAAIC,iBAAiB,GAAGlB,GAAG;YAAAuB,QAAA,CAAAE,IAAA;YAAA;UAAA;UAAA,OAAAF,QAAA,CAAAY,MAAA;QAAA;UAAA,MAInElB,mBAAmB,IAAId,KAAK;YAAAoB,QAAA,CAAAE,IAAA;YAAA;UAAA;UACxBJ,cAAc,GAAG,CAACJ,mBAAmB,EAAEC,iBAAiB,GAAG,CAAC,CAAC;UAAAK,QAAA,CAAAE,IAAA;UAEnE,OAAMJ,cAAc;QAAA;UAGtBL,UAAU,GAAGE,iBAAiB;UAAAK,QAAA,CAAAE,IAAA;UAAA;QAAA;QAAA;UAAA,OAAAF,QAAA,CAAAa,IAAA;MAAA;IAAA,GAAA5B,OAAA;EAAA;AAAA","ignoreList":[]}
@@ -1,5 +1,4 @@
1
1
  import _regeneratorRuntime from "@babel/runtime/regenerator";
2
- var _marked = /*#__PURE__*/_regeneratorRuntime.mark(getNextExactDateOfMonth);
3
2
  import moment from 'moment-timezone';
4
3
  import { Unit } from '../scheduling.types';
5
4
 
@@ -7,52 +6,56 @@ import { Unit } from '../scheduling.types';
7
6
  * Generates next occurrence interval for exact date of month strategy
8
7
  */
9
8
  export function getNextExactDateOfMonth(_ref) {
10
- var end, isInitial, options, start, timezone, date, duration, frequency, durationUnit, durationValue, frequencyUnit, frequencyValue, dateCursor, monthDate, hasExactDate, nextOccurrenceEnd, nextOccurrenceStart, nextOccurrence, nextDateCursor;
11
- return _regeneratorRuntime.wrap(function getNextExactDateOfMonth$(_context) {
12
- while (1) {
13
- switch (_context.prev = _context.next) {
9
+ var end = _ref.end,
10
+ isInitial = _ref.isInitial,
11
+ options = _ref.options,
12
+ start = _ref.start,
13
+ timezone = _ref.timezone;
14
+ return /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
15
+ var date, duration, frequency, durationUnit, durationValue, frequencyUnit, frequencyValue, dateCursor, monthDate, hasExactDate, nextOccurrenceEnd, nextOccurrenceStart, nextOccurrence, nextDateCursor;
16
+ return _regeneratorRuntime.wrap(function (_context) {
17
+ while (1) switch (_context.prev = _context.next) {
14
18
  case 0:
15
- end = _ref.end, isInitial = _ref.isInitial, options = _ref.options, start = _ref.start, timezone = _ref.timezone;
16
19
  date = options.date, duration = options.duration, frequency = options.frequency;
17
20
  durationUnit = duration.unit, durationValue = duration.value;
18
21
  frequencyUnit = frequency.unit, frequencyValue = frequency.value;
19
22
  dateCursor = isInitial ? moment.tz(start, timezone).startOf(Unit.Month).valueOf() : moment.tz(start, timezone).add(frequencyValue, frequencyUnit).startOf(Unit.Month).valueOf();
20
- case 5:
23
+ case 1:
21
24
  if (!(dateCursor < end)) {
22
- _context.next = 21;
25
+ _context.next = 4;
23
26
  break;
24
27
  }
25
28
  monthDate = moment.tz(dateCursor, timezone).date(date).date();
26
29
  hasExactDate = monthDate === date;
27
30
  if (!hasExactDate) {
28
- _context.next = 17;
31
+ _context.next = 3;
29
32
  break;
30
33
  }
31
34
  nextOccurrenceEnd = moment.tz(dateCursor, timezone).date(date).add(1, Unit.Day).valueOf();
32
35
  nextOccurrenceStart = moment.tz(nextOccurrenceEnd, timezone).subtract(durationValue, durationUnit).valueOf();
33
36
  if (!(nextOccurrenceEnd <= nextOccurrenceStart || nextOccurrenceEnd > end)) {
34
- _context.next = 13;
37
+ _context.next = 2;
35
38
  break;
36
39
  }
37
40
  return _context.abrupt("return");
38
- case 13:
41
+ case 2:
39
42
  if (!(nextOccurrenceStart >= start)) {
40
- _context.next = 17;
43
+ _context.next = 3;
41
44
  break;
42
45
  }
43
46
  nextOccurrence = [nextOccurrenceStart, nextOccurrenceEnd - 1];
44
- _context.next = 17;
47
+ _context.next = 3;
45
48
  return nextOccurrence;
46
- case 17:
49
+ case 3:
47
50
  nextDateCursor = moment.tz(dateCursor, timezone).add(1, Unit.Month).valueOf();
48
51
  dateCursor = nextDateCursor;
49
- _context.next = 5;
52
+ _context.next = 1;
50
53
  break;
51
- case 21:
54
+ case 4:
52
55
  case "end":
53
56
  return _context.stop();
54
57
  }
55
- }
56
- }, _marked);
58
+ }, _callee);
59
+ })();
57
60
  }
58
61
  //# sourceMappingURL=getNextExactDateOfMonth.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getNextExactDateOfMonth.js","names":["getNextExactDateOfMonth","moment","Unit","_ref","end","isInitial","options","start","timezone","date","duration","frequency","durationUnit","durationValue","frequencyUnit","frequencyValue","dateCursor","monthDate","hasExactDate","nextOccurrenceEnd","nextOccurrenceStart","nextOccurrence","nextDateCursor","_regeneratorRuntime","wrap","getNextExactDateOfMonth$","_context","prev","next","unit","value","tz","startOf","Month","valueOf","add","Day","subtract","abrupt","stop","_marked"],"sources":["../../../src/scheduling/strategies/getNextExactDateOfMonth.ts"],"sourcesContent":["import moment from 'moment-timezone'\n\nimport { GetNext, Interval, Unit } from '../scheduling.types'\n\n/**\n * Generates next occurrence interval for exact date of month strategy\n */\nexport function* getNextExactDateOfMonth({\n end,\n isInitial,\n options,\n start,\n timezone,\n}: GetNext): IterableIterator<Interval> {\n const { date, duration, frequency } = options\n const { unit: durationUnit, value: durationValue } = duration\n const { unit: frequencyUnit, value: frequencyValue } = frequency\n\n let dateCursor: number = isInitial\n ? moment\n .tz(start, timezone)\n .startOf(Unit.Month)\n .valueOf()\n : moment\n .tz(start, timezone)\n .add(frequencyValue, frequencyUnit)\n .startOf(Unit.Month)\n .valueOf()\n\n while (dateCursor < end) {\n const monthDate = moment\n .tz(dateCursor, timezone)\n .date(date)\n .date()\n\n const hasExactDate = monthDate === date\n\n if (hasExactDate) {\n const nextOccurrenceEnd: number = moment\n .tz(dateCursor, timezone)\n .date(date)\n .add(1, Unit.Day)\n .valueOf()\n\n const nextOccurrenceStart: number = moment\n .tz(nextOccurrenceEnd, timezone)\n .subtract(durationValue, durationUnit)\n .valueOf()\n\n if (nextOccurrenceEnd <= nextOccurrenceStart || nextOccurrenceEnd > end) {\n return\n }\n\n if (nextOccurrenceStart >= start) {\n const nextOccurrence: Interval = [\n nextOccurrenceStart,\n nextOccurrenceEnd - 1,\n ]\n\n yield nextOccurrence\n }\n }\n\n const nextDateCursor: number = moment\n .tz(dateCursor, timezone)\n .add(1, Unit.Month)\n .valueOf()\n\n dateCursor = nextDateCursor\n }\n}\n"],"mappings":";oDAOiBA,uBAAuB;AAPxC,OAAOC,MAAM,MAAM,iBAAiB;AAEpC,SAA4BC,IAAI,QAAQ,qBAAqB;;AAE7D;AACA;AACA;AACA,OAAO,SAAUF,uBAAuBA,CAAAG,IAAA;EAAA,IAAAC,GAAA,EAAAC,SAAA,EAAAC,OAAA,EAAAC,KAAA,EAAAC,QAAA,EAAAC,IAAA,EAAAC,QAAA,EAAAC,SAAA,EAAAC,YAAA,EAAAC,aAAA,EAAAC,aAAA,EAAAC,cAAA,EAAAC,UAAA,EAAAC,SAAA,EAAAC,YAAA,EAAAC,iBAAA,EAAAC,mBAAA,EAAAC,cAAA,EAAAC,cAAA;EAAA,OAAAC,mBAAA,CAAAC,IAAA,UAAAC,yBAAAC,QAAA;IAAA;MAAA,QAAAA,QAAA,CAAAC,IAAA,GAAAD,QAAA,CAAAE,IAAA;QAAA;UACtCxB,GAAG,GAAAD,IAAA,CAAHC,GAAG,EACHC,SAAS,GAAAF,IAAA,CAATE,SAAS,EACTC,OAAO,GAAAH,IAAA,CAAPG,OAAO,EACPC,KAAK,GAAAJ,IAAA,CAALI,KAAK,EACLC,QAAQ,GAAAL,IAAA,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Q,CAAC,CAC/B6B,QAAQ,CAACxB,aAAa,EAAED,YAAY,CAAC,CACrCsB,OAAO,CAAC,CAAC;UAAA,MAERf,iBAAiB,IAAIC,mBAAmB,IAAID,iBAAiB,GAAGf,GAAG;YAAAsB,QAAA,CAAAE,IAAA;YAAA;UAAA;UAAA,OAAAF,QAAA,CAAAY,MAAA;QAAA;UAAA,MAInElB,mBAAmB,IAAIb,KAAK;YAAAmB,QAAA,CAAAE,IAAA;YAAA;UAAA;UACxBP,cAAwB,GAAG,CAC/BD,mBAAmB,EACnBD,iBAAiB,GAAG,CAAC,CACtB;UAAAO,QAAA,CAAAE,IAAA;UAED,OAAMP,cAAc;QAAA;UAIlBC,cAAsB,GAAGrB,MAAM,CAClC8B,EAAE,CAACf,UAAU,EAAER,QAAQ,CAAC,CACxB2B,GAAG,CAAC,CAAC,EAAEjC,IAAI,CAAC+B,KAAK,CAAC,CAClBC,OAAO,CAAC,CAAC;UAEZlB,UAAU,GAAGM,cAAc;UAAAI,QAAA,CAAAE,IAAA;UAAA;QAAA;QAAA;UAAA,OAAAF,QAAA,CAAAa,IAAA;MAAA;IAAA;EAAA,GAAAC,OAAA;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"getNextExactDateOfMonth.js","names":["moment","Unit","getNextExactDateOfMonth","_ref","end","isInitial","options","start","timezone","_regeneratorRuntime","mark","_callee","date","duration","frequency","durationUnit","durationValue","frequencyUnit","frequencyValue","dateCursor","monthDate","hasExactDate","nextOccurrenceEnd","nextOccurrenceStart","nextOccurrence","nextDateCursor","wrap","_context","prev","next","unit","value","tz","startOf","Month","valueOf","add","Day","subtract","abrupt","stop"],"sources":["../../../src/scheduling/strategies/getNextExactDateOfMonth.ts"],"sourcesContent":["import moment from 'moment-timezone'\n\nimport { GetNext, Interval, Unit } from '../scheduling.types'\n\n/**\n * Generates next occurrence interval for exact date of month strategy\n */\nexport function* getNextExactDateOfMonth({\n end,\n isInitial,\n options,\n start,\n timezone,\n}: GetNext): IterableIterator<Interval> {\n const { date, duration, frequency } = options\n const { unit: durationUnit, value: durationValue } = duration\n const { unit: frequencyUnit, value: frequencyValue } = frequency\n\n let dateCursor: number = isInitial\n ? moment\n .tz(start, timezone)\n .startOf(Unit.Month)\n .valueOf()\n : moment\n .tz(start, timezone)\n .add(frequencyValue, frequencyUnit)\n .startOf(Unit.Month)\n .valueOf()\n\n while (dateCursor < end) {\n const monthDate = moment\n .tz(dateCursor, timezone)\n .date(date)\n .date()\n\n const hasExactDate = monthDate === date\n\n if (hasExactDate) {\n const nextOccurrenceEnd: number = moment\n .tz(dateCursor, timezone)\n .date(date)\n .add(1, Unit.Day)\n .valueOf()\n\n const nextOccurrenceStart: number = moment\n .tz(nextOccurrenceEnd, timezone)\n .subtract(durationValue, durationUnit)\n .valueOf()\n\n if (nextOccurrenceEnd <= nextOccurrenceStart || nextOccurrenceEnd > end) {\n return\n }\n\n if (nextOccurrenceStart >= start) {\n const nextOccurrence: Interval = [\n nextOccurrenceStart,\n nextOccurrenceEnd - 1,\n ]\n\n yield nextOccurrence\n }\n }\n\n const nextDateCursor: number = moment\n .tz(dateCursor, timezone)\n .add(1, Unit.Month)\n .valueOf()\n\n dateCursor = nextDateCursor\n }\n}\n"],"mappings":";AAAA,OAAOA,MAAM,MAAM,iBAAiB;AAEpC,SAA4BC,IAAI,QAAQ,qBAAqB;;AAE7D;AACA;AACA;AACA,OAAO,SAAUC,uBAAuBA,CAAAC,IAAA;EAAA,IACtCC,GAAG,GAAAD,IAAA,CAAHC,GAAG;IACHC,SAAS,GAAAF,IAAA,CAATE,SAAS;IACTC,OAAO,GAAAH,IAAA,CAAPG,OAAO;IACPC,KAAK,GAAAJ,IAAA,CAALI,KAAK;IACLC,QAAQ,GAAAL,IAAA,CAARK,QAAQ;EAAA,oBAAAC,mBAAA,CAAAC,IAAA,UAAAC,QAAA;IAAA,IAAAC,IAAA,EAAAC,QAAA,EAAAC,SAAA,EAAAC,YAAA,EAAAC,aAAA,EAAAC,aAAA,EAAAC,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