@forge/teamwork-graph 2.0.0-next.6 → 2.0.0-next.7

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.
Files changed (55) hide show
  1. package/out/__test__/entity-operations.test.js +615 -10
  2. package/out/__test__/error-handling.test.js +38 -96
  3. package/out/__test__/graph-extended.test.js +12 -2
  4. package/out/__test__/group-operations.test.js +5 -4
  5. package/out/__test__/user-operations.test.js +16 -5
  6. package/out/__test__/validators.test.js +254 -218
  7. package/out/graph.d.ts +0 -3
  8. package/out/graph.d.ts.map +1 -1
  9. package/out/graph.js +121 -91
  10. package/out/index.d.ts +1 -2
  11. package/out/index.d.ts.map +1 -1
  12. package/out/index.js +1 -4
  13. package/out/types/entities/index.d.ts +11 -2
  14. package/out/types/entities/index.d.ts.map +1 -1
  15. package/out/types/entities/project.d.ts +40 -0
  16. package/out/types/entities/project.d.ts.map +1 -0
  17. package/out/types/entities/project.js +2 -0
  18. package/out/types/entities/pull-request.d.ts +44 -0
  19. package/out/types/entities/pull-request.d.ts.map +1 -0
  20. package/out/types/entities/pull-request.js +2 -0
  21. package/out/types/entities/remote-link.d.ts +33 -0
  22. package/out/types/entities/remote-link.d.ts.map +1 -0
  23. package/out/types/entities/remote-link.js +2 -0
  24. package/out/types/entities/repository.d.ts +14 -0
  25. package/out/types/entities/repository.d.ts.map +1 -0
  26. package/out/types/entities/repository.js +2 -0
  27. package/out/types/entities/software-service.d.ts +17 -0
  28. package/out/types/entities/software-service.d.ts.map +1 -0
  29. package/out/types/entities/software-service.js +2 -0
  30. package/out/types/entities/space.d.ts +21 -0
  31. package/out/types/entities/space.d.ts.map +1 -0
  32. package/out/types/entities/space.js +2 -0
  33. package/out/types/entities/video.d.ts +48 -0
  34. package/out/types/entities/video.d.ts.map +1 -0
  35. package/out/types/entities/video.js +2 -0
  36. package/out/types/entities/work-item.d.ts +44 -0
  37. package/out/types/entities/work-item.d.ts.map +1 -0
  38. package/out/types/entities/work-item.js +2 -0
  39. package/out/types/entities/worker.d.ts +23 -0
  40. package/out/types/entities/worker.d.ts.map +1 -0
  41. package/out/types/entities/worker.js +2 -0
  42. package/out/types/requests.d.ts +29 -8
  43. package/out/types/requests.d.ts.map +1 -1
  44. package/out/utils/error-handling.d.ts +4 -0
  45. package/out/utils/error-handling.d.ts.map +1 -0
  46. package/out/utils/error-handling.js +77 -0
  47. package/out/utils/errors.d.ts +21 -15
  48. package/out/utils/errors.d.ts.map +1 -1
  49. package/out/utils/errors.js +43 -15
  50. package/out/utils/validators.d.ts.map +1 -1
  51. package/out/utils/validators.js +18 -15
  52. package/package.json +1 -1
  53. package/out/error-handling.d.ts +0 -3
  54. package/out/error-handling.d.ts.map +0 -1
  55. package/out/error-handling.js +0 -36
