@devrev/ts-adaas 1.11.0 → 1.11.1-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.
@@ -18,7 +18,7 @@ export declare function getPrintableState(state: Record<string, any>): Printable
18
18
  */
19
19
  export declare function formatAxiosError(error: AxiosError): object;
20
20
  export declare const serializeError: (error: unknown) => unknown;
21
- export declare function serializeAxiosError(error: AxiosError): {
21
+ export interface AxiosErrorResponse {
22
22
  config: {
23
23
  method: string | undefined;
24
24
  params: any;
@@ -26,11 +26,14 @@ export declare function serializeAxiosError(error: AxiosError): {
26
26
  };
27
27
  isAxiosError: boolean;
28
28
  isCorsOrNoNetworkError: boolean;
29
- response: {
29
+ response?: {
30
30
  data: unknown;
31
31
  headers: RawAxiosResponseHeaders;
32
32
  status: number;
33
33
  statusText: string;
34
- } | null;
35
- };
34
+ };
35
+ code?: string;
36
+ message?: string;
37
+ }
38
+ export declare function serializeAxiosError(error: AxiosError): AxiosErrorResponse;
36
39
  //# sourceMappingURL=logger.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC,OAAO,EACL,sBAAsB,EACtB,QAAQ,EAER,cAAc,EACf,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,UAAU,EAAE,uBAAuB,EAAgB,MAAM,OAAO,CAAC;AAI1E,qBAAa,MAAO,SAAQ,OAAO;IACjC,OAAO,CAAC,OAAO,CAAC,CAAuB;IACvC,OAAO,CAAC,IAAI,CAAqC;gBAErC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,sBAAsB;IAStD,OAAO,CAAC,aAAa;IAYrB,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,QAAQ,GAAG,IAAI;IAmCpC,GAAG,CAAC,GAAG,IAAI,EAAE,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AI;IAI9B,KAAK,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;CAGzC;AAID,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,cAAc,CA2B5E;AACD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAE1D;AAED,eAAO,MAAM,cAAc,GAAI,OAAO,OAAO,YAK5C,CAAC;AAEF,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE;QACN,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;QAC3B,MAAM,EAAE,GAAG,CAAC;QACZ,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;KACzB,CAAC;IACF,YAAY,EAAE,OAAO,CAAC;IACtB,sBAAsB,EAAE,OAAO,CAAC;IAChC,QAAQ,CAAC,EAAE;QACT,IAAI,EAAE,OAAO,CAAC;QACd,OAAO,EAAE,uBAAuB,CAAC;QACjC,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,UAAU,GAAG,kBAAkB,CAwBzE"}
@@ -119,23 +119,26 @@ const serializeError = (error) => {
119
119
  exports.serializeError = serializeError;
120
120
  function serializeAxiosError(error) {
121
121
  var _a, _b, _c;
122
- const response = error.response
123
- ? {
122
+ const serializedAxiosError = {
123
+ config: {
124
+ method: (_a = error.config) === null || _a === void 0 ? void 0 : _a.method,
125
+ params: (_b = error.config) === null || _b === void 0 ? void 0 : _b.params,
126
+ url: (_c = error.config) === null || _c === void 0 ? void 0 : _c.url,
127
+ },
128
+ isAxiosError: true,
129
+ isCorsOrNoNetworkError: !error.response,
130
+ };
131
+ if (error.response) {
132
+ serializedAxiosError.response = {
124
133
  data: error.response.data,
125
134
  headers: error.response.headers,
126
135
  status: error.response.status,
127
136
  statusText: error.response.statusText,
128
- }
129
- : null;
130
- const config = {
131
- method: (_a = error.config) === null || _a === void 0 ? void 0 : _a.method,
132
- params: (_b = error.config) === null || _b === void 0 ? void 0 : _b.params,
133
- url: (_c = error.config) === null || _c === void 0 ? void 0 : _c.url,
134
- };
135
- return {
136
- config,
137
- isAxiosError: true,
138
- isCorsOrNoNetworkError: !error.response,
139
- response,
140
- };
137
+ };
138
+ }
139
+ else {
140
+ serializedAxiosError.code = error.code;
141
+ serializedAxiosError.message = error.message;
142
+ }
143
+ return serializedAxiosError;
141
144
  }
@@ -1 +1 @@
1
- {"version":3,"file":"backwards-compatibility.test.d.ts","sourceRoot":"","sources":["../../../src/tests/backwards-compatibility/backwards-compatibility.test.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,cAAc,EAGd,WAAW,EAEX,kBAAkB,EAKnB,MAAM,gCAAgC,CAAC;AAgBxC,wBAAgB,0BAA0B,CAAC,WAAW,EAAE,WAAW,GAAG,cAAc,GAAG,kBAAkB,EAAE,eAAe,EAAE,WAAW,GAAG,cAAc,GAAG,kBAAkB,QA8C5K"}
1
+ {"version":3,"file":"backwards-compatibility.test.d.ts","sourceRoot":"","sources":["../../../src/tests/backwards-compatibility/backwards-compatibility.test.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,cAAc,EAGd,WAAW,EAEX,kBAAkB,EAKnB,MAAM,gCAAgC,CAAC;AAgBxC,wBAAgB,0BAA0B,CAAC,WAAW,EAAE,WAAW,GAAG,cAAc,GAAG,kBAAkB,EAAE,eAAe,EAAE,WAAW,GAAG,cAAc,GAAG,kBAAkB,QAmD5K"}
@@ -23,9 +23,14 @@ function checkFunctionCompatibility(newFunction, currentFunction) {
23
23
  // This check fails if it's a constructor, as those don't have a return type
24
24
  if (currentFunction instanceof api_extractor_model_1.ApiFunction && newFunction instanceof api_extractor_model_1.ApiFunction) {
25
25
  if (!((_a = currentFunction.returnTypeExcerpt) === null || _a === void 0 ? void 0 : _a.isEmpty)) {
26
- it(`Function ${newFunction.displayName} should have the same return type as the current function`, () => {
27
- expect(newFunction.returnTypeExcerpt.text).toEqual(currentFunction.returnTypeExcerpt.text);
28
- });
26
+ if (newFunction.returnTypeExcerpt.text != currentFunction.returnTypeExcerpt.text) {
27
+ // This will pass, if the new implementation is an object and the current one is not specified or a hard-coded type.
28
+ if (!(currentFunction.returnTypeExcerpt.text.split(" ").length != 1 && newFunction.returnTypeExcerpt.text.split(" ").length == 1)) {
29
+ it(`Function ${newFunction.displayName} should have the same return type as the current function`, () => {
30
+ expect(newFunction.returnTypeExcerpt.text).toEqual(currentFunction.returnTypeExcerpt.text);
31
+ });
32
+ }
33
+ }
29
34
  }
30
35
  }
31
36
  it(`Function ${newFunction.displayName} should have all new parameters as optional`, () => {
@@ -17,7 +17,7 @@ async function createWorker(workerData) {
17
17
  });
18
18
  worker.on(workers_1.WorkerEvent.WorkerError, (error) => {
19
19
  logger.error('Worker error', error);
20
- reject();
20
+ reject(error);
21
21
  });
22
22
  worker.on(workers_1.WorkerEvent.WorkerOnline, () => {
23
23
  resolve(worker);
@@ -1 +1 @@
1
- {"version":3,"file":"process-task.d.ts","sourceRoot":"","sources":["../../src/workers/process-task.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAGxD,wBAAgB,WAAW,CAAC,cAAc,EAAE,EAC1C,IAAI,EACJ,SAAS,GACV,EAAE,oBAAoB,CAAC,cAAc,CAAC,QA2CtC"}
1
+ {"version":3,"file":"process-task.d.ts","sourceRoot":"","sources":["../../src/workers/process-task.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAGxD,wBAAgB,WAAW,CAAC,cAAc,EAAE,EAC1C,IAAI,EACJ,SAAS,GACV,EAAE,oBAAoB,CAAC,cAAc,CAAC,QAgDtC"}
@@ -9,34 +9,40 @@ const logger_1 = require("../logger/logger");
9
9
  function processTask({ task, onTimeout, }) {
10
10
  if (!node_worker_threads_1.isMainThread) {
11
11
  void (async () => {
12
- const event = node_worker_threads_1.workerData.event;
13
- const initialState = node_worker_threads_1.workerData.initialState;
14
- const initialDomainMapping = node_worker_threads_1.workerData.initialDomainMapping;
15
- const options = node_worker_threads_1.workerData.options;
16
- console = new logger_1.Logger({ event, options });
17
- const adapterState = await (0, state_1.createAdapterState)({
18
- event,
19
- initialState,
20
- initialDomainMapping,
21
- options,
22
- });
23
- if (node_worker_threads_1.parentPort && node_worker_threads_1.workerData.event) {
24
- const adapter = new worker_adapter_1.WorkerAdapter({
12
+ try {
13
+ const event = node_worker_threads_1.workerData.event;
14
+ const initialState = node_worker_threads_1.workerData.initialState;
15
+ const initialDomainMapping = node_worker_threads_1.workerData.initialDomainMapping;
16
+ const options = node_worker_threads_1.workerData.options;
17
+ console = new logger_1.Logger({ event, options });
18
+ const adapterState = await (0, state_1.createAdapterState)({
25
19
  event,
26
- adapterState,
20
+ initialState,
21
+ initialDomainMapping,
27
22
  options,
28
23
  });
29
- node_worker_threads_1.parentPort.on(workers_1.WorkerEvent.WorkerMessage, async (message) => {
30
- if (message.subject === workers_1.WorkerMessageSubject.WorkerMessageExit) {
31
- console.log('Worker received message to gracefully exit. Setting isTimeout flag and executing onTimeout function.');
32
- adapter.handleTimeout();
33
- await onTimeout({ adapter });
34
- console.log('Finished executing onTimeout function. Exiting worker.');
35
- process.exit(0);
36
- }
37
- });
38
- await task({ adapter });
39
- process.exit(0);
24
+ if (node_worker_threads_1.parentPort && node_worker_threads_1.workerData.event) {
25
+ const adapter = new worker_adapter_1.WorkerAdapter({
26
+ event,
27
+ adapterState,
28
+ options,
29
+ });
30
+ node_worker_threads_1.parentPort.on(workers_1.WorkerEvent.WorkerMessage, async (message) => {
31
+ if (message.subject === workers_1.WorkerMessageSubject.WorkerMessageExit) {
32
+ console.log('Worker received message to gracefully exit. Setting isTimeout flag and executing onTimeout function.');
33
+ adapter.handleTimeout();
34
+ await onTimeout({ adapter });
35
+ console.log('Finished executing onTimeout function. Exiting worker.');
36
+ process.exit(0);
37
+ }
38
+ });
39
+ await task({ adapter });
40
+ process.exit(0);
41
+ }
42
+ }
43
+ catch (error) {
44
+ console.error('Error while processing task.', (0, logger_1.serializeError)(error));
45
+ process.exit(1);
40
46
  }
41
47
  })();
42
48
  }
@@ -1 +1 @@
1
- {"version":3,"file":"spawn.d.ts","sourceRoot":"","sources":["../../src/workers/spawn.ts"],"names":[],"mappings":"AAYA,OAAO,EAIL,qBAAqB,EACrB,cAAc,EACf,MAAM,kBAAkB,CAAC;AA4D1B;;;;;;;;;;GAUG;AACH,wBAAsB,KAAK,CAAC,cAAc,EAAE,EAC1C,KAAK,EACL,YAAY,EACZ,UAAU,EACV,oBAAoB,EACpB,OAAO,GACR,EAAE,qBAAqB,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAiEvD;AAED,qBAAa,KAAK;IAChB,OAAO,CAAC,KAAK,CAAe;IAC5B,OAAO,CAAC,cAAc,CAAU;IAChC,OAAO,CAAC,oBAAoB,CAAkC;IAC9D,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,gBAAgB,CAA4C;IACpE,OAAO,CAAC,gBAAgB,CAA4C;IACpE,OAAO,CAAC,wBAAwB,CAA6C;IAC7E,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAA4C;gBAE/C,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,cAAc;IAiF/D,OAAO,CAAC,aAAa;YAYP,kBAAkB;CA6BjC"}
1
+ {"version":3,"file":"spawn.d.ts","sourceRoot":"","sources":["../../src/workers/spawn.ts"],"names":[],"mappings":"AAYA,OAAO,EAIL,qBAAqB,EACrB,cAAc,EACf,MAAM,kBAAkB,CAAC;AA4D1B;;;;;;;;;;GAUG;AACH,wBAAsB,KAAK,CAAC,cAAc,EAAE,EAC1C,KAAK,EACL,YAAY,EACZ,UAAU,EACV,oBAAoB,EACpB,OAAO,GACR,EAAE,qBAAqB,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAmEvD;AAED,qBAAa,KAAK;IAChB,OAAO,CAAC,KAAK,CAAe;IAC5B,OAAO,CAAC,cAAc,CAAU;IAChC,OAAO,CAAC,oBAAoB,CAAkC;IAC9D,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,gBAAgB,CAA4C;IACpE,OAAO,CAAC,gBAAgB,CAA4C;IACpE,OAAO,CAAC,wBAAwB,CAA6C;IAC7E,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAA4C;gBAE/C,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,cAAc;IAiF/D,OAAO,CAAC,aAAa;YAYP,kBAAkB;CA6BjC"}
@@ -105,10 +105,11 @@ async function spawn({ event, initialState, workerPath, initialDomainMapping, op
105
105
  }
106
106
  catch (error) {
107
107
  logger.error('Worker error while processing task', error);
108
+ return Promise.reject(error);
108
109
  }
109
110
  }
110
111
  else {
111
- console.error('Script was not found for event type: ' + event.payload.event_type + '.');
112
+ logger.error('Script was not found for event type: ' + event.payload.event_type + '.');
112
113
  try {
113
114
  await (0, control_protocol_1.emit)({
114
115
  event,
@@ -123,7 +124,8 @@ async function spawn({ event, initialState, workerPath, initialDomainMapping, op
123
124
  });
124
125
  }
125
126
  catch (error) {
126
- console.error('Error while emitting event.', (0, logger_1.serializeError)(error));
127
+ logger.error('Error while emitting event.', (0, logger_1.serializeError)(error));
128
+ return Promise.reject(error);
127
129
  }
128
130
  }
129
131
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devrev/ts-adaas",
3
- "version": "1.11.0",
3
+ "version": "1.11.1-beta.0",
4
4
  "description": "Typescript library containing the ADaaS(AirDrop as a Service) control protocol.",
5
5
  "type": "commonjs",
6
6
  "main": "./dist/index.js",