@forge/teamwork-graph 2.3.0-next.2 → 2.3.0-next.4
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 +1 -38
- package/out/__test__/entity-operations.test.js +28 -15
- package/out/__test__/error-handling.test.js +11 -7
- package/out/__test__/validators.test.js +9 -122
- package/out/graph.d.ts +1 -3
- package/out/graph.d.ts.map +1 -1
- package/out/graph.js +6 -40
- package/out/types/graph.d.ts +1 -3
- package/out/types/graph.d.ts.map +1 -1
- package/out/types/objects/common.d.ts +3 -2
- package/out/types/objects/common.d.ts.map +1 -1
- package/out/types/requests.d.ts +4 -25
- package/out/types/requests.d.ts.map +1 -1
- package/out/utils/error-handling.d.ts.map +1 -1
- package/out/utils/error-handling.js +1 -4
- package/out/utils/errors.d.ts +0 -6
- package/out/utils/errors.d.ts.map +1 -1
- package/out/utils/errors.js +1 -13
- package/out/utils/validators.d.ts +1 -3
- package/out/utils/validators.d.ts.map +1 -1
- package/out/utils/validators.js +3 -29
- package/package.json +1 -1
- package/out/__test__/graph-extended.test.d.ts +0 -2
- package/out/__test__/graph-extended.test.d.ts.map +0 -1
- package/out/__test__/graph-extended.test.js +0 -113
package/README.md
CHANGED
|
@@ -205,37 +205,6 @@ const deleteGroupsResult = await graph.deleteGroupsByExternalId({
|
|
|
205
205
|
});
|
|
206
206
|
```
|
|
207
207
|
|
|
208
|
-
### Data Operations
|
|
209
|
-
|
|
210
|
-
```typescript
|
|
211
|
-
import { graph } from '@forge/teamwork-graph';
|
|
212
|
-
|
|
213
|
-
// Fetch external data
|
|
214
|
-
const fetchResult = await graph.fetchData({
|
|
215
|
-
requestConfig: {
|
|
216
|
-
url: 'https://api.example.com/data',
|
|
217
|
-
method: 'GET',
|
|
218
|
-
headers: { 'Authorization': 'Bearer token' }
|
|
219
|
-
},
|
|
220
|
-
onResult: (data) => {
|
|
221
|
-
console.log('Data received:', data);
|
|
222
|
-
return data;
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
// Transform data
|
|
227
|
-
const transformResult = await graph.transformData({
|
|
228
|
-
data: { items: [{ id: 1, name: 'Item 1' }] },
|
|
229
|
-
transformMethod: (data) => {
|
|
230
|
-
return data.items.map(item => ({
|
|
231
|
-
id: `doc-${item.id}`,
|
|
232
|
-
displayName: item.name,
|
|
233
|
-
// Additional object properties would be added here
|
|
234
|
-
}));
|
|
235
|
-
}
|
|
236
|
-
});
|
|
237
|
-
```
|
|
238
|
-
|
|
239
208
|
## Error Handling
|
|
240
209
|
|
|
241
210
|
The SDK provides comprehensive error handling with consistent error responses and access to original error objects for debugging.
|
|
@@ -335,12 +304,6 @@ import type {
|
|
|
335
304
|
GetGroupByExternalIdRequest,
|
|
336
305
|
GetGroupByExternalIdResponse,
|
|
337
306
|
|
|
338
|
-
// Data operation types
|
|
339
|
-
FetchDataRequest,
|
|
340
|
-
FetchDataResponse,
|
|
341
|
-
TransformDataRequest,
|
|
342
|
-
TransformDataResponse,
|
|
343
|
-
|
|
344
307
|
// Common types
|
|
345
308
|
DeleteObjectsByExternalIdRequest,
|
|
346
309
|
DeleteObjectsByExternalIdResponse,
|
|
@@ -362,4 +325,4 @@ The SDK automatically handles authentication and configuration through the Forge
|
|
|
362
325
|
1. **Always check success flag**: Verify `result.success` before accessing response data
|
|
363
326
|
2. **Handle errors gracefully**: Use the `error` field for user-facing messages and `originalError` for debugging
|
|
364
327
|
3. **Validate input**: The SDK will throw validation errors for invalid input, so handle them appropriately
|
|
365
|
-
|
|
328
|
+
4. **Monitor rate limits**: The SDK handles rate limiting automatically, but monitor for `429` errors
|
|
@@ -137,7 +137,7 @@ describe('TeamWorkGraphClient - setObjects', () => {
|
|
|
137
137
|
containerKey: {
|
|
138
138
|
type: 'atlassian:conversation',
|
|
139
139
|
value: {
|
|
140
|
-
|
|
140
|
+
entityId: 'CFG3W7TKJ'
|
|
141
141
|
}
|
|
142
142
|
},
|
|
143
143
|
'atlassian:message': {
|
|
@@ -200,7 +200,7 @@ describe('TeamWorkGraphClient - setObjects', () => {
|
|
|
200
200
|
parentKey: {
|
|
201
201
|
type: 'atlassian:organisation',
|
|
202
202
|
value: {
|
|
203
|
-
|
|
203
|
+
entityId: 'id of the parent org of this org'
|
|
204
204
|
}
|
|
205
205
|
},
|
|
206
206
|
'atlassian:organisation': {}
|
|
@@ -399,12 +399,18 @@ describe('TeamWorkGraphClient - deleteObjectsByProperties', () => {
|
|
|
399
399
|
json: () => Promise.resolve(expectedResponse)
|
|
400
400
|
});
|
|
401
401
|
const result = await graphClient.deleteObjectsByProperties({
|
|
402
|
-
|
|
402
|
+
properties: {
|
|
403
|
+
environment: 'staging'
|
|
404
|
+
},
|
|
405
|
+
objectType: 'atlassian:document'
|
|
403
406
|
});
|
|
404
407
|
expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.OBJECTS.DELETE_BY_PROPERTIES), {
|
|
405
408
|
method: 'DELETE',
|
|
406
409
|
body: JSON.stringify({
|
|
407
|
-
|
|
410
|
+
properties: {
|
|
411
|
+
environment: 'staging'
|
|
412
|
+
},
|
|
413
|
+
entityType: 'atlassian:document'
|
|
408
414
|
}),
|
|
409
415
|
redirect: 'follow',
|
|
410
416
|
headers: { 'Content-Type': 'application/json' }
|
|
@@ -413,24 +419,30 @@ describe('TeamWorkGraphClient - deleteObjectsByProperties', () => {
|
|
|
413
419
|
});
|
|
414
420
|
it('should throw error when multiple properties are provided', async () => {
|
|
415
421
|
await expect(graphClient.deleteObjectsByProperties({
|
|
416
|
-
|
|
417
|
-
|
|
422
|
+
properties: {
|
|
423
|
+
environment: 'production',
|
|
424
|
+
status: 'completed'
|
|
425
|
+
},
|
|
426
|
+
objectType: 'atlassian:document'
|
|
418
427
|
})).rejects.toThrow('properties object must contain exactly 1 property');
|
|
419
428
|
});
|
|
420
429
|
it('should throw error when properties is missing', async () => {
|
|
421
|
-
await expect(graphClient.deleteObjectsByProperties(
|
|
430
|
+
await expect(graphClient.deleteObjectsByProperties({ properties: {}, objectType: 'atlassian:document' })).rejects.toThrow('properties object cannot be empty');
|
|
422
431
|
});
|
|
423
432
|
it('should throw error when properties is not an object', async () => {
|
|
424
|
-
await expect(graphClient.deleteObjectsByProperties('not-an-object')).rejects.toThrow('properties must be an object');
|
|
433
|
+
await expect(graphClient.deleteObjectsByProperties({ properties: 'not-an-object', objectType: 'atlassian:document' })).rejects.toThrow('properties must be an object');
|
|
425
434
|
});
|
|
426
435
|
it('should throw error when properties object is empty', async () => {
|
|
427
|
-
await expect(graphClient.deleteObjectsByProperties({})).rejects.toThrow('properties object cannot be empty');
|
|
436
|
+
await expect(graphClient.deleteObjectsByProperties({ properties: {}, objectType: 'atlassian:document' })).rejects.toThrow('properties object cannot be empty');
|
|
428
437
|
});
|
|
429
438
|
it('should throw error when multiple properties are provided', async () => {
|
|
430
439
|
await expect(graphClient.deleteObjectsByProperties({
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
440
|
+
properties: {
|
|
441
|
+
environment: 'production',
|
|
442
|
+
status: 'completed',
|
|
443
|
+
priority: 'high'
|
|
444
|
+
},
|
|
445
|
+
objectType: 'atlassian:document'
|
|
434
446
|
})).rejects.toThrow('properties object must contain exactly 1 property');
|
|
435
447
|
});
|
|
436
448
|
});
|
|
@@ -1170,10 +1182,11 @@ describe('TeamWorkGraphClient - bulk entities', () => {
|
|
|
1170
1182
|
parentKey: {
|
|
1171
1183
|
type: 'atlassian:organisation',
|
|
1172
1184
|
value: {
|
|
1173
|
-
|
|
1185
|
+
entityId: 'org-tech-company-123'
|
|
1174
1186
|
}
|
|
1175
1187
|
},
|
|
1176
1188
|
associations: {
|
|
1189
|
+
lastUpdatedAt: '2024-07-09T14:27:37.000Z',
|
|
1177
1190
|
set: [
|
|
1178
1191
|
{
|
|
1179
1192
|
associationType: 'atlassian:worker',
|
|
@@ -1314,7 +1327,7 @@ describe('TeamWorkGraphClient - bulk entities', () => {
|
|
|
1314
1327
|
containerKey: {
|
|
1315
1328
|
type: 'atlassian:repository',
|
|
1316
1329
|
value: {
|
|
1317
|
-
|
|
1330
|
+
entityId: 'repo-company-main-123'
|
|
1318
1331
|
}
|
|
1319
1332
|
},
|
|
1320
1333
|
lastUpdatedAt: '2024-07-09T14:27:37.000Z',
|
|
@@ -1783,7 +1796,7 @@ describe('TeamWorkGraphClient - bulk entities', () => {
|
|
|
1783
1796
|
containerKey: {
|
|
1784
1797
|
type: 'atlassian:space',
|
|
1785
1798
|
value: {
|
|
1786
|
-
|
|
1799
|
+
entityId: 'space-engineering-team-docs'
|
|
1787
1800
|
}
|
|
1788
1801
|
},
|
|
1789
1802
|
lastUpdatedAt: '2024-07-09T14:27:37.000Z',
|
|
@@ -12,6 +12,14 @@ describe('TeamWorkGraphClient - Error Handling Functions', () => {
|
|
|
12
12
|
expect(result.originalError).toBe(validationError);
|
|
13
13
|
expect(result.results).toBeUndefined();
|
|
14
14
|
});
|
|
15
|
+
test('should handle network errors correctly', () => {
|
|
16
|
+
const networkError = new errors_1.ForgeTeamWorkGraphNetworkError('Connection timeout');
|
|
17
|
+
const result = (0, error_handling_1.handleError)(networkError, 'set objects');
|
|
18
|
+
expect(result.success).toBe(false);
|
|
19
|
+
expect(result.error).toBe('Connection timeout');
|
|
20
|
+
expect(result.originalError).toBe(networkError);
|
|
21
|
+
expect(result.results).toBeUndefined();
|
|
22
|
+
});
|
|
15
23
|
test('should handle generic errors correctly', () => {
|
|
16
24
|
const genericError = new Error('Network timeout');
|
|
17
25
|
const result = (0, error_handling_1.handleError)(genericError, 'delete objects');
|
|
@@ -21,26 +29,22 @@ describe('TeamWorkGraphClient - Error Handling Functions', () => {
|
|
|
21
29
|
});
|
|
22
30
|
test('should handle unknown errors correctly', () => {
|
|
23
31
|
const unknownError = 'Something went wrong';
|
|
24
|
-
const result = (0, error_handling_1.handleError)(unknownError, '
|
|
32
|
+
const result = (0, error_handling_1.handleError)(unknownError, 'set objects');
|
|
25
33
|
expect(result.success).toBe(false);
|
|
26
|
-
expect(result.error).toBe('Failed to
|
|
34
|
+
expect(result.error).toBe('Failed to set objects: Unknown error');
|
|
27
35
|
expect(result.originalError).toBe(unknownError);
|
|
28
|
-
expect(result.
|
|
36
|
+
expect(result.results).toBeUndefined();
|
|
29
37
|
});
|
|
30
38
|
test('should work with different response types', () => {
|
|
31
39
|
const error = new Error('API rate limit exceeded');
|
|
32
40
|
const bulkResult = (0, error_handling_1.handleError)(error, 'set objects');
|
|
33
41
|
const deleteResult = (0, error_handling_1.handleError)(error, 'delete objects');
|
|
34
|
-
const fetchResult = (0, error_handling_1.handleError)(error, 'fetch data');
|
|
35
42
|
expect(bulkResult.success).toBe(false);
|
|
36
43
|
expect(deleteResult.success).toBe(false);
|
|
37
|
-
expect(fetchResult.success).toBe(false);
|
|
38
44
|
expect(bulkResult.error).toBe('Failed to set objects: API rate limit exceeded');
|
|
39
45
|
expect(deleteResult.error).toBe('Failed to delete objects: API rate limit exceeded');
|
|
40
|
-
expect(fetchResult.error).toBe('Failed to fetch data: API rate limit exceeded');
|
|
41
46
|
expect(bulkResult.originalError).toBe(error);
|
|
42
47
|
expect(deleteResult.originalError).toBe(error);
|
|
43
|
-
expect(fetchResult.originalError).toBe(error);
|
|
44
48
|
});
|
|
45
49
|
});
|
|
46
50
|
});
|
|
@@ -176,136 +176,23 @@ describe('TeamWorkGraphClient - Validators', () => {
|
|
|
176
176
|
describe('validateDeleteObjectsByPropertiesRequest', () => {
|
|
177
177
|
it('should pass with valid single property object', () => {
|
|
178
178
|
const properties = { type: 'issue' };
|
|
179
|
-
expect(() => (0, validators_1.validateDeleteObjectsByPropertiesRequest)(properties)).not.toThrow();
|
|
179
|
+
expect(() => (0, validators_1.validateDeleteObjectsByPropertiesRequest)(properties, 'atlassian:issue')).not.toThrow();
|
|
180
180
|
});
|
|
181
181
|
it('should throw validation error for non-object input', () => {
|
|
182
|
-
expect(() => (0, validators_1.validateDeleteObjectsByPropertiesRequest)('invalid')).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
183
|
-
expect(() => (0, validators_1.validateDeleteObjectsByPropertiesRequest)(null)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
184
|
-
expect(() => (0, validators_1.validateDeleteObjectsByPropertiesRequest)(undefined)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
182
|
+
expect(() => (0, validators_1.validateDeleteObjectsByPropertiesRequest)('invalid', 'atlassian:issue')).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
183
|
+
expect(() => (0, validators_1.validateDeleteObjectsByPropertiesRequest)(null, 'atlassian:issue')).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
184
|
+
expect(() => (0, validators_1.validateDeleteObjectsByPropertiesRequest)(undefined, 'atlassian:issue')).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
185
185
|
});
|
|
186
186
|
it('should throw validation error for empty object', () => {
|
|
187
|
-
expect(() => (0, validators_1.validateDeleteObjectsByPropertiesRequest)({})).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
187
|
+
expect(() => (0, validators_1.validateDeleteObjectsByPropertiesRequest)({}, 'atlassian:issue')).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
188
188
|
});
|
|
189
189
|
it('should throw validation error for multiple properties', () => {
|
|
190
190
|
const properties = { type: 'issue', status: 'open' };
|
|
191
|
-
expect(() => (0, validators_1.validateDeleteObjectsByPropertiesRequest)(properties)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
191
|
+
expect(() => (0, validators_1.validateDeleteObjectsByPropertiesRequest)(properties, 'atlassian:issue')).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
192
192
|
});
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
const request = {
|
|
197
|
-
requestConfig: {
|
|
198
|
-
url: 'https://api.example.com/data',
|
|
199
|
-
method: 'GET',
|
|
200
|
-
headers: {}
|
|
201
|
-
},
|
|
202
|
-
onResult: jest.fn()
|
|
203
|
-
};
|
|
204
|
-
expect(() => (0, validators_1.validateFetchDataRequest)(request)).not.toThrow();
|
|
205
|
-
});
|
|
206
|
-
it('should throw validation error for non-object request', () => {
|
|
207
|
-
expect(() => (0, validators_1.validateFetchDataRequest)('invalid')).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
208
|
-
expect(() => (0, validators_1.validateFetchDataRequest)(null)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
209
|
-
expect(() => (0, validators_1.validateFetchDataRequest)(undefined)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
210
|
-
});
|
|
211
|
-
it('should throw validation error for missing requestConfig', () => {
|
|
212
|
-
const request = { onResult: jest.fn() };
|
|
213
|
-
expect(() => (0, validators_1.validateFetchDataRequest)(request)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
214
|
-
});
|
|
215
|
-
it('should throw validation error for non-object requestConfig', () => {
|
|
216
|
-
const request = {
|
|
217
|
-
requestConfig: 'invalid',
|
|
218
|
-
onResult: jest.fn()
|
|
219
|
-
};
|
|
220
|
-
expect(() => (0, validators_1.validateFetchDataRequest)(request)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
221
|
-
});
|
|
222
|
-
it('should throw validation error for missing url', () => {
|
|
223
|
-
const request = {
|
|
224
|
-
requestConfig: {
|
|
225
|
-
method: 'GET',
|
|
226
|
-
headers: {}
|
|
227
|
-
},
|
|
228
|
-
onResult: jest.fn()
|
|
229
|
-
};
|
|
230
|
-
expect(() => (0, validators_1.validateFetchDataRequest)(request)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
231
|
-
});
|
|
232
|
-
it('should throw validation error for non-string url', () => {
|
|
233
|
-
const request = {
|
|
234
|
-
requestConfig: {
|
|
235
|
-
url: 123,
|
|
236
|
-
method: 'GET',
|
|
237
|
-
headers: {}
|
|
238
|
-
},
|
|
239
|
-
onResult: jest.fn()
|
|
240
|
-
};
|
|
241
|
-
expect(() => (0, validators_1.validateFetchDataRequest)(request)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
242
|
-
});
|
|
243
|
-
it('should throw validation error for missing method', () => {
|
|
244
|
-
const request = {
|
|
245
|
-
requestConfig: {
|
|
246
|
-
url: 'https://api.example.com/data',
|
|
247
|
-
headers: {}
|
|
248
|
-
},
|
|
249
|
-
onResult: jest.fn()
|
|
250
|
-
};
|
|
251
|
-
expect(() => (0, validators_1.validateFetchDataRequest)(request)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
252
|
-
});
|
|
253
|
-
it('should throw validation error for non-string method', () => {
|
|
254
|
-
const request = {
|
|
255
|
-
requestConfig: {
|
|
256
|
-
url: 'https://api.example.com/data',
|
|
257
|
-
method: 123,
|
|
258
|
-
headers: {}
|
|
259
|
-
},
|
|
260
|
-
onResult: jest.fn()
|
|
261
|
-
};
|
|
262
|
-
expect(() => (0, validators_1.validateFetchDataRequest)(request)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
263
|
-
});
|
|
264
|
-
it('should throw validation error for missing onResult', () => {
|
|
265
|
-
const request = {
|
|
266
|
-
requestConfig: {
|
|
267
|
-
url: 'https://api.example.com/data',
|
|
268
|
-
method: 'GET',
|
|
269
|
-
headers: {}
|
|
270
|
-
}
|
|
271
|
-
};
|
|
272
|
-
expect(() => (0, validators_1.validateFetchDataRequest)(request)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
273
|
-
});
|
|
274
|
-
it('should throw validation error for non-function onResult', () => {
|
|
275
|
-
const request = {
|
|
276
|
-
requestConfig: {
|
|
277
|
-
url: 'https://api.example.com/data',
|
|
278
|
-
method: 'GET',
|
|
279
|
-
headers: {}
|
|
280
|
-
},
|
|
281
|
-
onResult: 'not a function'
|
|
282
|
-
};
|
|
283
|
-
expect(() => (0, validators_1.validateFetchDataRequest)(request)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
284
|
-
});
|
|
285
|
-
});
|
|
286
|
-
describe('validateTransformDataRequest', () => {
|
|
287
|
-
it('should pass with valid request', () => {
|
|
288
|
-
const request = {
|
|
289
|
-
data: { key: 'value' },
|
|
290
|
-
transformMethod: jest.fn()
|
|
291
|
-
};
|
|
292
|
-
expect(() => (0, validators_1.validateTransformDataRequest)(request)).not.toThrow();
|
|
293
|
-
});
|
|
294
|
-
it('should throw validation error for non-object request', () => {
|
|
295
|
-
expect(() => (0, validators_1.validateTransformDataRequest)('invalid')).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
296
|
-
expect(() => (0, validators_1.validateTransformDataRequest)(null)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
297
|
-
expect(() => (0, validators_1.validateTransformDataRequest)(undefined)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
298
|
-
});
|
|
299
|
-
it('should throw validation error for missing transformMethod', () => {
|
|
300
|
-
const request = { data: { key: 'value' } };
|
|
301
|
-
expect(() => (0, validators_1.validateTransformDataRequest)(request)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
302
|
-
});
|
|
303
|
-
it('should throw validation error for non-function transformMethod', () => {
|
|
304
|
-
const request = {
|
|
305
|
-
data: { key: 'value' },
|
|
306
|
-
transformMethod: 'not a function'
|
|
307
|
-
};
|
|
308
|
-
expect(() => (0, validators_1.validateTransformDataRequest)(request)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
193
|
+
it('should throw validation error for null entityType', () => {
|
|
194
|
+
const properties = { type: 'issue', status: 'open' };
|
|
195
|
+
expect(() => (0, validators_1.validateDeleteObjectsByPropertiesRequest)(properties, null)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
309
196
|
});
|
|
310
197
|
});
|
|
311
198
|
});
|
package/out/graph.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TeamWorkGraph, SetObjectsRequest, BulkObjectResponse, BulkUsersRequest, BulkUsersResponse, DeleteUsersByExternalIdRequest, DeleteUsersByExternalIdResponse, GetUserByExternalIdRequest, GetUserByExternalIdResponse, MapUsersRequest, MapUsersResponse, BulkGroupsRequest, BulkGroupsResponse, DeleteGroupsByExternalIdRequest, DeleteGroupsByExternalIdResponse, GetGroupByExternalIdRequest, GetGroupByExternalIdResponse, GetObjectByExternalIdRequest, GetObjectByExternalIdResponse, DeleteObjectsByExternalIdRequest, DeleteObjectsByExternalIdResponse, DeleteObjectsByPropertiesRequest, DeleteObjectsByPropertiesResponse
|
|
1
|
+
import { TeamWorkGraph, SetObjectsRequest, BulkObjectResponse, BulkUsersRequest, BulkUsersResponse, DeleteUsersByExternalIdRequest, DeleteUsersByExternalIdResponse, GetUserByExternalIdRequest, GetUserByExternalIdResponse, MapUsersRequest, MapUsersResponse, BulkGroupsRequest, BulkGroupsResponse, DeleteGroupsByExternalIdRequest, DeleteGroupsByExternalIdResponse, GetGroupByExternalIdRequest, GetGroupByExternalIdResponse, GetObjectByExternalIdRequest, GetObjectByExternalIdResponse, DeleteObjectsByExternalIdRequest, DeleteObjectsByExternalIdResponse, DeleteObjectsByPropertiesRequest, DeleteObjectsByPropertiesResponse } from './types';
|
|
2
2
|
export declare class TeamWorkGraphClient implements TeamWorkGraph {
|
|
3
3
|
setObjects: (request: SetObjectsRequest) => Promise<BulkObjectResponse>;
|
|
4
4
|
getObjectByExternalId: (request: GetObjectByExternalIdRequest) => Promise<GetObjectByExternalIdResponse>;
|
|
@@ -11,8 +11,6 @@ export declare class TeamWorkGraphClient implements TeamWorkGraph {
|
|
|
11
11
|
deleteUsersByExternalId: (request: DeleteUsersByExternalIdRequest) => Promise<DeleteUsersByExternalIdResponse>;
|
|
12
12
|
getUserByExternalId: (request: GetUserByExternalIdRequest) => Promise<GetUserByExternalIdResponse>;
|
|
13
13
|
mapUsers: (request: MapUsersRequest) => Promise<MapUsersResponse>;
|
|
14
|
-
fetchData: (request: FetchDataRequest) => Promise<FetchDataResponse>;
|
|
15
|
-
transformData: (request: TransformDataRequest) => Promise<TransformDataResponse>;
|
|
16
14
|
private sendRequest;
|
|
17
15
|
}
|
|
18
16
|
export declare const teamworkgraph: TeamWorkGraphClient;
|
package/out/graph.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../src/graph.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../src/graph.ts"],"names":[],"mappings":"AAiBA,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,EAC7B,gCAAgC,EAChC,iCAAiC,EACjC,gCAAgC,EAChC,iCAAiC,EAClC,MAAM,SAAS,CAAC;AAEjB,qBAAa,mBAAoB,YAAW,aAAa;IACvD,UAAU,YAAmB,iBAAiB,KAAG,QAAQ,kBAAkB,CAAC,CAoB1E;IAKF,qBAAqB,YAAmB,4BAA4B,KAAG,QAAQ,6BAA6B,CAAC,CAoB3G;IAKF,yBAAyB,YACd,gCAAgC,KACxC,QAAQ,iCAAiC,CAAC,CAe3C;IAKF,yBAAyB,YACd,gCAAgC,KACxC,QAAQ,iCAAiC,CAAC,CAkB3C;IAKF,SAAS,YAAmB,iBAAiB,KAAG,QAAQ,kBAAkB,CAAC,CAmBzE;IAKF,wBAAwB,YACb,+BAA+B,KACvC,QAAQ,gCAAgC,CAAC,CAgB1C;IAKF,oBAAoB,YAAmB,2BAA2B,KAAG,QAAQ,4BAA4B,CAAC,CAgBxG;IAEF,QAAQ,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,CAapE;YAEY,WAAW;CA2B1B;AAED,eAAO,MAAM,aAAa,qBAA4B,CAAC"}
|
package/out/graph.js
CHANGED
|
@@ -66,11 +66,15 @@ class TeamWorkGraphClient {
|
|
|
66
66
|
}
|
|
67
67
|
};
|
|
68
68
|
deleteObjectsByProperties = async (request) => {
|
|
69
|
-
|
|
69
|
+
const { properties, objectType } = request;
|
|
70
|
+
(0, validators_1.validateDeleteObjectsByPropertiesRequest)(properties, objectType);
|
|
70
71
|
try {
|
|
71
72
|
await this.sendRequest(endpoints_1.ENDPOINTS.OBJECTS.DELETE_BY_PROPERTIES, {
|
|
72
73
|
method: 'DELETE',
|
|
73
|
-
body: JSON.stringify(
|
|
74
|
+
body: JSON.stringify({
|
|
75
|
+
properties,
|
|
76
|
+
entityType: objectType
|
|
77
|
+
})
|
|
74
78
|
});
|
|
75
79
|
return {
|
|
76
80
|
success: true
|
|
@@ -202,44 +206,6 @@ class TeamWorkGraphClient {
|
|
|
202
206
|
return (0, error_handling_1.handleError)(error, 'map users');
|
|
203
207
|
}
|
|
204
208
|
};
|
|
205
|
-
fetchData = async (request) => {
|
|
206
|
-
(0, validators_1.validateFetchDataRequest)(request);
|
|
207
|
-
try {
|
|
208
|
-
const { requestConfig, onResult } = request;
|
|
209
|
-
const { url, method, headers } = requestConfig;
|
|
210
|
-
const res = await (0, api_1.fetch)(url, {
|
|
211
|
-
method: method,
|
|
212
|
-
headers: headers
|
|
213
|
-
});
|
|
214
|
-
if (!res.ok) {
|
|
215
|
-
throw new errors_1.ForgeTeamWorkGraphFetchError(`Remote call failed with status: ${res.status}`);
|
|
216
|
-
}
|
|
217
|
-
const data = await res.json();
|
|
218
|
-
onResult(data);
|
|
219
|
-
return {
|
|
220
|
-
success: true,
|
|
221
|
-
data: data
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
catch (error) {
|
|
225
|
-
return (0, error_handling_1.handleError)(error, 'fetch data');
|
|
226
|
-
}
|
|
227
|
-
};
|
|
228
|
-
transformData = async (request) => {
|
|
229
|
-
(0, validators_1.validateTransformDataRequest)(request);
|
|
230
|
-
try {
|
|
231
|
-
const { data, transformMethod } = request;
|
|
232
|
-
const transformedData = transformMethod(data);
|
|
233
|
-
return {
|
|
234
|
-
success: true,
|
|
235
|
-
transformedData: transformedData
|
|
236
|
-
};
|
|
237
|
-
}
|
|
238
|
-
catch (error) {
|
|
239
|
-
const transformError = new errors_1.ForgeTeamWorkGraphTransformError('Transform failed', error instanceof Error ? error : undefined);
|
|
240
|
-
return (0, error_handling_1.handleError)(transformError, 'transform data');
|
|
241
|
-
}
|
|
242
|
-
};
|
|
243
209
|
async sendRequest(path, options) {
|
|
244
210
|
try {
|
|
245
211
|
const reqPath = (0, endpoints_1.getFullPath)(path);
|
package/out/types/graph.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { SetObjectsRequest, BulkObjectResponse, BulkUsersRequest, BulkUsersResponse, DeleteUsersByExternalIdRequest, DeleteUsersByExternalIdResponse, GetUserByExternalIdRequest, GetUserByExternalIdResponse, MapUsersRequest, MapUsersResponse, BulkGroupsRequest, BulkGroupsResponse, DeleteGroupsByExternalIdRequest, DeleteGroupsByExternalIdResponse, GetGroupByExternalIdRequest, GetGroupByExternalIdResponse, GetObjectByExternalIdRequest, GetObjectByExternalIdResponse, DeleteObjectsByExternalIdRequest, DeleteObjectsByExternalIdResponse, DeleteObjectsByPropertiesRequest, DeleteObjectsByPropertiesResponse
|
|
1
|
+
import { SetObjectsRequest, BulkObjectResponse, BulkUsersRequest, BulkUsersResponse, DeleteUsersByExternalIdRequest, DeleteUsersByExternalIdResponse, GetUserByExternalIdRequest, GetUserByExternalIdResponse, MapUsersRequest, MapUsersResponse, BulkGroupsRequest, BulkGroupsResponse, DeleteGroupsByExternalIdRequest, DeleteGroupsByExternalIdResponse, GetGroupByExternalIdRequest, GetGroupByExternalIdResponse, GetObjectByExternalIdRequest, GetObjectByExternalIdResponse, DeleteObjectsByExternalIdRequest, DeleteObjectsByExternalIdResponse, DeleteObjectsByPropertiesRequest, DeleteObjectsByPropertiesResponse } from './';
|
|
2
2
|
export interface TeamWorkGraph {
|
|
3
3
|
setObjects(request: SetObjectsRequest): Promise<BulkObjectResponse>;
|
|
4
4
|
getObjectByExternalId(request: GetObjectByExternalIdRequest): Promise<GetObjectByExternalIdResponse>;
|
|
5
5
|
deleteObjectsByExternalId(request: DeleteObjectsByExternalIdRequest): Promise<DeleteObjectsByExternalIdResponse>;
|
|
6
6
|
deleteObjectsByProperties(request: DeleteObjectsByPropertiesRequest): Promise<DeleteObjectsByPropertiesResponse>;
|
|
7
|
-
fetchData(request: FetchDataRequest): Promise<FetchDataResponse>;
|
|
8
|
-
transformData(request: TransformDataRequest): Promise<TransformDataResponse>;
|
|
9
7
|
setUsers(request: BulkUsersRequest): Promise<BulkUsersResponse>;
|
|
10
8
|
deleteUsersByExternalId(request: DeleteUsersByExternalIdRequest): Promise<DeleteUsersByExternalIdResponse>;
|
|
11
9
|
getUserByExternalId(request: GetUserByExternalIdRequest): Promise<GetUserByExternalIdResponse>;
|
package/out/types/graph.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../src/types/graph.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,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,EAC7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nE,wBAAwB,CAAC,OAAO,EAAE,+BAA+B,GAAG,OAAO,CAAC,gCAAgC,CAAC,CAAC;IAC9G,oBAAoB,CAAC,OAAO,EAAE,2BAA2B,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;CACnG"}
|
|
@@ -16,13 +16,13 @@ export declare type Permissions = {
|
|
|
16
16
|
export declare type ContainerKeyObject = {
|
|
17
17
|
type: string;
|
|
18
18
|
value: {
|
|
19
|
-
|
|
19
|
+
entityId: string;
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
22
|
export declare type ParentKeyObject = {
|
|
23
23
|
type: string;
|
|
24
24
|
value: {
|
|
25
|
-
|
|
25
|
+
entityId: string;
|
|
26
26
|
};
|
|
27
27
|
};
|
|
28
28
|
export declare type BaseObjectProperties = {
|
|
@@ -49,6 +49,7 @@ export declare type AssociationObject = {
|
|
|
49
49
|
values: string[];
|
|
50
50
|
};
|
|
51
51
|
export declare type Associations = {
|
|
52
|
+
lastUpdatedAt: string;
|
|
52
53
|
set: AssociationObject[];
|
|
53
54
|
};
|
|
54
55
|
//# sourceMappingURL=common.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/types/objects/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAE1B,oBAAY,SAAS,GAAG;IACtB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,oBAAY,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEvC,oBAAY,SAAS,GAAG;IACtB,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,qBAAqB,GAAG,WAAW,CAAC;IAC1E,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACpB,CAAC;AAEF,oBAAY,aAAa,GAAG;IAC1B,UAAU,EAAE,SAAS,EAAE,CAAC;CACzB,CAAC;AAEF,oBAAY,WAAW,GAAG;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AAM,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;IACzB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,SAAS,CAAC,EAAE,eAAe,GAAG,MAAM,CAAC;IACrC,YAAY,CAAC,EAAE,kBAAkB,GAAG,MAAM,CAAC;IAC3C,WAAW,EAAE,WAAW,EAAE,CAAC;IAC3B,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAClC,CAAC;AAEF,oBAAY,iBAAiB,GAAG;IAC9B,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAEF,oBAAY,YAAY,GAAG;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,GAAG,EAAE,iBAAiB,EAAE,CAAC;CAC1B,CAAC"}
|
package/out/types/requests.d.ts
CHANGED
|
@@ -55,7 +55,10 @@ export declare type DeleteObjectsByExternalIdResponse = {
|
|
|
55
55
|
error?: string;
|
|
56
56
|
originalError?: unknown;
|
|
57
57
|
};
|
|
58
|
-
export declare type DeleteObjectsByPropertiesRequest =
|
|
58
|
+
export declare type DeleteObjectsByPropertiesRequest = {
|
|
59
|
+
properties: Record<string, string>;
|
|
60
|
+
objectType: string;
|
|
61
|
+
};
|
|
59
62
|
export declare type DeleteObjectsByPropertiesResponse = {
|
|
60
63
|
success: boolean;
|
|
61
64
|
error?: string;
|
|
@@ -180,28 +183,4 @@ export declare type GetGroupByExternalIdResponse = {
|
|
|
180
183
|
error?: string;
|
|
181
184
|
originalError?: unknown;
|
|
182
185
|
};
|
|
183
|
-
export declare type FetchDataRequest = {
|
|
184
|
-
requestConfig: {
|
|
185
|
-
url: string;
|
|
186
|
-
method: string;
|
|
187
|
-
headers?: Record<string, string>;
|
|
188
|
-
};
|
|
189
|
-
onResult: (data: any) => any;
|
|
190
|
-
};
|
|
191
|
-
export declare type FetchDataResponse = {
|
|
192
|
-
success: boolean;
|
|
193
|
-
data?: any;
|
|
194
|
-
error?: string;
|
|
195
|
-
originalError?: unknown;
|
|
196
|
-
};
|
|
197
|
-
export declare type TransformDataRequest = {
|
|
198
|
-
data: any;
|
|
199
|
-
transformMethod: (data: any) => any;
|
|
200
|
-
};
|
|
201
|
-
export declare type TransformDataResponse = {
|
|
202
|
-
success: boolean;
|
|
203
|
-
transformedData?: any;
|
|
204
|
-
error?: string;
|
|
205
|
-
originalError?: unknown;
|
|
206
|
-
};
|
|
207
186
|
//# sourceMappingURL=requests.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requests.d.ts","sourceRoot":"","sources":["../../src/types/requests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,IAAI,CAAC;AAGpE,oBAAY,iBAAiB,GAAG;IAC9B,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACrC,CAAC;AAEF,oBAAY,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE9C,oBAAY,WAAW,GAAG;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,oBAAY,cAAc,GAAG;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,oBAAY,iBAAiB,GAAG;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;CACpB,CAAC;AAEF,oBAAY,eAAe,GAAG;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;CAC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,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,oBAAY,4BAA4B,GAAG;IACzC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-handling.d.ts","sourceRoot":"","sources":["../../src/utils/error-handling.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"error-handling.d.ts","sourceRoot":"","sources":["../../src/utils/error-handling.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAgBzC,wBAAsB,mBAAmB,CAAC,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAoDhG;AAwBD,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,GAAG,CAAC,CAQnE"}
|
|
@@ -58,10 +58,7 @@ function createErrorMessage(error, operation) {
|
|
|
58
58
|
if (error instanceof errors_1.ForgeTeamWorkGraphAPIError) {
|
|
59
59
|
return `Failed to ${operation}: ${error.message}`;
|
|
60
60
|
}
|
|
61
|
-
if (error instanceof errors_1.
|
|
62
|
-
return error.message;
|
|
63
|
-
}
|
|
64
|
-
if (error instanceof errors_1.ForgeTeamWorkGraphTransformError) {
|
|
61
|
+
if (error instanceof errors_1.ForgeTeamWorkGraphNetworkError) {
|
|
65
62
|
return error.message;
|
|
66
63
|
}
|
|
67
64
|
return `Failed to ${operation}: ${error instanceof Error ? error.message : 'Unknown error'}`;
|
package/out/utils/errors.d.ts
CHANGED
|
@@ -15,10 +15,4 @@ export declare class ForgeTeamWorkGraphAPIError extends ForgeTeamWorkGraphError
|
|
|
15
15
|
readonly responseBody?: any;
|
|
16
16
|
constructor(message: string, status: number, responseBody?: any);
|
|
17
17
|
}
|
|
18
|
-
export declare class ForgeTeamWorkGraphFetchError extends ForgeTeamWorkGraphError {
|
|
19
|
-
constructor(message: string, cause?: Error);
|
|
20
|
-
}
|
|
21
|
-
export declare class ForgeTeamWorkGraphTransformError extends ForgeTeamWorkGraphError {
|
|
22
|
-
constructor(message: string, cause?: Error);
|
|
23
|
-
}
|
|
24
18
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAGA,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,KAAK,CAAC,EAAE,MAAM,CAAC;IAC/B,SAAgB,OAAO,CAAC,EAAE,GAAG,CAAC;gBAElB,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG;CAOzE;AAKD,qBAAa,iCAAkC,SAAQ,uBAAuB;gBAChE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG;CAG3D;AAKD,qBAAa,8BAA+B,SAAQ,uBAAuB;gBAC7D,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;CAG3C;AAKD,qBAAa,0BAA2B,SAAQ,uBAAuB;IACrE,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,SAAgB,YAAY,CAAC,EAAE,GAAG,CAAC;gBAEvB,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,GAAG;CAKhE
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAGA,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,KAAK,CAAC,EAAE,MAAM,CAAC;IAC/B,SAAgB,OAAO,CAAC,EAAE,GAAG,CAAC;gBAElB,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG;CAOzE;AAKD,qBAAa,iCAAkC,SAAQ,uBAAuB;gBAChE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG;CAG3D;AAKD,qBAAa,8BAA+B,SAAQ,uBAAuB;gBAC7D,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;CAG3C;AAKD,qBAAa,0BAA2B,SAAQ,uBAAuB;IACrE,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,SAAgB,YAAY,CAAC,EAAE,GAAG,CAAC;gBAEvB,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,GAAG;CAKhE"}
|
package/out/utils/errors.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ForgeTeamWorkGraphAPIError = exports.ForgeTeamWorkGraphNetworkError = exports.ForgeTeamWorkGraphValidationError = exports.ForgeTeamWorkGraphError = void 0;
|
|
4
4
|
class ForgeTeamWorkGraphError extends Error {
|
|
5
5
|
code;
|
|
6
6
|
field;
|
|
@@ -36,15 +36,3 @@ class ForgeTeamWorkGraphAPIError extends ForgeTeamWorkGraphError {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
exports.ForgeTeamWorkGraphAPIError = ForgeTeamWorkGraphAPIError;
|
|
39
|
-
class ForgeTeamWorkGraphFetchError extends ForgeTeamWorkGraphError {
|
|
40
|
-
constructor(message, cause) {
|
|
41
|
-
super(message, 'FETCH_ERROR', undefined, { cause: cause?.message });
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
exports.ForgeTeamWorkGraphFetchError = ForgeTeamWorkGraphFetchError;
|
|
45
|
-
class ForgeTeamWorkGraphTransformError extends ForgeTeamWorkGraphError {
|
|
46
|
-
constructor(message, cause) {
|
|
47
|
-
super(message, 'TRANSFORM_ERROR', undefined, { cause: cause?.message });
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
exports.ForgeTeamWorkGraphTransformError = ForgeTeamWorkGraphTransformError;
|
|
@@ -22,7 +22,5 @@ export declare function validateGetObjectByExternalIdRequest(objectType: string,
|
|
|
22
22
|
export declare function validateGetUserByExternalIdRequest(externalId: string): void;
|
|
23
23
|
export declare function validateGetGroupByExternalIdRequest(externalId: string): void;
|
|
24
24
|
export declare function validateMapUsersRequest(directMappings: any[]): void;
|
|
25
|
-
export declare function validateDeleteObjectsByPropertiesRequest(properties: Record<string, string
|
|
26
|
-
export declare function validateFetchDataRequest(request: any): void;
|
|
27
|
-
export declare function validateTransformDataRequest(request: any): void;
|
|
25
|
+
export declare function validateDeleteObjectsByPropertiesRequest(properties: Record<string, string>, objectType: string): void;
|
|
28
26
|
//# sourceMappingURL=validators.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../src/utils/validators.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,gBAAgB,MAAM,CAAC;AACpC,eAAO,MAAM,cAAc,MAAM,CAAC;AAClC,eAAO,MAAM,eAAe,MAAM,CAAC;AACnC,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAC3C,eAAO,MAAM,iBAAiB,MAAM,CAAC;AACrC,eAAO,MAAM,cAAc,IAAI,CAAC;AAChC,eAAO,MAAM,qBAAqB,MAAM,CAAC;AACzC,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAC1C,eAAO,MAAM,qB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AgB,yBAAyB,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAWhG;AAKD,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,IAAI,CAG1D;AAKD,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAG5D;AAKD,wBAAgB,wCAAwC,CAAC,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,IAAI,CAIxG;AAKD,wBAAgB,sCAAsC,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,IAAI,CAGlF;AAKD,wBAAgB,uCAAuC,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,IAAI,CAGnF;AAKD,wBAAgB,oCAAoC,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAGjG;AAKD,wBAAgB,kCAAkC,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAE3E;AAKD,wBAAgB,mCAAmC,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAE5E;AAKD,wBAAgB,uBAAuB,CAAC,cAAc,EAAE,GAAG,EAAE,GAAG,IAAI,CAmBnE;AAKD,wBAAgB,wCAAwC,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAIrH"}
|
package/out/utils/validators.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.validateDeleteObjectsByPropertiesRequest = exports.validateMapUsersRequest = exports.validateGetGroupByExternalIdRequest = exports.validateGetUserByExternalIdRequest = exports.validateGetObjectByExternalIdRequest = exports.validateDeleteGroupsByExternalIdRequest = exports.validateDeleteUsersByExternalIdRequest = exports.validateDeleteObjectsByExternalIdRequest = exports.validateSetGroupsRequest = exports.validateSetUsersRequest = exports.validateSetObjectsRequest = exports.validatePropertyCount = exports.validateObject = exports.validateRequiredString = exports.validateArrayMaxLength = exports.validateArray = exports.MAX_PROPERTIES_DELETE = exports.MAX_BULK_GROUPS_DELETE = exports.MAX_BULK_USERS_DELETE = exports.MAX_PROPERTIES = exports.MAX_USER_MAPPINGS = exports.MAX_BULK_OBJECTS_DELETE = exports.MAX_BULK_GROUPS = exports.MAX_BULK_USERS = exports.MAX_BULK_OBJECTS = void 0;
|
|
4
4
|
const errors_1 = require("./errors");
|
|
5
5
|
exports.MAX_BULK_OBJECTS = 100;
|
|
6
6
|
exports.MAX_BULK_USERS = 100;
|
|
@@ -115,35 +115,9 @@ function validateMapUsersRequest(directMappings) {
|
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
exports.validateMapUsersRequest = validateMapUsersRequest;
|
|
118
|
-
function validateDeleteObjectsByPropertiesRequest(properties) {
|
|
118
|
+
function validateDeleteObjectsByPropertiesRequest(properties, objectType) {
|
|
119
119
|
validateObject(properties, 'properties');
|
|
120
120
|
validatePropertyCount(properties, 'properties', exports.MAX_PROPERTIES_DELETE);
|
|
121
|
+
validateRequiredString(objectType, 'objectType');
|
|
121
122
|
}
|
|
122
123
|
exports.validateDeleteObjectsByPropertiesRequest = validateDeleteObjectsByPropertiesRequest;
|
|
123
|
-
function validateFetchDataRequest(request) {
|
|
124
|
-
if (!request || typeof request !== 'object') {
|
|
125
|
-
throw new errors_1.ForgeTeamWorkGraphValidationError('request must be an object', 'request');
|
|
126
|
-
}
|
|
127
|
-
if (!request.requestConfig || typeof request.requestConfig !== 'object') {
|
|
128
|
-
throw new errors_1.ForgeTeamWorkGraphValidationError('requestConfig is required and must be an object', 'requestConfig');
|
|
129
|
-
}
|
|
130
|
-
if (!request.requestConfig.url || typeof request.requestConfig.url !== 'string') {
|
|
131
|
-
throw new errors_1.ForgeTeamWorkGraphValidationError('requestConfig.url is required and must be a string', 'requestConfig.url');
|
|
132
|
-
}
|
|
133
|
-
if (!request.requestConfig.method || typeof request.requestConfig.method !== 'string') {
|
|
134
|
-
throw new errors_1.ForgeTeamWorkGraphValidationError('requestConfig.method is required and must be a string', 'requestConfig.method');
|
|
135
|
-
}
|
|
136
|
-
if (!request.onResult || typeof request.onResult !== 'function') {
|
|
137
|
-
throw new errors_1.ForgeTeamWorkGraphValidationError('onResult is required and must be a function', 'onResult');
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
exports.validateFetchDataRequest = validateFetchDataRequest;
|
|
141
|
-
function validateTransformDataRequest(request) {
|
|
142
|
-
if (!request || typeof request !== 'object') {
|
|
143
|
-
throw new errors_1.ForgeTeamWorkGraphValidationError('request must be an object', 'request');
|
|
144
|
-
}
|
|
145
|
-
if (!request.transformMethod || typeof request.transformMethod !== 'function') {
|
|
146
|
-
throw new errors_1.ForgeTeamWorkGraphValidationError('transformMethod is required and must be a function', 'transformMethod');
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
exports.validateTransformDataRequest = validateTransformDataRequest;
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"graph-extended.test.d.ts","sourceRoot":"","sources":["../../src/__test__/graph-extended.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const api_1 = require("@forge/api");
|
|
4
|
-
const graph_1 = require("../graph");
|
|
5
|
-
jest.mock('@forge/api', () => ({
|
|
6
|
-
__fetchProduct: jest.fn(),
|
|
7
|
-
fetch: jest.fn()
|
|
8
|
-
}));
|
|
9
|
-
describe('TeamWorkGraphClient - Extended Features', () => {
|
|
10
|
-
let graphClient;
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
graphClient = new graph_1.TeamWorkGraphClient();
|
|
13
|
-
jest.clearAllMocks();
|
|
14
|
-
});
|
|
15
|
-
describe('fetchData', () => {
|
|
16
|
-
it('should successfully fetch and process external data', async () => {
|
|
17
|
-
const mockData = { items: [{ id: 1, name: 'Task 1' }] };
|
|
18
|
-
const mockResponse = {
|
|
19
|
-
ok: true,
|
|
20
|
-
status: 200,
|
|
21
|
-
json: jest.fn().mockResolvedValue(mockData)
|
|
22
|
-
};
|
|
23
|
-
api_1.fetch.mockResolvedValue(mockResponse);
|
|
24
|
-
const request = {
|
|
25
|
-
requestConfig: {
|
|
26
|
-
url: 'https://api.gitbook.com/api/tasks',
|
|
27
|
-
method: 'GET',
|
|
28
|
-
headers: { Authorization: 'Bearer token' }
|
|
29
|
-
},
|
|
30
|
-
onResult: jest.fn()
|
|
31
|
-
};
|
|
32
|
-
const result = await graphClient.fetchData(request);
|
|
33
|
-
expect(api_1.fetch).toHaveBeenCalledWith('https://api.gitbook.com/api/tasks', {
|
|
34
|
-
method: 'GET',
|
|
35
|
-
headers: { Authorization: 'Bearer token' }
|
|
36
|
-
});
|
|
37
|
-
expect(request.onResult).toHaveBeenCalledWith(mockData);
|
|
38
|
-
expect(result).toEqual({
|
|
39
|
-
success: true,
|
|
40
|
-
data: mockData
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
it('should return error response when fetch fails', async () => {
|
|
44
|
-
const mockResponse = {
|
|
45
|
-
ok: false,
|
|
46
|
-
status: 401
|
|
47
|
-
};
|
|
48
|
-
api_1.fetch.mockResolvedValue(mockResponse);
|
|
49
|
-
const request = {
|
|
50
|
-
requestConfig: {
|
|
51
|
-
url: 'https://api.gitbook.com/api/tasks',
|
|
52
|
-
method: 'GET'
|
|
53
|
-
},
|
|
54
|
-
onResult: jest.fn()
|
|
55
|
-
};
|
|
56
|
-
const result = await graphClient.fetchData(request);
|
|
57
|
-
expect(result).toEqual({
|
|
58
|
-
success: false,
|
|
59
|
-
error: 'Remote call failed with status: 401',
|
|
60
|
-
originalError: expect.any(Error)
|
|
61
|
-
});
|
|
62
|
-
expect(request.onResult).not.toHaveBeenCalled();
|
|
63
|
-
});
|
|
64
|
-
it('should throw error for validation errors', async () => {
|
|
65
|
-
const request = {};
|
|
66
|
-
await expect(graphClient.fetchData(request)).rejects.toThrow('requestConfig is required and must be an object');
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
describe('transformData', () => {
|
|
70
|
-
it('should transform data using the provided transform method', async () => {
|
|
71
|
-
const inputData = { items: [{ id: 1, name: 'Task 1' }] };
|
|
72
|
-
const transformMethod = jest.fn().mockImplementation((data) => ({
|
|
73
|
-
entities: data.items.map((item) => ({
|
|
74
|
-
id: `task-${item.id}`,
|
|
75
|
-
name: item.name,
|
|
76
|
-
type: 'task'
|
|
77
|
-
}))
|
|
78
|
-
}));
|
|
79
|
-
const request = {
|
|
80
|
-
data: inputData,
|
|
81
|
-
transformMethod
|
|
82
|
-
};
|
|
83
|
-
const result = await graphClient.transformData(request);
|
|
84
|
-
expect(transformMethod).toHaveBeenCalledWith(inputData);
|
|
85
|
-
expect(result).toEqual({
|
|
86
|
-
success: true,
|
|
87
|
-
transformedData: {
|
|
88
|
-
entities: [{ id: 'task-1', name: 'Task 1', type: 'task' }]
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
it('should return error response when transform method throws', async () => {
|
|
93
|
-
const inputData = { items: [{ id: 1, name: 'Task 1' }] };
|
|
94
|
-
const transformMethod = jest.fn().mockImplementation(() => {
|
|
95
|
-
throw new Error('Transform failed');
|
|
96
|
-
});
|
|
97
|
-
const request = {
|
|
98
|
-
data: inputData,
|
|
99
|
-
transformMethod
|
|
100
|
-
};
|
|
101
|
-
const result = await graphClient.transformData(request);
|
|
102
|
-
expect(result).toEqual({
|
|
103
|
-
success: false,
|
|
104
|
-
error: 'Transform failed',
|
|
105
|
-
originalError: expect.any(Error)
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
it('should throw error for validation errors', async () => {
|
|
109
|
-
const request = {};
|
|
110
|
-
await expect(graphClient.transformData(request)).rejects.toThrow('transformMethod is required and must be a function');
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
});
|