@forge/teamwork-graph 2.0.0-next.7 → 2.1.0-next.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.
- package/README.md +289 -174
- package/out/__test__/entity-operations.test.js +468 -420
- package/out/__test__/error-handling.test.js +9 -9
- package/out/__test__/validators.test.js +43 -43
- package/out/graph.d.ts +5 -5
- package/out/graph.d.ts.map +1 -1
- package/out/graph.js +19 -19
- package/out/types/graph.d.ts +5 -5
- package/out/types/graph.d.ts.map +1 -1
- package/out/types/index.d.ts +2 -2
- package/out/types/index.d.ts.map +1 -1
- package/out/types/index.js +2 -2
- package/out/types/objects/branch.d.ts +14 -0
- package/out/types/objects/branch.d.ts.map +1 -0
- package/out/types/{entities → objects}/build.d.ts +3 -3
- package/out/types/objects/build.d.ts.map +1 -0
- package/out/types/{entities → objects}/calendar-event.d.ts +3 -3
- package/out/types/objects/calendar-event.d.ts.map +1 -0
- package/out/types/{entities → objects}/comment.d.ts +4 -4
- package/out/types/objects/comment.d.ts.map +1 -0
- package/out/types/{entities → objects}/commit.d.ts +3 -3
- package/out/types/objects/commit.d.ts.map +1 -0
- package/out/types/{common.d.ts → objects/common.d.ts} +7 -10
- package/out/types/objects/common.d.ts.map +1 -0
- package/out/types/{entities → objects}/conversation.d.ts +3 -3
- package/out/types/objects/conversation.d.ts.map +1 -0
- package/out/types/{entities → objects}/customer-org.d.ts +3 -3
- package/out/types/objects/customer-org.d.ts.map +1 -0
- package/out/types/{entities → objects}/deal.d.ts +3 -3
- package/out/types/objects/deal.d.ts.map +1 -0
- package/out/types/{entities → objects}/deployment.d.ts +3 -3
- package/out/types/objects/deployment.d.ts.map +1 -0
- package/out/types/{entities → objects}/design.d.ts +3 -3
- package/out/types/objects/design.d.ts.map +1 -0
- package/out/types/{entities → objects}/document.d.ts +3 -3
- package/out/types/objects/document.d.ts.map +1 -0
- package/out/types/objects/index.d.ts +26 -0
- package/out/types/objects/index.d.ts.map +1 -0
- package/out/types/{entities → objects}/message.d.ts +3 -3
- package/out/types/objects/message.d.ts.map +1 -0
- package/out/types/objects/organisation.d.ts +9 -0
- package/out/types/objects/organisation.d.ts.map +1 -0
- package/out/types/{entities → objects}/position.d.ts +3 -3
- package/out/types/objects/position.d.ts.map +1 -0
- package/out/types/{entities → objects}/project.d.ts +4 -4
- package/out/types/objects/project.d.ts.map +1 -0
- package/out/types/{entities → objects}/pull-request.d.ts +3 -3
- package/out/types/objects/pull-request.d.ts.map +1 -0
- package/out/types/{entities → objects}/remote-link.d.ts +3 -3
- package/out/types/objects/remote-link.d.ts.map +1 -0
- package/out/types/{entities → objects}/repository.d.ts +3 -3
- package/out/types/objects/repository.d.ts.map +1 -0
- package/out/types/{entities → objects}/software-service.d.ts +3 -3
- package/out/types/objects/software-service.d.ts.map +1 -0
- package/out/types/{entities → objects}/space.d.ts +3 -3
- package/out/types/objects/space.d.ts.map +1 -0
- package/out/types/{entities → objects}/video.d.ts +3 -3
- package/out/types/objects/video.d.ts.map +1 -0
- package/out/types/{entities → objects}/work-item.d.ts +3 -3
- package/out/types/objects/work-item.d.ts.map +1 -0
- package/out/types/{entities → objects}/worker.d.ts +3 -3
- package/out/types/objects/worker.d.ts.map +1 -0
- package/out/types/requests.d.ts +15 -15
- package/out/types/requests.d.ts.map +1 -1
- package/out/utils/validators.d.ts +6 -6
- package/out/utils/validators.d.ts.map +1 -1
- package/out/utils/validators.js +16 -16
- package/package.json +2 -2
- package/out/types/common.d.ts.map +0 -1
- package/out/types/entities/branch.d.ts +0 -14
- package/out/types/entities/branch.d.ts.map +0 -1
- package/out/types/entities/build.d.ts.map +0 -1
- package/out/types/entities/calendar-event.d.ts.map +0 -1
- package/out/types/entities/comment.d.ts.map +0 -1
- package/out/types/entities/commit.d.ts.map +0 -1
- package/out/types/entities/conversation.d.ts.map +0 -1
- package/out/types/entities/customer-org.d.ts.map +0 -1
- package/out/types/entities/deal.d.ts.map +0 -1
- package/out/types/entities/deployment.d.ts.map +0 -1
- package/out/types/entities/design.d.ts.map +0 -1
- package/out/types/entities/document.d.ts.map +0 -1
- package/out/types/entities/index.d.ts +0 -26
- package/out/types/entities/index.d.ts.map +0 -1
- package/out/types/entities/message.d.ts.map +0 -1
- package/out/types/entities/organisation.d.ts +0 -9
- package/out/types/entities/organisation.d.ts.map +0 -1
- package/out/types/entities/position.d.ts.map +0 -1
- package/out/types/entities/project.d.ts.map +0 -1
- package/out/types/entities/pull-request.d.ts.map +0 -1
- package/out/types/entities/remote-link.d.ts.map +0 -1
- package/out/types/entities/repository.d.ts.map +0 -1
- package/out/types/entities/software-service.d.ts.map +0 -1
- package/out/types/entities/space.d.ts.map +0 -1
- package/out/types/entities/video.d.ts.map +0 -1
- package/out/types/entities/work-item.d.ts.map +0 -1
- package/out/types/entities/worker.d.ts.map +0 -1
- /package/out/types/{entities → objects}/branch.js +0 -0
- /package/out/types/{entities → objects}/build.js +0 -0
- /package/out/types/{entities → objects}/calendar-event.js +0 -0
- /package/out/types/{entities → objects}/comment.js +0 -0
- /package/out/types/{entities → objects}/commit.js +0 -0
- /package/out/types/{common.js → objects/common.js} +0 -0
- /package/out/types/{entities → objects}/conversation.js +0 -0
- /package/out/types/{entities → objects}/customer-org.js +0 -0
- /package/out/types/{entities → objects}/deal.js +0 -0
- /package/out/types/{entities → objects}/deployment.js +0 -0
- /package/out/types/{entities → objects}/design.js +0 -0
- /package/out/types/{entities → objects}/document.js +0 -0
- /package/out/types/{entities → objects}/index.js +0 -0
- /package/out/types/{entities → objects}/message.js +0 -0
- /package/out/types/{entities → objects}/organisation.js +0 -0
- /package/out/types/{entities → objects}/position.js +0 -0
- /package/out/types/{entities → objects}/project.js +0 -0
- /package/out/types/{entities → objects}/pull-request.js +0 -0
- /package/out/types/{entities → objects}/remote-link.js +0 -0
- /package/out/types/{entities → objects}/repository.js +0 -0
- /package/out/types/{entities → objects}/software-service.js +0 -0
- /package/out/types/{entities → objects}/space.js +0 -0
- /package/out/types/{entities → objects}/video.js +0 -0
- /package/out/types/{entities → objects}/work-item.js +0 -0
- /package/out/types/{entities → objects}/worker.js +0 -0
|
@@ -4,7 +4,7 @@ const api_1 = require("@forge/api");
|
|
|
4
4
|
const graph_1 = require("../graph");
|
|
5
5
|
const validators_1 = require("../utils/validators");
|
|
6
6
|
jest.mock('@forge/api');
|
|
7
|
-
describe('TeamWorkGraphClient -
|
|
7
|
+
describe('TeamWorkGraphClient - setObjects', () => {
|
|
8
8
|
let graphClient;
|
|
9
9
|
let mockFetch;
|
|
10
10
|
beforeEach(() => {
|
|
@@ -13,13 +13,13 @@ describe('TeamWorkGraphClient - setEntities', () => {
|
|
|
13
13
|
api_1.__fetchProduct.mockReturnValue(mockFetch);
|
|
14
14
|
jest.clearAllMocks();
|
|
15
15
|
});
|
|
16
|
-
it('throws if
|
|
17
|
-
await expect(graphClient.
|
|
18
|
-
|
|
19
|
-
})).rejects.toThrow('
|
|
16
|
+
it('throws if objects array is empty', async () => {
|
|
17
|
+
await expect(graphClient.setObjects({
|
|
18
|
+
objects: []
|
|
19
|
+
})).rejects.toThrow('objects array cannot be empty');
|
|
20
20
|
});
|
|
21
|
-
it('throws if more than 100
|
|
22
|
-
const
|
|
21
|
+
it('throws if more than 100 objects', async () => {
|
|
22
|
+
const documentObject = {
|
|
23
23
|
schemaVersion: '1.0',
|
|
24
24
|
id: 'my-document',
|
|
25
25
|
updateSequenceNumber: 123,
|
|
@@ -27,17 +27,19 @@ describe('TeamWorkGraphClient - setEntities', () => {
|
|
|
27
27
|
url: 'https://document.com',
|
|
28
28
|
createdAt: '2024-04-16T09:01:32+00:00',
|
|
29
29
|
lastUpdatedAt: '2024-04-16T09:01:32+00:00',
|
|
30
|
-
permissions:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
30
|
+
permissions: [
|
|
31
|
+
{
|
|
32
|
+
accessControls: [
|
|
33
|
+
{
|
|
34
|
+
principals: [
|
|
35
|
+
{
|
|
36
|
+
type: 'EVERYONE'
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
],
|
|
41
43
|
'atlassian:document': {
|
|
42
44
|
type: {
|
|
43
45
|
category: 'document',
|
|
@@ -49,13 +51,13 @@ describe('TeamWorkGraphClient - setEntities', () => {
|
|
|
49
51
|
}
|
|
50
52
|
}
|
|
51
53
|
};
|
|
52
|
-
const
|
|
53
|
-
await expect(graphClient.
|
|
54
|
-
|
|
55
|
-
})).rejects.toThrow(`Bulk ingestion supports maximum ${validators_1.
|
|
54
|
+
const manyObjects = Array(validators_1.MAX_BULK_OBJECTS + 1).fill(documentObject);
|
|
55
|
+
await expect(graphClient.setObjects({
|
|
56
|
+
objects: manyObjects
|
|
57
|
+
})).rejects.toThrow(`Bulk ingestion supports maximum ${validators_1.MAX_BULK_OBJECTS} objects. Received ${validators_1.MAX_BULK_OBJECTS + 1}`);
|
|
56
58
|
});
|
|
57
59
|
it('posts to /api/v1/entities/bulk and returns response', async () => {
|
|
58
|
-
const
|
|
60
|
+
const documentObject = {
|
|
59
61
|
schemaVersion: '1.0',
|
|
60
62
|
id: 'my-document',
|
|
61
63
|
updateSequenceNumber: 123,
|
|
@@ -63,17 +65,19 @@ describe('TeamWorkGraphClient - setEntities', () => {
|
|
|
63
65
|
url: 'https://document.com',
|
|
64
66
|
createdAt: '2024-04-16T09:01:32+00:00',
|
|
65
67
|
lastUpdatedAt: '2024-04-16T09:01:32+00:00',
|
|
66
|
-
permissions:
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
68
|
+
permissions: [
|
|
69
|
+
{
|
|
70
|
+
accessControls: [
|
|
71
|
+
{
|
|
72
|
+
principals: [
|
|
73
|
+
{
|
|
74
|
+
type: 'EVERYONE'
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
],
|
|
77
81
|
'atlassian:document': {
|
|
78
82
|
type: {
|
|
79
83
|
category: 'document',
|
|
@@ -85,18 +89,18 @@ describe('TeamWorkGraphClient - setEntities', () => {
|
|
|
85
89
|
}
|
|
86
90
|
}
|
|
87
91
|
};
|
|
88
|
-
const req = {
|
|
89
|
-
const expected = { success: true, results: [{
|
|
92
|
+
const req = { objects: [documentObject] };
|
|
93
|
+
const expected = { success: true, results: [{ objectId: 'my-document', success: true }] };
|
|
90
94
|
mockFetch.mockResolvedValueOnce({
|
|
91
95
|
ok: true,
|
|
92
96
|
json: () => Promise.resolve(expected)
|
|
93
97
|
});
|
|
94
|
-
const result = await graphClient.
|
|
98
|
+
const result = await graphClient.setObjects(req);
|
|
95
99
|
expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
|
|
96
100
|
expect(result).toEqual(expected);
|
|
97
101
|
});
|
|
98
102
|
it('posts message entities to /api/v1/entities/bulk and returns response', async () => {
|
|
99
|
-
const
|
|
103
|
+
const messageObject = {
|
|
100
104
|
schemaVersion: '2.0',
|
|
101
105
|
id: 'message-1',
|
|
102
106
|
updateSequenceNumber: 1,
|
|
@@ -104,21 +108,23 @@ describe('TeamWorkGraphClient - setEntities', () => {
|
|
|
104
108
|
url: 'https://atlassian.slack.com/archives/C03DZ3WCN94/p1722400000000000',
|
|
105
109
|
createdAt: '2024-07-09T14:27:37.000Z',
|
|
106
110
|
lastUpdatedAt: '2024-07-09T14:27:37.000Z',
|
|
107
|
-
permissions:
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
111
|
+
permissions: [
|
|
112
|
+
{
|
|
113
|
+
accessControls: [
|
|
114
|
+
{
|
|
115
|
+
principals: [
|
|
116
|
+
{
|
|
117
|
+
type: 'EVERYONE'
|
|
118
|
+
}
|
|
119
|
+
]
|
|
120
|
+
}
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
],
|
|
118
124
|
containerKey: {
|
|
119
125
|
type: 'atlassian:conversation',
|
|
120
126
|
value: {
|
|
121
|
-
|
|
127
|
+
objectId: 'CFG3W7TKJ'
|
|
122
128
|
}
|
|
123
129
|
},
|
|
124
130
|
'atlassian:message': {
|
|
@@ -134,18 +140,18 @@ describe('TeamWorkGraphClient - setEntities', () => {
|
|
|
134
140
|
lastActive: '2024-07-09T15:27:37.000Z'
|
|
135
141
|
}
|
|
136
142
|
};
|
|
137
|
-
const req = {
|
|
138
|
-
const expected = { success: true, results: [{
|
|
143
|
+
const req = { objects: [messageObject] };
|
|
144
|
+
const expected = { success: true, results: [{ objectId: 'message-1', success: true }] };
|
|
139
145
|
mockFetch.mockResolvedValueOnce({
|
|
140
146
|
ok: true,
|
|
141
147
|
json: () => Promise.resolve(expected)
|
|
142
148
|
});
|
|
143
|
-
const result = await graphClient.
|
|
149
|
+
const result = await graphClient.setObjects(req);
|
|
144
150
|
expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
|
|
145
151
|
expect(result).toEqual(expected);
|
|
146
152
|
});
|
|
147
153
|
it('posts organisation entities to /api/v1/entities/bulk and returns response', async () => {
|
|
148
|
-
const
|
|
154
|
+
const organisationObject = {
|
|
149
155
|
schemaVersion: '2.0',
|
|
150
156
|
id: 'org-1',
|
|
151
157
|
updateSequenceNumber: 2,
|
|
@@ -153,41 +159,43 @@ describe('TeamWorkGraphClient - setEntities', () => {
|
|
|
153
159
|
url: 'https://workday.atlassian.com/path-to-org',
|
|
154
160
|
createdAt: '2024-07-09T14:27:37.000Z',
|
|
155
161
|
lastUpdatedAt: '2024-07-09T14:27:37.000Z',
|
|
156
|
-
permissions:
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
162
|
+
permissions: [
|
|
163
|
+
{
|
|
164
|
+
accessControls: [
|
|
165
|
+
{
|
|
166
|
+
principals: [
|
|
167
|
+
{
|
|
168
|
+
type: 'EVERYONE'
|
|
169
|
+
}
|
|
170
|
+
]
|
|
171
|
+
}
|
|
172
|
+
]
|
|
173
|
+
}
|
|
174
|
+
],
|
|
167
175
|
parentKey: {
|
|
168
176
|
type: 'atlassian:organisation',
|
|
169
177
|
value: {
|
|
170
|
-
|
|
178
|
+
objectId: 'id of the parent org of this org'
|
|
171
179
|
}
|
|
172
180
|
},
|
|
173
181
|
'atlassian:organisation': {}
|
|
174
182
|
};
|
|
175
|
-
const req = {
|
|
176
|
-
const expected = { success: false, results: [{
|
|
183
|
+
const req = { objects: [organisationObject] };
|
|
184
|
+
const expected = { success: false, results: [{ objectId: 'org-1', success: true }] };
|
|
177
185
|
mockFetch.mockResolvedValueOnce({
|
|
178
186
|
ok: true,
|
|
179
187
|
json: () => Promise.resolve(expected)
|
|
180
188
|
});
|
|
181
|
-
const result = await graphClient.
|
|
189
|
+
const result = await graphClient.setObjects(req);
|
|
182
190
|
expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
|
|
183
191
|
expect(result).toEqual(expected);
|
|
184
192
|
});
|
|
185
|
-
it('throws if
|
|
186
|
-
const req = {
|
|
187
|
-
await expect(graphClient.
|
|
193
|
+
it('throws if objects is not an array', async () => {
|
|
194
|
+
const req = { objects: null };
|
|
195
|
+
await expect(graphClient.setObjects(req)).rejects.toThrow('objects must be an array');
|
|
188
196
|
});
|
|
189
197
|
});
|
|
190
|
-
describe('TeamWorkGraphClient -
|
|
198
|
+
describe('TeamWorkGraphClient - getObjectByExternalId', () => {
|
|
191
199
|
let graphClient;
|
|
192
200
|
let mockFetch;
|
|
193
201
|
beforeEach(() => {
|
|
@@ -196,11 +204,11 @@ describe('TeamWorkGraphClient - getEntityByExternalId', () => {
|
|
|
196
204
|
api_1.__fetchProduct.mockReturnValue(mockFetch);
|
|
197
205
|
jest.clearAllMocks();
|
|
198
206
|
});
|
|
199
|
-
it('should successfully get
|
|
200
|
-
const
|
|
201
|
-
id: 'ari:cloud:teamwork-graph:
|
|
207
|
+
it('should successfully get object by external ID and object type', async () => {
|
|
208
|
+
const expectedObject = {
|
|
209
|
+
id: 'ari:cloud:teamwork-graph:object/123',
|
|
202
210
|
externalId: 'pipelines/123/builds/456',
|
|
203
|
-
|
|
211
|
+
objectType: 'atlassian:document',
|
|
204
212
|
displayName: 'Build Documentation',
|
|
205
213
|
description: 'Documentation for build process',
|
|
206
214
|
url: 'https://example.com/builds/456',
|
|
@@ -215,10 +223,10 @@ describe('TeamWorkGraphClient - getEntityByExternalId', () => {
|
|
|
215
223
|
};
|
|
216
224
|
mockFetch.mockResolvedValueOnce({
|
|
217
225
|
ok: true,
|
|
218
|
-
json: () => Promise.resolve(
|
|
226
|
+
json: () => Promise.resolve(expectedObject)
|
|
219
227
|
});
|
|
220
|
-
const result = await graphClient.
|
|
221
|
-
|
|
228
|
+
const result = await graphClient.getObjectByExternalId({
|
|
229
|
+
objectType: 'atlassian:document',
|
|
222
230
|
externalId: 'pipelines/123/builds/456'
|
|
223
231
|
});
|
|
224
232
|
expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities?entityType=atlassian%3Adocument&externalId=pipelines%2F123%2Fbuilds%2F456', {
|
|
@@ -228,10 +236,10 @@ describe('TeamWorkGraphClient - getEntityByExternalId', () => {
|
|
|
228
236
|
});
|
|
229
237
|
expect(result).toEqual({
|
|
230
238
|
success: true,
|
|
231
|
-
|
|
239
|
+
object: expectedObject
|
|
232
240
|
});
|
|
233
241
|
});
|
|
234
|
-
it('should handle
|
|
242
|
+
it('should handle object not found', async () => {
|
|
235
243
|
const errorResponse = {
|
|
236
244
|
ok: false,
|
|
237
245
|
status: 404,
|
|
@@ -245,30 +253,30 @@ describe('TeamWorkGraphClient - getEntityByExternalId', () => {
|
|
|
245
253
|
})
|
|
246
254
|
};
|
|
247
255
|
mockFetch.mockResolvedValueOnce(errorResponse);
|
|
248
|
-
const result = await graphClient.
|
|
249
|
-
|
|
256
|
+
const result = await graphClient.getObjectByExternalId({
|
|
257
|
+
objectType: 'atlassian:document',
|
|
250
258
|
externalId: 'nonexistent-entity'
|
|
251
259
|
});
|
|
252
260
|
expect(result).toEqual({
|
|
253
261
|
success: false,
|
|
254
|
-
error: 'Failed to get
|
|
262
|
+
error: 'Failed to get object by external ID: Not Found - Entity not found',
|
|
255
263
|
originalError: expect.any(Error)
|
|
256
264
|
});
|
|
257
265
|
});
|
|
258
|
-
it('should throw error when
|
|
259
|
-
await expect(graphClient.
|
|
260
|
-
|
|
266
|
+
it('should throw error when objectType is missing', async () => {
|
|
267
|
+
await expect(graphClient.getObjectByExternalId({
|
|
268
|
+
objectType: '',
|
|
261
269
|
externalId: 'pipelines/123/builds/456'
|
|
262
|
-
})).rejects.toThrow('
|
|
270
|
+
})).rejects.toThrow('objectType is required');
|
|
263
271
|
});
|
|
264
272
|
it('should throw error when externalId is missing', async () => {
|
|
265
|
-
await expect(graphClient.
|
|
266
|
-
|
|
273
|
+
await expect(graphClient.getObjectByExternalId({
|
|
274
|
+
objectType: 'atlassian:document',
|
|
267
275
|
externalId: ''
|
|
268
276
|
})).rejects.toThrow('externalId is required');
|
|
269
277
|
});
|
|
270
278
|
});
|
|
271
|
-
describe('TeamWorkGraphClient -
|
|
279
|
+
describe('TeamWorkGraphClient - deleteObjectsByExternalId', () => {
|
|
272
280
|
let graphClient;
|
|
273
281
|
let mockFetch;
|
|
274
282
|
beforeEach(() => {
|
|
@@ -277,7 +285,7 @@ describe('TeamWorkGraphClient - deleteEntitiesByExternalId', () => {
|
|
|
277
285
|
api_1.__fetchProduct.mockReturnValue(mockFetch);
|
|
278
286
|
jest.clearAllMocks();
|
|
279
287
|
});
|
|
280
|
-
it('should successfully delete
|
|
288
|
+
it('should successfully delete objects in bulk', async () => {
|
|
281
289
|
const expectedResponse = {
|
|
282
290
|
success: true,
|
|
283
291
|
results: [
|
|
@@ -289,8 +297,8 @@ describe('TeamWorkGraphClient - deleteEntitiesByExternalId', () => {
|
|
|
289
297
|
ok: true,
|
|
290
298
|
json: () => Promise.resolve(expectedResponse)
|
|
291
299
|
});
|
|
292
|
-
const result = await graphClient.
|
|
293
|
-
|
|
300
|
+
const result = await graphClient.deleteObjectsByExternalId({
|
|
301
|
+
objectType: 'atlassian:document',
|
|
294
302
|
externalIds: ['pipelines/123/builds/456', 'pipelines/123/builds/789']
|
|
295
303
|
});
|
|
296
304
|
expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk/delete', {
|
|
@@ -304,33 +312,33 @@ describe('TeamWorkGraphClient - deleteEntitiesByExternalId', () => {
|
|
|
304
312
|
});
|
|
305
313
|
expect(result).toEqual(expectedResponse);
|
|
306
314
|
});
|
|
307
|
-
it('should throw error when
|
|
308
|
-
await expect(graphClient.
|
|
309
|
-
|
|
315
|
+
it('should throw error when objectType is missing', async () => {
|
|
316
|
+
await expect(graphClient.deleteObjectsByExternalId({
|
|
317
|
+
objectType: '',
|
|
310
318
|
externalIds: ['pipelines/123/builds/456']
|
|
311
|
-
})).rejects.toThrow('
|
|
319
|
+
})).rejects.toThrow('objectType is required');
|
|
312
320
|
});
|
|
313
321
|
it('should throw error when externalIds array is empty', async () => {
|
|
314
|
-
await expect(graphClient.
|
|
315
|
-
|
|
322
|
+
await expect(graphClient.deleteObjectsByExternalId({
|
|
323
|
+
objectType: 'atlassian:document',
|
|
316
324
|
externalIds: []
|
|
317
325
|
})).rejects.toThrow('externalIds array cannot be empty');
|
|
318
326
|
});
|
|
319
327
|
it('should throw error when externalIds array exceeds limit', async () => {
|
|
320
|
-
const manyExternalIds = Array(validators_1.
|
|
321
|
-
await expect(graphClient.
|
|
322
|
-
|
|
328
|
+
const manyExternalIds = Array(validators_1.MAX_BULK_OBJECTS_DELETE + 1).fill('pipelines/123/builds/456');
|
|
329
|
+
await expect(graphClient.deleteObjectsByExternalId({
|
|
330
|
+
objectType: 'atlassian:document',
|
|
323
331
|
externalIds: manyExternalIds
|
|
324
|
-
})).rejects.toThrow(`Bulk
|
|
332
|
+
})).rejects.toThrow(`Bulk object deletion supports maximum ${validators_1.MAX_BULK_OBJECTS_DELETE} objects`);
|
|
325
333
|
});
|
|
326
334
|
it('should throw error when externalIds is not an array', async () => {
|
|
327
|
-
await expect(graphClient.
|
|
328
|
-
|
|
335
|
+
await expect(graphClient.deleteObjectsByExternalId({
|
|
336
|
+
objectType: 'atlassian:document',
|
|
329
337
|
externalIds: null
|
|
330
338
|
})).rejects.toThrow('externalIds must be an array');
|
|
331
339
|
});
|
|
332
340
|
});
|
|
333
|
-
describe('TeamWorkGraphClient -
|
|
341
|
+
describe('TeamWorkGraphClient - deleteObjectsByProperties', () => {
|
|
334
342
|
let graphClient;
|
|
335
343
|
let mockFetch;
|
|
336
344
|
beforeEach(() => {
|
|
@@ -339,19 +347,19 @@ describe('TeamWorkGraphClient - deleteEntitiesByProperties', () => {
|
|
|
339
347
|
api_1.__fetchProduct.mockReturnValue(mockFetch);
|
|
340
348
|
jest.clearAllMocks();
|
|
341
349
|
});
|
|
342
|
-
it('should successfully delete
|
|
350
|
+
it('should successfully delete objects by properties', async () => {
|
|
343
351
|
const expectedResponse = {
|
|
344
352
|
success: true,
|
|
345
353
|
results: [
|
|
346
|
-
{
|
|
347
|
-
{
|
|
354
|
+
{ objectId: 'entity-123', success: true },
|
|
355
|
+
{ objectId: 'entity-456', success: true }
|
|
348
356
|
]
|
|
349
357
|
};
|
|
350
358
|
mockFetch.mockResolvedValueOnce({
|
|
351
359
|
ok: true,
|
|
352
360
|
json: () => Promise.resolve(expectedResponse)
|
|
353
361
|
});
|
|
354
|
-
const result = await graphClient.
|
|
362
|
+
const result = await graphClient.deleteObjectsByProperties({
|
|
355
363
|
environment: 'staging',
|
|
356
364
|
status: 'failed'
|
|
357
365
|
});
|
|
@@ -369,13 +377,13 @@ describe('TeamWorkGraphClient - deleteEntitiesByProperties', () => {
|
|
|
369
377
|
it('should handle complex properties object', async () => {
|
|
370
378
|
const expectedResponse = {
|
|
371
379
|
success: true,
|
|
372
|
-
results: [{
|
|
380
|
+
results: [{ objectId: 'entity-789', success: true }]
|
|
373
381
|
};
|
|
374
382
|
mockFetch.mockResolvedValueOnce({
|
|
375
383
|
ok: true,
|
|
376
384
|
json: () => Promise.resolve(expectedResponse)
|
|
377
385
|
});
|
|
378
|
-
const result = await graphClient.
|
|
386
|
+
const result = await graphClient.deleteObjectsByProperties({
|
|
379
387
|
environment: 'production',
|
|
380
388
|
status: 'completed',
|
|
381
389
|
priority: 'high',
|
|
@@ -397,16 +405,16 @@ describe('TeamWorkGraphClient - deleteEntitiesByProperties', () => {
|
|
|
397
405
|
expect(result).toEqual(expectedResponse);
|
|
398
406
|
});
|
|
399
407
|
it('should throw error when properties is missing', async () => {
|
|
400
|
-
await expect(graphClient.
|
|
408
|
+
await expect(graphClient.deleteObjectsByProperties(null)).rejects.toThrow('properties must be an object');
|
|
401
409
|
});
|
|
402
410
|
it('should throw error when properties is not an object', async () => {
|
|
403
|
-
await expect(graphClient.
|
|
411
|
+
await expect(graphClient.deleteObjectsByProperties('not-an-object')).rejects.toThrow('properties must be an object');
|
|
404
412
|
});
|
|
405
413
|
it('should throw error when properties object is empty', async () => {
|
|
406
|
-
await expect(graphClient.
|
|
414
|
+
await expect(graphClient.deleteObjectsByProperties({})).rejects.toThrow('properties object cannot be empty');
|
|
407
415
|
});
|
|
408
416
|
it('posts branch entities to /api/v1/entities/bulk and returns response', async () => {
|
|
409
|
-
const
|
|
417
|
+
const branchObject = {
|
|
410
418
|
schemaVersion: '2.0',
|
|
411
419
|
id: 'branch-1',
|
|
412
420
|
updateSequenceNumber: 1,
|
|
@@ -414,31 +422,33 @@ describe('TeamWorkGraphClient - deleteEntitiesByProperties', () => {
|
|
|
414
422
|
url: 'https://github.com/org/repo/tree/feature-branch',
|
|
415
423
|
createdAt: '2024-07-09T14:27:37.000Z',
|
|
416
424
|
lastUpdatedAt: '2024-07-09T14:27:37.000Z',
|
|
417
|
-
permissions:
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
425
|
+
permissions: [
|
|
426
|
+
{
|
|
427
|
+
accessControls: [
|
|
428
|
+
{
|
|
429
|
+
principals: [
|
|
430
|
+
{
|
|
431
|
+
type: 'EVERYONE'
|
|
432
|
+
}
|
|
433
|
+
]
|
|
434
|
+
}
|
|
435
|
+
]
|
|
436
|
+
}
|
|
437
|
+
],
|
|
428
438
|
'atlassian:branch': {}
|
|
429
439
|
};
|
|
430
|
-
const req = {
|
|
431
|
-
const expected = { success: true, results: [{
|
|
440
|
+
const req = { objects: [branchObject] };
|
|
441
|
+
const expected = { success: true, results: [{ objectId: 'branch-1', success: true }] };
|
|
432
442
|
mockFetch.mockResolvedValueOnce({
|
|
433
443
|
ok: true,
|
|
434
444
|
json: () => Promise.resolve(expected)
|
|
435
445
|
});
|
|
436
|
-
const result = await graphClient.
|
|
446
|
+
const result = await graphClient.setObjects(req);
|
|
437
447
|
expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
|
|
438
448
|
expect(result).toEqual(expected);
|
|
439
449
|
});
|
|
440
450
|
it('posts commit entities to /api/v1/entities/bulk and returns response', async () => {
|
|
441
|
-
const
|
|
451
|
+
const commitObject = {
|
|
442
452
|
schemaVersion: '2.0',
|
|
443
453
|
id: 'commit-1',
|
|
444
454
|
updateSequenceNumber: 1,
|
|
@@ -446,17 +456,19 @@ describe('TeamWorkGraphClient - deleteEntitiesByProperties', () => {
|
|
|
446
456
|
url: 'https://github.com/org/repo/commit/abc123',
|
|
447
457
|
createdAt: '2024-07-09T14:27:37.000Z',
|
|
448
458
|
lastUpdatedAt: '2024-07-09T14:27:37.000Z',
|
|
449
|
-
permissions:
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
459
|
+
permissions: [
|
|
460
|
+
{
|
|
461
|
+
accessControls: [
|
|
462
|
+
{
|
|
463
|
+
principals: [
|
|
464
|
+
{
|
|
465
|
+
type: 'EVERYONE'
|
|
466
|
+
}
|
|
467
|
+
]
|
|
468
|
+
}
|
|
469
|
+
]
|
|
470
|
+
}
|
|
471
|
+
],
|
|
460
472
|
'atlassian:commit': {
|
|
461
473
|
flags: ['flag1', 'flag2'],
|
|
462
474
|
fileCount: 10,
|
|
@@ -471,18 +483,18 @@ describe('TeamWorkGraphClient - deleteEntitiesByProperties', () => {
|
|
|
471
483
|
]
|
|
472
484
|
}
|
|
473
485
|
};
|
|
474
|
-
const req = {
|
|
475
|
-
const expected = { success: true, results: [{
|
|
486
|
+
const req = { objects: [commitObject] };
|
|
487
|
+
const expected = { success: true, results: [{ objectId: 'commit-1', success: true }] };
|
|
476
488
|
mockFetch.mockResolvedValueOnce({
|
|
477
489
|
ok: true,
|
|
478
490
|
json: () => Promise.resolve(expected)
|
|
479
491
|
});
|
|
480
|
-
const result = await graphClient.
|
|
492
|
+
const result = await graphClient.setObjects(req);
|
|
481
493
|
expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
|
|
482
494
|
expect(result).toEqual(expected);
|
|
483
495
|
});
|
|
484
496
|
it('posts build entities to /api/v1/entities/bulk and returns response', async () => {
|
|
485
|
-
const
|
|
497
|
+
const buildObject = {
|
|
486
498
|
schemaVersion: '2.0',
|
|
487
499
|
id: 'build-1',
|
|
488
500
|
updateSequenceNumber: 1,
|
|
@@ -490,17 +502,19 @@ describe('TeamWorkGraphClient - deleteEntitiesByProperties', () => {
|
|
|
490
502
|
url: 'https://ci.example.com/builds/42',
|
|
491
503
|
createdAt: '2024-07-09T14:27:37.000Z',
|
|
492
504
|
lastUpdatedAt: '2024-07-09T14:27:37.000Z',
|
|
493
|
-
permissions:
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
505
|
+
permissions: [
|
|
506
|
+
{
|
|
507
|
+
accessControls: [
|
|
508
|
+
{
|
|
509
|
+
principals: [
|
|
510
|
+
{
|
|
511
|
+
type: 'EVERYONE'
|
|
512
|
+
}
|
|
513
|
+
]
|
|
514
|
+
}
|
|
515
|
+
]
|
|
516
|
+
}
|
|
517
|
+
],
|
|
504
518
|
'atlassian:build': {
|
|
505
519
|
pipelineId: 'pipeline-123',
|
|
506
520
|
buildNumber: 42,
|
|
@@ -527,18 +541,18 @@ describe('TeamWorkGraphClient - deleteEntitiesByProperties', () => {
|
|
|
527
541
|
]
|
|
528
542
|
}
|
|
529
543
|
};
|
|
530
|
-
const req = {
|
|
531
|
-
const expected = { success: true, results: [{
|
|
544
|
+
const req = { objects: [buildObject] };
|
|
545
|
+
const expected = { success: true, results: [{ objectId: 'build-1', success: true }] };
|
|
532
546
|
mockFetch.mockResolvedValueOnce({
|
|
533
547
|
ok: true,
|
|
534
548
|
json: () => Promise.resolve(expected)
|
|
535
549
|
});
|
|
536
|
-
const result = await graphClient.
|
|
550
|
+
const result = await graphClient.setObjects(req);
|
|
537
551
|
expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
|
|
538
552
|
expect(result).toEqual(expected);
|
|
539
553
|
});
|
|
540
554
|
it('posts calendar event entities to /api/v1/entities/bulk and returns response', async () => {
|
|
541
|
-
const
|
|
555
|
+
const calendarEventObject = {
|
|
542
556
|
schemaVersion: '2.0',
|
|
543
557
|
id: 'calendar-event-1',
|
|
544
558
|
updateSequenceNumber: 1,
|
|
@@ -548,17 +562,19 @@ describe('TeamWorkGraphClient - deleteEntitiesByProperties', () => {
|
|
|
548
562
|
createdAt: '2024-07-09T14:27:37.000Z',
|
|
549
563
|
createdBy: {},
|
|
550
564
|
lastUpdatedAt: '2024-07-09T14:27:37.000Z',
|
|
551
|
-
permissions:
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
565
|
+
permissions: [
|
|
566
|
+
{
|
|
567
|
+
accessControls: [
|
|
568
|
+
{
|
|
569
|
+
principals: [
|
|
570
|
+
{
|
|
571
|
+
type: 'EVERYONE'
|
|
572
|
+
}
|
|
573
|
+
]
|
|
574
|
+
}
|
|
575
|
+
]
|
|
576
|
+
}
|
|
577
|
+
],
|
|
562
578
|
'atlassian:calendar-event': {
|
|
563
579
|
eventStartTime: '2024-07-10T09:00:00.000Z',
|
|
564
580
|
eventEndTime: '2024-07-10T10:00:00.000Z',
|
|
@@ -598,18 +614,18 @@ describe('TeamWorkGraphClient - deleteEntitiesByProperties', () => {
|
|
|
598
614
|
]
|
|
599
615
|
}
|
|
600
616
|
};
|
|
601
|
-
const req = {
|
|
602
|
-
const expected = { success: true, results: [{
|
|
617
|
+
const req = { objects: [calendarEventObject] };
|
|
618
|
+
const expected = { success: true, results: [{ objectId: 'calendar-event-1', success: true }] };
|
|
603
619
|
mockFetch.mockResolvedValueOnce({
|
|
604
620
|
ok: true,
|
|
605
621
|
json: () => Promise.resolve(expected)
|
|
606
622
|
});
|
|
607
|
-
const result = await graphClient.
|
|
623
|
+
const result = await graphClient.setObjects(req);
|
|
608
624
|
expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
|
|
609
625
|
expect(result).toEqual(expected);
|
|
610
626
|
});
|
|
611
627
|
it('posts comment entities to /api/v1/entities/bulk and returns response', async () => {
|
|
612
|
-
const
|
|
628
|
+
const commentObject = {
|
|
613
629
|
schemaVersion: '2.0',
|
|
614
630
|
id: 'comment-1',
|
|
615
631
|
updateSequenceNumber: 1,
|
|
@@ -622,17 +638,19 @@ describe('TeamWorkGraphClient - deleteEntitiesByProperties', () => {
|
|
|
622
638
|
displayName: 'Jane Developer'
|
|
623
639
|
},
|
|
624
640
|
lastUpdatedAt: '2024-07-09T14:27:37.000Z',
|
|
625
|
-
permissions:
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
641
|
+
permissions: [
|
|
642
|
+
{
|
|
643
|
+
accessControls: [
|
|
644
|
+
{
|
|
645
|
+
principals: [
|
|
646
|
+
{
|
|
647
|
+
type: 'EVERYONE'
|
|
648
|
+
}
|
|
649
|
+
]
|
|
650
|
+
}
|
|
651
|
+
]
|
|
652
|
+
}
|
|
653
|
+
],
|
|
636
654
|
'atlassian:comment': {
|
|
637
655
|
text: 'This is a really well-implemented feature. The code is clean and the tests are comprehensive. Thanks for the hard work!',
|
|
638
656
|
reactionsV2: [
|
|
@@ -643,18 +661,18 @@ describe('TeamWorkGraphClient - deleteEntitiesByProperties', () => {
|
|
|
643
661
|
]
|
|
644
662
|
}
|
|
645
663
|
};
|
|
646
|
-
const req = {
|
|
647
|
-
const expected = { success: true, results: [{
|
|
664
|
+
const req = { objects: [commentObject] };
|
|
665
|
+
const expected = { success: true, results: [{ objectId: 'comment-1', success: true }] };
|
|
648
666
|
mockFetch.mockResolvedValueOnce({
|
|
649
667
|
ok: true,
|
|
650
668
|
json: () => Promise.resolve(expected)
|
|
651
669
|
});
|
|
652
|
-
const result = await graphClient.
|
|
670
|
+
const result = await graphClient.setObjects(req);
|
|
653
671
|
expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
|
|
654
672
|
expect(result).toEqual(expected);
|
|
655
673
|
});
|
|
656
674
|
it('posts conversation entities to /api/v1/entities/bulk and returns response', async () => {
|
|
657
|
-
const
|
|
675
|
+
const conversationObject = {
|
|
658
676
|
schemaVersion: '2.0',
|
|
659
677
|
id: 'conversation-1',
|
|
660
678
|
updateSequenceNumber: 1,
|
|
@@ -663,17 +681,19 @@ describe('TeamWorkGraphClient - deleteEntitiesByProperties', () => {
|
|
|
663
681
|
url: 'https://slack.com/channels/dev-team',
|
|
664
682
|
createdAt: '2024-07-09T14:27:37.000Z',
|
|
665
683
|
lastUpdatedAt: '2024-07-09T14:27:37.000Z',
|
|
666
|
-
permissions:
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
684
|
+
permissions: [
|
|
685
|
+
{
|
|
686
|
+
accessControls: [
|
|
687
|
+
{
|
|
688
|
+
principals: [
|
|
689
|
+
{
|
|
690
|
+
type: 'EVERYONE'
|
|
691
|
+
}
|
|
692
|
+
]
|
|
693
|
+
}
|
|
694
|
+
]
|
|
695
|
+
}
|
|
696
|
+
],
|
|
677
697
|
'atlassian:conversation': {
|
|
678
698
|
type: 'channel',
|
|
679
699
|
membershipType: 'public',
|
|
@@ -707,18 +727,18 @@ describe('TeamWorkGraphClient - deleteEntitiesByProperties', () => {
|
|
|
707
727
|
memberCount: 3
|
|
708
728
|
}
|
|
709
729
|
};
|
|
710
|
-
const req = {
|
|
711
|
-
const expected = { success: true, results: [{
|
|
730
|
+
const req = { objects: [conversationObject] };
|
|
731
|
+
const expected = { success: true, results: [{ objectId: 'conversation-1', success: true }] };
|
|
712
732
|
mockFetch.mockResolvedValueOnce({
|
|
713
733
|
ok: true,
|
|
714
734
|
json: () => Promise.resolve(expected)
|
|
715
735
|
});
|
|
716
|
-
const result = await graphClient.
|
|
736
|
+
const result = await graphClient.setObjects(req);
|
|
717
737
|
expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
|
|
718
738
|
expect(result).toEqual(expected);
|
|
719
739
|
});
|
|
720
740
|
it('posts customer org entities to /api/v1/entities/bulk and returns response', async () => {
|
|
721
|
-
const
|
|
741
|
+
const customerOrgObject = {
|
|
722
742
|
schemaVersion: '2.0',
|
|
723
743
|
id: 'customer-org-1',
|
|
724
744
|
updateSequenceNumber: 1,
|
|
@@ -727,17 +747,19 @@ describe('TeamWorkGraphClient - deleteEntitiesByProperties', () => {
|
|
|
727
747
|
url: 'https://crm.example.com/customers/acme-corp',
|
|
728
748
|
createdAt: '2024-07-09T14:27:37.000Z',
|
|
729
749
|
lastUpdatedAt: '2024-07-09T14:27:37.000Z',
|
|
730
|
-
permissions:
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
750
|
+
permissions: [
|
|
751
|
+
{
|
|
752
|
+
accessControls: [
|
|
753
|
+
{
|
|
754
|
+
principals: [
|
|
755
|
+
{
|
|
756
|
+
type: 'EVERYONE'
|
|
757
|
+
}
|
|
758
|
+
]
|
|
759
|
+
}
|
|
760
|
+
]
|
|
761
|
+
}
|
|
762
|
+
],
|
|
741
763
|
'atlassian:customer-org': {
|
|
742
764
|
contacts: [
|
|
743
765
|
{
|
|
@@ -780,18 +802,18 @@ describe('TeamWorkGraphClient - deleteEntitiesByProperties', () => {
|
|
|
780
802
|
accountType: 'Enterprise'
|
|
781
803
|
}
|
|
782
804
|
};
|
|
783
|
-
const req = {
|
|
784
|
-
const expected = { success: true, results: [{
|
|
805
|
+
const req = { objects: [customerOrgObject] };
|
|
806
|
+
const expected = { success: true, results: [{ objectId: 'customer-org-1', success: true }] };
|
|
785
807
|
mockFetch.mockResolvedValueOnce({
|
|
786
808
|
ok: true,
|
|
787
809
|
json: () => Promise.resolve(expected)
|
|
788
810
|
});
|
|
789
|
-
const result = await graphClient.
|
|
811
|
+
const result = await graphClient.setObjects(req);
|
|
790
812
|
expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
|
|
791
813
|
expect(result).toEqual(expected);
|
|
792
814
|
});
|
|
793
815
|
it('posts deal entities to /api/v1/entities/bulk and returns response', async () => {
|
|
794
|
-
const
|
|
816
|
+
const dealObject = {
|
|
795
817
|
schemaVersion: '2.0',
|
|
796
818
|
id: 'deal-1',
|
|
797
819
|
updateSequenceNumber: 1,
|
|
@@ -800,17 +822,19 @@ describe('TeamWorkGraphClient - deleteEntitiesByProperties', () => {
|
|
|
800
822
|
url: 'https://crm.example.com/deals/enterprise-software-123',
|
|
801
823
|
createdAt: '2024-07-09T14:27:37.000Z',
|
|
802
824
|
lastUpdatedAt: '2024-07-09T14:27:37.000Z',
|
|
803
|
-
permissions:
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
825
|
+
permissions: [
|
|
826
|
+
{
|
|
827
|
+
accessControls: [
|
|
828
|
+
{
|
|
829
|
+
principals: [
|
|
830
|
+
{
|
|
831
|
+
type: 'EVERYONE'
|
|
832
|
+
}
|
|
833
|
+
]
|
|
834
|
+
}
|
|
835
|
+
]
|
|
836
|
+
}
|
|
837
|
+
],
|
|
814
838
|
'atlassian:deal': {
|
|
815
839
|
contact: {
|
|
816
840
|
accountId: 'contact-deal-123',
|
|
@@ -853,18 +877,18 @@ describe('TeamWorkGraphClient - deleteEntitiesByProperties', () => {
|
|
|
853
877
|
isClosed: false
|
|
854
878
|
}
|
|
855
879
|
};
|
|
856
|
-
const req = {
|
|
857
|
-
const expected = { success: true, results: [{
|
|
880
|
+
const req = { objects: [dealObject] };
|
|
881
|
+
const expected = { success: true, results: [{ objectId: 'deal-1', success: true }] };
|
|
858
882
|
mockFetch.mockResolvedValueOnce({
|
|
859
883
|
ok: true,
|
|
860
884
|
json: () => Promise.resolve(expected)
|
|
861
885
|
});
|
|
862
|
-
const result = await graphClient.
|
|
886
|
+
const result = await graphClient.setObjects(req);
|
|
863
887
|
expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
|
|
864
888
|
expect(result).toEqual(expected);
|
|
865
889
|
});
|
|
866
890
|
it('posts deployment entities to /api/v1/entities/bulk and returns response', async () => {
|
|
867
|
-
const
|
|
891
|
+
const deploymentObject = {
|
|
868
892
|
schemaVersion: '2.0',
|
|
869
893
|
id: 'deployment-1',
|
|
870
894
|
updateSequenceNumber: 1,
|
|
@@ -873,17 +897,19 @@ describe('TeamWorkGraphClient - deleteEntitiesByProperties', () => {
|
|
|
873
897
|
url: 'https://ci.example.com/deployments/prod-api-v2.4.5',
|
|
874
898
|
createdAt: '2024-07-09T14:27:37.000Z',
|
|
875
899
|
lastUpdatedAt: '2024-07-09T14:27:37.000Z',
|
|
876
|
-
permissions:
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
900
|
+
permissions: [
|
|
901
|
+
{
|
|
902
|
+
accessControls: [
|
|
903
|
+
{
|
|
904
|
+
principals: [
|
|
905
|
+
{
|
|
906
|
+
type: 'EVERYONE'
|
|
907
|
+
}
|
|
908
|
+
]
|
|
909
|
+
}
|
|
910
|
+
]
|
|
911
|
+
}
|
|
912
|
+
],
|
|
887
913
|
'atlassian:deployment': {
|
|
888
914
|
deploymentSequenceNumber: 12345,
|
|
889
915
|
label: 'v2.4.5 - Bug fixes and performance improvements',
|
|
@@ -922,18 +948,18 @@ describe('TeamWorkGraphClient - deleteEntitiesByProperties', () => {
|
|
|
922
948
|
region: 'us-east-1'
|
|
923
949
|
}
|
|
924
950
|
};
|
|
925
|
-
const req = {
|
|
926
|
-
const expected = { success: true, results: [{
|
|
951
|
+
const req = { objects: [deploymentObject] };
|
|
952
|
+
const expected = { success: true, results: [{ objectId: 'deployment-1', success: true }] };
|
|
927
953
|
mockFetch.mockResolvedValueOnce({
|
|
928
954
|
ok: true,
|
|
929
955
|
json: () => Promise.resolve(expected)
|
|
930
956
|
});
|
|
931
|
-
const result = await graphClient.
|
|
957
|
+
const result = await graphClient.setObjects(req);
|
|
932
958
|
expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
|
|
933
959
|
expect(result).toEqual(expected);
|
|
934
960
|
});
|
|
935
961
|
it('posts design entities to /api/v1/entities/bulk and returns response', async () => {
|
|
936
|
-
const
|
|
962
|
+
const designObject = {
|
|
937
963
|
schemaVersion: '2.0',
|
|
938
964
|
id: 'design-1',
|
|
939
965
|
updateSequenceNumber: 1,
|
|
@@ -942,17 +968,19 @@ describe('TeamWorkGraphClient - deleteEntitiesByProperties', () => {
|
|
|
942
968
|
url: 'https://figma.com/design/mobile-login-screen',
|
|
943
969
|
createdAt: '2024-07-09T14:27:37.000Z',
|
|
944
970
|
lastUpdatedAt: '2024-07-09T14:27:37.000Z',
|
|
945
|
-
permissions:
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
971
|
+
permissions: [
|
|
972
|
+
{
|
|
973
|
+
accessControls: [
|
|
974
|
+
{
|
|
975
|
+
principals: [
|
|
976
|
+
{
|
|
977
|
+
type: 'EVERYONE'
|
|
978
|
+
}
|
|
979
|
+
]
|
|
980
|
+
}
|
|
981
|
+
]
|
|
982
|
+
}
|
|
983
|
+
],
|
|
956
984
|
'atlassian:design': {
|
|
957
985
|
liveEmbedUrl: 'https://figma.com/embed/mobile-login-screen',
|
|
958
986
|
inspectUrl: 'https://figma.com/inspect/mobile-login-screen',
|
|
@@ -961,18 +989,18 @@ describe('TeamWorkGraphClient - deleteEntitiesByProperties', () => {
|
|
|
961
989
|
iconUrl: 'https://figma.com/icons/mobile-login-screen.svg'
|
|
962
990
|
}
|
|
963
991
|
};
|
|
964
|
-
const req = {
|
|
965
|
-
const expected = { success: true, results: [{
|
|
992
|
+
const req = { objects: [designObject] };
|
|
993
|
+
const expected = { success: true, results: [{ objectId: 'design-1', success: true }] };
|
|
966
994
|
mockFetch.mockResolvedValueOnce({
|
|
967
995
|
ok: true,
|
|
968
996
|
json: () => Promise.resolve(expected)
|
|
969
997
|
});
|
|
970
|
-
const result = await graphClient.
|
|
998
|
+
const result = await graphClient.setObjects(req);
|
|
971
999
|
expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
|
|
972
1000
|
expect(result).toEqual(expected);
|
|
973
1001
|
});
|
|
974
1002
|
it('posts position entities to /api/v1/entities/bulk and returns response', async () => {
|
|
975
|
-
const
|
|
1003
|
+
const positionObject = {
|
|
976
1004
|
schemaVersion: '2.0',
|
|
977
1005
|
id: 'position-1',
|
|
978
1006
|
updateSequenceNumber: 1,
|
|
@@ -980,21 +1008,23 @@ describe('TeamWorkGraphClient - deleteEntitiesByProperties', () => {
|
|
|
980
1008
|
url: 'https://hr.example.com/positions/senior-backend-engineer',
|
|
981
1009
|
createdAt: '2024-07-09T14:27:37.000Z',
|
|
982
1010
|
lastUpdatedAt: '2024-07-09T14:27:37.000Z',
|
|
983
|
-
permissions:
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
1011
|
+
permissions: [
|
|
1012
|
+
{
|
|
1013
|
+
accessControls: [
|
|
1014
|
+
{
|
|
1015
|
+
principals: [
|
|
1016
|
+
{
|
|
1017
|
+
type: 'EVERYONE'
|
|
1018
|
+
}
|
|
1019
|
+
]
|
|
1020
|
+
}
|
|
1021
|
+
]
|
|
1022
|
+
}
|
|
1023
|
+
],
|
|
994
1024
|
parentKey: {
|
|
995
1025
|
type: 'atlassian:organisation',
|
|
996
1026
|
value: {
|
|
997
|
-
|
|
1027
|
+
objectId: 'org-tech-company-123'
|
|
998
1028
|
}
|
|
999
1029
|
},
|
|
1000
1030
|
associations: {
|
|
@@ -1011,18 +1041,18 @@ describe('TeamWorkGraphClient - deleteEntitiesByProperties', () => {
|
|
|
1011
1041
|
jobTitle: 'Senior Software Engineer - Backend'
|
|
1012
1042
|
}
|
|
1013
1043
|
};
|
|
1014
|
-
const req = {
|
|
1015
|
-
const expected = { success: true, results: [{
|
|
1044
|
+
const req = { objects: [positionObject] };
|
|
1045
|
+
const expected = { success: true, results: [{ objectId: 'position-1', success: true }] };
|
|
1016
1046
|
mockFetch.mockResolvedValueOnce({
|
|
1017
1047
|
ok: true,
|
|
1018
1048
|
json: () => Promise.resolve(expected)
|
|
1019
1049
|
});
|
|
1020
|
-
const result = await graphClient.
|
|
1050
|
+
const result = await graphClient.setObjects(req);
|
|
1021
1051
|
expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
|
|
1022
1052
|
expect(result).toEqual(expected);
|
|
1023
1053
|
});
|
|
1024
1054
|
it('posts project entities to /api/v1/entities/bulk and returns response', async () => {
|
|
1025
|
-
const
|
|
1055
|
+
const projectObject = {
|
|
1026
1056
|
schemaVersion: '2.0',
|
|
1027
1057
|
id: 'project-1',
|
|
1028
1058
|
updateSequenceNumber: 1,
|
|
@@ -1042,17 +1072,19 @@ describe('TeamWorkGraphClient - deleteEntitiesByProperties', () => {
|
|
|
1042
1072
|
]
|
|
1043
1073
|
},
|
|
1044
1074
|
lastUpdatedAt: '2024-07-09T14:27:37.000Z',
|
|
1045
|
-
permissions:
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1075
|
+
permissions: [
|
|
1076
|
+
{
|
|
1077
|
+
accessControls: [
|
|
1078
|
+
{
|
|
1079
|
+
principals: [
|
|
1080
|
+
{
|
|
1081
|
+
type: 'EVERYONE'
|
|
1082
|
+
}
|
|
1083
|
+
]
|
|
1084
|
+
}
|
|
1085
|
+
]
|
|
1086
|
+
}
|
|
1087
|
+
],
|
|
1056
1088
|
'atlassian:project': {
|
|
1057
1089
|
key: 'ECOM-123',
|
|
1058
1090
|
dueDate: '2024-12-31T23:59:59.000Z',
|
|
@@ -1090,18 +1122,18 @@ describe('TeamWorkGraphClient - deleteEntitiesByProperties', () => {
|
|
|
1090
1122
|
watchersCount: 8
|
|
1091
1123
|
}
|
|
1092
1124
|
};
|
|
1093
|
-
const req = {
|
|
1094
|
-
const expected = { success: true, results: [{
|
|
1125
|
+
const req = { objects: [projectObject] };
|
|
1126
|
+
const expected = { success: true, results: [{ objectId: 'project-1', success: true }] };
|
|
1095
1127
|
mockFetch.mockResolvedValueOnce({
|
|
1096
1128
|
ok: true,
|
|
1097
1129
|
json: () => Promise.resolve(expected)
|
|
1098
1130
|
});
|
|
1099
|
-
const result = await graphClient.
|
|
1131
|
+
const result = await graphClient.setObjects(req);
|
|
1100
1132
|
expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
|
|
1101
1133
|
expect(result).toEqual(expected);
|
|
1102
1134
|
});
|
|
1103
1135
|
it('posts pull request entities to /api/v1/entities/bulk and returns response', async () => {
|
|
1104
|
-
const
|
|
1136
|
+
const pullRequestObject = {
|
|
1105
1137
|
schemaVersion: '2.0',
|
|
1106
1138
|
id: 'pr-1',
|
|
1107
1139
|
updateSequenceNumber: 1,
|
|
@@ -1112,21 +1144,23 @@ describe('TeamWorkGraphClient - deleteEntitiesByProperties', () => {
|
|
|
1112
1144
|
containerKey: {
|
|
1113
1145
|
type: 'atlassian:repository',
|
|
1114
1146
|
value: {
|
|
1115
|
-
|
|
1147
|
+
objectId: 'repo-company-main-123'
|
|
1116
1148
|
}
|
|
1117
1149
|
},
|
|
1118
1150
|
lastUpdatedAt: '2024-07-09T14:27:37.000Z',
|
|
1119
|
-
permissions:
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1151
|
+
permissions: [
|
|
1152
|
+
{
|
|
1153
|
+
accessControls: [
|
|
1154
|
+
{
|
|
1155
|
+
principals: [
|
|
1156
|
+
{
|
|
1157
|
+
type: 'EVERYONE'
|
|
1158
|
+
}
|
|
1159
|
+
]
|
|
1160
|
+
}
|
|
1161
|
+
]
|
|
1162
|
+
}
|
|
1163
|
+
],
|
|
1130
1164
|
'atlassian:pull-request': {
|
|
1131
1165
|
title: 'Add user authentication feature',
|
|
1132
1166
|
displayId: 'PR-42',
|
|
@@ -1170,35 +1204,37 @@ describe('TeamWorkGraphClient - deleteEntitiesByProperties', () => {
|
|
|
1170
1204
|
taskCount: 3
|
|
1171
1205
|
}
|
|
1172
1206
|
};
|
|
1173
|
-
const req = {
|
|
1174
|
-
const expected = { success: true, results: [{
|
|
1207
|
+
const req = { objects: [pullRequestObject] };
|
|
1208
|
+
const expected = { success: true, results: [{ objectId: 'pr-1', success: true }] };
|
|
1175
1209
|
mockFetch.mockResolvedValueOnce({
|
|
1176
1210
|
ok: true,
|
|
1177
1211
|
json: () => Promise.resolve(expected)
|
|
1178
1212
|
});
|
|
1179
|
-
const result = await graphClient.
|
|
1213
|
+
const result = await graphClient.setObjects(req);
|
|
1180
1214
|
expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
|
|
1181
1215
|
expect(result).toEqual(expected);
|
|
1182
1216
|
});
|
|
1183
1217
|
it('posts remote link entities to /api/v1/entities/bulk and returns response', async () => {
|
|
1184
|
-
const
|
|
1218
|
+
const remoteLinkObject = {
|
|
1185
1219
|
schemaVersion: '2.0',
|
|
1186
1220
|
id: 'remote-link-1',
|
|
1187
1221
|
updateSequenceNumber: 1,
|
|
1188
1222
|
displayName: 'JIRA Issue Link - Fix user authentication bug',
|
|
1189
1223
|
url: 'https://company.atlassian.net/browse/AUTH-123',
|
|
1190
1224
|
lastUpdatedAt: '2024-07-09T14:27:37.000Z',
|
|
1191
|
-
permissions:
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1225
|
+
permissions: [
|
|
1226
|
+
{
|
|
1227
|
+
accessControls: [
|
|
1228
|
+
{
|
|
1229
|
+
principals: [
|
|
1230
|
+
{
|
|
1231
|
+
type: 'EVERYONE'
|
|
1232
|
+
}
|
|
1233
|
+
]
|
|
1234
|
+
}
|
|
1235
|
+
]
|
|
1236
|
+
}
|
|
1237
|
+
],
|
|
1202
1238
|
'atlassian:remote-link': {
|
|
1203
1239
|
type: 'issue',
|
|
1204
1240
|
status: {
|
|
@@ -1234,18 +1270,18 @@ describe('TeamWorkGraphClient - deleteEntitiesByProperties', () => {
|
|
|
1234
1270
|
fullNounThirdPartyAri: 'ari:cloud:jira:company-site:issue/AUTH-123'
|
|
1235
1271
|
}
|
|
1236
1272
|
};
|
|
1237
|
-
const req = {
|
|
1238
|
-
const expected = { success: true, results: [{
|
|
1273
|
+
const req = { objects: [remoteLinkObject] };
|
|
1274
|
+
const expected = { success: true, results: [{ objectId: 'remote-link-1', success: true }] };
|
|
1239
1275
|
mockFetch.mockResolvedValueOnce({
|
|
1240
1276
|
ok: true,
|
|
1241
1277
|
json: () => Promise.resolve(expected)
|
|
1242
1278
|
});
|
|
1243
|
-
const result = await graphClient.
|
|
1279
|
+
const result = await graphClient.setObjects(req);
|
|
1244
1280
|
expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
|
|
1245
1281
|
expect(result).toEqual(expected);
|
|
1246
1282
|
});
|
|
1247
1283
|
it('posts repository entities to /api/v1/entities/bulk and returns response', async () => {
|
|
1248
|
-
const
|
|
1284
|
+
const repositoryObject = {
|
|
1249
1285
|
schemaVersion: '2.0',
|
|
1250
1286
|
id: 'repository-1',
|
|
1251
1287
|
updateSequenceNumber: 1,
|
|
@@ -1253,17 +1289,19 @@ describe('TeamWorkGraphClient - deleteEntitiesByProperties', () => {
|
|
|
1253
1289
|
url: 'https://github.com/company/ecommerce-backend',
|
|
1254
1290
|
createdAt: '2024-07-09T14:27:37.000Z',
|
|
1255
1291
|
lastUpdatedAt: '2024-07-09T14:27:37.000Z',
|
|
1256
|
-
permissions:
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1292
|
+
permissions: [
|
|
1293
|
+
{
|
|
1294
|
+
accessControls: [
|
|
1295
|
+
{
|
|
1296
|
+
principals: [
|
|
1297
|
+
{
|
|
1298
|
+
type: 'EVERYONE'
|
|
1299
|
+
}
|
|
1300
|
+
]
|
|
1301
|
+
}
|
|
1302
|
+
]
|
|
1303
|
+
}
|
|
1304
|
+
],
|
|
1267
1305
|
'atlassian:repository': {
|
|
1268
1306
|
name: 'ecommerce-backend',
|
|
1269
1307
|
forkOf: 'https://github.com/upstream/ecommerce-platform',
|
|
@@ -1271,18 +1309,18 @@ describe('TeamWorkGraphClient - deleteEntitiesByProperties', () => {
|
|
|
1271
1309
|
avatarDescription: 'Company logo representing the ecommerce backend repository'
|
|
1272
1310
|
}
|
|
1273
1311
|
};
|
|
1274
|
-
const req = {
|
|
1275
|
-
const expected = { success: true, results: [{
|
|
1312
|
+
const req = { objects: [repositoryObject] };
|
|
1313
|
+
const expected = { success: true, results: [{ objectId: 'repository-1', success: true }] };
|
|
1276
1314
|
mockFetch.mockResolvedValueOnce({
|
|
1277
1315
|
ok: true,
|
|
1278
1316
|
json: () => Promise.resolve(expected)
|
|
1279
1317
|
});
|
|
1280
|
-
const result = await graphClient.
|
|
1318
|
+
const result = await graphClient.setObjects(req);
|
|
1281
1319
|
expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
|
|
1282
1320
|
expect(result).toEqual(expected);
|
|
1283
1321
|
});
|
|
1284
1322
|
it('posts software service entities to /api/v1/entities/bulk and returns response', async () => {
|
|
1285
|
-
const
|
|
1323
|
+
const softwareServiceObject = {
|
|
1286
1324
|
schemaVersion: '2.0',
|
|
1287
1325
|
id: 'software-service-1',
|
|
1288
1326
|
updateSequenceNumber: 1,
|
|
@@ -1290,17 +1328,19 @@ describe('TeamWorkGraphClient - deleteEntitiesByProperties', () => {
|
|
|
1290
1328
|
url: 'https://monitoring.example.com/services/payment-processor',
|
|
1291
1329
|
createdAt: '2024-07-09T14:27:37.000Z',
|
|
1292
1330
|
lastUpdatedAt: '2024-07-09T14:27:37.000Z',
|
|
1293
|
-
permissions:
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1331
|
+
permissions: [
|
|
1332
|
+
{
|
|
1333
|
+
accessControls: [
|
|
1334
|
+
{
|
|
1335
|
+
principals: [
|
|
1336
|
+
{
|
|
1337
|
+
type: 'EVERYONE'
|
|
1338
|
+
}
|
|
1339
|
+
]
|
|
1340
|
+
}
|
|
1341
|
+
]
|
|
1342
|
+
}
|
|
1343
|
+
],
|
|
1304
1344
|
'atlassian:software-service': {
|
|
1305
1345
|
description: 'Microservice responsible for processing all payment transactions with secure payment gateway integration',
|
|
1306
1346
|
associationsMetadata: {
|
|
@@ -1317,18 +1357,18 @@ describe('TeamWorkGraphClient - deleteEntitiesByProperties', () => {
|
|
|
1317
1357
|
serviceType: 'REST API'
|
|
1318
1358
|
}
|
|
1319
1359
|
};
|
|
1320
|
-
const req = {
|
|
1321
|
-
const expected = { success: true, results: [{
|
|
1360
|
+
const req = { objects: [softwareServiceObject] };
|
|
1361
|
+
const expected = { success: true, results: [{ objectId: 'software-service-1', success: true }] };
|
|
1322
1362
|
mockFetch.mockResolvedValueOnce({
|
|
1323
1363
|
ok: true,
|
|
1324
1364
|
json: () => Promise.resolve(expected)
|
|
1325
1365
|
});
|
|
1326
|
-
const result = await graphClient.
|
|
1366
|
+
const result = await graphClient.setObjects(req);
|
|
1327
1367
|
expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
|
|
1328
1368
|
expect(result).toEqual(expected);
|
|
1329
1369
|
});
|
|
1330
1370
|
it('posts space entities to /api/v1/entities/bulk and returns response', async () => {
|
|
1331
|
-
const
|
|
1371
|
+
const spaceObject = {
|
|
1332
1372
|
schemaVersion: '2.0',
|
|
1333
1373
|
id: 'space-1',
|
|
1334
1374
|
updateSequenceNumber: 1,
|
|
@@ -1336,17 +1376,19 @@ describe('TeamWorkGraphClient - deleteEntitiesByProperties', () => {
|
|
|
1336
1376
|
url: 'https://company.atlassian.net/wiki/spaces/ENGDOC',
|
|
1337
1377
|
createdAt: '2024-07-09T14:27:37.000Z',
|
|
1338
1378
|
lastUpdatedAt: '2024-07-09T14:27:37.000Z',
|
|
1339
|
-
permissions:
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1379
|
+
permissions: [
|
|
1380
|
+
{
|
|
1381
|
+
accessControls: [
|
|
1382
|
+
{
|
|
1383
|
+
principals: [
|
|
1384
|
+
{
|
|
1385
|
+
type: 'EVERYONE'
|
|
1386
|
+
}
|
|
1387
|
+
]
|
|
1388
|
+
}
|
|
1389
|
+
]
|
|
1390
|
+
}
|
|
1391
|
+
],
|
|
1350
1392
|
'atlassian:space': {
|
|
1351
1393
|
key: 'ENGDOC',
|
|
1352
1394
|
spaceType: 'global',
|
|
@@ -1360,18 +1402,18 @@ describe('TeamWorkGraphClient - deleteEntitiesByProperties', () => {
|
|
|
1360
1402
|
labels: ['engineering', 'documentation', 'team-resources', 'best-practices', 'onboarding']
|
|
1361
1403
|
}
|
|
1362
1404
|
};
|
|
1363
|
-
const req = {
|
|
1364
|
-
const expected = { success: true, results: [{
|
|
1405
|
+
const req = { objects: [spaceObject] };
|
|
1406
|
+
const expected = { success: true, results: [{ objectId: 'space-1', success: true }] };
|
|
1365
1407
|
mockFetch.mockResolvedValueOnce({
|
|
1366
1408
|
ok: true,
|
|
1367
1409
|
json: () => Promise.resolve(expected)
|
|
1368
1410
|
});
|
|
1369
|
-
const result = await graphClient.
|
|
1411
|
+
const result = await graphClient.setObjects(req);
|
|
1370
1412
|
expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
|
|
1371
1413
|
expect(result).toEqual(expected);
|
|
1372
1414
|
});
|
|
1373
1415
|
it('posts video entities to /api/v1/entities/bulk and returns response', async () => {
|
|
1374
|
-
const
|
|
1416
|
+
const videoObject = {
|
|
1375
1417
|
schemaVersion: '2.0',
|
|
1376
1418
|
id: 'video-1',
|
|
1377
1419
|
updateSequenceNumber: 1,
|
|
@@ -1379,17 +1421,19 @@ describe('TeamWorkGraphClient - deleteEntitiesByProperties', () => {
|
|
|
1379
1421
|
url: 'https://company.video.com/watch/react-hooks-intro',
|
|
1380
1422
|
createdAt: '2024-07-09T14:27:37.000Z',
|
|
1381
1423
|
lastUpdatedAt: '2024-07-09T14:27:37.000Z',
|
|
1382
|
-
permissions:
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1424
|
+
permissions: [
|
|
1425
|
+
{
|
|
1426
|
+
accessControls: [
|
|
1427
|
+
{
|
|
1428
|
+
principals: [
|
|
1429
|
+
{
|
|
1430
|
+
type: 'EVERYONE'
|
|
1431
|
+
}
|
|
1432
|
+
]
|
|
1433
|
+
}
|
|
1434
|
+
]
|
|
1435
|
+
}
|
|
1436
|
+
],
|
|
1393
1437
|
'atlassian:video': {
|
|
1394
1438
|
thumbnailUrl: 'https://company.video.com/thumbnails/react-hooks-intro.jpg',
|
|
1395
1439
|
embedUrl: 'https://company.video.com/embed/react-hooks-intro',
|
|
@@ -1475,18 +1519,18 @@ describe('TeamWorkGraphClient - deleteEntitiesByProperties', () => {
|
|
|
1475
1519
|
]
|
|
1476
1520
|
}
|
|
1477
1521
|
};
|
|
1478
|
-
const req = {
|
|
1479
|
-
const expected = { success: true, results: [{
|
|
1522
|
+
const req = { objects: [videoObject] };
|
|
1523
|
+
const expected = { success: true, results: [{ objectId: 'video-1', success: true }] };
|
|
1480
1524
|
mockFetch.mockResolvedValueOnce({
|
|
1481
1525
|
ok: true,
|
|
1482
1526
|
json: () => Promise.resolve(expected)
|
|
1483
1527
|
});
|
|
1484
|
-
const result = await graphClient.
|
|
1528
|
+
const result = await graphClient.setObjects(req);
|
|
1485
1529
|
expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
|
|
1486
1530
|
expect(result).toEqual(expected);
|
|
1487
1531
|
});
|
|
1488
1532
|
it('posts work item entities to /api/v1/entities/bulk and returns response', async () => {
|
|
1489
|
-
const
|
|
1533
|
+
const workItemObject = {
|
|
1490
1534
|
schemaVersion: '2.0',
|
|
1491
1535
|
id: 'work-item-1',
|
|
1492
1536
|
updateSequenceNumber: 1,
|
|
@@ -1497,21 +1541,23 @@ describe('TeamWorkGraphClient - deleteEntitiesByProperties', () => {
|
|
|
1497
1541
|
containerKey: {
|
|
1498
1542
|
type: 'atlassian:space',
|
|
1499
1543
|
value: {
|
|
1500
|
-
|
|
1544
|
+
objectId: 'space-engineering-team-docs'
|
|
1501
1545
|
}
|
|
1502
1546
|
},
|
|
1503
1547
|
lastUpdatedAt: '2024-07-09T14:27:37.000Z',
|
|
1504
|
-
permissions:
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1548
|
+
permissions: [
|
|
1549
|
+
{
|
|
1550
|
+
accessControls: [
|
|
1551
|
+
{
|
|
1552
|
+
principals: [
|
|
1553
|
+
{
|
|
1554
|
+
type: 'EVERYONE'
|
|
1555
|
+
}
|
|
1556
|
+
]
|
|
1557
|
+
}
|
|
1558
|
+
]
|
|
1559
|
+
}
|
|
1560
|
+
],
|
|
1515
1561
|
'atlassian:work-item': {
|
|
1516
1562
|
dueDate: '2024-08-15T17:00:00.000Z',
|
|
1517
1563
|
assignee: {
|
|
@@ -1569,18 +1615,18 @@ describe('TeamWorkGraphClient - deleteEntitiesByProperties', () => {
|
|
|
1569
1615
|
team: 'Backend Infrastructure Team'
|
|
1570
1616
|
}
|
|
1571
1617
|
};
|
|
1572
|
-
const req = {
|
|
1573
|
-
const expected = { success: true, results: [{
|
|
1618
|
+
const req = { objects: [workItemObject] };
|
|
1619
|
+
const expected = { success: true, results: [{ objectId: 'work-item-1', success: true }] };
|
|
1574
1620
|
mockFetch.mockResolvedValueOnce({
|
|
1575
1621
|
ok: true,
|
|
1576
1622
|
json: () => Promise.resolve(expected)
|
|
1577
1623
|
});
|
|
1578
|
-
const result = await graphClient.
|
|
1624
|
+
const result = await graphClient.setObjects(req);
|
|
1579
1625
|
expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
|
|
1580
1626
|
expect(result).toEqual(expected);
|
|
1581
1627
|
});
|
|
1582
1628
|
it('posts worker entities to /api/v1/entities/bulk and returns response', async () => {
|
|
1583
|
-
const
|
|
1629
|
+
const workerObject = {
|
|
1584
1630
|
schemaVersion: '2.0',
|
|
1585
1631
|
id: 'worker-1',
|
|
1586
1632
|
updateSequenceNumber: 1,
|
|
@@ -1588,17 +1634,19 @@ describe('TeamWorkGraphClient - deleteEntitiesByProperties', () => {
|
|
|
1588
1634
|
url: 'https://hr.example.com/employees/sarah-johnson',
|
|
1589
1635
|
createdAt: '2024-07-09T14:27:37.000Z',
|
|
1590
1636
|
lastUpdatedAt: '2024-07-09T14:27:37.000Z',
|
|
1591
|
-
permissions:
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1637
|
+
permissions: [
|
|
1638
|
+
{
|
|
1639
|
+
accessControls: [
|
|
1640
|
+
{
|
|
1641
|
+
principals: [
|
|
1642
|
+
{
|
|
1643
|
+
type: 'EVERYONE'
|
|
1644
|
+
}
|
|
1645
|
+
]
|
|
1646
|
+
}
|
|
1647
|
+
]
|
|
1648
|
+
}
|
|
1649
|
+
],
|
|
1602
1650
|
'atlassian:worker': {
|
|
1603
1651
|
hiredAt: '2022-03-15T09:00:00.000Z',
|
|
1604
1652
|
workerUser: {
|
|
@@ -1614,13 +1662,13 @@ describe('TeamWorkGraphClient - deleteEntitiesByProperties', () => {
|
|
|
1614
1662
|
customAndSensitiveData: 'Employee ID: EMP001234, Department: Engineering, Salary Grade: L5, Manager: Alex Rodriguez, Office Location: San Francisco HQ'
|
|
1615
1663
|
}
|
|
1616
1664
|
};
|
|
1617
|
-
const req = {
|
|
1618
|
-
const expected = { success: true, results: [{
|
|
1665
|
+
const req = { objects: [workerObject] };
|
|
1666
|
+
const expected = { success: true, results: [{ objectId: 'worker-1', success: true }] };
|
|
1619
1667
|
mockFetch.mockResolvedValueOnce({
|
|
1620
1668
|
ok: true,
|
|
1621
1669
|
json: () => Promise.resolve(expected)
|
|
1622
1670
|
});
|
|
1623
|
-
const result = await graphClient.
|
|
1671
|
+
const result = await graphClient.setObjects(req);
|
|
1624
1672
|
expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
|
|
1625
1673
|
expect(result).toEqual(expected);
|
|
1626
1674
|
});
|