@segment/action-destinations 3.127.3-staging.143 → 3.128.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.
Files changed (170) hide show
  1. package/dist/destinations/actable-predictive/index.js +1 -1
  2. package/dist/destinations/actable-predictive/index.js.map +1 -1
  3. package/dist/destinations/actable-predictive/sendCustomEvent/index.js +13 -13
  4. package/dist/destinations/actable-predictive/sendCustomEvent/index.js.map +1 -1
  5. package/dist/destinations/actable-predictive/sendEmailEvent/index.js +20 -20
  6. package/dist/destinations/actable-predictive/sendEmailEvent/index.js.map +1 -1
  7. package/dist/destinations/actable-predictive/sendTransactionEvent/index.js +28 -28
  8. package/dist/destinations/actable-predictive/sendTransactionEvent/index.js.map +1 -1
  9. package/dist/destinations/actable-predictive/sendWebEvent/index.js +25 -25
  10. package/dist/destinations/actable-predictive/sendWebEvent/index.js.map +1 -1
  11. package/dist/destinations/braze/trackEvent/generated-types.d.ts +1 -0
  12. package/dist/destinations/braze/trackEvent/index.js +11 -35
  13. package/dist/destinations/braze/trackEvent/index.js.map +1 -1
  14. package/dist/destinations/braze/trackPurchase/index.js +2 -43
  15. package/dist/destinations/braze/trackPurchase/index.js.map +1 -1
  16. package/dist/destinations/braze/utils.d.ts +6 -0
  17. package/dist/destinations/braze/utils.js +81 -0
  18. package/dist/destinations/braze/utils.js.map +1 -0
  19. package/dist/destinations/braze-cohorts/syncAudiences/index.js +3 -3
  20. package/dist/destinations/braze-cohorts/syncAudiences/index.js.map +1 -1
  21. package/dist/destinations/clevertap/userDelete/index.js +4 -4
  22. package/dist/destinations/clevertap/userDelete/index.js.map +1 -1
  23. package/dist/destinations/customerio/createUpdateObject/generated-types.d.ts +1 -1
  24. package/dist/destinations/customerio/createUpdateObject/index.js +5 -5
  25. package/dist/destinations/customerio/createUpdateObject/index.js.map +1 -1
  26. package/dist/destinations/customerio/createUpdatePerson/index.js +2 -2
  27. package/dist/destinations/customerio/createUpdatePerson/index.js.map +1 -1
  28. package/dist/destinations/engage-messaging-twilio/index.js +1 -3
  29. package/dist/destinations/engage-messaging-twilio/index.js.map +1 -1
  30. package/dist/destinations/engage-messaging-twilio/sendSms/index.js +104 -2
  31. package/dist/destinations/engage-messaging-twilio/sendSms/index.js.map +1 -1
  32. package/dist/destinations/google-enhanced-conversions/index.js +1 -1
  33. package/dist/destinations/google-enhanced-conversions/index.js.map +1 -1
  34. package/dist/destinations/heap/constants.d.ts +1 -1
  35. package/dist/destinations/heap/constants.js +2 -2
  36. package/dist/destinations/heap/constants.js.map +1 -1
  37. package/dist/destinations/heap/trackEvent/generated-types.d.ts +1 -1
  38. package/dist/destinations/heap/trackEvent/index.js +13 -10
  39. package/dist/destinations/heap/trackEvent/index.js.map +1 -1
  40. package/dist/destinations/index.js +1 -1
  41. package/dist/destinations/index.js.map +1 -1
  42. package/dist/destinations/mixpanel/index.js +1 -1
  43. package/dist/destinations/mixpanel/mixpanel-properties.js.map +1 -1
  44. package/dist/destinations/mixpanel/trackEvent/functions.js +1 -1
  45. package/dist/destinations/mixpanel/trackEvent/functions.js.map +1 -1
  46. package/dist/destinations/mixpanel/trackEvent/index.js.map +1 -1
  47. package/dist/destinations/mixpanel/trackPurchase/index.js.map +1 -1
  48. package/dist/destinations/mixpanel/utils.js +1 -1
  49. package/dist/destinations/mixpanel/utils.js.map +1 -1
  50. package/dist/destinations/pipedrive/createUpdateActivity/index.js +44 -17
  51. package/dist/destinations/pipedrive/createUpdateActivity/index.js.map +1 -1
  52. package/dist/destinations/pipedrive/createUpdateDeal/index.js +35 -11
  53. package/dist/destinations/pipedrive/createUpdateDeal/index.js.map +1 -1
  54. package/dist/destinations/pipedrive/createUpdateLead/generated-types.d.ts +3 -8
  55. package/dist/destinations/pipedrive/createUpdateLead/index.js +54 -27
  56. package/dist/destinations/pipedrive/createUpdateLead/index.js.map +1 -1
  57. package/dist/destinations/pipedrive/createUpdateNote/generated-types.d.ts +1 -1
  58. package/dist/destinations/pipedrive/createUpdateNote/index.js +22 -13
  59. package/dist/destinations/pipedrive/createUpdateNote/index.js.map +1 -1
  60. package/dist/destinations/pipedrive/createUpdateOrganization/index.js +8 -2
  61. package/dist/destinations/pipedrive/createUpdateOrganization/index.js.map +1 -1
  62. package/dist/destinations/pipedrive/createUpdatePerson/index.js +15 -3
  63. package/dist/destinations/pipedrive/createUpdatePerson/index.js.map +1 -1
  64. package/dist/destinations/pipedrive/index.d.ts +1 -1
  65. package/dist/destinations/pipedrive/index.js +22 -1
  66. package/dist/destinations/pipedrive/index.js.map +1 -1
  67. package/dist/destinations/pipedrive/pipedriveApi/leads.d.ts +5 -1
  68. package/dist/destinations/pipedrive/pipedriveApi/leads.js.map +1 -1
  69. package/dist/destinations/pipedrive/pipedriveApi/notes.d.ts +1 -1
  70. package/dist/destinations/pipedrive/pipedriveApi/pipedrive-client.d.ts +2 -1
  71. package/dist/destinations/pipedrive/pipedriveApi/pipedrive-client.js +7 -1
  72. package/dist/destinations/pipedrive/pipedriveApi/pipedrive-client.js.map +1 -1
  73. package/dist/destinations/salesforce/sf-properties.d.ts +0 -1
  74. package/dist/destinations/salesforce/sf-properties.js.map +1 -1
  75. package/dist/destinations/saleswings/api.d.ts +35 -0
  76. package/dist/destinations/saleswings/api.js +19 -0
  77. package/dist/destinations/saleswings/api.js.map +1 -0
  78. package/dist/destinations/saleswings/common.d.ts +5 -0
  79. package/dist/destinations/saleswings/common.js +37 -0
  80. package/dist/destinations/saleswings/common.js.map +1 -0
  81. package/dist/destinations/saleswings/converter.d.ts +12 -0
  82. package/dist/destinations/saleswings/converter.js +34 -0
  83. package/dist/destinations/saleswings/converter.js.map +1 -0
  84. package/dist/destinations/saleswings/fields.d.ts +12 -0
  85. package/dist/destinations/saleswings/fields.js +102 -0
  86. package/dist/destinations/saleswings/fields.js.map +1 -0
  87. package/dist/destinations/{google-sheets-partner → saleswings}/generated-types.d.ts +1 -0
  88. package/dist/destinations/{actions-bingads → saleswings}/generated-types.js +0 -0
  89. package/dist/destinations/saleswings/generated-types.js.map +1 -0
  90. package/dist/destinations/{actions-bingads → saleswings}/index.d.ts +1 -1
  91. package/dist/destinations/saleswings/index.js +67 -0
  92. package/dist/destinations/saleswings/index.js.map +1 -0
  93. package/dist/destinations/saleswings/submitIdentifyEvent/generated-types.d.ts +14 -0
  94. package/dist/destinations/{actions-bingads/offlineConversions → saleswings/submitIdentifyEvent}/generated-types.js +0 -0
  95. package/dist/destinations/saleswings/submitIdentifyEvent/generated-types.js.map +1 -0
  96. package/dist/destinations/{actions-bingads/offlineConversions → saleswings/submitIdentifyEvent}/index.d.ts +0 -0
  97. package/dist/destinations/saleswings/submitIdentifyEvent/index.js +39 -0
  98. package/dist/destinations/saleswings/submitIdentifyEvent/index.js.map +1 -0
  99. package/dist/destinations/saleswings/submitPageEvent/generated-types.d.ts +8 -0
  100. package/dist/destinations/{engage-messaging-twilio/sendWhatsApp → saleswings/submitPageEvent}/generated-types.js +0 -0
  101. package/dist/destinations/saleswings/submitPageEvent/generated-types.js.map +1 -0
  102. package/dist/destinations/{engage-messaging-twilio/sendWhatsApp → saleswings/submitPageEvent}/index.d.ts +0 -0
  103. package/dist/destinations/saleswings/submitPageEvent/index.js +35 -0
  104. package/dist/destinations/saleswings/submitPageEvent/index.js.map +1 -0
  105. package/dist/destinations/saleswings/submitScreenEvent/generated-types.d.ts +14 -0
  106. package/dist/destinations/{google-sheets-partner → saleswings/submitScreenEvent}/generated-types.js +0 -0
  107. package/dist/destinations/saleswings/submitScreenEvent/generated-types.js.map +1 -0
  108. package/dist/destinations/{google-sheets-partner/postSheet → saleswings/submitScreenEvent}/index.d.ts +1 -1
  109. package/dist/destinations/saleswings/submitScreenEvent/index.js +42 -0
  110. package/dist/destinations/saleswings/submitScreenEvent/index.js.map +1 -0
  111. package/dist/destinations/saleswings/submitTrackEvent/generated-types.d.ts +14 -0
  112. package/dist/destinations/{google-sheets-partner/postSheet → saleswings/submitTrackEvent}/generated-types.js +0 -0
  113. package/dist/destinations/saleswings/submitTrackEvent/generated-types.js.map +1 -0
  114. package/dist/destinations/saleswings/submitTrackEvent/index.d.ts +5 -0
  115. package/dist/destinations/saleswings/submitTrackEvent/index.js +42 -0
  116. package/dist/destinations/saleswings/submitTrackEvent/index.js.map +1 -0
  117. package/dist/destinations/saleswings/testing.d.ts +10 -0
  118. package/dist/destinations/saleswings/testing.js +55 -0
  119. package/dist/destinations/saleswings/testing.js.map +1 -0
  120. package/dist/destinations/segment/segment-properties.js +2 -1
  121. package/dist/destinations/segment/segment-properties.js.map +1 -1
  122. package/dist/destinations/segment/sendTrack/generated-types.d.ts +1 -1
  123. package/package.json +2 -4
  124. package/dist/destinations/actions-bingads/functions.d.ts +0 -0
  125. package/dist/destinations/actions-bingads/functions.js +0 -2
  126. package/dist/destinations/actions-bingads/functions.js.map +0 -1
  127. package/dist/destinations/actions-bingads/generated-types.d.ts +0 -10
  128. package/dist/destinations/actions-bingads/generated-types.js.map +0 -1
  129. package/dist/destinations/actions-bingads/index.js +0 -77
  130. package/dist/destinations/actions-bingads/index.js.map +0 -1
  131. package/dist/destinations/actions-bingads/offlineConversions/formatter.d.ts +0 -8
  132. package/dist/destinations/actions-bingads/offlineConversions/formatter.js +0 -33
  133. package/dist/destinations/actions-bingads/offlineConversions/formatter.js.map +0 -1
  134. package/dist/destinations/actions-bingads/offlineConversions/generated-types.d.ts +0 -7
  135. package/dist/destinations/actions-bingads/offlineConversions/generated-types.js.map +0 -1
  136. package/dist/destinations/actions-bingads/offlineConversions/index.js +0 -131
  137. package/dist/destinations/actions-bingads/offlineConversions/index.js.map +0 -1
  138. package/dist/destinations/braze-cohorts/cohortChanges.d.ts +0 -10
  139. package/dist/destinations/braze-cohorts/cohortChanges.js +0 -3
  140. package/dist/destinations/braze-cohorts/cohortChanges.js.map +0 -1
  141. package/dist/destinations/engage-messaging-twilio/sendSms/sms-sender.d.ts +0 -14
  142. package/dist/destinations/engage-messaging-twilio/sendSms/sms-sender.js +0 -65
  143. package/dist/destinations/engage-messaging-twilio/sendSms/sms-sender.js.map +0 -1
  144. package/dist/destinations/engage-messaging-twilio/sendWhatsApp/generated-types.d.ts +0 -23
  145. package/dist/destinations/engage-messaging-twilio/sendWhatsApp/generated-types.js.map +0 -1
  146. package/dist/destinations/engage-messaging-twilio/sendWhatsApp/index.js +0 -122
  147. package/dist/destinations/engage-messaging-twilio/sendWhatsApp/index.js.map +0 -1
  148. package/dist/destinations/engage-messaging-twilio/sendWhatsApp/whatsapp-sender.d.ts +0 -14
  149. package/dist/destinations/engage-messaging-twilio/sendWhatsApp/whatsapp-sender.js +0 -65
  150. package/dist/destinations/engage-messaging-twilio/sendWhatsApp/whatsapp-sender.js.map +0 -1
  151. package/dist/destinations/engage-messaging-twilio/utils/message-sender.d.ts +0 -22
  152. package/dist/destinations/engage-messaging-twilio/utils/message-sender.js +0 -97
  153. package/dist/destinations/engage-messaging-twilio/utils/message-sender.js.map +0 -1
  154. package/dist/destinations/google-sheets-partner/constants.d.ts +0 -3
  155. package/dist/destinations/google-sheets-partner/constants.js +0 -7
  156. package/dist/destinations/google-sheets-partner/constants.js.map +0 -1
  157. package/dist/destinations/google-sheets-partner/generated-types.js.map +0 -1
  158. package/dist/destinations/google-sheets-partner/googleapis/index.d.ts +0 -17
  159. package/dist/destinations/google-sheets-partner/googleapis/index.js +0 -34
  160. package/dist/destinations/google-sheets-partner/googleapis/index.js.map +0 -1
  161. package/dist/destinations/google-sheets-partner/index.d.ts +0 -4
  162. package/dist/destinations/google-sheets-partner/index.js +0 -43
  163. package/dist/destinations/google-sheets-partner/index.js.map +0 -1
  164. package/dist/destinations/google-sheets-partner/postSheet/generated-types.d.ts +0 -11
  165. package/dist/destinations/google-sheets-partner/postSheet/generated-types.js.map +0 -1
  166. package/dist/destinations/google-sheets-partner/postSheet/index.js +0 -79
  167. package/dist/destinations/google-sheets-partner/postSheet/index.js.map +0 -1
  168. package/dist/destinations/google-sheets-partner/postSheet/operations.d.ts +0 -10
  169. package/dist/destinations/google-sheets-partner/postSheet/operations.js +0 -96
  170. package/dist/destinations/google-sheets-partner/postSheet/operations.js.map +0 -1
