@forge/teamwork-graph 3.1.0-next.3-experimental-4bd2ca0 → 3.1.0-next.3-experimental-ec29181

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.
@@ -8,6 +8,7 @@ jest.mock('@forge/api');
8
8
  describe('TeamWorkGraphClient - Group Operations', () => {
9
9
  let graphClient;
10
10
  let mockFetch;
11
+ const TEST_CONNECTION_ID = 'test-connection-123';
11
12
  beforeEach(() => {
12
13
  graphClient = new graph_1.TeamWorkGraphClient();
13
14
  mockFetch = jest.fn();
@@ -49,13 +50,17 @@ describe('TeamWorkGraphClient - Group Operations', () => {
49
50
  json: () => Promise.resolve(backendResponse)
50
51
  });
51
52
  const result = await graphClient.setGroups({
52
- groups: [groupPayload]
53
+ groups: [groupPayload],
54
+ connectionId: TEST_CONNECTION_ID
53
55
  });
54
56
  expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.GROUPS.BULK), {
55
57
  method: 'POST',
56
58
  body: JSON.stringify({ groups: [groupPayload] }),
57
59
  redirect: 'follow',
58
- headers: { 'Content-Type': 'application/json' }
60
+ headers: {
61
+ 'Content-Type': 'application/json',
62
+ 'Atl-Connection-Id': TEST_CONNECTION_ID
63
+ }
59
64
  });
60
65
  expect(result).toEqual(expectedResponse);
61
66
  });
@@ -83,30 +88,37 @@ describe('TeamWorkGraphClient - Group Operations', () => {
83
88
  json: () => Promise.resolve(backendResponse)
84
89
  });
85
90
  const result = await graphClient.setGroups({
86
- groups: [groupWithoutMembers]
91
+ groups: [groupWithoutMembers],
92
+ connectionId: TEST_CONNECTION_ID
87
93
  });
88
94
  expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.GROUPS.BULK), {
89
95
  method: 'POST',
90
96
  body: JSON.stringify({ groups: [groupWithoutMembers] }),
91
97
  redirect: 'follow',
92
- headers: { 'Content-Type': 'application/json' }
98
+ headers: {
99
+ 'Content-Type': 'application/json',
100
+ 'Atl-Connection-Id': TEST_CONNECTION_ID
101
+ }
93
102
  });
94
103
  expect(result).toEqual(expectedResponse);
95
104
  });
96
105
  it('should throw error when groups array is empty', async () => {
97
106
  await expect(graphClient.setGroups({
98
- groups: []
107
+ groups: [],
108
+ connectionId: TEST_CONNECTION_ID
99
109
  })).rejects.toThrow('groups array cannot be empty');
100
110
  });
101
111
  it('should throw error when groups array exceeds limit', async () => {
102
112
  const manyGroups = Array(validators_1.MAX_BULK_GROUPS + 1).fill(groupPayload);
103
113
  await expect(graphClient.setGroups({
104
- groups: manyGroups
114
+ groups: manyGroups,
115
+ connectionId: TEST_CONNECTION_ID
105
116
  })).rejects.toThrow(`Bulk group ingestion supports maximum ${validators_1.MAX_BULK_GROUPS} groups. Received ${validators_1.MAX_BULK_GROUPS + 1}`);
106
117
  });
107
118
  it('should throw error when groups is not an array', async () => {
108
119
  await expect(graphClient.setGroups({
109
- groups: null
120
+ groups: null,
121
+ connectionId: TEST_CONNECTION_ID
110
122
  })).rejects.toThrow('groups must be an array');
111
123
  });
112
124
  it('should pass Atl-Connection-Id header when connectionId is provided', async () => {
@@ -137,36 +149,6 @@ describe('TeamWorkGraphClient - Group Operations', () => {
137
149
  })
138
150
  }));
139
151
  });
