@awell-health/awell-extensions 2.1.68 → 2.1.70

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 (19) hide show
  1. package/dist/extensions/dateHelpers/actions/getNextDateOccurrence/config/dataPoints.d.ts +6 -0
  2. package/dist/extensions/dateHelpers/actions/getNextDateOccurrence/config/dataPoints.js +10 -0
  3. package/dist/extensions/dateHelpers/actions/getNextDateOccurrence/config/dataPoints.js.map +1 -0
  4. package/dist/extensions/dateHelpers/actions/getNextDateOccurrence/config/fields.d.ts +18 -0
  5. package/dist/extensions/dateHelpers/actions/getNextDateOccurrence/config/fields.js +18 -0
  6. package/dist/extensions/dateHelpers/actions/getNextDateOccurrence/config/fields.js.map +1 -0
  7. package/dist/extensions/dateHelpers/actions/getNextDateOccurrence/config/index.d.ts +2 -0
  8. package/dist/extensions/dateHelpers/actions/getNextDateOccurrence/config/index.js +9 -0
  9. package/dist/extensions/dateHelpers/actions/getNextDateOccurrence/config/index.js.map +1 -0
  10. package/dist/extensions/dateHelpers/actions/getNextDateOccurrence/getNextDateOccurrence.d.ts +4 -0
  11. package/dist/extensions/dateHelpers/actions/getNextDateOccurrence/getNextDateOccurrence.js +50 -0
  12. package/dist/extensions/dateHelpers/actions/getNextDateOccurrence/getNextDateOccurrence.js.map +1 -0
  13. package/dist/extensions/dateHelpers/actions/getNextDateOccurrence/index.d.ts +1 -0
  14. package/dist/extensions/dateHelpers/actions/getNextDateOccurrence/index.js +18 -0
  15. package/dist/extensions/dateHelpers/actions/getNextDateOccurrence/index.js.map +1 -0
  16. package/dist/extensions/dateHelpers/actions/index.d.ts +9 -0
  17. package/dist/extensions/dateHelpers/actions/index.js +2 -0
  18. package/dist/extensions/dateHelpers/actions/index.js.map +1 -1
  19. package/package.json +1 -1
