@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,95 @@
|
|
|
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.Uploader = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const typescript_sdk_1 = require("@devrev/typescript-sdk");
|
|
9
|
+
const helpers_1 = require("../adapter/helpers");
|
|
10
|
+
/**
|
|
11
|
+
* Uploader class is used to upload files to the DevRev platform.
|
|
12
|
+
* The class provides utilities to
|
|
13
|
+
* - prepare artifact
|
|
14
|
+
* - upload artifact
|
|
15
|
+
* - return the artifact information to the platform
|
|
16
|
+
*
|
|
17
|
+
* @class Uploader
|
|
18
|
+
* @constructor
|
|
19
|
+
* @param {string} endpoint - The endpoint of the DevRev platform
|
|
20
|
+
* @param {string} token - The token to authenticate with the DevRev platform
|
|
21
|
+
*/
|
|
22
|
+
class Uploader {
|
|
23
|
+
constructor(endpoint, token) {
|
|
24
|
+
this.betaDevrevSdk = typescript_sdk_1.client.setupBeta({
|
|
25
|
+
endpoint,
|
|
26
|
+
token,
|
|
27
|
+
});
|
|
28
|
+
this.publicDevrevSdk = typescript_sdk_1.client.setup({ endpoint, token });
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
*
|
|
32
|
+
* Uploads the file to the DevRev platform. The file is uploaded to the platform
|
|
33
|
+
* and the artifact information is returned.
|
|
34
|
+
*
|
|
35
|
+
* @param {string} filename - The name of the file to be uploaded
|
|
36
|
+
* @param {string} entity - The entity type of the file to be uploaded
|
|
37
|
+
* @param {object[] | object} fetchedObjects - The objects to be uploaded
|
|
38
|
+
* @param filetype - The type of the file to be uploaded
|
|
39
|
+
* @returns {Promise<UploadResponse>} - The response object containing the artifact information
|
|
40
|
+
*/
|
|
41
|
+
async upload(filename, entity, fetchedObjects, filetype = 'application/jsonl+json') {
|
|
42
|
+
const preparedArtifact = await this.prepareArtifact(filename, filetype);
|
|
43
|
+
if (!preparedArtifact) {
|
|
44
|
+
return {
|
|
45
|
+
artifact: undefined,
|
|
46
|
+
error: { message: 'Error while preparing artifact' },
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
const uploadedArtifact = await this.uploadToArtifact(preparedArtifact, fetchedObjects);
|
|
50
|
+
if (!uploadedArtifact) {
|
|
51
|
+
return {
|
|
52
|
+
artifact: undefined,
|
|
53
|
+
error: { message: 'Error while uploading artifact' },
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
// If file was successfully uploaded we want to post data about that file when emitting
|
|
57
|
+
const itemCount = Array.isArray(fetchedObjects) ? fetchedObjects.length : 1;
|
|
58
|
+
const artifact = {
|
|
59
|
+
id: preparedArtifact.id,
|
|
60
|
+
item_type: entity,
|
|
61
|
+
item_count: itemCount,
|
|
62
|
+
};
|
|
63
|
+
return { artifact, error: undefined };
|
|
64
|
+
}
|
|
65
|
+
async prepareArtifact(filename, filetype) {
|
|
66
|
+
try {
|
|
67
|
+
const response = await this.betaDevrevSdk.artifactsPrepare({
|
|
68
|
+
file_name: filename,
|
|
69
|
+
file_type: filetype,
|
|
70
|
+
});
|
|
71
|
+
return response.data;
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
throw new Error('Error while fetching upload url: ' + error);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
async uploadToArtifact(
|
|
78
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
79
|
+
preparedArtifact, fetchedObjects) {
|
|
80
|
+
const formData = (0, helpers_1.createFormData)(preparedArtifact, fetchedObjects);
|
|
81
|
+
try {
|
|
82
|
+
const response = await axios_1.default.post(preparedArtifact.url, formData, {
|
|
83
|
+
headers: {
|
|
84
|
+
'Content-Type': 'multipart/form',
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
return response;
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
console.error('Error while uploading artifact: ' + error);
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
exports.Uploader = Uploader;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
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
|
+
const axios_1 = __importDefault(require("axios"));
|
|
7
|
+
const adapter_1 = require("../src/adapter");
|
|
8
|
+
const types_1 = require("../src/types");
|
|
9
|
+
const test_helpers_1 = require("./test-helpers");
|
|
10
|
+
describe('Adapter', () => {
|
|
11
|
+
it('should be able to create an instance of Adapter', () => {
|
|
12
|
+
const event = (0, test_helpers_1.createAirdropEvent)(types_1.EventType.ExtractionExternalSyncUnitsStart);
|
|
13
|
+
const adapter = new adapter_1.Adapter(event);
|
|
14
|
+
expect(adapter).toBeInstanceOf(adapter_1.Adapter);
|
|
15
|
+
});
|
|
16
|
+
describe('update', () => {
|
|
17
|
+
it('should add an artifact to the artifacts array', () => {
|
|
18
|
+
const event = (0, test_helpers_1.createAirdropEvent)(types_1.EventType.ExtractionDataStart);
|
|
19
|
+
const adapter = new adapter_1.Adapter(event);
|
|
20
|
+
const artifact = { id: 'id', item_type: 'item_type', item_count: 1 };
|
|
21
|
+
adapter.update({ artifact });
|
|
22
|
+
expect(adapter.getArtifacts()).toContain(artifact);
|
|
23
|
+
});
|
|
24
|
+
it('should not add anything if artifact is not provided', () => {
|
|
25
|
+
const event = (0, test_helpers_1.createAirdropEvent)(types_1.EventType.ExtractionDataStart);
|
|
26
|
+
const adapter = new adapter_1.Adapter(event);
|
|
27
|
+
adapter.update({});
|
|
28
|
+
expect(adapter.getArtifacts()).toHaveLength(0);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
describe('emit', () => {
|
|
32
|
+
it('should call axios.post with correct parameters - case without error', async () => {
|
|
33
|
+
const event = (0, test_helpers_1.createAirdropEvent)(types_1.EventType.ExtractionDataStart);
|
|
34
|
+
const adapter = new adapter_1.Adapter(event);
|
|
35
|
+
const axiosSpy = jest.spyOn(axios_1.default, 'post').mockResolvedValue({});
|
|
36
|
+
const newEventType = types_1.ExtractorEventType.ExtractionDataDone;
|
|
37
|
+
await adapter.emit(newEventType);
|
|
38
|
+
expect(axiosSpy).toHaveBeenCalledWith(event.payload.event_context.callback_url, expect.objectContaining({
|
|
39
|
+
event_type: newEventType,
|
|
40
|
+
}), expect.objectContaining({
|
|
41
|
+
headers: {
|
|
42
|
+
Accept: 'application/json, text/plain, */*',
|
|
43
|
+
Authorization: event.context.secrets["service_account_token"],
|
|
44
|
+
'Content-Type': 'application/json',
|
|
45
|
+
},
|
|
46
|
+
}));
|
|
47
|
+
axiosSpy.mockRestore();
|
|
48
|
+
});
|
|
49
|
+
it('should call axios.post with correct parameters - case with error', async () => {
|
|
50
|
+
const event = (0, test_helpers_1.createAirdropEvent)(types_1.EventType.ExtractionDataStart);
|
|
51
|
+
const adapter = new adapter_1.Adapter(event);
|
|
52
|
+
const axiosSpy = jest.spyOn(axios_1.default, 'post').mockResolvedValue({});
|
|
53
|
+
const newEventType = types_1.ExtractorEventType.ExtractionDataError;
|
|
54
|
+
const data = {
|
|
55
|
+
error: { message: 'some error message' },
|
|
56
|
+
};
|
|
57
|
+
await adapter.emit(newEventType, data);
|
|
58
|
+
expect(axiosSpy).toHaveBeenCalledWith(event.payload.event_context.callback_url, expect.objectContaining({
|
|
59
|
+
event_type: newEventType,
|
|
60
|
+
event_data: expect.objectContaining({
|
|
61
|
+
error: data.error,
|
|
62
|
+
}),
|
|
63
|
+
}), expect.objectContaining({
|
|
64
|
+
headers: {
|
|
65
|
+
Accept: 'application/json, text/plain, */*',
|
|
66
|
+
Authorization: event.context.secrets["service_account_token"],
|
|
67
|
+
'Content-Type': 'application/json',
|
|
68
|
+
},
|
|
69
|
+
}));
|
|
70
|
+
axiosSpy.mockRestore();
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const types_1 = require("../src/types");
|
|
4
|
+
const adapter_1 = require("../src/adapter");
|
|
5
|
+
const uploader_1 = require("../src/uploader");
|
|
6
|
+
const demo_extractor_1 = require("../src/demo-extractor");
|
|
7
|
+
const test_helpers_1 = require("./test-helpers");
|
|
8
|
+
jest.mock('../src/adapter');
|
|
9
|
+
jest.mock('../src/uploader');
|
|
10
|
+
describe('DemoExtractor', () => {
|
|
11
|
+
let adapterMock;
|
|
12
|
+
let uploaderMock;
|
|
13
|
+
let demoExtractor;
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
adapterMock = new adapter_1.Adapter({});
|
|
16
|
+
uploaderMock = new uploader_1.Uploader('', '');
|
|
17
|
+
adapter_1.Adapter.mockImplementation(() => adapterMock);
|
|
18
|
+
uploader_1.Uploader.mockImplementation(() => uploaderMock);
|
|
19
|
+
demoExtractor = new demo_extractor_1.DemoExtractor();
|
|
20
|
+
});
|
|
21
|
+
afterEach(() => {
|
|
22
|
+
jest.resetAllMocks();
|
|
23
|
+
});
|
|
24
|
+
it('should be able to create an instance of DemoExtractor', () => {
|
|
25
|
+
expect(demoExtractor).toBeInstanceOf(demo_extractor_1.DemoExtractor);
|
|
26
|
+
});
|
|
27
|
+
it('should emit ExtractionExternalSyncUnitsDone when EventType is ExtractionExternalSyncUnitsStart', async () => {
|
|
28
|
+
const event = (0, test_helpers_1.createAirdropEvent)(types_1.EventType.ExtractionExternalSyncUnitsStart);
|
|
29
|
+
await demoExtractor.run(event);
|
|
30
|
+
expect(adapterMock.emit).toHaveBeenCalledWith(types_1.ExtractorEventType.ExtractionExternalSyncUnitsDone, expect.objectContaining({
|
|
31
|
+
external_sync_units: [
|
|
32
|
+
{
|
|
33
|
+
id: 'devrev',
|
|
34
|
+
name: 'devrev',
|
|
35
|
+
description: 'Loopback for DevRev',
|
|
36
|
+
item_count: 0,
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
}));
|
|
40
|
+
});
|
|
41
|
+
it('should emit ExtractionMetadataDone when metadata is uploaded successfully', async () => {
|
|
42
|
+
const event = (0, test_helpers_1.createAirdropEvent)(types_1.EventType.ExtractionMetadataStart);
|
|
43
|
+
const artifact = { id: 'id', item_type: 'item_type', item_count: 1 };
|
|
44
|
+
uploaderMock.upload.mockResolvedValueOnce({ artifact, error: undefined });
|
|
45
|
+
await demoExtractor.run(event);
|
|
46
|
+
expect(adapterMock.update).toHaveBeenCalledWith({ artifact });
|
|
47
|
+
expect(adapterMock.emit).toHaveBeenCalledWith(types_1.ExtractorEventType.ExtractionMetadataDone);
|
|
48
|
+
});
|
|
49
|
+
it("should emit ExtractionMetadataError when there's an error uploading metadata", async () => {
|
|
50
|
+
const event = (0, test_helpers_1.createAirdropEvent)(types_1.EventType.ExtractionMetadataStart);
|
|
51
|
+
const error = new Error('Failed to upload metadata');
|
|
52
|
+
uploaderMock.upload.mockResolvedValueOnce({ artifact: undefined, error });
|
|
53
|
+
await demoExtractor.run(event);
|
|
54
|
+
expect(adapterMock.emit).toHaveBeenCalledWith(types_1.ExtractorEventType.ExtractionMetadataError, { error });
|
|
55
|
+
});
|
|
56
|
+
it('should emit ExtractionDataProgress when data is uploaded successfully', async () => {
|
|
57
|
+
const event = (0, test_helpers_1.createAirdropEvent)(types_1.EventType.ExtractionDataStart);
|
|
58
|
+
const artifact = { id: 'id', item_type: 'item_type', item_count: 1 };
|
|
59
|
+
uploaderMock.upload.mockResolvedValueOnce({ artifact, error: undefined });
|
|
60
|
+
await demoExtractor.run(event);
|
|
61
|
+
expect(adapterMock.update).toHaveBeenCalledWith({ artifact });
|
|
62
|
+
expect(adapterMock.emit).toHaveBeenCalledWith(types_1.ExtractorEventType.ExtractionDataProgress, { progress: 50 });
|
|
63
|
+
});
|
|
64
|
+
it('should emit ExtractionDataDone when data is uploaded successfully', async () => {
|
|
65
|
+
const event = (0, test_helpers_1.createAirdropEvent)(types_1.EventType.ExtractionDataContinue);
|
|
66
|
+
const artifact = { id: 'id', item_type: 'item_type', item_count: 1 };
|
|
67
|
+
uploaderMock.upload
|
|
68
|
+
.mockResolvedValueOnce({ artifact, error: undefined }) // First call to upload (users data)
|
|
69
|
+
.mockResolvedValueOnce({ artifact, error: undefined }); // Second call to upload (recipe.json)
|
|
70
|
+
await demoExtractor.run(event);
|
|
71
|
+
expect(adapterMock.update).toHaveBeenCalledTimes(2);
|
|
72
|
+
expect(adapterMock.update).toHaveBeenCalledWith({ artifact });
|
|
73
|
+
expect(adapterMock.emit).toHaveBeenCalledWith(types_1.ExtractorEventType.ExtractionDataDone, { progress: 100 });
|
|
74
|
+
});
|
|
75
|
+
it("should emit ExtractionDataError when there's an error uploading data", async () => {
|
|
76
|
+
const event = (0, test_helpers_1.createAirdropEvent)(types_1.EventType.ExtractionDataStart);
|
|
77
|
+
const error = new Error('Failed to upload data');
|
|
78
|
+
uploaderMock.upload.mockResolvedValueOnce({ artifact: undefined, error });
|
|
79
|
+
await demoExtractor.run(event);
|
|
80
|
+
expect(adapterMock.emit).toHaveBeenCalledWith(types_1.ExtractorEventType.ExtractionDataError, { error });
|
|
81
|
+
});
|
|
82
|
+
it('should emit ExtractionAttachmentsDone when attachments are uploaded successfully', async () => {
|
|
83
|
+
const event = (0, test_helpers_1.createAirdropEvent)(types_1.EventType.ExtractionAttachmentsStart);
|
|
84
|
+
const artifact = { id: 'id', item_type: 'item_type', item_count: 1 };
|
|
85
|
+
uploaderMock.upload.mockResolvedValueOnce({ artifact, error: undefined });
|
|
86
|
+
await demoExtractor.run(event);
|
|
87
|
+
expect(adapterMock.update).toHaveBeenCalledWith({ artifact });
|
|
88
|
+
expect(adapterMock.emit).toHaveBeenCalledWith(types_1.ExtractorEventType.ExtractionAttachmentsProgress);
|
|
89
|
+
});
|
|
90
|
+
it("should emit ExtractionAttachmentsError when there's an error uploading attachments", async () => {
|
|
91
|
+
const event = (0, test_helpers_1.createAirdropEvent)(types_1.EventType.ExtractionAttachmentsStart);
|
|
92
|
+
const error = new Error('Failed to upload attachment');
|
|
93
|
+
uploaderMock.upload.mockResolvedValueOnce({ artifact: undefined, error });
|
|
94
|
+
await demoExtractor.run(event);
|
|
95
|
+
expect(adapterMock.emit).toHaveBeenCalledWith(types_1.ExtractorEventType.ExtractionAttachmentsError, { error });
|
|
96
|
+
});
|
|
97
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const helpers_1 = require("../src/adapter/helpers");
|
|
4
|
+
const types_1 = require("../src/types");
|
|
5
|
+
describe('createFormData', () => {
|
|
6
|
+
it('should create a FormData object', () => {
|
|
7
|
+
const preparedArtifact = {
|
|
8
|
+
form_data: [{ key: 'key', value: 'value' }],
|
|
9
|
+
};
|
|
10
|
+
const fetchedObjects = [{ key: 'value' }];
|
|
11
|
+
const formData = (0, helpers_1.createFormData)(preparedArtifact, fetchedObjects);
|
|
12
|
+
expect(formData).toBeInstanceOf(FormData);
|
|
13
|
+
expect(formData.get('key')).toBe('value');
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
describe('createArtifact', () => {
|
|
17
|
+
it('should create an Artifact object', () => {
|
|
18
|
+
const preparedArtifact = { id: 'id' };
|
|
19
|
+
const fetchedObjects = [{ key: 'value' }];
|
|
20
|
+
const entity = 'entity';
|
|
21
|
+
const artifact = (0, helpers_1.createArtifact)(preparedArtifact, fetchedObjects, entity);
|
|
22
|
+
expect(artifact).toEqual({
|
|
23
|
+
item_count: 1,
|
|
24
|
+
id: 'id',
|
|
25
|
+
item_type: 'entity',
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
describe('getTimeoutExtractorEventType', () => {
|
|
30
|
+
it('should return the correct ExtractorEventType', () => {
|
|
31
|
+
expect((0, helpers_1.getTimeoutExtractorEventType)(types_1.EventType.ExtractionMetadataStart)).toBe(types_1.ExtractorEventType.ExtractionMetadataError);
|
|
32
|
+
expect((0, helpers_1.getTimeoutExtractorEventType)(types_1.EventType.ExtractionDataStart)).toBe(types_1.ExtractorEventType.ExtractionDataProgress);
|
|
33
|
+
expect((0, helpers_1.getTimeoutExtractorEventType)(types_1.EventType.ExtractionDataContinue)).toBe(types_1.ExtractorEventType.ExtractionDataProgress);
|
|
34
|
+
expect((0, helpers_1.getTimeoutExtractorEventType)(types_1.EventType.ExtractionAttachmentsStart)).toBe(types_1.ExtractorEventType.ExtractionAttachmentsProgress);
|
|
35
|
+
expect((0, helpers_1.getTimeoutExtractorEventType)(types_1.EventType.ExtractionAttachmentsContinue)).toBe(types_1.ExtractorEventType.ExtractionAttachmentsProgress);
|
|
36
|
+
expect((0, helpers_1.getTimeoutExtractorEventType)(types_1.EventType.ExtractionExternalSyncUnitsStart)).toBe(types_1.ExtractorEventType.ExtractionExternalSyncUnitsError);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createAirdropEvent = void 0;
|
|
4
|
+
function createAirdropEvent(event_type, overrides) {
|
|
5
|
+
return Object.assign({ execution_metadata: {
|
|
6
|
+
devrev_endpoint: 'devrev_endpoint',
|
|
7
|
+
}, context: {
|
|
8
|
+
secrets: {
|
|
9
|
+
service_account_token: 'service_account_token',
|
|
10
|
+
},
|
|
11
|
+
}, payload: {
|
|
12
|
+
connection_data: {
|
|
13
|
+
org_id: 'org_id',
|
|
14
|
+
org_name: 'org_name',
|
|
15
|
+
key: 'key',
|
|
16
|
+
key_type: 'key_type',
|
|
17
|
+
},
|
|
18
|
+
event_context: {
|
|
19
|
+
mode: 'mode',
|
|
20
|
+
callback_url: 'callback_url',
|
|
21
|
+
dev_org_id: 'dev_org_id',
|
|
22
|
+
dev_user_id: 'dev_user_id',
|
|
23
|
+
external_system_id: 'external_system_id',
|
|
24
|
+
uuid: 'uuid',
|
|
25
|
+
sync_run_id: 'sync_run_id',
|
|
26
|
+
},
|
|
27
|
+
event_type,
|
|
28
|
+
}, input_data: {
|
|
29
|
+
global_values: {},
|
|
30
|
+
event_sources: {},
|
|
31
|
+
} }, overrides);
|
|
32
|
+
}
|
|
33
|
+
exports.createAirdropEvent = createAirdropEvent;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
describe('Airdrop event types', () => {
|
|
4
|
+
describe('ExternalSyncUnit', () => {
|
|
5
|
+
test('should have the required properties', () => {
|
|
6
|
+
const externalSyncUnit = {
|
|
7
|
+
id: '123',
|
|
8
|
+
name: 'test-unit-name',
|
|
9
|
+
description: 'test-unit-description',
|
|
10
|
+
item_count: 0,
|
|
11
|
+
};
|
|
12
|
+
expect(externalSyncUnit).toHaveProperty('id');
|
|
13
|
+
expect(externalSyncUnit).toHaveProperty('name');
|
|
14
|
+
expect(externalSyncUnit).toHaveProperty('description');
|
|
15
|
+
expect(externalSyncUnit).toHaveProperty('item_count');
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
describe('EventContextIn', () => {
|
|
19
|
+
test('should have the required properties', () => {
|
|
20
|
+
const eventContext = {
|
|
21
|
+
mode: 'INITIAL',
|
|
22
|
+
callback_url: 'https://test.com',
|
|
23
|
+
dev_org_id: 'DEV-123',
|
|
24
|
+
dev_user_id: 'DEVU-123',
|
|
25
|
+
external_system_id: '123',
|
|
26
|
+
sync_run_id: '123',
|
|
27
|
+
uuid: '123',
|
|
28
|
+
};
|
|
29
|
+
expect(eventContext).toHaveProperty('mode');
|
|
30
|
+
expect(eventContext).toHaveProperty('callback_url');
|
|
31
|
+
expect(eventContext).toHaveProperty('dev_org_id');
|
|
32
|
+
expect(eventContext).toHaveProperty('dev_user_id');
|
|
33
|
+
expect(eventContext).toHaveProperty('external_system_id');
|
|
34
|
+
expect(eventContext).toHaveProperty('uuid');
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
describe('ConnectionData', () => {
|
|
38
|
+
test('should have the required properties', () => {
|
|
39
|
+
const connectionData = {
|
|
40
|
+
org_id: '123',
|
|
41
|
+
org_name: 'test-org-name',
|
|
42
|
+
key: 'test-key',
|
|
43
|
+
key_type: 'test-key-type',
|
|
44
|
+
};
|
|
45
|
+
expect(connectionData).toHaveProperty('org_id');
|
|
46
|
+
expect(connectionData).toHaveProperty('org_name');
|
|
47
|
+
expect(connectionData).toHaveProperty('key');
|
|
48
|
+
expect(connectionData).toHaveProperty('key_type');
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
describe('ErrorRecord', () => {
|
|
52
|
+
test('should have the required properties', () => {
|
|
53
|
+
const errorRecord = {
|
|
54
|
+
message: 'test-message',
|
|
55
|
+
};
|
|
56
|
+
expect(errorRecord).toHaveProperty('message');
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
describe('Artifact', () => {
|
|
60
|
+
test('should have the required properties', () => {
|
|
61
|
+
const artifact = {
|
|
62
|
+
item_count: 0,
|
|
63
|
+
id: '123',
|
|
64
|
+
item_type: 'test-item-type',
|
|
65
|
+
};
|
|
66
|
+
expect(artifact).toHaveProperty('item_type');
|
|
67
|
+
expect(artifact).toHaveProperty('id');
|
|
68
|
+
expect(artifact).toHaveProperty('item_count');
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@devrev/ts-adaas",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Typescript library containing the ADaaS(AirDrop as a Service) control protocol.",
|
|
5
|
+
"type": "commonjs",
|
|
6
|
+
"main": "./dist/src/index.js",
|
|
7
|
+
"typings": "./dist/src/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsc",
|
|
10
|
+
"start": "ts-node src/index.ts",
|
|
11
|
+
"lint": "eslint .",
|
|
12
|
+
"lint:fix": "eslint . --fix",
|
|
13
|
+
"test": "jest --forceExit --coverage"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/devrev/adaas-sdk.git"
|
|
18
|
+
},
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"registry": "https://registry.npmjs.org"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [],
|
|
23
|
+
"author": "devrev",
|
|
24
|
+
"license": "ISC",
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/jest": "^29.5.12",
|
|
27
|
+
"@typescript-eslint/eslint-plugin": "^7.12.0",
|
|
28
|
+
"@typescript-eslint/parser": "^7.12.0",
|
|
29
|
+
"eslint": "^8.57.0",
|
|
30
|
+
"eslint-config-prettier": "^9.1.0",
|
|
31
|
+
"eslint-plugin-prettier": "^5.1.3",
|
|
32
|
+
"jest": "^29.7.0",
|
|
33
|
+
"ts-jest": "^29.1.2",
|
|
34
|
+
"typescript": "^5.3.3"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@devrev/typescript-sdk": "^1.1.27",
|
|
38
|
+
"axios": "^1.5.1",
|
|
39
|
+
"js-jsonl": "^1.1.1",
|
|
40
|
+
"ts-node": "^10.9.2"
|
|
41
|
+
},
|
|
42
|
+
"files": [
|
|
43
|
+
"dist"
|
|
44
|
+
]
|
|
45
|
+
}
|