@segment/action-destinations 3.182.1-CONMAN-576.1 → 3.183.0
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/dist/destinations/app-fit/config.d.ts +3 -0
- package/dist/destinations/app-fit/config.js +7 -0
- package/dist/destinations/app-fit/config.js.map +1 -0
- package/dist/destinations/app-fit/generated-types.d.ts +3 -0
- package/dist/destinations/app-fit/generated-types.js +3 -0
- package/dist/destinations/app-fit/generated-types.js.map +1 -0
- package/dist/destinations/app-fit/index.d.ts +4 -0
- package/dist/destinations/app-fit/index.js +39 -0
- package/dist/destinations/app-fit/index.js.map +1 -0
- package/dist/destinations/app-fit/track/generated-types.d.ts +13 -0
- package/dist/destinations/app-fit/track/generated-types.js +3 -0
- package/dist/destinations/app-fit/track/generated-types.js.map +1 -0
- package/dist/destinations/app-fit/track/index.d.ts +5 -0
- package/dist/destinations/app-fit/track/index.js +109 -0
- package/dist/destinations/app-fit/track/index.js.map +1 -0
- package/dist/destinations/engage-messaging-twilio/operationTracking/GenericMethodDecorator.d.ts +1 -0
- package/dist/destinations/engage-messaging-twilio/operationTracking/GenericMethodDecorator.js +3 -0
- package/dist/destinations/engage-messaging-twilio/operationTracking/GenericMethodDecorator.js.map +1 -0
- package/dist/destinations/engage-messaging-twilio/operationTracking/OperationDecorator.d.ts +46 -0
- package/dist/destinations/engage-messaging-twilio/operationTracking/OperationDecorator.js +46 -0
- package/dist/destinations/engage-messaging-twilio/operationTracking/OperationDecorator.js.map +1 -0
- package/dist/destinations/engage-messaging-twilio/operationTracking/OperationDuration.d.ts +12 -0
- package/dist/destinations/engage-messaging-twilio/operationTracking/OperationDuration.js +23 -0
- package/dist/destinations/engage-messaging-twilio/operationTracking/OperationDuration.js.map +1 -0
- package/dist/destinations/engage-messaging-twilio/operationTracking/OperationErrorHandler.d.ts +12 -0
- package/dist/destinations/engage-messaging-twilio/operationTracking/OperationErrorHandler.js +35 -0
- package/dist/destinations/engage-messaging-twilio/operationTracking/OperationErrorHandler.js.map +1 -0
- package/dist/destinations/engage-messaging-twilio/operationTracking/OperationFinallyHooks.d.ts +10 -0
- package/dist/destinations/engage-messaging-twilio/operationTracking/OperationFinallyHooks.js +29 -0
- package/dist/destinations/engage-messaging-twilio/operationTracking/OperationFinallyHooks.js.map +1 -0
- package/dist/destinations/engage-messaging-twilio/operationTracking/OperationLogger.d.ts +30 -0
- package/dist/destinations/engage-messaging-twilio/operationTracking/OperationLogger.js +107 -0
- package/dist/destinations/engage-messaging-twilio/operationTracking/OperationLogger.js.map +1 -0
- package/dist/destinations/engage-messaging-twilio/operationTracking/OperationStats.d.ts +39 -0
- package/dist/destinations/engage-messaging-twilio/operationTracking/OperationStats.js +130 -0
- package/dist/destinations/engage-messaging-twilio/operationTracking/OperationStats.js.map +1 -0
- package/dist/destinations/engage-messaging-twilio/operationTracking/OperationTracker.test.d.ts +1 -0
- package/dist/destinations/engage-messaging-twilio/operationTracking/OperationTracker.test.js +377 -0
- package/dist/destinations/engage-messaging-twilio/operationTracking/OperationTracker.test.js.map +1 -0
- package/dist/destinations/engage-messaging-twilio/operationTracking/OperationTree.d.ts +23 -0
- package/dist/destinations/engage-messaging-twilio/operationTracking/OperationTree.js +49 -0
- package/dist/destinations/engage-messaging-twilio/operationTracking/OperationTree.js.map +1 -0
- package/dist/destinations/engage-messaging-twilio/operationTracking/TrackedError.d.ts +6 -0
- package/dist/destinations/engage-messaging-twilio/operationTracking/TrackedError.js +3 -0
- package/dist/destinations/engage-messaging-twilio/operationTracking/TrackedError.js.map +1 -0
- package/dist/destinations/engage-messaging-twilio/operationTracking/index.d.ts +10 -0
- package/dist/destinations/engage-messaging-twilio/operationTracking/index.js +23 -0
- package/dist/destinations/engage-messaging-twilio/operationTracking/index.js.map +1 -0
- package/dist/destinations/engage-messaging-twilio/operationTracking/wrapTryCatchFinallyPromisable.d.ts +21 -0
- package/dist/destinations/engage-messaging-twilio/operationTracking/wrapTryCatchFinallyPromisable.js +99 -0
- package/dist/destinations/engage-messaging-twilio/operationTracking/wrapTryCatchFinallyPromisable.js.map +1 -0
- package/dist/destinations/engage-messaging-twilio/sendMobilePush/generated-types.d.ts +1 -1
- package/dist/destinations/engage-messaging-twilio/sendMobilePush/index.js +7 -25
- package/dist/destinations/engage-messaging-twilio/sendMobilePush/index.js.map +1 -1
- package/dist/destinations/engage-messaging-twilio/sendMobilePush/push-sender.d.ts +1 -1
- package/dist/destinations/engage-messaging-twilio/sendMobilePush/push-sender.js +31 -25
- package/dist/destinations/engage-messaging-twilio/sendMobilePush/push-sender.js.map +1 -1
- package/dist/destinations/engage-messaging-twilio/sendSms/index.js +1 -1
- package/dist/destinations/engage-messaging-twilio/sendSms/index.js.map +1 -1
- package/dist/destinations/engage-messaging-twilio/sendSms/sms-sender.d.ts +1 -1
- package/dist/destinations/engage-messaging-twilio/sendSms/sms-sender.js +20 -10
- package/dist/destinations/engage-messaging-twilio/sendSms/sms-sender.js.map +1 -1
- package/dist/destinations/engage-messaging-twilio/sendWhatsApp/index.js +1 -1
- package/dist/destinations/engage-messaging-twilio/sendWhatsApp/index.js.map +1 -1
- package/dist/destinations/engage-messaging-twilio/sendWhatsApp/whatsapp-sender.d.ts +1 -1
- package/dist/destinations/engage-messaging-twilio/sendWhatsApp/whatsapp-sender.js +42 -36
- package/dist/destinations/engage-messaging-twilio/sendWhatsApp/whatsapp-sender.js.map +1 -1
- package/dist/destinations/engage-messaging-twilio/utils/IntegrationErrorWrapper.d.ts +12 -0
- package/dist/destinations/engage-messaging-twilio/utils/IntegrationErrorWrapper.js +31 -0
- package/dist/destinations/engage-messaging-twilio/utils/IntegrationErrorWrapper.js.map +1 -0
- package/dist/destinations/engage-messaging-twilio/utils/MessageLogger.d.ts +15 -0
- package/dist/destinations/engage-messaging-twilio/utils/MessageLogger.js +36 -0
- package/dist/destinations/engage-messaging-twilio/utils/MessageLogger.js.map +1 -0
- package/dist/destinations/engage-messaging-twilio/utils/MessageStats.d.ts +14 -0
- package/dist/destinations/engage-messaging-twilio/utils/MessageStats.js +78 -0
- package/dist/destinations/engage-messaging-twilio/utils/MessageStats.js.map +1 -0
- package/dist/destinations/engage-messaging-twilio/utils/index.d.ts +6 -0
- package/dist/destinations/engage-messaging-twilio/utils/index.js +19 -0
- package/dist/destinations/engage-messaging-twilio/utils/index.js.map +1 -0
- package/dist/destinations/engage-messaging-twilio/utils/isDestinationActionService.d.ts +1 -0
- package/dist/destinations/engage-messaging-twilio/utils/isDestinationActionService.js +8 -0
- package/dist/destinations/engage-messaging-twilio/utils/isDestinationActionService.js.map +1 -0
- package/dist/destinations/engage-messaging-twilio/utils/message-sender.d.ts +21 -54
- package/dist/destinations/engage-messaging-twilio/utils/message-sender.js +112 -225
- package/dist/destinations/engage-messaging-twilio/utils/message-sender.js.map +1 -1
- package/dist/destinations/engage-messaging-twilio/utils/phone-message.d.ts +7 -0
- package/dist/destinations/engage-messaging-twilio/utils/phone-message.js +30 -33
- package/dist/destinations/engage-messaging-twilio/utils/phone-message.js.map +1 -1
- package/dist/destinations/engage-messaging-twilio/utils/track.d.ts +45 -0
- package/dist/destinations/engage-messaging-twilio/utils/track.js +9 -0
- package/dist/destinations/engage-messaging-twilio/utils/track.js.map +1 -0
- package/dist/destinations/index.js +3 -0
- package/dist/destinations/index.js.map +1 -1
- package/dist/destinations/insider/trackEvent/index.js +1 -1
- package/dist/destinations/insider/trackEvent/index.js.map +1 -1
- package/dist/destinations/listrak/generated-types.d.ts +4 -0
- package/dist/destinations/listrak/generated-types.js +3 -0
- package/dist/destinations/listrak/generated-types.js.map +1 -0
- package/dist/destinations/listrak/index.d.ts +4 -0
- package/dist/destinations/listrak/index.js +55 -0
- package/dist/destinations/listrak/index.js.map +1 -0
- package/dist/destinations/listrak/updateEmailContactProfileFields/generated-types.d.ts +8 -0
- package/dist/destinations/listrak/updateEmailContactProfileFields/generated-types.js +3 -0
- package/dist/destinations/listrak/updateEmailContactProfileFields/generated-types.js.map +1 -0
- package/dist/destinations/listrak/updateEmailContactProfileFields/index.d.ts +13 -0
- package/dist/destinations/listrak/updateEmailContactProfileFields/index.js +77 -0
- package/dist/destinations/listrak/updateEmailContactProfileFields/index.js.map +1 -0
- package/dist/destinations/m3ter/auth.d.ts +7 -0
- package/dist/destinations/m3ter/auth.js +16 -0
- package/dist/destinations/m3ter/auth.js.map +1 -0
- package/dist/destinations/m3ter/constants.d.ts +4 -0
- package/dist/destinations/m3ter/constants.js +8 -0
- package/dist/destinations/m3ter/constants.js.map +1 -0
- package/dist/destinations/m3ter/generated-types.d.ts +5 -0
- package/dist/destinations/m3ter/generated-types.js +3 -0
- package/dist/destinations/m3ter/generated-types.js.map +1 -0
- package/dist/destinations/m3ter/index.d.ts +4 -0
- package/dist/destinations/m3ter/index.js +68 -0
- package/dist/destinations/m3ter/index.js.map +1 -0
- package/dist/destinations/m3ter/submitMeasurements/generated-types.d.ts +32 -0
- package/dist/destinations/m3ter/submitMeasurements/generated-types.js +3 -0
- package/dist/destinations/m3ter/submitMeasurements/generated-types.js.map +1 -0
- package/dist/destinations/m3ter/submitMeasurements/index.d.ts +5 -0
- package/dist/destinations/m3ter/submitMeasurements/index.js +116 -0
- package/dist/destinations/m3ter/submitMeasurements/index.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/destinations/app-fit/config.ts"],"names":[],"mappings":";;AAAA,MAAqB,YAAY;;AAAjC,+BAEC;AADQ,mBAAM,GAAG,uBAAuB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../src/destinations/app-fit/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const config_1 = __importDefault(require("./config"));
|
|
7
|
+
const track_1 = __importDefault(require("./track"));
|
|
8
|
+
const destination = {
|
|
9
|
+
name: 'App Fit',
|
|
10
|
+
slug: 'actions-app-fit',
|
|
11
|
+
mode: 'cloud',
|
|
12
|
+
authentication: {
|
|
13
|
+
scheme: 'custom',
|
|
14
|
+
fields: {
|
|
15
|
+
apiKey: {
|
|
16
|
+
label: 'API Key',
|
|
17
|
+
description: 'AppFit project API key. ',
|
|
18
|
+
type: 'string',
|
|
19
|
+
required: true
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
testAuthentication: (request, { settings }) => {
|
|
23
|
+
return request(`${config_1.default.apiUrl}/api-key/current`, {
|
|
24
|
+
headers: { Authorization: `Bearer ${settings.apiKey}` }
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
onDelete: async (request, { settings, payload }) => {
|
|
29
|
+
return request(`${config_1.default.apiUrl}/metric-event-users/${payload.userId}?source=segment_destination`, {
|
|
30
|
+
headers: { Authorization: `Bearer ${settings.apiKey}` },
|
|
31
|
+
method: 'DELETE'
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
actions: {
|
|
35
|
+
track: track_1.default
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
exports.default = destination;
|
|
39
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/app-fit/index.ts"],"names":[],"mappings":";;;;;AAGA,sDAAmC;AACnC,oDAA2B;AAE3B,MAAM,WAAW,GAAoC;IACnD,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,iBAAiB;IACvB,IAAI,EAAE,OAAO;IAEb,cAAc,EAAE;QACd,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE;YACN,MAAM,EAAE;gBACN,KAAK,EAAE,SAAS;gBAChB,WAAW,EAAE,0BAA0B;gBACvC,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,IAAI;aACf;SACF;QACD,kBAAkB,EAAE,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;YAC5C,OAAO,OAAO,CAAC,GAAG,gBAAY,CAAC,MAAM,kBAAkB,EAAE;gBACvD,OAAO,EAAE,EAAE,aAAa,EAAE,UAAU,QAAQ,CAAC,MAAM,EAAE,EAAE;aACxD,CAAC,CAAA;QACJ,CAAC;KACF;IAED,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE;QAIjD,OAAO,OAAO,CAAC,GAAG,gBAAY,CAAC,MAAM,uBAAuB,OAAO,CAAC,MAAM,6BAA6B,EAAE;YACvG,OAAO,EAAE,EAAE,aAAa,EAAE,UAAU,QAAQ,CAAC,MAAM,EAAE,EAAE;YACvD,MAAM,EAAE,QAAQ;SACjB,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,EAAE;QACP,KAAK,EAAL,eAAK;KACN;CACF,CAAA;AAED,kBAAe,WAAW,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/app-fit/track/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const config_1 = __importDefault(require("../config"));
|
|
7
|
+
const action = {
|
|
8
|
+
title: 'Track',
|
|
9
|
+
description: 'Send an event to AppFit.',
|
|
10
|
+
fields: {
|
|
11
|
+
userId: {
|
|
12
|
+
label: 'External User ID',
|
|
13
|
+
description: 'The unique user identifier',
|
|
14
|
+
type: 'string',
|
|
15
|
+
default: {
|
|
16
|
+
'@path': '$.userId'
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
occurredAt: {
|
|
20
|
+
label: 'Time',
|
|
21
|
+
description: 'When the event occurred.',
|
|
22
|
+
type: 'datetime',
|
|
23
|
+
required: true,
|
|
24
|
+
default: {
|
|
25
|
+
'@path': '$.timestamp'
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
name: {
|
|
29
|
+
label: 'Event Name',
|
|
30
|
+
description: 'The event name',
|
|
31
|
+
type: 'string',
|
|
32
|
+
required: true,
|
|
33
|
+
default: {
|
|
34
|
+
'@path': '$.event'
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
anonymousId: {
|
|
38
|
+
label: 'Anonymous ID',
|
|
39
|
+
description: 'The anonymous ID of the user',
|
|
40
|
+
type: 'string',
|
|
41
|
+
default: {
|
|
42
|
+
'@path': '$.anonymousId'
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
properties: {
|
|
46
|
+
label: 'Event Properties',
|
|
47
|
+
description: 'Properties of the event',
|
|
48
|
+
type: 'object',
|
|
49
|
+
default: {
|
|
50
|
+
'@path': '$.properties'
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
deviceId: {
|
|
54
|
+
label: 'Device ID',
|
|
55
|
+
description: 'The device ID of the user',
|
|
56
|
+
type: 'string',
|
|
57
|
+
default: {
|
|
58
|
+
'@path': '$.context.device.id'
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
deviceType: {
|
|
62
|
+
label: 'Device Type',
|
|
63
|
+
description: 'The device type',
|
|
64
|
+
type: 'string',
|
|
65
|
+
default: {
|
|
66
|
+
'@path': '$.context.device.type'
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
osName: {
|
|
70
|
+
label: 'OS Name',
|
|
71
|
+
description: 'The name of the operating system',
|
|
72
|
+
type: 'string',
|
|
73
|
+
default: {
|
|
74
|
+
'@path': '$.context.os.name'
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
eventId: {
|
|
78
|
+
label: 'Event ID',
|
|
79
|
+
description: 'The event ID',
|
|
80
|
+
type: 'string',
|
|
81
|
+
required: true,
|
|
82
|
+
default: {
|
|
83
|
+
'@path': '$.messageId'
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
perform: (request, { payload, settings }) => {
|
|
88
|
+
return request(`${config_1.default.apiUrl}/metric-events`, {
|
|
89
|
+
method: 'POST',
|
|
90
|
+
headers: { Authorization: `Bearer ${settings.apiKey}` },
|
|
91
|
+
json: {
|
|
92
|
+
eventSource: 'segment',
|
|
93
|
+
occurredAt: payload.occurredAt,
|
|
94
|
+
payload: {
|
|
95
|
+
eventId: payload.eventId,
|
|
96
|
+
userId: payload.userId,
|
|
97
|
+
anonymousId: payload.anonymousId,
|
|
98
|
+
name: payload.name,
|
|
99
|
+
properties: payload.properties,
|
|
100
|
+
deviceId: payload.deviceId,
|
|
101
|
+
deviceType: payload.deviceType,
|
|
102
|
+
osName: payload.osName
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
exports.default = action;
|
|
109
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/app-fit/track/index.ts"],"names":[],"mappings":";;;;;AACA,uDAAoC;AAIpC,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,OAAO;IACd,WAAW,EAAE,0BAA0B;IACvC,MAAM,EAAE;QACN,MAAM,EAAE;YACN,KAAK,EAAE,kBAAkB;YACzB,WAAW,EAAE,4BAA4B;YACzC,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,OAAO,EAAE,UAAU;aACpB;SACF;QACD,UAAU,EAAE;YACV,KAAK,EAAE,MAAM;YACb,WAAW,EAAE,0BAA0B;YACvC,IAAI,EAAE,UAAU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C1C,OAAO,OAAO,CAAC,GAAG,gBAAY,CAAC,MAAM,gBAAgB,EAAE;YACrD,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,EAAE,aAAa,EAAE,UAAU,QAAQ,CAAC,MAAM,EAAE,EAAE;YAEvD,IAAI,EAAE;gBACJ,WAAW,EAAE,SAAS;gBACtB,UAAU,EAAE,OAAO,CAAC,UAAU;gBAC9B,OAAO,EAAE;oBACP,OAAO,EAAE,OAAO,CAAC,OAAO;oBACxB,MAAM,EAAE,OAAO,CAAC,MAAM;oBACtB,WAAW,EAAE,OAAO,CAAC,WAAW;oBAChC,IAAI,EAAE,OAAO,CAAC,IAAI;oBAClB,UAAU,EAAE,OAAO,CAAC,UAAU;oBAC9B,QAAQ,EAAE,OAAO,CAAC,QAAQ;oBAC1B,UAAU,EAAE,OAAO,CAAC,UAAU;oBAC9B,MAAM,EAAE,OAAO,CAAC,MAAM;iBACvB;aACF;SACF,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
package/dist/destinations/engage-messaging-twilio/operationTracking/GenericMethodDecorator.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare type GenericMethodDecorator<TFunc extends (this: any, ...args: any[]) => any = (this: any, ...args: any) => any> = (target: ThisParameterType<TFunc>, propertyKey: string, descriptor: TypedPropertyDescriptor<TFunc>) => TypedPropertyDescriptor<TFunc> | void;
|
package/dist/destinations/engage-messaging-twilio/operationTracking/GenericMethodDecorator.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GenericMethodDecorator.js","sourceRoot":"","sources":["../../../../src/destinations/engage-messaging-twilio/operationTracking/GenericMethodDecorator.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { GenericMethodDecorator } from './GenericMethodDecorator';
|
|
2
|
+
import { OperationDuration } from './OperationDuration';
|
|
3
|
+
import { OperationErrorHandler } from './OperationErrorHandler';
|
|
4
|
+
import { OperationFinallyHooks } from './OperationFinallyHooks';
|
|
5
|
+
import { OperationTree } from './OperationTree';
|
|
6
|
+
import { FuncFromTryCatchFinallyContext, TryCatchFinallyContext, TryCatchFinallyHook } from './wrapTryCatchFinallyPromisable';
|
|
7
|
+
export interface DecoratorArgs {
|
|
8
|
+
operation?: string;
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
}
|
|
11
|
+
export declare type OperationHookContext<TContext extends TryCatchFinallyContext = TryCatchFinallyContext, TDecoratorArgs extends DecoratorArgs = DecoratorArgs> = TContext & {
|
|
12
|
+
decoratorArgs?: TDecoratorArgs;
|
|
13
|
+
};
|
|
14
|
+
export interface OperationHookProvider<TContext extends OperationHookContext = OperationHookContext, TDecoratorUtils = {}> {
|
|
15
|
+
getTryCatchFinallyHook(ctx: TContext): TryCatchFinallyHook<TContext>;
|
|
16
|
+
getDecoratorUtils?(): TDecoratorUtils;
|
|
17
|
+
}
|
|
18
|
+
export declare type UnionToIntersection<TUnion> = (TUnion extends any ? (k: TUnion) => void : never) extends (k: infer I) => void ? I : never;
|
|
19
|
+
export declare type ContextFromHookProviders<TProviders extends OperationHookProvider[]> = TProviders extends OperationHookProvider<infer TContext>[] ? UnionToIntersection<TContext> : TryCatchFinallyContext;
|
|
20
|
+
export declare type DecoratorArgsFromContext<TContext extends TryCatchFinallyContext> = TContext extends {
|
|
21
|
+
decoratorArgs?: infer TDecoratorArgs;
|
|
22
|
+
} ? TDecoratorArgs : DecoratorArgs;
|
|
23
|
+
export declare type DecoratorArgsFromHookProviders<TProviders extends OperationHookProvider[]> = DecoratorArgsFromContext<ContextFromHookProviders<TProviders>>;
|
|
24
|
+
export declare type DecoratorUtilsFromHookProviders<TProviders extends OperationHookProvider[]> = TProviders extends OperationHookProvider<any, infer TDecoratorUtils>[] ? UnionToIntersection<TDecoratorUtils> : {};
|
|
25
|
+
export declare type FuncFromHookProviders<TProviders extends OperationHookProvider[]> = FuncFromTryCatchFinallyContext<ContextFromHookProviders<TProviders>>;
|
|
26
|
+
export declare class OperationDecorator {
|
|
27
|
+
static createDecoratorFactory<TOperationHookProviders extends OperationHookProvider[]>(...hookProviders: TOperationHookProviders): ((decoratorArgs?: DecoratorArgsFromHookProviders<TOperationHookProviders>) => GenericMethodDecorator<FuncFromHookProviders<TOperationHookProviders>>) & DecoratorUtilsFromHookProviders<TOperationHookProviders> & {
|
|
28
|
+
_contextType: ContextFromHookProviders<TOperationHookProviders>;
|
|
29
|
+
};
|
|
30
|
+
static createDecoratorFactoryWithDefault<TOperationHookProviders extends OperationHookProvider[]>(...customHookProviders: TOperationHookProviders): ((decoratorArgs?: DecoratorArgsFromContext<ContextFromHookProviders<[typeof OperationErrorHandler, typeof OperationTree, typeof OperationDuration, typeof OperationFinallyHooks, ...TOperationHookProviders]>> | undefined) => GenericMethodDecorator<FuncFromTryCatchFinallyContext<ContextFromHookProviders<[typeof OperationErrorHandler, typeof OperationTree, typeof OperationDuration, typeof OperationFinallyHooks, ...TOperationHookProviders]>>>) & DecoratorUtilsFromHookProviders<[typeof OperationErrorHandler, typeof OperationTree, typeof OperationDuration, typeof OperationFinallyHooks, ...TOperationHookProviders]> & {
|
|
31
|
+
_contextType: ContextFromHookProviders<[typeof OperationErrorHandler, typeof OperationTree, typeof OperationDuration, typeof OperationFinallyHooks, ...TOperationHookProviders]>;
|
|
32
|
+
};
|
|
33
|
+
static getOperationName<TContext extends TryCatchFinallyContext>(ctx: TContext): string | undefined;
|
|
34
|
+
}
|
|
35
|
+
export declare type OperationDecoratorContext<TContext extends TryCatchFinallyContext = TryCatchFinallyContext> = TContext & {
|
|
36
|
+
decoratorOf?: {
|
|
37
|
+
classProto: any;
|
|
38
|
+
methodName: string;
|
|
39
|
+
descriptor: TypedPropertyDescriptor<any>;
|
|
40
|
+
originalMethod: FuncFromTryCatchFinallyContext<TContext>;
|
|
41
|
+
};
|
|
42
|
+
decoratorArgs?: DecoratorArgsFromContext<TContext> & DecoratorArgs;
|
|
43
|
+
};
|
|
44
|
+
export declare type ContextFromDecorator<TDecorator> = TDecorator extends {
|
|
45
|
+
_contextType: infer TContext;
|
|
46
|
+
} ? TContext : never;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OperationDecorator = void 0;
|
|
4
|
+
const OperationDuration_1 = require("./OperationDuration");
|
|
5
|
+
const OperationErrorHandler_1 = require("./OperationErrorHandler");
|
|
6
|
+
const OperationFinallyHooks_1 = require("./OperationFinallyHooks");
|
|
7
|
+
const OperationTree_1 = require("./OperationTree");
|
|
8
|
+
const wrapTryCatchFinallyPromisable_1 = require("./wrapTryCatchFinallyPromisable");
|
|
9
|
+
class OperationDecorator {
|
|
10
|
+
static createDecoratorFactory(...hookProviders) {
|
|
11
|
+
const decorator = (decoratorArgs) => {
|
|
12
|
+
return function (classProto, methodName, descriptor) {
|
|
13
|
+
const originalMethod = descriptor.value;
|
|
14
|
+
if (!(originalMethod instanceof Function))
|
|
15
|
+
throw new Error('Track decorator can only be applied to class methods');
|
|
16
|
+
const decoratorOf = {
|
|
17
|
+
classProto,
|
|
18
|
+
methodName,
|
|
19
|
+
descriptor,
|
|
20
|
+
originalMethod
|
|
21
|
+
};
|
|
22
|
+
descriptor.value = wrapTryCatchFinallyPromisable_1.wrapTryCatchFinallyPromisable(originalMethod, (ctx) => {
|
|
23
|
+
ctx.decoratorOf = decoratorOf;
|
|
24
|
+
ctx.decoratorArgs = decoratorArgs;
|
|
25
|
+
return hookProviders.map((h) => h.getTryCatchFinallyHook(ctx));
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
const decoratorUtils = {};
|
|
30
|
+
for (const hookProvider of hookProviders) {
|
|
31
|
+
Object.assign(decoratorUtils, hookProvider.getDecoratorUtils?.() || {});
|
|
32
|
+
}
|
|
33
|
+
return Object.assign(decorator, decoratorUtils);
|
|
34
|
+
}
|
|
35
|
+
static createDecoratorFactoryWithDefault(...customHookProviders) {
|
|
36
|
+
return OperationDecorator.createDecoratorFactory(OperationErrorHandler_1.OperationErrorHandler, OperationTree_1.OperationTree, OperationDuration_1.OperationDuration, OperationFinallyHooks_1.OperationFinallyHooks, ...customHookProviders);
|
|
37
|
+
}
|
|
38
|
+
static getOperationName(ctx) {
|
|
39
|
+
const ctxDecorated = ctx;
|
|
40
|
+
return (ctxDecorated.decoratorArgs?.operation ||
|
|
41
|
+
ctxDecorated.decoratorOf?.methodName ||
|
|
42
|
+
ctxDecorated.decoratorOf?.originalMethod?.name);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.OperationDecorator = OperationDecorator;
|
|
46
|
+
//# sourceMappingURL=OperationDecorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OperationDecorator.js","sourceRoot":"","sources":["../../../../src/destinations/engage-messaging-twilio/operationTracking/OperationDecorator.ts"],"names":[],"mappings":";;;AAEA,2DAAuD;AACvD,mEAA+D;AAC/D,mEAA+D;AAC/D,mDAA+C;AAC/C,mFAKwC;AAmFxC,MAAa,kBAAkB;IAO7B,MAAM,CAAC,sBAAsB,CAC3B,GAAG,aAAsC;QAUzC,MAAM,SAAS,GAAG,CAAC,aAA8B,EAAiC,EAAE;YAClF,OAAO,UAAU,UAAU,EAAE,UAAU,EAAE,UAAU;gBACjD,MAAM,cAAc,GAAG,UAAU,CAAC,KAAc,CAAA;gBAChD,IAAI,CAAC,CAAC,cAAc,YAAY,QAAQ,CAAC;oBACvC,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAA;gBAEzE,MAAM,WAAW,GAA6C;oBAC5D,UAAU;oBACV,UAAU;oBACV,UAAU;oBACV,cAAc;iBACf,CAAA;gBACD,UAAU,CAAC,KAAK,GAAG,6DAA6B,CAAC,cAAc,EAAE,CAAC,GAA8B,EAAE,EAAE;oBAClG,GAAG,CAAC,WAAW,GAAG,WAAW,CAAA;oBAC7B,GAAG,CAAC,aAAa,GAAG,aAAa,CAAA;oBACjC,OAAO,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC,CAAA;gBAChE,CAAC,CAAC,CAAA;YACJ,CAAC,CAAA;QACH,CAAC,CAAA;QACD,MAAM,cAAc,GAAG,EAAE,CAAA;QACzB,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE;YACxC,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,YAAY,CAAC,iBAAiB,EAAE,EAAE,IAAI,EAAE,CAAC,CAAA;SACxE;QAED,OAAO,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,cAAc,CAAQ,CAAA;IACxD,CAAC;IAWD,MAAM,CAAC,iCAAiC,CACtC,GAAG,mBAA4C;QAE/C,OAAO,kBAAkB,CAAC,sBAAsB,CAC9C,6CAAqB,EACrB,6BAAa,EACb,qCAAiB,EACjB,6CAAqB,EACrB,GAAG,mBAAmB,CACvB,CAAA;IACH,CAAC;IAED,MAAM,CAAC,gBAAgB,CAA0C,GAAa;QAC5E,MAAM,YAAY,GAAG,GAAgC,CAAA;QACrD,OAAO,CACL,YAAY,CAAC,aAAa,EAAE,SAAS;YACrC,YAAY,CAAC,WAAW,EAAE,UAAU;YACpC,YAAY,CAAC,WAAW,EAAE,cAAc,EAAE,IAAI,CAC/C,CAAA;IACH,CAAC;CACF;AA1ED,gDA0EC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TryCatchFinallyContext, TryCatchFinallyHook } from './wrapTryCatchFinallyPromisable';
|
|
2
|
+
export declare type OperationDurationContext<TContext extends TryCatchFinallyContext = TryCatchFinallyContext> = TContext & {
|
|
3
|
+
start?: number;
|
|
4
|
+
duration?: number;
|
|
5
|
+
};
|
|
6
|
+
export declare class OperationDuration {
|
|
7
|
+
static getTryCatchFinallyHook(_ctx: OperationDurationContext): TryCatchFinallyHook<OperationDurationContext>;
|
|
8
|
+
static getPriority(): number;
|
|
9
|
+
static onTry(ctx: OperationDurationContext): void;
|
|
10
|
+
static onFinally(ctx: OperationDurationContext): void;
|
|
11
|
+
static getDuration<TContext extends OperationDurationContext>(ctx: TContext): number | undefined;
|
|
12
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OperationDuration = void 0;
|
|
4
|
+
class OperationDuration {
|
|
5
|
+
static getTryCatchFinallyHook(_ctx) {
|
|
6
|
+
return this;
|
|
7
|
+
}
|
|
8
|
+
static getPriority() {
|
|
9
|
+
return -1000;
|
|
10
|
+
}
|
|
11
|
+
static onTry(ctx) {
|
|
12
|
+
ctx.start = Date.now();
|
|
13
|
+
}
|
|
14
|
+
static onFinally(ctx) {
|
|
15
|
+
if (ctx.start !== undefined)
|
|
16
|
+
ctx.duration = Date.now() - ctx.start;
|
|
17
|
+
}
|
|
18
|
+
static getDuration(ctx) {
|
|
19
|
+
return ctx.duration;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.OperationDuration = OperationDuration;
|
|
23
|
+
//# sourceMappingURL=OperationDuration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OperationDuration.js","sourceRoot":"","sources":["../../../../src/destinations/engage-messaging-twilio/operationTracking/OperationDuration.ts"],"names":[],"mappings":";;;AAOA,MAAa,iBAAiB;IAC5B,MAAM,CAAC,sBAAsB,CAAC,IAA8B;QAC1D,OAAO,IAAI,CAAA;IACb,CAAC;IACD,MAAM,CAAC,WAAW;QAChB,OAAO,CAAC,IAAI,CAAA;IACd,CAAC;IACD,MAAM,CAAC,KAAK,CAAC,GAA6B;QACxC,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;IACxB,CAAC;IAED,MAAM,CAAC,SAAS,CAAC,GAA6B;QAC5C,IAAI,GAAG,CAAC,KAAK,KAAK,SAAS;YAAE,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC,KAAK,CAAA;IACpE,CAAC;IACD,MAAM,CAAC,WAAW,CAA4C,GAAa;QACzE,OAAO,GAAG,CAAC,QAAQ,CAAA;IACrB,CAAC;CACF;AAjBD,8CAiBC"}
|
package/dist/destinations/engage-messaging-twilio/operationTracking/OperationErrorHandler.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TrackedError } from './TrackedError';
|
|
2
|
+
import { TryCatchFinallyContext, TryCatchFinallyHook } from './wrapTryCatchFinallyPromisable';
|
|
3
|
+
export declare type OperationErrorHandlerContext<TContext extends TryCatchFinallyContext = TryCatchFinallyContext> = TContext & {
|
|
4
|
+
decoratorArgs?: {
|
|
5
|
+
onError?: (ctx: OperationErrorHandlerContext<TContext>) => void;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export declare class OperationErrorHandler {
|
|
9
|
+
static getTryCatchFinallyHook(_ctx: OperationErrorHandlerContext): TryCatchFinallyHook<OperationErrorHandlerContext>;
|
|
10
|
+
static onCatch(ctx: OperationErrorHandlerContext): void;
|
|
11
|
+
static wrap<TContext extends OperationErrorHandlerContext = OperationErrorHandlerContext>(originalError: unknown, getWrapper: (e: unknown) => unknown | undefined, ctx?: TContext): TrackedError<TryCatchFinallyContext<(this: any, ...args: any[]) => any>> | undefined;
|
|
12
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OperationErrorHandler = void 0;
|
|
4
|
+
class OperationErrorHandler {
|
|
5
|
+
static getTryCatchFinallyHook(_ctx) {
|
|
6
|
+
return this;
|
|
7
|
+
}
|
|
8
|
+
static onCatch(ctx) {
|
|
9
|
+
const dArgs = ctx.decoratorArgs;
|
|
10
|
+
ctx.error = this.wrap(ctx.error, () => {
|
|
11
|
+
dArgs?.onError?.apply(this, [ctx]);
|
|
12
|
+
return ctx.error;
|
|
13
|
+
}, ctx);
|
|
14
|
+
}
|
|
15
|
+
static wrap(originalError, getWrapper, ctx) {
|
|
16
|
+
const wrapper = getWrapper(originalError);
|
|
17
|
+
if (wrapper && originalError !== wrapper)
|
|
18
|
+
wrapper.underlyingError = originalError;
|
|
19
|
+
const trackedError = wrapper;
|
|
20
|
+
if (!trackedError)
|
|
21
|
+
return;
|
|
22
|
+
if (!ctx)
|
|
23
|
+
return;
|
|
24
|
+
if (!trackedError.trackedContext)
|
|
25
|
+
trackedError.trackedContext = ctx;
|
|
26
|
+
const trackedContextProp = Object.getOwnPropertyDescriptor(trackedError, 'trackedContext');
|
|
27
|
+
if (trackedContextProp?.enumerable) {
|
|
28
|
+
trackedContextProp.enumerable = false;
|
|
29
|
+
Object.defineProperty(trackedError, 'trackedContext', trackedContextProp);
|
|
30
|
+
}
|
|
31
|
+
return wrapper;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.OperationErrorHandler = OperationErrorHandler;
|
|
35
|
+
//# sourceMappingURL=OperationErrorHandler.js.map
|
package/dist/destinations/engage-messaging-twilio/operationTracking/OperationErrorHandler.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OperationErrorHandler.js","sourceRoot":"","sources":["../../../../src/destinations/engage-messaging-twilio/operationTracking/OperationErrorHandler.ts"],"names":[],"mappings":";;;AAaA,MAAa,qBAAqB;IAChC,MAAM,CAAC,sBAAsB,CAAC,IAAkC;QAC9D,OAAO,IAAI,CAAA;IACb,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,GAAiC;QAC9C,MAAM,KAAK,GAAG,GAAG,CAAC,aAAa,CAAA;QAG/B,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CACnB,GAAG,CAAC,KAAK,EACT,GAAG,EAAE;YAEH,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAA;YAClC,OAAO,GAAG,CAAC,KAAqB,CAAA;QAClC,CAAC,EACD,GAAG,CACJ,CAAA;IACH,CAAC;IAED,MAAM,CAAC,IAAI,CACT,aAAsB,EACtB,UAA+C,EAC/C,GAAc;QAEd,MAAM,OAAO,GAAG,UAAU,CAAC,aAAa,CAAiB,CAAA;QAEzD,IAAI,OAAO,IAAI,aAAa,KAAK,OAAO;YAAE,OAAO,CAAC,eAAe,GAAG,aAAa,CAAA;QAEjF,MAAM,YAAY,GAAG,OAAO,CAAA;QAC5B,IAAI,CAAC,YAAY;YAAE,OAAM;QAEzB,IAAI,CAAC,GAAG;YAAE,OAAM;QAGhB,IAAI,CAAC,YAAY,CAAC,cAAc;YAAE,YAAY,CAAC,cAAc,GAAG,GAAG,CAAA;QAGnE,MAAM,kBAAkB,GAAG,MAAM,CAAC,wBAAwB,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAA;QAC1F,IAAI,kBAAkB,EAAE,UAAU,EAAE;YAElC,kBAAkB,CAAC,UAAU,GAAG,KAAK,CAAA;YACrC,MAAM,CAAC,cAAc,CAAC,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,CAAC,CAAA;SAC1E;QAED,OAAO,OAAO,CAAA;IAChB,CAAC;CACF;AA/CD,sDA+CC"}
|
package/dist/destinations/engage-messaging-twilio/operationTracking/OperationFinallyHooks.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TryCatchFinallyContext, TryCatchFinallyHook } from './wrapTryCatchFinallyPromisable';
|
|
2
|
+
export declare type OperationFinallyHooksContext<TContext extends TryCatchFinallyContext = TryCatchFinallyContext> = TContext & {
|
|
3
|
+
onFinally: (() => void)[];
|
|
4
|
+
};
|
|
5
|
+
export declare class OperationFinallyHooks {
|
|
6
|
+
static getTryCatchFinallyHook(_ctx: OperationFinallyHooksContext): TryCatchFinallyHook<OperationFinallyHooksContext>;
|
|
7
|
+
static getPriority(): number;
|
|
8
|
+
static onTry<TContext extends TryCatchFinallyContext>(ctx: OperationFinallyHooksContext<TContext>): void;
|
|
9
|
+
static onFinally<TContext extends TryCatchFinallyContext>(ctx: OperationFinallyHooksContext<TContext>): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OperationFinallyHooks = void 0;
|
|
4
|
+
class OperationFinallyHooks {
|
|
5
|
+
static getTryCatchFinallyHook(_ctx) {
|
|
6
|
+
return this;
|
|
7
|
+
}
|
|
8
|
+
static getPriority() {
|
|
9
|
+
return 100;
|
|
10
|
+
}
|
|
11
|
+
static onTry(ctx) {
|
|
12
|
+
ctx.onFinally = [];
|
|
13
|
+
}
|
|
14
|
+
static onFinally(ctx) {
|
|
15
|
+
for (const hook of ctx.onFinally) {
|
|
16
|
+
try {
|
|
17
|
+
hook();
|
|
18
|
+
}
|
|
19
|
+
catch (e) {
|
|
20
|
+
const error = e;
|
|
21
|
+
const loggerCtx = ctx;
|
|
22
|
+
if (loggerCtx.logs)
|
|
23
|
+
loggerCtx.logs.push(`Error in onFinally hook: ${error?.message || error.toString()}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.OperationFinallyHooks = OperationFinallyHooks;
|
|
29
|
+
//# sourceMappingURL=OperationFinallyHooks.js.map
|
package/dist/destinations/engage-messaging-twilio/operationTracking/OperationFinallyHooks.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OperationFinallyHooks.js","sourceRoot":"","sources":["../../../../src/destinations/engage-messaging-twilio/operationTracking/OperationFinallyHooks.ts"],"names":[],"mappings":";;;AAWA,MAAa,qBAAqB;IAChC,MAAM,CAAC,sBAAsB,CAAC,IAAkC;QAC9D,OAAO,IAAI,CAAA;IACb,CAAC;IACD,MAAM,CAAC,WAAW;QAChB,OAAO,GAAG,CAAA;IACZ,CAAC;IAED,MAAM,CAAC,KAAK,CAA0C,GAA2C;QAC/F,GAAG,CAAC,SAAS,GAAG,EAAE,CAAA;IACpB,CAAC;IAED,MAAM,CAAC,SAAS,CAA0C,GAA2C;QACnG,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,SAAS,EAAE;YAChC,IAAI;gBACF,IAAI,EAAE,CAAA;aACP;YAAC,OAAO,CAAC,EAAE;gBACV,MAAM,KAAK,GAAG,CAAU,CAAA;gBAExB,MAAM,SAAS,GAAG,GAAsC,CAAA;gBACxD,IAAI,SAAS,CAAC,IAAI;oBAAE,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,4BAA4B,KAAK,EAAE,OAAO,IAAI,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;aAC1G;SACF;IACH,CAAC;CACF;AAxBD,sDAwBC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { TryCatchFinallyContext, TryCatchFinallyHook } from './wrapTryCatchFinallyPromisable';
|
|
2
|
+
import { TrackedError } from './TrackedError';
|
|
3
|
+
import { OperationDecoratorContext } from './OperationDecorator';
|
|
4
|
+
export declare type OperationLoggerContext<TContext extends TryCatchFinallyContext = TryCatchFinallyContext> = TContext & {
|
|
5
|
+
logs: string[];
|
|
6
|
+
logMetadata?: Record<string, unknown>;
|
|
7
|
+
decoratorArgs?: OperationLoggerDecoratorArgs;
|
|
8
|
+
sharedContext: OperationLoggerSharedContext;
|
|
9
|
+
};
|
|
10
|
+
export interface OperationLoggerSharedContext {
|
|
11
|
+
logs: string[];
|
|
12
|
+
logMetadata?: Record<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
export interface OperationLoggerDecoratorArgs {
|
|
15
|
+
shouldLog?: (ctx: OperationLoggerContext) => boolean | void;
|
|
16
|
+
}
|
|
17
|
+
export declare abstract class OperationLogger implements TryCatchFinallyHook<OperationLoggerContext> {
|
|
18
|
+
static getTryCatchFinallyHook(_ctx: OperationLoggerContext): TryCatchFinallyHook<OperationLoggerContext>;
|
|
19
|
+
abstract logInfo(msg: string, metadata?: object): void;
|
|
20
|
+
abstract logError(msg: string, metadata?: object): void;
|
|
21
|
+
onTry(ctx: OperationLoggerContext): () => void;
|
|
22
|
+
shouldLogDefault(_ctx: OperationLoggerContext): boolean;
|
|
23
|
+
getOperationLogMessages(ctx: OperationLoggerContext): string[];
|
|
24
|
+
getOperationTryMessage(ctx: OperationLoggerContext): string;
|
|
25
|
+
getOperationName<TContext extends OperationDecoratorContext>(ctx: TContext, fullPath?: boolean, separator?: string): string;
|
|
26
|
+
getOperationCompletedMessage(ctx: OperationLoggerContext): string;
|
|
27
|
+
getOperationErrorDetails(error: TrackedError, ctx: OperationLoggerContext): string[];
|
|
28
|
+
getErrorMessage(error: unknown, _ctx?: OperationLoggerContext): string;
|
|
29
|
+
onFinally(ctx: OperationLoggerContext): () => void;
|
|
30
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OperationLogger = void 0;
|
|
4
|
+
const OperationTree_1 = require("./OperationTree");
|
|
5
|
+
const OperationDecorator_1 = require("./OperationDecorator");
|
|
6
|
+
class OperationLogger {
|
|
7
|
+
static getTryCatchFinallyHook(_ctx) {
|
|
8
|
+
throw new Error('OperationLogger.getTryCatchFinallyHook is abstract and must be implemented by derived class');
|
|
9
|
+
}
|
|
10
|
+
onTry(ctx) {
|
|
11
|
+
ctx.logs = [];
|
|
12
|
+
if (!ctx.sharedContext.logs)
|
|
13
|
+
ctx.sharedContext.logs = [];
|
|
14
|
+
return () => {
|
|
15
|
+
let shouldLog = ctx.decoratorArgs?.shouldLog?.(ctx);
|
|
16
|
+
if (shouldLog === undefined)
|
|
17
|
+
shouldLog = this.shouldLogDefault(ctx);
|
|
18
|
+
if (shouldLog) {
|
|
19
|
+
const fullLogMessage = this.getOperationLogMessages(ctx)?.join('. ');
|
|
20
|
+
this.logInfo(fullLogMessage, ctx.logMetadata || ctx.sharedContext.logMetadata
|
|
21
|
+
? { ...ctx.sharedContext.logMetadata, ...ctx.logMetadata }
|
|
22
|
+
: undefined);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
shouldLogDefault(_ctx) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
getOperationLogMessages(ctx) {
|
|
30
|
+
const res = [];
|
|
31
|
+
switch (ctx.stage) {
|
|
32
|
+
case 'try':
|
|
33
|
+
res.push(this.getOperationTryMessage(ctx));
|
|
34
|
+
break;
|
|
35
|
+
case 'finally':
|
|
36
|
+
res.push(this.getOperationCompletedMessage(ctx));
|
|
37
|
+
if (ctx.error) {
|
|
38
|
+
const error = ctx.error;
|
|
39
|
+
res.push(...(this.getOperationErrorDetails(error, ctx) || []));
|
|
40
|
+
}
|
|
41
|
+
break;
|
|
42
|
+
default:
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
return res;
|
|
46
|
+
}
|
|
47
|
+
getOperationTryMessage(ctx) {
|
|
48
|
+
return `${this.getOperationName(ctx)} starting...`;
|
|
49
|
+
}
|
|
50
|
+
getOperationName(ctx, fullPath = true, separator = ' > ') {
|
|
51
|
+
if (!fullPath)
|
|
52
|
+
return OperationDecorator_1.OperationDecorator.getOperationName(ctx) || '(anonymous)';
|
|
53
|
+
const fullOperationName = OperationTree_1.OperationTree.getOperationsStack(ctx)
|
|
54
|
+
.map((op) => this.getOperationName(op, false))
|
|
55
|
+
.join(separator);
|
|
56
|
+
return fullOperationName;
|
|
57
|
+
}
|
|
58
|
+
getOperationCompletedMessage(ctx) {
|
|
59
|
+
const hasError = !!ctx.error;
|
|
60
|
+
const fullOperationName = this.getOperationName(ctx);
|
|
61
|
+
const duration = ctx.duration;
|
|
62
|
+
if (duration !== undefined)
|
|
63
|
+
return `${fullOperationName} ${hasError ? 'failed' : 'succeeded'} after ${duration} ms`;
|
|
64
|
+
else
|
|
65
|
+
return `${fullOperationName} ${hasError ? 'failed' : 'succeeded'}`;
|
|
66
|
+
}
|
|
67
|
+
getOperationErrorDetails(error, ctx) {
|
|
68
|
+
const errorContext = error.trackedContext;
|
|
69
|
+
const logMessages = [];
|
|
70
|
+
logMessages.push(this.getErrorMessage(error, ctx));
|
|
71
|
+
if (errorContext == ctx && error.underlyingError) {
|
|
72
|
+
logMessages.push(`Underlying error: ${this.getErrorMessage(error.underlyingError, ctx)}`);
|
|
73
|
+
}
|
|
74
|
+
return logMessages;
|
|
75
|
+
}
|
|
76
|
+
getErrorMessage(error, _ctx) {
|
|
77
|
+
if (error instanceof Error) {
|
|
78
|
+
const trError = error;
|
|
79
|
+
const errorClass = trError?.constructor?.name;
|
|
80
|
+
return `${errorClass || '[undefined]'}: ${trError.message}`;
|
|
81
|
+
}
|
|
82
|
+
return error?.toString?.() || 'unknown error';
|
|
83
|
+
}
|
|
84
|
+
onFinally(ctx) {
|
|
85
|
+
ctx.logs.push(...(this.getOperationLogMessages(ctx) || []));
|
|
86
|
+
return () => {
|
|
87
|
+
let shouldLog = ctx.decoratorArgs?.shouldLog?.(ctx);
|
|
88
|
+
if (shouldLog === undefined)
|
|
89
|
+
shouldLog = this.shouldLogDefault(ctx);
|
|
90
|
+
if (shouldLog) {
|
|
91
|
+
const fullLogMessage = (ctx.sharedContext.logs?.filter((t) => t) || [])
|
|
92
|
+
.concat(...(ctx.logs || []))
|
|
93
|
+
.filter((t) => t)
|
|
94
|
+
.join('. ');
|
|
95
|
+
const logDetails = ctx.logMetadata || ctx.sharedContext.logMetadata
|
|
96
|
+
? { ...ctx.sharedContext.logMetadata, ...ctx.logMetadata }
|
|
97
|
+
: undefined;
|
|
98
|
+
if (ctx.error)
|
|
99
|
+
this.logError(fullLogMessage, { error: ctx.error, ...logDetails });
|
|
100
|
+
else
|
|
101
|
+
this.logInfo(fullLogMessage, logDetails);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
exports.OperationLogger = OperationLogger;
|
|
107
|
+
//# sourceMappingURL=OperationLogger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OperationLogger.js","sourceRoot":"","sources":["../../../../src/destinations/engage-messaging-twilio/operationTracking/OperationLogger.ts"],"names":[],"mappings":";;;AAGA,mDAA+C;AAC/C,6DAAoF;AAiCpF,MAAsB,eAAe;IACnC,MAAM,CAAC,sBAAsB,CAAC,IAA4B;QACxD,MAAM,IAAI,KAAK,CAAC,6FAA6F,CAAC,CAAA;IAChH,CAAC;IAMD,KAAK,CAAC,GAA2B;QAC/B,GAAG,CAAC,IAAI,GAAG,EAAE,CAAA;QACb,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI;YAAE,GAAG,CAAC,aAAa,CAAC,IAAI,GAAG,EAAE,CAAA;QACxD,OAAO,GAAG,EAAE;YACV,IAAI,SAAS,GAAG,GAAG,CAAC,aAAa,EAAE,SAAS,EAAE,CAAC,GAAG,CAAC,CAAA;YACnD,IAAI,SAAS,KAAK,SAAS;gBAAE,SAAS,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAA;YAEnE,IAAI,SAAS,EAAE;gBACb,MAAM,cAAc,GAAG,IAAI,CAAC,uBAAuB,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;gBACpE,IAAI,CAAC,OAAO,CACV,cAAc,EACd,GAAG,CAAC,WAAW,IAAI,GAAG,CAAC,aAAa,CAAC,WAAW;oBAC9C,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,aAAa,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,WAAW,EAAE;oBAC1D,CAAC,CAAC,SAAS,CACd,CAAA;aACF;QACH,CAAC,CAAA;IACH,CAAC;IAQD,gBAAgB,CAAC,IAA4B;QAC3C,OAAO,IAAI,CAAA;IACb,CAAC;IAMD,uBAAuB,CAAC,GAA2B;QACjD,MAAM,GAAG,GAAa,EAAE,CAAA;QACxB,QAAQ,GAAG,C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