@devrev/airsync-sdk 2.0.0-beta.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 (180) hide show
  1. package/README.md +31 -0
  2. package/dist/attachments-streaming/attachments-streaming-pool.d.ts +16 -0
  3. package/dist/attachments-streaming/attachments-streaming-pool.d.ts.map +1 -0
  4. package/dist/attachments-streaming/attachments-streaming-pool.interfaces.d.ts +9 -0
  5. package/dist/attachments-streaming/attachments-streaming-pool.interfaces.d.ts.map +1 -0
  6. package/dist/attachments-streaming/attachments-streaming-pool.interfaces.js +2 -0
  7. package/dist/attachments-streaming/attachments-streaming-pool.js +97 -0
  8. package/dist/attachments-streaming/attachments-streaming-pool.test.d.ts +2 -0
  9. package/dist/attachments-streaming/attachments-streaming-pool.test.d.ts.map +1 -0
  10. package/dist/attachments-streaming/attachments-streaming-pool.test.js +267 -0
  11. package/dist/common/constants.d.ts +25 -0
  12. package/dist/common/constants.d.ts.map +1 -0
  13. package/dist/common/constants.js +58 -0
  14. package/dist/common/control-protocol.d.ts +10 -0
  15. package/dist/common/control-protocol.d.ts.map +1 -0
  16. package/dist/common/control-protocol.js +31 -0
  17. package/dist/common/errors.d.ts +6 -0
  18. package/dist/common/errors.d.ts.map +1 -0
  19. package/dist/common/errors.js +4 -0
  20. package/dist/common/event-type-translation.d.ts +24 -0
  21. package/dist/common/event-type-translation.d.ts.map +1 -0
  22. package/dist/common/event-type-translation.js +117 -0
  23. package/dist/common/helpers.d.ts +41 -0
  24. package/dist/common/helpers.d.ts.map +1 -0
  25. package/dist/common/helpers.js +124 -0
  26. package/dist/common/install-initial-domain-mapping.d.ts +4 -0
  27. package/dist/common/install-initial-domain-mapping.d.ts.map +1 -0
  28. package/dist/common/install-initial-domain-mapping.js +58 -0
  29. package/dist/common/install-initial-domain-mapping.test.d.ts +2 -0
  30. package/dist/common/install-initial-domain-mapping.test.d.ts.map +1 -0
  31. package/dist/common/install-initial-domain-mapping.test.js +207 -0
  32. package/dist/deprecated/adapter/index.d.ts +62 -0
  33. package/dist/deprecated/adapter/index.d.ts.map +1 -0
  34. package/dist/deprecated/adapter/index.js +151 -0
  35. package/dist/deprecated/common/helpers.d.ts +7 -0
  36. package/dist/deprecated/common/helpers.d.ts.map +1 -0
  37. package/dist/deprecated/common/helpers.js +47 -0
  38. package/dist/deprecated/demo-extractor/external_domain_metadata.json +38 -0
  39. package/dist/deprecated/demo-extractor/index.d.ts +18 -0
  40. package/dist/deprecated/demo-extractor/index.d.ts.map +1 -0
  41. package/dist/deprecated/demo-extractor/index.js +161 -0
  42. package/dist/deprecated/http/client.d.ts +22 -0
  43. package/dist/deprecated/http/client.d.ts.map +1 -0
  44. package/dist/deprecated/http/client.js +161 -0
  45. package/dist/deprecated/uploader/index.d.ts +35 -0
  46. package/dist/deprecated/uploader/index.d.ts.map +1 -0
  47. package/dist/deprecated/uploader/index.js +161 -0
  48. package/dist/http/axios-client-internal.d.ts +3 -0
  49. package/dist/http/axios-client-internal.d.ts.map +1 -0
  50. package/dist/http/axios-client-internal.js +66 -0
  51. package/dist/http/axios-client-internal.test.d.ts +2 -0
  52. package/dist/http/axios-client-internal.test.d.ts.map +1 -0
  53. package/dist/http/axios-client-internal.test.js +154 -0
  54. package/dist/http/axios-client.d.ts +27 -0
  55. package/dist/http/axios-client.d.ts.map +1 -0
  56. package/dist/http/axios-client.js +57 -0
  57. package/dist/http/constants.d.ts +4 -0
  58. package/dist/http/constants.d.ts.map +1 -0
  59. package/dist/http/constants.js +6 -0
  60. package/dist/http/index.d.ts +3 -0
  61. package/dist/http/index.d.ts.map +1 -0
  62. package/dist/http/index.js +18 -0
  63. package/dist/http/types.d.ts +17 -0
  64. package/dist/http/types.d.ts.map +1 -0
  65. package/dist/http/types.js +2 -0
  66. package/dist/index.d.ts +14 -0
  67. package/dist/index.d.ts.map +1 -0
  68. package/dist/index.js +34 -0
  69. package/dist/logger/logger.constants.d.ts +6 -0
  70. package/dist/logger/logger.constants.d.ts.map +1 -0
  71. package/dist/logger/logger.constants.js +13 -0
  72. package/dist/logger/logger.context.d.ts +58 -0
  73. package/dist/logger/logger.context.d.ts.map +1 -0
  74. package/dist/logger/logger.context.js +86 -0
  75. package/dist/logger/logger.d.ts +89 -0
  76. package/dist/logger/logger.d.ts.map +1 -0
  77. package/dist/logger/logger.interfaces.d.ts +43 -0
  78. package/dist/logger/logger.interfaces.d.ts.map +1 -0
  79. package/dist/logger/logger.interfaces.js +9 -0
  80. package/dist/logger/logger.js +196 -0
  81. package/dist/logger/logger.test.d.ts +2 -0
  82. package/dist/logger/logger.test.d.ts.map +1 -0
  83. package/dist/logger/logger.test.js +490 -0
  84. package/dist/mappers/mappers.d.ts +52 -0
  85. package/dist/mappers/mappers.d.ts.map +1 -0
  86. package/dist/mappers/mappers.interface.d.ts +294 -0
  87. package/dist/mappers/mappers.interface.d.ts.map +1 -0
  88. package/dist/mappers/mappers.interface.js +48 -0
  89. package/dist/mappers/mappers.js +83 -0
  90. package/dist/mappers/mappers.test.d.ts +2 -0
  91. package/dist/mappers/mappers.test.d.ts.map +1 -0
  92. package/dist/mappers/mappers.test.js +107 -0
  93. package/dist/multithreading/create-worker.d.ts +5 -0
  94. package/dist/multithreading/create-worker.d.ts.map +1 -0
  95. package/dist/multithreading/create-worker.js +28 -0
  96. package/dist/multithreading/create-worker.test.d.ts +2 -0
  97. package/dist/multithreading/create-worker.test.d.ts.map +1 -0
  98. package/dist/multithreading/create-worker.test.js +89 -0
  99. package/dist/multithreading/process-task.d.ts +3 -0
  100. package/dist/multithreading/process-task.d.ts.map +1 -0
  101. package/dist/multithreading/process-task.js +58 -0
  102. package/dist/multithreading/spawn/spawn.d.ts +30 -0
  103. package/dist/multithreading/spawn/spawn.d.ts.map +1 -0
  104. package/dist/multithreading/spawn/spawn.helpers.d.ts +21 -0
  105. package/dist/multithreading/spawn/spawn.helpers.d.ts.map +1 -0
  106. package/dist/multithreading/spawn/spawn.helpers.js +114 -0
  107. package/dist/multithreading/spawn/spawn.helpers.test.d.ts +2 -0
  108. package/dist/multithreading/spawn/spawn.helpers.test.d.ts.map +1 -0
  109. package/dist/multithreading/spawn/spawn.helpers.test.js +293 -0
  110. package/dist/multithreading/spawn/spawn.js +249 -0
  111. package/dist/multithreading/worker-adapter/worker-adapter.artifacts.test.d.ts +2 -0
  112. package/dist/multithreading/worker-adapter/worker-adapter.artifacts.test.d.ts.map +1 -0
  113. package/dist/multithreading/worker-adapter/worker-adapter.artifacts.test.js +127 -0
  114. package/dist/multithreading/worker-adapter/worker-adapter.d.ts +91 -0
  115. package/dist/multithreading/worker-adapter/worker-adapter.d.ts.map +1 -0
  116. package/dist/multithreading/worker-adapter/worker-adapter.helpers.d.ts +22 -0
  117. package/dist/multithreading/worker-adapter/worker-adapter.helpers.d.ts.map +1 -0
  118. package/dist/multithreading/worker-adapter/worker-adapter.helpers.js +64 -0
  119. package/dist/multithreading/worker-adapter/worker-adapter.helpers.test.d.ts +2 -0
  120. package/dist/multithreading/worker-adapter/worker-adapter.helpers.test.d.ts.map +1 -0
  121. package/dist/multithreading/worker-adapter/worker-adapter.helpers.test.js +514 -0
  122. package/dist/multithreading/worker-adapter/worker-adapter.js +747 -0
  123. package/dist/multithreading/worker-adapter/worker-adapter.test.d.ts +2 -0
  124. package/dist/multithreading/worker-adapter/worker-adapter.test.d.ts.map +1 -0
  125. package/dist/multithreading/worker-adapter/worker-adapter.test.js +483 -0
  126. package/dist/multithreading/worker.d.ts +2 -0
  127. package/dist/multithreading/worker.d.ts.map +1 -0
  128. package/dist/multithreading/worker.js +9 -0
  129. package/dist/repo/repo.d.ts +18 -0
  130. package/dist/repo/repo.d.ts.map +1 -0
  131. package/dist/repo/repo.interfaces.d.ts +46 -0
  132. package/dist/repo/repo.interfaces.d.ts.map +1 -0
  133. package/dist/repo/repo.interfaces.js +2 -0
  134. package/dist/repo/repo.js +75 -0
  135. package/dist/repo/repo.test.d.ts +2 -0
  136. package/dist/repo/repo.test.d.ts.map +1 -0
  137. package/dist/repo/repo.test.js +131 -0
  138. package/dist/state/state.d.ts +30 -0
  139. package/dist/state/state.d.ts.map +1 -0
  140. package/dist/state/state.interfaces.d.ts +51 -0
  141. package/dist/state/state.interfaces.d.ts.map +1 -0
  142. package/dist/state/state.interfaces.js +21 -0
  143. package/dist/state/state.js +166 -0
  144. package/dist/state/state.test.d.ts +2 -0
  145. package/dist/state/state.test.d.ts.map +1 -0
  146. package/dist/state/state.test.js +224 -0
  147. package/dist/types/common.d.ts +50 -0
  148. package/dist/types/common.d.ts.map +1 -0
  149. package/dist/types/common.js +25 -0
  150. package/dist/types/extraction.d.ts +417 -0
  151. package/dist/types/extraction.d.ts.map +1 -0
  152. package/dist/types/extraction.js +170 -0
  153. package/dist/types/extraction.test.d.ts +2 -0
  154. package/dist/types/extraction.test.d.ts.map +1 -0
  155. package/dist/types/extraction.test.js +70 -0
  156. package/dist/types/index.d.ts +9 -0
  157. package/dist/types/index.d.ts.map +1 -0
  158. package/dist/types/index.js +18 -0
  159. package/dist/types/loading.d.ts +147 -0
  160. package/dist/types/loading.d.ts.map +1 -0
  161. package/dist/types/loading.js +48 -0
  162. package/dist/types/workers.d.ts +161 -0
  163. package/dist/types/workers.d.ts.map +1 -0
  164. package/dist/types/workers.js +22 -0
  165. package/dist/uploader/uploader.d.ts +92 -0
  166. package/dist/uploader/uploader.d.ts.map +1 -0
  167. package/dist/uploader/uploader.helpers.d.ts +33 -0
  168. package/dist/uploader/uploader.helpers.d.ts.map +1 -0
  169. package/dist/uploader/uploader.helpers.js +139 -0
  170. package/dist/uploader/uploader.helpers.test.d.ts +2 -0
  171. package/dist/uploader/uploader.helpers.test.d.ts.map +1 -0
  172. package/dist/uploader/uploader.helpers.test.js +267 -0
  173. package/dist/uploader/uploader.interfaces.d.ts +95 -0
  174. package/dist/uploader/uploader.interfaces.d.ts.map +1 -0
  175. package/dist/uploader/uploader.interfaces.js +2 -0
  176. package/dist/uploader/uploader.js +305 -0
  177. package/dist/uploader/uploader.test.d.ts +2 -0
  178. package/dist/uploader/uploader.test.d.ts.map +1 -0
  179. package/dist/uploader/uploader.test.js +589 -0
  180. package/package.json +60 -0
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=extraction.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extraction.test.d.ts","sourceRoot":"","sources":["../../src/types/extraction.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const test_helpers_1 = require("../tests/test-helpers");
4
+ const extraction_1 = require("./extraction");
5
+ // Test the EventContext interface and related extraction types
6
+ describe('ExtractionTypes', () => {
7
+ const baseEvent = (0, test_helpers_1.createEvent)({ eventType: extraction_1.EventType.ExtractionDataStart });
8
+ it('should create event context without optional fields', () => {
9
+ const event = Object.assign({}, baseEvent);
10
+ // If this compiles, the test passes
11
+ expect(event).toBeDefined();
12
+ expect(event.payload.event_context).toBeDefined();
13
+ });
14
+ it('should create event context with all optional fields', () => {
15
+ const event = Object.assign({}, baseEvent);
16
+ event.payload.event_context = Object.assign(Object.assign({}, baseEvent.payload.event_context), { extract_from: '2024-01-01T00:00:00Z', initial_sync_scope: extraction_1.InitialSyncScope.TIME_SCOPED, reset_extract_from: true });
17
+ expect(event).toBeDefined();
18
+ expect(event.payload.event_context.extract_from).toBe('2024-01-01T00:00:00Z');
19
+ expect(event.payload.event_context.initial_sync_scope).toBe(extraction_1.InitialSyncScope.TIME_SCOPED);
20
+ expect(event.payload.event_context.reset_extract_from).toBe(true);
21
+ });
22
+ it('should create event context with partial optional fields', () => {
23
+ const event = Object.assign({}, baseEvent);
24
+ event.payload.event_context = Object.assign(Object.assign({}, baseEvent.payload.event_context), { extract_from: '2024-01-01T00:00:00Z' });
25
+ expect(event).toBeDefined();
26
+ expect(event.payload.event_context.extract_from).toBe('2024-01-01T00:00:00Z');
27
+ });
28
+ it('should handle different InitialSyncScope values', () => {
29
+ const event = Object.assign({}, baseEvent);
30
+ event.payload.event_context = Object.assign(Object.assign({}, baseEvent.payload.event_context), { initial_sync_scope: extraction_1.InitialSyncScope.FULL_HISTORY });
31
+ expect(event.payload.event_context.initial_sync_scope).toBe(extraction_1.InitialSyncScope.FULL_HISTORY);
32
+ });
33
+ it('[edge] should handle null event context gracefully', () => {
34
+ const event = Object.assign({}, baseEvent);
35
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
36
+ event.payload.event_context = null;
37
+ expect(event.payload.event_context).toBeNull();
38
+ });
39
+ it('[edge] should handle undefined optional fields', () => {
40
+ const event = Object.assign({}, baseEvent);
41
+ event.payload.event_context = Object.assign(Object.assign({}, baseEvent.payload.event_context), { extract_from: undefined, initial_sync_scope: undefined, reset_extract_from: undefined });
42
+ expect(event.payload.event_context.extract_from).toBeUndefined();
43
+ expect(event.payload.event_context.initial_sync_scope).toBeUndefined();
44
+ expect(event.payload.event_context.reset_extract_from).toBeUndefined();
45
+ });
46
+ it('[edge] should handle invalid date format in extract_from', () => {
47
+ const event = Object.assign({}, baseEvent);
48
+ event.payload.event_context = Object.assign(Object.assign({}, baseEvent.payload.event_context), { extract_from: 'invalid-date-format' });
49
+ expect(event.payload.event_context.extract_from).toBe('invalid-date-format');
50
+ // Note: Type validation would typically happen at runtime, not compile time
51
+ });
52
+ it('[edge] should handle explicit boolean values for reset_extract_from', () => {
53
+ const eventWithTrue = (0, test_helpers_1.createEvent)({
54
+ eventType: extraction_1.EventType.ExtractionDataStart,
55
+ eventContextOverrides: {
56
+ reset_extract_from: true,
57
+ },
58
+ });
59
+ const eventWithFalse = (0, test_helpers_1.createEvent)({
60
+ eventType: extraction_1.EventType.ExtractionDataStart,
61
+ eventContextOverrides: {
62
+ reset_extract_from: false,
63
+ },
64
+ });
65
+ expect(eventWithTrue.payload.event_context.reset_extract_from).toBe(true);
66
+ expect(eventWithFalse.payload.event_context.reset_extract_from).toBe(false);
67
+ expect(typeof eventWithTrue.payload.event_context.reset_extract_from).toBe('boolean');
68
+ expect(typeof eventWithFalse.payload.event_context.reset_extract_from).toBe('boolean');
69
+ });
70
+ });
@@ -0,0 +1,9 @@
1
+ export { AdapterUpdateParams, ErrorLevel, ErrorRecord, InitialDomainMapping, LogRecord, SyncMode, } from './common';
2
+ export { AirdropEvent, AirdropMessage, ConnectionData, DomainObjectState, EventContextIn, EventContextOut, EventData, EventType, ExternalProcessAttachmentFunction, ExternalSyncUnit, ExternalSystemAttachmentIteratorFunction, ExternalSystemAttachmentReducerFunction, ExternalSystemAttachmentStreamingFunction, ExternalSystemAttachmentStreamingParams, ExternalSystemAttachmentStreamingResponse, ExtractionMode, ExtractorEvent, ExtractorEventType, ProcessAttachmentReturnType, } from './extraction';
3
+ export { ExternalSystemAttachment, ExternalSystemItem, ExternalSystemItemLoadingParams, ExternalSystemItemLoadingResponse, LoaderEventType, } from './loading';
4
+ export { NormalizedAttachment, NormalizedItem, RepoInterface, } from '../repo/repo.interfaces';
5
+ export { AdapterState } from '../state/state.interfaces';
6
+ export { Artifact, ArtifactsPrepareResponse, SsorAttachment, StreamAttachmentsResponse, StreamResponse, UploadResponse, } from '../uploader/uploader.interfaces';
7
+ export type { MappersCreateParams, MappersGetByExternalIdParams, MappersGetByTargetIdParams, MappersUpdateParams, } from '../mappers/mappers.interface';
8
+ export { SyncMapperRecordStatus, SyncMapperRecordTargetType, } from '../mappers/mappers.interface';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mBAAmB,EACnB,UAAU,EACV,WAAW,EACX,oBAAoB,EACpB,SAAS,EACT,QAAQ,GACT,MAAM,UAAU,CAAC;AAGlB,OAAO,EACL,YAAY,EACZ,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,SAAS,EACT,SAAS,EACT,iCAAiC,EACjC,gBAAgB,EAChB,wCAAwC,EACxC,uCAAuC,EACvC,yCAAyC,EACzC,uCAAuC,EACvC,yCAAyC,EACzC,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,2BAA2B,GAC5B,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EAClB,+BAA+B,EAC/B,iCAAiC,EACjC,eAAe,GAChB,MAAM,WAAW,CAAC;AAGnB,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,aAAa,GACd,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD,OAAO,EACL,QAAQ,EACR,wBAAwB,EACxB,cAAc,EACd,yBAAyB,EACzB,cAAc,EACd,cAAc,GACf,MAAM,iCAAiC,CAAC;AAGzC,YAAY,EACV,mBAAmB,EACnB,4BAA4B,EAC5B,0BAA0B,EAC1B,mBAAmB,GACpB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EACL,sBAAsB,EACtB,0BAA0B,GAC3B,MAAM,8BAA8B,CAAC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SyncMapperRecordTargetType = exports.SyncMapperRecordStatus = exports.LoaderEventType = exports.ExtractorEventType = exports.ExtractionMode = exports.EventType = exports.SyncMode = exports.ErrorLevel = void 0;
4
+ // Common
5
+ var common_1 = require("./common");
6
+ Object.defineProperty(exports, "ErrorLevel", { enumerable: true, get: function () { return common_1.ErrorLevel; } });
7
+ Object.defineProperty(exports, "SyncMode", { enumerable: true, get: function () { return common_1.SyncMode; } });
8
+ // Extraction
9
+ var extraction_1 = require("./extraction");
10
+ Object.defineProperty(exports, "EventType", { enumerable: true, get: function () { return extraction_1.EventType; } });
11
+ Object.defineProperty(exports, "ExtractionMode", { enumerable: true, get: function () { return extraction_1.ExtractionMode; } });
12
+ Object.defineProperty(exports, "ExtractorEventType", { enumerable: true, get: function () { return extraction_1.ExtractorEventType; } });
13
+ // Loading
14
+ var loading_1 = require("./loading");
15
+ Object.defineProperty(exports, "LoaderEventType", { enumerable: true, get: function () { return loading_1.LoaderEventType; } });
16
+ var mappers_interface_1 = require("../mappers/mappers.interface");
17
+ Object.defineProperty(exports, "SyncMapperRecordStatus", { enumerable: true, get: function () { return mappers_interface_1.SyncMapperRecordStatus; } });
18
+ Object.defineProperty(exports, "SyncMapperRecordTargetType", { enumerable: true, get: function () { return mappers_interface_1.SyncMapperRecordTargetType; } });
@@ -0,0 +1,147 @@
1
+ import { Mappers } from '../mappers/mappers';
2
+ import { ErrorRecord } from './common';
3
+ import { AirdropEvent } from './extraction';
4
+ export interface StatsFileObject {
5
+ id: string;
6
+ item_type: string;
7
+ file_name: string;
8
+ count: string;
9
+ }
10
+ export interface FileToLoad {
11
+ id: string;
12
+ file_name: string;
13
+ itemType: string;
14
+ count: number;
15
+ lineToProcess: number;
16
+ completed: boolean;
17
+ }
18
+ export interface ExternalSystemAttachment {
19
+ reference_id: DonV2;
20
+ parent_type: string;
21
+ parent_reference_id: DonV2;
22
+ file_name: string;
23
+ file_type: string;
24
+ file_size: number;
25
+ url: string;
26
+ valid_until: string;
27
+ created_by_id: string;
28
+ created_date: string;
29
+ modified_by_id: string;
30
+ modified_date: string;
31
+ parent_id?: string;
32
+ grand_parent_id?: string;
33
+ }
34
+ export interface ExternalSystemItem {
35
+ id: {
36
+ devrev: DonV2;
37
+ external?: string;
38
+ };
39
+ created_date: string;
40
+ modified_date: string;
41
+ data: any;
42
+ }
43
+ export interface ExternalSystemItem {
44
+ id: {
45
+ devrev: DonV2;
46
+ external?: string;
47
+ };
48
+ created_date: string;
49
+ modified_date: string;
50
+ data: any;
51
+ }
52
+ export interface ExternalSystemItemLoadingParams<Type> {
53
+ item: Type;
54
+ mappers: Mappers;
55
+ event: AirdropEvent;
56
+ }
57
+ export interface ExternalSystemItemLoadingResponse {
58
+ id?: string;
59
+ error?: string;
60
+ modifiedDate?: string;
61
+ delay?: number;
62
+ }
63
+ export interface ExternalSystemItemLoadedItem {
64
+ id?: string;
65
+ error?: string;
66
+ modifiedDate?: string;
67
+ }
68
+ export type ExternalSystemLoadingFunction<Item> = ({ item, mappers, event, }: ExternalSystemItemLoadingParams<Item>) => Promise<ExternalSystemItemLoadingResponse>;
69
+ export interface ItemTypeToLoad {
70
+ itemType: string;
71
+ create: ExternalSystemLoadingFunction<ExternalSystemItem>;
72
+ update: ExternalSystemLoadingFunction<ExternalSystemItem>;
73
+ }
74
+ export interface ItemTypesToLoadParams {
75
+ itemTypesToLoad: ItemTypeToLoad[];
76
+ }
77
+ export interface LoaderReport {
78
+ item_type: string;
79
+ [ActionType.CREATED]?: number;
80
+ [ActionType.UPDATED]?: number;
81
+ [ActionType.SKIPPED]?: number;
82
+ [ActionType.DELETED]?: number;
83
+ [ActionType.FAILED]?: number;
84
+ }
85
+ export interface RateLimited {
86
+ delay: number;
87
+ }
88
+ export interface LoadItemResponse {
89
+ error?: ErrorRecord;
90
+ report?: LoaderReport;
91
+ rateLimit?: RateLimited;
92
+ }
93
+ export interface LoadItemTypesResponse {
94
+ reports: LoaderReport[];
95
+ processed_files: string[];
96
+ }
97
+ export declare enum ActionType {
98
+ CREATED = "created",
99
+ UPDATED = "updated",
100
+ SKIPPED = "skipped",
101
+ DELETED = "deleted",
102
+ FAILED = "failed"
103
+ }
104
+ export type DonV2 = string;
105
+ export type SyncMapperRecord = {
106
+ external_ids: string[];
107
+ secondary_ids: string[];
108
+ devrev_ids: string[];
109
+ status: string[];
110
+ input_file?: string;
111
+ };
112
+ export declare enum LoaderEventType {
113
+ DataLoadingProgress = "DATA_LOADING_PROGRESS",
114
+ /**
115
+ * @deprecated This was a typo. Use DataLoadingDelayed for the corrected spelling
116
+ */
117
+ DataLoadingDelay = "DATA_LOADING_DELAYED",
118
+ DataLoadingDone = "DATA_LOADING_DONE",
119
+ DataLoadingError = "DATA_LOADING_ERROR",
120
+ AttachmentLoadingProgress = "ATTACHMENT_LOADING_PROGRESS",
121
+ AttachmentLoadingDelayed = "ATTACHMENT_LOADING_DELAYED",
122
+ AttachmentLoadingDone = "ATTACHMENT_LOADING_DONE",
123
+ AttachmentLoadingError = "ATTACHMENT_LOADING_ERROR",
124
+ LoaderStateDeletionDone = "LOADER_STATE_DELETION_DONE",
125
+ LoaderStateDeletionError = "LOADER_STATE_DELETION_ERROR",
126
+ LoaderAttachmentStateDeletionDone = "LOADER_ATTACHMENT_STATE_DELETION_DONE",
127
+ LoaderAttachmentStateDeletionError = "LOADER_ATTACHMENT_STATE_DELETION_ERROR",
128
+ UnknownEventType = "UNKNOWN_EVENT_TYPE",
129
+ DataLoadingDelayed = "DATA_LOADING_DELAYED",
130
+ /**
131
+ * @deprecated Use AttachmentsLoadingProgress instead (note: singular changed to plural)
132
+ */
133
+ AttachmentsLoadingProgress = "ATTACHMENT_LOADING_PROGRESS",
134
+ /**
135
+ * @deprecated Use AttachmentsLoadingDelayed instead (note: singular changed to plural)
136
+ */
137
+ AttachmentsLoadingDelayed = "ATTACHMENT_LOADING_DELAYED",
138
+ /**
139
+ * @deprecated Use AttachmentsLoadingDone instead (note: singular changed to plural)
140
+ */
141
+ AttachmentsLoadingDone = "ATTACHMENT_LOADING_DONE",
142
+ /**
143
+ * @deprecated Use AttachmentsLoadingError instead (note: singular changed to plural)
144
+ */
145
+ AttachmentsLoadingError = "ATTACHMENT_LOADING_ERROR"
146
+ }
147
+ //# sourceMappingURL=loading.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loading.d.ts","sourceRoot":"","sources":["../../src/types/loading.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MA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AM,CAAC,EAAE,YAAY,CAAC;IACtB,SAAS,CAAC,EAAE,WAAW,CAAC;CACzB;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,oBAAY,UAAU;IACpB,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,MAAM,WAAW;CAClB;AAED,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC;AAE3B,MAAM,MAAM,gBAAgB,GAAG;IAC7B,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAGF,oBAAY,eAAe;IACzB,mBAAmB,0BAA0B;IAC7C;;OAEG;IACH,gBAAgB,yBAAyB;IACzC,eAAe,sBAAsB;IACrC,gBAAgB,uBAAuB;IAEvC,yBAAyB,gCAAgC;IACzD,wBAAwB,+BAA+B;IACvD,qBAAqB,4BAA4B;IACjD,sBAAsB,6BAA6B;IAEnD,uBAAuB,+BAA+B;IACtD,wBAAwB,gCAAgC;IAExD,iCAAiC,0CAA0C;IAC3E,kCAAkC,2CAA2C;IAE7E,gBAAgB,uBAAuB;IACvC,kBAAkB,yBAAyB;IAE3C;;OAEG;IACH,0BAA0B,gCAAgC;IAC1D;;OAEG;IACH,yBAAyB,+BAA+B;IACxD;;OAEG;IACH,sBAAsB,4BAA4B;IAClD;;OAEG;IACH,uBAAuB,6BAA6B;CACrD"}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LoaderEventType = exports.ActionType = void 0;
4
+ var ActionType;
5
+ (function (ActionType) {
6
+ ActionType["CREATED"] = "created";
7
+ ActionType["UPDATED"] = "updated";
8
+ ActionType["SKIPPED"] = "skipped";
9
+ ActionType["DELETED"] = "deleted";
10
+ ActionType["FAILED"] = "failed";
11
+ })(ActionType || (exports.ActionType = ActionType = {}));
12
+ /* eslint-disable @typescript-eslint/no-duplicate-enum-values */
13
+ var LoaderEventType;
14
+ (function (LoaderEventType) {
15
+ LoaderEventType["DataLoadingProgress"] = "DATA_LOADING_PROGRESS";
16
+ /**
17
+ * @deprecated This was a typo. Use DataLoadingDelayed for the corrected spelling
18
+ */
19
+ LoaderEventType["DataLoadingDelay"] = "DATA_LOADING_DELAYED";
20
+ LoaderEventType["DataLoadingDone"] = "DATA_LOADING_DONE";
21
+ LoaderEventType["DataLoadingError"] = "DATA_LOADING_ERROR";
22
+ LoaderEventType["AttachmentLoadingProgress"] = "ATTACHMENT_LOADING_PROGRESS";
23
+ LoaderEventType["AttachmentLoadingDelayed"] = "ATTACHMENT_LOADING_DELAYED";
24
+ LoaderEventType["AttachmentLoadingDone"] = "ATTACHMENT_LOADING_DONE";
25
+ LoaderEventType["AttachmentLoadingError"] = "ATTACHMENT_LOADING_ERROR";
26
+ LoaderEventType["LoaderStateDeletionDone"] = "LOADER_STATE_DELETION_DONE";
27
+ LoaderEventType["LoaderStateDeletionError"] = "LOADER_STATE_DELETION_ERROR";
28
+ LoaderEventType["LoaderAttachmentStateDeletionDone"] = "LOADER_ATTACHMENT_STATE_DELETION_DONE";
29
+ LoaderEventType["LoaderAttachmentStateDeletionError"] = "LOADER_ATTACHMENT_STATE_DELETION_ERROR";
30
+ LoaderEventType["UnknownEventType"] = "UNKNOWN_EVENT_TYPE";
31
+ LoaderEventType["DataLoadingDelayed"] = "DATA_LOADING_DELAYED";
32
+ /**
33
+ * @deprecated Use AttachmentsLoadingProgress instead (note: singular changed to plural)
34
+ */
35
+ LoaderEventType["AttachmentsLoadingProgress"] = "ATTACHMENT_LOADING_PROGRESS";
36
+ /**
37
+ * @deprecated Use AttachmentsLoadingDelayed instead (note: singular changed to plural)
38
+ */
39
+ LoaderEventType["AttachmentsLoadingDelayed"] = "ATTACHMENT_LOADING_DELAYED";
40
+ /**
41
+ * @deprecated Use AttachmentsLoadingDone instead (note: singular changed to plural)
42
+ */
43
+ LoaderEventType["AttachmentsLoadingDone"] = "ATTACHMENT_LOADING_DONE";
44
+ /**
45
+ * @deprecated Use AttachmentsLoadingError instead (note: singular changed to plural)
46
+ */
47
+ LoaderEventType["AttachmentsLoadingError"] = "ATTACHMENT_LOADING_ERROR";
48
+ })(LoaderEventType || (exports.LoaderEventType = LoaderEventType = {}));
@@ -0,0 +1,161 @@
1
+ import { Worker } from 'worker_threads';
2
+ import type { LogLevel } from '../logger/logger.interfaces';
3
+ import { State } from '../state/state';
4
+ import { WorkerAdapter } from '../multithreading/worker-adapter/worker-adapter';
5
+ import { AirdropEvent, EventType, ExtractorEventType } from './extraction';
6
+ import { LoaderEventType } from './loading';
7
+ import { InitialDomainMapping } from './common';
8
+ /**
9
+ * WorkerAdapterInterface is an interface for WorkerAdapter class.
10
+ * @interface WorkerAdapterInterface
11
+ * @constructor
12
+ * @param {AirdropEvent} event - The event object received from the platform
13
+ * @param {object=} initialState - The initial state of the adapter
14
+ * @param {WorkerAdapterInterface} options - The options to create a new instance of WorkerAdapter class
15
+ */
16
+ export interface WorkerAdapterInterface<ConnectorState> {
17
+ event: AirdropEvent;
18
+ adapterState: State<ConnectorState>;
19
+ options?: WorkerAdapterOptions;
20
+ }
21
+ /**
22
+ * WorkerAdapterOptions represents the options for WorkerAdapter class.
23
+ * @interface WorkerAdapterOptions
24
+ * @constructor
25
+ * @param {boolean=} isLocalDevelopment - A flag to indicate if the adapter is being used in local development
26
+ * @param {number=} timeout - The timeout for the worker thread
27
+ * @param {number=} batchSize - Maximum number of extracted items in a batch
28
+ * @param {Record<EventType, string>=} workerPathOverrides - A map of event types to custom worker paths to override default worker paths
29
+ */
30
+ export interface WorkerAdapterOptions {
31
+ isLocalDevelopment?: boolean;
32
+ timeout?: number;
33
+ batchSize?: number;
34
+ workerPathOverrides?: WorkerPathOverrides;
35
+ }
36
+ /**
37
+ * SpawnInterface is an interface for Spawn class.
38
+ * @interface SpawnInterface
39
+ * @constructor
40
+ * @param {AirdropEvent} event - The event object received from the platform
41
+ * @param {Worker} worker - The worker thread
42
+ */
43
+ export interface SpawnInterface {
44
+ event: AirdropEvent;
45
+ worker: Worker;
46
+ options?: WorkerAdapterOptions;
47
+ resolve: (value: void | PromiseLike<void>) => void;
48
+ originalConsole?: Console;
49
+ }
50
+ /**
51
+ * SpawnFactoryInterface is an interface for Spawn class factory.
52
+ * Spawn class is responsible for spawning a new worker thread and managing the lifecycle of the worker.
53
+ * The class provides utilities to emit control events to the platform and exit the worker gracefully.
54
+ * In case of lambda timeout, the class emits a lambda timeout event to the platform.
55
+ * @interface SpawnFactoryInterface
56
+ * @constructor
57
+ * @param {AirdropEvent} event - The event object received from the platform
58
+ * @param {object=} initialState - The initial state of the adapter
59
+ * @param {string} workerPath - The path to the worker file
60
+ * @param {string} initialDomainMapping - The initial domain mapping
61
+ * @param {WorkerAdapterOptions} options - The options to create a new instance of Spawn class
62
+ * @param {string=} baseWorkerPath - The base path for the worker files, usually `__dirname`
63
+ */
64
+ export interface SpawnFactoryInterface<ConnectorState> {
65
+ event: AirdropEvent;
66
+ initialState: ConnectorState;
67
+ /** @deprecated Remove getWorkerPath function and use baseWorkerPath: __dirname instead of workerPath */
68
+ workerPath?: string;
69
+ options?: WorkerAdapterOptions;
70
+ initialDomainMapping?: InitialDomainMapping;
71
+ baseWorkerPath?: string;
72
+ }
73
+ /**
74
+ * TaskAdapterInterface is an interface for TaskAdapter class.
75
+ * @interface TaskAdapterInterface
76
+ * @constructor
77
+ * @param {WorkerAdapter} adapter - The adapter object
78
+ */
79
+ export interface TaskAdapterInterface<ConnectorState> {
80
+ adapter: WorkerAdapter<ConnectorState>;
81
+ }
82
+ /**
83
+ * ProcessTaskInterface is an interface for ProcessTask class.
84
+ * @interface ProcessTaskInterface
85
+ * @constructor
86
+ * @param {function} task - The task to be executed, returns exit code
87
+ * @param {function} onTimeout - The task to be executed on timeout, returns exit code
88
+ */
89
+ export interface ProcessTaskInterface<ConnectorState> {
90
+ task: (params: TaskAdapterInterface<ConnectorState>) => Promise<void>;
91
+ onTimeout: (params: TaskAdapterInterface<ConnectorState>) => Promise<void>;
92
+ }
93
+ /**
94
+ * WorkerEvent represents the standard worker events.
95
+ */
96
+ export declare enum WorkerEvent {
97
+ WorkerMessage = "message",
98
+ WorkerOnline = "online",
99
+ WorkerError = "error",
100
+ WorkerExit = "exit"
101
+ }
102
+ /**
103
+ * WorkerMessageSubject represents the handled worker message subjects.
104
+ */
105
+ export declare enum WorkerMessageSubject {
106
+ WorkerMessageEmitted = "emit",
107
+ WorkerMessageExit = "exit",
108
+ WorkerMessageLog = "log"
109
+ }
110
+ /**
111
+ * WorkerMessageEmitted interface represents the structure of the emitted worker message.
112
+ */
113
+ export interface WorkerMessageEmitted {
114
+ subject: WorkerMessageSubject.WorkerMessageEmitted;
115
+ payload: {
116
+ eventType: ExtractorEventType | LoaderEventType;
117
+ };
118
+ }
119
+ /**
120
+ * WorkerMessageExit interface represents the structure of the exit worker message.
121
+ */
122
+ export interface WorkerMessageExit {
123
+ subject: WorkerMessageSubject.WorkerMessageExit;
124
+ }
125
+ /**
126
+ * WorkerMessageLog interface represents the structure of the worker log message.
127
+ */
128
+ export interface WorkerMessageLog {
129
+ subject: WorkerMessageSubject.WorkerMessageLog;
130
+ payload: {
131
+ stringifiedArgs: string;
132
+ level: LogLevel;
133
+ isSdkLog?: boolean;
134
+ };
135
+ }
136
+ /**
137
+ * WorkerMessage represents the structure of the worker message.
138
+ */
139
+ export type WorkerMessage = WorkerMessageEmitted | WorkerMessageExit | WorkerMessageLog;
140
+ /**
141
+ * WorkerData represents the structure of the worker data object.
142
+ */
143
+ export interface WorkerData<ConnectorState> {
144
+ event: AirdropEvent;
145
+ initialState: ConnectorState;
146
+ workerPath: string;
147
+ initialDomainMapping?: InitialDomainMapping;
148
+ options?: WorkerAdapterOptions;
149
+ }
150
+ /**
151
+ * GetWorkerPathInterface is an interface for getting the worker path.
152
+ */
153
+ export interface GetWorkerPathInterface {
154
+ event: AirdropEvent;
155
+ workerBasePath?: string | null;
156
+ }
157
+ /**
158
+ * WorkerPathOverrides represents a mapping of event types to custom worker paths.
159
+ */
160
+ export type WorkerPathOverrides = Partial<Record<EventType, string>>;
161
+ //# sourceMappingURL=workers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workers.d.ts","sourceRoot":"","sources":["../../src/types/workers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,iDAAiD,CAAC;AAEhF,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAE3E,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAEhD;;;;;;;GAOG;AACH,MAAM,WAAW,sBAAsB,CAAC,cAAc;IACpD,KAAK,EAAE,YAAY,CAAC;IACpB,YAAY,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IACpC,OAAO,CAAC,EAAE,oBAAoB,CAAC;CAChC;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,oBAAoB;IACnC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;CAC3C;AAED;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,YAAY,CAAC;IACpB,MAAM,EAAE,MAAM,CA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MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,oBAAoB,CAAC,iBAAiB,CAAC;CACjD;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,oBAAoB,CAAC,gBAAgB,CAAC;IAC/C,OAAO,EAAE;QACP,eAAe,EAAE,MAAM,CAAC;QACxB,KAAK,EAAE,QAAQ,CAAC;QAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;KACpB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GACrB,oBAAoB,GACpB,iBAAiB,GACjB,gBAAgB,CAAC;AAErB;;GAEG;AACH,MAAM,WAAW,UAAU,CAAC,cAAc;IACxC,KAAK,EAAE,YAAY,CAAC;IACpB,YAAY,EAAE,cAAc,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAC5C,OAAO,CAAC,EAAE,oBAAoB,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,YAAY,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WorkerMessageSubject = exports.WorkerEvent = void 0;
4
+ /**
5
+ * WorkerEvent represents the standard worker events.
6
+ */
7
+ var WorkerEvent;
8
+ (function (WorkerEvent) {
9
+ WorkerEvent["WorkerMessage"] = "message";
10
+ WorkerEvent["WorkerOnline"] = "online";
11
+ WorkerEvent["WorkerError"] = "error";
12
+ WorkerEvent["WorkerExit"] = "exit";
13
+ })(WorkerEvent || (exports.WorkerEvent = WorkerEvent = {}));
14
+ /**
15
+ * WorkerMessageSubject represents the handled worker message subjects.
16
+ */
17
+ var WorkerMessageSubject;
18
+ (function (WorkerMessageSubject) {
19
+ WorkerMessageSubject["WorkerMessageEmitted"] = "emit";
20
+ WorkerMessageSubject["WorkerMessageExit"] = "exit";
21
+ WorkerMessageSubject["WorkerMessageLog"] = "log";
22
+ })(WorkerMessageSubject || (exports.WorkerMessageSubject = WorkerMessageSubject = {}));
@@ -0,0 +1,92 @@
1
+ import { AxiosResponse } from 'axios';
2
+ import { NormalizedAttachment } from '../repo/repo.interfaces';
3
+ import { ArtifactToUpload, UploadResponse, UploaderFactoryInterface, UploaderResult } from './uploader.interfaces';
4
+ export declare class Uploader {
5
+ private isLocalDevelopment?;
6
+ private devrevApiEndpoint;
7
+ private devrevApiToken;
8
+ private requestId;
9
+ private defaultHeaders;
10
+ constructor({ event, options }: UploaderFactoryInterface);
11
+ /**
12
+ * Uploads the fetched objects to the DevRev platform. Fetched objects are compressed to a gzipped jsonl object and uploaded to the platform.
13
+ * @param {string} itemType - The type of the item to be uploaded
14
+ * @param {object[] | object} fetchedObjects - The objects to be uploaded
15
+ * @returns {Promise<UploadResponse>} - The response object containing the artifact information or error information if there was an error
16
+ */
17
+ upload(itemType: string, fetchedObjects: object[] | object): Promise<UploadResponse>;
18
+ /**
19
+ * Gets the upload URL for an artifact from the DevRev API.
20
+ * @param {string} filename - The name of the file to upload
21
+ * @param {string} fileType - The MIME type of the file
22
+ * @param {number} [fileSize] - Optional file size in bytes
23
+ * @returns {Promise<ArtifactToUpload | void>} The artifact upload information or undefined on error
24
+ */
25
+ getArtifactUploadUrl(filename: string, fileType: string, fileSize?: number): Promise<UploaderResult<ArtifactToUpload>>;
26
+ /**
27
+ * Uploads an artifact file to the provided upload URL using multipart form data.
28
+ * @param {ArtifactToUpload} artifact - The artifact upload information containing upload URL and form data
29
+ * @param {Buffer} file - The file buffer to upload
30
+ * @returns {Promise<AxiosResponse | void>} The axios response or undefined on error
31
+ */
32
+ uploadArtifact(artifact: ArtifactToUpload, file: Buffer): Promise<UploaderResult<AxiosResponse>>;
33
+ /**
34
+ * Streams an artifact file from an axios response to the upload URL.
35
+ * @param {ArtifactToUpload} artifact - The artifact upload information containing upload URL and form data
36
+ * @param {AxiosResponse} fileStream - The axios response stream containing the file data
37
+ * @returns {Promise<AxiosResponse | void>} The axios response or undefined on error
38
+ */
39
+ streamArtifact(artifact: ArtifactToUpload, fileStream: AxiosResponse): Promise<UploaderResult<AxiosResponse>>;
40
+ /**
41
+ * Confirms that an artifact upload has been completed successfully.
42
+ * @param {string} artifactId - The ID of the artifact to confirm
43
+ * @returns {Promise<AxiosResponse | void>} The axios response or undefined on error
44
+ */
45
+ confirmArtifactUpload(artifactId: string): Promise<{
46
+ response?: AxiosResponse;
47
+ error?: unknown;
48
+ }>;
49
+ /**
50
+ * Destroys a stream to prevent resource leaks.
51
+ * @param {any} fileStream - The axios response stream to destroy
52
+ */
53
+ private destroyStream;
54
+ /**
55
+ * Retrieves attachment metadata from an artifact by downloading and parsing it.
56
+ * @param {object} param0 - Configuration object
57
+ * @param {string} param0.artifact - The artifact ID to download attachments from
58
+ * @returns {Promise<{attachments?: NormalizedAttachment[], error?: {message: string}}>} The attachments array or error object
59
+ */
60
+ getAttachmentsFromArtifactId({ artifact, }: {
61
+ artifact: string;
62
+ }): Promise<{
63
+ attachments?: NormalizedAttachment[];
64
+ error?: {
65
+ message: string;
66
+ };
67
+ }>;
68
+ /**
69
+ * Gets the download URL for an artifact from the DevRev API.
70
+ * @param {string} artifactId - The ID of the artifact to download
71
+ * @returns {Promise<string | void>} The download URL or undefined on error
72
+ */
73
+ private getArtifactDownloadUrl;
74
+ /**
75
+ * Downloads an artifact file from the given URL.
76
+ * @param {string} artifactUrl - The URL to download the artifact from
77
+ * @returns {Promise<Buffer | void>} The artifact file buffer or undefined on error
78
+ */
79
+ private downloadArtifact;
80
+ /**
81
+ * Retrieves and parses JSON objects from an artifact by artifact ID.
82
+ * @param {object} param0 - Configuration object
83
+ * @param {string} param0.artifactId - The artifact ID to download and parse
84
+ * @param {boolean} [param0.isGzipped=false] - Whether the artifact is gzipped
85
+ * @returns {Promise<object[] | object | void>} The parsed JSON objects or undefined on error
86
+ */
87
+ getJsonObjectByArtifactId({ artifactId, isGzipped, }: {
88
+ artifactId: string;
89
+ isGzipped?: boolean;
90
+ }): Promise<UploaderResult<object[] | object>>;
91
+ }
92
+ //# sourceMappingURL=uploader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uploader.d.ts","sourceRoot":"","sources":["../../src/uploader/uploader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAMtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAU/D,OAAO,EAEL,gBAAgB,EAChB,cAAc,EACd,wBAAwB,EACxB,cAAc,EACf,MAAM,uBAAuB,CAAC;AAE/B,qBAAa,QAAQ;IACnB,OAAO,CAAC,kBAAkB,CAAC,CAAU;IACrC,OAAO,CAAC,iBAAiB,CAAS;IAClC,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,cAAc,CAAyB;gBAEnC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,wBAAwB;IAUxD;;;;;OAKG;IACG,MAAM,CACV,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,MAAM,EAAE,GAAG,MAAM,GAChC,OAAO,CAAC,cAAc,CAAC;IA6D1B;;;;;;OAMG;IACG,oBAAoB,CACxB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC;IAqB5C;;;;;OAKG;IACG,cAAc,CAClB,QAAQ,EAAE,gBAAgB,EAC1B,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;IAmBzC;;;;;OAKG;IACG,cAAc,CAClB,QAAQ,EAAE,gBAAgB,EAC1B,UAAU,EAAE,aAAa,GACxB,OAAO,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;IA8BzC;;;;OAIG;IACG,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC;QACvD,QAAQ,CAAC,EAAE,aAAa,CAAC;QACzB,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB,CAAC;IAgCF;;;OAGG;IACH,OAAO,CAAC,aAAa;IAerB;;;;;OAKG;IACG,4BAA4B,CAAC,EACjC,QAAQ,GACT,EAAE;QACD,QAAQ,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC;QACV,WAAW,CAAC,EAAE,oBAAoB,EAAE,CAAC;QACrC,KAAK,CAAC,EAAE;YAAE,OAAO,EAAE,MAAM,CAAA;SAAE,CAAC;KAC7B,CAAC;IAsDF;;;;OAIG;YACW,sBAAsB;IAsBpC;;;;OAIG;YACW,gBAAgB;IAc9B;;;;;;OAMG;IACG,yBAAyB,CAAC,EAC9B,UAAU,EACV,SAAiB,GAClB,EAAE;QACD,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE,OAAO,CAAC;KACrB,GAAG,OAAO,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC;CA6B/C"}
@@ -0,0 +1,33 @@
1
+ import { UploaderResult } from './uploader.interfaces';
2
+ /**
3
+ * Compresses a JSONL string using gzip compression.
4
+ * @param {string} jsonlObject - The JSONL string to compress
5
+ * @returns {Buffer | void} The compressed buffer or undefined on error
6
+ */
7
+ export declare function compressGzip(jsonlObject: string): UploaderResult<Buffer>;
8
+ /**
9
+ * Decompresses a gzipped buffer to a JSONL string.
10
+ * @param {Buffer} gzippedJsonlObject - The gzipped buffer to decompress
11
+ * @returns {string | void} The decompressed JSONL string or undefined on error
12
+ */
13
+ export declare function decompressGzip(gzippedJsonlObject: Buffer): UploaderResult<string>;
14
+ /**
15
+ * Parses a JSONL string into an array of objects.
16
+ * @param {string} jsonlObject - The JSONL string to parse
17
+ * @returns {object[] | null} The parsed array of objects or null on error
18
+ */
19
+ export declare function parseJsonl(jsonlObject: string): UploaderResult<object[]>;
20
+ /**
21
+ * Downloads fetched objects to the local file system (for local development).
22
+ * @param {string} itemType - The type of items being downloaded
23
+ * @param {object | object[]} fetchedObjects - The objects to write to file
24
+ * @returns {Promise<void>} Resolves when the file is written or rejects on error
25
+ */
26
+ export declare function downloadToLocal(itemType: string, fetchedObjects: object | object[]): Promise<void>;
27
+ /**
28
+ * Truncates a filename if it exceeds the maximum allowed length.
29
+ * @param {string} filename - The filename to truncate
30
+ * @returns {string} The truncated filename
31
+ */
32
+ export declare function truncateFilename(filename: string): string;
33
+ //# sourceMappingURL=uploader.helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uploader.helpers.d.ts","sourceRoot":"","sources":["../../src/uploader/uploader.helpers.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,cAAc,CAAC,MAAM,CAAC,CAMxE;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,kBAAkB,EAAE,MAAM,GACzB,cAAc,CAAC,MAAM,CAAC,CAOxB;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,WAAW,EAAE,MAAM,GAAG,cAAc,CAAC,MAAM,EAAE,CAAC,CAMxE;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CACnC,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,MAAM,GAAG,MAAM,EAAE,GAChC,OAAO,CAAC,IAAI,CAAC,CA4Bf;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAmBzD"}