@@ -0,0 +1,48 @@
1
+ import { BaseEntityProperties } from '../common';
2
+ export interface UserReference {
3
+ accountId?: string;
4
+ email?: string;
5
+ externalId?: string;
6
+ ari?: string;
7
+ name?: string;
8
+ userName?: string;
9
+ avatar?: string;
10
+ url?: string;
11
+ }
12
+ export interface Cue {
13
+ id?: string;
14
+ startTimeInSeconds: number;
15
+ endTimeInSeconds?: number;
16
+ text: string;
17
+ }
18
+ export interface Track {
19
+ name?: string;
20
+ locale?: string;
21
+ cues: Cue[];
22
+ }
23
+ export interface Chapter {
24
+ startTimeInSeconds: number;
25
+ title: string;
26
+ }
27
+ export interface Contributor {
28
+ user: UserReference;
29
+ interactionCount: number;
30
+ }
31
+ export declare type VideoAttributes = {
32
+ thumbnailUrl: string;
33
+ embedUrl: string;
34
+ durationInSeconds?: number;
35
+ width?: number;
36
+ height?: number;
37
+ commentCount?: number;
38
+ textTracks?: Track[];
39
+ chapters?: Chapter[];
40
+ contributors?: Contributor[];
41
+ };
42
+ export declare type VideoEntity = BaseEntityProperties & {
43
+ displayName: string;
44
+ lastUpdatedAt: string;
45
+ permissions: NonNullable<BaseEntityProperties['permissions']>;
46
+ 'atlassian:video': VideoAttributes;
47
+ };
48
+ //# sourceMapping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AC;IACrB,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;IACrB,YAAY,CAAC,EAAE,WAAW,EAAE,CAAC;CAC9B,CAAC;AAEF,oBAAY,WAAW,GAAG,oBAAoB,GAAG;IAC/C,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,WAAW,CAAC,oBAAoB,CAAC,aAAa,CAAC,CAAC,CAAC;IAC9D,iBAAiB,EAAE,eAAe,CAAC;CACpC,CAAC"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,44 @@
1
+ import { BaseEntityProperties, ContainerKeyObject } from '../common';
2
+ export interface UserReference {
3
+ accountId?: string;
4
+ email?: string;
5
+ externalId?: string;
6
+ ari?: string;
7
+ name?: string;
8
+ userName?: string;
9
+ avatar?: string;
10
+ url?: string;
11
+ }
12
+ export interface WorkItemProject {
13
+ id: string;
14
+ name: string;
15
+ }
16
+ export interface Attachment {
17
+ url?: string;
18
+ thumbnailUrl?: string;
19
+ title?: string;
20
+ mimeType?: string;
21
+ byteSize?: number;
22
+ }
23
+ export declare type WorkItemAttributes = {
24
+ dueDate?: string;
25
+ assignee?: UserReference;
26
+ workItemProject?: WorkItemProject;
27
+ collaborators?: UserReference[];
28
+ exceedsMaxCollaborators?: boolean;
29
+ status?: string;
30
+ subtype?: string;
31
+ attachments?: Attachment[];
32
+ team?: string;
33
+ };
34
+ export declare type WorkItemEntity = BaseEntityProperties & {
35
+ displayName: string;
36
+ description: string;
37
+ containerKey: ContainerKeyObject & {
38
+ type: 'atlassian:space';
39
+ };
40
+ lastUpdatedAt: string;
41
+ permissions: NonNullable<BaseEntityProperties['permissions']>;
42
+ 'atlassian:work-item': WorkItemAttributes;
43
+ };
44
+ //# sourceMappingURL=work-item.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"work-item.d.ts","sourceRoot":"","sources":["../../../src/types/entities/work-item.ts"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CAAA;KAAE,CAAC;IAC/D,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,WAAW,CAAC,oBAAoB,CAAC,aAAa,CAAC,CAAC,CAAC;IAC9D,qBAAqB,EAAE,kBAAkB,CAAC;CAC3C,CAAC"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,23 @@
1
+ import { BaseEntityProperties } from '../common';
2
+ export interface UserReference {
3
+ accountId?: string;
4
+ email?: string;
5
+ externalId?: string;
6
+ ari?: string;
7
+ name?: string;
8
+ userName?: string;
9
+ avatar?: string;
10
+ url?: string;
11
+ }
12
+ export declare type WorkerAttributes = {
13
+ hiredAt: string;
14
+ workerUser: UserReference;
15
+ customAndSensitiveData?: string;
16
+ };
17
+ export declare type WorkerEntity = BaseEntityProperties & {
18
+ displayName: string;
19
+ lastUpdatedAt: string;
20
+ permissions: NonNullable<BaseEntityProperties['permissions']>;
21
+ 'atlassian:worker': WorkerAttributes;
22
+ };
23
+ //# sourceMappingURL=worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../../src/types/entities/worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAEjD,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,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"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -4,11 +4,13 @@ export declare type BulkEntityRequest = {
4
4
  };
