@devrev/ts-adaas 0.0.1 → 0.0.3
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 +20 -4
- package/dist/src/adapter/index.d.ts +35 -30
- package/dist/src/adapter/index.js +93 -56
- package/dist/src/common/constants.d.ts +2 -0
- package/dist/src/common/constants.js +10 -0
- package/dist/src/{adapter → common}/helpers.d.ts +4 -1
- package/dist/src/{adapter → common}/helpers.js +16 -4
- package/dist/src/common/install-initial-domain-mapping.d.ts +3 -0
- package/dist/src/common/install-initial-domain-mapping.js +60 -0
- package/dist/src/demo-extractor/external_domain_metadata.json +38 -0
- package/dist/src/demo-extractor/index.d.ts +8 -1
- package/dist/src/demo-extractor/index.js +79 -73
- package/dist/src/http/client.d.ts +1 -1
- package/dist/src/http/client.js +2 -2
- package/dist/src/http/index.d.ts +0 -1
- package/dist/src/http/index.js +0 -1
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +2 -0
- package/dist/src/logging/index.d.ts +5 -18
- package/dist/src/logging/index.js +20 -41
- package/dist/src/state/index.d.ts +23 -0
- package/dist/src/state/index.js +111 -0
- package/dist/src/types/common.d.ts +4 -0
- package/dist/src/types/extraction.d.ts +17 -5
- package/dist/src/uploader/index.d.ts +4 -2
- package/dist/src/uploader/index.js +61 -4
- package/dist/tests/adapter.helpers.test.js +60 -0
- package/dist/tests/adapter.test.js +107 -57
- package/dist/tests/demo-extractor.test.js +45 -81
- package/dist/tests/state.test.js +101 -0
- package/dist/tests/uploader.test.js +29 -0
- package/package.json +1 -1
- package/dist/src/adapter/index.test.js +0 -105
- package/dist/src/demo-extractor/recipe.json +0 -37
- package/dist/tests/helpers.test.js +0 -38
- package/dist/tests/test-helpers.d.ts +0 -2
- package/dist/tests/test-helpers.js +0 -33
- package/dist/tests/types.test.js +0 -71
- /package/dist/{src/adapter/index.test.d.ts → tests/adapter.helpers.test.d.ts} +0 -0
- /package/dist/tests/{helpers.test.d.ts → state.test.d.ts} +0 -0
- /package/dist/tests/{types.test.d.ts → uploader.test.d.ts} +0 -0
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const types_1 = require("../types");
|
|
4
|
-
const index_1 = require("./index");
|
|
5
|
-
jest.useFakeTimers();
|
|
6
|
-
const defaultEvent = {
|
|
7
|
-
context: {
|
|
8
|
-
secrets: {
|
|
9
|
-
service_account_token: 'mockToken',
|
|
10
|
-
},
|
|
11
|
-
},
|
|
12
|
-
payload: {
|
|
13
|
-
connection_data: {
|
|
14
|
-
org_id: 'mockOrgId',
|
|
15
|
-
org_name: 'mockOrgName',
|
|
16
|
-
key: 'mockKey',
|
|
17
|
-
key_type: 'mockKeyType',
|
|
18
|
-
},
|
|
19
|
-
event_context: {
|
|
20
|
-
mode: 'INITIAL',
|
|
21
|
-
uuid: 'mockUuid',
|
|
22
|
-
callback_url: 'mockCallbackUrl',
|
|
23
|
-
dev_org_id: 'DEV-TESTORG',
|
|
24
|
-
dev_user_id: 'DEV-TESTUSER',
|
|
25
|
-
external_system_id: 'TESTSYSTEM',
|
|
26
|
-
sync_run_id: 'mockSyncRunId',
|
|
27
|
-
},
|
|
28
|
-
event_type: types_1.EventType.ExtractionExternalSyncUnitsStart,
|
|
29
|
-
},
|
|
30
|
-
execution_metadata: {
|
|
31
|
-
devrev_endpoint: 'http://api.dev.devrev-eng.ai',
|
|
32
|
-
},
|
|
33
|
-
input_data: {
|
|
34
|
-
global_values: {},
|
|
35
|
-
event_sources: {},
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
describe('Adapter', () => {
|
|
39
|
-
let adapter;
|
|
40
|
-
beforeEach(() => {
|
|
41
|
-
// Initialize the Adapter instance with mock data
|
|
42
|
-
adapter = new index_1.Adapter(defaultEvent);
|
|
43
|
-
});
|
|
44
|
-
afterEach(async () => {
|
|
45
|
-
// Clear all timers
|
|
46
|
-
jest.clearAllTimers();
|
|
47
|
-
// Clear all instances
|
|
48
|
-
jest.clearAllMocks();
|
|
49
|
-
});
|
|
50
|
-
it('should add artifact to the list of artifacts', async () => {
|
|
51
|
-
const artifact = {
|
|
52
|
-
id: 'mockId',
|
|
53
|
-
item_type: 'mockItemType',
|
|
54
|
-
item_count: 1,
|
|
55
|
-
// Mock artifact data
|
|
56
|
-
};
|
|
57
|
-
adapter.update({ artifact: artifact });
|
|
58
|
-
const artifacts = adapter.getArtifacts();
|
|
59
|
-
expect(artifacts).toContain(artifact);
|
|
60
|
-
// Run all timers
|
|
61
|
-
jest.runAllTimers();
|
|
62
|
-
});
|
|
63
|
-
it('should set extractor state if provided', async () => {
|
|
64
|
-
const state = {
|
|
65
|
-
testing: false,
|
|
66
|
-
};
|
|
67
|
-
adapter = new index_1.Adapter(Object.assign({}, defaultEvent), state);
|
|
68
|
-
expect(adapter['extractorState']).toEqual(state);
|
|
69
|
-
const newState = {
|
|
70
|
-
testing: true,
|
|
71
|
-
};
|
|
72
|
-
adapter.update({ extractor_state: newState });
|
|
73
|
-
expect(adapter['extractorState']).toEqual(newState);
|
|
74
|
-
// Run all timers
|
|
75
|
-
jest.runAllTimers();
|
|
76
|
-
});
|
|
77
|
-
it('update both an artifact and extractor state', async () => {
|
|
78
|
-
const artifact = {
|
|
79
|
-
id: 'mockId',
|
|
80
|
-
item_type: 'mockItemType',
|
|
81
|
-
item_count: 1,
|
|
82
|
-
};
|
|
83
|
-
const state = {
|
|
84
|
-
willUpdateToTrue: false,
|
|
85
|
-
willAdd4: 0,
|
|
86
|
-
};
|
|
87
|
-
adapter.update({ artifact: artifact, extractor_state: state });
|
|
88
|
-
const artifacts = adapter.getArtifacts();
|
|
89
|
-
expect(artifacts).toContain(artifact);
|
|
90
|
-
expect(adapter['extractorState']).toEqual(state);
|
|
91
|
-
const newState = {
|
|
92
|
-
willUpdateToTrue: true,
|
|
93
|
-
willAdd4: 4,
|
|
94
|
-
newField: 'newField',
|
|
95
|
-
};
|
|
96
|
-
const newArtifact = {
|
|
97
|
-
id: 'newMockId',
|
|
98
|
-
item_type: 'newMockItemType',
|
|
99
|
-
item_count: 2,
|
|
100
|
-
};
|
|
101
|
-
adapter.update({ artifact: newArtifact, extractor_state: newState });
|
|
102
|
-
// Run all timers
|
|
103
|
-
jest.runAllTimers();
|
|
104
|
-
});
|
|
105
|
-
});
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"initial_object_mappings": [
|
|
3
|
-
{
|
|
4
|
-
"external_type": "contacts",
|
|
5
|
-
"possible_targets": {
|
|
6
|
-
"rev_user": {}
|
|
7
|
-
},
|
|
8
|
-
"default_target": "rev_user",
|
|
9
|
-
"allow_item_type_decisions": true
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
"external_type": "users",
|
|
13
|
-
"possible_targets": {
|
|
14
|
-
"dev_user": {}
|
|
15
|
-
},
|
|
16
|
-
"default_target": "dev_user",
|
|
17
|
-
"allow_item_type_decisions": true
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
"external_type": "tickets",
|
|
21
|
-
"possible_targets": {
|
|
22
|
-
"work.ticket": {}
|
|
23
|
-
},
|
|
24
|
-
"default_target": "work.ticket",
|
|
25
|
-
"allow_item_type_decisions": true
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
"external_type": "conversations",
|
|
29
|
-
"possible_targets": {
|
|
30
|
-
"comment": {}
|
|
31
|
-
},
|
|
32
|
-
"default_target": "comment",
|
|
33
|
-
"allow_item_type_decisions": true
|
|
34
|
-
}
|
|
35
|
-
],
|
|
36
|
-
"external_system_short_name": "source-system"
|
|
37
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
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;
|
package/dist/tests/types.test.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
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
|
-
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|