@forge/teamwork-graph 3.0.0-next.2 → 3.0.0-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/__test__/entity-operations.test.js +0 -172
- package/out/__test__/error-handling.test.js +95 -0
- package/out/types/objects/index.d.ts +2 -5
- package/out/types/objects/index.d.ts.map +1 -1
- package/out/utils/error-handling.d.ts.map +1 -1
- package/out/utils/error-handling.js +5 -1
- package/out/utils/errors.d.ts +2 -1
- package/out/utils/errors.d.ts.map +1 -1
- package/out/utils/errors.js +4 -2
- package/package.json +1 -1
- package/out/types/objects/organisation.d.ts +0 -9
- package/out/types/objects/organisation.d.ts.map +0 -1
- package/out/types/objects/organisation.js +0 -2
- package/out/types/objects/position.d.ts +0 -24
- package/out/types/objects/position.d.ts.map +0 -1
- package/out/types/objects/position.js +0 -2
- package/out/types/objects/worker.d.ts +0 -13
- package/out/types/objects/worker.d.ts.map +0 -1
- package/out/types/objects/worker.js +0 -2
|
@@ -175,58 +175,6 @@ describe('TeamWorkGraphClient - setObjects', () => {
|
|
|
175
175
|
expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.OBJECTS.BULK), expect.objectContaining({ method: 'POST' }));
|
|
176
176
|
expect(result).toEqual(expected);
|
|
177
177
|
});
|
|
178
|
-
it('posts organisation entities to /api/v1/entities/bulk and returns response', async () => {
|
|
179
|
-
const organisationObject = {
|
|
180
|
-
schemaVersion: '2.0',
|
|
181
|
-
id: 'org-1',
|
|
182
|
-
updateSequenceNumber: 2,
|
|
183
|
-
displayName: 'pos 2',
|
|
184
|
-
url: 'https://workday.atlassian.com/path-to-org',
|
|
185
|
-
createdAt: '2024-07-09T14:27:37.000Z',
|
|
186
|
-
lastUpdatedAt: '2024-07-09T14:27:37.000Z',
|
|
187
|
-
permissions: [
|
|
188
|
-
{
|
|
189
|
-
accessControls: [
|
|
190
|
-
{
|
|
191
|
-
principals: [
|
|
192
|
-
{
|
|
193
|
-
type: 'EVERYONE'
|
|
194
|
-
}
|
|
195
|
-
]
|
|
196
|
-
}
|
|
197
|
-
]
|
|
198
|
-
}
|
|
199
|
-
],
|
|
200
|
-
parentKey: {
|
|
201
|
-
type: 'atlassian:organisation',
|
|
202
|
-
value: {
|
|
203
|
-
entityId: 'id of the parent org of this org'
|
|
204
|
-
}
|
|
205
|
-
},
|
|
206
|
-
'atlassian:organisation': {}
|
|
207
|
-
};
|
|
208
|
-
const req = { objects: [organisationObject] };
|
|
209
|
-
const backendResponse = {
|
|
210
|
-
accepted: [
|
|
211
|
-
{
|
|
212
|
-
entityType: 'atlassian:organisation',
|
|
213
|
-
entityId: { id: 'org-1' },
|
|
214
|
-
thirdPartyAri: 'ari:third-party:test::organisation/org-1'
|
|
215
|
-
}
|
|
216
|
-
]
|
|
217
|
-
};
|
|
218
|
-
const expected = {
|
|
219
|
-
success: true,
|
|
220
|
-
results: { accepted: backendResponse.accepted, rejected: undefined, validEntities: undefined }
|
|
221
|
-
};
|
|
222
|
-
mockFetch.mockResolvedValueOnce({
|
|
223
|
-
ok: true,
|
|
224
|
-
json: () => Promise.resolve(backendResponse)
|
|
225
|
-
});
|
|
226
|
-
const result = await graphClient.setObjects(req);
|
|
227
|
-
expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.OBJECTS.BULK), expect.objectContaining({ method: 'POST' }));
|
|
228
|
-
expect(result).toEqual(expected);
|
|
229
|
-
});
|
|
230
178
|
it('throws if objects is not an array', async () => {
|
|
231
179
|
const req = { objects: null };
|
|
232
180
|
await expect(graphClient.setObjects(req)).rejects.toThrow('objects must be an array');
|
|
@@ -1338,71 +1286,6 @@ describe('TeamWorkGraphClient - bulk entities', () => {
|
|
|
1338
1286
|
expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.OBJECTS.BULK), expect.objectContaining({ method: 'POST' }));
|
|
1339
1287
|
expect(result).toEqual(expected);
|
|
1340
1288
|
});
|
|
1341
|
-
it('posts position entities to /api/v1/entities/bulk and returns response', async () => {
|
|
1342
|
-
const positionObject = {
|
|
1343
|
-
schemaVersion: '2.0',
|
|
1344
|
-
id: 'position-1',
|
|
1345
|
-
updateSequenceNumber: 1,
|
|
1346
|
-
displayName: 'Senior Software Engineer - Backend',
|
|
1347
|
-
url: 'https://hr.example.com/positions/senior-backend-engineer',
|
|
1348
|
-
createdAt: '2024-07-09T14:27:37.000Z',
|
|
1349
|
-
lastUpdatedAt: '2024-07-09T14:27:37.000Z',
|
|
1350
|
-
permissions: [
|
|
1351
|
-
{
|
|
1352
|
-
accessControls: [
|
|
1353
|
-
{
|
|
1354
|
-
principals: [
|
|
1355
|
-
{
|
|
1356
|
-
type: 'EVERYONE'
|
|
1357
|
-
}
|
|
1358
|
-
]
|
|
1359
|
-
}
|
|
1360
|
-
]
|
|
1361
|
-
}
|
|
1362
|
-
],
|
|
1363
|
-
parentKey: {
|
|
1364
|
-
type: 'atlassian:organisation',
|
|
1365
|
-
value: {
|
|
1366
|
-
entityId: 'org-tech-company-123'
|
|
1367
|
-
}
|
|
1368
|
-
},
|
|
1369
|
-
associations: {
|
|
1370
|
-
lastUpdatedAt: '2024-07-09T14:27:37.000Z',
|
|
1371
|
-
set: [
|
|
1372
|
-
{
|
|
1373
|
-
associationType: 'atlassian:worker',
|
|
1374
|
-
values: ['worker-alice-johnson-456']
|
|
1375
|
-
}
|
|
1376
|
-
]
|
|
1377
|
-
},
|
|
1378
|
-
'atlassian:position': {
|
|
1379
|
-
customAndSensitiveData: 'Salary range: $120,000-$150,000. Remote work eligible.',
|
|
1380
|
-
status: 'Open',
|
|
1381
|
-
jobTitle: 'Senior Software Engineer - Backend'
|
|
1382
|
-
}
|
|
1383
|
-
};
|
|
1384
|
-
const req = { objects: [positionObject] };
|
|
1385
|
-
const backendResponse = {
|
|
1386
|
-
accepted: [
|
|
1387
|
-
{
|
|
1388
|
-
entityType: 'atlassian:position',
|
|
1389
|
-
entityId: { id: 'position-1' },
|
|
1390
|
-
thirdPartyAri: 'ari:third-party:test::position/position-1'
|
|
1391
|
-
}
|
|
1392
|
-
]
|
|
1393
|
-
};
|
|
1394
|
-
const expected = {
|
|
1395
|
-
success: true,
|
|
1396
|
-
results: { accepted: backendResponse.accepted, rejected: undefined, validEntities: undefined }
|
|
1397
|
-
};
|
|
1398
|
-
mockFetch.mockResolvedValueOnce({
|
|
1399
|
-
ok: true,
|
|
1400
|
-
json: () => Promise.resolve(backendResponse)
|
|
1401
|
-
});
|
|
1402
|
-
const result = await graphClient.setObjects(req);
|
|
1403
|
-
expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.OBJECTS.BULK), expect.objectContaining({ method: 'POST' }));
|
|
1404
|
-
expect(result).toEqual(expected);
|
|
1405
|
-
});
|
|
1406
1289
|
it('posts project entities to /api/v1/entities/bulk and returns response', async () => {
|
|
1407
1290
|
const projectObject = {
|
|
1408
1291
|
schemaVersion: '2.0',
|
|
@@ -1978,7 +1861,6 @@ describe('TeamWorkGraphClient - bulk entities', () => {
|
|
|
1978
1861
|
],
|
|
1979
1862
|
exceedsMaxCollaborators: false,
|
|
1980
1863
|
status: 'In Progress',
|
|
1981
|
-
subtype: 'Development Task',
|
|
1982
1864
|
attachments: [
|
|
1983
1865
|
{
|
|
1984
1866
|
url: 'https://files.example.com/auth-api-spec.pdf',
|
|
@@ -2020,60 +1902,6 @@ describe('TeamWorkGraphClient - bulk entities', () => {
|
|
|
2020
1902
|
expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.OBJECTS.BULK), expect.objectContaining({ method: 'POST' }));
|
|
2021
1903
|
expect(result).toEqual(expected);
|
|
2022
1904
|
});
|
|
2023
|
-
it('posts worker entities to /api/v1/entities/bulk and returns response', async () => {
|
|
2024
|
-
const workerObject = {
|
|
2025
|
-
schemaVersion: '2.0',
|
|
2026
|
-
id: 'worker-1',
|
|
2027
|
-
updateSequenceNumber: 1,
|
|
2028
|
-
displayName: 'Sarah Johnson - Senior Software Engineer',
|
|
2029
|
-
url: 'https://hr.example.com/employees/sarah-johnson',
|
|
2030
|
-
createdAt: '2024-07-09T14:27:37.000Z',
|
|
2031
|
-
lastUpdatedAt: '2024-07-09T14:27:37.000Z',
|
|
2032
|
-
permissions: [
|
|
2033
|
-
{
|
|
2034
|
-
accessControls: [
|
|
2035
|
-
{
|
|
2036
|
-
principals: [
|
|
2037
|
-
{
|
|
2038
|
-
type: 'EVERYONE'
|
|
2039
|
-
}
|
|
2040
|
-
]
|
|
2041
|
-
}
|
|
2042
|
-
]
|
|
2043
|
-
}
|
|
2044
|
-
],
|
|
2045
|
-
'atlassian:worker': {
|
|
2046
|
-
hiredAt: '2022-03-15T09:00:00.000Z',
|
|
2047
|
-
workerUser: {
|
|
2048
|
-
accountId: 'worker-sarah-123',
|
|
2049
|
-
externalId: 'emp-sarah-456',
|
|
2050
|
-
email: 'sarah.johnson@example.com'
|
|
2051
|
-
},
|
|
2052
|
-
customAndSensitiveData: 'Employee ID: EMP001234, Department: Engineering, Salary Grade: L5, Manager: Alex Rodriguez, Office Location: San Francisco HQ'
|
|
2053
|
-
}
|
|
2054
|
-
};
|
|
2055
|
-
const req = { objects: [workerObject] };
|
|
2056
|
-
const backendResponse = {
|
|
2057
|
-
accepted: [
|
|
2058
|
-
{
|
|
2059
|
-
entityType: 'atlassian:worker',
|
|
2060
|
-
entityId: { id: 'worker-1' },
|
|
2061
|
-
thirdPartyAri: 'ari:third-party:test::worker/worker-1'
|
|
2062
|
-
}
|
|
2063
|
-
]
|
|
2064
|
-
};
|
|
2065
|
-
const expected = {
|
|
2066
|
-
success: true,
|
|
2067
|
-
results: { accepted: backendResponse.accepted, rejected: undefined, validEntities: undefined }
|
|
2068
|
-
};
|
|
2069
|
-
mockFetch.mockResolvedValueOnce({
|
|
2070
|
-
ok: true,
|
|
2071
|
-
json: () => Promise.resolve(backendResponse)
|
|
2072
|
-
});
|
|
2073
|
-
const result = await graphClient.setObjects(req);
|
|
2074
|
-
expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.OBJECTS.BULK), expect.objectContaining({ method: 'POST' }));
|
|
2075
|
-
expect(result).toEqual(expected);
|
|
2076
|
-
});
|
|
2077
1905
|
it('posts dashboard entities to /api/v1/entities/bulk and returns response', async () => {
|
|
2078
1906
|
const dashboardObject = {
|
|
2079
1907
|
schemaVersion: '2.0',
|
|
@@ -47,4 +47,99 @@ describe('TeamWorkGraphClient - Error Handling Functions', () => {
|
|
|
47
47
|
expect(deleteResult.originalError).toBe(error);
|
|
48
48
|
});
|
|
49
49
|
});
|
|
50
|
+
describe('handleResponseError', () => {
|
|
51
|
+
test('should extract trace ID from atl-traceid header and include it in error message', async () => {
|
|
52
|
+
const mockResponse = {
|
|
53
|
+
ok: false,
|
|
54
|
+
status: 500,
|
|
55
|
+
statusText: 'Internal Server Error',
|
|
56
|
+
headers: {
|
|
57
|
+
get: jest.fn((headerName) => {
|
|
58
|
+
if (headerName === 'atl-traceid') {
|
|
59
|
+
return 'trace-12345-abcdef';
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
})
|
|
63
|
+
},
|
|
64
|
+
json: jest.fn().mockResolvedValue({
|
|
65
|
+
message: 'Something went wrong',
|
|
66
|
+
code: 'INTERNAL_ERROR'
|
|
67
|
+
})
|
|
68
|
+
};
|
|
69
|
+
try {
|
|
70
|
+
await (0, error_handling_1.handleResponseError)(mockResponse, 'API request failed');
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
expect(error).toBeInstanceOf(errors_1.ForgeTeamWorkGraphAPIError);
|
|
74
|
+
expect(error.message).toContain('Internal Server Error - Something went wrong');
|
|
75
|
+
expect(error.message).toContain('(Trace ID: trace-12345-abcdef)');
|
|
76
|
+
expect(error.traceId).toBe('trace-12345-abcdef');
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
test('should handle response without trace ID', async () => {
|
|
80
|
+
const mockResponse = {
|
|
81
|
+
ok: false,
|
|
82
|
+
status: 404,
|
|
83
|
+
statusText: 'Not Found',
|
|
84
|
+
headers: {
|
|
85
|
+
get: jest.fn(() => null)
|
|
86
|
+
},
|
|
87
|
+
json: jest.fn().mockResolvedValue({
|
|
88
|
+
message: 'Resource not found'
|
|
89
|
+
})
|
|
90
|
+
};
|
|
91
|
+
try {
|
|
92
|
+
await (0, error_handling_1.handleResponseError)(mockResponse, 'API request failed');
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
expect(error).toBeInstanceOf(errors_1.ForgeTeamWorkGraphAPIError);
|
|
96
|
+
expect(error.message).toContain('Not Found - Resource not found');
|
|
97
|
+
expect(error.message).not.toContain('Trace ID:');
|
|
98
|
+
expect(error.traceId).toBeUndefined();
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
test('should handle response with unparseable JSON and trace ID', async () => {
|
|
102
|
+
const mockResponse = {
|
|
103
|
+
ok: false,
|
|
104
|
+
status: 502,
|
|
105
|
+
statusText: 'Bad Gateway',
|
|
106
|
+
headers: {
|
|
107
|
+
get: jest.fn((headerName) => {
|
|
108
|
+
if (headerName === 'atl-traceid') {
|
|
109
|
+
return 'trace-99999-xyz';
|
|
110
|
+
}
|
|
111
|
+
return null;
|
|
112
|
+
})
|
|
113
|
+
},
|
|
114
|
+
json: jest.fn().mockRejectedValue(new Error('Invalid JSON'))
|
|
115
|
+
};
|
|
116
|
+
try {
|
|
117
|
+
await (0, error_handling_1.handleResponseError)(mockResponse, 'API request failed');
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
expect(error).toBeInstanceOf(errors_1.ForgeTeamWorkGraphAPIError);
|
|
121
|
+
expect(error.message).toContain('Bad Gateway - API request failed: HTTP 502 - Bad Gateway');
|
|
122
|
+
expect(error.message).toContain('(Trace ID: trace-99999-xyz)');
|
|
123
|
+
expect(error.traceId).toBe('trace-99999-xyz');
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
describe('ForgeTeamWorkGraphAPIError with trace ID', () => {
|
|
128
|
+
test('should create API error with trace ID', () => {
|
|
129
|
+
const error = new errors_1.ForgeTeamWorkGraphAPIError('Test error message', 500, { details: 'Some details' }, 'trace-12345');
|
|
130
|
+
expect(error.message).toBe('Test error message');
|
|
131
|
+
expect(error.status).toBe(500);
|
|
132
|
+
expect(error.responseBody).toEqual({ details: 'Some details' });
|
|
133
|
+
expect(error.traceId).toBe('trace-12345');
|
|
134
|
+
expect(error.code).toBe('API_ERROR');
|
|
135
|
+
});
|
|
136
|
+
test('should create API error without trace ID', () => {
|
|
137
|
+
const error = new errors_1.ForgeTeamWorkGraphAPIError('Test error message', 400, { details: 'Some details' });
|
|
138
|
+
expect(error.message).toBe('Test error message');
|
|
139
|
+
expect(error.status).toBe(400);
|
|
140
|
+
expect(error.responseBody).toEqual({ details: 'Some details' });
|
|
141
|
+
expect(error.traceId).toBeUndefined();
|
|
142
|
+
expect(error.code).toBe('API_ERROR');
|
|
143
|
+
});
|
|
144
|
+
});
|
|
50
145
|
});
|
|
@@ -11,8 +11,6 @@ import { DeploymentObject } from './deployment';
|
|
|
11
11
|
import { DesignObject } from './design';
|
|
12
12
|
import { DocumentObject } from './document';
|
|
13
13
|
import { MessageObject } from './message';
|
|
14
|
-
import { OrganisationObject } from './organisation';
|
|
15
|
-
import { PositionObject } from './position';
|
|
16
14
|
import { ProjectObject } from './project';
|
|
17
15
|
import { PullRequestObject } from './pull-request';
|
|
18
16
|
import { RemoteLinkObject } from './remote-link';
|
|
@@ -25,7 +23,6 @@ import { TestPlanObject } from './test-plan';
|
|
|
25
23
|
import { TestRunObject } from './test-run';
|
|
26
24
|
import { VideoObject } from './video';
|
|
27
25
|
import { WorkItemObject } from './work-item';
|
|
28
|
-
|
|
29
|
-
export
|
|
30
|
-
export declare type Object = BranchObject | BuildObject | CalendarEventObject | CommentObject | CommitObject | ConversationObject | CustomerOrgObject | DashboardObject | DealObject | DeploymentObject | DesignObject | DocumentObject | MessageObject | OrganisationObject | PositionObject | ProjectObject | PullRequestObject | RemoteLinkObject | RepositoryObject | SoftwareServiceObject | SpaceObject | TestObject | TestExecutionObject | TestPlanObject | TestRunObject | VideoObject | WorkItemObject | WorkerObject;
|
|
26
|
+
export { BranchObject, BuildObject, CalendarEventObject, CommentObject, CommitObject, ConversationObject, CustomerOrgObject, DashboardObject, DealObject, DeploymentObject, DesignObject, DocumentObject, MessageObject, ProjectObject, PullRequestObject, RemoteLinkObject, RepositoryObject, SoftwareServiceObject, SpaceObject, TestObject, TestExecutionObject, TestPlanObject, TestRunObject, VideoObject, WorkItemObject };
|
|
27
|
+
export declare type Object = BranchObject | BuildObject | CalendarEventObject | CommentObject | CommitObject | ConversationObject | CustomerOrgObject | DashboardObject | DealObject | DeploymentObject | DesignObject | DocumentObject | MessageObject | ProjectObject | PullRequestObject | RemoteLinkObject | RepositoryObject | SoftwareServiceObject | SpaceObject | TestObject | TestExecutionObject | TestPlanObject | TestRunObject | VideoObject | WorkItemObject;
|
|
31
28
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/objects/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/objects/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAG7C,OAAO,EACL,YAAY,EACZ,WAAW,EACX,mBAAmB,EACnB,aAAa,EACb,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,UAAU,EACV,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,qBAAqB,EACrB,WAAW,EACX,UAAU,EACV,mBAAmB,EACnB,cAAc,EACd,aAAa,EACb,WAAW,EACX,cAAc,EACf,CAAC;AAGF,oBAAY,MAAM,GACd,YAAY,GACZ,WAAW,GACX,mBAAmB,GACnB,aAAa,GACb,YAAY,GACZ,kBAAkB,GAClB,iBAAiB,GACjB,eAAe,GACf,UAAU,GACV,gBAAgB,GAChB,YAAY,GACZ,cAAc,GACd,aAAa,GACb,aAAa,GACb,iBAAiB,GACjB,gBAAgB,GAChB,gBAAgB,GAChB,qBAAqB,GACrB,WAAW,GACX,UAAU,GACV,mBAAmB,GACnB,cAAc,GACd,aAAa,GACb,WAAW,GACX,cAAc,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;AAgBzC,wBAAsB,mBAAmB,CAAC,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,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,CA4DhG;AAwBD,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,GAAG,CAAC,CAQnE"}
|
|
@@ -4,6 +4,7 @@ exports.handleError = exports.handleResponseError = void 0;
|
|
|
4
4
|
const errors_1 = require("./errors");
|
|
5
5
|
async function handleResponseError(response, context) {
|
|
6
6
|
let errorDetails;
|
|
7
|
+
const traceId = response.headers.get('atl-traceid') ?? undefined;
|
|
7
8
|
try {
|
|
8
9
|
const responseBody = await response.json();
|
|
9
10
|
errorDetails = {
|
|
@@ -48,7 +49,10 @@ async function handleResponseError(response, context) {
|
|
|
48
49
|
default:
|
|
49
50
|
errorMessage = `HTTP ${response.status} - ${errorDetails.message}`;
|
|
50
51
|
}
|
|
51
|
-
|
|
52
|
+
if (traceId) {
|
|
53
|
+
errorMessage += ` (Trace ID: ${traceId})`;
|
|
54
|
+
}
|
|
55
|
+
throw new errors_1.ForgeTeamWorkGraphAPIError(errorMessage, response.status, errorDetails.details, traceId);
|
|
52
56
|
}
|
|
53
57
|
exports.handleResponseError = handleResponseError;
|
|
54
58
|
function createErrorMessage(error, operation) {
|
package/out/utils/errors.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export declare class ForgeTeamWorkGraphNetworkError extends ForgeTeamWorkGraphEr
|
|
|
13
13
|
export declare class ForgeTeamWorkGraphAPIError extends ForgeTeamWorkGraphError {
|
|
14
14
|
readonly status: number;
|
|
15
15
|
readonly responseBody?: any;
|
|
16
|
-
|
|
16
|
+
readonly traceId?: string;
|
|
17
|
+
constructor(message: string, status: number, responseBody?: any, traceId?: string);
|
|
17
18
|
}
|
|
18
19
|
//# 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;
|
|
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;IACnC,SAAgB,OAAO,CAAC,EAAE,MAAM,CAAC;gBAErB,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM;CAMlF"}
|
package/out/utils/errors.js
CHANGED
|
@@ -29,10 +29,12 @@ exports.ForgeTeamWorkGraphNetworkError = ForgeTeamWorkGraphNetworkError;
|
|
|
29
29
|
class ForgeTeamWorkGraphAPIError extends ForgeTeamWorkGraphError {
|
|
30
30
|
status;
|
|
31
31
|
responseBody;
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
traceId;
|
|
33
|
+
constructor(message, status, responseBody, traceId) {
|
|
34
|
+
super(message, 'API_ERROR', undefined, { status, responseBody, traceId });
|
|
34
35
|
this.status = status;
|
|
35
36
|
this.responseBody = responseBody;
|
|
37
|
+
this.traceId = traceId;
|
|
36
38
|
}
|
|
37
39
|
}
|
|
38
40
|
exports.ForgeTeamWorkGraphAPIError = ForgeTeamWorkGraphAPIError;
|
package/package.json
CHANGED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { BaseObjectProperties } from './common';
|
|
2
|
-
export declare type OrganisationAttributes = {};
|
|
3
|
-
export declare type OrganisationObject = BaseObjectProperties & {
|
|
4
|
-
displayName: string;
|
|
5
|
-
lastUpdatedAt: string;
|
|
6
|
-
permissions: NonNullable<BaseObjectProperties['permissions']>;
|
|
7
|
-
'atlassian:organisation': OrganisationAttributes;
|
|
8
|
-
};
|
|
9
|
-
//# sourceMappingURL=organisation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"organisation.d.ts","sourceRoot":"","sources":["../../../src/types/objects/organisation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAEhD,oBAAY,sBAAsB,GAAG,EAAE,CAAC;AAExC,oBAAY,kBAAkB,GAAG,oBAAoB,GAAG;IACtD,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,WAAW,CAAC,oBAAoB,CAAC,aAAa,CAAC,CAAC,CAAC;IAC9D,wBAAwB,EAAE,sBAAsB,CAAC;CAClD,CAAC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { BaseObjectProperties, ParentKeyObject, Associations } from './common';
|
|
2
|
-
export declare type PositionAttributes = {
|
|
3
|
-
customAndSensitiveData?: string;
|
|
4
|
-
status: string;
|
|
5
|
-
jobTitle?: string;
|
|
6
|
-
};
|
|
7
|
-
export declare type PositionObject = BaseObjectProperties & {
|
|
8
|
-
displayName: string;
|
|
9
|
-
lastUpdatedAt: string;
|
|
10
|
-
permissions: NonNullable<BaseObjectProperties['permissions']>;
|
|
11
|
-
parentKey: ParentKeyObject & {
|
|
12
|
-
type: 'atlassian:organisation';
|
|
13
|
-
};
|
|
14
|
-
associations: Associations & {
|
|
15
|
-
set: [
|
|
16
|
-
{
|
|
17
|
-
associationType: 'atlassian:worker';
|
|
18
|
-
values: [string] | [];
|
|
19
|
-
}
|
|
20
|
-
];
|
|
21
|
-
};
|
|
22
|
-
'atlassian:position': PositionAttributes;
|
|
23
|
-
};
|
|
24
|
-
//# sourceMappingURL=position.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"position.d.ts","sourceRoot":"","sources":["../../../src/types/objects/position.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE/E,oBAAY,kBAAkB,GAAG;IAC/B,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,oBAAY,cAAc,GAAG,oBAAoB,GAAG;IAClD,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,WAAW,CAAC,oBAAoB,CAAC,aAAa,CAAC,CAAC,CAAC;IAC9D,SAAS,EAAE,eAAe,GAAG;QAAE,IAAI,EAAE,wBAAwB,CAAA;KAAE,CAAC;IAChE,YAAY,EAAE,YAAY,GAAG;QAC3B,GAAG,EAAE;YACH;gBACE,eAAe,EAAE,kBAAkB,CAAC;gBACpC,MAAM,EAAE,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;aACvB;SACF,CAAC;KACH,CAAC;IACF,oBAAoB,EAAE,kBAAkB,CAAC;CAC1C,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { BaseObjectProperties, UserReference } from './common';
|
|
2
|
-
export declare type WorkerAttributes = {
|
|
3
|
-
hiredAt: string;
|
|
4
|
-
workerUser: UserReference;
|
|
5
|
-
customAndSensitiveData?: string;
|
|
6
|
-
};
|
|
7
|
-
export declare type WorkerObject = BaseObjectProperties & {
|
|
8
|
-
displayName: string;
|
|
9
|
-
lastUpdatedAt: string;
|
|
10
|
-
permissions: NonNullable<BaseObjectProperties['permissions']>;
|
|
11
|
-
'atlassian:worker': WorkerAttributes;
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=worker.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../../src/types/objects/worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE/D,oBAAY,gBAAgB,GAAG;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,aAAa,CAAC;IAC1B,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC,CAAC;AAEF,oBAAY,YAAY,GAAG,oBAAoB,GAAG;IAChD,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,WAAW,CAAC,oBAAoB,CAAC,aAAa,CAAC,CAAC,CAAC;IAC9D,kBAAkB,EAAE,gBAAgB,CAAC;CACtC,CAAC"}
|