@mondaydotcomorg/monday-authorization 3.5.0-feat-shaime-support-entity-attributes-in-authorization-sdk-c9e4cfc → 3.5.0-feat-shaime-support-entity-attributes-in-authorization-sdk-8d846f1

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 (38) hide show
  1. package/dist/authorization-attributes-ms-service.d.ts +17 -0
  2. package/dist/authorization-attributes-ms-service.d.ts.map +1 -1
  3. package/dist/authorization-attributes-ms-service.js +166 -1
  4. package/dist/authorization-attributes-service.d.ts +52 -66
  5. package/dist/authorization-attributes-service.d.ts.map +1 -1
  6. package/dist/authorization-attributes-service.js +105 -353
  7. package/dist/constants/sns.d.ts +2 -0
  8. package/dist/constants/sns.d.ts.map +1 -1
  9. package/dist/constants/sns.js +4 -0
  10. package/dist/esm/authorization-attributes-ms-service.d.ts +17 -0
  11. package/dist/esm/authorization-attributes-ms-service.d.ts.map +1 -1
  12. package/dist/esm/authorization-attributes-ms-service.mjs +166 -1
  13. package/dist/esm/authorization-attributes-service.d.ts +52 -66
  14. package/dist/esm/authorization-attributes-service.d.ts.map +1 -1
  15. package/dist/esm/authorization-attributes-service.mjs +107 -355
  16. package/dist/esm/constants/sns.d.ts +2 -0
  17. package/dist/esm/constants/sns.d.ts.map +1 -1
  18. package/dist/esm/constants/sns.mjs +3 -1
  19. package/dist/esm/resource-attribute-assignment.d.ts.map +1 -1
  20. package/dist/esm/resource-attributes-constants.d.ts +1 -1
  21. package/dist/esm/resource-attributes-constants.d.ts.map +1 -1
  22. package/dist/esm/types/authorization-attributes-contracts.d.ts +16 -0
  23. package/dist/esm/types/authorization-attributes-contracts.d.ts.map +1 -1
  24. package/dist/esm/types/authorization-attributes-contracts.mjs +6 -1
  25. package/dist/resource-attribute-assignment.d.ts.map +1 -1
  26. package/dist/resource-attributes-constants.d.ts +1 -1
  27. package/dist/resource-attributes-constants.d.ts.map +1 -1
  28. package/dist/types/authorization-attributes-contracts.d.ts +16 -0
  29. package/dist/types/authorization-attributes-contracts.d.ts.map +1 -1
  30. package/dist/types/authorization-attributes-contracts.js +5 -0
  31. package/package.json +1 -1
  32. package/src/authorization-attributes-ms-service.ts +258 -17
  33. package/src/authorization-attributes-service.ts +146 -428
  34. package/src/constants/sns.ts +2 -0
  35. package/src/errors/argument-error.ts +1 -2
  36. package/src/resource-attribute-assignment.ts +1 -4
  37. package/src/resource-attributes-constants.ts +1 -2
  38. package/src/types/authorization-attributes-contracts.ts +22 -5
@@ -29,16 +29,32 @@ export interface ResourceAttributeDelete {
29
29
  resourceId: Resource['id'];
30
30
  key: string;
31
31
  }
32
+ export interface EntityAttributeDelete {
33
+ entityType: EntityType;
34
+ entityId: number;
35
+ key: string;
36
+ }
32
37
  export declare enum ResourceAttributeOperationEnum {
33
38
  UPSERT = "upsert",
34
39
  DELETE = "delete"
35
40
  }
41
+ export declare enum EntityAttributeOperationEnum {
42
+ UPSERT = "upsert",
43
+ DELETE = "delete"
44
+ }
36
45
  interface UpsertResourceAttributeOperation extends ResourceAttributeAssignment {
37
46
  operationType: ResourceAttributeOperationEnum.UPSERT;
38
47
  }
39
48
  interface DeleteResourceAttributeOperation extends ResourceAttributeDelete {
40
49
  operationType: ResourceAttributeOperationEnum.DELETE;
41
50
  }