140
- it('should not pass Atl-Connection-Id header when connectionId is not provided', async () => {
141
- const backendResponse = {
142
- success: [
143
- {
144
- externalId: 'developers',
145
- statusCode: 200,
146
- message: 'Group created successfully'
147
- }
148
- ],
149
- failures: []
150
- };
151
- mockFetch.mockResolvedValueOnce({
152
- ok: true,
153
- json: () => Promise.resolve(backendResponse)
154
- });
155
- await graphClient.setGroups({
156
- groups: [groupPayload]
157
- });
158
- expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.GROUPS.BULK), expect.objectContaining({
159
- method: 'POST',
160
- headers: expect.objectContaining({
161
- 'Content-Type': 'application/json'
162
- })
163
- }));
164
- expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.GROUPS.BULK), expect.not.objectContaining({
165
- headers: expect.objectContaining({
166
- 'Atl-Connection-Id': expect.anything()
167
- })
168
- }));
169
- });
170
152
  });
171
153
  describe('deleteGroupsByExternalId', () => {
172
154
  it('should successfully delete groups in bulk', async () => {
@@ -185,24 +167,30 @@ describe('TeamWorkGraphClient - Group Operations', () => {
185
167
  json: () => Promise.resolve(backendResponse)
186
168
  });
187
169
  const result = await graphClient.deleteGroupsByExternalId({
188
- externalIds: ['developers', 'admins']
170
+ externalIds: ['developers', 'admins'],
171
+ connectionId: TEST_CONNECTION_ID
189
172
  });
190
173
  expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.GROUPS.DELETE), {
191
174
  method: 'DELETE',
192
175
  body: JSON.stringify({ externalIds: ['developers', 'admins'] }),
193
176
  redirect: 'follow',
194
- headers: { 'Content-Type': 'application/json' }
177
+ headers: {
178
+ 'Content-Type': 'application/json',
179
+ 'Atl-Connection-Id': TEST_CONNECTION_ID
180
+ }
195
181
  });
196
182
  expect(result).toEqual(expectedResponse);
197
183
  });
198
184
  it('should throw error when externalIds array is empty', async () => {
199
185
  await expect(graphClient.deleteGroupsByExternalId({
200
- externalIds: []
186
+ externalIds: [],
187
+ connectionId: TEST_CONNECTION_ID
201
188
  })).rejects.toThrow('externalIds array cannot be empty');
202
189
  });
203
190
  it('should throw error when externalIds is not an array', async () => {
204
191
  await expect(graphClient.deleteGroupsByExternalId({
205
- externalIds: null
192
+ externalIds: null,
193
+ connectionId: TEST_CONNECTION_ID
206
194
  })).rejects.toThrow('externalIds must be an array');
207
195
  });
208
196
  });
@@ -234,12 +222,16 @@ describe('TeamWorkGraphClient - Group Operations', () => {
234
222
  json: () => Promise.resolve(expectedGroup)
235
223
  });
236
224
  const result = await graphClient.getGroupByExternalId({
237
- externalId: 'developers'
225
+ externalId: 'developers',
226
+ connectionId: TEST_CONNECTION_ID
238
227
  });
239
228
  expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.GROUPS.GET_BY_EXTERNAL_ID) + '/developers', {
240
229
  method: 'GET',
241
230
  redirect: 'follow',
242
- headers: { 'Content-Type': 'application/json' }
231
+ headers: {
232
+ 'Content-Type': 'application/json',
233
+ 'Atl-Connection-Id': TEST_CONNECTION_ID
234
+ }
243
235
  });
