@forge/teamwork-graph 2.1.0 → 2.2.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const api_1 = require("@forge/api");
4
4
  const graph_1 = require("../graph");
5
+ const endpoints_1 = require("../utils/endpoints");
5
6
  const validators_1 = require("../utils/validators");
6
7
  jest.mock('@forge/api');
7
8
  describe('TeamWorkGraphClient - setObjects', () => {
@@ -96,7 +97,7 @@ describe('TeamWorkGraphClient - setObjects', () => {
96
97
  json: () => Promise.resolve(expected)
97
98
  });
98
99
  const result = await graphClient.setObjects(req);
99
- expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
100
+ expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.ENTITIES.BULK), expect.objectContaining({ method: 'POST' }));
100
101
  expect(result).toEqual(expected);
101
102
  });
102
103
  it('posts message entities to /api/v1/entities/bulk and returns response', async () => {
@@ -147,7 +148,7 @@ describe('TeamWorkGraphClient - setObjects', () => {
147
148
  json: () => Promise.resolve(expected)
148
149
  });
149
150
  const result = await graphClient.setObjects(req);
150
- expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
151
+ expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.ENTITIES.BULK), expect.objectContaining({ method: 'POST' }));
151
152
  expect(result).toEqual(expected);
152
153
  });
153
154
  it('posts organisation entities to /api/v1/entities/bulk and returns response', async () => {
@@ -187,7 +188,7 @@ describe('TeamWorkGraphClient - setObjects', () => {
187
188
  json: () => Promise.resolve(expected)
188
189
  });
189
190
  const result = await graphClient.setObjects(req);
190
- expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
191
+ expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.ENTITIES.BULK), expect.objectContaining({ method: 'POST' }));
191
192
  expect(result).toEqual(expected);
192
193
  });
193
194
  it('throws if objects is not an array', async () => {
@@ -229,10 +230,14 @@ describe('TeamWorkGraphClient - getObjectByExternalId', () => {
229
230
  objectType: 'atlassian:document',
230
231
  externalId: 'pipelines/123/builds/456'
231
232
  });
232
- expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities?entityType=atlassian%3Adocument&externalId=pipelines%2F123%2Fbuilds%2F456', {
233
- method: 'GET',
233
+ expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.ENTITIES.GET_BY_EXTERNAL_ID), {
234
+ method: 'POST',
234
235
  redirect: 'follow',
235
- headers: { 'Content-Type': 'application/json' }
236
+ headers: { 'Content-Type': 'application/json' },
237
+ body: JSON.stringify({
238
+ entityType: 'atlassian:document',
239
+ entityIds: ['pipelines/123/builds/456']
240
+ })
236
241
  });