51
+ interface UpsertEntityAttributeOperation extends EntityAttributeAssignment {
52
+ operationType: EntityAttributeOperationEnum.UPSERT;
53
+ }
54
+ interface DeleteEntityAttributeOperation extends EntityAttributeDelete {
55
+ operationType: EntityAttributeOperationEnum.DELETE;
56
+ }
42
57
  export type ResourceAttributesOperation = UpsertResourceAttributeOperation | DeleteResourceAttributeOperation;
58
+ export type EntityAttributesOperation = UpsertEntityAttributeOperation | DeleteEntityAttributeOperation;
43
59
  export {};
44
60
  //# sourceMappingURL=authorization-attributes-contracts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"authorization-attributes-contracts.d.ts","sourceRoot":"","sources":["../../src/types/authorization-attributes-contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAGrC,MAAM,MAAM,YAAY,GACpB,SAAS,GACT,iBAAiB,GACjB,WAAW,GACX,OAAO,GACP,MAAM,GACN,MAAM,GACN,UAAU,GACV,UAAU,GACV,KAAK,CAAC;AAGV,MAAM,MAAM,UAAU,GAClB,MAAM,GACN,MAAM,GACN,SAAS,CAAC;AAGd,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAGxC,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC;AAG1C,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAGxC,MAAM,MAAM,wBAAwB,GAAG,kBAAkB,GAAG,oBAAoB,CAAC;AACjF,MAAM,MAAM,sBAAsB,GAAG,kBAAkB,GAAG,kBAAkB,CAAC;AAG7E,MAAM,WAAW,2BAA2B;IAC1C,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,YAAY,CAAC;IAC3B,GAAG,EAAE,wBAAwB,CAAC;IAC9B,KAAK,EAAE,MAAM,CAAC;CACf;AAGD,MAAM,WAAW,yBAAyB;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,UAAU,CAAC;IACvB,GAAG,EAAE,sBAAsB,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;CACf;AAGD,MAAM,WAAW,yBAAyB;IACxC,UAAU,EAAE,2BAA2B,EAAE,CAAC;CAC3C;AAED,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,yBAAyB,EAAE,CAAC;CACzC;AAGD,MAAM,WAAW,uBAAuB;IACtC,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC/B,UAAU,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC3B,GAAG,EAAE,MAAM,CAAC;CACb;AAED,oBAAY,8BAA8B;IACxC,MAAM,WAAW;IACjB,MAAM,WAAW;CAClB;AAED,UAAU,gCAAiC,SAAQ,2BAA2B;IAC5E,aAAa,EAAE,8BAA8B,CAAC,MAAM,CAAC;CACtD;AAED,UAAU,gCAAiC,SAAQ,uBAAuB;IACxE,aAAa,EAAE,8BAA8B,CAAC,MAAM,CAAC;CACtD;AAED,MAAM,MAAM,2BAA2B,GAAG,gCAAgC,GAAG,gCAAgC,CAAC"}