244
236
  expect(result).toEqual({
245
237
  success: true,
@@ -261,7 +253,8 @@ describe('TeamWorkGraphClient - Group Operations', () => {
261
253
  };
262
254
  mockFetch.mockResolvedValueOnce(errorResponse);
263
255
  const result = await graphClient.getGroupByExternalId({
264
- externalId: 'nonexistent-group'
256
+ externalId: 'nonexistent-group',
257
+ connectionId: TEST_CONNECTION_ID
265
258
  });
266
259
  expect(result).toEqual({
267
260
  success: false,
@@ -271,12 +264,14 @@ describe('TeamWorkGraphClient - Group Operations', () => {
271
264
  });
272
265
  it('should throw error when externalId is missing', async () => {
273
266
  await expect(graphClient.getGroupByExternalId({
274
- externalId: ''
267
+ externalId: '',
268
+ connectionId: TEST_CONNECTION_ID
275
269
  })).rejects.toThrow('externalId is required');
276
270
  });
277
271
  it('should throw error when externalId is null', async () => {
278
272
  await expect(graphClient.getGroupByExternalId({
279
- externalId: null
273
+ externalId: null,
274
+ connectionId: TEST_CONNECTION_ID
280
275
  })).rejects.toThrow('externalId is required');
281
276
  });
282
277
  });
@@ -8,6 +8,7 @@ jest.mock('@forge/api');
8
8
  describe('TeamWorkGraphClient - User Operations', () => {
9
9
  let graphClient;
10
10
  let mockFetch;
11
+ const TEST_CONNECTION_ID = 'test-connection-123';
11
12
  beforeEach(() => {
12
13
  graphClient = new graph_1.TeamWorkGraphClient();
13
14
  mockFetch = jest.fn();
@@ -54,30 +55,37 @@ describe('TeamWorkGraphClient - User Operations', () => {
54
55
  json: () => Promise.resolve(apiResponse)
55
56
  });
56
57
  const result = await graphClient.setUsers({
57
- users: [userPayload]
58
+ users: [userPayload],
59
+ connectionId: TEST_CONNECTION_ID
58
60
  });
59
61
  expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.USERS.BULK), {
60
62
  method: 'POST',
61
63
  body: JSON.stringify({ users: [userPayload] }),
62
64
  redirect: 'follow',
63
- headers: { 'Content-Type': 'application/json' }
65
+ headers: {
66
+ 'Content-Type': 'application/json',
67
+ 'Atl-Connection-Id': TEST_CONNECTION_ID
68
+ }
64
69
  });
65
70
  expect(result).toEqual(expectedResponse);
66
71
  });
67
72
  it('should throw error when users array is empty', async () => {
68
73
  await expect(graphClient.setUsers({
69
- users: []
74
+ users: [],
75
+ connectionId: TEST_CONNECTION_ID
70
76
  })).rejects.toThrow('users array cannot be empty');
71
77
  });
72
78
  it('should throw error when users array exceeds limit', async () => {
73
79
  const manyUsers = Array(validators_1.MAX_BULK_USERS + 1).fill(userPayload);
74
80
  await expect(graphClient.setUsers({
75
- users: manyUsers
81
+ users: manyUsers,
82
+ connectionId: TEST_CONNECTION_ID
76
83
  })).rejects.toThrow(`Bulk user ingestion supports maximum ${validators_1.MAX_BULK_USERS} users. Received ${validators_1.MAX_BULK_USERS + 1}`);
77
84
  });
78
85
  it('should throw error when users is not an array', async () => {
79
86
  await expect(graphClient.setUsers({
80
- users: null
87
+ users: null,
88
+ connectionId: TEST_CONNECTION_ID
81
89
  })).rejects.toThrow('users must be an array');
82
90
  });
83
91
  it('should pass Atl-Connection-Id header when connectionId is provided', async () => {
@@ -102,30 +110,6 @@ describe('TeamWorkGraphClient - User Operations', () => {
102
110
  })
103
111
  }));
104
112
  });
105
- it('should not pass Atl-Connection-Id header when connectionId is not provided', async () => {
106
- const apiResponse = {
107
- success: [{ externalId: 'user-123', success: true, statusCode: 200 }],
108
- failures: []
109
- };
110
- mockFetch.mockResolvedValueOnce({
111
- ok: true,
112
- json: () => Promise.resolve(apiResponse)
113
- });
114
- await graphClient.setUsers({
115
- users: [userPayload]
116
- });
117
- expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.USERS.BULK), expect.objectContaining({
118
- method: 'POST',
119
- headers: expect.objectContaining({
120
- 'Content-Type': 'application/json'
121
- })
122
- }));
123
- expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.USERS.BULK), expect.not.objectContaining({
124
- headers: expect.objectContaining({
125
- 'Atl-Connection-Id': expect.anything()
126
- })
127
- }));
128
- });
129
113
  });
