@segment/action-destinations 3.115.1-alpha.5 → 3.115.1-alpha.6

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 (69) hide show
  1. package/dist/destinations/google-sheets-partner/constants.d.ts +3 -0
  2. package/dist/destinations/google-sheets-partner/constants.js +7 -0
  3. package/dist/destinations/google-sheets-partner/constants.js.map +1 -0
  4. package/dist/destinations/google-sheets-partner/generated-types.d.ts +2 -0
  5. package/dist/destinations/google-sheets-partner/generated-types.js +3 -0
  6. package/dist/destinations/google-sheets-partner/generated-types.js.map +1 -0
  7. package/dist/destinations/google-sheets-partner/googleapis/index.d.ts +17 -0
  8. package/dist/destinations/google-sheets-partner/googleapis/index.js +34 -0
  9. package/dist/destinations/google-sheets-partner/googleapis/index.js.map +1 -0
  10. package/dist/destinations/google-sheets-partner/index.d.ts +4 -0
  11. package/dist/destinations/google-sheets-partner/index.js +39 -0
  12. package/dist/destinations/google-sheets-partner/index.js.map +1 -0
  13. package/dist/destinations/google-sheets-partner/postSheet/generated-types.d.ts +11 -0
  14. package/dist/destinations/google-sheets-partner/postSheet/generated-types.js +3 -0
  15. package/dist/destinations/google-sheets-partner/postSheet/generated-types.js.map +1 -0
  16. package/dist/destinations/google-sheets-partner/postSheet/index.d.ts +5 -0
  17. package/dist/destinations/google-sheets-partner/postSheet/index.js +79 -0
  18. package/dist/destinations/google-sheets-partner/postSheet/index.js.map +1 -0
  19. package/dist/destinations/google-sheets-partner/postSheet/operations.d.ts +10 -0
  20. package/dist/destinations/google-sheets-partner/postSheet/operations.js +96 -0
  21. package/dist/destinations/google-sheets-partner/postSheet/operations.js.map +1 -0
  22. package/dist/destinations/index.js +2 -0
  23. package/dist/destinations/index.js.map +1 -1
  24. package/dist/destinations/segment/errors.d.ts +3 -0
  25. package/dist/destinations/segment/errors.js +7 -0
  26. package/dist/destinations/segment/errors.js.map +1 -0
  27. package/dist/destinations/segment/generated-types.d.ts +4 -0
  28. package/dist/destinations/segment/generated-types.js +3 -0
  29. package/dist/destinations/segment/generated-types.js.map +1 -0
  30. package/dist/destinations/segment/index.d.ts +4 -0
  31. package/dist/destinations/segment/index.js +58 -0
  32. package/dist/destinations/segment/index.js.map +1 -0
  33. package/dist/destinations/segment/properties.d.ts +10 -0
  34. package/dist/destinations/segment/properties.js +17 -0
  35. package/dist/destinations/segment/properties.js.map +1 -0
  36. package/dist/destinations/segment/segment-properties.d.ts +23 -0
  37. package/dist/destinations/segment/segment-properties.js +322 -0
  38. package/dist/destinations/segment/segment-properties.js.map +1 -0
  39. package/dist/destinations/segment/sendGroup/generated-types.d.ts +65 -0
  40. package/dist/destinations/segment/sendGroup/generated-types.js +3 -0
  41. package/dist/destinations/segment/sendGroup/generated-types.js.map +1 -0
  42. package/dist/destinations/segment/sendGroup/index.d.ts +5 -0
  43. package/dist/destinations/segment/sendGroup/index.js +67 -0
  44. package/dist/destinations/segment/sendGroup/index.js.map +1 -0
  45. package/dist/destinations/segment/sendIdentify/generated-types.d.ts +65 -0
  46. package/dist/destinations/segment/sendIdentify/generated-types.js +3 -0
  47. package/dist/destinations/segment/sendIdentify/generated-types.js.map +1 -0
  48. package/dist/destinations/segment/sendIdentify/index.d.ts +5 -0
  49. package/dist/destinations/segment/sendIdentify/index.js +67 -0
  50. package/dist/destinations/segment/sendIdentify/index.js.map +1 -0
  51. package/dist/destinations/segment/sendPage/generated-types.d.ts +67 -0
  52. package/dist/destinations/segment/sendPage/generated-types.js +3 -0
  53. package/dist/destinations/segment/sendPage/generated-types.js.map +1 -0
  54. package/dist/destinations/segment/sendPage/index.d.ts +5 -0
  55. package/dist/destinations/segment/sendPage/index.js +77 -0
  56. package/dist/destinations/segment/sendPage/index.js.map +1 -0
  57. package/dist/destinations/segment/sendScreen/generated-types.d.ts +66 -0
  58. package/dist/destinations/segment/sendScreen/generated-types.js +3 -0
  59. package/dist/destinations/segment/sendScreen/generated-types.js.map +1 -0
  60. package/dist/destinations/segment/sendScreen/index.d.ts +5 -0
  61. package/dist/destinations/segment/sendScreen/index.js +69 -0
  62. package/dist/destinations/segment/sendScreen/index.js.map +1 -0
  63. package/dist/destinations/segment/sendTrack/generated-types.d.ts +66 -0
  64. package/dist/destinations/segment/sendTrack/generated-types.js +3 -0
  65. package/dist/destinations/segment/sendTrack/generated-types.js.map +1 -0
  66. package/dist/destinations/segment/sendTrack/index.d.ts +5 -0
  67. package/dist/destinations/segment/sendTrack/index.js +69 -0
  68. package/dist/destinations/segment/sendTrack/index.js.map +1 -0
  69. package/package.json +4 -5