1
+ {"version":3,"file":"authorization-attributes-contracts.d.ts","sourceRoot":"","sources":["../../src/types/authorization-attributes-contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAGrC,MAAM,MAAM,YAAY,GACpB,SAAS,GACT,iBAAiB,GACjB,WAAW,GACX,OAAO,GACP,MAAM,GACN,MAAM,GACN,UAAU,GACV,UAAU,GACV,KAAK,CAAC;AAGV,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AAGrD,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAGxC,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC;AAG1C,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAGxC,MAAM,MAAM,wBAAwB,GAAG,kBAAkB,GAAG,oBAAoB,CAAC;AACjF,MAAM,MAAM,sBAAsB,GAAG,kBAAkB,GAAG,kBAAkB,CAAC;AAG7E,MAAM,WAAW,2BAA2B;IAC1C,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,YAAY,CAAC;IAC3B,GAAG,EAAE,wBAAwB,CAAC;IAC9B,KAAK,EAAE,MAAM,CAAC;CACf;AAGD,MAAM,WAAW,yBAAyB;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,UAAU,CAAC;IACvB,GAAG,EAAE,sBAAsB,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;CACf;AAGD,MAAM,WAAW,yBAAyB;IACxC,UAAU,EAAE,2BAA2B,EAAE,CAAC;CAC3C;AAED,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,yBAAyB,EAAE,CAAC;CACzC;AAGD,MAAM,WAAW,uBAAuB;IACtC,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC/B,UAAU,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC3B,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,UAAU,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,oBAAY,8BAA8B;IACxC,MAAM,WAAW;IACjB,MAAM,WAAW;CAClB;AAED,oBAAY,4BAA4B;IACtC,MAAM,WAAW;IACjB,MAAM,WAAW;CAClB;AAED,UAAU,gCAAiC,SAAQ,2BAA2B;IAC5E,aAAa,EAAE,8BAA8B,CAAC,MAAM,CAAC;CACtD;AAED,UAAU,gCAAiC,SAAQ,uBAAuB;IACxE,aAAa,EAAE,8BAA8B,CAAC,MAAM,CAAC;CACtD;AAED,UAAU,8BAA+B,SAAQ,yBAAyB;IACxE,aAAa,EAAE,4BAA4B,CAAC,MAAM,CAAC;CACpD;AAED,UAAU,8BAA+B,SAAQ,qBAAqB;IACpE,aAAa,EAAE,4BAA4B,CAAC,MAAM,CAAC;CACpD;AAED,MAAM,MAAM,2BAA2B,GAAG,gCAAgC,GAAG,gCAAgC,CAAC;AAC9G,MAAM,MAAM,yBAAyB,GAAG,8BAA8B,GAAG,8BAA8B,CAAC"}
@@ -5,3 +5,8 @@ exports.ResourceAttributeOperationEnum = void 0;
5
5
  ResourceAttributeOperationEnum["UPSERT"] = "upsert";
6
6
  ResourceAttributeOperationEnum["DELETE"] = "delete";
7
7
  })(exports.ResourceAttributeOperationEnum || (exports.ResourceAttributeOperationEnum = {}));
