@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.
- package/out/__test__/entity-operations.test.js +615 -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/index.d.ts +11 -2
- package/out/types/entities/index.d.ts.map +1 -1
- 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 +1 -1
- 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,329 +1,365 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const validators_1 = require("../utils/validators");
|
|
4
|
+
const errors_1 = require("../utils/errors");
|
|
4
5
|
describe('TeamWorkGraphClient - Validators', () => {
|
|
5
|
-
describe('validateArray', () => {
|
|
6
|
-
it('should pass for valid array', () => {
|
|
7
|
-
expect(() => (0, validators_1.validateArray)([1, 2, 3], 'test')).not.toThrow();
|
|
8
|
-
});
|
|
9
|
-
it('should throw for non-array', () => {
|
|
10
|
-
expect(() => (0, validators_1.validateArray)('not an array', 'test')).toThrow('test must be an array');
|
|
11
|
-
});
|
|
12
|
-
it('should throw for empty array', () => {
|
|
13
|
-
expect(() => (0, validators_1.validateArray)([], 'test')).toThrow('test array cannot be empty');
|
|
14
|
-
});
|
|
15
|
-
it('should throw for null', () => {
|
|
16
|
-
expect(() => (0, validators_1.validateArray)(null, 'test')).toThrow('test must be an array');
|
|
17
|
-
});
|
|
18
|
-
it('should throw for undefined', () => {
|
|
19
|
-
expect(() => (0, validators_1.validateArray)(undefined, 'test')).toThrow('test must be an array');
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
describe('validateArrayMaxLength', () => {
|
|
23
|
-
it('should pass for array within limit', () => {
|
|
24
|
-
expect(() => (0, validators_1.validateArrayMaxLength)([1, 2], 'test', 5)).not.toThrow();
|
|
25
|
-
});
|
|
26
|
-
it('should pass for array at limit', () => {
|
|
27
|
-
expect(() => (0, validators_1.validateArrayMaxLength)([1, 2, 3], 'test', 3)).not.toThrow();
|
|
28
|
-
});
|
|
29
|
-
it('should throw for array exceeding limit', () => {
|
|
30
|
-
expect(() => (0, validators_1.validateArrayMaxLength)([1, 2, 3, 4], 'test', 3)).toThrow('test supports maximum 3 items. Received 4');
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
describe('validateRequiredString', () => {
|
|
34
|
-
it('should pass for valid string', () => {
|
|
35
|
-
expect(() => (0, validators_1.validateRequiredString)('valid string', 'test')).not.toThrow();
|
|
36
|
-
});
|
|
37
|
-
it('should throw for empty string', () => {
|
|
38
|
-
expect(() => (0, validators_1.validateRequiredString)('', 'test')).toThrow('test is required');
|
|
39
|
-
});
|
|
40
|
-
it('should throw for whitespace string', () => {
|
|
41
|
-
expect(() => (0, validators_1.validateRequiredString)(' ', 'test')).toThrow('test is required');
|
|
42
|
-
});
|
|
43
|
-
it('should throw for null', () => {
|
|
44
|
-
expect(() => (0, validators_1.validateRequiredString)(null, 'test')).toThrow('test is required');
|
|
45
|
-
});
|
|
46
|
-
it('should throw for undefined', () => {
|
|
47
|
-
expect(() => (0, validators_1.validateRequiredString)(undefined, 'test')).toThrow('test is required');
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
describe('validateObject', () => {
|
|
51
|
-
it('should pass for valid object', () => {
|
|
52
|
-
expect(() => (0, validators_1.validateObject)({ key: 'value' }, 'test')).not.toThrow();
|
|
53
|
-
});
|
|
54
|
-
it('should throw for null', () => {
|
|
55
|
-
expect(() => (0, validators_1.validateObject)(null, 'test')).toThrow('test must be an object');
|
|
56
|
-
});
|
|
57
|
-
it('should throw for undefined', () => {
|
|
58
|
-
expect(() => (0, validators_1.validateObject)(undefined, 'test')).toThrow('test must be an object');
|
|
59
|
-
});
|
|
60
|
-
it('should throw for non-object', () => {
|
|
61
|
-
expect(() => (0, validators_1.validateObject)('not an object', 'test')).toThrow('test must be an object');
|
|
62
|
-
});
|
|
63
|
-
it('should throw for empty object', () => {
|
|
64
|
-
expect(() => (0, validators_1.validateObject)({}, 'test')).toThrow('test object cannot be empty');
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
6
|
describe('validateSetEntitiesRequest', () => {
|
|
68
|
-
it('should pass
|
|
69
|
-
const entities =
|
|
7
|
+
it('should pass with valid entities array', () => {
|
|
8
|
+
const entities = [{ id: '1', name: 'Entity 1' }];
|
|
70
9
|
expect(() => (0, validators_1.validateSetEntitiesRequest)(entities)).not.toThrow();
|
|
71
10
|
});
|
|
72
|
-
it('should throw for non-array', () => {
|
|
73
|
-
expect(() => (0, validators_1.validateSetEntitiesRequest)('
|
|
11
|
+
it('should throw validation error for non-array input', () => {
|
|
12
|
+
expect(() => (0, validators_1.validateSetEntitiesRequest)('invalid')).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
13
|
+
expect(() => (0, validators_1.validateSetEntitiesRequest)(null)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
14
|
+
expect(() => (0, validators_1.validateSetEntitiesRequest)(undefined)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
74
15
|
});
|
|
75
|
-
it('should throw for empty array', () => {
|
|
76
|
-
expect(() => (0, validators_1.validateSetEntitiesRequest)([])).toThrow(
|
|
16
|
+
it('should throw validation error for empty array', () => {
|
|
17
|
+
expect(() => (0, validators_1.validateSetEntitiesRequest)([])).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
77
18
|
});
|
|
78
|
-
it('should throw for array exceeding
|
|
79
|
-
const entities = Array(validators_1.MAX_BULK_ENTITIES + 1).fill({ id: '
|
|
80
|
-
expect(() => (0, validators_1.validateSetEntitiesRequest)(entities)).toThrow(
|
|
19
|
+
it('should throw validation error for array exceeding max length', () => {
|
|
20
|
+
const entities = Array(validators_1.MAX_BULK_ENTITIES + 1).fill({ id: '1', name: 'Entity' });
|
|
21
|
+
expect(() => (0, validators_1.validateSetEntitiesRequest)(entities)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
81
22
|
});
|
|
82
23
|
});
|
|
83
24
|
describe('validateSetUsersRequest', () => {
|
|
84
|
-
it('should pass
|
|
85
|
-
const users =
|
|
25
|
+
it('should pass with valid users array', () => {
|
|
26
|
+
const users = [{ id: '1', name: 'User 1' }];
|
|
86
27
|
expect(() => (0, validators_1.validateSetUsersRequest)(users)).not.toThrow();
|
|
87
28
|
});
|
|
88
|
-
it('should throw for non-array', () => {
|
|
89
|
-
expect(() => (0, validators_1.validateSetUsersRequest)('
|
|
29
|
+
it('should throw validation error for non-array input', () => {
|
|
30
|
+
expect(() => (0, validators_1.validateSetUsersRequest)('invalid')).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
31
|
+
expect(() => (0, validators_1.validateSetUsersRequest)(null)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
32
|
+
expect(() => (0, validators_1.validateSetUsersRequest)(undefined)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
90
33
|
});
|
|
91
|
-
it('should throw for empty array', () => {
|
|
92
|
-
expect(() => (0, validators_1.validateSetUsersRequest)([])).toThrow(
|
|
34
|
+
it('should throw validation error for empty array', () => {
|
|
35
|
+
expect(() => (0, validators_1.validateSetUsersRequest)([])).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
93
36
|
});
|
|
94
|
-
it('should throw for array exceeding
|
|
95
|
-
const users = Array(validators_1.MAX_BULK_USERS + 1).fill({ id: '
|
|
96
|
-
expect(() => (0, validators_1.validateSetUsersRequest)(users)).toThrow(
|
|
37
|
+
it('should throw validation error for array exceeding max length', () => {
|
|
38
|
+
const users = Array(validators_1.MAX_BULK_USERS + 1).fill({ id: '1', name: 'User' });
|
|
39
|
+
expect(() => (0, validators_1.validateSetUsersRequest)(users)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
97
40
|
});
|
|
98
41
|
});
|
|
99
42
|
describe('validateSetGroupsRequest', () => {
|
|
100
|
-
it('should pass
|
|
101
|
-
const groups =
|
|
43
|
+
it('should pass with valid groups array', () => {
|
|
44
|
+
const groups = [{ id: '1', name: 'Group 1' }];
|
|
102
45
|
expect(() => (0, validators_1.validateSetGroupsRequest)(groups)).not.toThrow();
|
|
103
46
|
});
|
|
104
|
-
it('should throw for non-array', () => {
|
|
105
|
-
expect(() => (0, validators_1.validateSetGroupsRequest)('
|
|
47
|
+
it('should throw validation error for non-array input', () => {
|
|
48
|
+
expect(() => (0, validators_1.validateSetGroupsRequest)('invalid')).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
49
|
+
expect(() => (0, validators_1.validateSetGroupsRequest)(null)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
50
|
+
expect(() => (0, validators_1.validateSetGroupsRequest)(undefined)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
106
51
|
});
|
|
107
|
-
it('should throw for empty array', () => {
|
|
108
|
-
expect(() => (0, validators_1.validateSetGroupsRequest)([])).toThrow(
|
|
52
|
+
it('should throw validation error for empty array', () => {
|
|
53
|
+
expect(() => (0, validators_1.validateSetGroupsRequest)([])).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
109
54
|
});
|
|
110
|
-
it('should throw for array exceeding
|
|
111
|
-
const groups = Array(validators_1.MAX_BULK_GROUPS + 1).fill({ id: '
|
|
112
|
-
expect(() => (0, validators_1.validateSetGroupsRequest)(groups)).toThrow(
|
|
55
|
+
it('should throw validation error for array exceeding max length', () => {
|
|
56
|
+
const groups = Array(validators_1.MAX_BULK_GROUPS + 1).fill({ id: '1', name: 'Group' });
|
|
57
|
+
expect(() => (0, validators_1.validateSetGroupsRequest)(groups)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
113
58
|
});
|
|
114
59
|
});
|
|
115
60
|
describe('validateDeleteEntitiesByExternalIdRequest', () => {
|
|
116
|
-
it('should pass
|
|
117
|
-
|
|
118
|
-
const externalIds = Array(validators_1.MAX_BULK_ENTITIES_DELETE).fill('test-id');
|
|
119
|
-
expect(() => (0, validators_1.validateDeleteEntitiesByExternalIdRequest)(entityType, externalIds)).not.toThrow();
|
|
61
|
+
it('should pass with valid parameters', () => {
|
|
62
|
+
expect(() => (0, validators_1.validateDeleteEntitiesByExternalIdRequest)('issue', ['1', '2'])).not.toThrow();
|
|
120
63
|
});
|
|
121
|
-
it('should throw for empty entityType', () => {
|
|
122
|
-
expect(() => (0, validators_1.validateDeleteEntitiesByExternalIdRequest)('', ['
|
|
64
|
+
it('should throw validation error for empty entityType', () => {
|
|
65
|
+
expect(() => (0, validators_1.validateDeleteEntitiesByExternalIdRequest)('', ['1'])).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
66
|
+
expect(() => (0, validators_1.validateDeleteEntitiesByExternalIdRequest)(' ', ['1'])).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
123
67
|
});
|
|
124
|
-
it('should throw for
|
|
125
|
-
expect(() => (0, validators_1.validateDeleteEntitiesByExternalIdRequest)('
|
|
68
|
+
it('should throw validation error for non-array externalIds', () => {
|
|
69
|
+
expect(() => (0, validators_1.validateDeleteEntitiesByExternalIdRequest)('issue', 'invalid')).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
70
|
+
expect(() => (0, validators_1.validateDeleteEntitiesByExternalIdRequest)('issue', null)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
126
71
|
});
|
|
127
|
-
it('should throw for
|
|
128
|
-
expect(() => (0, validators_1.validateDeleteEntitiesByExternalIdRequest)('
|
|
72
|
+
it('should throw validation error for empty externalIds array', () => {
|
|
73
|
+
expect(() => (0, validators_1.validateDeleteEntitiesByExternalIdRequest)('issue', [])).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
129
74
|
});
|
|
130
|
-
it('should throw for
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
it('should throw for externalIds exceeding limit', () => {
|
|
134
|
-
const externalIds = Array(validators_1.MAX_BULK_ENTITIES_DELETE + 1).fill('test-id');
|
|
135
|
-
expect(() => (0, validators_1.validateDeleteEntitiesByExternalIdRequest)('type', externalIds)).toThrow(`Bulk entity deletion supports maximum ${validators_1.MAX_BULK_ENTITIES_DELETE} entities. Received ${validators_1.MAX_BULK_ENTITIES_DELETE + 1}`);
|
|
75
|
+
it('should throw validation error for array exceeding max length', () => {
|
|
76
|
+
const externalIds = Array(validators_1.MAX_BULK_ENTITIES_DELETE + 1).fill('id');
|
|
77
|
+
expect(() => (0, validators_1.validateDeleteEntitiesByExternalIdRequest)('issue', externalIds)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
136
78
|
});
|
|
137
79
|
});
|
|
138
80
|
describe('validateDeleteUsersByExternalIdRequest', () => {
|
|
139
|
-
it('should pass
|
|
140
|
-
|
|
141
|
-
expect(() => (0, validators_1.validateDeleteUsersByExternalIdRequest)(externalIds)).not.toThrow();
|
|
81
|
+
it('should pass with valid externalIds array', () => {
|
|
82
|
+
expect(() => (0, validators_1.validateDeleteUsersByExternalIdRequest)(['1', '2'])).not.toThrow();
|
|
142
83
|
});
|
|
143
|
-
it('should throw for non-array', () => {
|
|
144
|
-
expect(() => (0, validators_1.validateDeleteUsersByExternalIdRequest)('
|
|
84
|
+
it('should throw validation error for non-array input', () => {
|
|
85
|
+
expect(() => (0, validators_1.validateDeleteUsersByExternalIdRequest)('invalid')).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
86
|
+
expect(() => (0, validators_1.validateDeleteUsersByExternalIdRequest)(null)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
87
|
+
expect(() => (0, validators_1.validateDeleteUsersByExternalIdRequest)(undefined)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
145
88
|
});
|
|
146
|
-
it('should throw for empty array', () => {
|
|
147
|
-
expect(() => (0, validators_1.validateDeleteUsersByExternalIdRequest)([])).toThrow(
|
|
89
|
+
it('should throw validation error for empty array', () => {
|
|
90
|
+
expect(() => (0, validators_1.validateDeleteUsersByExternalIdRequest)([])).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
148
91
|
});
|
|
149
92
|
});
|
|
150
93
|
describe('validateDeleteGroupsByExternalIdRequest', () => {
|
|
151
|
-
it('should pass
|
|
152
|
-
|
|
153
|
-
expect(() => (0, validators_1.validateDeleteGroupsByExternalIdRequest)(externalIds)).not.toThrow();
|
|
94
|
+
it('should pass with valid externalIds array', () => {
|
|
95
|
+
expect(() => (0, validators_1.validateDeleteGroupsByExternalIdRequest)(['1', '2'])).not.toThrow();
|
|
154
96
|
});
|
|
155
|
-
it('should throw for non-array', () => {
|
|
156
|
-
expect(() => (0, validators_1.validateDeleteGroupsByExternalIdRequest)('
|
|
97
|
+
it('should throw validation error for non-array input', () => {
|
|
98
|
+
expect(() => (0, validators_1.validateDeleteGroupsByExternalIdRequest)('invalid')).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
99
|
+
expect(() => (0, validators_1.validateDeleteGroupsByExternalIdRequest)(null)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
100
|
+
expect(() => (0, validators_1.validateDeleteGroupsByExternalIdRequest)(undefined)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
157
101
|
});
|
|
158
|
-
it('should throw for empty array', () => {
|
|
159
|
-
expect(() => (0, validators_1.validateDeleteGroupsByExternalIdRequest)([])).toThrow(
|
|
102
|
+
it('should throw validation error for empty array', () => {
|
|
103
|
+
expect(() => (0, validators_1.validateDeleteGroupsByExternalIdRequest)([])).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
160
104
|
});
|
|
161
105
|
});
|
|
162
106
|
describe('validateGetEntityByExternalIdRequest', () => {
|
|
163
|
-
it('should pass
|
|
164
|
-
expect(() => (0, validators_1.validateGetEntityByExternalIdRequest)('
|
|
107
|
+
it('should pass with valid parameters', () => {
|
|
108
|
+
expect(() => (0, validators_1.validateGetEntityByExternalIdRequest)('issue', '123')).not.toThrow();
|
|
165
109
|
});
|
|
166
|
-
it('should throw for empty entityType', () => {
|
|
167
|
-
expect(() => (0, validators_1.validateGetEntityByExternalIdRequest)('', '
|
|
110
|
+
it('should throw validation error for empty entityType', () => {
|
|
111
|
+
expect(() => (0, validators_1.validateGetEntityByExternalIdRequest)('', '123')).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
112
|
+
expect(() => (0, validators_1.validateGetEntityByExternalIdRequest)(' ', '123')).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
168
113
|
});
|
|
169
|
-
it('should throw for empty externalId', () => {
|
|
170
|
-
expect(() => (0, validators_1.validateGetEntityByExternalIdRequest)('
|
|
114
|
+
it('should throw validation error for empty externalId', () => {
|
|
115
|
+
expect(() => (0, validators_1.validateGetEntityByExternalIdRequest)('issue', '')).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
116
|
+
expect(() => (0, validators_1.validateGetEntityByExternalIdRequest)('issue', ' ')).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
171
117
|
});
|
|
172
118
|
});
|
|
173
119
|
describe('validateGetUserByExternalIdRequest', () => {
|
|
174
|
-
it('should pass
|
|
175
|
-
expect(() => (0, validators_1.validateGetUserByExternalIdRequest)('
|
|
120
|
+
it('should pass with valid externalId', () => {
|
|
121
|
+
expect(() => (0, validators_1.validateGetUserByExternalIdRequest)('123')).not.toThrow();
|
|
176
122
|
});
|
|
177
|
-
it('should throw for empty externalId', () => {
|
|
178
|
-
expect(() => (0, validators_1.validateGetUserByExternalIdRequest)('')).toThrow(
|
|
123
|
+
it('should throw validation error for empty externalId', () => {
|
|
124
|
+
expect(() => (0, validators_1.validateGetUserByExternalIdRequest)('')).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
125
|
+
expect(() => (0, validators_1.validateGetUserByExternalIdRequest)(' ')).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
179
126
|
});
|
|
180
127
|
});
|
|
181
128
|
describe('validateGetGroupByExternalIdRequest', () => {
|
|
182
|
-
it('should pass
|
|
183
|
-
expect(() => (0, validators_1.validateGetGroupByExternalIdRequest)('
|
|
129
|
+
it('should pass with valid externalId', () => {
|
|
130
|
+
expect(() => (0, validators_1.validateGetGroupByExternalIdRequest)('123')).not.toThrow();
|
|
184
131
|
});
|
|
185
|
-
it('should throw for empty externalId', () => {
|
|
186
|
-
expect(() => (0, validators_1.validateGetGroupByExternalIdRequest)('')).toThrow(
|
|
132
|
+
it('should throw validation error for empty externalId', () => {
|
|
133
|
+
expect(() => (0, validators_1.validateGetGroupByExternalIdRequest)('')).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
134
|
+
expect(() => (0, validators_1.validateGetGroupByExternalIdRequest)(' ')).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
187
135
|
});
|
|
188
136
|
});
|
|
189
137
|
describe('validateMapUsersRequest', () => {
|
|
190
|
-
it('should pass
|
|
191
|
-
const
|
|
192
|
-
{ externalId: '
|
|
193
|
-
{ externalId: '
|
|
138
|
+
it('should pass with valid mappings', () => {
|
|
139
|
+
const mappings = [
|
|
140
|
+
{ externalId: '1', accountId: 'acc1' },
|
|
141
|
+
{ externalId: '2', externalEmailAddress: 'user@example.com' }
|
|
194
142
|
];
|
|
195
|
-
expect(() => (0, validators_1.validateMapUsersRequest)(
|
|
143
|
+
expect(() => (0, validators_1.validateMapUsersRequest)(mappings)).not.toThrow();
|
|
196
144
|
});
|
|
197
|
-
it('should throw for non-array', () => {
|
|
198
|
-
expect(() => (0, validators_1.validateMapUsersRequest)('
|
|
145
|
+
it('should throw validation error for non-array input', () => {
|
|
146
|
+
expect(() => (0, validators_1.validateMapUsersRequest)('invalid')).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
147
|
+
expect(() => (0, validators_1.validateMapUsersRequest)(null)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
148
|
+
expect(() => (0, validators_1.validateMapUsersRequest)(undefined)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
199
149
|
});
|
|
200
|
-
it('should throw for empty array', () => {
|
|
201
|
-
expect(() => (0, validators_1.validateMapUsersRequest)([])).toThrow(
|
|
150
|
+
it('should throw validation error for empty array', () => {
|
|
151
|
+
expect(() => (0, validators_1.validateMapUsersRequest)([])).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
202
152
|
});
|
|
203
|
-
it('should throw for array exceeding
|
|
204
|
-
const
|
|
205
|
-
expect(() => (0, validators_1.validateMapUsersRequest)(
|
|
153
|
+
it('should throw validation error for array exceeding max length', () => {
|
|
154
|
+
const mappings = Array(validators_1.MAX_USER_MAPPINGS + 1).fill({ externalId: '1', accountId: 'acc1' });
|
|
155
|
+
expect(() => (0, validators_1.validateMapUsersRequest)(mappings)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
206
156
|
});
|
|
207
|
-
it('should throw for mapping without accountId or externalEmailAddress', () => {
|
|
208
|
-
const
|
|
209
|
-
expect(() => (0, validators_1.validateMapUsersRequest)(
|
|
157
|
+
it('should throw validation error for mapping without accountId or externalEmailAddress', () => {
|
|
158
|
+
const mappings = [{ externalId: '1' }];
|
|
159
|
+
expect(() => (0, validators_1.validateMapUsersRequest)(mappings)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
210
160
|
});
|
|
211
|
-
it('should throw for mapping without externalId', () => {
|
|
212
|
-
const
|
|
213
|
-
expect(() => (0, validators_1.validateMapUsersRequest)(
|
|
161
|
+
it('should throw validation error for mapping without externalId', () => {
|
|
162
|
+
const mappings = [{ accountId: 'acc1' }];
|
|
163
|
+
expect(() => (0, validators_1.validateMapUsersRequest)(mappings)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
214
164
|
});
|
|
215
165
|
});
|
|
216
166
|
describe('validateDeleteEntitiesByPropertiesRequest', () => {
|
|
217
|
-
it('should pass
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
it('should throw for null', () => {
|
|
221
|
-
expect(() => (0, validators_1.validateDeleteEntitiesByPropertiesRequest)(null)).toThrow('properties must be an object');
|
|
167
|
+
it('should pass with valid properties object', () => {
|
|
168
|
+
const properties = { type: 'issue', status: 'open' };
|
|
169
|
+
expect(() => (0, validators_1.validateDeleteEntitiesByPropertiesRequest)(properties)).not.toThrow();
|
|
222
170
|
});
|
|
223
|
-
it('should throw for non-object', () => {
|
|
224
|
-
expect(() => (0, validators_1.validateDeleteEntitiesByPropertiesRequest)('
|
|
171
|
+
it('should throw validation error for non-object input', () => {
|
|
172
|
+
expect(() => (0, validators_1.validateDeleteEntitiesByPropertiesRequest)('invalid')).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
173
|
+
expect(() => (0, validators_1.validateDeleteEntitiesByPropertiesRequest)(null)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
174
|
+
expect(() => (0, validators_1.validateDeleteEntitiesByPropertiesRequest)(undefined)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
225
175
|
});
|
|
226
|
-
it('should throw for empty object', () => {
|
|
227
|
-
expect(() => (0, validators_1.validateDeleteEntitiesByPropertiesRequest)({})).toThrow(
|
|
176
|
+
it('should throw validation error for empty object', () => {
|
|
177
|
+
expect(() => (0, validators_1.validateDeleteEntitiesByPropertiesRequest)({})).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
228
178
|
});
|
|
229
179
|
});
|
|
230
180
|
describe('validateFetchDataRequest', () => {
|
|
231
|
-
it('should pass
|
|
181
|
+
it('should pass with valid request', () => {
|
|
232
182
|
const request = {
|
|
233
183
|
requestConfig: {
|
|
234
|
-
url: 'https://
|
|
184
|
+
url: 'https://api.example.com/data',
|
|
235
185
|
method: 'GET',
|
|
236
|
-
headers: {
|
|
186
|
+
headers: {}
|
|
237
187
|
},
|
|
238
|
-
onResult: ()
|
|
239
|
-
}
|
|
188
|
+
onResult: jest.fn()
|
|
240
189
|
};
|
|
241
190
|
expect(() => (0, validators_1.validateFetchDataRequest)(request)).not.toThrow();
|
|
242
191
|
});
|
|
243
|
-
it('should throw for
|
|
244
|
-
expect(() => (0, validators_1.validateFetchDataRequest)(
|
|
192
|
+
it('should throw validation error for non-object request', () => {
|
|
193
|
+
expect(() => (0, validators_1.validateFetchDataRequest)('invalid')).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
194
|
+
expect(() => (0, validators_1.validateFetchDataRequest)(null)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
195
|
+
expect(() => (0, validators_1.validateFetchDataRequest)(undefined)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
245
196
|
});
|
|
246
|
-
it('should throw for
|
|
247
|
-
|
|
197
|
+
it('should throw validation error for missing requestConfig', () => {
|
|
198
|
+
const request = { onResult: jest.fn() };
|
|
199
|
+
expect(() => (0, validators_1.validateFetchDataRequest)(request)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
248
200
|
});
|
|
249
|
-
it('should throw for
|
|
201
|
+
it('should throw validation error for non-object requestConfig', () => {
|
|
250
202
|
const request = {
|
|
251
|
-
|
|
252
|
-
|
|
203
|
+
requestConfig: 'invalid',
|
|
204
|
+
onResult: jest.fn()
|
|
253
205
|
};
|
|
254
|
-
expect(() => (0, validators_1.validateFetchDataRequest)(request)).toThrow(
|
|
206
|
+
expect(() => (0, validators_1.validateFetchDataRequest)(request)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
255
207
|
});
|
|
256
|
-
it('should throw for
|
|
208
|
+
it('should throw validation error for missing url', () => {
|
|
257
209
|
const request = {
|
|
258
|
-
requestConfig:
|
|
259
|
-
|
|
260
|
-
|
|
210
|
+
requestConfig: {
|
|
211
|
+
method: 'GET',
|
|
212
|
+
headers: {}
|
|
213
|
+
},
|
|
214
|
+
onResult: jest.fn()
|
|
261
215
|
};
|
|
262
|
-
expect(() => (0, validators_1.validateFetchDataRequest)(request)).toThrow(
|
|
216
|
+
expect(() => (0, validators_1.validateFetchDataRequest)(request)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
263
217
|
});
|
|
264
|
-
it('should throw for
|
|
218
|
+
it('should throw validation error for non-string url', () => {
|
|
265
219
|
const request = {
|
|
266
|
-
requestConfig: {
|
|
267
|
-
|
|
268
|
-
|
|
220
|
+
requestConfig: {
|
|
221
|
+
url: 123,
|
|
222
|
+
method: 'GET',
|
|
223
|
+
headers: {}
|
|
224
|
+
},
|
|
225
|
+
onResult: jest.fn()
|
|
269
226
|
};
|
|
270
|
-
expect(() => (0, validators_1.validateFetchDataRequest)(request)).toThrow(
|
|
227
|
+
expect(() => (0, validators_1.validateFetchDataRequest)(request)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
271
228
|
});
|
|
272
|
-
it('should throw for
|
|
229
|
+
it('should throw validation error for missing method', () => {
|
|
273
230
|
const request = {
|
|
274
|
-
requestConfig: {
|
|
275
|
-
|
|
276
|
-
|
|
231
|
+
requestConfig: {
|
|
232
|
+
url: 'https://api.example.com/data',
|
|
233
|
+
headers: {}
|
|
234
|
+
},
|
|
235
|
+
onResult: jest.fn()
|
|
277
236
|
};
|
|
278
|
-
expect(() => (0, validators_1.validateFetchDataRequest)(request)).toThrow(
|
|
237
|
+
expect(() => (0, validators_1.validateFetchDataRequest)(request)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
279
238
|
});
|
|
280
|
-
it('should throw for
|
|
239
|
+
it('should throw validation error for non-string method', () => {
|
|
281
240
|
const request = {
|
|
282
|
-
requestConfig: {
|
|
283
|
-
|
|
284
|
-
|
|
241
|
+
requestConfig: {
|
|
242
|
+
url: 'https://api.example.com/data',
|
|
243
|
+
method: 123,
|
|
244
|
+
headers: {}
|
|
245
|
+
},
|
|
246
|
+
onResult: jest.fn()
|
|
285
247
|
};
|
|
286
|
-
expect(() => (0, validators_1.validateFetchDataRequest)(request)).toThrow(
|
|
248
|
+
expect(() => (0, validators_1.validateFetchDataRequest)(request)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
287
249
|
});
|
|
288
|
-
it('should throw for
|
|
250
|
+
it('should throw validation error for missing onResult', () => {
|
|
289
251
|
const request = {
|
|
290
|
-
requestConfig: {
|
|
291
|
-
|
|
252
|
+
requestConfig: {
|
|
253
|
+
url: 'https://api.example.com/data',
|
|
254
|
+
method: 'GET',
|
|
255
|
+
headers: {}
|
|
292
256
|
}
|
|
293
257
|
};
|
|
294
|
-
expect(() => (0, validators_1.validateFetchDataRequest)(request)).toThrow(
|
|
295
|
-
});
|
|
296
|
-
it('should throw for missing onResult', () => {
|
|
297
|
-
const request = { requestConfig: { url: 'https://test.com', method: 'GET' } };
|
|
298
|
-
expect(() => (0, validators_1.validateFetchDataRequest)(request)).toThrow('onResult is required and must be a function');
|
|
258
|
+
expect(() => (0, validators_1.validateFetchDataRequest)(request)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
299
259
|
});
|
|
300
|
-
it('should throw for non-function onResult', () => {
|
|
301
|
-
const request = {
|
|
302
|
-
|
|
260
|
+
it('should throw validation error for non-function onResult', () => {
|
|
261
|
+
const request = {
|
|
262
|
+
requestConfig: {
|
|
263
|
+
url: 'https://api.example.com/data',
|
|
264
|
+
method: 'GET',
|
|
265
|
+
headers: {}
|
|
266
|
+
},
|
|
267
|
+
onResult: 'not a function'
|
|
268
|
+
};
|
|
269
|
+
expect(() => (0, validators_1.validateFetchDataRequest)(request)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
303
270
|
});
|
|
304
271
|
});
|
|
305
272
|
describe('validateTransformDataRequest', () => {
|
|
306
|
-
it('should pass
|
|
273
|
+
it('should pass with valid request', () => {
|
|
307
274
|
const request = {
|
|
308
|
-
data: {
|
|
309
|
-
transformMethod: ()
|
|
310
|
-
}
|
|
275
|
+
data: { key: 'value' },
|
|
276
|
+
transformMethod: jest.fn()
|
|
311
277
|
};
|
|
312
278
|
expect(() => (0, validators_1.validateTransformDataRequest)(request)).not.toThrow();
|
|
313
279
|
});
|
|
314
|
-
it('should throw for
|
|
315
|
-
expect(() => (0, validators_1.validateTransformDataRequest)(
|
|
280
|
+
it('should throw validation error for non-object request', () => {
|
|
281
|
+
expect(() => (0, validators_1.validateTransformDataRequest)('invalid')).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
282
|
+
expect(() => (0, validators_1.validateTransformDataRequest)(null)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
283
|
+
expect(() => (0, validators_1.validateTransformDataRequest)(undefined)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
316
284
|
});
|
|
317
|
-
it('should throw for
|
|
318
|
-
|
|
285
|
+
it('should throw validation error for missing transformMethod', () => {
|
|
286
|
+
const request = { data: { key: 'value' } };
|
|
287
|
+
expect(() => (0, validators_1.validateTransformDataRequest)(request)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
319
288
|
});
|
|
320
|
-
it('should throw for
|
|
321
|
-
const request = {
|
|
322
|
-
|
|
289
|
+
it('should throw validation error for non-function transformMethod', () => {
|
|
290
|
+
const request = {
|
|
291
|
+
data: { key: 'value' },
|
|
292
|
+
transformMethod: 'not a function'
|
|
293
|
+
};
|
|
294
|
+
expect(() => (0, validators_1.validateTransformDataRequest)(request)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
323
295
|
});
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
296
|
+
});
|
|
297
|
+
describe('Error Handling Integration', () => {
|
|
298
|
+
it('should handle validation errors with proper error types', () => {
|
|
299
|
+
expect(() => (0, validators_1.validateSetEntitiesRequest)('invalid')).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
300
|
+
try {
|
|
301
|
+
(0, validators_1.validateSetEntitiesRequest)([]);
|
|
302
|
+
}
|
|
303
|
+
catch (error) {
|
|
304
|
+
expect(error).toBeInstanceOf(errors_1.ForgeTeamWorkGraphValidationError);
|
|
305
|
+
expect(error.message).toContain('entities array cannot be empty');
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
it('should handle array max length validation with proper error details', () => {
|
|
309
|
+
const entities = Array(validators_1.MAX_BULK_ENTITIES + 1).fill({ id: '1' });
|
|
310
|
+
try {
|
|
311
|
+
(0, validators_1.validateSetEntitiesRequest)(entities);
|
|
312
|
+
}
|
|
313
|
+
catch (error) {
|
|
314
|
+
expect(error).toBeInstanceOf(errors_1.ForgeTeamWorkGraphValidationError);
|
|
315
|
+
expect(error.message).toContain(`supports maximum ${validators_1.MAX_BULK_ENTITIES} entities`);
|
|
316
|
+
expect(error.message).toContain(`Received ${validators_1.MAX_BULK_ENTITIES + 1}`);
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
it('should handle user mapping validation with proper error details', () => {
|
|
320
|
+
const mappings = [{ externalId: '1' }];
|
|
321
|
+
try {
|
|
322
|
+
(0, validators_1.validateMapUsersRequest)(mappings);
|
|
323
|
+
}
|
|
324
|
+
catch (error) {
|
|
325
|
+
expect(error).toBeInstanceOf(errors_1.ForgeTeamWorkGraphValidationError);
|
|
326
|
+
expect(error.message).toContain('Each mapping must have either accountId or externalEmailAddress');
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
it('should handle required string validation with proper error details', () => {
|
|
330
|
+
try {
|
|
331
|
+
(0, validators_1.validateGetEntityByExternalIdRequest)('', '123');
|
|
332
|
+
}
|
|
333
|
+
catch (error) {
|
|
334
|
+
expect(error).toBeInstanceOf(errors_1.ForgeTeamWorkGraphValidationError);
|
|
335
|
+
expect(error.message).toContain('entityType is required');
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
it('should handle object validation with proper error details', () => {
|
|
339
|
+
try {
|
|
340
|
+
(0, validators_1.validateDeleteEntitiesByPropertiesRequest)({});
|
|
341
|
+
}
|
|
342
|
+
catch (error) {
|
|
343
|
+
expect(error).toBeInstanceOf(errors_1.ForgeTeamWorkGraphValidationError);
|
|
344
|
+
expect(error.message).toContain('properties object cannot be empty');
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
it('should handle function validation with proper error details', () => {
|
|
348
|
+
const request = {
|
|
349
|
+
requestConfig: {
|
|
350
|
+
url: 'https://api.example.com/data',
|
|
351
|
+
method: 'GET',
|
|
352
|
+
headers: {}
|
|
353
|
+
},
|
|
354
|
+
onResult: 'not a function'
|
|
355
|
+
};
|
|
356
|
+
try {
|
|
357
|
+
(0, validators_1.validateFetchDataRequest)(request);
|
|
358
|
+
}
|
|
359
|
+
catch (error) {
|
|
360
|
+
expect(error).toBeInstanceOf(errors_1.ForgeTeamWorkGraphValidationError);
|
|
361
|
+
expect(error.message).toContain('onResult is required and must be a function');
|
|
362
|
+
}
|
|
327
363
|
});
|
|
328
364
|
});
|
|
329
365
|
});
|
package/out/graph.d.ts
CHANGED
|
@@ -13,9 +13,6 @@ export declare class TeamWorkGraphClient implements TeamWorkGraph {
|
|
|
13
13
|
mapUsers: (request: MapUsersRequest) => Promise<MapUsersResponse>;
|
|
14
14
|
fetchData: (request: FetchDataRequest) => Promise<FetchDataResponse>;
|
|
15
15
|
transformData: (request: TransformDataRequest) => Promise<TransformDataResponse>;
|
|
16
|
-
private sendPostRequest;
|
|
17
|
-
private sendDeleteRequest;
|
|
18
|
-
private sendGetRequest;
|
|
19
16
|
private sendRequest;
|
|
20
17
|
}
|
|
21
18
|
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":"AAuBA,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,8BAA8B,EAC9B,+BAA+B,EAC/B,0BAA0B,EAC1B,2BAA2B,EAC3B,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,+BAA+B,EAC/B,gCAAgC,EAChC,2BAA2B,EAC3B,4BAA4B,EAC5B,4BAA4B,EAC5B,6BAA6B,EAC7B,iCAAiC,EACjC,kCAAkC,EAClC,iCAAiC,EACjC,kCAAkC,EAClC,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,SAAS,CAAC;AAIjB,qBAAa,mBAAoB,YAAW,aAAa;IACvD,WAAW,YAAmB,iBAAiB,KAAG,QAAQ,kBAAkB,CAAC,CAa3E;IAKF,qBAAqB,YAAmB,4BAA4B,KAAG,QAAQ,6BAA6B,CAAC,CAmB3G;IAKF,0BAA0B,YACf,iCAAiC,KACzC,QAAQ,kCAAkC,CAAC,CAa5C;IAKF,0BAA0B,YACf,iCAAiC,KACzC,QAAQ,kCAAkC,CAAC,CAY5C;IAKF,SAAS,YAAmB,iBAAiB,KAAG,QAAQ,kBAAkB,CAAC,CAazE;IAKF,wBAAwB,YACb,+BAA+B,KACvC,QAAQ,gCAAgC,CAAC,CAa1C;IAKF,oBAAoB,YAAmB,2BAA2B,KAAG,QAAQ,4BAA4B,CAAC,CAkBxG;IAEF,QAAQ,YAAmB,gBAAgB,KAAG,QAAQ,iBAAiB,CAAC,CAatE;IAEF,uBAAuB,YACZ,8BAA8B,KACtC,QAAQ,+BAA+B,CAAC,CAazC;IAEF,mBAAmB,YAAmB,0BAA0B,KAAG,QAAQ,2BAA2B,CAAC,CAkBrG;IAEF,QAAQ,YAAmB,eAAe,KAAG,QAAQ,gBAAgB,CAAC,CAapE;IAEF,SAAS,YAAmB,gBAAgB,KAAG,QAAQ,iBAAiB,CAAC,CA2BvE;IAEF,aAAa,YAAmB,oBAAoB,KAAG,QAAQ,qBAAqB,CAAC,CAoBnF;YAEY,WAAW;CA2B1B;AAED,eAAO,MAAM,aAAa,qBAA4B,CAAC"}
|