@@ -0,0 +1,3 @@
1
+ export declare const CONSTANTS: {
2
+ MAX_CELLS: number;
3
+ };
@@ -0,0 +1,7 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,2 @@
1
+ export interface Settings {
2
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=generated-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../src/destinations/google-sheets-partner/generated-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,17 @@
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
+ }
@@ -0,0 +1,34 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,4 @@
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;
@@ -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 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: 'oauth2',
13
+ fields: {},
14
+ refreshAccessToken: async (request, { auth }) => {
15
+ const res = await request('https://www.googleapis.com/oauth2/v4/token', {
16
+ method: 'POST',
17
+ body: new URLSearchParams({
18
+ refresh_token: auth.refreshToken,
19
+ client_id: auth.clientId,
20
+ client_secret: auth.clientSecret,
21
+ grant_type: 'refresh_token'
22
+ })
23
+ });
24
+ return { accessToken: res.data.access_token };
25
+ }
26
+ },
27
+ extendRequest({ auth }) {
28
+ return {
29
+ headers: {
30
+ authorization: `Bearer ${auth?.accessToken}`
31
+ }
32
+ };
33
+ },
34
+ actions: {
35
+ postSheet: postSheet_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/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,QAAQ;QAChB,MAAM,EAAE,EAAE;QAMV,kBAAkB,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;YAC9C,MAAM,GAAG,GAAG,MAAM,OAAO,CAAuB,4CAA4C,EAAE;gBAC5F,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"}
@@ -0,0 +1,11 @@
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
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=generated-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/google-sheets-partner/postSheet/generated-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ import { ActionDefinition } from '@segment/actions-core';
2
+ import type { Settings } from '../generated-types';
3
+ import type { Payload } from './generated-types';
4
+ declare const action: ActionDefinition<Settings, Payload>;
5
+ export default action;
@@ -0,0 +1,79 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,10 @@
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 };
@@ -0,0 +1,96 @@
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
@@ -0,0 +1 @@
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,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAA;IACtD,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;IAC1B,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAQD,SAAS,6BAA6B,CAAC,QAAqB,EAAE,MAAiB,EAAE,eAAgC;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AAG;QACf,kBAAkB,CAAC,eAAe,EAAE,WAAW,EAAE,EAAE,CAAC;QACpD,kBAAkB,CAAC,eAAe,EAAE,WAAW,EAAE,EAAE,CAAC;KACrD,CAAA;IAED,OAAO,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;AACpC,CAAC;AAEQ,kCAAW"}
@@ -68,6 +68,8 @@ register('62ded0cf5753c743883ca0f3', './intercom');
68
68
  register('631a6f32946dd8197e9cab66', './sendgrid');
69
69
  register('632b1116e0cb83902f3fd717', './hubspot');
70
70
  register('636d38db78d7834347d76c44', './1plusx-asset-api');