8
+ exports.EntityAttributeOperationEnum = void 0;
9
+ (function (EntityAttributeOperationEnum) {
10
+ EntityAttributeOperationEnum["UPSERT"] = "upsert";
11
+ EntityAttributeOperationEnum["DELETE"] = "delete";
12
+ })(exports.EntityAttributeOperationEnum || (exports.EntityAttributeOperationEnum = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mondaydotcomorg/monday-authorization",
3
- "version": "3.5.0-feat-shaime-support-entity-attributes-in-authorization-sdk-c9e4cfc",
3
+ "version": "3.5.0-feat-shaime-support-entity-attributes-in-authorization-sdk-8d846f1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "license": "BSD-3-Clause",
@@ -1,16 +1,22 @@
1
- import { Api, HttpClient } from '@mondaydotcomorg/trident-backend-api';
1
+ import { Api } from '@mondaydotcomorg/trident-backend-api';
2
2
  import { signAuthorizationHeader } from '@mondaydotcomorg/monday-jwt';
3
3
  import { HttpFetcherError } from '@mondaydotcomorg/monday-fetch-api';
4
4
  import { ResourceAttributeAssignment } from './resource-attribute-assignment';
5
+ import {
6
+ EntityAttributeAssignment,
7
+ EntityType,
8
+ EntityAttributeKeyType,
9
+ } from './types/authorization-attributes-contracts';
5
10
  import { ArgumentError } from './errors/argument-error';
6
- import { logger } from './authorization-internal-service';
11
+ import { AuthorizationInternalService, logger } from './authorization-internal-service';
7
12
  import { getAttributionsFromApi } from './attributions-service';
8
- import { AuthorizationInternalService } from './authorization-internal-service';
9
13
  import { APP_NAME } from './constants';
10
14
 
11
15
  const INTERNAL_APP_NAME = 'internal_ms';
12
16
  const UPSERT_RESOURCE_ATTRIBUTES_PATH = '/attributes/{accountId}/resource';
13
17
  const DELETE_RESOURCE_ATTRIBUTES_PATH = '/attributes/{accountId}/resource/{resourceType}/{resourceId}';
18
+ const UPSERT_ENTITY_ATTRIBUTES_PATH = '/attributes/{accountId}/entity';
19
+ const DELETE_ENTITY_ATTRIBUTES_PATH = '/attributes/{accountId}/entity/{entityType}/{entityId}';
14
20
 
15
21
  interface Resource {
16
22
  resourceType: string;
@@ -18,12 +24,21 @@ interface Resource {
18
24
  }
19
25
 
20
26
  interface UpsertRequestBody {
21
- resourceAttributeAssignments: Array<{
27
+ resourceAttributeAssignments: {
22
28
  resourceId: number;
23
29
  resourceType: string;
24
30
  key: string;
25
31
  value: string;
26
- }>;
32
+ }[];
33
+ }
34
+
35
+ interface UpsertEntityRequestBody {
36
+ entityAttributeAssignments: {
37
+ entityId: number;
38
+ entityType: string;
39
+ key: string;
40
+ value: string;
41
+ }[];
27
42
  }
28
43
 
29
44
  interface DeleteRequestBody {
@@ -56,7 +71,7 @@ export class AuthorizationAttributesMsService {
56
71
  // Add attribution headers if available
57
72
  const attributionHeaders = getAttributionsFromApi();
58
73
  for (const key in attributionHeaders) {
59
- if (attributionHeaders.hasOwnProperty(key)) {
74
+ if (Object.prototype.hasOwnProperty.call(attributionHeaders, key)) {
60
75
  headers[key] = attributionHeaders[key];
61
76
  }
62
77
  }
@@ -90,10 +105,7 @@ export class AuthorizationAttributesMsService {
90
105
  /**
91
106
  * Validates that all messages are instances of the specified message class
92
107
  */
93
- private static validateMessages<T>(
94
- attributesMessages: T[],
95
- messageClass: new (...args: any[]) => T
96
- ): void {
108
+ private static validateMessages<T>(attributesMessages: T[], messageClass: abstract new (...args: any[]) => T): void {
97
109
  if (typeof messageClass !== 'function') {
98
110
  throw new ArgumentError('messageClass must be a class/constructor function');
99
111
  }
@@ -104,7 +116,7 @@ export class AuthorizationAttributesMsService {
104
116
 
105
117
  for (let i = 0; i < attributesMessages.length; i++) {
106
118
  if (!(attributesMessages[i] instanceof messageClass)) {
107
- const className = (messageClass as any).name || 'ResourceAttributeAssignment';
119
+ const className = (messageClass as { name?: string }).name || 'ResourceAttributeAssignment';
108
120
  throw new ArgumentError(
109
121
  `All attributesMessages must be instances of ${className}, but item at index ${i} is not`
110
122
  );
@@ -252,7 +264,10 @@ export class AuthorizationAttributesMsService {
252
264
  }
253
265
 
254
266
  if (attributeKeys.length === 0) {
255
- logger.warn({ tag: this.LOG_TAG, accountId, resource }, 'deleteResourceAttributesSync called with empty keys array');
267
+ logger.warn(
268
+ { tag: this.LOG_TAG, accountId, resource },
269
+ 'deleteResourceAttributesSync called with empty keys array'
270
+ );
256
271
  return;
257
272
  }
258
273
 
@@ -278,10 +293,7 @@ export class AuthorizationAttributesMsService {
278
293
  const headers = this.getRequestHeaders(accountId);
279
294
 
280
295
  try {
281
- logger.info(
282
- { tag: this.LOG_TAG, accountId, resource, keys: attributeKeys },
283
- 'Deleting resource attributes'
284
- );
296
+ logger.info({ tag: this.LOG_TAG, accountId, resource, keys: attributeKeys }, 'Deleting resource attributes');
285
297
 
286
298
  await httpClient.fetch(
287
299
  {
@@ -323,5 +335,234 @@ export class AuthorizationAttributesMsService {
323
335
  throw err;
324
336
  }
325
337
  }
326
- }
327
338
 
339
+ /**
340
+ * Creates or updates entity attributes synchronously.
341
+ * @param accountId The account ID
342
+ * @param entityAttributeAssignments Array of EntityAttributeAssignment objects
343
+ * @returns Promise<void>
344
+ */
345
+ static async upsertEntityAttributesSync(
346
+ accountId: number,
347
+ entityAttributeAssignments: EntityAttributeAssignment[]
348
+ ): Promise<void> {
349
+ // Skip HTTP requests in test environment
350
+ if (process.env.NODE_ENV === 'test') {
351
+ logger.debug(
352
+ { tag: this.LOG_TAG, accountId, count: entityAttributeAssignments.length },
353
+ 'Skipping upsertEntityAttributesSync in test environment'
354
+ );
355
+ return;
356
+ }
357
+
358
+ // Validate inputs
359
+ if (!Number.isInteger(accountId)) {
360
+ throw new ArgumentError(`accountId must be an integer, got: ${accountId}`);
361
+ }
362
+
363
+ if (!Array.isArray(entityAttributeAssignments)) {
364
+ throw new ArgumentError('entityAttributeAssignments must be an array');
365
+ }
366
+
367
+ if (entityAttributeAssignments.length === 0) {
368
+ logger.warn({ tag: this.LOG_TAG, accountId }, 'upsertEntityAttributesSync called with empty array');
369
+ return;
370
+ }
371
+
372
+ // Validate each assignment
373
+ for (let i = 0; i < entityAttributeAssignments.length; i++) {
374
+ const assignment = entityAttributeAssignments[i];
375
+ if (!assignment.entityId || typeof assignment.entityId !== 'number') {
376
+ throw new ArgumentError(`entityAttributeAssignments[${i}].entityId is required and must be a number`);
377
+ }
378
+ if (!assignment.entityType || typeof assignment.entityType !== 'string') {
379
+ throw new ArgumentError(`entityAttributeAssignments[${i}].entityType is required and must be a string`);
380
+ }
381
+ if (!assignment.key || typeof assignment.key !== 'string') {
382
+ throw new ArgumentError(`entityAttributeAssignments[${i}].key is required and must be a string`);
383
+ }
384
+ if (assignment.value === undefined || typeof assignment.value !== 'string') {
385
+ throw new ArgumentError(`entityAttributeAssignments[${i}].value is required and must be a string`);
386
+ }
387
+ }
388
+
389
+ // Build request body
390
+ const requestBody: UpsertEntityRequestBody = {
391
+ entityAttributeAssignments: entityAttributeAssignments.map(assignment => ({
392
+ entityId: assignment.entityId,
393
+ entityType: assignment.entityType,
394
+ key: assignment.key,
395
+ value: assignment.value,
396
+ })),
397
+ };
398
+
399
+ const httpClient = Api.getPart('httpClient');
400
+ if (!httpClient) {
401
+ throw new Error('AuthorizationAttributesMsService: HTTP client is not initialized');
402
+ }
403
+ const path = UPSERT_ENTITY_ATTRIBUTES_PATH.replace('{accountId}', accountId.toString());
404
+ const headers = this.getRequestHeaders(accountId);
405
+
406
+ try {
407
+ logger.info(
408
+ { tag: this.LOG_TAG, accountId, count: entityAttributeAssignments.length },
409
+ 'Upserting entity attributes'
410
+ );
411
+
412
+ await httpClient.fetch(
413
+ {
414
+ url: {
415
+ appName: APP_NAME,
416
+ path,
417
+ },
418
+ method: 'POST',
419
+ headers,
420
+ body: JSON.stringify(requestBody),
421
+ },
422
+ {
423
+ timeout: AuthorizationInternalService.getRequestTimeout(),
424
+ retryPolicy: AuthorizationInternalService.getRetriesPolicy(),
425
+ }
426
+ );
427
+
428
+ logger.info(
429
+ { tag: this.LOG_TAG, accountId, count: entityAttributeAssignments.length },
430
+ 'Successfully upserted entity attributes'
431
+ );
432
+ } catch (err) {
433
+ logger.error(
434
+ {
435
+ tag: this.LOG_TAG,
436
+ accountId,
437
+ method: 'upsertEntityAttributesSync',
438
+ error: err instanceof Error ? err.message : String(err),
439
+ },
440
+ 'Failed to upsert entity attributes'
441
+ );
442
+
443
+ if (err instanceof HttpFetcherError) {
444
+ throw new Error(
445
+ `AuthorizationAttributesMsService: [upsertEntityAttributesSync] request failed with status ${err.status}: ${err.message}`
446
+ );
447
+ }
448
+ throw err;
449
+ }
450
+ }
451
+
452
+ /**
453
+ * Deletes specific attributes from an entity synchronously.
454
+ * @param accountId The account ID
455
+ * @param entityType The entity type
456
+ * @param entityId The entity ID
457
+ * @param attributeKeys Array of attribute key strings to delete
458
+ * @returns Promise<void>
459
+ */
460
+ static async deleteEntityAttributesSync(
461
+ accountId: number,
462
+ entityType: EntityType,
463
+ entityId: number,
464
+ attributeKeys: EntityAttributeKeyType[]
465
+ ): Promise<void> {
466
+ // Skip HTTP requests in test environment
467
+ if (process.env.NODE_ENV === 'test') {
468
+ logger.debug(
469
+ { tag: this.LOG_TAG, accountId, entityType, entityId, attributeKeys },
470
+ 'Skipping deleteEntityAttributesSync in test environment'
471
+ );
472
+ return;
473
+ }
474
+
475
+ // Validate inputs
476
+ if (!Number.isInteger(accountId)) {
477
+ throw new ArgumentError(`accountId must be an integer, got: ${accountId}`);
478
+ }
479
+
480
+ if (!entityType || typeof entityType !== 'string') {
481
+ throw new ArgumentError(`entityType must be a string, got: ${typeof entityType}`);
482
+ }
483
+
484
+ if (!Number.isInteger(entityId)) {
485
+ throw new ArgumentError(`entityId must be an integer, got: ${entityId}`);
486
+ }
487
+
488
+ if (!Array.isArray(attributeKeys)) {
489
+ throw new ArgumentError('attributeKeys must be an array');
490
+ }
491
+
492
+ if (attributeKeys.length === 0) {
493
+ logger.warn(
494
+ { tag: this.LOG_TAG, accountId, entityType, entityId },
495
+ 'deleteEntityAttributesSync called with empty keys array'
496
+ );
497
+ return;
498
+ }
499
+
500
+ // Validate all keys are strings
501
+ for (let i = 0; i < attributeKeys.length; i++) {
502
+ if (typeof attributeKeys[i] !== 'string') {
503
+ throw new ArgumentError(`All attributeKeys must be strings, but item at index ${i} is not`);
504
+ }
505
+ }
506
+
507
+ // Build request body
508
+ const requestBody: DeleteRequestBody = {
509
+ keys: attributeKeys,
510
+ };
511
+
512
+ const httpClient = Api.getPart('httpClient');
513
+ if (!httpClient) {
514
+ throw new Error('AuthorizationAttributesMsService: HTTP client is not initialized');
515
+ }
516
+ const path = DELETE_ENTITY_ATTRIBUTES_PATH.replace('{accountId}', accountId.toString())
517
+ .replace('{entityType}', entityType)
518
+ .replace('{entityId}', entityId.toString());
519
+ const headers = this.getRequestHeaders(accountId);
520
+
521
+ try {
522
+ logger.info(
523
+ { tag: this.LOG_TAG, accountId, entityType, entityId, keys: attributeKeys },
524
+ 'Deleting entity attributes'
525
+ );
526
+
527
+ await httpClient.fetch(
528
+ {
529
+ url: {
530
+ appName: APP_NAME,
531
+ path,
532
+ },
533
+ method: 'DELETE',
534
+ headers,
535
+ body: JSON.stringify(requestBody),
536
+ },
537
+ {
538
+ timeout: AuthorizationInternalService.getRequestTimeout(),
539
+ retryPolicy: AuthorizationInternalService.getRetriesPolicy(),
540
+ }
541
+ );
542
+
543
+ logger.info(
544
+ { tag: this.LOG_TAG, accountId, entityType, entityId, keys: attributeKeys },
545
+ 'Successfully deleted entity attributes'
546
+ );
547
+ } catch (err) {
548
+ logger.error(
549
+ {
550
+ tag: this.LOG_TAG,
551
+ accountId,
552
+ method: 'deleteEntityAttributesSync',
553
+ entityType,
554
+ entityId,
555
+ error: err instanceof Error ? err.message : String(err),
556
+ },
557
+ 'Failed to delete entity attributes'
558
+ );
559
+
560
+ if (err instanceof HttpFetcherError) {
561
+ throw new Error(
562
+ `AuthorizationAttributesMsService: [deleteEntityAttributesSync] request failed with status ${err.status}: ${err.message}`
563
+ );
564
+ }
565
+ throw err;
566
+ }
567
+ }
568
+ }