130
114
  describe('deleteUsersByExternalId', () => {
131
115
  it('should successfully delete users in bulk', async () => {
@@ -141,24 +125,30 @@ describe('TeamWorkGraphClient - User Operations', () => {
141
125
  json: () => Promise.resolve(expectedResponse)
142
126
  });
143
127
  const result = await graphClient.deleteUsersByExternalId({
144
- externalIds: ['user-123', 'user-456']
128
+ externalIds: ['user-123', 'user-456'],
129
+ connectionId: TEST_CONNECTION_ID
145
130
  });
146
131
  expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.USERS.DELETE), {
147
132
  method: 'DELETE',
148
133
  body: JSON.stringify({ externalIds: ['user-123', 'user-456'] }),
149
134
  redirect: 'follow',
150
- headers: { 'Content-Type': 'application/json' }
135
+ headers: {
136
+ 'Content-Type': 'application/json',
137
+ 'Atl-Connection-Id': TEST_CONNECTION_ID
138
+ }
151
139
  });
152
140
  expect(result).toEqual(expectedResponse);
153
141
  });
154
142
  it('should throw error when externalIds array is empty', async () => {
155
143
  await expect(graphClient.deleteUsersByExternalId({
156
- externalIds: []
144
+ externalIds: [],
145
+ connectionId: TEST_CONNECTION_ID
157
146
  })).rejects.toThrow('externalIds array cannot be empty');
158
147
  });
159
148
  it('should throw error when externalIds is not an array', async () => {
160
149
  await expect(graphClient.deleteUsersByExternalId({
161
- externalIds: null
150
+ externalIds: null,
151
+ connectionId: TEST_CONNECTION_ID
162
152
  })).rejects.toThrow('externalIds must be an array');
163
153
  });
164
154
  });
@@ -188,12 +178,16 @@ describe('TeamWorkGraphClient - User Operations', () => {
188
178
  json: () => Promise.resolve(expectedUser)
189
179
  });
190
180
  const result = await graphClient.getUserByExternalId({
191
- externalId: 'user-123'
181
+ externalId: 'user-123',
182
+ connectionId: TEST_CONNECTION_ID
192
183
  });
193
184
  expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.USERS.GET_BY_EXTERNAL_ID) + '/user-123', {
194
185
  method: 'GET',
195
186
  redirect: 'follow',
196
- headers: { 'Content-Type': 'application/json' }
187
+ headers: {
188
+ 'Content-Type': 'application/json',
189
+ 'Atl-Connection-Id': TEST_CONNECTION_ID
190
+ }
197
191
  });
198
192
  expect(result).toEqual({
199
193
  success: true,
@@ -215,7 +209,8 @@ describe('TeamWorkGraphClient - User Operations', () => {
215
209
  };
216
210
  mockFetch.mockResolvedValueOnce(errorResponse);
217
211
  const result = await graphClient.getUserByExternalId({
218
- externalId: 'nonexistent-user'
212
+ externalId: 'nonexistent-user',
213
+ connectionId: TEST_CONNECTION_ID
219
214
  });
220
215
  expect(result).toEqual({
221
216
  success: false,
@@ -225,7 +220,8 @@ describe('TeamWorkGraphClient - User Operations', () => {
225
220
  });
226
221
  it('should throw error when externalId is missing', async () => {
227
222
  await expect(graphClient.getUserByExternalId({
228
- externalId: ''
223
+ externalId: '',
224
+ connectionId: TEST_CONNECTION_ID
229
225
  })).rejects.toThrow('externalId is required');
230
226
  });
231
227
  });
@@ -262,13 +258,17 @@ describe('TeamWorkGraphClient - User Operations', () => {
262
258
  json: () => Promise.resolve(mockApiResponse)
263
259
  });
264
260
  const result = await graphClient.mapUsers({
265
- directMappings: [mappingWithAccountId]
261
+ directMappings: [mappingWithAccountId],
262
+ connectionId: TEST_CONNECTION_ID
266
263
  });
267
264
  expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.USERS.MAPPINGS), {
268
265
  method: 'POST',
269
266
  body: JSON.stringify({ directMappings: [mappingWithAccountId] }),
270
267
  redirect: 'follow',
271
- headers: { 'Content-Type': 'application/json' }
268
+ headers: {
269
+ 'Content-Type': 'application/json',
270
+ 'Atl-Connection-Id': TEST_CONNECTION_ID
271
+ }
272
272
  });
273
273
  expect(result).toEqual(expectedResponse);
274
274
  });