@@ -0,0 +1,6 @@
1
+ export declare const dataPoints: {
2
+ nextDateOccurrence: {
3
+ key: string;
4
+ valueType: "date";
5
+ };
6
+ };
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dataPoints = void 0;
4
+ exports.dataPoints = {
5
+ nextDateOccurrence: {
6
+ key: 'nextDateOccurrence',
7
+ valueType: 'date',
8
+ },
9
+ };
10
+ //# sourceMappingURL=dataPoints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dataPoints.js","sourceRoot":"","sources":["../../../../../../extensions/dateHelpers/actions/getNextDateOccurrence/config/dataPoints.ts"],"names":[],"mappings":";;;AAEa,QAAA,UAAU,GAAG;IACxB,kBAAkB,EAAE;QAClB,GAAG,EAAE,oBAAoB;QACzB,SAAS,EAAE,MAAM;KAClB;CAC4C,CAAA"}
@@ -0,0 +1,18 @@
1
+ import { z } from 'zod';
2
+ import { FieldType } from '@awell-health/extensions-core';
3
+ export declare const fields: {
4
+ referenceDate: {
5
+ id: string;
6
+ label: string;
7
+ description: string;
8
+ type: FieldType.DATE;
9
+ required: false;
10
+ };
11
+ };
12
+ export declare const FieldsValidationSchema: z.ZodObject<{
13
+ referenceDate: z.ZodOptional<z.ZodDate>;
14
+ }, "strip", z.ZodTypeAny, {
15
+ referenceDate?: Date | undefined;
16
+ }, {
17
+ referenceDate?: Date | undefined;
18
+ }>;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FieldsValidationSchema = exports.fields = void 0;
4
+ const zod_1 = require("zod");
5
+ const extensions_core_1 = require("@awell-health/extensions-core");
6
+ exports.fields = {
7
+ referenceDate: {
8
+ id: 'referenceDate',
9
+ label: 'Reference date',
10
+ description: 'The date for which to calculate the next occurrence. If the year in the provided date is in the past, the next occurrence is computed in the upcoming year. If omitted, today’s date is used.',
11
+ type: extensions_core_1.FieldType.DATE,
12
+ required: false,
13
+ },
14
+ };
15
+ exports.FieldsValidationSchema = zod_1.z.object({
16
+ referenceDate: zod_1.z.optional(zod_1.z.coerce.date()),
17
+ });
18
+ //# sourceMappingURL=fields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fields.js","sourceRoot":"","sources":["../../../../../../extensions/dateHelpers/actions/getNextDateOccurrence/config/fields.ts"],"names":[],"mappings":";;;AAAA,6BAAwC;AACxC,mEAAqE;AAExD,QAAA,MAAM,GAAG;IACpB,aAAa,EAAE;QACb,EAAE,EAAE,eAAe;QACnB,KAAK,EAAE,gBAAgB;QACvB,WAAW,EACT,+LAA+L;QACjM,IAAI,EAAE,2BAAS,CAAC,IAAI;QACpB,QAAQ,EAAE,KAAK;KAChB;CAC8B,CAAA;AAEpB,QAAA,sBAAsB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC7C,aAAa,EAAE,OAAC,CAAC,QAAQ,CAAC,OAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;CACO,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { fields, FieldsValidationSchema } from './fields';
2
+ export { dataPoints } from './dataPoints';
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dataPoints = exports.FieldsValidationSchema = exports.fields = void 0;
4
+ var fields_1 = require("./fields");
5
+ Object.defineProperty(exports, "fields", { enumerable: true, get: function () { return fields_1.fields; } });
6
+ Object.defineProperty(exports, "FieldsValidationSchema", { enumerable: true, get: function () { return fields_1.FieldsValidationSchema; } });
7
+ var dataPoints_1 = require("./dataPoints");
8
+ Object.defineProperty(exports, "dataPoints", { enumerable: true, get: function () { return dataPoints_1.dataPoints; } });
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../extensions/dateHelpers/actions/getNextDateOccurrence/config/index.ts"],"names":[],"mappings":";;;AAAA,mCAAyD;AAAhD,gGAAA,MAAM,OAAA;AAAE,gHAAA,sBAAsB,OAAA;AACvC,2CAAyC;AAAhC,wGAAA,UAAU,OAAA"}
@@ -0,0 +1,4 @@
1
+ import { type Action } from '@awell-health/extensions-core';
2
+ import { type settings } from '../../settings';
3
+ import { dataPoints, fields } from './config';
4
+ export declare const getNextDateOccurrence: Action<typeof fields, typeof settings, keyof typeof dataPoints>;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getNextDateOccurrence = void 0;
4
+ const extensions_core_1 = require("@awell-health/extensions-core");
5
+ const config_1 = require("./config");
6
+ exports.getNextDateOccurrence = {
7
+ key: 'getNextDateOccurrence',
8
+ title: 'Get next date occurrence',
9
+ description: 'Get the next occurrence of a given date.',
10
+ category: extensions_core_1.Category.WORKFLOW,
11
+ fields: config_1.fields,
12
+ dataPoints: config_1.dataPoints,
13
+ previewable: true,
14
+ onActivityCreated: async (payload, onComplete, onError) => {
15
+ const { referenceDate: referenceDateInput } = config_1.FieldsValidationSchema.parse(payload.fields);
16
+ const now = new Date();
17
+ const referenceDate = referenceDateInput !== null && referenceDateInput !== void 0 ? referenceDateInput : now;
18
+ const targetMonth = referenceDate.getMonth(); // 0–11
19
+ const targetDay = referenceDate.getDate(); // 1–31
20
+ /**
21
+ * Find the first occurrence of (targetMonth, targetDay)
22
+ * that is strictly in the future compared to `afterDate`.
23
+ */
24
+ const findNextOccurrence = (afterDate) => {
25
+ let candidateYear = afterDate.getFullYear();
26
+ // Loop until we get a valid candidate strictly > afterDate
27
+ // and with the same month/day (handles Feb 29 properly).
28
+ // eslint-disable-next-line no-constant-condition
29
+ while (true) {
30
+ const candidate = new Date(candidateYear, targetMonth, targetDay, 0, 0, 0, 0);
31
+ const isSameMonthDay = candidate.getMonth() === targetMonth &&
32
+ candidate.getDate() === targetDay;
33
+ if (isSameMonthDay && candidate.getTime() > afterDate.getTime()) {
34
+ return candidate;
35
+ }
36
+ candidateYear += 1;
37
+ }
38
+ };
39
+ // If the reference date is in the future, compare against it.
40
+ // Otherwise, compare against "now".
41
+ const anchorDate = referenceDate.getTime() > now.getTime() ? referenceDate : now;
42
+ const nextOccurrence = findNextOccurrence(anchorDate);
43
+ await onComplete({
44
+ data_points: {
45
+ nextDateOccurrence: nextOccurrence.toISOString(),
46
+ },
47
+ });
48
+ },
49
+ };
50
+ //# sourceMappingURL=getNextDateOccurrence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getNextDateOccurrence.js","sourceRoot":"","sources":["../../../../../extensions/dateHelpers/actions/getNextDateOccurrence/getNextDateOccurrence.ts"],"names":[],"mappings":";;;AACA,mEAAwD;AAExD,qCAAqE;AAExD,QAAA,qBAAqB,GAI9B;IACF,GAAG,EAAE,uBAAuB;IAC5B,KAAK,EAAE,0BAA0B;IACjC,WAAW,EAAE,0CAA0C;IACvD,QAAQ,EAAE,0BAAQ,CAAC,QAAQ;IAC3B,MAAM,EAAN,eAAM;IACN,UAAU,EAAV,mBAAU;IACV,WAAW,EAAE,IAAI;IACjB,iBAAiB,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE;QACxD,MAAM,EAAE,aAAa,EAAE,kBAAkB,EAAE,GAAG,+BAAsB,CAAC,KAAK,CACxE,OAAO,CAAC,MAAM,CACf,CAAA;QAED,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAA;QACtB,MAAM,aAAa,GAAG,kBAAkB,aAAlB,kBAAkB,cAAlB,kBAAkB,GAAI,GAAG,CAAA;QAE/C,MAAM,WAAW,GAAG,aAAa,CAAC,QAAQ,EAAE,CAAA,CAAC,OAAO;QACpD,MAAM,SAAS,GAAG,aAAa,CAAC,OAAO,EAAE,CAAA,CAAC,OAAO;QAEjD;;;WAGG;QACH,MAAM,kBAAkB,GAAG,CAAC,SAAe,EAAQ,EAAE;YACnD,IAAI,aAAa,GAAG,SAAS,CAAC,WAAW,EAAE,CAAA;YAE3C,2DAA2D;YAC3D,yDAAyD;YACzD,iDAAiD;YACjD,OAAO,IAAI,EAAE,CAAC;gBACZ,MAAM,SAAS,GAAG,IAAI,IAAI,CACxB,aAAa,EACb,WAAW,EACX,SAAS,EACT,CAAC,EACD,CAAC,EACD,CAAC,EACD,CAAC,CACF,CAAA;gBAED,MAAM,cAAc,GAClB,SAAS,CAAC,QAAQ,EAAE,KAAK,WAAW;oBACpC,SAAS,CAAC,OAAO,EAAE,KAAK,SAAS,CAAA;gBAEnC,IAAI,cAAc,IAAI,SAAS,CAAC,OAAO,EAAE,GAAG,SAAS,CAAC,OAAO,EAAE,EAAE,CAAC;oBAChE,OAAO,SAAS,CAAA;gBAClB,CAAC;gBAED,aAAa,IAAI,CAAC,CAAA;YACpB,CAAC;QACH,CAAC,CAAA;QAED,8DAA8D;QAC9D,oCAAoC;QACpC,MAAM,UAAU,GACd,aAAa,CAAC,OAAO,EAAE,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,CAAA;QAE/D,MAAM,cAAc,GAAG,kBAAkB,CAAC,UAAU,CAAC,CAAA;QAErD,MAAM,UAAU,CAAC;YACf,WAAW,EAAE;gBACX,kBAAkB,EAAE,cAAc,CAAC,WAAW,EAAE;aACjD;SACF,CAAC,CAAA;IACJ,CAAC;CACF,CAAA"}
@@ -0,0 +1 @@
1
+ export * from './getNextDateOccurrence';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./getNextDateOccurrence"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../extensions/dateHelpers/actions/getNextDateOccurrence/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAuC"}
@@ -45,4 +45,13 @@ export declare const actions: {
45
45
  required: false;
46
46
  };
