@devrev/ts-adaas 0.0.1
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/README.md +163 -0
- package/dist/src/adapter/helpers.d.ts +4 -0
- package/dist/src/adapter/helpers.js +47 -0
- package/dist/src/adapter/index.d.ts +53 -0
- package/dist/src/adapter/index.js +110 -0
- package/dist/src/adapter/index.test.d.ts +1 -0
- package/dist/src/adapter/index.test.js +105 -0
- package/dist/src/demo-extractor/index.d.ts +4 -0
- package/dist/src/demo-extractor/index.js +149 -0
- package/dist/src/demo-extractor/recipe.json +37 -0
- package/dist/src/http/client.d.ts +16 -0
- package/dist/src/http/client.js +147 -0
- package/dist/src/http/constants.d.ts +3 -0
- package/dist/src/http/constants.js +6 -0
- package/dist/src/http/index.d.ts +3 -0
- package/dist/src/http/index.js +19 -0
- package/dist/src/http/types.d.ts +12 -0
- package/dist/src/http/types.js +2 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.js +20 -0
- package/dist/src/logging/index.d.ts +31 -0
- package/dist/src/logging/index.js +60 -0
- package/dist/src/types/common.d.ts +33 -0
- package/dist/src/types/common.js +9 -0
- package/dist/src/types/extraction.d.ts +105 -0
- package/dist/src/types/extraction.js +67 -0
- package/dist/src/types/index.d.ts +2 -0
- package/dist/src/types/index.js +18 -0
- package/dist/src/uploader/index.d.ts +32 -0
- package/dist/src/uploader/index.js +95 -0
- package/dist/tests/adapter.test.d.ts +1 -0
- package/dist/tests/adapter.test.js +73 -0
- package/dist/tests/demo-extractor.test.d.ts +1 -0
- package/dist/tests/demo-extractor.test.js +97 -0
- package/dist/tests/helpers.test.d.ts +1 -0
- package/dist/tests/helpers.test.js +38 -0
- package/dist/tests/test-helpers.d.ts +2 -0
- package/dist/tests/test-helpers.js +33 -0
- package/dist/tests/types.test.d.ts +1 -0
- package/dist/tests/types.test.js +71 -0
- package/package.json +45 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { HTTPResponse } from './types';
|
|
2
|
+
export declare const defaultResponse: HTTPResponse;
|
|
3
|
+
export default class HTTPClient {
|
|
4
|
+
private retryAfter;
|
|
5
|
+
private retryAt;
|
|
6
|
+
private axiosInstance;
|
|
7
|
+
constructor();
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* Function to make a GET call to the endpoint.
|
|
11
|
+
* There is special handling for rate limit exceeded error.
|
|
12
|
+
* In case of rate limit exceeded, the function returns success as true and the delay time in seconds
|
|
13
|
+
* In case of any other error, the function returns success as false and the error message
|
|
14
|
+
*/
|
|
15
|
+
getCall(endpoint: string, headers: Record<string, string>, params?: any): Promise<HTTPResponse>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.defaultResponse = void 0;
|
|
27
|
+
const axios_1 = __importStar(require("axios"));
|
|
28
|
+
const constants_1 = require("./constants");
|
|
29
|
+
exports.defaultResponse = {
|
|
30
|
+
data: {
|
|
31
|
+
delay: 0,
|
|
32
|
+
nextPage: 1,
|
|
33
|
+
records: [],
|
|
34
|
+
},
|
|
35
|
+
message: '',
|
|
36
|
+
success: false,
|
|
37
|
+
};
|
|
38
|
+
class HTTPClient {
|
|
39
|
+
constructor() {
|
|
40
|
+
this.retryAfter = 0;
|
|
41
|
+
this.retryAt = 0;
|
|
42
|
+
this.axiosInstance = axios_1.default.create();
|
|
43
|
+
// Add request interceptor to check for retryAfter before making a request
|
|
44
|
+
this.axiosInstance.interceptors.request.use((config) => {
|
|
45
|
+
// Check if retryAfter is not 0 and return a LIMIT_EXCEEDED error
|
|
46
|
+
if (this.retryAfter !== 0) {
|
|
47
|
+
// check if the current time is greater than the retryAt time
|
|
48
|
+
const currentTime = new Date().getTime();
|
|
49
|
+
if (currentTime < this.retryAt) {
|
|
50
|
+
console.error('Rate limit exceeded. Interceptor has retryAfter: ' +
|
|
51
|
+
this.retryAfter);
|
|
52
|
+
// Rate limit exceeded.
|
|
53
|
+
return Promise.reject(constants_1.RATE_LIMIT_EXCEEDED);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
// Reset the retryAfter
|
|
57
|
+
this.retryAfter = 0;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return config;
|
|
61
|
+
}, (error) => {
|
|
62
|
+
return Promise.reject(error);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
*
|
|
67
|
+
* Function to make a GET call to the endpoint.
|
|
68
|
+
* There is special handling for rate limit exceeded error.
|
|
69
|
+
* In case of rate limit exceeded, the function returns success as true and the delay time in seconds
|
|
70
|
+
* In case of any other error, the function returns success as false and the error message
|
|
71
|
+
*/
|
|
72
|
+
async getCall(endpoint, headers,
|
|
73
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
74
|
+
params) {
|
|
75
|
+
var _a;
|
|
76
|
+
// Return the LIMIT_EXCEEDED error if the retryAfter is not 0
|
|
77
|
+
try {
|
|
78
|
+
const res = await this.axiosInstance.get(endpoint, {
|
|
79
|
+
headers: headers,
|
|
80
|
+
params: params,
|
|
81
|
+
});
|
|
82
|
+
return Object.assign(Object.assign({}, exports.defaultResponse), { data: {
|
|
83
|
+
delay: 0,
|
|
84
|
+
records: res.data,
|
|
85
|
+
}, success: true });
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
console.log('Error in getCall: ' + JSON.stringify(error));
|
|
89
|
+
// send error to adapter
|
|
90
|
+
if ((0, axios_1.isAxiosError)(error)) {
|
|
91
|
+
if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === constants_1.RATE_LIMIT_EXCEEDED_STATUS_CODE) {
|
|
92
|
+
this.retryAfter = error.response.headers['retry-after']
|
|
93
|
+
? error.response.headers['retry-after']
|
|
94
|
+
: 0;
|
|
95
|
+
this.retryAt = new Date().getTime() + this.retryAfter * 1000;
|
|
96
|
+
console.warn('Rate limit exceeded. Error code: ' +
|
|
97
|
+
error.response.status +
|
|
98
|
+
' RetryAfter: ' +
|
|
99
|
+
this.retryAfter +
|
|
100
|
+
' RetryAt: ' +
|
|
101
|
+
this.retryAt);
|
|
102
|
+
return {
|
|
103
|
+
data: {
|
|
104
|
+
delay: this.retryAfter,
|
|
105
|
+
records: [],
|
|
106
|
+
},
|
|
107
|
+
message: constants_1.RATE_LIMIT_EXCEEDED,
|
|
108
|
+
success: true,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
if (error.response) {
|
|
112
|
+
return Object.assign(Object.assign({}, exports.defaultResponse), { message: error.response.data });
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
return Object.assign(Object.assign({}, exports.defaultResponse), { message: error.message });
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
if (this.retryAfter !== 0) {
|
|
120
|
+
console.warn('Rate limit exceeded. Going to return the following response: ' +
|
|
121
|
+
JSON.stringify(error));
|
|
122
|
+
return {
|
|
123
|
+
data: {
|
|
124
|
+
delay: this.retryAfter,
|
|
125
|
+
records: [],
|
|
126
|
+
},
|
|
127
|
+
message: typeof error === 'string'
|
|
128
|
+
? error
|
|
129
|
+
: JSON.stringify(error, Object.getOwnPropertyNames(error)),
|
|
130
|
+
success: true,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
data: {
|
|
135
|
+
delay: this.retryAfter,
|
|
136
|
+
records: [],
|
|
137
|
+
},
|
|
138
|
+
message: typeof error === 'string'
|
|
139
|
+
? error
|
|
140
|
+
: JSON.stringify(error, Object.getOwnPropertyNames(error)),
|
|
141
|
+
success: false,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
exports.default = HTTPClient;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RATE_LIMIT_EXCEEDED_STATUS_CODE = exports.LAMBDA_LIMIT_EXCEEDED = exports.RATE_LIMIT_EXCEEDED = void 0;
|
|
4
|
+
exports.RATE_LIMIT_EXCEEDED = 'LIMIT_EXCEEDED';
|
|
5
|
+
exports.LAMBDA_LIMIT_EXCEEDED = 'LAMBDA_LIMIT_EXCEEDED';
|
|
6
|
+
exports.RATE_LIMIT_EXCEEDED_STATUS_CODE = 429;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./client"), exports);
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
19
|
+
__exportStar(require("./constants"), exports);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./adapter"), exports);
|
|
18
|
+
__exportStar(require("./demo-extractor"), exports);
|
|
19
|
+
__exportStar(require("./uploader"), exports);
|
|
20
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
declare enum LogLevel {
|
|
2
|
+
INFO = "info",
|
|
3
|
+
WARN = "warn",
|
|
4
|
+
ERROR = "error",
|
|
5
|
+
DEBUG = "debug"
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Logger class to log messages based on the log level.
|
|
9
|
+
* The log level can be set to one of the following:
|
|
10
|
+
* - INFO
|
|
11
|
+
* - WARN
|
|
12
|
+
* - ERROR
|
|
13
|
+
* - DEBUG
|
|
14
|
+
*
|
|
15
|
+
* The log tags can be set to any key-value pair.
|
|
16
|
+
*/
|
|
17
|
+
declare class Logger {
|
|
18
|
+
private level;
|
|
19
|
+
private logTags;
|
|
20
|
+
private static instance;
|
|
21
|
+
private constructor();
|
|
22
|
+
private log;
|
|
23
|
+
static getInstance(level: LogLevel, logTags?: Record<string, any>): Logger;
|
|
24
|
+
setTags(tags: Record<string, any>): void;
|
|
25
|
+
addTags(tags: Record<string, any>): void;
|
|
26
|
+
info(message: string): void;
|
|
27
|
+
warn(message: string): void;
|
|
28
|
+
error(message: string): void;
|
|
29
|
+
debug(message: string): void;
|
|
30
|
+
}
|
|
31
|
+
export default Logger;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var LogLevel;
|
|
4
|
+
(function (LogLevel) {
|
|
5
|
+
LogLevel["INFO"] = "info";
|
|
6
|
+
LogLevel["WARN"] = "warn";
|
|
7
|
+
LogLevel["ERROR"] = "error";
|
|
8
|
+
LogLevel["DEBUG"] = "debug";
|
|
9
|
+
})(LogLevel || (LogLevel = {}));
|
|
10
|
+
/**
|
|
11
|
+
* Logger class to log messages based on the log level.
|
|
12
|
+
* The log level can be set to one of the following:
|
|
13
|
+
* - INFO
|
|
14
|
+
* - WARN
|
|
15
|
+
* - ERROR
|
|
16
|
+
* - DEBUG
|
|
17
|
+
*
|
|
18
|
+
* The log tags can be set to any key-value pair.
|
|
19
|
+
*/
|
|
20
|
+
class Logger {
|
|
21
|
+
// Private constructor to prevent instantiation
|
|
22
|
+
constructor(level, logTags = {}) {
|
|
23
|
+
this.logTags = {};
|
|
24
|
+
this.level = level;
|
|
25
|
+
this.logTags = logTags;
|
|
26
|
+
}
|
|
27
|
+
log(level, message) {
|
|
28
|
+
if (this.level === level) {
|
|
29
|
+
console.log(`[${level.toUpperCase()}]: ${message}`, this.logTags);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
// Singleton instance
|
|
33
|
+
static getInstance(level, logTags = {}) {
|
|
34
|
+
if (!Logger.instance) {
|
|
35
|
+
Logger.instance = new Logger(level, logTags);
|
|
36
|
+
}
|
|
37
|
+
return Logger.instance;
|
|
38
|
+
}
|
|
39
|
+
// Set log tags destructively.
|
|
40
|
+
setTags(tags) {
|
|
41
|
+
this.logTags = tags;
|
|
42
|
+
}
|
|
43
|
+
// Add log tags. If the key already exists, it will be overwritten.
|
|
44
|
+
addTags(tags) {
|
|
45
|
+
this.logTags = Object.assign(Object.assign({}, this.logTags), tags);
|
|
46
|
+
}
|
|
47
|
+
info(message) {
|
|
48
|
+
this.log(LogLevel.INFO, message);
|
|
49
|
+
}
|
|
50
|
+
warn(message) {
|
|
51
|
+
this.log(LogLevel.WARN, message);
|
|
52
|
+
}
|
|
53
|
+
error(message) {
|
|
54
|
+
this.log(LogLevel.ERROR, message);
|
|
55
|
+
}
|
|
56
|
+
debug(message) {
|
|
57
|
+
this.log(LogLevel.DEBUG, message);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.default = Logger;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export declare enum ErrorLevel {
|
|
2
|
+
Warning = "WARNING",
|
|
3
|
+
Error = "ERROR",
|
|
4
|
+
Info = "INFO"
|
|
5
|
+
}
|
|
6
|
+
export interface ErrorRecord {
|
|
7
|
+
message: string;
|
|
8
|
+
}
|
|
9
|
+
export interface LogRecord {
|
|
10
|
+
level: ErrorLevel;
|
|
11
|
+
message: string;
|
|
12
|
+
}
|
|
13
|
+
export interface Artifact {
|
|
14
|
+
id: string;
|
|
15
|
+
item_type: string;
|
|
16
|
+
item_count: number;
|
|
17
|
+
}
|
|
18
|
+
export interface ArtifactsPrepareResponse {
|
|
19
|
+
url: string;
|
|
20
|
+
id: string;
|
|
21
|
+
form_data: {
|
|
22
|
+
key: string;
|
|
23
|
+
value: string;
|
|
24
|
+
}[];
|
|
25
|
+
}
|
|
26
|
+
export interface AdapterUpdateParams {
|
|
27
|
+
artifact?: Artifact;
|
|
28
|
+
extractor_state?: object;
|
|
29
|
+
}
|
|
30
|
+
export interface UploadResponse {
|
|
31
|
+
artifact?: Artifact;
|
|
32
|
+
error?: ErrorRecord;
|
|
33
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ErrorLevel = void 0;
|
|
4
|
+
var ErrorLevel;
|
|
5
|
+
(function (ErrorLevel) {
|
|
6
|
+
ErrorLevel["Warning"] = "WARNING";
|
|
7
|
+
ErrorLevel["Error"] = "ERROR";
|
|
8
|
+
ErrorLevel["Info"] = "INFO";
|
|
9
|
+
})(ErrorLevel || (exports.ErrorLevel = ErrorLevel = {}));
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { InputData, Context, ExecutionMetadata } from '@devrev/typescript-sdk/dist/snap-ins';
|
|
2
|
+
import { Artifact, ErrorRecord } from './common';
|
|
3
|
+
export declare enum EventType {
|
|
4
|
+
ExtractionExternalSyncUnitsStart = "EXTRACTION_EXTERNAL_SYNC_UNITS_START",
|
|
5
|
+
ExtractionMetadataStart = "EXTRACTION_METADATA_START",
|
|
6
|
+
ExtractionDataStart = "EXTRACTION_DATA_START",
|
|
7
|
+
ExtractionDataContinue = "EXTRACTION_DATA_CONTINUE",
|
|
8
|
+
ExtractionDataDelete = "EXTRACTION_DATA_DELETE",
|
|
9
|
+
ExtractionAttachmentsStart = "EXTRACTION_ATTACHMENTS_START",
|
|
10
|
+
ExtractionAttachmentsContinue = "EXTRACTION_ATTACHMENTS_CONTINUE",
|
|
11
|
+
ExtractionAttachmentsDelete = "EXTRACTION_ATTACHMENTS_DELETE"
|
|
12
|
+
}
|
|
13
|
+
export declare enum ExtractorEventType {
|
|
14
|
+
ExtractionExternalSyncUnitsDone = "EXTRACTION_EXTERNAL_SYNC_UNITS_DONE",
|
|
15
|
+
ExtractionExternalSyncUnitsError = "EXTRACTION_EXTERNAL_SYNC_UNITS_ERROR",
|
|
16
|
+
ExtractionMetadataDone = "EXTRACTION_METADATA_DONE",
|
|
17
|
+
ExtractionMetadataError = "EXTRACTION_METADATA_ERROR",
|
|
18
|
+
ExtractionDataProgress = "EXTRACTION_DATA_PROGRESS",
|
|
19
|
+
ExtractionDataDelay = "EXTRACTION_DATA_DELAY",
|
|
20
|
+
ExtractionDataDone = "EXTRACTION_DATA_DONE",
|
|
21
|
+
ExtractionDataError = "EXTRACTION_DATA_ERROR",
|
|
22
|
+
ExtractionDataDeleteDone = "EXTRACTION_DATA_DELETE_DONE",
|
|
23
|
+
ExtractionDataDeleteError = "EXTRACTION_DATA_DELETE_ERROR",
|
|
24
|
+
ExtractionAttachmentsProgress = "EXTRACTION_ATTACHMENTS_PROGRESS",
|
|
25
|
+
ExtractionAttachmentsDelay = "EXTRACTION_ATTACHMENTS_DELAY",
|
|
26
|
+
ExtractionAttachmentsDone = "EXTRACTION_ATTACHMENTS_DONE",
|
|
27
|
+
ExtractionAttachmentsError = "EXTRACTION_ATTACHMENTS_ERROR",
|
|
28
|
+
ExtractionAttachmentsDeleteDone = "EXTRACTION_ATTACHMENTS_DELETE_DONE",
|
|
29
|
+
ExtractionAttachmentsDeleteError = "EXTRACTION_ATTACHMENTS_DELETE_ERROR"
|
|
30
|
+
}
|
|
31
|
+
export interface EventData {
|
|
32
|
+
external_sync_units?: ExternalSyncUnit[];
|
|
33
|
+
progress?: number;
|
|
34
|
+
error?: ErrorRecord;
|
|
35
|
+
delay?: number;
|
|
36
|
+
artifacts?: Artifact[];
|
|
37
|
+
}
|
|
38
|
+
export declare enum ExtractionMode {
|
|
39
|
+
INITIAL = "INITIAL",
|
|
40
|
+
INCREMENTAL = "INCREMENTAL"
|
|
41
|
+
}
|
|
42
|
+
export interface ExternalSyncUnit {
|
|
43
|
+
id: string;
|
|
44
|
+
name: string;
|
|
45
|
+
description: string;
|
|
46
|
+
item_count: number;
|
|
47
|
+
}
|
|
48
|
+
export interface EventContextIn {
|
|
49
|
+
mode: string;
|
|
50
|
+
callback_url: string;
|
|
51
|
+
dev_org_id: string;
|
|
52
|
+
dev_user_id: string;
|
|
53
|
+
external_sync_unit_id?: string;
|
|
54
|
+
sync_unit_id?: string;
|
|
55
|
+
sync_run_id: string;
|
|
56
|
+
external_system_id: string;
|
|
57
|
+
uuid: string;
|
|
58
|
+
}
|
|
59
|
+
export interface EventContextOut {
|
|
60
|
+
uuid: string;
|
|
61
|
+
sync_run: string;
|
|
62
|
+
sync_unit?: string;
|
|
63
|
+
}
|
|
64
|
+
export interface ConnectionData {
|
|
65
|
+
org_id: string;
|
|
66
|
+
org_name: string;
|
|
67
|
+
key: string;
|
|
68
|
+
key_type: string;
|
|
69
|
+
}
|
|
70
|
+
export interface EventData {
|
|
71
|
+
external_sync_units?: ExternalSyncUnit[];
|
|
72
|
+
progress?: number;
|
|
73
|
+
error?: ErrorRecord;
|
|
74
|
+
delay?: number;
|
|
75
|
+
artifacts?: Artifact[];
|
|
76
|
+
}
|
|
77
|
+
export interface DomainObjectState {
|
|
78
|
+
name: string;
|
|
79
|
+
nextChunkId: number;
|
|
80
|
+
pages?: {
|
|
81
|
+
pages: number[];
|
|
82
|
+
};
|
|
83
|
+
lastModified: string;
|
|
84
|
+
isDone: boolean;
|
|
85
|
+
count: number;
|
|
86
|
+
}
|
|
87
|
+
export interface AirdropEvent {
|
|
88
|
+
context: Context;
|
|
89
|
+
payload: AirdropMessage;
|
|
90
|
+
execution_metadata: ExecutionMetadata;
|
|
91
|
+
input_data: InputData;
|
|
92
|
+
}
|
|
93
|
+
export interface AirdropMessage {
|
|
94
|
+
connection_data: ConnectionData;
|
|
95
|
+
event_context: EventContextIn;
|
|
96
|
+
event_type: EventType;
|
|
97
|
+
event_data?: EventData;
|
|
98
|
+
extractor_state?: any;
|
|
99
|
+
}
|
|
100
|
+
export interface ExtractorEvent {
|
|
101
|
+
event_type: string;
|
|
102
|
+
event_context: EventContextOut;
|
|
103
|
+
extractor_state: string;
|
|
104
|
+
event_data?: EventData;
|
|
105
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExtractionMode = exports.ExtractorEventType = exports.EventType = void 0;
|
|
4
|
+
var EventType;
|
|
5
|
+
(function (EventType) {
|
|
6
|
+
// Get the list of sync units (repos, projects, ...) that can be extracted
|
|
7
|
+
EventType["ExtractionExternalSyncUnitsStart"] = "EXTRACTION_EXTERNAL_SYNC_UNITS_START";
|
|
8
|
+
// Start the extraction of external sync unit's metadata (repos, projects, ...)
|
|
9
|
+
EventType["ExtractionMetadataStart"] = "EXTRACTION_METADATA_START";
|
|
10
|
+
// Start the extraction of a specific external sync unit
|
|
11
|
+
EventType["ExtractionDataStart"] = "EXTRACTION_DATA_START";
|
|
12
|
+
// Continue the extraction of a specific external sync unit
|
|
13
|
+
EventType["ExtractionDataContinue"] = "EXTRACTION_DATA_CONTINUE";
|
|
14
|
+
// Give the external extractor an opportunity to clean up after itself
|
|
15
|
+
EventType["ExtractionDataDelete"] = "EXTRACTION_DATA_DELETE";
|
|
16
|
+
// Extract all the attachments for a specific external sync unit
|
|
17
|
+
EventType["ExtractionAttachmentsStart"] = "EXTRACTION_ATTACHMENTS_START";
|
|
18
|
+
// Continue the extraction of attachments for a specific external sync unit
|
|
19
|
+
EventType["ExtractionAttachmentsContinue"] = "EXTRACTION_ATTACHMENTS_CONTINUE";
|
|
20
|
+
// Give the external extractor an opportunity to clean up after extractions of external sync units
|
|
21
|
+
EventType["ExtractionAttachmentsDelete"] = "EXTRACTION_ATTACHMENTS_DELETE";
|
|
22
|
+
})(EventType || (exports.EventType = EventType = {}));
|
|
23
|
+
var ExtractorEventType;
|
|
24
|
+
(function (ExtractorEventType) {
|
|
25
|
+
/* Sync Units */
|
|
26
|
+
// Sent when the extraction of external sync units finished
|
|
27
|
+
ExtractorEventType["ExtractionExternalSyncUnitsDone"] = "EXTRACTION_EXTERNAL_SYNC_UNITS_DONE";
|
|
28
|
+
// Sent when there was an unrecoverable error for extraction of external sync units.
|
|
29
|
+
// Must contain a list of error records.
|
|
30
|
+
ExtractorEventType["ExtractionExternalSyncUnitsError"] = "EXTRACTION_EXTERNAL_SYNC_UNITS_ERROR";
|
|
31
|
+
/* Metadata */
|
|
32
|
+
// Sent when the extraction of metadata finished
|
|
33
|
+
ExtractorEventType["ExtractionMetadataDone"] = "EXTRACTION_METADATA_DONE";
|
|
34
|
+
// Sent when there was an unrecoverable error for extraction of metadata.
|
|
35
|
+
ExtractorEventType["ExtractionMetadataError"] = "EXTRACTION_METADATA_ERROR";
|
|
36
|
+
/* Data */
|
|
37
|
+
// Sent after a batch was extracted, contains artifact IDs of the uploaded files
|
|
38
|
+
ExtractorEventType["ExtractionDataProgress"] = "EXTRACTION_DATA_PROGRESS";
|
|
39
|
+
// Sent when there is a rate limit of more than ~1m, adapter will restart the extraction after the delay
|
|
40
|
+
ExtractorEventType["ExtractionDataDelay"] = "EXTRACTION_DATA_DELAY";
|
|
41
|
+
// Sent when the extraction of data finished
|
|
42
|
+
ExtractorEventType["ExtractionDataDone"] = "EXTRACTION_DATA_DONE";
|
|
43
|
+
// Sent when there was an unrecoverable error for extraction of data
|
|
44
|
+
ExtractorEventType["ExtractionDataError"] = "EXTRACTION_DATA_ERROR";
|
|
45
|
+
// Sent when the external extractor has finished cleaning up after itself
|
|
46
|
+
ExtractorEventType["ExtractionDataDeleteDone"] = "EXTRACTION_DATA_DELETE_DONE";
|
|
47
|
+
// Sent when there was an unrecoverable error for extraction of data
|
|
48
|
+
ExtractorEventType["ExtractionDataDeleteError"] = "EXTRACTION_DATA_DELETE_ERROR";
|
|
49
|
+
/* Attachments */
|
|
50
|
+
// Sent after a batch was extracted, contains artifact IDs of the uploaded files
|
|
51
|
+
ExtractorEventType["ExtractionAttachmentsProgress"] = "EXTRACTION_ATTACHMENTS_PROGRESS";
|
|
52
|
+
// Sent when there is a rate limit of more than ~30s, adapter will restart the extraction after the delay
|
|
53
|
+
ExtractorEventType["ExtractionAttachmentsDelay"] = "EXTRACTION_ATTACHMENTS_DELAY";
|
|
54
|
+
// Sent when the extraction of attachements is finished
|
|
55
|
+
ExtractorEventType["ExtractionAttachmentsDone"] = "EXTRACTION_ATTACHMENTS_DONE";
|
|
56
|
+
// Sent when there was an unrecoverable error for extraction of attachments
|
|
57
|
+
ExtractorEventType["ExtractionAttachmentsError"] = "EXTRACTION_ATTACHMENTS_ERROR";
|
|
58
|
+
// Sent when the external extractor has finished cleaning up after itself
|
|
59
|
+
ExtractorEventType["ExtractionAttachmentsDeleteDone"] = "EXTRACTION_ATTACHMENTS_DELETE_DONE";
|
|
60
|
+
// Sent when there was an unrecoverable error for extraction of attachments
|
|
61
|
+
ExtractorEventType["ExtractionAttachmentsDeleteError"] = "EXTRACTION_ATTACHMENTS_DELETE_ERROR";
|
|
62
|
+
})(ExtractorEventType || (exports.ExtractorEventType = ExtractorEventType = {}));
|
|
63
|
+
var ExtractionMode;
|
|
64
|
+
(function (ExtractionMode) {
|
|
65
|
+
ExtractionMode["INITIAL"] = "INITIAL";
|
|
66
|
+
ExtractionMode["INCREMENTAL"] = "INCREMENTAL";
|
|
67
|
+
})(ExtractionMode || (exports.ExtractionMode = ExtractionMode = {}));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./common"), exports);
|
|
18
|
+
__exportStar(require("./extraction"), exports);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { UploadResponse } from '../types/common';
|
|
2
|
+
/**
|
|
3
|
+
* Uploader class is used to upload files to the DevRev platform.
|
|
4
|
+
* The class provides utilities to
|
|
5
|
+
* - prepare artifact
|
|
6
|
+
* - upload artifact
|
|
7
|
+
* - return the artifact information to the platform
|
|
8
|
+
*
|
|
9
|
+
* @class Uploader
|
|
10
|
+
* @constructor
|
|
11
|
+
* @param {string} endpoint - The endpoint of the DevRev platform
|
|
12
|
+
* @param {string} token - The token to authenticate with the DevRev platform
|
|
13
|
+
*/
|
|
14
|
+
export declare class Uploader {
|
|
15
|
+
private betaDevrevSdk;
|
|
16
|
+
private publicDevrevSdk;
|
|
17
|
+
constructor(endpoint: string, token: string);
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* Uploads the file to the DevRev platform. The file is uploaded to the platform
|
|
21
|
+
* and the artifact information is returned.
|
|
22
|
+
*
|
|
23
|
+
* @param {string} filename - The name of the file to be uploaded
|
|
24
|
+
* @param {string} entity - The entity type of the file to be uploaded
|
|
25
|
+
* @param {object[] | object} fetchedObjects - The objects to be uploaded
|
|
26
|
+
* @param filetype - The type of the file to be uploaded
|
|
27
|
+
* @returns {Promise<UploadResponse>} - The response object containing the artifact information
|
|
28
|
+
*/
|
|
29
|
+
upload(filename: string, entity: string, fetchedObjects: object[] | object, filetype?: string): Promise<UploadResponse>;
|
|
30
|
+
private prepareArtifact;
|
|
31
|
+
private uploadToArtifact;
|
|
32
|
+
}
|