@@ -290,13 +290,17 @@ describe('TeamWorkGraphClient - User Operations', () => {
290
290
  json: () => Promise.resolve(mockApiResponse)
291
291
  });
292
292
  const result = await graphClient.mapUsers({
293
- directMappings: [mappingWithEmail]
293
+ directMappings: [mappingWithEmail],
294
+ connectionId: TEST_CONNECTION_ID
294
295
  });
295
296
  expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.USERS.MAPPINGS), {
296
297
  method: 'POST',
297
298
  body: JSON.stringify({ directMappings: [mappingWithEmail] }),
298
299
  redirect: 'follow',
299
- headers: { 'Content-Type': 'application/json' }
300
+ headers: {
301
+ 'Content-Type': 'application/json',
302
+ 'Atl-Connection-Id': TEST_CONNECTION_ID
303
+ }
300
304
  });
301
305
  expect(result).toEqual(expectedResponse);
302
306
  });
@@ -326,30 +330,37 @@ describe('TeamWorkGraphClient - User Operations', () => {
326
330
  json: () => Promise.resolve(mockApiResponse)
327
331
  });
328
332
  const result = await graphClient.mapUsers({
329
- directMappings: [mappingWithAccountId, mappingWithEmail]
333
+ directMappings: [mappingWithAccountId, mappingWithEmail],
334
+ connectionId: TEST_CONNECTION_ID
330
335
  });
331
336
  expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.USERS.MAPPINGS), {
332
337
  method: 'POST',
333
338
  body: JSON.stringify({ directMappings: [mappingWithAccountId, mappingWithEmail] }),
334
339
  redirect: 'follow',
335
- headers: { 'Content-Type': 'application/json' }
340
+ headers: {
341
+ 'Content-Type': 'application/json',
342
+ 'Atl-Connection-Id': TEST_CONNECTION_ID
343
+ }
336
344
  });
337
345
  expect(result).toEqual(expectedResponse);
338
346
  });
339
347
  it('should throw error when directMappings array is empty', async () => {
340
348
  await expect(graphClient.mapUsers({
341
- directMappings: []
349
+ directMappings: [],
350
+ connectionId: TEST_CONNECTION_ID
342
351
  })).rejects.toThrow('directMappings array cannot be empty');
343
352
  });
344
353
  it('should throw error when directMappings array exceeds limit', async () => {
345
354
  const manyMappings = Array(validators_1.MAX_USER_MAPPINGS + 1).fill(mappingWithAccountId);
346
355
  await expect(graphClient.mapUsers({
347
- directMappings: manyMappings
356
+ directMappings: manyMappings,
357
+ connectionId: TEST_CONNECTION_ID
348
358
  })).rejects.toThrow(`Bulk user mapping supports maximum ${validators_1.MAX_USER_MAPPINGS} mappings. Received ${validators_1.MAX_USER_MAPPINGS + 1}`);
349
359
  });
350
360
  it('should throw error when directMappings is not an array', async () => {
351
361
  await expect(graphClient.mapUsers({
352
- directMappings: null
362
+ directMappings: null,
363
+ connectionId: TEST_CONNECTION_ID
353
364
  })).rejects.toThrow('directMappings must be an array');
354
365
  });
355
366
  it('should throw error when mapping has neither accountId nor email', async () => {
@@ -359,7 +370,8 @@ describe('TeamWorkGraphClient - User Operations', () => {
359
370
  updatedAt: Date.now()
360
371
  };
361
372
  await expect(graphClient.mapUsers({
362
- directMappings: [invalidMapping]
373
+ directMappings: [invalidMapping],
374
+ connectionId: TEST_CONNECTION_ID
363
375
  })).rejects.toThrow('Each mapping must have either accountId or email');
364
376
  });
365
377
  it('should throw error when mapping is missing externalId', async () => {
@@ -370,7 +382,8 @@ describe('TeamWorkGraphClient - User Operations', () => {
370
382
  updatedAt: Date.now()
371
383
  };
372
384
  await expect(graphClient.mapUsers({
373
- directMappings: [invalidMapping]
385
+ directMappings: [invalidMapping],
386
+ connectionId: TEST_CONNECTION_ID
374
387
  })).rejects.toThrow('Each mapping must have an externalId');
375
388
  });
376
389
  });