237
242
  expect(result).toEqual({
238
243
  success: true,
@@ -301,7 +306,7 @@ describe('TeamWorkGraphClient - deleteObjectsByExternalId', () => {
301
306
  objectType: 'atlassian:document',
302
307
  externalIds: ['pipelines/123/builds/456', 'pipelines/123/builds/789']
303
308
  });
304
- expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk/delete', {
309
+ expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.ENTITIES.BULK_DELETE), {
305
310
  method: 'DELETE',
306
311
  body: JSON.stringify({
307
312
  entityType: 'atlassian:document',
@@ -363,7 +368,7 @@ describe('TeamWorkGraphClient - deleteObjectsByProperties', () => {
363
368
  environment: 'staging',
364
369
  status: 'failed'
365
370
  });
366
- expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk/delete-by-properties', {
371
+ expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.ENTITIES.DELETE_BY_PROPERTIES), {
367
372
  method: 'DELETE',
368
373
  body: JSON.stringify({
369
374
  environment: 'staging',
@@ -390,7 +395,7 @@ describe('TeamWorkGraphClient - deleteObjectsByProperties', () => {
390
395
  team: 'backend',
391
396
  region: 'us-east-1'
392
397
  });
393
- expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk/delete-by-properties', {
398
+ expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.ENTITIES.DELETE_BY_PROPERTIES), {
394
399
  method: 'DELETE',
395
400
  body: JSON.stringify({
396
401
  environment: 'production',
@@ -444,7 +449,7 @@ describe('TeamWorkGraphClient - deleteObjectsByProperties', () => {
444
449
  json: () => Promise.resolve(expected)
445
450
  });
446
451
  const result = await graphClient.setObjects(req);
447
- expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
452
+ expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.ENTITIES.BULK), expect.objectContaining({ method: 'POST' }));
448
453
  expect(result).toEqual(expected);
449
454
  });
450
455
  it('posts commit entities to /api/v1/entities/bulk and returns response', async () => {
@@ -490,7 +495,7 @@ describe('TeamWorkGraphClient - deleteObjectsByProperties', () => {
490
495
  json: () => Promise.resolve(expected)
491
496
  });
492
497
  const result = await graphClient.setObjects(req);
493
- expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
498
+ expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.ENTITIES.BULK), expect.objectContaining({ method: 'POST' }));
494
499
  expect(result).toEqual(expected);
495
500
  });
496
501
  it('posts build entities to /api/v1/entities/bulk and returns response', async () => {
@@ -548,7 +553,7 @@ describe('TeamWorkGraphClient - deleteObjectsByProperties', () => {
548
553
  json: () => Promise.resolve(expected)
549
554
  });
550
555
  const result = await graphClient.setObjects(req);
551
- expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
556
+ expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.ENTITIES.BULK), expect.objectContaining({ method: 'POST' }));
552
557
  expect(result).toEqual(expected);
553
558
  });
554
559
  it('posts calendar event entities to /api/v1/entities/bulk and returns response', async () => {
@@ -621,7 +626,7 @@ describe('TeamWorkGraphClient - deleteObjectsByProperties', () => {
621
626
  json: () => Promise.resolve(expected)
622
627
  });
623
628
  const result = await graphClient.setObjects(req);
624
- expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
629
+ expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.ENTITIES.BULK), expect.objectContaining({ method: 'POST' }));
625
630
  expect(result).toEqual(expected);
626
631
  });
627
632
  it('posts comment entities to /api/v1/entities/bulk and returns response', async () => {
@@ -668,7 +673,7 @@ describe('TeamWorkGraphClient - deleteObjectsByProperties', () => {
668
673
  json: () => Promise.resolve(expected)
669
674
  });
670
675
  const result = await graphClient.setObjects(req);
671
- expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
676
+ expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.ENTITIES.BULK), expect.objectContaining({ method: 'POST' }));
672
677
  expect(result).toEqual(expected);
673
678
  });
674
679
  it('posts conversation entities to /api/v1/entities/bulk and returns response', async () => {
@@ -734,7 +739,7 @@ describe('TeamWorkGraphClient - deleteObjectsByProperties', () => {
734
739
  json: () => Promise.resolve(expected)
735
740
  });
736
741
  const result = await graphClient.setObjects(req);
737
- expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
742
+ expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.ENTITIES.BULK), expect.objectContaining({ method: 'POST' }));
738
743
  expect(result).toEqual(expected);
739
744
  });
740
745
  it('posts customer org entities to /api/v1/entities/bulk and returns response', async () => {
@@ -809,7 +814,7 @@ describe('TeamWorkGraphClient - deleteObjectsByProperties', () => {
809
814
  json: () => Promise.resolve(expected)
810
815
  });
811
816
  const result = await graphClient.setObjects(req);
812
- expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
817
+ expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.ENTITIES.BULK), expect.objectContaining({ method: 'POST' }));
813
818
  expect(result).toEqual(expected);
814
819
  });
815
820
  it('posts deal entities to /api/v1/entities/bulk and returns response', async () => {
@@ -884,7 +889,7 @@ describe('TeamWorkGraphClient - deleteObjectsByProperties', () => {
884
889
  json: () => Promise.resolve(expected)
885
890
  });
886
891
  const result = await graphClient.setObjects(req);
887
- expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
892
+ expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.ENTITIES.BULK), expect.objectContaining({ method: 'POST' }));
888
893
  expect(result).toEqual(expected);