5
5
  export declare type BulkEntityResponse = {
6
6
  success: boolean;
7
- results: Array<{
7
+ results?: Array<{
8
8
  entityId: string;
9
9
  success: boolean;
10
10
  error?: string;
11
11
  }>;
12
+ error?: string;
13
+ originalError?: unknown;
12
14
  };
13
15
  export declare type GetEntityByExternalIdRequest = {
14
16
  entityType: string;
@@ -18,6 +20,7 @@ export declare type GetEntityByExternalIdResponse = {
18
20
  success: boolean;
19
21
  entity?: Entity;
20
22
  error?: string;
23
+ originalError?: unknown;
21
24
  };
22
25
  export declare type DeleteEntitiesByExternalIdRequest = {
23
26
  entityType: string;
@@ -25,42 +28,50 @@ export declare type DeleteEntitiesByExternalIdRequest = {
25
28
  };
26
29
  export declare type DeleteEntitiesByExternalIdResponse = {
27
30
  success: boolean;
28
- results: Array<{
31
+ results?: Array<{
29
32
  externalId: string;
30
33
  success: boolean;
31
34
  error?: string;
32
35
  }>;
36
+ error?: string;
37
+ originalError?: unknown;
33
38
  };
34
39
  export declare type DeleteEntitiesByPropertiesRequest = Record<string, any>;
35
40
  export declare type DeleteEntitiesByPropertiesResponse = {
36
41
  success: boolean;
37
- results: Array<{
42
+ results?: Array<{
38
43
  entityId: string;
39
44
  success: boolean;
40
45
  error?: string;
41
46
  }>;
47
+ error?: string;
48
+ originalError?: unknown;
42
49
  };
43
50
  export declare type BulkUsersRequest = {
44
51
  users: UserPayload[];
45
52
  };
46
53
  export declare type BulkUsersResponse = {
47
54
  success: boolean;
48
- results: Array<{
55
+ results?: Array<{
49
56
  externalId: string;
50
57
  success: boolean;
51
58
  error?: string;
52
59
  }>;
60
+ error?: string;
61
+ originalError?: unknown;
53
62
  };
54
63
  export declare type DeleteUsersByExternalIdRequest = {
55
64
  externalIds: string[];
56
65
  };
57
66
  export declare type DeleteUsersByExternalIdResponse = {
58
67
  success: boolean;
59
- results: Array<{
68
+ results?: Array<{
60
69
  externalId: string;
61
70
  success: boolean;
62
71
  error?: string;
63
72
  }>;
73
+ error?: string;
74
+ originalError?: unknown;
64
75
  };
65
76
  export declare type GetUserByExternalIdRequest = {
66
77
  externalId: string;
@@ -69,6 +80,7 @@ export declare type GetUserByExternalIdResponse = {
69
80
  success: boolean;
70
81
  user?: User;
71
82
  error?: string;
83
+ originalError?: unknown;
72
84
  };
73
85
  export declare type UserMapping = {
74
86
  externalId: string;
@@ -82,34 +94,40 @@ export declare type MapUsersRequest = {
82
94
  };
83
95
  export declare type MapUsersResponse = {
84
96
  success: boolean;
85
- results: Array<{
97
+ results?: Array<{
86
98
  externalId: string;
87
99
  accountId?: string;
88
100
  success: boolean;
89
101
  error?: string;
90
102
  }>;
103
+ error?: string;
104
+ originalError?: unknown;
91
105
  };
92
106
  export declare type BulkGroupsRequest = {
93
107
  groups: GroupPayload[];
94
108
  };
95
109
  export declare type BulkGroupsResponse = {
96
110
  success: boolean;
97
- results: Array<{
111
+ results?: Array<{
98
112
  externalId: string;
99
113
  success: boolean;
100
114
  error?: string;
101
115
  }>;
116
+ error?: string;
117
+ originalError?: unknown;
102
118
  };
103
119
  export declare type DeleteGroupsByExternalIdRequest = {
104
120
  externalIds: string[];
105
121
  };
106
122
  export declare type DeleteGroupsByExternalIdResponse = {
107
123
  success: boolean;
108
- results: Array<{
124
+ results?: Array<{
109
125
  externalId: string;
110
126
  success: boolean;
111
127
  error?: string;
112
128
  }>;
129
+ error?: string;
130
+ originalError?: unknown;
113
131
  };
114
132
  export declare type GetGroupByExternalIdRequest = {
115
133
  externalId: string;
@@ -118,6 +136,7 @@ export declare type GetGroupByExternalIdResponse = {
118
136
  success: boolean;
119
137
  group?: Group;
120
138
  error?: string;
139
+ originalError?: unknown;
121
140
  };
122
141
  export declare type FetchDataRequest = {
123
142
  requestConfig: {
@@ -131,6 +150,7 @@ export declare type FetchDataResponse = {
131
150
  success: boolean;
132
151
  data?: any;
133
152
  error?: string;
153
+ originalError?: unknown;
134
154
  };
135
155
  export declare type TransformDataRequest = {
136
156
  data: any;
@@ -140,5 +160,6 @@ export declare type TransformDataResponse = {
140
160
  success: boolean;
141
161
  transformedData?: any;
142
162
  error?: string;
163
+ originalError?: unknown;
143
164
  };
144
165
  //# 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,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CACzB,CAAC;AAEF,oBAAY,kBAAkB,GAAG;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,KAAK,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,OAAO,CAAC;QACjB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC,CAAC;CACJ,CAAC;AAEF,oBAAY,4BAA4B,GAAG;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,oBAAY,6BAA6B,GAAG;IAC1C,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,oBAAY,iCAAiC,GAAG;IAC9C,UAAU,EAAE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ACjB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAGF,oBAAY,gBAAgB,GAAG;IAC7B,aAAa,EAAE;QACb,GAAG,EAAE,MAAM,CAAC;QACZ,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAClC,CAAC;IACF,QAAQ,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,GAAG,CAAC;CAC9B,CAAC;AAEF,oBAAY,iBAAiB,GAAG;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,oBAAY,oBAAoB,GAAG;IACjC,IAAI,EAAE,GAAG,CAAC;IACV,eAAe,EAAE,CAAC,IAAI,EAAE,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,4 @@
1
+ import { APIResponse } from '@forge/api';
2
+ export declare function handleResponseError(response: APIResponse, context: string): Promise<never>;
3
+ export declare function handleError<T>(error: unknown, operation: string): T;
4
+ //# sourceMappingURL=error-handling.d.ts.map
@@ -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;
@@ -1,18 +1,24 @@
1
- export declare const errorCodes: {
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 context?: Record<string, unknown> | undefined;
16
- constructor(responseDetails: APIErrorResponseDetails, code: string, message: string, context?: Record<string, unknown> | undefined);
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":"AAAA,eAAO,MAAM,UAAU;;;;;CAKb,CAAC;AASX,MAAM,WAAW,uBAAuB;IAEtC,MAAM,EAAE,MAAM,CAAC;IAGf,UAAU,EAAE,MAAM,CAAC;IAGnB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAMD,qBAAa,kBAAmB,SAAQ,KAAK;aAEzB,eAAe,EAAE,uBAAuB;aACxC,IAAI,EAAE,MAAM;aAEZ,OAAO,CAAC;gBAHR,eAAe,EAAE,uBAAuB,EACxC,IAAI,EAAE,MAAM,EAC5B,OAAO,EAAE,MAAM,EACC,OAAO,CAAC,qCAAyB;CAKpD"}
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"}
@@ -1,22 +1,50 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ForgeGraphAPIError = exports.errorCodes = void 0;
4
- exports.errorCodes = {
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
- context;
14
- constructor(responseDetails, code, message, context) {
6
+ field;
7
+ details;
8
+ constructor(message, code, field, details) {
15
9
  super(message);
16
- this.responseDetails = responseDetails;
10
+ this.name = this.constructor.name;
17
11
  this.code = code;
18
- this.context = context;
19
- this.name = 'ForgeGraphAPIError';
12
+ this.field = field;
13
+ this.details = details;
20
14
  }
21
15
  }
22
- exports.ForgeGraphAPIError = ForgeGraphAPIError;
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":"AACA,eAAO,MAAM,iBAAiB,MAAM,CAAC;AACrC,eAAO,MAAM,cAAc,MAAM,CAAC;AAClC,eAAO,MAAM,eAAe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BAAgB,sCAAsC,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,IAAI,CAElF;AAKD,wBAAgB,uCAAuC,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,IAAI,CAEnF;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,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"}
@@ -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 Error(`${fieldName} must be an array`);
12
+ throw new errors_1.ForgeTeamWorkGraphValidationError(`${fieldName} must be an array`, fieldName);
12
13
  }
13
14
  if (value.length === 0) {
14
- throw new Error(`${fieldName} array cannot be empty`);
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 Error(`${fieldName} supports maximum ${maxLength} ${itemType}. Received ${value.length}`);
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 Error(`${fieldName} is required`);
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 Error(`${fieldName} must be an object`);
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 Error(`${fieldName} object cannot be empty`);
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 Error('Each mapping must have either accountId or externalEmailAddress');
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 Error('Each mapping must have an externalId');
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 Error('request must be an object');
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 Error('requestConfig is required and must be an object');
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 Error('requestConfig.url is required and must be a string');
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 Error('requestConfig.method is required and must be a string');
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 Error('onResult is required and must be a function');
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 Error('request must be an object');
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 Error('transformMethod is required and must be a function');
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": "2.0.0-next.6",
3
+ "version": "2.0.0-next.7",
4
4
  "description": "Forge TeamworkGraph SDK",
5
5
  "author": "Atlassian",
6
6
  "license": "UNLICENSED",
@@ -1,3 +0,0 @@
1
- import { APIResponse } from '@forge/api';
2
- export declare function handleResponseError(response: APIResponse, defaultMessage?: string): Promise<void>;
3
- //# sourceMappingURL=error-handling.d.ts.map
@@ -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"}