71
+ register('635fea9131814aa2aa18a640', './google-sheets-partner');
72
+ register('6371eee1ae5e324869aa8b1b', './segment');
71
73
  function register(id, destinationPath) {
72
74
  const definition = require(destinationPath).default;
73
75
  const resolvedPath = require.resolve(destinationPath);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/destinations/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,wDAAmD;AACnD,gDAAuB;AAWV,QAAA,YAAY,GAA0C,EAAE,CAAA;AACxD,QAAA,QAAQ,GAAsC,EAAE,CAAA;AAU7D,QAAQ,CAAC,0BAA0B,EAAE,UAAU,CAAC,CAAA;AAChD,QAAQ,CAAC,0BAA0B,EAAE,gBAAgB,CAAC,CAAA;AACtD,QAAQ,CAAC,0BAA0B,EAAE,aAAa,CAAC,CAAA;AACnD,QAAQ,CAAC,0BAA0B,EAAE,SAAS,CAAC,CAAA;AAC/C,QAAQ,CAAC,0BAA0B,EAAE,aAAa,CAAC,CAAA;AACnD,QAAQ,CAAC,0BAA0B,EAAE,SAAS,CAAC,CAAA;AAC/C,QAAQ,CAAC,0BAA0B,EAAE,WAAW,CAAC,CAAA;AACjD,QAAQ,CAAC,0BAA0B,EAAE,oBAAoB,CAAC,CAAA;AAC1D,QAAQ,CAAC,0BAA0B,EAAE,cAAc,CAAC,CAAA;AACpD,QAAQ,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AAG,MAAM,kDAAO,KAAK,IAAI,EAAE,IAAE,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;IAGxE,IAAI,CAAC,WAAW,EAAE,IAAI,IAAI,OAAO,WAAW,EAAE,OAAO,KAAK,QAAQ,EAAE;QAClE,OAAO,IAAI,CAAA;KACZ;IAED,OAAO,WAAW,CAAA;AACpB,CAAC;AAED,KAAK,UAAU,uBAAuB,CAAC,GAAW;IAChD,MAAM,WAAW,GAAG,oBAAY,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAA;IAExE,IAAI,CAAC,WAAW,EAAE;QAChB,OAAO,IAAI,CAAA;KACZ;IAGD,OAAO,IAAI,0BAAW,CAAC,WAAyC,CAAC,CAAA;AACnE,CAAC;AAED,SAAgB,kBAAkB,CAAC,EAAU;IAC3C,MAAM,WAAW,GAAG,gBAAQ,CAAC,EAAE,CAAC,CAAA;IAEhC,IAAI,CAAC,WAAW,EAAE,UAAU,EAAE;QAC5B,OAAO,IAAI,CAAA;KACZ;IAED,OAAO,IAAI,0BAAW,CAAC,WAAW,CAAC,UAAU,CAAC,CAAA;AAChD,CAAC;AARD,gDAQC;AAEM,KAAK,UAAU,uBAAuB,CAAC,WAAmB;IAC/D,OAAO,kBAAkB,CAAC,WAAW,CAAC,IAAI,uBAAuB,CAAC,WAAW,CAAC,CAAA;AAChF,CAAC;AAFD,0DAEC"}
@@ -0,0 +1,3 @@
1
+ import { IntegrationError } from '@segment/actions-core';
2
+ export declare const MissingUserOrAnonymousIdThrowableError: IntegrationError;
3
+ export declare const InvalidEndpointSelectedThrowableError: IntegrationError;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InvalidEndpointSelectedThrowableError = exports.MissingUserOrAnonymousIdThrowableError = void 0;
4
+ const actions_core_1 = require("@segment/actions-core");
5
+ exports.MissingUserOrAnonymousIdThrowableError = new actions_core_1.IntegrationError('Either `Anonymous ID` or `User ID` must be defined.', 'Missing Required Field', 400);
6
+ exports.InvalidEndpointSelectedThrowableError = new actions_core_1.IntegrationError('A valid endpoint must be selected. Please check your Segment settings.', 'Misconfigured Endpoint', 400);
7
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/destinations/segment/errors.ts"],"names":[],"mappings":";;;AAAA,wDAAwD;AAE3C,QAAA,sCAAsC,GAAG,IAAI,+BAAgB,CACxE,qDAAqD,EACrD,wBAAwB,EACxB,GAAG,CACJ,CAAA;AAEY,QAAA,qCAAqC,GAAG,IAAI,+BAAgB,CACvE,wEAAwE,EACxE,wBAAwB,EACxB,GAAG,CACJ,CAAA"}
@@ -0,0 +1,4 @@
1
+ export interface Settings {
2
+ source_write_key: string;
3
+ endpoint?: string;
4
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=generated-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../src/destinations/segment/generated-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
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;
@@ -0,0 +1,58 @@
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 sendIdentify_1 = __importDefault(require("./sendIdentify"));
7
+ const sendGroup_1 = __importDefault(require("./sendGroup"));
8
+ const sendScreen_1 = __importDefault(require("./sendScreen"));
9
+ const sendPage_1 = __importDefault(require("./sendPage"));
10
+ const sendTrack_1 = __importDefault(require("./sendTrack"));
11
+ const properties_1 = require("./properties");
12
+ const destination = {
13
+ name: 'Segment',
14
+ slug: 'actions-segment',
15
+ mode: 'cloud',
16
+ authentication: {
17
+ scheme: 'custom',
18
+ fields: {
19
+ source_write_key: {
20
+ label: 'Source Write Key',
21
+ description: 'The **Write Key** of a Segment source.',
22
+ type: 'string',
23
+ required: true
24
+ },
25
+ endpoint: {
26
+ label: 'Endpoint Region',
27
+ description: 'The region to send your data.',
28
+ type: 'string',
29
+ format: 'text',
30
+ choices: Object.keys(properties_1.SEGMENT_ENDPOINTS).map((key) => ({
31
+ label: properties_1.SEGMENT_ENDPOINTS[key].label,
32
+ value: key
33
+ })),
34
+ default: properties_1.DEFAULT_SEGMENT_ENDPOINT
35
+ }
36
+ },
37
+ testAuthentication: async (request, { settings }) => {
38
+ const { source_write_key, endpoint } = settings;
39
+ return request(`${properties_1.SEGMENT_ENDPOINTS[endpoint || properties_1.DEFAULT_SEGMENT_ENDPOINT].cdn}/projects/${source_write_key}/settings`);
40
+ }
41
+ },
42
+ extendRequest({ settings }) {
43
+ return {
44
+ headers: {
45
+ authorization: `Basic ${Buffer.from(settings.source_write_key + ':').toString('base64')}`
46
+ }
47
+ };
48
+ },
49
+ actions: {
50
+ sendIdentify: sendIdentify_1.default,
51
+ sendGroup: sendGroup_1.default,
52
+ sendScreen: sendScreen_1.default,
53
+ sendPage: sendPage_1.default,
54
+ sendTrack: sendTrack_1.default
55
+ }
56
+ };
57
+ exports.default = destination;
58
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/segment/index.ts"],"names":[],"mappings":";;;;;AAGA,kEAAyC;AACzC,4DAAmC;AACnC,8DAAqC;AACrC,0DAAiC;AACjC,4DAAmC;AAEnC,6CAA0E;AAE1E,MAAM,WAAW,GAAoC;IAEnD,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,iBAAiB;IACvB,IAAI,EAAE,OAAO;IAEb,cAAc,EAAE;QACd,MAAM,EA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+ interface SegmentEndpoint {
2
+ label: string;
3
+ url: string;
4
+ cdn: string;
5
+ }
6
+ export declare const SEGMENT_ENDPOINTS: {
7
+ [key: string]: SegmentEndpoint;
8
+ };
9
+ export declare const DEFAULT_SEGMENT_ENDPOINT = "north_america";
10
+ export {};
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_SEGMENT_ENDPOINT = exports.SEGMENT_ENDPOINTS = void 0;
4
+ exports.SEGMENT_ENDPOINTS = {
5
+ north_america: {
6
+ label: 'North America',
7
+ url: 'https://api.segment.io/v1',
8
+ cdn: 'https://cdn.segment.com/v1'
9
+ },
10
+ europe: {
11
+ label: 'Europe',
12
+ url: 'https://events.eu1.segmentapis.com/v1',
13
+ cdn: 'https://cdn.segment.com/v1'
14
+ }
15
+ };
16
+ exports.DEFAULT_SEGMENT_ENDPOINT = 'north_america';
17
+ //# sourceMappingURL=properties.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"properties.js","sourceRoot":"","sources":["../../../src/destinations/segment/properties.ts"],"names":[],"mappings":";;;AAMa,QAAA,iBAAiB,GAAuC;IACnE,aAAa,EAAE;QACb,KAAK,EAAE,eAAe;QACtB,GAAG,EAAE,2BAA2B;QAChC,GAAG,EAAE,4BAA4B;KAClC;IACD,MAAM,EAAE;QACN,KAAK,EAAE,QAAQ;QACf,GAAG,EAAE,uCAAuC;QAC5C,GAAG,EAAE,4BAA4B;KAClC;CACF,CAAA;AAEY,QAAA,wBAAwB,GAAG,eAAe,CAAA"}
@@ -0,0 +1,23 @@
1
+ import { InputField } from '@segment/actions-core/src/destination-kit/types';
2
+ export declare const user_id: InputField;
3
+ export declare const anonymous_id: InputField;
4
+ export declare const timestamp: InputField;
5
+ export declare const page_name: InputField;
6
+ export declare const screen_name: InputField;
7
+ export declare const event_name: InputField;
8
+ export declare const page_category: InputField;
9
+ export declare const application: InputField;
10
+ export declare const campaign_parameters: InputField;
11
+ export declare const device: InputField;
12
+ export declare const ip_address: InputField;
13
+ export declare const locale: InputField;
14
+ export declare const location: InputField;
15
+ export declare const network: InputField;
16
+ export declare const operating_system: InputField;
17
+ export declare const page: InputField;
18
+ export declare const screen: InputField;
19
+ export declare const user_agent: InputField;
20
+ export declare const timezone: InputField;
21
+ export declare const group_id: InputField;
22
+ export declare const properties: InputField;
23
+ export declare const traits: InputField;