889
894
  });
890
895
  it('posts deployment entities to /api/v1/entities/bulk and returns response', async () => {
@@ -955,7 +960,7 @@ describe('TeamWorkGraphClient - deleteObjectsByProperties', () => {
955
960
  json: () => Promise.resolve(expected)
956
961
  });
957
962
  const result = await graphClient.setObjects(req);
958
- expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
963
+ expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.ENTITIES.BULK), expect.objectContaining({ method: 'POST' }));
959
964
  expect(result).toEqual(expected);
960
965
  });
961
966
  it('posts design entities to /api/v1/entities/bulk and returns response', async () => {
@@ -996,7 +1001,7 @@ describe('TeamWorkGraphClient - deleteObjectsByProperties', () => {
996
1001
  json: () => Promise.resolve(expected)
997
1002
  });
998
1003
  const result = await graphClient.setObjects(req);
999
- expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
1004
+ expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.ENTITIES.BULK), expect.objectContaining({ method: 'POST' }));
1000
1005
  expect(result).toEqual(expected);
1001
1006
  });
1002
1007
  it('posts position entities to /api/v1/entities/bulk and returns response', async () => {
@@ -1048,7 +1053,7 @@ describe('TeamWorkGraphClient - deleteObjectsByProperties', () => {
1048
1053
  json: () => Promise.resolve(expected)
1049
1054
  });
1050
1055
  const result = await graphClient.setObjects(req);
1051
- expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
1056
+ expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.ENTITIES.BULK), expect.objectContaining({ method: 'POST' }));
1052
1057
  expect(result).toEqual(expected);
1053
1058
  });
1054
1059
  it('posts project entities to /api/v1/entities/bulk and returns response', async () => {
@@ -1129,7 +1134,7 @@ describe('TeamWorkGraphClient - deleteObjectsByProperties', () => {
1129
1134
  json: () => Promise.resolve(expected)
1130
1135
  });
1131
1136
  const result = await graphClient.setObjects(req);
1132
- expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
1137
+ expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.ENTITIES.BULK), expect.objectContaining({ method: 'POST' }));
1133
1138
  expect(result).toEqual(expected);
1134
1139
  });
1135
1140
  it('posts pull request entities to /api/v1/entities/bulk and returns response', async () => {
@@ -1211,7 +1216,7 @@ describe('TeamWorkGraphClient - deleteObjectsByProperties', () => {
1211
1216
  json: () => Promise.resolve(expected)
1212
1217
  });
1213
1218
  const result = await graphClient.setObjects(req);
1214
- expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
1219
+ expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.ENTITIES.BULK), expect.objectContaining({ method: 'POST' }));
1215
1220
  expect(result).toEqual(expected);
1216
1221
  });
1217
1222
  it('posts remote link entities to /api/v1/entities/bulk and returns response', async () => {
@@ -1277,7 +1282,7 @@ describe('TeamWorkGraphClient - deleteObjectsByProperties', () => {
1277
1282
  json: () => Promise.resolve(expected)
1278
1283
  });
1279
1284
  const result = await graphClient.setObjects(req);
1280
- expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
1285
+ expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.ENTITIES.BULK), expect.objectContaining({ method: 'POST' }));
1281
1286
  expect(result).toEqual(expected);
1282
1287
  });
1283
1288
  it('posts repository entities to /api/v1/entities/bulk and returns response', async () => {
@@ -1316,7 +1321,7 @@ describe('TeamWorkGraphClient - deleteObjectsByProperties', () => {
1316
1321
  json: () => Promise.resolve(expected)
1317
1322
  });
1318
1323
  const result = await graphClient.setObjects(req);
1319
- expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
1324
+ expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.ENTITIES.BULK), expect.objectContaining({ method: 'POST' }));
1320
1325
  expect(result).toEqual(expected);
1321
1326
  });
