@activepieces/piece-date-helper 0.0.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.
package/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # pieces-date-helper
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Building
6
+
7
+ Run `nx build pieces-date-helper` to build the library.
package/package.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "@activepieces/piece-date-helper",
3
+ "version": "0.0.1",
4
+ "dependencies": {
5
+ "@sinclair/typebox": "^0.26.3",
6
+ "axios": "1.4.0",
7
+ "dayjs": "^1.11.8",
8
+ "is-base64": "^1.1.0",
9
+ "nanoid": "^3.3.4",
10
+ "semver": "7.5.4",
11
+ "@activepieces/pieces-framework": "0.6.16",
12
+ "@activepieces/shared": "0.8.1",
13
+ "tslib": "2.6.1"
14
+ },
15
+ "main": "./src/index.js",
16
+ "types": "./src/index.d.ts"
17
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare const utilityDate: import("@activepieces/pieces-framework").Piece<import("@activepieces/pieces-framework").PieceAuthProperty>;
package/src/index.js ADDED
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.utilityDate = void 0;
4
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
5
+ const get_current_date_1 = require("./lib/actions/get-current-date");
6
+ const format_date_1 = require("./lib/actions/format-date");
7
+ const extract_date_parts_1 = require("./lib/actions/extract-date-parts");
8
+ const date_difference_1 = require("./lib/actions/date-difference");
9
+ const add_subtract_date_1 = require("./lib/actions/add-subtract-date");
10
+ const description = `Effortlessly manipulate, format, and extract time units for all your date and time needs.`;
11
+ exports.utilityDate = (0, pieces_framework_1.createPiece)({
12
+ displayName: 'Date Helper',
13
+ auth: pieces_framework_1.PieceAuth.None(),
14
+ minimumSupportedRelease: '0.8.0',
15
+ logoUrl: 'https://cdn.activepieces.com/pieces/calendar_piece.svg',
16
+ authors: ['Salem-Alaa'],
17
+ actions: [
18
+ get_current_date_1.getCurrentDate,
19
+ format_date_1.formatDateAction,
20
+ extract_date_parts_1.extractDateParts,
21
+ date_difference_1.dateDifferenceAction,
22
+ add_subtract_date_1.addSubtractDateAction,
23
+ ],
24
+ triggers: [],
25
+ description: description,
26
+ });
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/pieces/date-helper/src/index.ts"],"names":[],"mappings":";;;AAAA,qEAAwE;AACxE,qEAAgE;AAChE,2DAA6D;AAC7D,yEAAoE;AACpE,mEAAqE;AACrE,uEAAwE;AAExE,MAAM,WAAW,GAAG,2FAA2F,CAAC;AAEnG,QAAA,WAAW,GAAG,IAAA,8BAAW,EAAC;IACrC,WAAW,EAAE,aAAa;IAC1B,IAAI,EAAE,4BAAS,CAAC,IAAI,EAAE;IACtB,uBAAuB,EAAE,OAAO;IAChC,OAAO,EAAE,wDAAwD;IACjE,OAAO,EAAE,CAAC,YAAY,CAAC;IACvB,OAAO,EAAE;QACP,iCAAc;QACd,8BAAgB;QAChB,qCAAgB;QAChB,sCAAoB;QACpB,yCAAqB;KACtB;IACD,QAAQ,EAAE,EAAE;IACZ,WAAW,EAAE,WAAW;CACzB,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { timeFormat } from '../common';
2
+ export declare const addSubtractDateAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").PieceAuthProperty, {
3
+ inputDate: import("@activepieces/pieces-framework").ShortTextProperty<true>;
4
+ inputDateFormat: import("@activepieces/pieces-framework").StaticDropdownProperty<timeFormat, true>;
5
+ outputFormat: import("@activepieces/pieces-framework").StaticDropdownProperty<timeFormat, true>;
6
+ expression: import("@activepieces/pieces-framework").LongTextProperty<true>;
7
+ }>;
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addSubtractDateAction = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const common_1 = require("../common");
7
+ exports.addSubtractDateAction = (0, pieces_framework_1.createAction)({
8
+ name: 'add_subtract_date',
9
+ displayName: 'Add/Subtract Time',
10
+ description: 'Add or subtract time from a date',
11
+ props: {
12
+ inputDate: pieces_framework_1.Property.ShortText({
13
+ displayName: 'Input Date',
14
+ description: 'Enter the input date',
15
+ required: true,
16
+ }),
17
+ inputDateFormat: pieces_framework_1.Property.StaticDropdown({
18
+ displayName: 'From Time Format',
19
+ description: common_1.timeFormatDescription,
20
+ options: {
21
+ options: common_1.optionalTimeFormats,
22
+ },
23
+ required: true,
24
+ defaultValue: common_1.timeFormat.format00,
25
+ }),
26
+ outputFormat: pieces_framework_1.Property.StaticDropdown({
27
+ displayName: 'To Time Format',
28
+ description: common_1.timeFormatDescription,
29
+ options: {
30
+ options: common_1.optionalTimeFormats,
31
+ },
32
+ required: true,
33
+ defaultValue: common_1.timeFormat.format00,
34
+ }),
35
+ expression: pieces_framework_1.Property.LongText({
36
+ displayName: 'Expression',
37
+ description: `Provide an expression to add or subtract using the following units
38
+ <b>( year , month , day , hour , minute or second )</b> . <br>Examples:<br> +2 <b>second</b> +1 <b>hour</b> <br> + 1 <b>year</b> - 3 <b>day</b> - 2 <b>month</b> <br> + 5 <b>minute</b>`,
39
+ required: true,
40
+ }),
41
+ },
42
+ run(context) {
43
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
44
+ const inputDate = context.propsValue.inputDate;
45
+ if (typeof inputDate !== 'string') {
46
+ throw new Error(`Input date is not a string \ninput date: ${JSON.stringify(inputDate)}`);
47
+ }
48
+ const inputDateFormat = context.propsValue.inputDateFormat;
49
+ if (typeof inputDateFormat !== 'string') {
50
+ throw new Error(`Input format is not a string \ninput format: ${JSON.stringify(inputDate)}`);
51
+ }
52
+ const outputFormat = context.propsValue.outputFormat;
53
+ if (typeof outputFormat !== 'string') {
54
+ throw new Error(`Output format is not a string \noutput format: ${JSON.stringify(inputDate)}`);
55
+ }
56
+ const expression = context.propsValue.expression;
57
+ if (typeof expression !== 'string') {
58
+ throw new Error(`Expression is not a string \nexpression: ${JSON.stringify(inputDate)}`);
59
+ }
60
+ const DateInfo = (0, common_1.getDateInformation)(inputDate, inputDateFormat);
61
+ const BeforeDate = new Date(DateInfo.year, DateInfo.month - 1, DateInfo.day, DateInfo.hour, DateInfo.minute, DateInfo.second);
62
+ const AfterDate = (0, common_1.addSubtractTime)(BeforeDate, expression);
63
+ return { result: (0, common_1.createNewDate)(AfterDate, outputFormat) };
64
+ });
65
+ },
66
+ });
67
+ //# sourceMappingURL=add-subtract-date.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-subtract-date.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/date-helper/src/lib/actions/add-subtract-date.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,sCAOmB;AAEN,QAAA,qBAAqB,GAAG,IAAA,+BAAY,EAAC;IAChD,IAAI,EAAE,mBAAmB;IACzB,WAAW,EAAE,mBAAmB;IAChC,WAAW,EAAE,kCAAkC;IAC/C,KAAK,EAAE;QACL,SAAS,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC5B,WAAW,EAAE,YAAY;YACzB,WAAW,EAAE,sBAAsB;YACnC,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,eAAe,EAAE,2BAAQ,CAAC,cAAc,CAAC;YACvC,WAAW,EAAE,kBAAkB;YAC/B,WAAW,EAAE,8BAAqB;YAClC,OAAO,EAAE;gBACP,OAAO,EAAE,4BAAmB;aAC7B;YACD,QAAQ,EAAE,IAAI;YACd,YAAY,EAAE,mBAAU,CAAC,QAAQ;SAClC,CAAC;QACF,YAAY,EAAE,2BAAQ,CAAC,cAAc,CAAC;YACpC,WAAW,EAAE,gBAAgB;YAC7B,WAAW,EAAE,8BAAqB;YAClC,OAAO,EAAE;gBACP,OAAO,EAAE,4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Q,CAAC,GAAG,EACZ,QAAQ,CAAC,IAAI,EACb,QAAQ,CAAC,MAAM,EACf,QAAQ,CAAC,MAAM,CAChB,CAAC;YACF,MAAM,SAAS,GAAG,IAAA,wBAAe,EAAC,UAAU,EAAE,UAAU,CAAC,CAAC;YAE1D,OAAO,EAAE,MAAM,EAAE,IAAA,sBAAa,EAAC,SAAS,EAAE,YAAY,CAAC,EAAE,CAAC;QAC5D,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { timeFormat, timeParts } from '../common';
2
+ export declare const dateDifferenceAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").PieceAuthProperty, {
3
+ startDate: import("@activepieces/pieces-framework").ShortTextProperty<true>;
4
+ startDateFormat: import("@activepieces/pieces-framework").StaticDropdownProperty<timeFormat, true>;
5
+ endDate: import("@activepieces/pieces-framework").ShortTextProperty<true>;
6
+ endDateFormat: import("@activepieces/pieces-framework").StaticDropdownProperty<timeFormat, true>;
7
+ unitDifference: import("@activepieces/pieces-framework").StaticMultiSelectDropdownProperty<timeParts, true>;
8
+ }>;
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dateDifferenceAction = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const common_1 = require("../common");
7
+ exports.dateDifferenceAction = (0, pieces_framework_1.createAction)({
8
+ name: 'date_difference',
9
+ displayName: 'Date Difference',
10
+ description: 'Get the difference between two dates',
11
+ props: {
12
+ startDate: pieces_framework_1.Property.ShortText({
13
+ displayName: 'Starting Date',
14
+ description: 'Enter the starting date',
15
+ required: true,
16
+ }),
17
+ startDateFormat: pieces_framework_1.Property.StaticDropdown({
18
+ displayName: 'Starting date format',
19
+ description: common_1.timeFormatDescription,
20
+ options: {
21
+ options: common_1.optionalTimeFormats,
22
+ },
23
+ required: true,
24
+ defaultValue: common_1.timeFormat.format00,
25
+ }),
26
+ endDate: pieces_framework_1.Property.ShortText({
27
+ displayName: 'Ending Date',
28
+ description: 'Enter the ending date',
29
+ required: true,
30
+ }),
31
+ endDateFormat: pieces_framework_1.Property.StaticDropdown({
32
+ displayName: 'Ending date format',
33
+ description: common_1.timeFormatDescription,
34
+ options: {
35
+ options: common_1.optionalTimeFormats,
36
+ },
37
+ required: true,
38
+ defaultValue: common_1.timeFormat.format00,
39
+ }),
40
+ unitDifference: pieces_framework_1.Property.StaticMultiSelectDropdown({
41
+ displayName: 'Unit',
42
+ description: 'Select the unit of difference between the two dates',
43
+ options: {
44
+ options: [
45
+ { label: 'Year', value: common_1.timeParts.year },
46
+ { label: 'Month', value: common_1.timeParts.month },
47
+ { label: 'Day', value: common_1.timeParts.day },
48
+ { label: 'Hour', value: common_1.timeParts.hour },
49
+ { label: 'Minute', value: common_1.timeParts.minute },
50
+ { label: 'Second', value: common_1.timeParts.second },
51
+ ],
52
+ },
53
+ required: true,
54
+ defaultValue: [common_1.timeParts.year],
55
+ }),
56
+ },
57
+ run(context) {
58
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
59
+ const inputStartDate = context.propsValue.startDate;
60
+ if (typeof inputStartDate !== 'string') {
61
+ throw new Error(`Input start date is not a string \ninput date: ${JSON.stringify(inputStartDate)}`);
62
+ }
63
+ const startDateFormat = context.propsValue.startDateFormat;
64
+ if (typeof startDateFormat !== 'string') {
65
+ throw new Error(`Input start date format is not a string \ninput date: ${JSON.stringify(startDateFormat)}`);
66
+ }
67
+ const inputEndDate = context.propsValue.endDate;
68
+ if (typeof inputEndDate !== 'string') {
69
+ throw new Error(`Input end date is not a string \ninput date: ${JSON.stringify(inputEndDate)}`);
70
+ }
71
+ const endDateFormat = context.propsValue.endDateFormat;
72
+ if (typeof endDateFormat !== 'string') {
73
+ throw new Error(`Input end date format is not a string \ninput date: ${JSON.stringify(endDateFormat)}`);
74
+ }
75
+ const startDateInfo = (0, common_1.getDateInformation)(inputStartDate, startDateFormat);
76
+ const endDateInfo = (0, common_1.getDateInformation)(inputEndDate, endDateFormat);
77
+ const startDate = (0, common_1.createDateFromInfo)(startDateInfo);
78
+ const endDate = (0, common_1.createDateFromInfo)(endDateInfo);
79
+ const unitDifference = context.propsValue.unitDifference;
80
+ const difference = endDate.getTime() - startDate.getTime();
81
+ const outputresponse = {};
82
+ for (let i = 0; i < unitDifference.length; i++) {
83
+ switch (unitDifference[i]) {
84
+ case common_1.timeParts.year:
85
+ outputresponse[common_1.timeParts.year] = Math.floor(difference / (1000 * 60 * 60 * 24 * 365));
86
+ break;
87
+ case common_1.timeParts.month:
88
+ outputresponse[common_1.timeParts.month] = Math.floor(difference / (1000 * 60 * 60 * 24 * 30));
89
+ break;
90
+ case common_1.timeParts.day:
91
+ outputresponse[common_1.timeParts.day] = Math.floor(difference / (1000 * 60 * 60 * 24));
92
+ break;
93
+ case common_1.timeParts.hour:
94
+ outputresponse[common_1.timeParts.hour] = Math.floor(difference / (1000 * 60 * 60));
95
+ break;
96
+ case common_1.timeParts.minute:
97
+ outputresponse[common_1.timeParts.minute] = Math.floor(difference / (1000 * 60));
98
+ break;
99
+ case common_1.timeParts.second:
100
+ outputresponse[common_1.timeParts.second] = Math.floor(difference / 1000);
101
+ break;
102
+ default:
103
+ throw new Error(`Invalid unit :\n${JSON.stringify(unitDifference[i])}`);
104
+ }
105
+ }
106
+ return outputresponse;
107
+ });
108
+ },
109
+ });
110
+ //# sourceMappingURL=date-difference.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date-difference.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/date-helper/src/lib/actions/date-difference.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,sCAQmB;AAEN,QAAA,oBAAoB,GAAG,IAAA,+BAAY,EAAC;IAC/C,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE,iBAAiB;IAC9B,WAAW,EAAE,sCAAsC;IACnD,KAAK,EAAE;QACL,SAAS,EAAE,2BAAQ,CAAC,S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AG,CAAC,IAAI,GAAG,EAAE,CAAC,CACzB,CAAC;wBACF,MAAM;oBACR,KAAK,kBAAS,CAAC,MAAM;wBACnB,cAAc,CAAC,kBAAS,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;wBACjE,MAAM;oBACR;wBACE,MAAM,IAAI,KAAK,CACb,mBAAmB,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,EAAE,CACvD,CAAC;iBACL;aACF;YAED,OAAO,cAAc,CAAC;QACxB,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { timeFormat, timeParts } from '../common';
2
+ export declare const extractDateParts: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").PieceAuthProperty, {
3
+ inputDate: import("@activepieces/pieces-framework").ShortTextProperty<true>;
4
+ inputFormat: import("@activepieces/pieces-framework").StaticDropdownProperty<timeFormat, true>;
5
+ unitExtract: import("@activepieces/pieces-framework").StaticMultiSelectDropdownProperty<timeParts, true>;
6
+ }>;
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractDateParts = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const common_1 = require("../common");
7
+ exports.extractDateParts = (0, pieces_framework_1.createAction)({
8
+ name: 'extract_date_parts',
9
+ displayName: 'Extract Date Units',
10
+ description: 'Extract date units ( year , month , day , hour , minute , second , day of week , month name ) from a date',
11
+ props: {
12
+ inputDate: pieces_framework_1.Property.ShortText({
13
+ displayName: 'Input Date',
14
+ description: 'Enter the input date',
15
+ required: true,
16
+ }),
17
+ inputFormat: pieces_framework_1.Property.StaticDropdown({
18
+ displayName: 'From Time Format',
19
+ description: common_1.timeFormatDescription,
20
+ options: {
21
+ options: common_1.optionalTimeFormats,
22
+ },
23
+ required: true,
24
+ defaultValue: common_1.timeFormat.format00,
25
+ }),
26
+ unitExtract: pieces_framework_1.Property.StaticMultiSelectDropdown({
27
+ displayName: 'Unit to Extract',
28
+ description: 'Select the unit to extract from the date',
29
+ options: {
30
+ options: [
31
+ { label: 'Year', value: common_1.timeParts.year },
32
+ { label: 'Month', value: common_1.timeParts.month },
33
+ { label: 'Day', value: common_1.timeParts.day },
34
+ { label: 'Hour', value: common_1.timeParts.hour },
35
+ { label: 'Minute', value: common_1.timeParts.minute },
36
+ { label: 'Second', value: common_1.timeParts.second },
37
+ { label: 'Day of Week', value: common_1.timeParts.dayOfWeek },
38
+ { label: 'Month name', value: common_1.timeParts.monthName },
39
+ ],
40
+ },
41
+ required: true,
42
+ defaultValue: [common_1.timeParts.year],
43
+ }),
44
+ },
45
+ run(context) {
46
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
47
+ const inputDate = context.propsValue.inputDate;
48
+ if (typeof inputDate !== 'string') {
49
+ throw new Error(`Input date is not a string \ninput date: ${JSON.stringify(inputDate)}`);
50
+ }
51
+ const inputFormat = context.propsValue.inputFormat;
52
+ if (typeof inputFormat !== 'string') {
53
+ throw new Error(`Input format is not a string \ninput format: ${JSON.stringify(inputDate)}`);
54
+ }
55
+ const unitExtract = context.propsValue.unitExtract;
56
+ const DateInfo = (0, common_1.getDateInformation)(inputDate, inputFormat);
57
+ const BeforeDate = (0, common_1.createDateFromInfo)(DateInfo);
58
+ const outputresponse = {};
59
+ for (let i = 0; i < unitExtract.length; i++) {
60
+ switch (unitExtract[i]) {
61
+ case common_1.timeParts.year:
62
+ outputresponse[common_1.timeParts.year] = DateInfo.year;
63
+ break;
64
+ case common_1.timeParts.month:
65
+ outputresponse[common_1.timeParts.month] = DateInfo.month;
66
+ break;
67
+ case common_1.timeParts.day:
68
+ outputresponse[common_1.timeParts.day] = DateInfo.day;
69
+ break;
70
+ case common_1.timeParts.hour:
71
+ outputresponse[common_1.timeParts.hour] = DateInfo.hour;
72
+ break;
73
+ case common_1.timeParts.minute:
74
+ outputresponse[common_1.timeParts.minute] = DateInfo.minute;
75
+ break;
76
+ case common_1.timeParts.second:
77
+ outputresponse[common_1.timeParts.second] = DateInfo.second;
78
+ break;
79
+ case common_1.timeParts.dayOfWeek:
80
+ outputresponse[common_1.timeParts.dayOfWeek] = BeforeDate.toLocaleString('en-us', { weekday: 'long' });
81
+ break;
82
+ case common_1.timeParts.monthName:
83
+ outputresponse[common_1.timeParts.monthName] = BeforeDate.toLocaleString('en-us', { month: 'long' });
84
+ break;
85
+ case common_1.timeParts.unix_time:
86
+ default:
87
+ throw new Error(`Invalid unit to extract :\n${JSON.stringify(unitExtract[i])}`);
88
+ }
89
+ }
90
+ return outputresponse;
91
+ });
92
+ },
93
+ });
94
+ //# sourceMappingURL=extract-date-parts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extract-date-parts.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/date-helper/src/lib/actions/extract-date-parts.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,sCAQmB;AAEN,QAAA,gBAAgB,GAAG,IAAA,+BAAY,EAAC;IAC3C,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EAAE,oBAAoB;IACjC,WAAW,EACT,2GAA2G;IAC7G,KAAK,EAAE;QACL,SAAS,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC5B,WAAW,EAAE,YAAY;YACzB,WAAW,EAAE,sBAAsB;YACnC,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,WAAW,EAAE,2BAAQ,CAAC,cAAc,CAAC;YACnC,WAAW,EAAE,kBAAkB;YAC/B,WAAW,EAAE,8BAAqB;YAClC,OAAO,EAAE;gBACP,OAAO,EAAE,4BAAmB;aAC7B;YACD,QAAQ,EAAE,IAAI;YACd,YAAY,EAAE,mBAAU,CAAC,QAAQ;SAClC,CAAC;QACF,WAAW,EAAE,2BAAQ,CAAC,yBAAyB,CAAC;YAC9C,WAAW,EAAE,iBAAiB;YAC9B,WAAW,EAAE,0CAA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CAAC,SAAS;wBACtB,cAAc,CAAC,kBAAS,CAAC,SAAS,CAAC,GAAG,UAAU,CAAC,cAAc,CAC7D,OAAO,EACP,EAAE,KAAK,EAAE,MAAM,EAAE,CAClB,CAAC;wBACF,MAAM;oBACR,KAAK,kBAAS,CAAC,SAAS,CAAC;oBACzB;wBACE,MAAM,IAAI,KAAK,CACb,8BAA8B,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,CAC/D,CAAC;iBACL;aACF;YACD,OAAO,cAAc,CAAC;QACxB,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { timeFormat } from '../common';
2
+ export declare const formatDateAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").PieceAuthProperty, {
3
+ inputDate: import("@activepieces/pieces-framework").ShortTextProperty<true>;
4
+ inputFormat: import("@activepieces/pieces-framework").StaticDropdownProperty<timeFormat, true>;
5
+ inputTimeZone: import("@activepieces/pieces-framework").StaticDropdownProperty<string, false> | import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
6
+ outputFormat: import("@activepieces/pieces-framework").StaticDropdownProperty<timeFormat, true>;
7
+ outputTimeZone: import("@activepieces/pieces-framework").StaticDropdownProperty<string, false> | import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
8
+ }>;
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatDateAction = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const common_1 = require("../common");
7
+ exports.formatDateAction = (0, pieces_framework_1.createAction)({
8
+ name: 'format_date',
9
+ displayName: 'Format Date',
10
+ description: 'Converts a date from one format to another',
11
+ props: {
12
+ inputDate: pieces_framework_1.Property.ShortText({
13
+ displayName: 'Input Date',
14
+ description: 'Enter the input date',
15
+ required: true,
16
+ }),
17
+ inputFormat: pieces_framework_1.Property.StaticDropdown({
18
+ displayName: 'From Time Format',
19
+ description: common_1.timeFormatDescription,
20
+ options: {
21
+ options: common_1.optionalTimeFormats,
22
+ },
23
+ required: true,
24
+ defaultValue: common_1.timeFormat.format00,
25
+ }),
26
+ inputTimeZone: pieces_framework_1.Property.StaticDropdown({
27
+ displayName: 'From Time Zone',
28
+ options: {
29
+ options: common_1.timeZoneOptions,
30
+ },
31
+ required: true,
32
+ defaultValue: 'UTC',
33
+ }),
34
+ outputFormat: pieces_framework_1.Property.StaticDropdown({
35
+ displayName: 'To Time Format',
36
+ description: common_1.timeFormatDescription,
37
+ options: {
38
+ options: common_1.optionalTimeFormats,
39
+ },
40
+ required: true,
41
+ defaultValue: common_1.timeFormat.format00,
42
+ }),
43
+ outputTimeZone: pieces_framework_1.Property.StaticDropdown({
44
+ displayName: 'To Time Zone',
45
+ options: {
46
+ options: common_1.timeZoneOptions,
47
+ },
48
+ required: true,
49
+ defaultValue: 'UTC',
50
+ }),
51
+ },
52
+ run(context) {
53
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
54
+ const inputDate = context.propsValue.inputDate;
55
+ if (typeof inputDate !== 'string') {
56
+ throw new Error(`Input date is not a string \ninput date: ${JSON.stringify(inputDate)}`);
57
+ }
58
+ const inputFormat = context.propsValue.inputFormat;
59
+ if (typeof inputFormat !== 'string') {
60
+ throw new Error(`Input format is not a string \ninput format: ${JSON.stringify(inputDate)}`);
61
+ }
62
+ const inputTimeZone = context.propsValue.inputTimeZone;
63
+ const outputFormat = context.propsValue.outputFormat;
64
+ if (typeof outputFormat !== 'string') {
65
+ throw new Error(`Output format is not a string \noutput format: ${JSON.stringify(inputDate)}`);
66
+ }
67
+ const outputTimeZone = context.propsValue.outputTimeZone;
68
+ return {
69
+ result: (0, common_1.ChangeDateFormat)(inputDate, inputFormat, inputTimeZone, outputFormat, outputTimeZone),
70
+ };
71
+ });
72
+ },
73
+ });
74
+ //# sourceMappingURL=format-date.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-date.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/date-helper/src/lib/actions/format-date.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,sCAMmB;AAEN,QAAA,gBAAgB,GAAG,IAAA,+BAAY,EAAC;IAC3C,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,aAAa;IAC1B,WAAW,EAAE,4CAA4C;IACzD,KAAK,EAAE;QACL,SAAS,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC5B,WAAW,EAAE,YAAY;YACzB,WAAW,EAAE,sBAAsB;YACnC,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,WAAW,EAAE,2BAAQ,CAAC,cAAc,CAAC;YACnC,WAAW,EAAE,kBAAkB;YAC/B,WAAW,EAAE,8BAAqB;YAClC,OAAO,EAAE;gBACP,OAAO,EAAE,4BAAmB;aAC7B;YACD,QAAQ,EAAE,IAAI;YACd,YAAY,EAAE,mBAAU,CAAC,QAAQ;SAClC,CAAC;QACF,aAAa,EAAE,2BAAQ,CAAC,cAAc,CAAS;YAC7C,WAAW,EAAE,gBAAgB;YAC7B,OAAO,EAAE;gBACP,OAAO,EAAE,wBAAe;aACzB;YACD,QAAQ,EAAE,IAAI;YACd,YAAY,EAAE,KAAK;SACpB,CAAC;QACF,YAAY,EAAE,2BAAQ,CAAC,cAAc,CAAC;YACpC,WAAW,EAAE,gBAAgB;YAC7B,WAAW,EAAE,8BAAqB;YAClC,OAAO,EAAE;gBACP,OAAO,EAAE,4BAAmB;aAC7B;YACD,QAAQ,EAAE,IAAI;YACd,YAAY,EAAE,mBAAU,CAAC,QAAQ;SAClC,CAAC;QACF,cAAc,EAAE,2BAAQ,CAAC,cAAc,CAAS;YAC9C,WAAW,EAAE,cAAc;YAC3B,OAAO,EAAE;gBACP,OAAO,EAAE,wBAAe;aACzB;YACD,QAAQ,EAAE,IAAI;YACd,YAAY,EAAE,KAAK;SACpB,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;YACf,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC;YAC/C,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE;gBACjC,MAAM,IAAI,KAAK,CACb,4CAA4C,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CACxE,CAAC;aACH;YACD,MAAM,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,WAAqB,CAAC;YAC7D,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE;gBACnC,MAAM,IAAI,KAAK,CACb,gDAAgD,IAAI,CAAC,SAAS,CAC5D,SAAS,CACV,EAAE,CACJ,CAAC;aACH;YACD,MAAM,aAAa,GAAG,OAAO,CAAC,UAAU,CAAC,aAAuB,CAAC;YACjE,MAAM,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC,YAAsB,CAAC;YAC/D,IAAI,OAAO,YAAY,KAAK,QAAQ,EAAE;gBACpC,MAAM,IAAI,KAAK,CACb,kDAAkD,IAAI,CAAC,SAAS,CAC9D,SAAS,CACV,EAAE,CACJ,CAAC;aACH;YACD,MAAM,cAAc,GAAG,OAAO,CAAC,UAAU,CAAC,cAAwB,CAAC;YAEnE,OAAO;gBACL,MAAM,EAAE,IAAA,yBAAgB,EACtB,SAAS,EACT,WAAW,EACX,aAAa,EACb,YAAY,EACZ,cAAc,CACf;aACF,CAAC;QACJ,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { timeFormat } from '../common';
2
+ export declare const getCurrentDate: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").PieceAuthProperty, {
3
+ timeFormat: import("@activepieces/pieces-framework").StaticDropdownProperty<timeFormat, true>;
4
+ timeZone: import("@activepieces/pieces-framework").StaticDropdownProperty<string, false> | import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
5
+ }>;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCurrentDate = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const common_1 = require("../common");
7
+ exports.getCurrentDate = (0, pieces_framework_1.createAction)({
8
+ name: 'get_current_date',
9
+ displayName: 'Get Current Date',
10
+ description: 'Get the current date',
11
+ props: {
12
+ timeFormat: pieces_framework_1.Property.StaticDropdown({
13
+ displayName: 'To Time Format',
14
+ description: common_1.timeFormatDescription,
15
+ options: {
16
+ options: common_1.optionalTimeFormats,
17
+ },
18
+ required: true,
19
+ defaultValue: common_1.timeFormat.format00,
20
+ }),
21
+ timeZone: pieces_framework_1.Property.StaticDropdown({
22
+ displayName: 'Time Zone',
23
+ options: {
24
+ options: common_1.timeZoneOptions,
25
+ },
26
+ required: true,
27
+ defaultValue: 'UTC',
28
+ }),
29
+ },
30
+ run(context) {
31
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
32
+ const timeFormat = context.propsValue.timeFormat;
33
+ const timeZone = context.propsValue.timeZone;
34
+ const date = new Date();
35
+ if (typeof timeFormat !== 'string') {
36
+ throw new Error(`Output format is not a string \noutput format: ${JSON.stringify(timeFormat)}`);
37
+ }
38
+ date.setMinutes(date.getMinutes() + (0, common_1.timeDiff)('UTC', timeZone));
39
+ return { result: (0, common_1.createNewDate)(date, timeFormat) };
40
+ });
41
+ },
42
+ });
43
+ //# sourceMappingURL=get-current-date.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-current-date.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/date-helper/src/lib/actions/get-current-date.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,sCAOmB;AAEN,QAAA,cAAc,GAAG,IAAA,+BAAY,EAAC;IACzC,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,kBAAkB;IAC/B,WAAW,EAAE,sBAAsB;IACnC,KAAK,EAAE;QACL,UAAU,EAAE,2BAAQ,CAAC,cAAc,CAAC;YAClC,WAAW,EAAE,gBAAgB;YAC7B,WAAW,EAAE,8BAAqB;YAClC,OAAO,EAAE;gBACP,OAAO,EAAE,4BAAmB;aAC7B;YACD,QAAQ,EAAE,IAAI;YACd,YAAY,EAAE,mBAAU,CAAC,QAAQ;SAClC,CAAC;QACF,QAAQ,EAAE,2BAAQ,CAAC,cAAc,CAAS;YACxC,WAAW,EAAE,WAAW;YACxB,OAAO,EAAE;gBACP,OAAO,EAAE,wBAAe;aACzB;YACD,QAAQ,EAAE,IAAI;YACd,YAAY,EAAE,KAAK;SACpB,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;YACf,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC;YACjD,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,QAAkB,CAAC;YACvD,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;YAExB,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE;gBAClC,MAAM,IAAI,KAAK,CACb,kDAAkD,IAAI,CAAC,SAAS,CAC9D,UAAU,CACX,EAAE,CACJ,CAAC;aACH;YAED,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,IAAA,iBAAQ,EAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;YAE/D,OAAO,EAAE,MAAM,EAAE,IAAA,sBAAa,EAAC,IAAI,EAAE,UAAU,CAAC,EAAE,CAAC;QACrD,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,77 @@
1
+ export interface dateInformation {
2
+ year: number;
3
+ month: number;
4
+ day: number;
5
+ hour: number;
6
+ minute: number;
7
+ second: number;
8
+ unix_time: number;
9
+ }
10
+ export declare enum timeFormat {
11
+ format00 = "DDD MMM DD YYYY HH:mm:ss",
12
+ format01 = "DDD MMM DD HH:mm:ss YYYY",
13
+ format02 = "MMMM DD YYYY HH:mm:ss",
14
+ format03 = "MMMM DD YYYY",
15
+ format04 = "MMM DD YYYY",
16
+ format05 = "YYYY-MM-DDTHH:mm:ss",
17
+ format06 = "YYYY-MM-DD HH:mm:ss",
18
+ format07 = "YYYY-MM-DD",
19
+ format08 = "MM-DD-YYYY",
20
+ format09 = "MM/DD/YYYY",
21
+ format10 = "MM/DD/YY",
22
+ format11 = "DD-MM-YYYY",
23
+ format12 = "DD/MM/YYYY",
24
+ format13 = "DD/MM/YY",
25
+ format14 = "X"
26
+ }
27
+ export declare enum timeFormatLabel {
28
+ format00 = "DDD MMM DD YYYY HH:mm:ss (Sun Sep 17 2023 11:23:58)",
29
+ format01 = "DDD MMM DD HH:mm:ss YYYY (Sun Sep 17 11:23:58 2023)",
30
+ format02 = "MMMM DD YYYY HH:mm:ss (September 17 2023 11:23:58)",
31
+ format03 = "MMMM DD YYYY (September 17 2023)",
32
+ format04 = "MMM DD YYYY (Sep 17 2023)",
33
+ format05 = "YYYY-MM-DDTHH:mm:ss (2023-09-17T11:23:58) ",
34
+ format06 = "YYYY-MM-DD HH:mm:ss (2023-09-17 11:23:58)",
35
+ format07 = "YYYY-MM-DD (2023-09-17)",
36
+ format08 = "MM-DD-YYYY (09-17-2023)",
37
+ format09 = "MM/DD/YYYY (09/17/2023)",
38
+ format10 = "MM/DD/YY (09/17/23)",
39
+ format11 = "DD-MM-YYYY (17-09-2023)",
40
+ format12 = "DD/MM/YYYY (17/09/2023)",
41
+ format13 = "DD/MM/YY (17/09/23)",
42
+ format14 = "X (1694949838)"
43
+ }
44
+ export declare enum timeParts {
45
+ year = "year",
46
+ month = "month",
47
+ day = "day",
48
+ hour = "hour",
49
+ minute = "minute",
50
+ second = "second",
51
+ unix_time = "unix_time",
52
+ dayOfWeek = "dayOfWeek",
53
+ monthName = "monthName"
54
+ }
55
+ export declare const timeFormatDescription = "Here's what each part of the format (eg. YYYY) means:\n\nYYYY : Year (4 digits)\n\nYY : Year (2 digits)\n\nMMMM : Month (full name)\n\nMMM : Month (short name)\n\nMM : Month (2 digits)\n\nDDDD : Day (full name)\n\nDDD : Day (short name)\n\nDD : Day (2 digits)\n\nHH : Hour (2 digits)\n\nmm : Minute (2 digits)\n\nss : Second (2 digits)\n\nX : Time in unix format";
56
+ export declare const optionalTimeFormats: {
57
+ label: timeFormatLabel;
58
+ value: timeFormat;
59
+ }[];
60
+ export declare function createDateFromInfo(dateInfo: dateInformation): Date;
61
+ export declare function getDateInformation(date: string, TF: string): {
62
+ year: number;
63
+ month: number;
64
+ day: number;
65
+ hour: number;
66
+ minute: number;
67
+ second: number;
68
+ unix_time: number;
69
+ };
70
+ export declare function createNewDate(date: Date, TF: string): string;
71
+ export declare function timeDiff(beforeTimeZone: string, afterTimeZone: string): number;
72
+ export declare function ChangeDateFormat(date: string, beforeFormat: string, beforeTimeZone: string, afterFormat: string, afterTimeZone: string): string;
73
+ export declare function addSubtractTime(date: Date, expression: string): Date;
74
+ export declare const timeZoneOptions: {
75
+ label: string;
76
+ value: string;
77
+ }[];