@devrev/ts-adaas 1.17.1-beta.4 → 1.17.1-beta.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.
package/dist/index.d.ts CHANGED
@@ -12,4 +12,6 @@ export { spawn } from './multithreading/spawn/spawn';
12
12
  export { WorkerAdapter } from './multithreading/worker-adapter/worker-adapter';
13
13
  export * from './types/workers';
14
14
  export { formatAxiosError, serializeAxiosError } from './logger/logger';
15
+ export { MockServer } from './mock-server/mock-server';
16
+ export type { RequestInfo, RetryConfig, RouteConfig, } from './mock-server/mock-server.interfaces';
15
17
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AAEtC,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AAExB,cAAc,yCAAyC,CAAC;AAExD,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,gDAAgD,CAAC;AAE/E,cAAc,iBAAiB,CAAC;AAEhC,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AAEtC,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AAExB,cAAc,yCAAyC,CAAC;AAExD,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,gDAAgD,CAAC;AAE/E,cAAc,iBAAiB,CAAC;AAEhC,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAExE,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,YAAY,EACV,WAAW,EACX,WAAW,EACX,WAAW,GACZ,MAAM,sCAAsC,CAAC"}
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.serializeAxiosError = exports.formatAxiosError = exports.WorkerAdapter = exports.spawn = exports.processTask = exports.AirSyncDefaultItemTypes = void 0;
17
+ exports.MockServer = exports.serializeAxiosError = exports.formatAxiosError = exports.WorkerAdapter = exports.spawn = exports.processTask = exports.AirSyncDefaultItemTypes = void 0;
18
18
  __exportStar(require("./deprecated/adapter"), exports);
19
19
  __exportStar(require("./deprecated/demo-extractor"), exports);
20
20
  __exportStar(require("./deprecated/http/client"), exports);
@@ -34,3 +34,5 @@ __exportStar(require("./types/workers"), exports);
34
34
  var logger_1 = require("./logger/logger");
35
35
  Object.defineProperty(exports, "formatAxiosError", { enumerable: true, get: function () { return logger_1.formatAxiosError; } });
36
36
  Object.defineProperty(exports, "serializeAxiosError", { enumerable: true, get: function () { return logger_1.serializeAxiosError; } });