@@ -1 +1 @@
1
- {"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../src/graph.ts"],"names":[],"mappings":"AAoBA,OAAO,EACL,a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,YAAmB,gBAAgB,KAAG,QAAQ,iBAAiB,CAAC,CAoBtE;IAEF,uBAAuB,YACZ,8BAA8B,KACtC,QAAQ,+BAA+B,CAAC,CAgBzC;IAEF,mBAAmB,YAAmB,0BAA0B,KAAG,QAAQ,2BAA2B,CAAC,CAgBrG;IAEF,QAAQ,YAAmB,eAAe,KAAG,QAAQ,gBAAgB,CAAC,CAmBpE;IAOF,oBAAoB,YAAmB,mBAAmB,KAAG,QAAQ,oBAAoB,CAAC,CAqBxF;IAKF,iBAAiB,YAAmB,wBAAwB,KAAG,QAAQ,yBAAyB,CAAC,CAwB/F;IAKF,gBAAgB,YAAmB,uBAAuB,KAAG,QAAQ,wBAAwB,CAAC,CAyB5F;YAEY,WAAW;CA8B1B;AAED,eAAO,MAAM,aAAa,qBAA4B,CAAC"}
package/out/graph.js CHANGED
@@ -11,10 +11,10 @@ class TeamWorkGraphClient {
11
11
  const { objects, properties, connectionId } = request;
12
12
  (0, validators_1.validateSetObjectsRequest)(objects, properties);
13
13
  try {
14
- const response = await this.sendRequest(endpoints_1.ENDPOINTS.OBJECTS.BULK, {
14
+ const response = await this.sendRequest(connectionId, endpoints_1.ENDPOINTS.OBJECTS.BULK, {
15
15
  method: 'POST',
16
16
  body: JSON.stringify({ entities: objects, properties })
17
- }, connectionId);
17
+ });
18
18
  return {
19
19
  success: true,
20
20
  results: {
@@ -33,13 +33,13 @@ class TeamWorkGraphClient {
33
33
  (0, validators_1.validateGetObjectByExternalIdRequest)(objectType, externalId);
34
34
  try {
35
35
  const path = endpoints_1.ENDPOINTS.OBJECTS.GET_BY_EXTERNAL_ID;
36
- const response = await this.sendRequest(path, {
36
+ const response = await this.sendRequest(connectionId, path, {
37
37
  method: 'POST',
38
38
  body: JSON.stringify({
39
39
  entityType: objectType,
40
40
  entityIds: [externalId]
41
41
  })
42
- }, connectionId);
42
+ });
43
43
  return {
44
44
  success: true,
45
45
  object: response.entities.length > 0 ? response.entities[0] : null
@@ -53,10 +53,10 @@ class TeamWorkGraphClient {
53
53
  const { objectType, externalIds, connectionId } = request;
54
54
  (0, validators_1.validateDeleteObjectsByExternalIdRequest)(objectType, externalIds);
55
55
  try {
56
- await this.sendRequest(endpoints_1.ENDPOINTS.OBJECTS.BULK_DELETE, {
56
+ await this.sendRequest(connectionId, endpoints_1.ENDPOINTS.OBJECTS.BULK_DELETE, {
57
57
  method: 'DELETE',
58
58
  body: JSON.stringify({ entityType: objectType, entityIds: externalIds })
59
- }, connectionId);
59
+ });
60
60
  return {
61
61
  success: true
62
62
  };
@@ -69,13 +69,13 @@ class TeamWorkGraphClient {
69
69
  const { properties, objectType, connectionId } = request;
70
70
  (0, validators_1.validateDeleteObjectsByPropertiesRequest)(properties, objectType);
71
71
  try {
72
- await this.sendRequest(endpoints_1.ENDPOINTS.OBJECTS.DELETE_BY_PROPERTIES, {
72
+ await this.sendRequest(connectionId, endpoints_1.ENDPOINTS.OBJECTS.DELETE_BY_PROPERTIES, {
73
73
  method: 'DELETE',
74
74
  body: JSON.stringify({
75
75
  properties,
76
76
  entityType: objectType
77
77
  })
78
- }, connectionId);
78
+ });
79
79
  return {
80
80
  success: true
81
81
  };
@@ -88,10 +88,10 @@ class TeamWorkGraphClient {
88
88
  const { groups, connectionId } = request;
89
89
  (0, validators_1.validateSetGroupsRequest)(groups);
90
90
  try {
91
- const response = await this.sendRequest(endpoints_1.ENDPOINTS.GROUPS.BULK, {
91
+ const response = await this.sendRequest(connectionId, endpoints_1.ENDPOINTS.GROUPS.BULK, {
92
92
  method: 'POST',
93
93
  body: JSON.stringify({ groups })
94
- }, connectionId);
94
+ });
95
95
  return {
96
96
  success: true,
97
97
  results: {
@@ -108,10 +108,10 @@ class TeamWorkGraphClient {
108
108
  const { externalIds, connectionId } = request;
109
109
  (0, validators_1.validateDeleteGroupsByExternalIdRequest)(externalIds);
110
110
  try {
111
- const response = await this.sendRequest(endpoints_1.ENDPOINTS.GROUPS.DELETE, {
111
+ const response = await this.sendRequest(connectionId, endpoints_1.ENDPOINTS.GROUPS.DELETE, {
112
112
  method: 'DELETE',
113
113
  body: JSON.stringify({ externalIds })
114
- }, connectionId);
114
+ });
115
115
  return {
116
116
  success: true,
117
117
  results: response.results || []
@@ -126,9 +126,9 @@ class TeamWorkGraphClient {
126
126
  (0, validators_1.validateGetGroupByExternalIdRequest)(externalId);
127
127
  try {
128
128
  const path = `${endpoints_1.ENDPOINTS.GROUPS.GET_BY_EXTERNAL_ID}/${encodeURIComponent(externalId)}`;
129
- const response = await this.sendRequest(path, {
129
+ const response = await this.sendRequest(connectionId, path, {
130
130
  method: 'GET'
131
- }, connectionId);
131
+ });
132
132
  return {
133
133
  success: true,
134
134
  group: response
@@ -142,10 +142,10 @@ class TeamWorkGraphClient {
142
142
  const { users, connectionId } = request;
143
143
  (0, validators_1.validateSetUsersRequest)(users);
144
144
  try {
145
- const response = await this.sendRequest(endpoints_1.ENDPOINTS.USERS.BULK, {
145
+ const response = await this.sendRequest(connectionId, endpoints_1.ENDPOINTS.USERS.BULK, {
146
146
  method: 'POST',
147
147
  body: JSON.stringify({ users })
148
- }, connectionId);
148
+ });
149
149
  return {
150
150
  success: true,
151
151
  results: {
@@ -162,10 +162,10 @@ class TeamWorkGraphClient {
162
162
  const { externalIds, connectionId } = request;
163
163
  (0, validators_1.validateDeleteUsersByExternalIdRequest)(externalIds);
164
164
  try {
165
- const response = await this.sendRequest(endpoints_1.ENDPOINTS.USERS.DELETE, {
165
+ const response = await this.sendRequest(connectionId, endpoints_1.ENDPOINTS.USERS.DELETE, {
166
166
  method: 'DELETE',
167
167
  body: JSON.stringify({ externalIds })
168
- }, connectionId);
168
+ });
169
169
  return {
170
170
  success: true,
171
171
  results: response.results || []
@@ -180,9 +180,9 @@ class TeamWorkGraphClient {
180
180
  (0, validators_1.validateGetUserByExternalIdRequest)(externalId);
181
181
  try {
182
182
  const path = `${endpoints_1.ENDPOINTS.USERS.GET_BY_EXTERNAL_ID}/${encodeURIComponent(externalId)}`;
183
- const response = await this.sendRequest(path, {
183
+ const response = await this.sendRequest(connectionId, path, {
184
184
  method: 'GET'
185
- }, connectionId);
185
+ });
186
186
  return {
187
187
  success: true,
188
188
  user: response
@@ -196,10 +196,10 @@ class TeamWorkGraphClient {
196
196
  const { directMappings, connectionId } = request;
197
197
  (0, validators_1.validateMapUsersRequest)(directMappings);
198
198
  try {
199
- const response = await this.sendRequest(endpoints_1.ENDPOINTS.USERS.MAPPINGS, {
199
+ const response = await this.sendRequest(connectionId, endpoints_1.ENDPOINTS.USERS.MAPPINGS, {
200
200
  method: 'POST',
201
201
  body: JSON.stringify({ directMappings })
202
- }, connectionId);
202
+ });
203
203
  return {
204
204
  success: true,
205
205
  results: {
@@ -216,14 +216,14 @@ class TeamWorkGraphClient {
216
216
  const { scheduleInterval, task, connectionId } = request;
217
217
  (0, validators_1.validateTaskScheduleRequest)(connectionId, scheduleInterval, task);
218
218
  try {
219
- const response = await this.sendRequest(endpoints_1.ENDPOINTS.ORCHESTRATION.TASK_SCHEDULE, {
219
+ const response = await this.sendRequest(connectionId, endpoints_1.ENDPOINTS.ORCHESTRATION.TASK_SCHEDULE, {
220
220
  method: 'PUT',
221
221
  body: JSON.stringify({
222
222
  connectionId,
223
223
  scheduleInterval,
224
224
  task
225
225
  })
226
- }, connectionId);
226
+ });
227
227
  return {
228
228
  status: response.status || 'ACCEPTED',
229
229
  message: response.message || 'Task scheduled successfully',
@@ -239,13 +239,13 @@ class TeamWorkGraphClient {
239
239
  (0, validators_1.validateChildTaskScheduleRequest)(connectionId, task);
240
240
  try {
241
241
  const endpoint = endpoints_1.ENDPOINTS.ORCHESTRATION.CHILD_TASK_SCHEDULE.replace('{scanId}', scanId).replace('{taskExecutionId}', taskExecutionId);
242
- const response = await this.sendRequest(endpoint, {
242
+ const response = await this.sendRequest(connectionId, endpoint, {
243
243
  method: 'POST',
244
244
  body: JSON.stringify({
245
245
  connectionId,
246
246
  task
247
247
  })
248
- }, connectionId);
248
+ });
249
249
  return {
250
250
  status: response.status || 'ACCEPTED',
251
251
  message: response.message || 'Child task scheduled successfully'
@@ -260,7 +260,7 @@ class TeamWorkGraphClient {
260
260
  (0, validators_1.validateTaskStatusUpdateRequest)(connectionId, status, task, failureReason);
261
261
  const endpoint = endpoints_1.ENDPOINTS.ORCHESTRATION.TASK_STATUS_UPDATE.replace('{scanId}', scanId).replace('{taskExecutionId}', taskExecutionId);
262
262
  try {
263
- const response = await this.sendRequest(endpoint, {
263
+ const response = await this.sendRequest(connectionId, endpoint, {
264
264
  method: 'POST',
265
265
  body: JSON.stringify({
266
266
  connectionId,
@@ -268,7 +268,7 @@ class TeamWorkGraphClient {
268
268
  task,
269
269
  failureReason
270
270
  })
271
- }, connectionId);
271
+ });
272
272
  return {
273
273
  status: response.status || 'ACCEPTED',
274
274
  message: response.message || 'Task status updated successfully'
@@ -278,16 +278,14 @@ class TeamWorkGraphClient {
278
278
  return (0, error_handling_1.handleError)(error, 'update task status');
279
279
  }
280
280
  };
281
- async sendRequest(path, options, connectionId) {
281
+ async sendRequest(connectionId, path, options) {
282
282
  try {
283
283
  const reqPath = (0, endpoints_1.getFullPath)(path);
284
284
  const headers = {
285
285
  ...options?.headers,
286
- 'Content-Type': 'application/json'
286
+ 'Content-Type': 'application/json',
287
+ 'Atl-Connection-Id': connectionId
287
288
  };
288
- if (connectionId) {
289
- headers['Atl-Connection-Id'] = connectionId;
290
- }
291
289
  const response = await (0, api_1.__fetchProduct)({ provider: 'app', remote: 'stargate', type: 'fpp' })(reqPath, {
292
290
  ...options,
293
291
  redirect: 'follow',