1322
1327
  it('posts software service entities to /api/v1/entities/bulk and returns response', async () => {
@@ -1364,7 +1369,7 @@ describe('TeamWorkGraphClient - deleteObjectsByProperties', () => {
1364
1369
  json: () => Promise.resolve(expected)
1365
1370
  });
1366
1371
  const result = await graphClient.setObjects(req);
1367
- expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
1372
+ expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.ENTITIES.BULK), expect.objectContaining({ method: 'POST' }));
1368
1373
  expect(result).toEqual(expected);
1369
1374
  });
1370
1375
  it('posts space entities to /api/v1/entities/bulk and returns response', async () => {
@@ -1409,7 +1414,7 @@ describe('TeamWorkGraphClient - deleteObjectsByProperties', () => {
1409
1414
  json: () => Promise.resolve(expected)
1410
1415
  });
1411
1416
  const result = await graphClient.setObjects(req);
1412
- expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
1417
+ expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.ENTITIES.BULK), expect.objectContaining({ method: 'POST' }));
1413
1418
  expect(result).toEqual(expected);
1414
1419
  });
1415
1420
  it('posts video entities to /api/v1/entities/bulk and returns response', async () => {
@@ -1526,7 +1531,7 @@ describe('TeamWorkGraphClient - deleteObjectsByProperties', () => {
1526
1531
  json: () => Promise.resolve(expected)
1527
1532
  });
1528
1533
  const result = await graphClient.setObjects(req);
1529
- expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
1534
+ expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.ENTITIES.BULK), expect.objectContaining({ method: 'POST' }));
1530
1535
  expect(result).toEqual(expected);
1531
1536
  });
1532
1537
  it('posts work item entities to /api/v1/entities/bulk and returns response', async () => {
@@ -1622,7 +1627,7 @@ describe('TeamWorkGraphClient - deleteObjectsByProperties', () => {
1622
1627
  json: () => Promise.resolve(expected)
1623
1628
  });
1624
1629
  const result = await graphClient.setObjects(req);
1625
- expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
1630
+ expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.ENTITIES.BULK), expect.objectContaining({ method: 'POST' }));
1626
1631
  expect(result).toEqual(expected);
1627
1632
  });
1628
1633
  it('posts worker entities to /api/v1/entities/bulk and returns response', async () => {
@@ -1669,7 +1674,7 @@ describe('TeamWorkGraphClient - deleteObjectsByProperties', () => {
1669
1674
  json: () => Promise.resolve(expected)
1670
1675
  });
1671
1676
  const result = await graphClient.setObjects(req);
1672
- expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/entities/bulk', expect.objectContaining({ method: 'POST' }));
1677
+ expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.ENTITIES.BULK), expect.objectContaining({ method: 'POST' }));
1673
1678
  expect(result).toEqual(expected);
1674
1679
  });
1675
1680
  });
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const api_1 = require("@forge/api");
4
4
  const graph_1 = require("../graph");
5
5
  const validators_1 = require("../utils/validators");
6
+ const endpoints_1 = require("../utils/endpoints");
6
7
  jest.mock('@forge/api');