37
+ var mock_server_1 = require("./mock-server/mock-server");
38
+ Object.defineProperty(exports, "MockServer", { enumerable: true, get: function () { return mock_server_1.MockServer; } });
@@ -0,0 +1,80 @@
1
+ import { RequestInfo, RouteConfig } from './mock-server.interfaces';
2
+ /**
3
+ * MockServer used in tests to mock internal AirSync endpoints.
4
+ * This is a simple mock server that listens on a port and responds to requests.
5
+ * Supports per-test route configuration to simulate different response scenarios.
6
+ */
7
+ export declare class MockServer {
8
+ private app;
9
+ private server;
10
+ private internalPort;
11
+ port: number;
12
+ baseUrl: string;
13
+ private routeHandlers;
14
+ private requests;
15
+ private requestCounts;
16
+ constructor(port?: number);
17
+ start(): Promise<void>;
18
+ stop(): Promise<void>;
19
+ /**
20
+ * Sets up routes for the mock server.
21
+ */
22
+ private setupRoutes;
23
+ /**
24
+ * Creates a route handler that checks for custom handlers before using the default.
25
+ * @param method - The HTTP method
26
+ * @param path - The route path
27
+ * @returns A route handler function
28
+ */
29
+ private routeHandler;
30
+ /**
31
+ * Default route handler for the mock server. Returns { success: true } for
32
+ * routes that are not explicitly set.
33
+ * @param req - The request object
34
+ * @param res - The response object
35
+ * @returns void
36
+ */
37
+ private defaultRouteHandler;
38
+ /**
39
+ * Gets the route key for a given method and path.
40
+ * @param method - The HTTP method
41
+ * @param path - The route path
42
+ * @returns The route key in the format 'METHOD:path'
43
+ */
44
+ private getRouteKey;
45
+ /**
46
+ * Configures a route to return a specific status code and optional response body.
47
+ * @param config - The route configuration object
48
+ * @param config.path - The path of the route (e.g., '/callback_url')
49
+ * @param config.method - The HTTP method (e.g., 'GET', 'POST')
50
+ * @param config.status - The HTTP status code to return (e.g., 200, 401, 500)
51
+ * @param config.body - Optional response body to send as JSON
52
+ * @param config.retry - Optional retry configuration for simulating failures before success
53
+ */
54
+ setRoute(config: RouteConfig): void;
55
+ /**
56
+ * Resets all custom route handlers, restoring all default handlers.
57
+ * Also clears request tracking data.
58
+ */
59
+ resetRoutes(): void;
60
+ /**
61
+ * Returns the most recent request or undefined if no requests exist.
62
+ * @returns The last RequestInfo object or undefined
63
+ */
64
+ getLastRequest(): RequestInfo | undefined;
65
+ /**
66
+ * Gets the number of requests made to a specific endpoint.
67
+ * @param method - The HTTP method (e.g., 'GET', 'POST')
68
+ * @param path - The route path (e.g., '/test-endpoint', '/callback_url')
69
+ * @returns The number of requests made to the endpoint
70
+ */
71
+ getRequestCount(method: string, path: string): number;
72
+ /**
73
+ * Gets all requests made to a specific endpoint.
74
+ * @param method - The HTTP method (e.g., 'GET', 'POST')
75
+ * @param path - The route path (e.g., '/test-endpoint', '/callback_url')
76
+ * @returns An array of RequestInfo objects for the endpoint
77
+ */
78
+ getRequests(method: string, path: string): RequestInfo[];
79
+ }
80
+ //# sourceMappingURL=mock-server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mock-server.d.ts","sourceRoot":"","sources":["../../src/mock-server/mock-server.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,WAAW,EACX,WAAW,EAGZ,MAAM,0BAA0B,CAAC;AAElC;;;;GAIG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,GAAG,CAAU;IACrB,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,YAAY,CAAS;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,aAAa,CAA4B;IACjD,OAAO,CAAC,QAAQ,CAAqB;IACrC,OAAO,CAAC,aAAa,CAA4B;gBAErC,IAAI,GAAE,MAAiC;IAWtC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAgBtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAkBlC;;OAEG;IACH,OAAO,CAAC,WAAW;IAsDnB;;;;;OAKG;IACH,OAAO,CAAC,YAAY;IAsBpB;;;;;;OAMG;IACH,OAAO,CAAC,mBAAmB;IA8B3B;;;;;OAKG;IACH,OAAO,CAAC,WAAW;IAInB;;;;;;;;OAQG;IACI,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI;IA2E1C;;;OAGG;IACI,WAAW,IAAI,IAAI;IAM1B;;;OAGG;IACI,cAAc,IAAI,WAAW,GAAG,SAAS;IAOhD;;;;;OAKG;IACI,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM;IAI5D;;;;;OAKG;IACI,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,WAAW,EAAE;CAShE"}
@@ -0,0 +1,57 @@
1
+ import { Request, Response } from 'express';
2
+ export declare const DEFAULT_MOCK_SERVER_PORT = 3001;
3
+ /**
4
+ * Configuration for retry simulation behavior.
5
+ */
6
+ export interface RetryConfig {
7
+ /** Number of times to return error before succeeding (default: 4) */
8
+ failureCount?: number;
9
+ /** 5xx status code to return during failures (default: 500) */
10
+ errorStatus?: number;
11
+ /** Optional error response body to send as JSON during failures */
12
+ errorBody?: unknown;
13
+ /** Optional headers to send with the error response */
14
+ headers?: Record<string, string>;
15
+ /** Optional delay in milliseconds before sending each failure response */
16
+ delay?: number;
17
+ }
18
+ /**
19
+ * Configuration object for setting up a route response.
20
+ */
21
+ export interface RouteConfig {
22
+ /** The path of the route (e.g., '/callback_url', '/worker_data_url.get') */
23
+ path: string;
24
+ /** The HTTP method (e.g., 'GET', 'POST', 'PUT', 'DELETE') */
25
+ method: string;
26
+ /** The HTTP status code to return (e.g., 200, 401, 500) */
27
+ status: number;
28
+ /** Optional response body to send as JSON */
29
+ body?: unknown;
30
+ /** Optional headers to send with the response */
31
+ headers?: Record<string, string>;
32
+ /** Optional retry configuration for simulating failures before success */
33
+ retry?: RetryConfig;
34
+ /** Optional delay in milliseconds before sending the response */
35
+ delay?: number;
36
+ }
37
+ /**
38
+ * Type for custom route handler functions.
39
+ */
40
+ export type RouteHandler = (req: Request, res: Response) => unknown;
41
+ /**
42
+ * Information about a request received by the mock server.
43
+ */
44
+ export interface RequestInfo {
45
+ /** The HTTP method (e.g., 'GET', 'POST') */
46
+ method: string;
47
+ /** The full URL path of the request */
48
+ url: string;
49
+ /** Optional request body (for POST/PUT requests) */
50
+ body?: unknown;
51
+ }
52
+ export type RouteHandlers = Map<string, RouteHandler>;
53
+ /**
54
+ * Type for tracking request counts per route.
55
+ */
56
+ export type RequestCounts = Map<string, number>;
57
+ //# sourceMappingURL=mock-server.interfaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mock-server.interfaces.d.ts","sourceRoot":"","sources":["../../src/mock-server/mock-server.interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE5C,eAAO,MAAM,wBAAwB,OAAO,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,qEAAqE;IACrE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,+DAA+D;IAC/D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mEAAmE;IACnE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,uDAAuD;IACvD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,0EAA0E;IAC1E,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,4EAA4E;IAC5E,IAAI,EAAE,MAAM,CAAC;IACb,6DAA6D;IAC7D,MAAM,EAAE,MAAM,CAAC;IACf,2DAA2D;IAC3D,MAAM,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,iDAAiD;IACjD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,0EAA0E;IAC1E,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,iEAAiE;IACjE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,KAAK,OAAO,CAAC;AAEpE;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,4CAA4C;IAC5C,MAAM,EAAE,MAAM,CAAC;IACf,uCAAuC;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ,oDAAoD;IACpD,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;AAEtD;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_MOCK_SERVER_PORT = void 0;
4
+ exports.DEFAULT_MOCK_SERVER_PORT = 3001;
@@ -0,0 +1,271 @@
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.MockServer = void 0;
7
+ const express_1 = __importDefault(require("express"));
8
+ const mock_server_interfaces_1 = require("./mock-server.interfaces");
9
+ /**
10
+ * MockServer used in tests to mock internal AirSync endpoints.
11
+ * This is a simple mock server that listens on a port and responds to requests.
12
+ * Supports per-test route configuration to simulate different response scenarios.
13
+ */
14
+ class MockServer {
15
+ constructor(port = mock_server_interfaces_1.DEFAULT_MOCK_SERVER_PORT) {
16
+ this.server = null;
17
+ this.routeHandlers = new Map();
18
+ this.requests = [];
19
+ this.requestCounts = new Map();
20
+ this.internalPort = port;
21
+ this.port = port;
22
+ this.baseUrl = `http://localhost:${this.port}`;
23
+ this.app = (0, express_1.default)();
24
+ // Increase limit to handle size limit tests that send large artifact arrays
25
+ this.app.use(express_1.default.json({ limit: '10mb' }));
26
+ this.setupRoutes();
27
+ }
28
+ async start() {
29
+ return new Promise((resolve) => {
30
+ this.server = this.app.listen(this.internalPort, () => {
31
+ var _a, _b;
32
+ // Get the actual port assigned by the OS (important for port 0 = dynamic allocation)
33
+ const actualPort = (_b = (_a = this.server) === null || _a === void 0 ? void 0 : _a.address()) === null || _b === void 0 ? void 0 : _b.port;
34
+ if (actualPort) {
35
+ this.port = actualPort;
36
+ this.baseUrl = `http://localhost:${this.port}`;
37
+ }
38
+ console.log(`Mock server running on http://localhost:${this.port}.`);
39
+ resolve();
40
+ });
41
+ });
42
+ }
43
+ async stop() {
44
+ if (!this.server) {
45
+ return Promise.resolve();
46
+ }
47
+ return new Promise((resolve, reject) => {
48
+ this.server.close((err) => {
49
+ if (err) {
50
+ reject(err);
51
+ }
52
+ else {
53
+ console.log('Mock server stopped.');
54
+ this.server = null;
55
+ resolve();
56
+ }
57
+ });
58
+ });
59
+ }
60
+ /**
61
+ * Sets up routes for the mock server.
62
+ */
63
+ setupRoutes() {
64
+ // TEST ENDPOINT
65
+ this.app.get('/test-endpoint', this.routeHandler('GET', '/test-endpoint'));
66
+ // CALLBACK URL
67
+ this.app.post('/callback_url', this.routeHandler('POST', '/callback_url'));
68
+ // WORKER DATA URL
69
+ this.app.post('/worker_data_url', this.routeHandler('POST', '/worker_data_url'));
70
+ this.app.get('/worker_data_url.get', this.routeHandler('GET', '/worker_data_url.get'));
71
+ this.app.post('/worker_data_url.update', this.routeHandler('POST', '/worker_data_url.update'));
72
+ // SNAP-INS URL
73
+ this.app.get('/internal/snap-ins.get', this.routeHandler('GET', '/internal/snap-ins.get'));
74
+ // AIRDROP RECIPE INITIAL DOMAIN MAPPINGS INSTALL URL
75
+ this.app.post('/internal/airdrop.recipe.initial-domain-mappings.install', this.routeHandler('POST', '/internal/airdrop.recipe.initial-domain-mappings.install'));
76
+ // ARTIFACTS URL
77
+ this.app.get('/internal/airdrop.artifacts.upload-url', this.routeHandler('GET', '/internal/airdrop.artifacts.upload-url'));
78
+ this.app.post('/internal/airdrop.artifacts.confirm-upload', this.routeHandler('POST', '/internal/airdrop.artifacts.confirm-upload'));
79
+ // FILE UPLOAD URL
80
+ this.app.post('/file-upload-url', this.routeHandler('POST', '/file-upload-url'));
81
+ }
82
+ /**
83
+ * Creates a route handler that checks for custom handlers before using the default.
84
+ * @param method - The HTTP method
85
+ * @param path - The route path
86
+ * @returns A route handler function
87
+ */
88
+ routeHandler(method, path) {
89
+ return (req, res) => {
90
+ const requestInfo = Object.assign({ method: req.method, url: req.url || req.path }, (req.body !== undefined && req.body !== null
91
+ ? { body: req.body }
92
+ : {}));
93
+ this.requests.push(requestInfo);
94
+ const key = `${method}:${path}`;
95
+ const customHandler = this.routeHandlers.get(key);
96
+ if (customHandler) {
97
+ customHandler(req, res);
98
+ }
99
+ else {
100
+ this.defaultRouteHandler(req, res);
101
+ }
102
+ };
103
+ }
104
+ /**
105
+ * Default route handler for the mock server. Returns { success: true } for
106
+ * routes that are not explicitly set.
107
+ * @param req - The request object
108
+ * @param res - The response object
109
+ * @returns void
110
+ */
111
+ defaultRouteHandler(req, res) {
112
+ if (req.method === 'GET' && req.path === '/worker_data_url.get') {
113
+ res.status(200).json({
114
+ state: JSON.stringify({}),
115
+ });
116
+ }
117
+ else if (req.method === 'GET' && req.path === '/internal/snap-ins.get') {
118
+ res.status(200).json({
119
+ snap_in: {
120
+ imports: [{ name: 'test_import_slug' }],
121
+ snap_in_version: { slug: 'test_snap_in_slug' },
122
+ },
123
+ });
124
+ }
125
+ else if (req.method === 'GET' &&
126
+ req.path === '/internal/airdrop.artifacts.upload-url') {
127
+ // Generate a unique artifact ID for each request
128
+ const artifactId = `artifact-${Date.now()}-${Math.random()
129
+ .toString(36)
130
+ .substr(2, 9)}`;
131
+ res.status(200).json({
132
+ upload_url: `${this.baseUrl}/file-upload-url`,
133
+ artifact_id: artifactId,
134
+ form_data: [], // Empty form_data for local development
135
+ });
136
+ }
137
+ else {
138
+ res.status(200).json({ success: true });
139
+ }
140
+ }
141
+ /**
142
+ * Gets the route key for a given method and path.
143
+ * @param method - The HTTP method
144
+ * @param path - The route path
145
+ * @returns The route key in the format 'METHOD:path'
146
+ */
147
+ getRouteKey(method, path) {
148
+ return `${method.toUpperCase()}:${path}`;
149
+ }
150
+ /**
151
+ * Configures a route to return a specific status code and optional response body.
152
+ * @param config - The route configuration object
153
+ * @param config.path - The path of the route (e.g., '/callback_url')
154
+ * @param config.method - The HTTP method (e.g., 'GET', 'POST')
155
+ * @param config.status - The HTTP status code to return (e.g., 200, 401, 500)
156
+ * @param config.body - Optional response body to send as JSON
157
+ * @param config.retry - Optional retry configuration for simulating failures before success
158
+ */
159
+ setRoute(config) {
160
+ const { path, method, status, body, retry, headers, delay } = config;
161
+ const key = this.getRouteKey(method, path);
162
+ // Reset request count for this route if retry is configured
163
+ // This ensures a clean state each time setRoute is called
164
+ if (retry) {
165
+ this.requestCounts.set(key, 0);
166
+ }
167
+ this.routeHandlers.set(key, (req, res) => {
168
+ const sendResponse = (responseDelay) => {
169
+ const send = () => {
170
+ var _a, _b;
171
+ if (retry) {
172
+ const currentCount = this.requestCounts.get(key) || 0;
173
+ const failureCount = (_a = retry.failureCount) !== null && _a !== void 0 ? _a : 4;
174
+ const errorStatus = (_b = retry.errorStatus) !== null && _b !== void 0 ? _b : 500;
175
+ if (currentCount < failureCount) {
176
+ this.requestCounts.set(key, currentCount + 1);
177
+ const sendFailure = () => {
178
+ if (retry.headers) {
179
+ res.set(retry.headers);
180
+ }
181
+ if (retry.errorBody !== undefined) {
182
+ res.status(errorStatus).json(retry.errorBody);
183
+ }
184
+ else {
185
+ res.status(errorStatus).send();
186
+ }
187
+ };
188
+ if (retry.delay) {
189
+ setTimeout(sendFailure, retry.delay);
190
+ }
191
+ else {
192
+ sendFailure();
193
+ }
194
+ }
195
+ else {
196
+ this.requestCounts.set(key, currentCount + 1);
197
+ if (headers) {
198
+ res.set(headers);
199
+ }
200
+ if (body !== undefined) {
201
+ res.status(status).json(body);
202
+ }
203
+ else {
204
+ this.defaultRouteHandler(req, res);
205
+ }
206
+ }
207
+ }
208
+ else {
209
+ if (headers) {
210
+ res.set(headers);
211
+ }
212
+ if (body !== undefined) {
213
+ res.status(status).json(body);
214
+ }
215
+ else {
216
+ res.status(status).send();
217
+ }
218
+ }
219
+ };
220
+ if (responseDelay) {
221
+ setTimeout(send, responseDelay);
222
+ }
223
+ else {
224
+ send();
225
+ }
226
+ };
227
+ sendResponse(delay);
228
+ });
229
+ }
230
+ /**
231
+ * Resets all custom route handlers, restoring all default handlers.
232
+ * Also clears request tracking data.
233
+ */
234
+ resetRoutes() {
235
+ this.routeHandlers.clear();
236
+ this.requestCounts.clear();
237
+ this.requests = [];
238
+ }
239
+ /**
240
+ * Returns the most recent request or undefined if no requests exist.
241
+ * @returns The last RequestInfo object or undefined
242
+ */
243
+ getLastRequest() {
244
+ if (this.requests.length === 0) {
245
+ return undefined;
246
+ }
247
+ return this.requests[this.requests.length - 1];
248
+ }
249
+ /**
250
+ * Gets the number of requests made to a specific endpoint.
251
+ * @param method - The HTTP method (e.g., 'GET', 'POST')
252
+ * @param path - The route path (e.g., '/test-endpoint', '/callback_url')
253
+ * @returns The number of requests made to the endpoint
254
+ */
255
+ getRequestCount(method, path) {
256
+ return this.getRequests(method, path).length;
257
+ }
258
+ /**
259
+ * Gets all requests made to a specific endpoint.
260
+ * @param method - The HTTP method (e.g., 'GET', 'POST')
261
+ * @param path - The route path (e.g., '/test-endpoint', '/callback_url')
262
+ * @returns An array of RequestInfo objects for the endpoint
263
+ */
264
+ getRequests(method, path) {
265
+ // Remove query parameters for comparison
266
+ const pathWithoutQuery = path.split('?')[0];
267
+ return this.requests.filter((req) => req.method.toUpperCase() === method.toUpperCase() &&
268
+ req.url.split('?')[0] === pathWithoutQuery);
269
+ }
270
+ }
271
+ exports.MockServer = MockServer;
@@ -41,6 +41,12 @@ export declare class WorkerAdapter<ConnectorState> {
41
41
  get reports(): LoaderReport[];
42
42
  get processedFiles(): string[];
43
43
  get mappers(): Mappers;
44
+ get extractionScope(): import("../../types/workers").ExtractionScope;
45
+ /**
46
+ * Returns whether the given item type should be extracted.
47
+ * Defaults to true if the scope is empty or the item type is not listed.
48
+ */
49
+ shouldExtract(itemType: string): boolean;
44
50
  initializeRepos(repos: RepoInterface[]): void;
45
51
  getRepo(itemType: string): Repo | undefined;
46
52
  postState(): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"worker-adapter.d.ts","sourceRoot":"","sources":["../../../src/multithreading/worker-adapter/worker-adapter.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EACL,oBAAoB,EACpB,aAAa,EACd,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EACL,YAAY,EACZ,SAAS,EAET,kCAAkC,EAClC,yCAAyC,EACzC,kBAAkB,EAClB,2BAA2B,EAC3B,2BAA2B,EAC5B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAEL,wBAAwB,EACxB,kBAAkB,EAClB,6BAA6B,EAC7B,UAAU,EACV,qBAAqB,EACrB,cAAc,EACd,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,qBAAqB,EAEtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EAGrB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,QAAQ,EAAkB,MAAM,oCAAoC,CAAC;AAI9E,wBAAgB,mBAAmB,CAAC,cAAc,EAAE,EAClD,KAAK,EACL,YAAY,EACZ,OAAO,GACR,EAAE,sBAAsB,CAAC,cAAc,CAAC,GAAG,aAAa,CAAC,cAAc,CAAC,CAMxE;AAED;;;;;;;;;;;;;;GAcG;AACH,qBAAa,aAAa,CAAC,cAAc;IACvC,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,OAAO,CAAC,EAAE,oBAAoB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AAM,GACP,EAAE;QACD,MAAM,EAAE,6BAA6B,CAAC,wBAAwB,CAAC,CAAC;KACjE,GAAG,OAAO,CAAC,qBAAqB,CAAC;IA6E5B,QAAQ,CAAC,EACb,IAAI,EACJ,cAAc,GACf,EAAE;QACD,IAAI,EAAE,kBAAkB,CAAC;QACzB,cAAc,EAAE,cAAc,CAAC;KAChC,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAkMvB,iBAAiB,CACrB,UAAU,EAAE,oBAAoB,EAChC,MAAM,EAAE,yCAAyC,GAChD,OAAO,CAAC,2BAA2B,CAAC;IA6GvC;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAcnB,cAAc,CAAC,EACnB,IAAI,EACJ,MAAM,GACP,EAAE;QACD,IAAI,EAAE,wBAAwB,CAAC;QAC/B,MAAM,EAAE,6BAA6B,CAAC,wBAAwB,CAAC,CAAC;KACjE,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAqD7B;;;;;;OAMG;IACG,iBAAiB,CAAC,QAAQ,EAAE,EAChC,MAAM,EACN,UAAU,EACV,SAAa,GACd,EAAE;QACD,MAAM,EAAE,yCAAyC,CAAC;QAClD,UAAU,CAAC,EAAE,kCAAkC,CAC7C,cAAc,EACd,oBAAoB,EAAE,EACtB,QAAQ,CACT,CAAC;QACF,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC,2BAA2B,CAAC;CAmIzC"}
1
+ {"version":3,"file":"worker-adapter.d.ts","sourceRoot":"","sources":["../../../src/multithreading/worker-adapter/worker-adapter.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EACL,oBAAoB,EACpB,aAAa,EACd,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EACL,YAAY,EACZ,SAAS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P,EAAE;QACD,IAAI,EAAE,wBAAwB,CAAC;QAC/B,MAAM,EAAE,6BAA6B,CAAC,wBAAwB,CAAC,CAAC;KACjE,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAqD7B;;;;;;OAMG;IACG,iBAAiB,CAAC,QAAQ,EAAE,EAChC,MAAM,EACN,UAAU,EACV,SAAa,GACd,EAAE;QACD,MAAM,EAAE,yCAAyC,CAAC;QAClD,UAAU,CAAC,EAAE,kCAAkC,CAC7C,cAAc,EACd,oBAAoB,EAAE,EACtB,QAAQ,CACT,CAAC;QACF,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC,2BAA2B,CAAC;CAmIzC"}
@@ -81,6 +81,21 @@ class WorkerAdapter {
81
81
  get mappers() {
82
82
  return this._mappers;
83
83
  }
84
+ get extractionScope() {
85
+ return this.adapterState.extractionScope;
86
+ }
87
+ /**
88
+ * Returns whether the given item type should be extracted.
89
+ * Defaults to true if the scope is empty or the item type is not listed.
90
+ */
91
+ shouldExtract(itemType) {
92
+ const scope = this.extractionScope;
93
+ if (Object.keys(scope).length === 0)
94
+ return true;
95
+ if (!(itemType in scope))
96
+ return true;
97
+ return scope[itemType].extract;
98
+ }
84
99
  initializeRepos(repos) {
85
100
  this.repos = repos.map((repo) => {
86
101
  const shouldNormalize = repo.itemType !== constants_1.AirSyncDefaultItemTypes.EXTERNAL_DOMAIN_METADATA &&
@@ -191,11 +206,13 @@ class WorkerAdapter {
191
206
  if ((_b = data === null || data === void 0 ? void 0 : data.error) === null || _b === void 0 ? void 0 : _b.message) {
192
207
  data.error.message = (0, helpers_1.truncateMessage)(data.error.message);
193
208
  }
209
+ const isExtractionEvent = Object.values(extraction_1.ExtractorEventType).includes(newEventType);
210
+ const isLoaderEvent = Object.values(loading_1.LoaderEventType).includes(newEventType);
194
211
  await (0, control_protocol_1.emit)({
195
212
  eventType: newEventType,
196
213
  event: this.event,
197
- data: Object.assign(Object.assign({}, data), (constants_1.ALLOWED_EXTRACTION_EVENT_TYPES.includes(this.event.payload.event_type)
198
- ? { artifacts: this.artifacts }
214
+ data: Object.assign(Object.assign(Object.assign({}, data), (isExtractionEvent ? { artifacts: this.artifacts } : {})), (isLoaderEvent
215
+ ? { reports: this.reports, processed_files: this.processedFiles }
199
216
  : {})),
200
217
  });
201
218
  const message = {
@@ -771,9 +788,9 @@ class WorkerAdapter {
771
788
  if ((response === null || response === void 0 ? void 0 : response.delay) || (response === null || response === void 0 ? void 0 : response.error)) {
772
789
  return response;
773
790
  }
774
- // On timeout, emit progress and exit to allow resumption.
791
+ // On timeout, emit progress and exit to allow continuation.
775
792
  if (this.isTimeout) {
776
- console.log(`Timeout detected after processing attachments for artifact ID: ${attachmentsMetadataArtifactId}. Emitting progress to allow resumption.`);
793
+ console.log(`Timeout detected after processing attachments for artifact ID: ${attachmentsMetadataArtifactId}. Emitting progress to allow continuation.`);
777
794
  await this.emit(extraction_1.ExtractorEventType.AttachmentExtractionProgress);
778
795
  process.exit(0);
779
796
  return;
@@ -4,6 +4,7 @@ const attachments_streaming_pool_1 = require("../../attachments-streaming/attach
4
4
  const state_1 = require("../../state/state");
5
5
  const test_helpers_1 = require("../../tests/test-helpers");
6
6
  const types_1 = require("../../types");
7
+ const loading_1 = require("../../types/loading");
7
8
  const worker_adapter_1 = require("./worker-adapter");
8
9
  /* eslint-disable @typescript-eslint/no-require-imports */
9
10
  // Mock dependencies
@@ -467,10 +468,12 @@ describe(worker_adapter_1.WorkerAdapter.name, () => {
467
468
  'content-length': '100',
468
469
  }),
469
470
  });
470
- adapter['uploader'].getArtifactUploadUrl = jest
471
- .fn()
472
- .mockResolvedValue({
473
- response: { artifact_id: 'art_1', upload_url: 'https://upload', form_data: [] },
471
+ adapter['uploader'].getArtifactUploadUrl = jest.fn().mockResolvedValue({
472
+ response: {
473
+ artifact_id: 'art_1',
474
+ upload_url: 'https://upload',
475
+ form_data: [],
476
+ },
474
477
  });
475
478
  adapter['uploader'].streamArtifact = jest
476
479
  .fn()
@@ -495,10 +498,12 @@ describe(worker_adapter_1.WorkerAdapter.name, () => {
495
498
  'content-length': '200',
496
499
  }),
497
500
  });
498
- adapter['uploader'].getArtifactUploadUrl = jest
499
- .fn()
500
- .mockResolvedValue({
501
- response: { artifact_id: 'art_2', upload_url: 'https://upload', form_data: [] },
501
+ adapter['uploader'].getArtifactUploadUrl = jest.fn().mockResolvedValue({
502
+ response: {
503
+ artifact_id: 'art_2',
504
+ upload_url: 'https://upload',
505
+ form_data: [],
506
+ },
502
507
  });
503
508
  adapter['uploader'].streamArtifact = jest
504
509
  .fn()
@@ -519,10 +524,12 @@ describe(worker_adapter_1.WorkerAdapter.name, () => {
519
524
  const mockStream = jest.fn().mockResolvedValue({
520
525
  httpStream: createMockHttpStream({}),
521
526
  });
522
- adapter['uploader'].getArtifactUploadUrl = jest
523
- .fn()
524
- .mockResolvedValue({
525
- response: { artifact_id: 'art_3', upload_url: 'https://upload', form_data: [] },
527
+ adapter['uploader'].getArtifactUploadUrl = jest.fn().mockResolvedValue({
528
+ response: {
529
+ artifact_id: 'art_3',
530
+ upload_url: 'https://upload',
531
+ form_data: [],
532
+ },
526
533
  });
527
534
  adapter['uploader'].streamArtifact = jest
528
535
  .fn()
@@ -625,5 +632,159 @@ describe(worker_adapter_1.WorkerAdapter.name, () => {
625
632
  });
626
633
  expect(counter.counter).toBe(1);
627
634
  });
635
+ it('should include artifacts in data for extraction events', async () => {
636
+ const { emit: mockEmit } = require('../../common/control-protocol');
637
+ adapter['adapterState'].postState = jest
638
+ .fn()
639
+ .mockResolvedValue(undefined);
640
+ adapter.uploadAllRepos = jest.fn().mockResolvedValue(undefined);
641
+ adapter['_artifacts'] = [
642
+ { id: 'art-1', item_count: 10, item_type: 'issues' },
643
+ ];
644
+ await adapter.emit(types_1.ExtractorEventType.DataExtractionDone);
645
+ expect(mockEmit).toHaveBeenCalledWith(expect.objectContaining({
646
+ data: expect.objectContaining({
647
+ artifacts: expect.arrayContaining([
648
+ expect.objectContaining({ id: 'art-1' }),
649
+ ]),
650
+ }),
651
+ }));
652
+ // Should not include loader-specific fields
653
+ const callData = mockEmit.mock.calls[0][0].data;
654
+ expect(callData).not.toHaveProperty('reports');
655
+ expect(callData).not.toHaveProperty('processed_files');
656
+ });
657
+ it('should include reports and processed_files in data for loader events', async () => {
658
+ const { emit: mockEmit } = require('../../common/control-protocol');
659
+ adapter['adapterState'].postState = jest
660
+ .fn()
661
+ .mockResolvedValue(undefined);
662
+ adapter.uploadAllRepos = jest.fn().mockResolvedValue(undefined);
663
+ adapter['loaderReports'] = [
664
+ { item_type: 'tasks', [loading_1.ActionType.CREATED]: 5 },
665
+ ];
666
+ adapter['_processedFiles'] = ['file-1', 'file-2'];
667
+ await adapter.emit(types_1.LoaderEventType.DataLoadingDone);
668
+ expect(mockEmit).toHaveBeenCalledWith(expect.objectContaining({
669
+ data: expect.objectContaining({
670
+ reports: expect.arrayContaining([
671
+ expect.objectContaining({ item_type: 'tasks' }),
672
+ ]),
673
+ processed_files: ['file-1', 'file-2'],
674
+ }),
675
+ }));
676
+ // Should not include extraction-specific fields
677
+ const callData = mockEmit.mock.calls[0][0].data;
678
+ expect(callData).not.toHaveProperty('artifacts');
679
+ });
680
+ it('should not include artifacts, reports, or processed_files for unknown event types', async () => {
681
+ const { emit: mockEmit } = require('../../common/control-protocol');
682
+ adapter['adapterState'].postState = jest
683
+ .fn()
684
+ .mockResolvedValue(undefined);
685
+ adapter.uploadAllRepos = jest.fn().mockResolvedValue(undefined);
686
+ adapter['_artifacts'] = [
687
+ { id: 'art-1', item_count: 10, item_type: 'issues' },
688
+ ];
689
+ adapter['loaderReports'] = [
690
+ { item_type: 'tasks', [loading_1.ActionType.CREATED]: 5 },
691
+ ];
692
+ adapter['_processedFiles'] = ['file-1'];
693
+ await adapter.emit('SOME_UNKNOWN_EVENT');
694
+ const callData = mockEmit.mock.calls[0][0].data;
695
+ expect(callData).not.toHaveProperty('artifacts');
696
+ expect(callData).not.toHaveProperty('reports');
697
+ expect(callData).not.toHaveProperty('processed_files');
698
+ });
699
+ it('should include artifacts for all ExtractorEventType values', async () => {
700
+ var _a, _b;
701
+ const { emit: mockEmit } = require('../../common/control-protocol');
702
+ const extractorEvents = [
703
+ types_1.ExtractorEventType.DataExtractionDone,
704
+ types_1.ExtractorEventType.DataExtractionProgress,
705
+ types_1.ExtractorEventType.DataExtractionError,
706
+ types_1.ExtractorEventType.AttachmentExtractionDone,
707
+ types_1.ExtractorEventType.AttachmentExtractionProgress,
708
+ ];
709
+ for (const eventType of extractorEvents) {
710
+ jest.clearAllMocks();
711
+ adapter.hasWorkerEmitted = false;
712
+ adapter['adapterState'].postState = jest
713
+ .fn()
714
+ .mockResolvedValue(undefined);
715
+ adapter.uploadAllRepos = jest.fn().mockResolvedValue(undefined);
716
+ await adapter.emit(eventType);
717
+ const callData = (_b = (_a = mockEmit.mock.calls[0]) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.data;
718
+ expect(callData).toHaveProperty('artifacts');
719
+ expect(callData).not.toHaveProperty('reports');
720
+ }
721
+ });
722
+ it('should include reports and processed_files for all LoaderEventType values', async () => {
723
+ var _a, _b;
724
+ const { emit: mockEmit } = require('../../common/control-protocol');
725
+ const loaderEvents = [
726
+ types_1.LoaderEventType.DataLoadingDone,
727
+ types_1.LoaderEventType.DataLoadingProgress,
728
+ types_1.LoaderEventType.DataLoadingError,
729
+ types_1.LoaderEventType.AttachmentLoadingDone,
730
+ types_1.LoaderEventType.AttachmentLoadingProgress,
731
+ ];
732
+ for (const eventType of loaderEvents) {
733
+ jest.clearAllMocks();
734
+ adapter.hasWorkerEmitted = false;
735
+ adapter['adapterState'].postState = jest
736
+ .fn()
737
+ .mockResolvedValue(undefined);
738
+ adapter.uploadAllRepos = jest.fn().mockResolvedValue(undefined);
739
+ await adapter.emit(eventType);
740
+ const callData = (_b = (_a = mockEmit.mock.calls[0]) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.data;
741
+ expect(callData).toHaveProperty('reports');
742
+ expect(callData).toHaveProperty('processed_files');
743
+ expect(callData).not.toHaveProperty('artifacts');
744
+ }
745
+ });
746
+ });
747
+ describe('extractionScope', () => {
748
+ it('should return empty object by default', () => {
749
+ expect(adapter.extractionScope).toEqual({});
750
+ });
751
+ it('should return extraction scope from adapter state', () => {
752
+ const extractionScope = {
753
+ tasks: { extract: true },
754
+ users: { extract: false },
755
+ };
756
+ // Simulate what State.init() does when parsing objects from API
757
+ mockAdapterState._extractionScope = extractionScope;
758
+ expect(adapter.extractionScope).toEqual({
759
+ tasks: { extract: true },
760
+ users: { extract: false },
761
+ });
762
+ });
763
+ });
764
+ describe('shouldExtract', () => {
765
+ it('should return true when extraction scope is empty', () => {
766
+ expect(adapter.shouldExtract('tasks')).toBe(true);
767
+ expect(adapter.shouldExtract('users')).toBe(true);
768
+ });
769
+ it('should return true when item type is not in scope', () => {
770
+ mockAdapterState._extractionScope = {
771
+ tasks: { extract: true },
772
+ };
773
+ expect(adapter.shouldExtract('users')).toBe(true);
774
+ });
775
+ it('should return true when item type has extract: true', () => {
776
+ mockAdapterState._extractionScope = {
777
+ tasks: { extract: true },
778
+ };
779
+ expect(adapter.shouldExtract('tasks')).toBe(true);
780
+ });
781
+ it('should return false when item type has extract: false', () => {
782
+ mockAdapterState._extractionScope = {
783
+ tasks: { extract: false },
784
+ users: { extract: true },
785
+ };
786
+ expect(adapter.shouldExtract('tasks')).toBe(false);
787
+ expect(adapter.shouldExtract('users')).toBe(true);
788
+ });
628
789
  });
629
790
  });
@@ -1,7 +1,9 @@
1
1
  import { AdapterState, StateInterface } from './state.interfaces';
2
+ import { ExtractionScope } from '../types/workers';
2
3
  export declare function createAdapterState<ConnectorState>({ event, initialState, initialDomainMapping, options, }: StateInterface<ConnectorState>): Promise<State<ConnectorState>>;
3
4
  export declare class State<ConnectorState> {
4
5
  private _state;
6
+ private _extractionScope;
5
7
  private initialSdkState;
6
8
  private workerUrl;
7
9
  private devrevToken;
@@ -10,6 +12,7 @@ export declare class State<ConnectorState> {
10
12
  constructor({ event, initialState }: StateInterface<ConnectorState>);
11
13
  get state(): AdapterState<ConnectorState>;
12
14
  set state(value: AdapterState<ConnectorState>);
15
+ get extractionScope(): ExtractionScope;
13
16
  /**
14
17
  * Initializes the state for this adapter instance by fetching from API
15
18
  * or creating an initial state if none exists (404).
@@ -25,6 +28,9 @@ export declare class State<ConnectorState> {
25
28
  * Fetches the state of the adapter from API.
26
29
  * @return The raw state data from API
27
30
  */
28
- fetchState(): Promise<string>;
31
+ fetchState(): Promise<{
32
+ state: string;
33
+ objects?: string;
34
+ }>;
29
35
  }
30
36
  //# sourceMappingURL=state.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/state/state.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,YAAY,EAIZ,cAAc,EACf,MAAM,oBAAoB,CAAC;AAE5B,wBAAsB,kBAAkB,CAAC,cAAc,EAAE,EACvD,KAAK,EACL,YAAY,EACZ,oBAAoB,EACpB,OAAO,GACR,EAAE,cAAc,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CA8DjE;AAED,qBAAa,KAAK,CAAC,cAAc;IAC/B,OAAO,CAAC,MAAM,CAA+B;IAC7C,OAAO,CAAC,eAAe,CAAW;IAClC,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,SAAS,CAAS;gBAEd,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,cAAc,CAAC,cAAc,CAAC;IAenE,IAAI,KAAK,IAAI,YAAY,CAAC,cAAc,CAAC,CAExC;IAED,IAAI,KAAK,CAAC,KAAK,EAAE,YAAY,CAAC,cAAc,CAAC,EAE5C;IAED;;;;OAIG;IACG,IAAI,CAAC,YAAY,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,C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CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAqBjE"}
@@ -65,6 +65,7 @@ async function createAdapterState({ event, initialState, initialDomainMapping, o
65
65
  }
66
66
  class State {
67
67
  constructor({ event, initialState }) {
68
+ this._extractionScope = {};
68
69
  this.initialSdkState =
69
70
  event.payload.event_context.mode === common_1.SyncMode.LOADING
70
71
  ? state_interfaces_1.loadingSdkState
@@ -81,6 +82,9 @@ class State {
81
82
  set state(value) {
82
83
  this._state = value;
83
84
  }
85
+ get extractionScope() {
86
+ return this._extractionScope;
87
+ }
84
88
  /**
85
89
  * Initializes the state for this adapter instance by fetching from API
86
90
  * or creating an initial state if none exists (404).
@@ -89,7 +93,7 @@ class State {
89
93
  async init(initialState) {
90
94
  var _a;
91
95
  try {
92
- const stringifiedState = await this.fetchState();
96
+ const { state: stringifiedState, objects } = await this.fetchState();
93
97
  if (!stringifiedState) {
94
98
  throw new Error('No state found in response.');
95
99
  }
@@ -102,6 +106,14 @@ class State {
102
106
  }
103
107
  this.state = parsedState;
104
108
  console.log('State fetched successfully. Current state', (0, logger_1.getPrintableState)(this.state));
109
+ if (objects) {
110
+ try {
111
+ this._extractionScope = JSON.parse(objects);
112
+ }
113
+ catch (error) {
114
+ console.warn(`Failed to parse extractionScope. ${error}`);
115
+ }
116
+ }
105
117
  }
106
118
  catch (error) {
107
119
  if (axios_1.default.isAxiosError(error) && ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 404) {
@@ -170,7 +182,7 @@ class State {
170
182
  * @return The raw state data from API
171
183
  */
172
184
  async fetchState() {
173
- var _a;
185
+ var _a, _b;
174
186
  console.log(`Fetching state with sync unit id ${this.syncUnitId} and request id ${this.requestId}.`);
175
187
  const url = this.workerUrl + '.get';
176
188
  const response = await axios_client_internal_1.axiosClient.get(url, {
@@ -182,7 +194,10 @@ class State {
182
194
  request_id: this.requestId,
183
195
  },
184
196
  });
185
- return (_a = response.data) === null || _a === void 0 ? void 0 : _a.state;
197
+ return {
198
+ state: (_a = response.data) === null || _a === void 0 ? void 0 : _a.state,
199
+ objects: (_b = response.data) === null || _b === void 0 ? void 0 : _b.objects,
200
+ };
186
201
  }
187
202
  }
188
203
  exports.State = State;
@@ -63,7 +63,7 @@ describe(state_1.State.name, () => {
63
63
  const event = (0, test_helpers_1.createEvent)({
64
64
  eventType: eventType,
65
65
  });
66
- fetchStateSpy.mockResolvedValue('invalid-json');
66
+ fetchStateSpy.mockResolvedValue({ state: 'invalid-json' });
67
67
  jest.spyOn(console, 'error').mockImplementation(() => { });
68
68
  // Act & Assert
69
69
  await expect((0, state_1.createAdapterState)({
@@ -78,7 +78,7 @@ describe(state_1.State.name, () => {
78
78
  const event = (0, test_helpers_1.createEvent)({
79
79
  eventType: eventType,
80
80
  });
81
- fetchStateSpy.mockResolvedValue(null);
81
+ fetchStateSpy.mockResolvedValue({ state: null });
82
82
  jest.spyOn(console, 'error').mockImplementation(() => { });
83
83
  // Act & Assert
84
84
  await expect((0, state_1.createAdapterState)({
@@ -159,9 +159,11 @@ describe(state_1.State.name, () => {
159
159
  const event = (0, test_helpers_1.createEvent)({
160
160
  eventType: eventType,
161
161
  });
162
- fetchStateSpy.mockResolvedValue(JSON.stringify({
163
- test: 'test',
164
- }));
162
+ fetchStateSpy.mockResolvedValue({
163
+ state: JSON.stringify({
164
+ test: 'test',
165
+ }),
166
+ });
165
167
  jest.spyOn(console, 'log').mockImplementation(() => { });
166
168
  jest.spyOn(console, 'error').mockImplementation(() => { });
167
169
  // Act & Assert
@@ -184,7 +186,7 @@ describe(state_1.State.name, () => {
184
186
  test: 'test',
185
187
  snapInVersionId: '1.0.0',
186
188
  });
187
- fetchStateSpy.mockResolvedValue(stringifiedState);
189
+ fetchStateSpy.mockResolvedValue({ state: stringifiedState });
188
190
  jest.spyOn(console, 'log').mockImplementation(() => { });
189
191
  // Act & Assert
190
192
  await (0, state_1.createAdapterState)({
@@ -207,7 +209,7 @@ describe(state_1.State.name, () => {
207
209
  test: 'test',
208
210
  snapInVersionId: '1.0.0',
209
211
  });
210
- fetchStateSpy.mockResolvedValue(stringifiedState);
212
+ fetchStateSpy.mockResolvedValue({ state: stringifiedState });
211
213
  installInitialDomainMappingSpy.mockResolvedValue({
212
214
  success: true,
213
215
  });
@@ -221,4 +223,70 @@ describe(state_1.State.name, () => {
221
223
  // Assert
222
224
  expect(installInitialDomainMappingSpy).toHaveBeenCalled();
223
225
  });
226
+ it('should populate extractionScope from API response', async () => {
227
+ // Arrange
228
+ const event = (0, test_helpers_1.createEvent)({
229
+ eventType: extraction_1.EventType.StartExtractingData,
230
+ contextOverrides: {
231
+ snap_in_version_id: '1.0.0',
232
+ },
233
+ });
234
+ fetchStateSpy.mockResolvedValue({
235
+ state: JSON.stringify({ snapInVersionId: '1.0.0' }),
236
+ objects: JSON.stringify({
237
+ tasks: { extract: true },
238
+ users: { extract: true },
239
+ }),
240
+ });
241
+ jest.spyOn(console, 'log').mockImplementation(() => { });
242
+ // Act
243
+ const result = await (0, state_1.createAdapterState)({
244
+ event,
245
+ initialState: {},
246
+ initialDomainMapping: {},
247
+ });
248
+ // Assert
249
+ expect(result.extractionScope).toEqual({
250
+ tasks: { extract: true },
251
+ users: { extract: true },
252
+ });
253
+ });
254
+ it('should have empty extractionScope on 404', async () => {
255
+ // Arrange
256
+ const event = (0, test_helpers_1.createEvent)({
257
+ eventType: extraction_1.EventType.StartExtractingMetadata,
258
+ contextOverrides: {
259
+ snap_in_version_id: '',
260
+ },
261
+ });
262
+ fetchStateSpy.mockRejectedValue({
263
+ isAxiosError: true,
264
+ response: { status: 404 },
265
+ });
266
+ installInitialDomainMappingSpy.mockResolvedValue({ success: true });
267
+ postStateSpy.mockResolvedValue({ success: true });
268
+ jest.spyOn(console, 'log').mockImplementation(() => { });
269
+ // Act
270
+ const result = await (0, state_1.createAdapterState)({
271
+ event,
272
+ initialState: {},
273
+ initialDomainMapping: {},
274
+ });
275
+ // Assert
276
+ expect(result.extractionScope).toEqual({});
277
+ });
278
+ it('should have empty extractionScope for stateless events', async () => {
279
+ // Arrange
280
+ const event = (0, test_helpers_1.createEvent)({
281
+ eventType: extraction_1.EventType.StartExtractingExternalSyncUnits,
282
+ });
283
+ // Act
284
+ const result = await (0, state_1.createAdapterState)({
285
+ event,
286
+ initialState: {},
287
+ initialDomainMapping: {},
288
+ });
289
+ // Assert
290
+ expect(result.extractionScope).toEqual({});
291
+ });
224
292
  });
@@ -1,5 +1,5 @@
1
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';
2
+ export { AirdropEvent, AirdropMessage, ConnectionData, DomainObjectState, EventContextIn, EventContextOut, EventContext, EventData, EventType, ExternalProcessAttachmentFunction, ExternalSyncUnit, ExternalSystemAttachmentIteratorFunction, ExternalSystemAttachmentReducerFunction, ExternalSystemAttachmentStreamingFunction, ExternalSystemAttachmentStreamingParams, ExternalSystemAttachmentStreamingResponse, ExtractionMode, ExtractorEvent, ExtractorEventType, ProcessAttachmentReturnType, } from './extraction';
3
3
  export { ExternalSystemAttachment, ExternalSystemItem, ExternalSystemItemLoadingParams, ExternalSystemItemLoadingResponse, LoaderEventType, } from './loading';
4
4
  export { NormalizedAttachment, NormalizedItem, RepoInterface, } from '../repo/repo.interfaces';
5
5
  export { AdapterState } from '../state/state.interfaces';
@@ -1 +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,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Q,EACR,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,aAAa,EACb,UAAU,EACV,iBAAiB,EACjB,QAAQ,EACR,kBAAkB,GACnB,MAAM,4BAA4B,CAAC"}
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,YAAY,EACZ,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;AAGtC,YAAY,EACV,cAAc,EACd,wBAAwB,EACxB,cAAc,EACd,eAAe,EACf,WAAW,EACX,WAAW,EACX,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,sBAAsB,EACtB,KAAK,EACL,cAAc,EACd,wBAAwB,EACxB,oBAAoB,EACpB,eAAe,EACf,QAAQ,EACR,kBAAkB,EAClB,kBAAkB,EAClB,SAAS,EACT,SAAS,EACT,OAAO,EACP,cAAc,EACd,UAAU,EACV,kBAAkB,EAClB,qBAAqB,EACrB,aAAa,EACb,uBAAuB,EACvB,eAAe,EACf,aAAa,EACb,eAAe,EACf,aAAa,EACb,aAAa,EACb,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,aAAa,EACb,UAAU,EACV,iBAAiB,EACjB,QAAQ,EACR,kBAAkB,GACnB,MAAM,4BAA4B,CAAC"}
@@ -18,6 +18,13 @@ export interface WorkerAdapterInterface<ConnectorState> {
18
18
  adapterState: State<ConnectorState>;
19
19
  options?: WorkerAdapterOptions;
20
20
  }
21
+ /**
22
+ * ExtractionScope represents the parsed extraction scope from the platform.
23
+ * Each key is an item type name, and the value indicates whether it should be extracted.
24
+ */
25
+ export type ExtractionScope = Record<string, {
26
+ extract: boolean;
27
+ }>;
21
28
  /**
22
29
  * WorkerAdapterOptions represents the options for WorkerAdapter class.
23
30
  * @interface WorkerAdapterOptions
@@ -1 +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,W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
- "version": "1.17.1-beta.4",
3
+ "version": "1.17.1-beta.5",
4
4
  "description": "Typescript library containing the ADaaS(AirDrop as a Service) control protocol.",
5
5
  "type": "commonjs",
6
6
  "main": "./dist/index.js",
@@ -46,6 +46,18 @@
46
46
  "typescript": "^5.3.3",
47
47
  "typescript-eslint": "^8.46.1"
48
48
  },
49
+ "peerDependencies": {
50
+ "@types/express": "^5.0.0",
51
+ "express": "^5.0.0"
52
+ },
53
+ "peerDependenciesMeta": {
54
+ "@types/express": {
55
+ "optional": true
56
+ },
57
+ "express": {
58
+ "optional": true
59
+ }
60
+ },
49
61
  "dependencies": {
50
62
  "@devrev/typescript-sdk": "^1.1.59",
51
63
  "axios": "^1.13.5",