@forge/teamwork-graph 2.3.0-next.0 → 2.3.0-next.2
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 +15 -38
- package/out/__test__/user-operations.test.js +3 -3
- package/out/__test__/validators.test.js +8 -72
- package/out/graph.d.ts.map +1 -1
- package/out/graph.js +4 -2
- package/out/types/requests.d.ts +2 -7
- package/out/types/requests.d.ts.map +1 -1
- package/out/utils/validators.d.ts +6 -2
- package/out/utils/validators.d.ts.map +1 -1
- package/out/utils/validators.js +20 -5
- package/package.json +2 -2
|
@@ -390,62 +390,32 @@ describe('TeamWorkGraphClient - deleteObjectsByProperties', () => {
|
|
|
390
390
|
api_1.__fetchProduct.mockReturnValue(mockFetch);
|
|
391
391
|
jest.clearAllMocks();
|
|
392
392
|
});
|
|
393
|
-
it('should successfully delete objects by
|
|
393
|
+
it('should successfully delete objects by single property', async () => {
|
|
394
394
|
const expectedResponse = {
|
|
395
|
-
success: true
|
|
396
|
-
results: [
|
|
397
|
-
{ objectId: 'entity-123', success: true },
|
|
398
|
-
{ objectId: 'entity-456', success: true }
|
|
399
|
-
]
|
|
395
|
+
success: true
|
|
400
396
|
};
|
|
401
397
|
mockFetch.mockResolvedValueOnce({
|
|
402
398
|
ok: true,
|
|
403
399
|
json: () => Promise.resolve(expectedResponse)
|
|
404
400
|
});
|
|
405
401
|
const result = await graphClient.deleteObjectsByProperties({
|
|
406
|
-
environment: 'staging'
|
|
407
|
-
status: 'failed'
|
|
402
|
+
environment: 'staging'
|
|
408
403
|
});
|
|
409
404
|
expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.OBJECTS.DELETE_BY_PROPERTIES), {
|
|
410
405
|
method: 'DELETE',
|
|
411
406
|
body: JSON.stringify({
|
|
412
|
-
environment: 'staging'
|
|
413
|
-
status: 'failed'
|
|
407
|
+
environment: 'staging'
|
|
414
408
|
}),
|
|
415
409
|
redirect: 'follow',
|
|
416
410
|
headers: { 'Content-Type': 'application/json' }
|
|
417
411
|
});
|
|
418
412
|
expect(result).toEqual(expectedResponse);
|
|
419
413
|
});
|
|
420
|
-
it('should
|
|
421
|
-
|
|
422
|
-
success: true,
|
|
423
|
-
results: [{ objectId: 'entity-789', success: true }]
|
|
424
|
-
};
|
|
425
|
-
mockFetch.mockResolvedValueOnce({
|
|
426
|
-
ok: true,
|
|
427
|
-
json: () => Promise.resolve(expectedResponse)
|
|
428
|
-
});
|
|
429
|
-
const result = await graphClient.deleteObjectsByProperties({
|
|
414
|
+
it('should throw error when multiple properties are provided', async () => {
|
|
415
|
+
await expect(graphClient.deleteObjectsByProperties({
|
|
430
416
|
environment: 'production',
|
|
431
|
-
status: 'completed'
|
|
432
|
-
|
|
433
|
-
team: 'backend',
|
|
434
|
-
region: 'us-east-1'
|
|
435
|
-
});
|
|
436
|
-
expect(mockFetch).toHaveBeenCalledWith((0, endpoints_1.getFullPath)(endpoints_1.ENDPOINTS.OBJECTS.DELETE_BY_PROPERTIES), {
|
|
437
|
-
method: 'DELETE',
|
|
438
|
-
body: JSON.stringify({
|
|
439
|
-
environment: 'production',
|
|
440
|
-
status: 'completed',
|
|
441
|
-
priority: 'high',
|
|
442
|
-
team: 'backend',
|
|
443
|
-
region: 'us-east-1'
|
|
444
|
-
}),
|
|
445
|
-
redirect: 'follow',
|
|
446
|
-
headers: { 'Content-Type': 'application/json' }
|
|
447
|
-
});
|
|
448
|
-
expect(result).toEqual(expectedResponse);
|
|
417
|
+
status: 'completed'
|
|
418
|
+
})).rejects.toThrow('properties object must contain exactly 1 property');
|
|
449
419
|
});
|
|
450
420
|
it('should throw error when properties is missing', async () => {
|
|
451
421
|
await expect(graphClient.deleteObjectsByProperties(null)).rejects.toThrow('properties must be an object');
|
|
@@ -456,6 +426,13 @@ describe('TeamWorkGraphClient - deleteObjectsByProperties', () => {
|
|
|
456
426
|
it('should throw error when properties object is empty', async () => {
|
|
457
427
|
await expect(graphClient.deleteObjectsByProperties({})).rejects.toThrow('properties object cannot be empty');
|
|
458
428
|
});
|
|
429
|
+
it('should throw error when multiple properties are provided', async () => {
|
|
430
|
+
await expect(graphClient.deleteObjectsByProperties({
|
|
431
|
+
environment: 'production',
|
|
432
|
+
status: 'completed',
|
|
433
|
+
priority: 'high'
|
|
434
|
+
})).rejects.toThrow('properties object must contain exactly 1 property');
|
|
435
|
+
});
|
|
459
436
|
});
|
|
460
437
|
describe('TeamWorkGraphClient - bulk entities', () => {
|
|
461
438
|
let graphClient;
|
|
@@ -203,7 +203,7 @@ describe('TeamWorkGraphClient - User Operations', () => {
|
|
|
203
203
|
};
|
|
204
204
|
const mappingWithEmail = {
|
|
205
205
|
externalId: 'user-456',
|
|
206
|
-
|
|
206
|
+
email: 'tagapitos@my-company.com',
|
|
207
207
|
updateSequenceNumber: 2,
|
|
208
208
|
updatedAt: Date.now()
|
|
209
209
|
};
|
|
@@ -286,7 +286,7 @@ describe('TeamWorkGraphClient - User Operations', () => {
|
|
|
286
286
|
directMappings: null
|
|
287
287
|
})).rejects.toThrow('directMappings must be an array');
|
|
288
288
|
});
|
|
289
|
-
it('should throw error when mapping has neither accountId nor
|
|
289
|
+
it('should throw error when mapping has neither accountId nor email', async () => {
|
|
290
290
|
const invalidMapping = {
|
|
291
291
|
externalId: 'user-123',
|
|
292
292
|
updateSequenceNumber: 1,
|
|
@@ -294,7 +294,7 @@ describe('TeamWorkGraphClient - User Operations', () => {
|
|
|
294
294
|
};
|
|
295
295
|
await expect(graphClient.mapUsers({
|
|
296
296
|
directMappings: [invalidMapping]
|
|
297
|
-
})).rejects.toThrow('Each mapping must have either accountId or
|
|
297
|
+
})).rejects.toThrow('Each mapping must have either accountId or email');
|
|
298
298
|
});
|
|
299
299
|
it('should throw error when mapping is missing externalId', async () => {
|
|
300
300
|
const invalidMapping = {
|
|
@@ -148,7 +148,7 @@ describe('TeamWorkGraphClient - Validators', () => {
|
|
|
148
148
|
it('should pass with valid mappings', () => {
|
|
149
149
|
const mappings = [
|
|
150
150
|
{ externalId: '1', accountId: 'acc1' },
|
|
151
|
-
{ externalId: '2',
|
|
151
|
+
{ externalId: '2', email: 'user@example.com' }
|
|
152
152
|
];
|
|
153
153
|
expect(() => (0, validators_1.validateMapUsersRequest)(mappings)).not.toThrow();
|
|
154
154
|
});
|
|
@@ -164,7 +164,7 @@ describe('TeamWorkGraphClient - Validators', () => {
|
|
|
164
164
|
const mappings = Array(validators_1.MAX_USER_MAPPINGS + 1).fill({ externalId: '1', accountId: 'acc1' });
|
|
165
165
|
expect(() => (0, validators_1.validateMapUsersRequest)(mappings)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
166
166
|
});
|
|
167
|
-
it('should throw validation error for mapping without accountId or
|
|
167
|
+
it('should throw validation error for mapping without accountId or email', () => {
|
|
168
168
|
const mappings = [{ externalId: '1' }];
|
|
169
169
|
expect(() => (0, validators_1.validateMapUsersRequest)(mappings)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
170
170
|
});
|
|
@@ -174,8 +174,8 @@ describe('TeamWorkGraphClient - Validators', () => {
|
|
|
174
174
|
});
|
|
175
175
|
});
|
|
176
176
|
describe('validateDeleteObjectsByPropertiesRequest', () => {
|
|
177
|
-
it('should pass with valid
|
|
178
|
-
const properties = { type: 'issue'
|
|
177
|
+
it('should pass with valid single property object', () => {
|
|
178
|
+
const properties = { type: 'issue' };
|
|
179
179
|
expect(() => (0, validators_1.validateDeleteObjectsByPropertiesRequest)(properties)).not.toThrow();
|
|
180
180
|
});
|
|
181
181
|
it('should throw validation error for non-object input', () => {
|
|
@@ -186,6 +186,10 @@ describe('TeamWorkGraphClient - Validators', () => {
|
|
|
186
186
|
it('should throw validation error for empty object', () => {
|
|
187
187
|
expect(() => (0, validators_1.validateDeleteObjectsByPropertiesRequest)({})).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
188
188
|
});
|
|
189
|
+
it('should throw validation error for multiple properties', () => {
|
|
190
|
+
const properties = { type: 'issue', status: 'open' };
|
|
191
|
+
expect(() => (0, validators_1.validateDeleteObjectsByPropertiesRequest)(properties)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
192
|
+
});
|
|
189
193
|
});
|
|
190
194
|
describe('validateFetchDataRequest', () => {
|
|
191
195
|
it('should pass with valid request', () => {
|
|
@@ -304,72 +308,4 @@ describe('TeamWorkGraphClient - Validators', () => {
|
|
|
304
308
|
expect(() => (0, validators_1.validateTransformDataRequest)(request)).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
305
309
|
});
|
|
306
310
|
});
|
|
307
|
-
describe('Error Handling Integration', () => {
|
|
308
|
-
it('should handle validation errors with proper error types', () => {
|
|
309
|
-
expect(() => (0, validators_1.validateSetObjectsRequest)('invalid')).toThrow(errors_1.ForgeTeamWorkGraphValidationError);
|
|
310
|
-
try {
|
|
311
|
-
(0, validators_1.validateSetObjectsRequest)([]);
|
|
312
|
-
}
|
|
313
|
-
catch (error) {
|
|
314
|
-
expect(error).toBeInstanceOf(errors_1.ForgeTeamWorkGraphValidationError);
|
|
315
|
-
expect(error.message).toContain('objects array cannot be empty');
|
|
316
|
-
}
|
|
317
|
-
});
|
|
318
|
-
it('should handle array max length validation with proper error details', () => {
|
|
319
|
-
const objects = Array(validators_1.MAX_BULK_OBJECTS + 1).fill({ id: '1' });
|
|
320
|
-
try {
|
|
321
|
-
(0, validators_1.validateSetObjectsRequest)(objects);
|
|
322
|
-
}
|
|
323
|
-
catch (error) {
|
|
324
|
-
expect(error).toBeInstanceOf(errors_1.ForgeTeamWorkGraphValidationError);
|
|
325
|
-
expect(error.message).toContain(`supports maximum ${validators_1.MAX_BULK_OBJECTS} objects`);
|
|
326
|
-
expect(error.message).toContain(`Received ${validators_1.MAX_BULK_OBJECTS + 1}`);
|
|
327
|
-
}
|
|
328
|
-
});
|
|
329
|
-
it('should handle user mapping validation with proper error details', () => {
|
|
330
|
-
const mappings = [{ externalId: '1' }];
|
|
331
|
-
try {
|
|
332
|
-
(0, validators_1.validateMapUsersRequest)(mappings);
|
|
333
|
-
}
|
|
334
|
-
catch (error) {
|
|
335
|
-
expect(error).toBeInstanceOf(errors_1.ForgeTeamWorkGraphValidationError);
|
|
336
|
-
expect(error.message).toContain('Each mapping must have either accountId or externalEmailAddress');
|
|
337
|
-
}
|
|
338
|
-
});
|
|
339
|
-
it('should handle required string validation with proper error details', () => {
|
|
340
|
-
try {
|
|
341
|
-
(0, validators_1.validateGetObjectByExternalIdRequest)('', '123');
|
|
342
|
-
}
|
|
343
|
-
catch (error) {
|
|
344
|
-
expect(error).toBeInstanceOf(errors_1.ForgeTeamWorkGraphValidationError);
|
|
345
|
-
expect(error.message).toContain('objectType is required');
|
|
346
|
-
}
|
|
347
|
-
});
|
|
348
|
-
it('should handle object validation with proper error details', () => {
|
|
349
|
-
try {
|
|
350
|
-
(0, validators_1.validateDeleteObjectsByPropertiesRequest)({});
|
|
351
|
-
}
|
|
352
|
-
catch (error) {
|
|
353
|
-
expect(error).toBeInstanceOf(errors_1.ForgeTeamWorkGraphValidationError);
|
|
354
|
-
expect(error.message).toContain('properties object cannot be empty');
|
|
355
|
-
}
|
|
356
|
-
});
|
|
357
|
-
it('should handle function validation with proper error details', () => {
|
|
358
|
-
const request = {
|
|
359
|
-
requestConfig: {
|
|
360
|
-
url: 'https://api.example.com/data',
|
|
361
|
-
method: 'GET',
|
|
362
|
-
headers: {}
|
|
363
|
-
},
|
|
364
|
-
onResult: 'not a function'
|
|
365
|
-
};
|
|
366
|
-
try {
|
|
367
|
-
(0, validators_1.validateFetchDataRequest)(request);
|
|
368
|
-
}
|
|
369
|
-
catch (error) {
|
|
370
|
-
expect(error).toBeInstanceOf(errors_1.ForgeTeamWorkGraphValidationError);
|
|
371
|
-
expect(error.message).toContain('onResult is required and must be a function');
|
|
372
|
-
}
|
|
373
|
-
});
|
|
374
|
-
});
|
|
375
311
|
});
|
package/out/graph.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../src/graph.ts"],"names":[],"mappings":"AAwBA,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,8BAA8B,EAC9B,+BAA+B,EAC/B,0BAA0B,EAC1B,2BAA2B,EAC3B,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,+BAA+B,EAC/B,gCAAgC,EAChC,2BAA2B,EAC3B,4BAA4B,EAC5B,4BAA4B,EAC5B,6BAA6B,EAC7B,gCAAgC,EAChC,iCAAiC,EACjC,gCAAgC,EAChC,iCAAiC,EACjC,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,SAAS,CAAC;AAEjB,qBAAa,mBAAoB,YAAW,aAAa;IACvD,UAAU,YAAmB,iBAAiB,KAAG,QAAQ,kBAAkB,CAAC,CAoB1E;IAKF,qBAAqB,YAAmB,4BAA4B,KAAG,QAAQ,6BAA6B,CAAC,CAoB3G;IAKF,yBAAyB,YACd,gCAAgC,KACxC,QAAQ,iCAAiC,CAAC,CAe3C;IAKF,yBAAyB,YACd,gCAAgC,KACxC,QAAQ,iCAAiC,CAAC,
|
|
1
|
+
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../src/graph.ts"],"names":[],"mappings":"AAwBA,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,8BAA8B,EAC9B,+BAA+B,EAC/B,0BAA0B,EAC1B,2BAA2B,EAC3B,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,+BAA+B,EAC/B,gCAAgC,EAChC,2BAA2B,EAC3B,4BAA4B,EAC5B,4BAA4B,EAC5B,6BAA6B,EAC7B,gCAAgC,EAChC,iCAAiC,EACjC,gCAAgC,EAChC,iCAAiC,EACjC,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,SAAS,CAAC;AAEjB,qBAAa,mBAAoB,YAAW,aAAa;IACvD,UAAU,YAAmB,iBAAiB,KAAG,QAAQ,kBAAkB,CAAC,CAoB1E;IAKF,qBAAqB,YAAmB,4BAA4B,KAAG,QAAQ,6BAA6B,CAAC,CAoB3G;IAKF,yBAAyB,YACd,gCAAgC,KACxC,QAAQ,iCAAiC,CAAC,CAe3C;IAKF,yBAAyB,YACd,gCAAgC,KACxC,QAAQ,iCAAiC,CAAC,CAc3C;IAKF,SAAS,YAAmB,iBAAiB,KAAG,QAAQ,kBAAkB,CAAC,CAmBzE;IAKF,wBAAwB,YACb,+BAA+B,KACvC,QAAQ,gCAAgC,CAAC,CAgB1C;IAKF,oBAAoB,YAAmB,2BAA2B,KAAG,QAAQ,4BAA4B,CAAC,CAgBxG;IAEF,QAAQ,YAAmB,gBAAgB,KAAG,QAAQ,iBAAiB,CAAC,CAoBtE;IAEF,uBAAuB,YACZ,8BAA8B,KACtC,QAAQ,+BAA+B,CAAC,CAgBzC;IAEF,mBAAmB,YAAmB,0BAA0B,KAAG,QAAQ,2BAA2B,CAAC,CAgBrG;IAEF,QAAQ,YAAmB,eAAe,KAAG,QAAQ,gBAAgB,CAAC,CAapE;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"}
|
package/out/graph.js
CHANGED
|
@@ -68,11 +68,13 @@ class TeamWorkGraphClient {
|
|
|
68
68
|
deleteObjectsByProperties = async (request) => {
|
|
69
69
|
(0, validators_1.validateDeleteObjectsByPropertiesRequest)(request);
|
|
70
70
|
try {
|
|
71
|
-
|
|
71
|
+
await this.sendRequest(endpoints_1.ENDPOINTS.OBJECTS.DELETE_BY_PROPERTIES, {
|
|
72
72
|
method: 'DELETE',
|
|
73
73
|
body: JSON.stringify(request)
|
|
74
74
|
});
|
|
75
|
-
return
|
|
75
|
+
return {
|
|
76
|
+
success: true
|
|
77
|
+
};
|
|
76
78
|
}
|
|
77
79
|
catch (error) {
|
|
78
80
|
return (0, error_handling_1.handleError)(error, 'delete objects by properties');
|
package/out/types/requests.d.ts
CHANGED
|
@@ -55,14 +55,9 @@ export declare type DeleteObjectsByExternalIdResponse = {
|
|
|
55
55
|
error?: string;
|
|
56
56
|
originalError?: unknown;
|
|
57
57
|
};
|
|
58
|
-
export declare type DeleteObjectsByPropertiesRequest = Record<string,
|
|
58
|
+
export declare type DeleteObjectsByPropertiesRequest = Record<string, string>;
|
|
59
59
|
export declare type DeleteObjectsByPropertiesResponse = {
|
|
60
60
|
success: boolean;
|
|
61
|
-
results?: Array<{
|
|
62
|
-
objectId: string;
|
|
63
|
-
success: boolean;
|
|
64
|
-
error?: string;
|
|
65
|
-
}>;
|
|
66
61
|
error?: string;
|
|
67
62
|
originalError?: unknown;
|
|
68
63
|
};
|
|
@@ -115,7 +110,7 @@ export declare type UserMapping = {
|
|
|
115
110
|
updateSequenceNumber: number;
|
|
116
111
|
updatedAt: number;
|
|
117
112
|
accountId?: string;
|
|
118
|
-
|
|
113
|
+
email?: string;
|
|
119
114
|
};
|
|
120
115
|
export declare type MapUsersRequest = {
|
|
121
116
|
directMappings: UserMapping[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requests.d.ts","sourceRoot":"","sources":["../../src/types/requests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,IAAI,CAAC;AAGpE,oBAAY,iBAAiB,GAAG;IAC9B,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACrC,CAAC;AAE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AAqB,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"}
|
|
@@ -4,10 +4,14 @@ export declare const MAX_BULK_GROUPS = 100;
|
|
|
4
4
|
export declare const MAX_BULK_OBJECTS_DELETE = 100;
|
|
5
5
|
export declare const MAX_USER_MAPPINGS = 100;
|
|
6
6
|
export declare const MAX_PROPERTIES = 5;
|
|
7
|
+
export declare const MAX_BULK_USERS_DELETE = 100;
|
|
8
|
+
export declare const MAX_BULK_GROUPS_DELETE = 100;
|
|
9
|
+
export declare const MAX_PROPERTIES_DELETE = 1;
|
|
7
10
|
export declare function validateArray(value: any, fieldName: string): void;
|
|
8
|
-
export declare function validateArrayMaxLength(value: any[],
|
|
11
|
+
export declare function validateArrayMaxLength(value: any[], operationDescription: string, maxLength: number, fieldName?: string): void;
|
|
9
12
|
export declare function validateRequiredString(value: string | undefined, fieldName: string): void;
|
|
10
13
|
export declare function validateObject(value: any, fieldName: string): void;
|
|
14
|
+
export declare function validatePropertyCount(value: Record<string, any>, fieldName: string, expectedCount: number): void;
|
|
11
15
|
export declare function validateSetObjectsRequest(objects: any[], properties?: Record<string, any>): void;
|
|
12
16
|
export declare function validateSetUsersRequest(users: any[]): void;
|
|
13
17
|
export declare function validateSetGroupsRequest(groups: any[]): void;
|
|
@@ -18,7 +22,7 @@ export declare function validateGetObjectByExternalIdRequest(objectType: string,
|
|
|
18
22
|
export declare function validateGetUserByExternalIdRequest(externalId: string): void;
|
|
19
23
|
export declare function validateGetGroupByExternalIdRequest(externalId: string): void;
|
|
20
24
|
export declare function validateMapUsersRequest(directMappings: any[]): void;
|
|
21
|
-
export declare function validateDeleteObjectsByPropertiesRequest(properties:
|
|
25
|
+
export declare function validateDeleteObjectsByPropertiesRequest(properties: Record<string, string>): void;
|
|
22
26
|
export declare function validateFetchDataRequest(request: any): void;
|
|
23
27
|
export declare function validateTransformDataRequest(request: any): void;
|
|
24
28
|
//# sourceMappingURL=validators.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../src/utils/validators.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,gBAAgB,MAAM,CAAC;AACpC,eAAO,MAAM,cAAc,MAAM,CAAC;AAClC,eAAO,MAAM,eAAe,MAAM,CAAC;AACnC,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAC3C,eAAO,MAAM,iBAAiB,MAAM,CAAC;AACrC,eAAO,MAAM,cAAc,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../src/utils/validators.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,gBAAgB,MAAM,CAAC;AACpC,eAAO,MAAM,cAAc,MAAM,CAAC;AAClC,eAAO,MAAM,eAAe,MAAM,CAAC;AACnC,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAC3C,eAAO,MAAM,iBAAiB,MAAM,CAAC;AACrC,eAAO,MAAM,cAAc,IAAI,CAAC;AAChC,eAAO,MAAM,qBAAqB,MAAM,CAAC;AACzC,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAC1C,eAAO,MAAM,qBAAqB,IAAI,CAAC;AAKvC,wBAAgB,aAAa,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAOjE;AASD,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,GAAG,EAAE,EACZ,oBAAoB,EAAE,MAAM,EAC5B,SAAS,EAAE,MAAM,EACjB,SAAS,SAAU,GAClB,IAAI,CAQN;AAKD,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAIzF;AAKD,wBAAgB,cAAc,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAA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ED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateTransformDataRequest = exports.validateFetchDataRequest = exports.validateDeleteObjectsByPropertiesRequest = exports.validateMapUsersRequest = exports.validateGetGroupByExternalIdRequest = exports.validateGetUserByExternalIdRequest = exports.validateGetObjectByExternalIdRequest = exports.validateDeleteGroupsByExternalIdRequest = exports.validateDeleteUsersByExternalIdRequest = exports.validateDeleteObjectsByExternalIdRequest = exports.validateSetGroupsRequest = exports.validateSetUsersRequest = exports.validateSetObjectsRequest = exports.validateObject = exports.validateRequiredString = exports.validateArrayMaxLength = exports.validateArray = exports.MAX_PROPERTIES = exports.MAX_USER_MAPPINGS = exports.MAX_BULK_OBJECTS_DELETE = exports.MAX_BULK_GROUPS = exports.MAX_BULK_USERS = exports.MAX_BULK_OBJECTS = void 0;
|
|
3
|
+
exports.validateTransformDataRequest = exports.validateFetchDataRequest = exports.validateDeleteObjectsByPropertiesRequest = exports.validateMapUsersRequest = exports.validateGetGroupByExternalIdRequest = exports.validateGetUserByExternalIdRequest = exports.validateGetObjectByExternalIdRequest = exports.validateDeleteGroupsByExternalIdRequest = exports.validateDeleteUsersByExternalIdRequest = exports.validateDeleteObjectsByExternalIdRequest = exports.validateSetGroupsRequest = exports.validateSetUsersRequest = exports.validateSetObjectsRequest = exports.validatePropertyCount = exports.validateObject = exports.validateRequiredString = exports.validateArrayMaxLength = exports.validateArray = exports.MAX_PROPERTIES_DELETE = exports.MAX_BULK_GROUPS_DELETE = exports.MAX_BULK_USERS_DELETE = exports.MAX_PROPERTIES = exports.MAX_USER_MAPPINGS = exports.MAX_BULK_OBJECTS_DELETE = exports.MAX_BULK_GROUPS = exports.MAX_BULK_USERS = exports.MAX_BULK_OBJECTS = void 0;
|
|
4
4
|
const errors_1 = require("./errors");
|
|
5
5
|
exports.MAX_BULK_OBJECTS = 100;
|
|
6
6
|
exports.MAX_BULK_USERS = 100;
|
|
@@ -8,6 +8,9 @@ exports.MAX_BULK_GROUPS = 100;
|
|
|
8
8
|
exports.MAX_BULK_OBJECTS_DELETE = 100;
|
|
9
9
|
exports.MAX_USER_MAPPINGS = 100;
|
|
10
10
|
exports.MAX_PROPERTIES = 5;
|
|
11
|
+
exports.MAX_BULK_USERS_DELETE = 100;
|
|
12
|
+
exports.MAX_BULK_GROUPS_DELETE = 100;
|
|
13
|
+
exports.MAX_PROPERTIES_DELETE = 1;
|
|
11
14
|
function validateArray(value, fieldName) {
|
|
12
15
|
if (!Array.isArray(value)) {
|
|
13
16
|
throw new errors_1.ForgeTeamWorkGraphValidationError(`${fieldName} must be an array`, fieldName);
|
|
@@ -17,9 +20,9 @@ function validateArray(value, fieldName) {
|
|
|
17
20
|
}
|
|
18
21
|
}
|
|
19
22
|
exports.validateArray = validateArray;
|
|
20
|
-
function validateArrayMaxLength(value,
|
|
23
|
+
function validateArrayMaxLength(value, operationDescription, maxLength, fieldName = 'items') {
|
|
21
24
|
if (value.length > maxLength) {
|
|
22
|
-
throw new errors_1.ForgeTeamWorkGraphValidationError(`${
|
|
25
|
+
throw new errors_1.ForgeTeamWorkGraphValidationError(`${operationDescription} supports maximum ${maxLength} ${fieldName}. Received ${value.length}`, operationDescription, { maxLength, actualLength: value.length, fieldName });
|
|
23
26
|
}
|
|
24
27
|
}
|
|
25
28
|
exports.validateArrayMaxLength = validateArrayMaxLength;
|
|
@@ -38,6 +41,13 @@ function validateObject(value, fieldName) {
|
|
|
38
41
|
}
|
|
39
42
|
}
|
|
40
43
|
exports.validateObject = validateObject;
|
|
44
|
+
function validatePropertyCount(value, fieldName, expectedCount) {
|
|
45
|
+
const propertyCount = Object.keys(value).length;
|
|
46
|
+
if (propertyCount !== expectedCount) {
|
|
47
|
+
throw new errors_1.ForgeTeamWorkGraphValidationError(`${fieldName} object must contain exactly ${expectedCount} propert${expectedCount === 1 ? 'y' : 'ies'}. Received ${propertyCount}`, fieldName, { propertyCount, expectedCount });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.validatePropertyCount = validatePropertyCount;
|
|
41
51
|
function validateSetObjectsRequest(objects, properties) {
|
|
42
52
|
validateArray(objects, 'objects');
|
|
43
53
|
validateArrayMaxLength(objects, 'Bulk ingestion', exports.MAX_BULK_OBJECTS, 'objects');
|
|
@@ -67,10 +77,12 @@ function validateDeleteObjectsByExternalIdRequest(objectType, externalIds) {
|
|
|
67
77
|
exports.validateDeleteObjectsByExternalIdRequest = validateDeleteObjectsByExternalIdRequest;
|
|
68
78
|
function validateDeleteUsersByExternalIdRequest(externalIds) {
|
|
69
79
|
validateArray(externalIds, 'externalIds');
|
|
80
|
+
validateArrayMaxLength(externalIds, 'Bulk user deletion', exports.MAX_BULK_USERS_DELETE, 'users');
|
|
70
81
|
}
|
|
71
82
|
exports.validateDeleteUsersByExternalIdRequest = validateDeleteUsersByExternalIdRequest;
|
|
72
83
|
function validateDeleteGroupsByExternalIdRequest(externalIds) {
|
|
73
84
|
validateArray(externalIds, 'externalIds');
|
|
85
|
+
validateArrayMaxLength(externalIds, 'Bulk group deletion', exports.MAX_BULK_GROUPS_DELETE, 'groups');
|
|
74
86
|
}
|
|
75
87
|
exports.validateDeleteGroupsByExternalIdRequest = validateDeleteGroupsByExternalIdRequest;
|
|
76
88
|
function validateGetObjectByExternalIdRequest(objectType, externalId) {
|
|
@@ -89,9 +101,11 @@ exports.validateGetGroupByExternalIdRequest = validateGetGroupByExternalIdReques
|
|
|
89
101
|
function validateMapUsersRequest(directMappings) {
|
|
90
102
|
validateArray(directMappings, 'directMappings');
|
|
91
103
|
validateArrayMaxLength(directMappings, 'Bulk user mapping', exports.MAX_USER_MAPPINGS, 'mappings');
|
|
92
|
-
const invalidMapping = directMappings.find((mapping) => !mapping.accountId && !mapping.
|
|
104
|
+
const invalidMapping = directMappings.find((mapping) => !mapping.accountId && !mapping.email);
|
|
93
105
|
if (invalidMapping) {
|
|
94
|
-
throw new errors_1.ForgeTeamWorkGraphValidationError('Each mapping must have either accountId or
|
|
106
|
+
throw new errors_1.ForgeTeamWorkGraphValidationError('Each mapping must have either accountId or email', 'directMappings', {
|
|
107
|
+
invalidMapping
|
|
108
|
+
});
|
|
95
109
|
}
|
|
96
110
|
const mappingWithoutExternalId = directMappings.find((mapping) => !mapping.externalId);
|
|
97
111
|
if (mappingWithoutExternalId) {
|
|
@@ -103,6 +117,7 @@ function validateMapUsersRequest(directMappings) {
|
|
|
103
117
|
exports.validateMapUsersRequest = validateMapUsersRequest;
|
|
104
118
|
function validateDeleteObjectsByPropertiesRequest(properties) {
|
|
105
119
|
validateObject(properties, 'properties');
|
|
120
|
+
validatePropertyCount(properties, 'properties', exports.MAX_PROPERTIES_DELETE);
|
|
106
121
|
}
|
|
107
122
|
exports.validateDeleteObjectsByPropertiesRequest = validateDeleteObjectsByPropertiesRequest;
|
|
108
123
|
function validateFetchDataRequest(request) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge/teamwork-graph",
|
|
3
|
-
"version": "2.3.0-next.
|
|
3
|
+
"version": "2.3.0-next.2",
|
|
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.1.0"
|
|
25
|
+
"@forge/api": "^6.1.1-next.0"
|
|
26
26
|
},
|
|
27
27
|
"publishConfig": {
|
|
28
28
|
"registry": "https://packages.atlassian.com/api/npm/npm-public/"
|