47
47
  }, {}, "isWithinWorkingHours" | "minutesToNextWorkingHours" | "nextWorkingHoursDatetime">;
48
+ getNextDateOccurrence: import("@awell-health/extensions-core").Action<{
49
+ referenceDate: {
50
+ id: string;
51
+ label: string;
52
+ description: string;
53
+ type: import("@awell-health/extensions-core").FieldType.DATE;
54
+ required: false;
55
+ };
56
+ }, {}, "nextDateOccurrence">;
48
57
  };
@@ -3,8 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.actions = void 0;
4
4
  const getNextWorkday_1 = require("./getNextWorkday");
5
5
  const checkWorkingHours_1 = require("./checkWorkingHours");
6
+ const getNextDateOccurrence_1 = require("./getNextDateOccurrence");
6
7
  exports.actions = {
7
8
  getNextWorkday: getNextWorkday_1.getNextWorkday,
8
9
  checkWorkingHours: checkWorkingHours_1.checkWorkingHours,
10
+ getNextDateOccurrence: getNextDateOccurrence_1.getNextDateOccurrence,
9
11
  };
10
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../extensions/dateHelpers/actions/index.ts"],"names":[],"mappings":";;;AAAA,qDAAiD;AACjD,2DAAuD;AAE1C,QAAA,OAAO,GAAG;IACrB,cAAc,EAAd,+BAAc;IACd,iBAAiB,EAAjB,qCAAiB;CAClB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../extensions/dateHelpers/actions/index.ts"],"names":[],"mappings":";;;AAAA,qDAAiD;AACjD,2DAAuD;AACvD,mEAA+D;AAElD,QAAA,OAAO,GAAG;IACrB,cAAc,EAAd,+BAAc;IACd,iBAAiB,EAAjB,qCAAiB;IACjB,qBAAqB,EAArB,6CAAqB;CACtB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awell-health/awell-extensions",
3
- "version": "2.1.68",
3
+ "version": "2.1.70",
4
4
  "packageManager": "yarn@4.5.3",
5
5
  "main": "dist/src/index.js",
6
6
  "repository": {