@forge/teamwork-graph 1.2.0-next.5 → 2.0.0-experimental-8191ad1
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 +276 -169
- package/out/__test__/entity-operations.test.js +1155 -10
- package/out/__test__/error-handling.test.js +38 -96
- package/out/__test__/graph-extended.test.js +12 -2
- package/out/__test__/group-operations.test.js +5 -4
- package/out/__test__/user-operations.test.js +16 -5
- package/out/__test__/validators.test.js +254 -218
- package/out/graph.d.ts +0 -3
- package/out/graph.d.ts.map +1 -1
- package/out/graph.js +121 -91
- package/out/index.d.ts +1 -2
- package/out/index.d.ts.map +1 -1
- package/out/index.js +1 -4
- package/out/types/entities/build.d.ts +33 -0
- package/out/types/entities/build.d.ts.map +1 -0
- package/out/types/entities/build.js +2 -0
- package/out/types/entities/calendar-event.d.ts +45 -0
- package/out/types/entities/calendar-event.d.ts.map +1 -0
- package/out/types/entities/calendar-event.js +2 -0
- package/out/types/entities/comment.d.ts +18 -0
- package/out/types/entities/comment.d.ts.map +1 -0
- package/out/types/entities/comment.js +2 -0
- package/out/types/entities/conversation.d.ts +28 -0
- package/out/types/entities/conversation.d.ts.map +1 -0
- package/out/types/entities/conversation.js +2 -0
- package/out/types/entities/customer-org.d.ts +36 -0
- package/out/types/entities/customer-org.d.ts.map +1 -0
- package/out/types/entities/customer-org.js +2 -0
- package/out/types/entities/deal.d.ts +37 -0
- package/out/types/entities/deal.d.ts.map +1 -0
- package/out/types/entities/deal.js +2 -0
- package/out/types/entities/deployment.d.ts +43 -0
- package/out/types/entities/deployment.d.ts.map +1 -0
- package/out/types/entities/deployment.js +2 -0
- package/out/types/entities/design.d.ts +15 -0
- package/out/types/entities/design.d.ts.map +1 -0
- package/out/types/entities/design.js +2 -0
- package/out/types/entities/index.d.ts +20 -2
- package/out/types/entities/index.d.ts.map +1 -1
- package/out/types/entities/position.d.ts +24 -0
- package/out/types/entities/position.d.ts.map +1 -0
- package/out/types/entities/position.js +2 -0
- package/out/types/entities/project.d.ts +40 -0
- package/out/types/entities/project.d.ts.map +1 -0
- package/out/types/entities/project.js +2 -0
- package/out/types/entities/pull-request.d.ts +44 -0
- package/out/types/entities/pull-request.d.ts.map +1 -0
- package/out/types/entities/pull-request.js +2 -0
- package/out/types/entities/remote-link.d.ts +33 -0
- package/out/types/entities/remote-link.d.ts.map +1 -0
- package/out/types/entities/remote-link.js +2 -0
- package/out/types/entities/repository.d.ts +14 -0
- package/out/types/entities/repository.d.ts.map +1 -0
- package/out/types/entities/repository.js +2 -0
- package/out/types/entities/software-service.d.ts +17 -0
- package/out/types/entities/software-service.d.ts.map +1 -0
- package/out/types/entities/software-service.js +2 -0
- package/out/types/entities/space.d.ts +21 -0
- package/out/types/entities/space.d.ts.map +1 -0
- package/out/types/entities/space.js +2 -0
- package/out/types/entities/video.d.ts +48 -0
- package/out/types/entities/video.d.ts.map +1 -0
- package/out/types/entities/video.js +2 -0
- package/out/types/entities/work-item.d.ts +44 -0
- package/out/types/entities/work-item.d.ts.map +1 -0
- package/out/types/entities/work-item.js +2 -0
- package/out/types/entities/worker.d.ts +23 -0
- package/out/types/entities/worker.d.ts.map +1 -0
- package/out/types/entities/worker.js +2 -0
- package/out/types/requests.d.ts +29 -8
- package/out/types/requests.d.ts.map +1 -1
- package/out/utils/error-handling.d.ts +4 -0
- package/out/utils/error-handling.d.ts.map +1 -0
- package/out/utils/error-handling.js +77 -0
- package/out/utils/errors.d.ts +21 -15
- package/out/utils/errors.d.ts.map +1 -1
- package/out/utils/errors.js +43 -15
- package/out/utils/validators.d.ts.map +1 -1
- package/out/utils/validators.js +18 -15
- package/package.json +2 -2
- package/out/error-handling.d.ts +0 -3
- package/out/error-handling.d.ts.map +0 -1
- package/out/error-handling.js +0 -36
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requests.d.ts","sourceRoot":"","sources":["../../src/types/requests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,WAAW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AE,GAAG,KAAK,GAAG,CAAC;CACrC,CAAC;AAEF,oBAAY,qBAAqB,GAAG;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,CAAC,EAAE,GAAG,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC"}
|
|
@@ -0,0 +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;AAiBzC,wBAAsB,mBAAmB,CAAC,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAoDhG;AA2BD,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,GAAG,CAAC,CAQnE"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleError = exports.handleResponseError = void 0;
|
|
4
|
+
const errors_1 = require("./errors");
|
|
5
|
+
async function handleResponseError(response, context) {
|
|
6
|
+
let errorDetails;
|
|
7
|
+
try {
|
|
8
|
+
const responseBody = await response.json();
|
|
9
|
+
errorDetails = {
|
|
10
|
+
message: responseBody.message || `HTTP ${response.status}: ${response.statusText}`,
|
|
11
|
+
code: responseBody.code,
|
|
12
|
+
details: responseBody.details || responseBody
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
errorDetails = {
|
|
17
|
+
message: `${context}: HTTP ${response.status} - ${response.statusText}`,
|
|
18
|
+
code: `HTTP_${response.status}`,
|
|
19
|
+
details: { status: response.status, statusText: response.statusText }
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
let errorMessage;
|
|
23
|
+
switch (response.status) {
|
|
24
|
+
case 400:
|
|
25
|
+
errorMessage = `Bad Request - ${errorDetails.message}`;
|
|
26
|
+
break;
|
|
27
|
+
case 401:
|
|
28
|
+
errorMessage = `Unauthorized - ${errorDetails.message}`;
|
|
29
|
+
break;
|
|
30
|
+
case 403:
|
|
31
|
+
errorMessage = `Forbidden - ${errorDetails.message}`;
|
|
32
|
+
break;
|
|
33
|
+
case 404:
|
|
34
|
+
errorMessage = `Not Found - ${errorDetails.message}`;
|
|
35
|
+
break;
|
|
36
|
+
case 429:
|
|
37
|
+
errorMessage = `Rate Limited - ${errorDetails.message}`;
|
|
38
|
+
break;
|
|
39
|
+
case 500:
|
|
40
|
+
errorMessage = `Internal Server Error - ${errorDetails.message}`;
|
|
41
|
+
break;
|
|
42
|
+
case 502:
|
|
43
|
+
errorMessage = `Bad Gateway - ${errorDetails.message}`;
|
|
44
|
+
break;
|
|
45
|
+
case 503:
|
|
46
|
+
errorMessage = `Service Unavailable - ${errorDetails.message}`;
|
|
47
|
+
break;
|
|
48
|
+
default:
|
|
49
|
+
errorMessage = `HTTP ${response.status} - ${errorDetails.message}`;
|
|
50
|
+
}
|
|
51
|
+
throw new errors_1.ForgeTeamWorkGraphAPIError(errorMessage, response.status, errorDetails.details);
|
|
52
|
+
}
|
|
53
|
+
exports.handleResponseError = handleResponseError;
|
|
54
|
+
function createErrorMessage(error, operation) {
|
|
55
|
+
if (error instanceof errors_1.ForgeTeamWorkGraphValidationError) {
|
|
56
|
+
return error.message;
|
|
57
|
+
}
|
|
58
|
+
if (error instanceof errors_1.ForgeTeamWorkGraphAPIError) {
|
|
59
|
+
return `Failed to ${operation}: ${error.message}`;
|
|
60
|
+
}
|
|
61
|
+
if (error instanceof errors_1.ForgeTeamWorkGraphFetchError) {
|
|
62
|
+
return error.message;
|
|
63
|
+
}
|
|
64
|
+
if (error instanceof errors_1.ForgeTeamWorkGraphTransformError) {
|
|
65
|
+
return error.message;
|
|
66
|
+
}
|
|
67
|
+
return `Failed to ${operation}: ${error instanceof Error ? error.message : 'Unknown error'}`;
|
|
68
|
+
}
|
|
69
|
+
function handleError(error, operation) {
|
|
70
|
+
const errorMessage = createErrorMessage(error, operation);
|
|
71
|
+
return {
|
|
72
|
+
success: false,
|
|
73
|
+
error: errorMessage,
|
|
74
|
+
originalError: error
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
exports.handleError = handleError;
|
package/out/utils/errors.d.ts
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
1
|
-
export declare
|
|
2
|
-
readonly UNKNOWN_ERROR: "UNKNOWN_ERROR";
|
|
3
|
-
readonly INVALID_REQUEST_BODY: "INVALID_REQUEST_BODY";
|
|
4
|
-
readonly INSUFFICIENT_SCOPE: "INSUFFICIENT_SCOPE";
|
|
5
|
-
readonly TOO_MANY_REQUESTS: "TOO_MANY_REQUESTS";
|
|
6
|
-
};
|
|
7
|
-
export interface APIErrorResponseDetails {
|
|
8
|
-
status: number;
|
|
9
|
-
statusText: string;
|
|
10
|
-
traceId?: string | null;
|
|
11
|
-
}
|
|
12
|
-
export declare class ForgeGraphAPIError extends Error {
|
|
13
|
-
readonly responseDetails: APIErrorResponseDetails;
|
|
1
|
+
export declare class ForgeTeamWorkGraphError extends Error {
|
|
14
2
|
readonly code: string;
|
|
15
|
-
readonly
|
|
16
|
-
|
|
3
|
+
readonly field?: string;
|
|
4
|
+
readonly details?: any;
|
|
5
|
+
constructor(message: string, code: string, field?: string, details?: any);
|
|
6
|
+
}
|
|
7
|
+
export declare class ForgeTeamWorkGraphValidationError extends ForgeTeamWorkGraphError {
|
|
8
|
+
constructor(message: string, field?: string, details?: any);
|
|
9
|
+
}
|
|
10
|
+
export declare class ForgeTeamWorkGraphNetworkError extends ForgeTeamWorkGraphError {
|
|
11
|
+
constructor(message: string, cause?: Error);
|
|
12
|
+
}
|
|
13
|
+
export declare class ForgeTeamWorkGraphAPIError extends ForgeTeamWorkGraphError {
|
|
14
|
+
readonly status: number;
|
|
15
|
+
readonly responseBody?: any;
|
|
16
|
+
constructor(message: string, status: number, responseBody?: any);
|
|
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);
|
|
17
23
|
}
|
|
18
24
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"
|
|
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;AAKD,qBAAa,4BAA6B,SAAQ,uBAAuB;gBAC3D,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;CAG3C;AAKD,qBAAa,gCAAiC,SAAQ,uBAAuB;gBAC/D,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;CAG3C"}
|
package/out/utils/errors.js
CHANGED
|
@@ -1,22 +1,50 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
UNKNOWN_ERROR: 'UNKNOWN_ERROR',
|
|
6
|
-
INVALID_REQUEST_BODY: 'INVALID_REQUEST_BODY',
|
|
7
|
-
INSUFFICIENT_SCOPE: 'INSUFFICIENT_SCOPE',
|
|
8
|
-
TOO_MANY_REQUESTS: 'TOO_MANY_REQUESTS'
|
|
9
|
-
};
|
|
10
|
-
class ForgeGraphAPIError extends Error {
|
|
11
|
-
responseDetails;
|
|
3
|
+
exports.ForgeTeamWorkGraphTransformError = exports.ForgeTeamWorkGraphFetchError = exports.ForgeTeamWorkGraphAPIError = exports.ForgeTeamWorkGraphNetworkError = exports.ForgeTeamWorkGraphValidationError = exports.ForgeTeamWorkGraphError = void 0;
|
|
4
|
+
class ForgeTeamWorkGraphError extends Error {
|
|
12
5
|
code;
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
field;
|
|
7
|
+
details;
|
|
8
|
+
constructor(message, code, field, details) {
|
|
15
9
|
super(message);
|
|
16
|
-
this.
|
|
10
|
+
this.name = this.constructor.name;
|
|
17
11
|
this.code = code;
|
|
18
|
-
this.
|
|
19
|
-
this.
|
|
12
|
+
this.field = field;
|
|
13
|
+
this.details = details;
|
|
20
14
|
}
|
|
21
15
|
}
|
|
22
|
-
exports.
|
|
16
|
+
exports.ForgeTeamWorkGraphError = ForgeTeamWorkGraphError;
|
|
17
|
+
class ForgeTeamWorkGraphValidationError extends ForgeTeamWorkGraphError {
|
|
18
|
+
constructor(message, field, details) {
|
|
19
|
+
super(message, 'VALIDATION_ERROR', field, details);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.ForgeTeamWorkGraphValidationError = ForgeTeamWorkGraphValidationError;
|
|
23
|
+
class ForgeTeamWorkGraphNetworkError extends ForgeTeamWorkGraphError {
|
|
24
|
+
constructor(message, cause) {
|
|
25
|
+
super(message, 'NETWORK_ERROR', undefined, { cause: cause?.message });
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.ForgeTeamWorkGraphNetworkError = ForgeTeamWorkGraphNetworkError;
|
|
29
|
+
class ForgeTeamWorkGraphAPIError extends ForgeTeamWorkGraphError {
|
|
30
|
+
status;
|
|
31
|
+
responseBody;
|
|
32
|
+
constructor(message, status, responseBody) {
|
|
33
|
+
super(message, 'API_ERROR', undefined, { status, responseBody });
|
|
34
|
+
this.status = status;
|
|
35
|
+
this.responseBody = responseBody;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
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;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../src/utils/validators.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../src/utils/valid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I,CAE3E;AAKD,wBAAgB,mCAAmC,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAE5E;AAKD,wBAAgB,uBAAuB,CAAC,cAAc,EAAE,GAAG,EAAE,GAAG,IAAI,CAqBnE;AAKD,wBAAgB,yCAAyC,CAAC,UAAU,EAAE,GAAG,GAAG,IAAI,CAE/E;AAKD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,GAAG,GAAG,IAAI,CA0B3D;AAKD,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,GAAG,GAAG,IAAI,CAW/D"}
|
package/out/utils/validators.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.validateTransformDataRequest = exports.validateFetchDataRequest = exports.validateDeleteEntitiesByPropertiesRequest = exports.validateMapUsersRequest = exports.validateGetGroupByExternalIdRequest = exports.validateGetUserByExternalIdRequest = exports.validateGetEntityByExternalIdRequest = exports.validateDeleteGroupsByExternalIdRequest = exports.validateDeleteUsersByExternalIdRequest = exports.validateDeleteEntitiesByExternalIdRequest = exports.validateSetGroupsRequest = exports.validateSetUsersRequest = exports.validateSetEntitiesRequest = exports.validateObject = exports.validateRequiredString = exports.validateArrayMaxLength = exports.validateArray = exports.MAX_USER_MAPPINGS = exports.MAX_BULK_ENTITIES_DELETE = exports.MAX_BULK_GROUPS = exports.MAX_BULK_USERS = exports.MAX_BULK_ENTITIES = void 0;
|
|
4
|
+
const errors_1 = require("./errors");
|
|
4
5
|
exports.MAX_BULK_ENTITIES = 100;
|
|
5
6
|
exports.MAX_BULK_USERS = 100;
|
|
6
7
|
exports.MAX_BULK_GROUPS = 100;
|
|
@@ -8,31 +9,31 @@ exports.MAX_BULK_ENTITIES_DELETE = 100;
|
|
|
8
9
|
exports.MAX_USER_MAPPINGS = 100;
|
|
9
10
|
function validateArray(value, fieldName) {
|
|
10
11
|
if (!Array.isArray(value)) {
|
|
11
|
-
throw new
|
|
12
|
+
throw new errors_1.ForgeTeamWorkGraphValidationError(`${fieldName} must be an array`, fieldName);
|
|
12
13
|
}
|
|
13
14
|
if (value.length === 0) {
|
|
14
|
-
throw new
|
|
15
|
+
throw new errors_1.ForgeTeamWorkGraphValidationError(`${fieldName} array cannot be empty`, fieldName);
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
18
|
exports.validateArray = validateArray;
|
|
18
19
|
function validateArrayMaxLength(value, fieldName, maxLength, itemType = 'items') {
|
|
19
20
|
if (value.length > maxLength) {
|
|
20
|
-
throw new
|
|
21
|
+
throw new errors_1.ForgeTeamWorkGraphValidationError(`${fieldName} supports maximum ${maxLength} ${itemType}. Received ${value.length}`, fieldName, { maxLength, actualLength: value.length, itemType });
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
exports.validateArrayMaxLength = validateArrayMaxLength;
|
|
24
25
|
function validateRequiredString(value, fieldName) {
|
|
25
26
|
if (!value || value.trim() === '') {
|
|
26
|
-
throw new
|
|
27
|
+
throw new errors_1.ForgeTeamWorkGraphValidationError(`${fieldName} is required`, fieldName);
|
|
27
28
|
}
|
|
28
29
|
}
|
|
29
30
|
exports.validateRequiredString = validateRequiredString;
|
|
30
31
|
function validateObject(value, fieldName) {
|
|
31
32
|
if (!value || typeof value !== 'object') {
|
|
32
|
-
throw new
|
|
33
|
+
throw new errors_1.ForgeTeamWorkGraphValidationError(`${fieldName} must be an object`, fieldName);
|
|
33
34
|
}
|
|
34
35
|
if (Object.keys(value).length === 0) {
|
|
35
|
-
throw new
|
|
36
|
+
throw new errors_1.ForgeTeamWorkGraphValidationError(`${fieldName} object cannot be empty`, fieldName);
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
exports.validateObject = validateObject;
|
|
@@ -83,11 +84,13 @@ function validateMapUsersRequest(directMappings) {
|
|
|
83
84
|
validateArrayMaxLength(directMappings, 'Bulk user mapping', exports.MAX_USER_MAPPINGS, 'mappings');
|
|
84
85
|
const invalidMapping = directMappings.find((mapping) => !mapping.accountId && !mapping.externalEmailAddress);
|
|
85
86
|
if (invalidMapping) {
|
|
86
|
-
throw new
|
|
87
|
+
throw new errors_1.ForgeTeamWorkGraphValidationError('Each mapping must have either accountId or externalEmailAddress', 'directMappings', { invalidMapping });
|
|
87
88
|
}
|
|
88
89
|
const mappingWithoutExternalId = directMappings.find((mapping) => !mapping.externalId);
|
|
89
90
|
if (mappingWithoutExternalId) {
|
|
90
|
-
throw new
|
|
91
|
+
throw new errors_1.ForgeTeamWorkGraphValidationError('Each mapping must have an externalId', 'directMappings', {
|
|
92
|
+
mappingWithoutExternalId
|
|
93
|
+
});
|
|
91
94
|
}
|
|
92
95
|
}
|
|
93
96
|
exports.validateMapUsersRequest = validateMapUsersRequest;
|
|
@@ -97,28 +100,28 @@ function validateDeleteEntitiesByPropertiesRequest(properties) {
|
|
|
97
100
|
exports.validateDeleteEntitiesByPropertiesRequest = validateDeleteEntitiesByPropertiesRequest;
|
|
98
101
|
function validateFetchDataRequest(request) {
|
|
99
102
|
if (!request || typeof request !== 'object') {
|
|
100
|
-
throw new
|
|
103
|
+
throw new errors_1.ForgeTeamWorkGraphValidationError('request must be an object', 'request');
|
|
101
104
|
}
|
|
102
105
|
if (!request.requestConfig || typeof request.requestConfig !== 'object') {
|
|
103
|
-
throw new
|
|
106
|
+
throw new errors_1.ForgeTeamWorkGraphValidationError('requestConfig is required and must be an object', 'requestConfig');
|
|
104
107
|
}
|
|
105
108
|
if (!request.requestConfig.url || typeof request.requestConfig.url !== 'string') {
|
|
106
|
-
throw new
|
|
109
|
+
throw new errors_1.ForgeTeamWorkGraphValidationError('requestConfig.url is required and must be a string', 'requestConfig.url');
|
|
107
110
|
}
|
|
108
111
|
if (!request.requestConfig.method || typeof request.requestConfig.method !== 'string') {
|
|
109
|
-
throw new
|
|
112
|
+
throw new errors_1.ForgeTeamWorkGraphValidationError('requestConfig.method is required and must be a string', 'requestConfig.method');
|
|
110
113
|
}
|
|
111
114
|
if (!request.onResult || typeof request.onResult !== 'function') {
|
|
112
|
-
throw new
|
|
115
|
+
throw new errors_1.ForgeTeamWorkGraphValidationError('onResult is required and must be a function', 'onResult');
|
|
113
116
|
}
|
|
114
117
|
}
|
|
115
118
|
exports.validateFetchDataRequest = validateFetchDataRequest;
|
|
116
119
|
function validateTransformDataRequest(request) {
|
|
117
120
|
if (!request || typeof request !== 'object') {
|
|
118
|
-
throw new
|
|
121
|
+
throw new errors_1.ForgeTeamWorkGraphValidationError('request must be an object', 'request');
|
|
119
122
|
}
|
|
120
123
|
if (!request.transformMethod || typeof request.transformMethod !== 'function') {
|
|
121
|
-
throw new
|
|
124
|
+
throw new errors_1.ForgeTeamWorkGraphValidationError('transformMethod is required and must be a function', 'transformMethod');
|
|
122
125
|
}
|
|
123
126
|
}
|
|
124
127
|
exports.validateTransformDataRequest = validateTransformDataRequest;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge/teamwork-graph",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-experimental-8191ad1",
|
|
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.2
|
|
25
|
+
"@forge/api": "^6.0.2"
|
|
26
26
|
},
|
|
27
27
|
"publishConfig": {
|
|
28
28
|
"registry": "https://packages.atlassian.com/api/npm/npm-public/"
|
package/out/error-handling.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"error-handling.d.ts","sourceRoot":"","sources":["../src/error-handling.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAUzC,wBAAsB,mBAAmB,CAAC,QAAQ,EAAE,WAAW,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAwBvG"}
|
package/out/error-handling.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.handleResponseError = void 0;
|
|
4
|
-
const errors_1 = require("./utils/errors");
|
|
5
|
-
async function handleResponseError(response, defaultMessage) {
|
|
6
|
-
const details = {
|
|
7
|
-
status: response.status,
|
|
8
|
-
statusText: response.statusText,
|
|
9
|
-
traceId: response.headers.get('x-b3-traceid') || response.headers.get('x-trace-id')
|
|
10
|
-
};
|
|
11
|
-
const responseText = await response.text();
|
|
12
|
-
try {
|
|
13
|
-
const body = JSON.parse(responseText);
|
|
14
|
-
const code = body.code || getErrorCodeFromStatus(response.status);
|
|
15
|
-
const message = body.message || defaultMessage || 'Unknown error occurred';
|
|
16
|
-
throw new errors_1.ForgeGraphAPIError(details, code, message, body.context);
|
|
17
|
-
}
|
|
18
|
-
catch (error) {
|
|
19
|
-
if (error instanceof errors_1.ForgeGraphAPIError)
|
|
20
|
-
throw error;
|
|
21
|
-
throw new errors_1.ForgeGraphAPIError(details, errors_1.errorCodes.UNKNOWN_ERROR, defaultMessage || 'Failed to parse error response', { responseText });
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
exports.handleResponseError = handleResponseError;
|
|
25
|
-
function getErrorCodeFromStatus(status) {
|
|
26
|
-
switch (status) {
|
|
27
|
-
case 400:
|
|
28
|
-
return errors_1.errorCodes.INVALID_REQUEST_BODY;
|
|
29
|
-
case 403:
|
|
30
|
-
return errors_1.errorCodes.INSUFFICIENT_SCOPE;
|
|
31
|
-
case 429:
|
|
32
|
-
return errors_1.errorCodes.TOO_MANY_REQUESTS;
|
|
33
|
-
default:
|
|
34
|
-
return errors_1.errorCodes.UNKNOWN_ERROR;
|
|
35
|
-
}
|
|
36
|
-
}
|