7
8
  describe('TeamWorkGraphClient - Group Operations', () => {
8
9
  let graphClient;
@@ -45,7 +46,7 @@ describe('TeamWorkGraphClient - Group Operations', () => {
45
46
  const result = await graphClient.setGroups({
46
47
  groups: [groupPayload]
47
48
  });
48
- expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/groups/bulk', {
49
+ expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.GROUPS.BULK), {
49
50
  method: 'POST',
50
51
  body: JSON.stringify({ groups: [groupPayload] }),
51
52
  redirect: 'follow',
@@ -74,7 +75,7 @@ describe('TeamWorkGraphClient - Group Operations', () => {
74
75
  const result = await graphClient.setGroups({
75
76
  groups: [groupWithoutMembers]
76
77
  });
77
- expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/groups/bulk', {
78
+ expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.GROUPS.BULK), {
78
79
  method: 'POST',
79
80
  body: JSON.stringify({ groups: [groupWithoutMembers] }),
80
81
  redirect: 'follow',
@@ -115,8 +116,8 @@ describe('TeamWorkGraphClient - Group Operations', () => {
115
116
  const result = await graphClient.deleteGroupsByExternalId({
116
117
  externalIds: ['developers', 'admins']
117
118
  });
118
- expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/groups/bulk/delete', {
119
- method: 'POST',
119
+ expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.GROUPS.DELETE), {
120
+ method: 'DELETE',
120
121
  body: JSON.stringify({ externalIds: ['developers', 'admins'] }),
121
122
  redirect: 'follow',
122
123
  headers: { 'Content-Type': 'application/json' }
@@ -164,7 +165,7 @@ describe('TeamWorkGraphClient - Group Operations', () => {
164
165
  const result = await graphClient.getGroupByExternalId({
165
166
  externalId: 'developers'
166
167
  });
167
- expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/groups?externalId=developers', {
168
+ expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.GROUPS.GET_BY_EXTERNAL_ID) + '?id=developers', {
168
169
  method: 'GET',
169
170
  redirect: 'follow',
170
171
  headers: { 'Content-Type': 'application/json' }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const api_1 = require("@forge/api");
4
4
  const graph_1 = require("../graph");
5
5
  const validators_1 = require("../utils/validators");
6
+ const endpoints_1 = require("../utils/endpoints");
6
7
  jest.mock('@forge/api');
7
8
  describe('TeamWorkGraphClient - User Operations', () => {
8
9
  let graphClient;
@@ -53,7 +54,7 @@ describe('TeamWorkGraphClient - User Operations', () => {
53
54
  const result = await graphClient.setUsers({
54
55
  users: [userPayload]
55
56
  });
56
- expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/users/bulk', {
57
+ expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.USERS.BULK), {
57
58
  method: 'POST',
58
59
  body: JSON.stringify({ users: [userPayload] }),
59
60
  redirect: 'follow',
@@ -94,8 +95,8 @@ describe('TeamWorkGraphClient - User Operations', () => {
94
95
  const result = await graphClient.deleteUsersByExternalId({
95
96
  externalIds: ['user-123', 'user-456']
96
97
  });
97
- expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/users/bulk/delete', {
98
- method: 'POST',
98
+ expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.USERS.DELETE), {
99
+ method: 'DELETE',
99
100
  body: JSON.stringify({ externalIds: ['user-123', 'user-456'] }),
100
101
  redirect: 'follow',
101
102
  headers: { 'Content-Type': 'application/json' }
@@ -147,7 +148,7 @@ describe('TeamWorkGraphClient - User Operations', () => {
147
148
  const result = await graphClient.getUserByExternalId({
148
149
  externalId: 'user-123'
149
150
  });
150
- expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/users?externalId=user-123', {
151
+ expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.USERS.GET_BY_EXTERNAL_ID) + '?id=user-123', {
151
152
  method: 'GET',
152
153
  redirect: 'follow',
153
154
  headers: { 'Content-Type': 'application/json' }
@@ -211,7 +212,7 @@ describe('TeamWorkGraphClient - User Operations', () => {
211
212
  const result = await graphClient.mapUsers({
212
213
  directMappings: [mappingWithAccountId]
213
214
  });
214
- expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/users/mappings', {
215
+ expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.USERS.MAPPINGS), {
215
216
  method: 'POST',
216
217
  body: JSON.stringify({ directMappings: [mappingWithAccountId] }),
217
218
  redirect: 'follow',
@@ -231,7 +232,7 @@ describe('TeamWorkGraphClient - User Operations', () => {
231
232
  const result = await graphClient.mapUsers({
232
233
  directMappings: [mappingWithEmail]
233
234
  });
234
- expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/users/mappings', {
235
+ expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.USERS.MAPPINGS), {
235
236
  method: 'POST',
236
237
  body: JSON.stringify({ directMappings: [mappingWithEmail] }),
237
238
  redirect: 'follow',
@@ -254,7 +255,7 @@ describe('TeamWorkGraphClient - User Operations', () => {
254
255
  const result = await graphClient.mapUsers({
255
256
  directMappings: [mappingWithAccountId, mappingWithEmail]
256
257
  });
257
- expect(mockFetch).toHaveBeenCalledWith('/graph/connector/api/v1/users/mappings', {
258
+ expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.USERS.MAPPINGS), {
258
259
  method: 'POST',
259
260
  body: JSON.stringify({ directMappings: [mappingWithAccountId, mappingWithEmail] }),
260
261
  redirect: 'follow',
@@ -1 +1 @@
1
- {"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../src/graph.ts"],"names":[],"mappings":"AAuBA,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,8BAA8B,EAC9B,+BAA+B,EAC/B,0BAA0B,EAC1B,2BAA2B,EAC3B,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,+BAA+B,EAC/B,gCAAgC,EAChC,2BAA2B,EAC3B,4BAA4B,EAC5B,4BAA4B,EAC5B,6BAA6B,EA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AAC"}
package/out/graph.js CHANGED
@@ -4,14 +4,14 @@ exports.teamworkgraph = exports.TeamWorkGraphClient = void 0;
4
4
  const api_1 = require("@forge/api");
5
5
  const error_handling_1 = require("./utils/error-handling");
6
6
  const validators_1 = require("./utils/validators");
7
+ const endpoints_1 = require("./utils/endpoints");
7
8
  const errors_1 = require("./utils/errors");
8
- const STARGATE_BASE = '/graph/connector';
9
9
  class TeamWorkGraphClient {
10
10
  setObjects = async (request) => {
11
11
  const { objects } = request;
12
12
  (0, validators_1.validateSetObjectsRequest)(objects);
13
13
  try {
14
- const response = await this.sendRequest('/api/v1/entities/bulk', {
14
+ const response = await this.sendRequest(endpoints_1.ENDPOINTS.ENTITIES.BULK, {
15
15
  method: 'POST',
16
16
  body: JSON.stringify({ entities: objects })
17
17
  });
@@ -25,12 +25,13 @@ class TeamWorkGraphClient {
25
25
  const { objectType, externalId } = request;
26
26
  (0, validators_1.validateGetObjectByExternalIdRequest)(objectType, externalId);
27
27
  try {
28
- const url = new URL('/api/v1/entities', 'https://teamwork-graph.atlassian.net/api');
29
- url.searchParams.set('entityType', objectType);
30
- url.searchParams.set('externalId', externalId);
31
- const path = url.pathname + url.search;
28
+ const path = endpoints_1.ENDPOINTS.ENTITIES.GET_BY_EXTERNAL_ID;
32
29
  const response = await this.sendRequest(path, {
33
- method: 'GET'
30
+ method: 'POST',
31
+ body: JSON.stringify({
32
+ entityType: objectType,
33
+ entityIds: [externalId]
34
+ })
34
35
  });
35
36
  return {
36
37
  success: true,
@@ -45,7 +46,7 @@ class TeamWorkGraphClient {
45
46
  const { objectType, externalIds } = request;
46
47
  (0, validators_1.validateDeleteObjectsByExternalIdRequest)(objectType, externalIds);
47
48
  try {
48
- const response = await this.sendRequest('/api/v1/entities/bulk/delete', {
49
+ const response = await this.sendRequest(endpoints_1.ENDPOINTS.ENTITIES.BULK_DELETE, {
49
50
  method: 'DELETE',
50
51
  body: JSON.stringify({ entityType: objectType, externalIds })
51
52
  });
@@ -58,7 +59,7 @@ class TeamWorkGraphClient {
58
59
  deleteObjectsByProperties = async (request) => {
59
60
  (0, validators_1.validateDeleteObjectsByPropertiesRequest)(request);
60
61
  try {
61
- const response = await this.sendRequest('/api/v1/entities/bulk/delete-by-properties', {
62
+ const response = await this.sendRequest(endpoints_1.ENDPOINTS.ENTITIES.DELETE_BY_PROPERTIES, {
62
63
  method: 'DELETE',
63
64
  body: JSON.stringify(request)
64
65
  });
@@ -72,7 +73,7 @@ class TeamWorkGraphClient {
72
73
  const { groups } = request;
73
74
  (0, validators_1.validateSetGroupsRequest)(groups);
74
75
  try {
75
- const response = await this.sendRequest('/api/v1/groups/bulk', {
76
+ const response = await this.sendRequest(endpoints_1.ENDPOINTS.GROUPS.BULK, {
76
77
  method: 'POST',
77
78
  body: JSON.stringify({ groups })
78
79
  });
@@ -86,8 +87,8 @@ class TeamWorkGraphClient {
86
87
  const { externalIds } = request;
87
88
  (0, validators_1.validateDeleteGroupsByExternalIdRequest)(externalIds);
88
89
  try {
89
- const response = await this.sendRequest('/api/v1/groups/bulk/delete', {
90
- method: 'POST',
90
+ const response = await this.sendRequest(endpoints_1.ENDPOINTS.GROUPS.DELETE, {
91
+ method: 'DELETE',
91
92
  body: JSON.stringify({ externalIds })
92
93
  });
93
94
  return response;
@@ -100,9 +101,7 @@ class TeamWorkGraphClient {
100
101
  const { externalId } = request;
101
102
  (0, validators_1.validateGetGroupByExternalIdRequest)(externalId);
102
103
  try {
103
- const url = new URL('/api/v1/groups', 'https://teamwork-graph.atlassian.net/api');
104
- url.searchParams.set('externalId', externalId);
105
- const path = url.pathname + url.search;
104
+ const path = `${endpoints_1.ENDPOINTS.GROUPS.GET_BY_EXTERNAL_ID}?id=${encodeURIComponent(externalId)}`;
106
105
  const response = await this.sendRequest(path, {
107
106
  method: 'GET'
108
107
  });
@@ -119,7 +118,7 @@ class TeamWorkGraphClient {
119
118
  const { users } = request;
120
119
  (0, validators_1.validateSetUsersRequest)(users);
121
120
  try {
122
- const response = await this.sendRequest('/api/v1/users/bulk', {
121
+ const response = await this.sendRequest(endpoints_1.ENDPOINTS.USERS.BULK, {
123
122
  method: 'POST',
124
123
  body: JSON.stringify({ users })
125
124
  });
@@ -133,8 +132,8 @@ class TeamWorkGraphClient {
133
132
  const { externalIds } = request;
134
133
  (0, validators_1.validateDeleteUsersByExternalIdRequest)(externalIds);
135
134
  try {
136
- const response = await this.sendRequest('/api/v1/users/bulk/delete', {
137
- method: 'POST',
135
+ const response = await this.sendRequest(endpoints_1.ENDPOINTS.USERS.DELETE, {
136
+ method: 'DELETE',
138
137
  body: JSON.stringify({ externalIds })
139
138
  });
140
139
  return response;
@@ -147,9 +146,7 @@ class TeamWorkGraphClient {
147
146
  const { externalId } = request;
148
147
  (0, validators_1.validateGetUserByExternalIdRequest)(externalId);
149
148
  try {
150
- const url = new URL('/api/v1/users', 'https://teamwork-graph.atlassian.net/api');
151
- url.searchParams.set('externalId', externalId);
152
- const path = url.pathname + url.search;
149
+ const path = `${endpoints_1.ENDPOINTS.USERS.GET_BY_EXTERNAL_ID}?id=${encodeURIComponent(externalId)}`;
153
150
  const response = await this.sendRequest(path, {
154
151
  method: 'GET'
155
152
  });
@@ -166,7 +163,7 @@ class TeamWorkGraphClient {
166
163
  const { directMappings } = request;
167
164
  (0, validators_1.validateMapUsersRequest)(directMappings);
168
165
  try {
169
- const response = await this.sendRequest('/api/v1/users/mappings', {
166
+ const response = await this.sendRequest(endpoints_1.ENDPOINTS.USERS.MAPPINGS, {
170
167
  method: 'POST',
171
168
  body: JSON.stringify({ directMappings })
172
169
  });
@@ -216,7 +213,7 @@ class TeamWorkGraphClient {
216
213
  };
217
214
  async sendRequest(path, options) {
218
215
  try {
219
- const reqPath = STARGATE_BASE + path;
216
+ const reqPath = (0, endpoints_1.getFullPath)(path);
220
217
  const response = await (0, api_1.__fetchProduct)({ provider: 'app', remote: 'stargate', type: 'fpp' })(reqPath, {
221
218
  ...options,
222
219
  redirect: 'follow',
@@ -0,0 +1,22 @@
1
+ export declare const ENDPOINTS: {
2
+ readonly ENTITIES: {
3
+ readonly BULK: "/entities";
4
+ readonly BULK_DELETE: "/entities/bulk";
5
+ readonly DELETE_BY_PROPERTIES: "/entities/bulkByProperty";
6
+ readonly GET_BY_EXTERNAL_ID: "/entities/query";
7
+ };
8
+ readonly GROUPS: {
9
+ readonly BULK: "/groups";
10
+ readonly DELETE: "/groups";
11
+ readonly GET_BY_EXTERNAL_ID: "/group";
12
+ };
13
+ readonly USERS: {
14
+ readonly BULK: "/users/bulk";
15
+ readonly DELETE: "/users/bulk";
16
+ readonly GET_BY_EXTERNAL_ID: "/users";
17
+ readonly MAPPINGS: "/usermappings";
18
+ };
19
+ };
20
+ export declare const STARGATE_BASE = "/graph/connector/{contextAri}";
21
+ export declare const getFullPath: (endpoint: string, stargateBase?: string) => string;
22
+ //# sourceMappingURL=endpoints.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoints.d.ts","sourceRoot":"","sources":["../../src/utils/endpoints.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;CAuBZ,CAAC;AAKX,eAAO,MAAM,aAAa,kCAAkC,CAAC;AAM7D,eAAO,MAAM,WAAW,aAAc,MAAM,iBAAgB,MAAM,KAAmB,MAEpF,CAAC"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getFullPath = exports.STARGATE_BASE = exports.ENDPOINTS = void 0;
4
+ exports.ENDPOINTS = {
5
+ ENTITIES: {
6
+ BULK: '/entities',
7
+ BULK_DELETE: '/entities/bulk',
8
+ DELETE_BY_PROPERTIES: '/entities/bulkByProperty',
9
+ GET_BY_EXTERNAL_ID: '/entities/query'
10
+ },
11
+ GROUPS: {
12
+ BULK: '/groups',
13
+ DELETE: '/groups',
14
+ GET_BY_EXTERNAL_ID: '/group'
15
+ },
16
+ USERS: {
17
+ BULK: '/users/bulk',
18
+ DELETE: '/users/bulk',
19
+ GET_BY_EXTERNAL_ID: '/users',
20
+ MAPPINGS: '/usermappings'
21
+ }
22
+ };
23
+ exports.STARGATE_BASE = '/graph/connector/{contextAri}';
24
+ const getFullPath = (endpoint, stargateBase = exports.STARGATE_BASE) => {
25
+ return `${stargateBase}${endpoint}`;
26
+ };
27
+ exports.getFullPath = getFullPath;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forge/teamwork-graph",
3
- "version": "2.1.0",
3
+ "version": "2.2.0-next.1",
4
4
  "description": "Forge TeamworkGraph SDK",
5
5
  "author": "Atlassian",
6
6
  "license": "UNLICENSED",
@@ -22,7 +22,7 @@
22
22
  "jest-when": "^3.6.0"
23
23
  },
24
24
  "dependencies": {
25
- "@forge/api": "^6.0.3"
25
+ "@forge/api": "^6.1.0-next.0"
26
26
  },
27
27
  "publishConfig": {
28
28
  "registry": "https://packages.atlassian.com/api/npm/npm-public/"