@@ -1,97 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MessageSender = void 0;
4
- const actions_core_1 = require("@segment/actions-core");
5
- var SendabilityStatus;
6
- (function (SendabilityStatus) {
7
- SendabilityStatus["NoSenderPhone"] = "no_sender_phone";
8
- SendabilityStatus["ShouldSend"] = "should_send";
9
- SendabilityStatus["DoNotSend"] = "do_not_send";
10
- SendabilityStatus["SendDisabled"] = "send_disabled";
11
- SendabilityStatus["InvalidSubscriptionStatus"] = "invalid_subscription_status";
12
- })(SendabilityStatus || (SendabilityStatus = {}));
13
- class MessageSender {
14
- constructor(request, payload, settings, statsClient, tags) {
15
- this.request = request;
16
- this.payload = payload;
17
- this.settings = settings;
18
- this.statsClient = statsClient;
19
- this.tags = tags;
20
- this.EXTERNAL_ID_KEY = 'phone';
21
- this.DEFAULT_HOSTNAME = 'api.twilio.com';
22
- this.DEFAULT_CONNECTION_OVERRIDES = 'rp=all&rc=5';
23
- this.send = async () => {
24
- const { phone, sendabilityStatus } = this.getSendabilityPayload();
25
- if (sendabilityStatus !== SendabilityStatus.ShouldSend || !phone) {
26
- return;
27
- }
28
- const body = await this.getBody(phone);
29
- const webhookUrlWithParams = this.getWebhookUrlWithParams(phone);
30
- if (webhookUrlWithParams)
31
- body.append('StatusCallback', webhookUrlWithParams);
32
- const twilioHostname = this.settings.twilioHostname ?? this.DEFAULT_HOSTNAME;
33
- const twilioToken = Buffer.from(`${this.settings.twilioApiKeySID}:${this.settings.twilioApiKeySecret}`).toString('base64');
34
- const response = await this.request(`https://${twilioHostname}/2010-04-01/Accounts/${this.settings.twilioAccountSID}/Messages.json`, {
35
- method: 'POST',
36
- headers: {
37
- authorization: `Basic ${twilioToken}`
38
- },
39
- body
40
- });
41
- this.tags?.push(`twilio_status_code:${response.status}`);
42
- this.statsClient?.incr('actions-personas-messaging-twilio.response', 1, this.tags);
43
- if (this.payload.eventOccurredTS != undefined) {
44
- this.statsClient?.histogram('actions-personas-messaging-twilio.eventDeliveryTS', Date.now() - new Date(this.payload.eventOccurredTS).getTime(), this.tags);
45
- }
46
- return response;
47
- };
48
- this.getSendabilityPayload = () => {
49
- const nonSendableStatuses = ['unsubscribed', 'did not subscribed', 'false'];
50
- const sendableStatuses = ['subscribed', 'true'];
51
- const externalId = this.payload.externalIds?.find(({ type }) => type === 'phone');
52
- let status;
53
- if (!this.payload.send) {
54
- this.statsClient?.incr('actions-personas-messaging-twilio.send-disabled', 1, this.tags);
55
- return { sendabilityStatus: SendabilityStatus.SendDisabled, phone: undefined };
56
- }
57
- if (!externalId?.subscriptionStatus || nonSendableStatuses.includes(externalId.subscriptionStatus)) {
58
- this.statsClient?.incr('actions-personas-messaging-twilio.notsubscribed', 1, this.tags);
59
- status = SendabilityStatus.DoNotSend;
60
- }
61
- else if (sendableStatuses.includes(externalId.subscriptionStatus)) {
62
- this.statsClient?.incr('actions-personas-messaging-twilio.subscribed', 1, this.tags);
63
- status = SendabilityStatus.ShouldSend;
64
- }
65
- else {
66
- this.statsClient?.incr('actions-personas-messaging-twilio.twilio-error', 1, this.tags);
67
- throw new actions_core_1.IntegrationError(`Failed to recognize the subscriptionStatus in the payload: "${externalId.subscriptionStatus}".`, 'Invalid subscriptionStatus value', 400);
68
- }
69
- const phone = this.payload.toNumber || externalId?.id;
70
- if (!phone) {
71
- status = SendabilityStatus.NoSenderPhone;
72
- }
73
- return { sendabilityStatus: status, phone };
74
- };
75
- this.getWebhookUrlWithParams = (phone) => {
76
- const webhookUrl = this.settings.webhookUrl;
77
- const connectionOverrides = this.settings.connectionOverrides;
78
- const customArgs = {
79
- ...this.payload.customArgs,
80
- space_id: this.settings.spaceId,
81
- __segment_internal_external_id_key__: this.EXTERNAL_ID_KEY,
82
- __segment_internal_external_id_value__: phone
83
- };
84
- if (webhookUrl && customArgs) {
85
- const webhookUrlWithParams = new URL(webhookUrl);
86
- for (const key of Object.keys(customArgs)) {
87
- webhookUrlWithParams.searchParams.append(key, String(customArgs[key]));
88
- }
89
- webhookUrlWithParams.hash = connectionOverrides || this.DEFAULT_CONNECTION_OVERRIDES;
90
- return webhookUrlWithParams.toString();
91
- }
92
- return null;
93
- };
94
- }
95
- }
96
- exports.MessageSender = MessageSender;
97
- //# sourceMappingURL=message-sender.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"message-sender.js","sourceRoot":"","sources":["../../../../src/destinations/engage-messaging-twilio/utils/message-sender.ts"],"names":[],"mappings":";;;AAIA,wDAAwD;AAGxD,IAAK,iBAMJ;AAND,WAAK,iBAAiB;IACpB,sDAAiC,CAAA;IACjC,+CAA0B,CAAA;IAC1B,8CAAyB,CAAA;IACzB,mDAA8B,CAAA;IAC9B,8EAAyD,CAAA;AAC3D,CAAC,EANI,iBAAiB,KAAjB,iBAAiB,QAMrB;AAWD,MAAsB,aAAa;IAKjC,YACW,OAAkB,EAClB,OAAmB,EACnB,QAAkB,EAClB,WAAoC,EACpC,IAAsC;QAJtC,YAAO,GAAP,OAAO,CAAW;QAClB,YAAO,GAAP,OAAO,CAAY;QACnB,aAAQ,GAAR,QAAQ,CAAU;QAClB,gBAAW,GAAX,WAAW,CAAyB;QACpC,SAAI,GAAJ,IAAI,CAAkC;QAThC,oBAAe,GAAG,OAAO,CAAA;QACzB,qBAAgB,GAAG,gBAAgB,CAAA;QACnC,iCAA4B,GAAG,aAAa,CAAA;QAY7D,SAAI,GAAG,KAAK,IAAI,EAAE;YAChB,MAAM,EAAE,KAAK,EAAE,iBAAiB,EAAE,GAAG,IAAI,CAAC,qBAAqB,EAAE,CAAA;YAEjE,IAAI,iBAAiB,KAAK,iBAAiB,CAAC,UAAU,IAAI,CAAC,KAAK,EAAE;gBAChE,OAAM;aACP;YAED,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;YAEtC,MAAM,oBAAoB,GAAG,IAAI,CAAC,uBAAuB,CAAC,KAAK,C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E,CAAA;YACrD,IAAI,CAAC,KAAK,EAAE;gBACV,MAAM,GAAG,iBAAiB,CAAC,aAAa,CAAA;aACzC;YAED,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,KAAK,EAAE,CAAA;QAC7C,CAAC,CAAA;QAEO,4BAAuB,GAAG,CAAC,KAAa,EAAiB,EAAE;YACjE,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAA;YAC3C,MAAM,mBAAmB,GAAG,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAA;YAC7D,MAAM,UAAU,GAAuC;gBACrD,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU;gBAC1B,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,OAAO;gBAC/B,oCAAoC,EAAE,IAAI,CAAC,eAAe;gBAC1D,sCAAsC,EAAE,KAAK;aAC9C,CAAA;YAED,IAAI,UAAU,IAAI,UAAU,EAAE;gBAI5B,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,CAAA;gBAChD,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE;oBACzC,oBAAoB,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;iBACvE;gBAED,oBAAoB,CAAC,IAAI,GAAG,mBAAmB,IAAI,IAAI,CAAC,4BAA4B,CAAA;gBAEpF,OAAO,oBAAoB,CAAC,QAAQ,EAAE,CAAA;aACvC;YAED,OAAO,IAAI,CAAA;QACb,CAAC,CAAA;IAxGE,CAAC;CAyGL;AApHD,sCAoHC"}
@@ -1,3 +0,0 @@
1
- export declare const CONSTANTS: {
2
- MAX_CELLS: number;
3
- };
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CONSTANTS = void 0;
4
- exports.CONSTANTS = {
5
- MAX_CELLS: 300000
6
- };
7
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/destinations/google-sheets-partner/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,SAAS,GAAG;IAIvB,SAAS,EAAE,MAAM;CAClB,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../src/destinations/google-sheets-partner/generated-types.ts"],"names":[],"mappings":""}
@@ -1,17 +0,0 @@
1
- import { ModifiedResponse, RequestClient } from '@segment/actions-core';
2
- import type { MappingSettings } from '../postSheet/operations';
3
- export declare type GetResponse = {
4
- range: string;
5
- majorDimension: string;
6
- values: string[][];
7
- };
8
- export declare class GoogleSheets {
9
- request: RequestClient;
10
- constructor(request: RequestClient);
11
- get: (mappingSettings: MappingSettings, range: string) => Promise<ModifiedResponse<GetResponse>>;
12
- batchUpdate: (mappingSettings: MappingSettings, batchPayload: {
13
- range: string;
14
- values: string[][];
15
- }[]) => Promise<ModifiedResponse<unknown>>;
16
- append: (mappingSettings: MappingSettings, range: string, values: string[][]) => Promise<ModifiedResponse<unknown>>;
17
- }
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GoogleSheets = void 0;
4
- const API_VERSION = 'v4';
5
- class GoogleSheets {
6
- constructor(request) {
7
- this.get = async (mappingSettings, range) => {
8
- return this.request(`https://sheets.googleapis.com/${API_VERSION}/spreadsheets/${mappingSettings.spreadsheetId}/values/${mappingSettings.spreadsheetName}!${range}`, {
9
- method: 'get',
10
- skipResponseCloning: true
11
- });
12
- };
13
- this.batchUpdate = async (mappingSettings, batchPayload) => {
14
- return this.request(`https://sheets.googleapis.com/${API_VERSION}/spreadsheets/${mappingSettings.spreadsheetId}/values:batchUpdate`, {
15
- method: 'post',
16
- json: {
17
- valueInputOption: mappingSettings.dataFormat,
18
- data: batchPayload
19
- }
20
- });
21
- };
22
- this.append = async (mappingSettings, range, values) => {
23
- return this.request(`https://sheets.googleapis.com/${API_VERSION}/spreadsheets/${mappingSettings.spreadsheetId}/values/${mappingSettings.spreadsheetName}!${range}:append?valueInputOption=${mappingSettings.dataFormat}&insertDataOption=INSERT_ROWS`, {
24
- method: 'post',
25
- json: {
26
- values: values
27
- }
28
- });
29
- };
30
- this.request = request;
31
- }
32
- }
33
- exports.GoogleSheets = GoogleSheets;
34
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/google-sheets-partner/googleapis/index.ts"],"names":[],"mappings":";;;AAGA,MAAM,WAAW,GAAG,IAAI,CAAA;AAOxB,MAAa,YAAY;IAGvB,YAAY,OAAsB;QAIlC,QAAG,GAAG,KAAK,EAAE,eAAgC,EAAE,KAAa,EAA0C,EAAE;YACtG,OAAO,IAAI,CAAC,OAAO,CACjB,iCAAiC,WAAW,iBAAiB,eAAe,CAAC,aAAa,WAAW,eAAe,CAAC,eAAe,IAAI,KAAK,EAAE,EAC/I;gBACE,MAAM,EAAE,KAAK;gBACb,mBAAmB,EAAE,IAAI;aAC1B,CACF,CAAA;QACH,CAAC,CAAA;QAED,gBAAW,GAAG,KAAK,EAAE,eAAgC,EAAE,YAAqD,EAAE,EAAE;YAC9G,OAAO,IAAI,CAAC,OAAO,CACjB,iCAAiC,WAAW,iBAAiB,eAAe,CAAC,aAAa,qBAAqB,EAC/G;gBACE,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE;oBACJ,gBAAgB,EAAE,eAAe,CAAC,UAAU;oBAC5C,IAAI,EAAE,YAAY;iBACnB;aACF,CACF,CAAA;QACH,CAAC,CAAA;QAeD,WAAM,GAAG,KAAK,EAAE,eAAgC,EAAE,KAAa,EAAE,MAAkB,EAAE,EAAE;YACrF,OAAO,IAAI,CAAC,OAAO,CACjB,iCAAiC,WAAW,iBAAiB,eAAe,CAAC,aAAa,WAAW,eAAe,CAAC,eAAe,IAAI,KAAK,4BAA4B,eAAe,CAAC,UAAU,+BAA+B,EAClO;gBACE,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE;oBACJ,MAAM,EAAE,MAAM;iBACf;aACF,CACF,CAAA;QACH,CAAC,CAAA;QAjDC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;CAiDF;AAtDD,oCAsDC"}
@@ -1,4 +0,0 @@
1
- import type { DestinationDefinition } from '@segment/actions-core';
2
- import type { Settings } from './generated-types';
3
- declare const destination: DestinationDefinition<Settings>;
4
- export default destination;
@@ -1,43 +0,0 @@
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 postSheet_1 = __importDefault(require("./postSheet"));
7
- const destination = {
8
- name: 'Google Sheets (Partner Test)',
9
- slug: 'actions-google-sheets-partner',
10
- mode: 'cloud',
11
- authentication: {
12
- scheme: 'oauth-managed',
13
- fields: {},
14
- refreshAccessToken: async (request, { auth }) => {
15
- if (!auth.refreshTokenUrl) {
16
- console.log('Could not find refresh token Url');
17
- auth.refreshTokenUrl = 'https://www.googleapis.com/oauth2/v4/token';
18
- }
19
- const res = await request(auth.refreshTokenUrl, {
20
- method: 'POST',
21
- body: new URLSearchParams({
22
- refresh_token: auth.refreshToken,
23
- client_id: auth.clientId,
24
- client_secret: auth.clientSecret,
25
- grant_type: 'refresh_token'
26
- })
27
- });
28
- return { accessToken: res.data.access_token };
29
- }
30
- },
31
- extendRequest({ auth }) {
32
- return {
33
- headers: {
34
- authorization: `Bearer ${auth?.accessToken}`
35
- }
36
- };
37
- },
38
- actions: {
39
- postSheet: postSheet_1.default
40
- }
41
- };
42
- exports.default = destination;
43
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/google-sheets-partner/index.ts"],"names":[],"mappings":";;;;;AAGA,4DAAmC;AAQnC,MAAM,WAAW,GAAoC;IACnD,IAAI,EAAE,8BAA8B;IACpC,IAAI,EAAE,+BAA+B;IACrC,IAAI,EAAE,OAAO;IAEb,cAAc,EAAE;QACd,MAAM,EAAE,eAAe;QACvB,MAAM,EAAE,EAAE;QAMV,kBAAkB,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;YAC9C,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;gBACzB,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAA;gBAC/C,IAAI,CAAC,eAAe,GAAG,4CAA4C,CAAA;aACpE;YACD,MAAM,GAAG,GAAG,MAAM,OAAO,CAAuB,IAAI,CAAC,eAAe,EAAE;gBACpE,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,IAAI,eAAe,CAAC;oBACxB,aAAa,EAAE,IAAI,CAAC,YAAY;oBAChC,SAAS,EAAE,IAAI,CAAC,QAAQ;oBACxB,aAAa,EAAE,IAAI,CAAC,YAAY;oBAChC,UAAU,EAAE,eAAe;iBAC5B,CAAC;aACH,CAAC,CAAA;YAEF,OAAO,EAAE,WAAW,EAAE,GAAG,CAAC,IAAI,CAAC,YAAY,EAAE,CAAA;QAC/C,CAAC;KACF;IACD,aAAa,CAAC,EAAE,IAAI,EAAE;QACpB,OAAO;YACL,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,IAAI,EAAE,WAAW,EAAE;aAC7C;SACF,CAAA;IACH,CAAC;IAQD,OAAO,EAAE;QACP,SAAS,EAAT,mBAAS;KACV;CACF,CAAA;AAED,kBAAe,WAAW,CAAA"}
@@ -1,11 +0,0 @@
1
- export interface Payload {
2
- record_identifier: string;
3
- operation_type: string;
4
- spreadsheet_id: string;
5
- spreadsheet_name: string;
6
- data_format: string;
7
- fields: {
8
- [k: string]: unknown;
9
- };
10
- enable_batching?: boolean;
11
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/google-sheets-partner/postSheet/generated-types.ts"],"names":[],"mappings":""}
@@ -1,79 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const operations_1 = require("./operations");
4
- const action = {
5
- title: 'Post Sheet',
6
- description: 'Write values to a Google Sheets spreadsheet.',
7
- defaultSubscription: 'event = "updated" or event = "new"',
8
- fields: {
9
- record_identifier: {
10
- label: 'Record Identifier',
11
- description: 'Property which uniquely identifies each row in the spreadsheet.',
12
- type: 'string',
13
- required: true,
14
- default: { '@path': '$.__segment_id' }
15
- },
16
- operation_type: {
17
- label: 'Operation Type',
18
- description: "Describes the nature of the operation being performed. Only supported values are 'new' and 'updated'.",
19
- type: 'hidden',
20
- required: true,
21
- default: { '@path': '$.event' }
22
- },
23
- spreadsheet_id: {
24
- label: 'Spreadsheet ID',
25
- description: 'The identifier of the spreadsheet. You can find this value in the URL of the spreadsheet. e.g. https://docs.google.com/spreadsheets/d/{SPREADSHEET_ID}/edit',
26
- type: 'string',
27
- required: true,
28
- default: ''
29
- },
30
- spreadsheet_name: {
31
- label: 'Spreadsheet Name',
32
- description: 'The name of the spreadsheet. You can find this value on the tab at the bottom of the spreadsheet. Please provide a valid name of a sheet that already exists.',
33
- type: 'string',
34
- required: true,
35
- default: 'Sheet1'
36
- },
37
- data_format: {
38
- label: 'Data Format',
39
- description: 'The way Google will interpret values. If you select raw, values will not be parsed and will be stored as-is. If you select user entered, values will be parsed as if you typed them into the UI. Numbers will stay as numbers, but strings may be converted to numbers, dates, etc. following the same rules that are applied when entering text into a cell via the Google Sheets UI.',
40
- type: 'string',
41
- required: true,
42
- default: 'RAW',
43
- choices: [
44
- { label: 'Raw', value: 'RAW' },
45
- { label: 'User Entered', value: 'USER_ENTERED' }
46
- ]
47
- },
48
- fields: {
49
- label: 'Fields',
50
- description: `
51
- The fields to write to the spreadsheet.
52
-
53
- On the left-hand side, input the name of the field as it will appear in the Google Sheet.
54
-
55
- On the right-hand side, select the field from your data model that maps to the given field in your sheet.
56
-
57
- ---
58
-
59
- `,
60
- type: 'object',
61
- required: true,
62
- defaultObjectUI: 'keyvalue:only'
63
- },
64
- enable_batching: {
65
- type: 'boolean',
66
- label: 'Batch Data to Google Sheets',
67
- description: 'Set as true to ensure Segment sends data to Google Sheets in batches. Please do not set to false.',
68
- default: true
69
- }
70
- },
71
- perform: (request, { payload }) => {
72
- return operations_1.processData(request, [payload]);
73
- },
74
- performBatch: (request, { payload }) => {
75
- return operations_1.processData(request, payload);
76
- }
77
- };
78
- exports.default = action;
79
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/google-sheets-partner/postSheet/index.ts"],"names":[],"mappings":";;AAIA,6CAA0C;AAE1C,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,YAAY;IACnB,WAAW,EAAE,8CAA8C;IAC3D,mBAAmB,EAAE,oCAAoC;IAEzD,MAAM,EAAE;QACN,iBAAiB,EAAE;YACjB,KAAK,EAAE,mBAAmB;YAC1B,WAAW,EAAE,iEAAiE;YAC9E,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,EAAE,OAAO,EAAE,gBAAgB,EAAE;SACvC;QACD,cAAc,EAAE;YACd,KAAK,EAAE,gBAAgB;YACvB,WAAW,EACT,uGAAuG;YACzG,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE;SAChC;QACD,cAAc,EAAE;YACd,KAAK,EAAE,gBAAgB;YACvB,WAAW,EACT,6JAA6J;YAC/J,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,EAAE;SACZ;QACD,gBAAgB,EAAE;YAChB,KAAK,EAAE,kBAAkB;YACzB,WAAW,EACT,+JAA+J;YACjK,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,QAAQ;SAClB;QACD,WAAW,EAAE;YACX,KAAK,EAAE,aAAa;YACpB,WAAW,EACT,wXAAwX;YAC1X,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,KAAK;YACd,OAAO,EAAE;gBACP,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;gBAC9B,EAAE,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,cAAc,EAAE;aACjD;SACF;QACD,MAAM,EAAE;YACN,KAAK,EAAE,QAAQ;YACf,WAAW,EAAE;;;;;;;;;GAShB;YACG,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,eAAe,EAAE,eAAe;SACjC;QACD,eAAe,EAAE;YACf,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,6BAA6B;YACpC,WAAW,EAAE,mGAAmG;YAChH,OAAO,EAAE,IAAI;SACd;KACF;IACD,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QAChC,OAAO,wBAAW,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,CAAC,CAAA;IACxC,CAAC;IACD,YAAY,EAAE,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QACrC,OAAO,wBAAW,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IACtC,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
@@ -1,10 +0,0 @@
1
- import type { Payload } from './generated-types';
2
- import { RequestClient } from '@segment/actions-core';
3
- export declare type MappingSettings = {
4
- spreadsheetId: string;
5
- spreadsheetName: string;
6
- dataFormat: string;
7
- columns: string[];
8
- };
9
- declare function processData(request: RequestClient, events: Payload[]): Promise<(import("@segment/actions-core").ModifiedResponse<unknown> | undefined)[]>;
10
- export { processData };
@@ -1,96 +0,0 @@
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
- exports.processData = void 0;
7
- const actions_core_1 = require("@segment/actions-core");
8
- const index_1 = require("../googleapis/index");
9
- const constants_1 = require("../constants");
10
- const a1_notation_1 = __importDefault(require("@segment/a1-notation"));
11
- const DATA_ROW_OFFSET = 2;
12
- const generateColumnValuesFromFields = (identifier, fields, columns) => {
13
- const retVal = columns.map((col) => fields[col] ?? '');
14
- retVal.unshift(identifier);
15
- return retVal;
16
- };
17
- function processGetSpreadsheetResponse(response, events, mappingSettings) {
18
- const numColumns = mappingSettings.columns.length;
19
- const numRows = response.values?.length;
20
- if (numRows * numColumns > constants_1.CONSTANTS.MAX_CELLS) {
21
- throw new actions_core_1.IntegrationError('Sheet has reached maximum limit', 'INVALID_REQUEST_DATA', 400);
22
- }
23
- const updateBatch = [];
24
- const appendBatch = [];
25
- const eventMap = new Map(events.map((e) => [e.record_identifier, e]));
26
- if (response.values && response.values.length > 0) {
27
- for (let i = 0; i < response.values.length; i++) {
28
- const targetIdentifier = response.values[i][0];
29
- if (eventMap.has(targetIdentifier)) {
30
- const targetEvent = eventMap.get(targetIdentifier);
31
- if (targetEvent.operation_type != 'deleted') {
32
- updateBatch.push({
33
- identifier: targetIdentifier,
34
- event: targetEvent.fields,
35
- index: i
36
- });
37
- }
38
- eventMap.delete(targetIdentifier);
39
- }
40
- }
41
- }
42
- eventMap.forEach((value, key) => {
43
- if (value.operation_type != 'deleted') {
44
- appendBatch.push({
45
- identifier: key,
46
- event: value.fields
47
- });
48
- }
49
- });
50
- return { appendBatch, updateBatch };
51
- }
52
- async function processUpdateBatch(mappingSettings, updateBatch, gs) {
53
- const getRange = (targetIndex, columnCount) => {
54
- const targetRange = new a1_notation_1.default(1, targetIndex);
55
- targetRange.addX(columnCount);
56
- return targetRange.toString();
57
- };
58
- const batchPayload = updateBatch.map(({ identifier, event, index }) => {
59
- const values = generateColumnValuesFromFields(identifier, event, mappingSettings.columns);
60
- return {
61
- range: `${mappingSettings.spreadsheetName}!${getRange(index + DATA_ROW_OFFSET, values.length)}`,
62
- values: [values]
63
- };
64
- });
65
- const headerRowRange = new a1_notation_1.default(1, 1, 1, mappingSettings.columns.length + 1);
66
- batchPayload.push({
67
- range: `${mappingSettings.spreadsheetName}!${headerRowRange.toString()}`,
68
- values: [['id', ...mappingSettings.columns]]
69
- });
70
- return gs.batchUpdate(mappingSettings, batchPayload);
71
- }
72
- async function processAppendBatch(mappingSettings, appendBatch, gs) {
73
- if (appendBatch.length <= 0) {
74
- return;
75
- }
76
- const values = appendBatch.map(({ identifier, event }) => generateColumnValuesFromFields(identifier, event, mappingSettings.columns));
77
- return gs.append(mappingSettings, `A${DATA_ROW_OFFSET}`, values);
78
- }
79
- async function processData(request, events) {
80
- const mappingSettings = {
81
- spreadsheetId: events[0].spreadsheet_id,
82
- spreadsheetName: events[0].spreadsheet_name,
83
- dataFormat: events[0].data_format,
84
- columns: Object.getOwnPropertyNames(events[0].fields)
85
- };
86
- const gs = new index_1.GoogleSheets(request);
87
- const response = await gs.get(mappingSettings, `A${DATA_ROW_OFFSET}:A`);
88
- const { appendBatch, updateBatch } = processGetSpreadsheetResponse(response.data, events, mappingSettings);
89
- const promises = [
90
- processUpdateBatch(mappingSettings, updateBatch, gs),
91
- processAppendBatch(mappingSettings, appendBatch, gs)
92
- ];
93
- return await Promise.all(promises);
94
- }
95
- exports.processData = processData;
96
- //# sourceMappingURL=operations.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"operations.js","sourceRoot":"","sources":["../../../../src/destinations/google-sheets-partner/postSheet/operations.ts"],"names":[],"mappings":";;;;;;AACA,wDAAuE;AACvE,+CAA+D;AAC/D,4CAAwC;AAExC,uEAAqC;AA4BrC,MAAM,eAAe,GAAG,CAAC,CAAA;AAwBzB,MAAM,8BAA8B,GAAG,CAAC,UAAkB,EAAE,MAAc,EAAE,OAAiB,EAAE,EAAE;IAC/F,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,G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