@or-sdk/contacts 3.5.5-beta.2131.0 → 3.5.5

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 (42) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/cjs/Contacts.js +0 -14
  3. package/dist/cjs/Contacts.js.map +1 -1
  4. package/dist/cjs/api/batchProcessApi.js +0 -10
  5. package/dist/cjs/api/batchProcessApi.js.map +1 -1
  6. package/dist/cjs/api/contactApi.js +40 -6
  7. package/dist/cjs/api/contactApi.js.map +1 -1
  8. package/dist/cjs/types.js.map +1 -1
  9. package/dist/esm/Contacts.js +0 -14
  10. package/dist/esm/Contacts.js.map +1 -1
  11. package/dist/esm/api/batchProcessApi.js +1 -9
  12. package/dist/esm/api/batchProcessApi.js.map +1 -1
  13. package/dist/esm/api/contactApi.js +30 -4
  14. package/dist/esm/api/contactApi.js.map +1 -1
  15. package/dist/esm/types.js.map +1 -1
  16. package/dist/types/Contacts.d.ts +0 -4
  17. package/dist/types/Contacts.d.ts.map +1 -1
  18. package/dist/types/api/batchProcessApi.d.ts +0 -1
  19. package/dist/types/api/batchProcessApi.d.ts.map +1 -1
  20. package/dist/types/api/contactApi.d.ts +4 -3
  21. package/dist/types/api/contactApi.d.ts.map +1 -1
  22. package/dist/types/types.d.ts +1 -10
  23. package/dist/types/types.d.ts.map +1 -1
  24. package/package.json +5 -4
  25. package/src/Contacts.ts +0 -17
  26. package/src/api/batchProcessApi.ts +1 -11
  27. package/src/api/contactApi.ts +40 -5
  28. package/src/types.ts +0 -16
  29. package/dist/cjs/api/baseWithPolingApi.js +0 -106
  30. package/dist/cjs/api/baseWithPolingApi.js.map +0 -1
  31. package/dist/cjs/api/bulkContactsCreateApi.js +0 -197
  32. package/dist/cjs/api/bulkContactsCreateApi.js.map +0 -1
  33. package/dist/esm/api/baseWithPolingApi.js +0 -47
  34. package/dist/esm/api/baseWithPolingApi.js.map +0 -1
  35. package/dist/esm/api/bulkContactsCreateApi.js +0 -92
  36. package/dist/esm/api/bulkContactsCreateApi.js.map +0 -1
  37. package/dist/types/api/baseWithPolingApi.d.ts +0 -11
  38. package/dist/types/api/baseWithPolingApi.d.ts.map +0 -1
  39. package/dist/types/api/bulkContactsCreateApi.d.ts +0 -15
  40. package/dist/types/api/bulkContactsCreateApi.d.ts.map +0 -1
  41. package/src/api/baseWithPolingApi.ts +0 -51
  42. package/src/api/bulkContactsCreateApi.ts +0 -110
@@ -2,6 +2,7 @@ import { v4 } from 'uuid';
2
2
 
3
3
  import {
4
4
  BatchProcessResponseDto,
5
+ BatchProcessStatus,
5
6
  ContactParamsDto,
6
7
  ContactRequestDto,
7
8
  ContactResponseDto,
@@ -18,22 +19,22 @@ import {
18
19
  UpdateContactDto,
19
20
  } from '@onereach/types-contacts-api';
20
21
  import { CalApiParams, List } from '@or-sdk/base';
22
+ import { BaseApi } from './baseApi';
21
23
  import BatchProcessApi from './batchProcessApi';
22
24
  import { getObjectSizeInBytes, chunkArrByMaxSize, debouncePromise } from '../utils';
23
25
  import { InitCreateBatchResponse, CreateContactsBatchResults } from '../types';
24
26
  import ContactBookApi from './contactBookApi';
25
- import { REQUEST_PAYLOAD_MAX_BYTES, CONTACTS_DELETE_MAX_AMOUNT } from '../constants';
27
+ import { REQUEST_PAYLOAD_MAX_BYTES, FAILED_REQUEST_REPEATS, CONTACTS_DELETE_MAX_AMOUNT } from '../constants';
26
28
  import { ApiError, CreateContactsBatchError } from '../apiError';
27
29
  import { DeleteContactsData } from '../types';
28
- import BaseWithPoling from './baseWithPolingApi';
29
30
 
30
- export default class ContactApi extends BaseWithPoling {
31
+ export default class ContactApi extends BaseApi {
31
32
  constructor(
32
33
  protected readonly apiCall: <T>(params: CalApiParams) => Promise<T>,
33
- protected batchProcessApi: BatchProcessApi,
34
+ private batchProcessApi: BatchProcessApi,
34
35
  private bookServiceApi: ContactBookApi
35
36
  ) {
36
- super(apiCall, batchProcessApi);
37
+ super(apiCall);
37
38
  }
38
39
 
39
40
  private readonly apiBasePath = 'contact';
@@ -367,4 +368,38 @@ export default class ContactApi extends BaseWithPoling {
367
368
  };
368
369
  }
369
370
 
371
+ /**
372
+ * Pols specific batch process until status of it isn't turned from 'pending to something else.
373
+ */
374
+ private async polling(batchId: string, repeats = 0): Promise<BatchProcessResponseDto> {
375
+ let batchProcess: BatchProcessResponseDto;
376
+
377
+ try {
378
+ batchProcess = await debouncePromise(() => this.batchProcessApi.getBatchProcess(batchId), 1000);
379
+ } catch (e) {
380
+ if (
381
+ repeats < FAILED_REQUEST_REPEATS
382
+ && 'statusCode' in (e as object)
383
+ && (e as unknown as ApiError).statusCode === 410
384
+ ) {
385
+ return await debouncePromise(() => this.polling(batchId, repeats + 1), 2000);
386
+ }
387
+ if (repeats < FAILED_REQUEST_REPEATS) {
388
+ return this.polling(batchId, repeats + 1);
389
+ }
390
+ throw new CreateContactsBatchError((e as unknown as Error).message, batchId);
391
+ }
392
+
393
+ if (batchProcess.status === BatchProcessStatus.failed) {
394
+ throw new CreateContactsBatchError(
395
+ 'Could not complete batch process',
396
+ batchId,
397
+ batchProcess.messages
398
+ );
399
+ }
400
+
401
+ return batchProcess.status === BatchProcessStatus.pending
402
+ ? this.polling(batchId)
403
+ : batchProcess;
404
+ }
370
405
  }
package/src/types.ts CHANGED
@@ -1,8 +1,6 @@
1
1
  import { Token } from '@or-sdk/base';
2
2
  import {
3
3
  BatchProcessStatus,
4
- BulkContactDto,
5
- BulkCreateRequestDto,
6
4
  ContactBookParamsDto,
7
5
  CreateFieldSchemaDto,
8
6
  DeleteContactMultiParamsDto,
@@ -41,12 +39,6 @@ export type ContactsConfig = {
41
39
  * make many requests, for example for bulk operations.
42
40
  */
43
41
  withKeepAliveAgents?: boolean;
44
-
45
- /**
46
- * If true, the API error details like request url, params and body,
47
- * will be outputted to console
48
- */
49
- withApiErrorLog?: boolean;
50
42
  };
51
43
 
52
44
  export interface ContactBookParams extends AdaptedListParams<ContactBookParamsDto> {
@@ -76,11 +68,3 @@ export type TrackBatchProcessResponse = {
76
68
  };
77
69
 
78
70
  export type CreateFieldSchemaParams = CreateFieldSchemaDto & {presetIds?: string[];};
79
-
80
- export type BulkCreateData = Omit<BulkCreateRequestDto, 'batchId' | 'batchGroupId' | 'contacts'>
81
- & { contacts: OptionalBy<BulkContactDto, 'contactKey'>[]; };
82
-
83
- export type BatchBulkCreateData = Omit<BulkCreateRequestDto, 'batchId' | 'batchGroupId'>;
84
-
85
- export type CreateBulkResults = {created: Record<string, string>; failed: Record<string, string>;};
86
-
@@ -1,106 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
- return new (P || (P = Promise))(function (resolve, reject) {
20
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
- step((generator = generator.apply(thisArg, _arguments || [])).next());
24
- });
25
- };
26
- var __generator = (this && this.__generator) || function (thisArg, body) {
27
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
- function verb(n) { return function (v) { return step([n, v]); }; }
30
- function step(op) {
31
- if (f) throw new TypeError("Generator is already executing.");
32
- while (_) try {
33
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
- if (y = 0, t) op = [op[0] & 2, t.value];
35
- switch (op[0]) {
36
- case 0: case 1: t = op; break;
37
- case 4: _.label++; return { value: op[1], done: false };
38
- case 5: _.label++; y = op[1]; op = [0]; continue;
39
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
- default:
41
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
- if (t[2]) _.ops.pop();
46
- _.trys.pop(); continue;
47
- }
48
- op = body.call(thisArg, _);
49
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
- }
52
- };
53
- Object.defineProperty(exports, "__esModule", { value: true });
54
- var baseApi_1 = require("./baseApi");
55
- var types_contacts_api_1 = require("@onereach/types-contacts-api");
56
- var utils_1 = require("../utils");
57
- var constants_1 = require("../constants");
58
- var apiError_1 = require("../apiError");
59
- var BaseWithPoling = (function (_super) {
60
- __extends(BaseWithPoling, _super);
61
- function BaseWithPoling(apiCall, batchProcessApi) {
62
- var _this = _super.call(this, apiCall) || this;
63
- _this.apiCall = apiCall;
64
- _this.batchProcessApi = batchProcessApi;
65
- return _this;
66
- }
67
- BaseWithPoling.prototype.polling = function (batchId, repeats) {
68
- if (repeats === void 0) { repeats = 0; }
69
- return __awaiter(this, void 0, void 0, function () {
70
- var batchProcess, e_1;
71
- var _this = this;
72
- return __generator(this, function (_a) {
73
- switch (_a.label) {
74
- case 0:
75
- _a.trys.push([0, 2, , 5]);
76
- return [4, (0, utils_1.debouncePromise)(function () { return _this.batchProcessApi.getBatchProcess(batchId); }, 1000)];
77
- case 1:
78
- batchProcess = _a.sent();
79
- return [3, 5];
80
- case 2:
81
- e_1 = _a.sent();
82
- if (!(repeats < constants_1.FAILED_REQUEST_REPEATS
83
- && 'statusCode' in e_1
84
- && e_1.statusCode === 410)) return [3, 4];
85
- return [4, (0, utils_1.debouncePromise)(function () { return _this.polling(batchId, repeats + 1); }, 2000)];
86
- case 3: return [2, _a.sent()];
87
- case 4:
88
- if (repeats < constants_1.FAILED_REQUEST_REPEATS) {
89
- return [2, this.polling(batchId, repeats + 1)];
90
- }
91
- throw new apiError_1.CreateContactsBatchError(e_1.message, batchId);
92
- case 5:
93
- if (batchProcess.status === types_contacts_api_1.BatchProcessStatus.failed) {
94
- throw new apiError_1.CreateContactsBatchError('Could not complete batch process', batchId, batchProcess.messages);
95
- }
96
- return [2, batchProcess.status === types_contacts_api_1.BatchProcessStatus.pending
97
- ? this.polling(batchId)
98
- : batchProcess];
99
- }
100
- });
101
- });
102
- };
103
- return BaseWithPoling;
104
- }(baseApi_1.BaseApi));
105
- exports.default = BaseWithPoling;
106
- //# sourceMappingURL=baseWithPolingApi.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"baseWithPolingApi.js","sourceRoot":"","sources":["../../../src/api/baseWithPolingApi.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,qCAAoC;AAEpC,mEAA2F;AAC3F,kCAA2C;AAC3C,0CAAsD;AACtD,wCAAiE;AAEjE;IAA4C,kCAAO;IACjD,wBACqB,OAAgD,EACzD,eAAgC;QAF5C,YAIE,kBAAM,OAAO,CAAC,SACf;QA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var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __assign = (this && this.__assign) || function () {
18
- __assign = Object.assign || function(t) {
19
- for (var s, i = 1, n = arguments.length; i < n; i++) {
20
- s = arguments[i];
21
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
- t[p] = s[p];
23
- }
24
- return t;
25
- };
26
- return __assign.apply(this, arguments);
27
- };
28
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
29
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
30
- return new (P || (P = Promise))(function (resolve, reject) {
31
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
32
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
33
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
34
- step((generator = generator.apply(thisArg, _arguments || [])).next());
35
- });
36
- };
37
- var __generator = (this && this.__generator) || function (thisArg, body) {
38
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
39
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
40
- function verb(n) { return function (v) { return step([n, v]); }; }
41
- function step(op) {
42
- if (f) throw new TypeError("Generator is already executing.");
43
- while (_) try {
44
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
45
- if (y = 0, t) op = [op[0] & 2, t.value];
46
- switch (op[0]) {
47
- case 0: case 1: t = op; break;
48
- case 4: _.label++; return { value: op[1], done: false };
49
- case 5: _.label++; y = op[1]; op = [0]; continue;
50
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
51
- default:
52
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
53
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
54
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
55
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
56
- if (t[2]) _.ops.pop();
57
- _.trys.pop(); continue;
58
- }
59
- op = body.call(thisArg, _);
60
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
61
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
62
- }
63
- };
64
- var __rest = (this && this.__rest) || function (s, e) {
65
- var t = {};
66
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
67
- t[p] = s[p];
68
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
69
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
70
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
71
- t[p[i]] = s[p[i]];
72
- }
73
- return t;
74
- };
75
- var __importDefault = (this && this.__importDefault) || function (mod) {
76
- return (mod && mod.__esModule) ? mod : { "default": mod };
77
- };
78
- Object.defineProperty(exports, "__esModule", { value: true });
79
- var baseWithPolingApi_1 = __importDefault(require("./baseWithPolingApi"));
80
- var constants_1 = require("../constants");
81
- var utils_1 = require("../utils");
82
- var uuid_1 = require("uuid");
83
- var BulkContactsCreateApi = (function (_super) {
84
- __extends(BulkContactsCreateApi, _super);
85
- function BulkContactsCreateApi(apiCall, batchProcessApi) {
86
- var _this = _super.call(this, apiCall, batchProcessApi) || this;
87
- _this.apiCall = apiCall;
88
- _this.batchProcessApi = batchProcessApi;
89
- _this.apiBasePath = 'bulk-create';
90
- return _this;
91
- }
92
- BulkContactsCreateApi.prototype.bulkCreateContacts = function (data) {
93
- return __awaiter(this, void 0, void 0, function () {
94
- var dataWithContactKeys, contacts, rest, contactsMaxSize, contactsChunks, batchGroupId;
95
- return __generator(this, function (_a) {
96
- switch (_a.label) {
97
- case 0:
98
- dataWithContactKeys = __assign(__assign({}, data), { contacts: data.contacts.map(function (c, idx) {
99
- return c.contactKey ? c : __assign(__assign({}, c), { contactKey: "".concat(idx) });
100
- }) });
101
- contacts = dataWithContactKeys.contacts, rest = __rest(dataWithContactKeys, ["contacts"]);
102
- contactsMaxSize = constants_1.REQUEST_PAYLOAD_MAX_BYTES - (0, utils_1.getObjectSizeInBytes)(__assign({}, rest));
103
- contactsChunks = (0, utils_1.chunkArrByMaxSize)(contacts, contactsMaxSize);
104
- batchGroupId = (0, uuid_1.v4)();
105
- if (!(contactsChunks.length === 1)) return [3, 2];
106
- return [4, this.createContactsInSingleBatch(dataWithContactKeys, batchGroupId)];
107
- case 1:
108
- _a.sent();
109
- return [3, 4];
110
- case 2: return [4, this.createContactsInMultiBatches(contactsChunks, rest, batchGroupId)];
111
- case 3:
112
- _a.sent();
113
- _a.label = 4;
114
- case 4: return [2, this.getBulkCreateResults(batchGroupId)];
115
- }
116
- });
117
- });
118
- };
119
- BulkContactsCreateApi.prototype.getBulkCreateResults = function (batchGroupId) {
120
- return __awaiter(this, void 0, void 0, function () {
121
- var batchProcessesGroup;
122
- return __generator(this, function (_a) {
123
- switch (_a.label) {
124
- case 0: return [4, this.batchProcessApi.getBatchProcessesGroup(batchGroupId)];
125
- case 1:
126
- batchProcessesGroup = _a.sent();
127
- return [2, batchProcessesGroup.reduce(function (acc, batch) {
128
- var createdContacts = batch.results.reduce(function (acc, result) { return (__assign(__assign({}, acc), JSON.parse(result))); }, {});
129
- var failedContacts = batch.messages.reduce(function (acc, message) { return (__assign(__assign({}, acc), JSON.parse(message))); }, {});
130
- return {
131
- created: __assign(__assign({}, acc.created), createdContacts),
132
- failed: __assign(__assign({}, acc.failed), failedContacts),
133
- };
134
- }, {
135
- created: {},
136
- failed: {},
137
- })];
138
- }
139
- });
140
- });
141
- };
142
- BulkContactsCreateApi.prototype.createContactsInSingleBatch = function (data, batchGroupId) {
143
- return __awaiter(this, void 0, void 0, function () {
144
- var batchId;
145
- var _this = this;
146
- return __generator(this, function (_a) {
147
- switch (_a.label) {
148
- case 0:
149
- batchId = (0, uuid_1.v4)();
150
- this.apiCall({
151
- method: 'POST',
152
- route: "".concat(this.apiBasePath, "/bulk"),
153
- data: __assign(__assign({}, data), { batchId: batchId, batchGroupId: batchGroupId }),
154
- });
155
- return [4, (0, utils_1.debouncePromise)(function () { return _this.polling(batchId); }, 3000)];
156
- case 1:
157
- _a.sent();
158
- return [2];
159
- }
160
- });
161
- });
162
- };
163
- BulkContactsCreateApi.prototype.createContactsInMultiBatches = function (contactsChunks, data, batchGroupId) {
164
- return __awaiter(this, void 0, void 0, function () {
165
- var batchPromises, promisesBatchSize, i, batch;
166
- var _this = this;
167
- return __generator(this, function (_a) {
168
- switch (_a.label) {
169
- case 0:
170
- batchPromises = contactsChunks
171
- .map(function (chunkContacts) { return function () { return __awaiter(_this, void 0, void 0, function () {
172
- return __generator(this, function (_a) {
173
- return [2, this.createContactsInSingleBatch(__assign({ contacts: chunkContacts }, data), batchGroupId)];
174
- });
175
- }); }; });
176
- promisesBatchSize = 4;
177
- i = 0;
178
- _a.label = 1;
179
- case 1:
180
- if (!(i < batchPromises.length)) return [3, 4];
181
- batch = batchPromises.slice(i, i + promisesBatchSize);
182
- return [4, Promise.all(batch.map(function (p) { return p(); }))];
183
- case 2:
184
- _a.sent();
185
- _a.label = 3;
186
- case 3:
187
- i += promisesBatchSize;
188
- return [3, 1];
189
- case 4: return [2];
190
- }
191
- });
192
- });
193
- };
194
- return BulkContactsCreateApi;
195
- }(baseWithPolingApi_1.default));
196
- exports.default = BulkContactsCreateApi;
197
- //# sourceMappingURL=bulkContactsCreateApi.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bulkContactsCreateApi.js","sourceRoot":"","sources":["../../../src/api/bulkContactsCreateApi.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,0EAAiD;AAEjD,0CAAyD;AACzD,kCAAoF;AACpF,6BAA0B;AAI1B;IAAmD,yCAAc;IAC/D,+BACqB,OAAgD,EACzD,eAAgC;QAF5C,YAIE,kBAAM,OAAO,EAAE,eAAe,CAAC,SAChC;QAJoB,aAAO,GAAP,OAAO,CAAyC;QACzD,qBAAe,GAAf,eAAe,CAAiB;QAK3B,iBAAW,GAAG,aAAa,CAAC;;IAF7C,CAAC;IAIK,kDAAkB,GAAxB,UACE,IAAoB;;;;;;wBAEd,mBAAmB,yBACpB,IAAI,KACP,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAC,CAAC,EAAE,GAAG;gCAAM,OAAO,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,uBAC7D,CAAC,KACJ,UAAU,EAAE,UAAG,GAAG,CAAE,GACrB,CAAC;4BAAA,CAAC,CAAC,GACL,CAAC;wBAEM,QAAQ,GAAc,mBAAmB,SAAjC,EAAK,IAAI,UAAK,mBAAmB,EAA3C,YAAqB,CAAF,CAAyB;wBAC5C,eAAe,GAAG,qCAAyB,GAAG,IAAA,4BAAoB,eAAM,IAAI,EAAG,CAAC;wBAChF,cAAc,GAAG,IAAA,yBAAiB,EAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;wBAE9D,YAAY,GAAG,IAAA,SAAE,GAAE,CAA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AAO,GAAG,IAAA,SAAE,GAAE,CAAC;wBACrB,IAAI,CAAC,OAAO,CAAC;4BACX,MAAM,EAAE,MAAM;4BACd,KAAK,EAAE,UAAG,IAAI,CAAC,WAAW,UAAO;4BACjC,IAAI,wBACC,IAAI,KACP,OAAO,SAAA,EACP,YAAY,cAAA,GACb;yBACF,CAAC,CAAC;wBAEH,WAAM,IAAA,uBAAe,EAAC,cAAM,OAAA,KAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAArB,CAAqB,EAAE,IAAI,CAAC,EAAA;;wBAAxD,SAAwD,CAAC;;;;;KAC1D;IAEa,4DAA4B,GAA1C,UACE,cAAkC,EAClC,IAAsC,EACtC,YAAoB;;;;;;;wBAEd,aAAa,GAAG,cAAc;6BACjC,GAAG,CAAC,UAAC,aAAa,IAAK,OAAA;;gCAAY,WAAA,IAAI,CAAC,2BAA2B,YAClE,QAAQ,EAAE,aAAa,IACpB,IAAI,GACN,YAAY,CAAC,EAAA;;6BAAA,EAHQ,CAGR,CAAC,CAAC;wBAEd,iBAAiB,GAAG,CAAC,CAAC;wBAEnB,CAAC,GAAG,CAAC;;;6BAAC,CAAA,CAAC,GAAG,aAAa,CAAC,MAAM,CAAA;wBAC/B,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,iBAAiB,CAAC,CAAC;wBAC5D,WAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,EAAE,EAAH,CAAG,CAAC,CAAC,EAAA;;wBAAxC,SAAwC,CAAC;;;wBAFH,CAAC,IAAI,iBAAiB,CAAA;;;;;;KAI/D;IAEH,4BAAC;AAAD,CAAC,AApGD,CAAmD,2BAAc,GAoGhE"}
@@ -1,47 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { BaseApi } from './baseApi';
11
- import { BatchProcessStatus } from '@onereach/types-contacts-api';
12
- import { debouncePromise } from '../utils';
13
- import { FAILED_REQUEST_REPEATS } from '../constants';
14
- import { CreateContactsBatchError } from '../apiError';
15
- export default class BaseWithPoling extends BaseApi {
16
- constructor(apiCall, batchProcessApi) {
17
- super(apiCall);
18
- this.apiCall = apiCall;
19
- this.batchProcessApi = batchProcessApi;
20
- }
21
- polling(batchId, repeats = 0) {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- let batchProcess;
24
- try {
25
- batchProcess = yield debouncePromise(() => this.batchProcessApi.getBatchProcess(batchId), 1000);
26
- }
27
- catch (e) {
28
- if (repeats < FAILED_REQUEST_REPEATS
29
- && 'statusCode' in e
30
- && e.statusCode === 410) {
31
- return yield debouncePromise(() => this.polling(batchId, repeats + 1), 2000);
32
- }
33
- if (repeats < FAILED_REQUEST_REPEATS) {
34
- return this.polling(batchId, repeats + 1);
35
- }
36
- throw new CreateContactsBatchError(e.message, batchId);
37
- }
38
- if (batchProcess.status === BatchProcessStatus.failed) {
39
- throw new CreateContactsBatchError('Could not complete batch process', batchId, batchProcess.messages);
40
- }
41
- return batchProcess.status === BatchProcessStatus.pending
42
- ? this.polling(batchId)
43
- : batchProcess;
44
- });
45
- }
46
- }
47
- //# sourceMappingURL=baseWithPolingApi.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"baseWithPolingApi.js","sourceRoot":"","sources":["../../../src/api/baseWithPolingApi.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAA2B,kBAAk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YAED,OAAO,YAAY,CAAC,MAAM,KAAK,kBAAkB,CAAC,OAAO;gBACvD,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;gBACvB,CAAC,CAAC,YAAY,CAAC;QACnB,CAAC;KAAA;CACF"}
@@ -1,92 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __rest = (this && this.__rest) || function (s, e) {
11
- var t = {};
12
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
13
- t[p] = s[p];
14
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
15
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
16
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
17
- t[p[i]] = s[p[i]];
18
- }
19
- return t;
20
- };
21
- import BaseWithPoling from './baseWithPolingApi';
22
- import { REQUEST_PAYLOAD_MAX_BYTES } from '../constants';
23
- import { chunkArrByMaxSize, debouncePromise, getObjectSizeInBytes } from '../utils';
24
- import { v4 } from 'uuid';
25
- export default class BulkContactsCreateApi extends BaseWithPoling {
26
- constructor(apiCall, batchProcessApi) {
27
- super(apiCall, batchProcessApi);
28
- this.apiCall = apiCall;
29
- this.batchProcessApi = batchProcessApi;
30
- this.apiBasePath = 'bulk-create';
31
- }
32
- bulkCreateContacts(data) {
33
- return __awaiter(this, void 0, void 0, function* () {
34
- const dataWithContactKeys = Object.assign(Object.assign({}, data), { contacts: data.contacts.map((c, idx) => {
35
- return c.contactKey ? c : Object.assign(Object.assign({}, c), { contactKey: `${idx}` });
36
- }) });
37
- const { contacts } = dataWithContactKeys, rest = __rest(dataWithContactKeys, ["contacts"]);
38
- const contactsMaxSize = REQUEST_PAYLOAD_MAX_BYTES - getObjectSizeInBytes(Object.assign({}, rest));
39
- const contactsChunks = chunkArrByMaxSize(contacts, contactsMaxSize);
40
- const batchGroupId = v4();
41
- if (contactsChunks.length === 1) {
42
- yield this.createContactsInSingleBatch(dataWithContactKeys, batchGroupId);
43
- }
44
- else {
45
- yield this.createContactsInMultiBatches(contactsChunks, rest, batchGroupId);
46
- }
47
- return this.getBulkCreateResults(batchGroupId);
48
- });
49
- }
50
- getBulkCreateResults(batchGroupId) {
51
- return __awaiter(this, void 0, void 0, function* () {
52
- const batchProcessesGroup = yield this.batchProcessApi.getBatchProcessesGroup(batchGroupId);
53
- return batchProcessesGroup.reduce((acc, batch) => {
54
- const createdContacts = batch.results.reduce((acc, result) => (Object.assign(Object.assign({}, acc), JSON.parse(result))), {});
55
- const failedContacts = batch.messages.reduce((acc, message) => (Object.assign(Object.assign({}, acc), JSON.parse(message))), {});
56
- return {
57
- created: Object.assign(Object.assign({}, acc.created), createdContacts),
58
- failed: Object.assign(Object.assign({}, acc.failed), failedContacts),
59
- };
60
- }, {
61
- created: {},
62
- failed: {},
63
- });
64
- });
65
- }
66
- createContactsInSingleBatch(data, batchGroupId) {
67
- return __awaiter(this, void 0, void 0, function* () {
68
- const batchId = v4();
69
- this.apiCall({
70
- method: 'POST',
71
- route: `${this.apiBasePath}/bulk`,
72
- data: Object.assign(Object.assign({}, data), { batchId,
73
- batchGroupId }),
74
- });
75
- yield debouncePromise(() => this.polling(batchId), 3000);
76
- });
77
- }
78
- createContactsInMultiBatches(contactsChunks, data, batchGroupId) {
79
- return __awaiter(this, void 0, void 0, function* () {
80
- const batchPromises = contactsChunks
81
- .map((chunkContacts) => () => __awaiter(this, void 0, void 0, function* () {
82
- return this.createContactsInSingleBatch(Object.assign({ contacts: chunkContacts }, data), batchGroupId);
83
- }));
84
- const promisesBatchSize = 4;
85
- for (let i = 0; i < batchPromises.length; i += promisesBatchSize) {
86
- const batch = batchPromises.slice(i, i + promisesBatchSize);
87
- yield Promise.all(batch.map((p) => p()));
88
- }
89
- });
90
- }
91
- }
92
- //# sourceMappingURL=bulkContactsCreateApi.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bulkContactsCreateApi.js","sourceRoot":"","sources":["../../../src/api/bulkContactsCreateApi.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AACA,OAAO,cAAc,MAAM,qBAAqB,CAAC;AAEjD,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AACpF,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAI1B,MAAM,CAAC,OAAO,OAAO,qBAAsB,SAAQ,cAAc;IAC/D,YACqB,OAAgD,EACzD,eAAgC;QAE1C,KAAK,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;QAHb,YAAO,GAAP,OAAO,CAAyC;QACzD,oBAAe,GAAf,eAAe,CAAiB;QAK3B,gBAAW,GAAG,aAAa,CAAC;IAF7C,CAAC;IAIK,kBAAkB,CACtB,IAAoB;;YAEpB,MAAM,mBAAmB,mCACpB,IAAI,KACP,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE;oBAAE,OAAO,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,iCAC7D,CAAC,KACJ,UAAU,EAAE,GAAG,GAAG,EAAE,GACrB,CAAC;gBAAA,CAAC,CAAC,GACL,CAAC;YAEF,MAAM,EAAE,QAAQ,KAAc,mBAAmB,EAA5B,IAAI,UAAK,mBAAmB,EAA3C,YAAqB,CAAsB,CAAC;YA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AAM,EAAE,EAAE;aACX,CAAC,CAAC;QACL,CAAC;KAAA;IAEa,2BAA2B,CACvC,IAAyB,EACzB,YAAoB;;YAEpB,MAAM,OAAO,GAAG,EAAE,EAAE,CAAC;YACrB,IAAI,CAAC,OAAO,CAAC;gBACX,MAAM,EAAE,MAAM;gBACd,KAAK,EAAE,GAAG,IAAI,CAAC,WAAW,OAAO;gBACjC,IAAI,kCACC,IAAI,KACP,OAAO;oBACP,YAAY,GACb;aACF,CAAC,CAAC;YAEH,MAAM,eAAe,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,CAAC;QAC3D,CAAC;KAAA;IAEa,4BAA4B,CACxC,cAAkC,EAClC,IAAsC,EACtC,YAAoB;;YAEpB,MAAM,aAAa,GAAG,cAAc;iBACjC,GAAG,CAAC,CAAC,aAAa,EAAE,EAAE,CAAC,GAAS,EAAE;gBAAC,OAAA,IAAI,CAAC,2BAA2B,iBAClE,QAAQ,EAAE,aAAa,IACpB,IAAI,GACN,YAAY,CAAC,CAAA;cAAA,CAAC,CAAC;YAEpB,MAAM,iBAAiB,GAAG,CAAC,CAAC;YAE5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAC,CAAC,GAAG,aAAa,CAAC,MAAM,EAAC,CAAC,IAAI,iBAAiB,EAAE;gBAC9D,MAAM,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,iBAAiB,CAAC,CAAC;gBAC5D,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;aAC1C;QACH,CAAC;KAAA;CAEF"}
@@ -1,11 +0,0 @@
1
- import { CalApiParams } from '@or-sdk/base';
2
- import { BaseApi } from './baseApi';
3
- import BatchProcessApi from './batchProcessApi';
4
- import { BatchProcessResponseDto } from '@onereach/types-contacts-api';
5
- export default class BaseWithPoling extends BaseApi {
6
- protected readonly apiCall: <T>(params: CalApiParams) => Promise<T>;
7
- protected batchProcessApi: BatchProcessApi;
8
- constructor(apiCall: <T>(params: CalApiParams) => Promise<T>, batchProcessApi: BatchProcessApi);
9
- protected polling(batchId: string, repeats?: number): Promise<BatchProcessResponseDto>;
10
- }
11
- //# sourceMappingURL=baseWithPolingApi.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"baseWithPolingApi.d.ts","sourceRoot":"","sources":["../../../src/api/baseWithPolingApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,uBAAuB,EAAsB,MAAM,8BAA8B,CAAC;AAK3F,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,OAAO;IAE/C,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,YAAY,KAAK,OAAO,CAAC,CAAC,CAAC;IACnE,SAAS,CAAC,eAAe,EAAE,eAAe;gBADvB,OAAO,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,YAAY,KAAK,OAAO,CAAC,CAAC,CAAC,EACzD,eAAe,EAAE,eAAe;cAQ5B,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,SAAI,GAAG,OAAO,CAAC,uBAAuB,CAAC;CA+BxF"}
@@ -1,15 +0,0 @@
1
- import { CalApiParams } from '@or-sdk/base';
2
- import BaseWithPoling from './baseWithPolingApi';
3
- import BatchProcessApi from './batchProcessApi';
4
- import { BulkCreateData, CreateBulkResults } from '../types';
5
- export default class BulkContactsCreateApi extends BaseWithPoling {
6
- protected readonly apiCall: <T>(params: CalApiParams) => Promise<T>;
7
- protected batchProcessApi: BatchProcessApi;
8
- constructor(apiCall: <T>(params: CalApiParams) => Promise<T>, batchProcessApi: BatchProcessApi);
9
- private readonly apiBasePath;
10
- bulkCreateContacts(data: BulkCreateData): Promise<CreateBulkResults>;
11
- private getBulkCreateResults;
12
- private createContactsInSingleBatch;
13
- private createContactsInMultiBatches;
14
- }
15
- //# sourceMappingURL=bulkContactsCreateApi.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bulkContactsCreateApi.d.ts","sourceRoot":"","sources":["../../../src/api/bulkContactsCreateApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,cAAc,MAAM,qBAAqB,CAAC;AACjD,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAKhD,OAAO,EAAuB,cAAc,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAElF,MAAM,CAAC,OAAO,OAAO,qBAAsB,SAAQ,cAAc;IAE7D,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,YAAY,KAAK,OAAO,CAAC,CAAC,CAAC;IACnE,SAAS,CAAC,eAAe,EAAE,eAAe;gBADvB,OAAO,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,YAAY,KAAK,OAAO,CAAC,CAAC,CAAC,EACzD,eAAe,EAAE,eAAe;IAK5C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAiB;IAEvC,kBAAkB,CACtB,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,iBAAiB,CAAC;YAwBf,oBAAoB;YA2BpB,2BAA2B;YAkB3B,4BAA4B;CAmB3C"}