@mondaydotcomorg/monday-authorization 3.5.1 → 3.5.2-feat-shaime-support-entity-attributes-3-6202ab7

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 (111) hide show
  1. package/dist/authorization-attributes-ms-service.d.ts +72 -0
  2. package/dist/authorization-attributes-ms-service.d.ts.map +1 -0
  3. package/dist/authorization-attributes-ms-service.js +279 -0
  4. package/dist/authorization-attributes-service.d.ts +25 -47
  5. package/dist/authorization-attributes-service.d.ts.map +1 -1
  6. package/dist/authorization-attributes-service.js +32 -171
  7. package/dist/authorization-attributes-sns-service.d.ts +70 -0
  8. package/dist/authorization-attributes-sns-service.d.ts.map +1 -0
  9. package/dist/authorization-attributes-sns-service.js +179 -0
  10. package/dist/base-attribute-assignment.d.ts +19 -0
  11. package/dist/base-attribute-assignment.d.ts.map +1 -0
  12. package/dist/base-attribute-assignment.js +34 -0
  13. package/dist/constants/sns.d.ts +12 -2
  14. package/dist/constants/sns.d.ts.map +1 -1
  15. package/dist/constants/sns.js +22 -2
  16. package/dist/entity-attribute-assignment.d.ts +16 -0
  17. package/dist/entity-attribute-assignment.d.ts.map +1 -0
  18. package/dist/entity-attribute-assignment.js +33 -0
  19. package/dist/entity-attributes-constants.d.ts +7 -0
  20. package/dist/entity-attributes-constants.d.ts.map +1 -0
  21. package/dist/entity-attributes-constants.js +11 -0
  22. package/dist/errors/argument-error.d.ts +4 -0
  23. package/dist/errors/argument-error.d.ts.map +1 -0
  24. package/dist/errors/argument-error.js +10 -0
  25. package/dist/esm/authorization-attributes-ms-service.d.ts +72 -0
  26. package/dist/esm/authorization-attributes-ms-service.d.ts.map +1 -0
  27. package/dist/esm/authorization-attributes-ms-service.mjs +277 -0
  28. package/dist/esm/authorization-attributes-service.d.ts +25 -47
  29. package/dist/esm/authorization-attributes-service.d.ts.map +1 -1
  30. package/dist/esm/authorization-attributes-service.mjs +32 -167
  31. package/dist/esm/authorization-attributes-sns-service.d.ts +70 -0
  32. package/dist/esm/authorization-attributes-sns-service.d.ts.map +1 -0
  33. package/dist/esm/authorization-attributes-sns-service.mjs +173 -0
  34. package/dist/esm/base-attribute-assignment.d.ts +19 -0
  35. package/dist/esm/base-attribute-assignment.d.ts.map +1 -0
  36. package/dist/esm/base-attribute-assignment.mjs +28 -0
  37. package/dist/esm/constants/sns.d.ts +12 -2
  38. package/dist/esm/constants/sns.d.ts.map +1 -1
  39. package/dist/esm/constants/sns.mjs +17 -3
  40. package/dist/esm/entity-attribute-assignment.d.ts +16 -0
  41. package/dist/esm/entity-attribute-assignment.d.ts.map +1 -0
  42. package/dist/esm/entity-attribute-assignment.mjs +31 -0
  43. package/dist/esm/entity-attributes-constants.d.ts +7 -0
  44. package/dist/esm/entity-attributes-constants.d.ts.map +1 -0
  45. package/dist/esm/entity-attributes-constants.mjs +9 -0
  46. package/dist/esm/errors/argument-error.d.ts +4 -0
  47. package/dist/esm/errors/argument-error.d.ts.map +1 -0
  48. package/dist/esm/errors/argument-error.mjs +8 -0
  49. package/dist/esm/resource-attribute-assignment.d.ts +16 -0
  50. package/dist/esm/resource-attribute-assignment.d.ts.map +1 -0
  51. package/dist/esm/resource-attribute-assignment.mjs +31 -0
  52. package/dist/esm/resource-attributes-constants.d.ts +25 -0
  53. package/dist/esm/resource-attributes-constants.d.ts.map +1 -0
  54. package/dist/esm/resource-attributes-constants.mjs +28 -0
  55. package/dist/esm/types/authorization-attributes-contracts.d.ts +26 -12
  56. package/dist/esm/types/authorization-attributes-contracts.d.ts.map +1 -1
  57. package/dist/esm/types/authorization-attributes-contracts.mjs +6 -6
  58. package/dist/esm/types/authorization-attributes-service.interface.d.ts +43 -0
  59. package/dist/esm/types/authorization-attributes-service.interface.d.ts.map +1 -0
  60. package/dist/esm/types/authorization-attributes-service.interface.mjs +1 -0
  61. package/dist/esm/types/general.d.ts +1 -1
  62. package/dist/esm/types/general.d.ts.map +1 -1
  63. package/dist/esm/utils/assigment-schema.d.ts +23 -0
  64. package/dist/esm/utils/assigment-schema.d.ts.map +1 -0
  65. package/dist/esm/utils/assigment-schema.mjs +29 -0
  66. package/dist/esm/utils/resource-schema.d.ts +17 -0
  67. package/dist/esm/utils/resource-schema.d.ts.map +1 -0
  68. package/dist/esm/utils/resource-schema.mjs +16 -0
  69. package/dist/esm/utils/validation.d.ts +26 -0
  70. package/dist/esm/utils/validation.d.ts.map +1 -0
  71. package/dist/esm/utils/validation.mjs +70 -0
  72. package/dist/resource-attribute-assignment.d.ts +16 -0
  73. package/dist/resource-attribute-assignment.d.ts.map +1 -0
  74. package/dist/resource-attribute-assignment.js +33 -0
  75. package/dist/resource-attributes-constants.d.ts +25 -0
  76. package/dist/resource-attributes-constants.d.ts.map +1 -0
  77. package/dist/resource-attributes-constants.js +31 -0
  78. package/dist/types/authorization-attributes-contracts.d.ts +26 -12
  79. package/dist/types/authorization-attributes-contracts.d.ts.map +1 -1
  80. package/dist/types/authorization-attributes-contracts.js +5 -5
  81. package/dist/types/authorization-attributes-service.interface.d.ts +43 -0
  82. package/dist/types/authorization-attributes-service.interface.d.ts.map +1 -0
  83. package/dist/types/authorization-attributes-service.interface.js +1 -0
  84. package/dist/types/general.d.ts +1 -1
  85. package/dist/types/general.d.ts.map +1 -1
  86. package/dist/utils/assigment-schema.d.ts +23 -0
  87. package/dist/utils/assigment-schema.d.ts.map +1 -0
  88. package/dist/utils/assigment-schema.js +36 -0
  89. package/dist/utils/resource-schema.d.ts +17 -0
  90. package/dist/utils/resource-schema.d.ts.map +1 -0
  91. package/dist/utils/resource-schema.js +22 -0
  92. package/dist/utils/validation.d.ts +26 -0
  93. package/dist/utils/validation.d.ts.map +1 -0
  94. package/dist/utils/validation.js +76 -0
  95. package/package.json +3 -1
  96. package/src/authorization-attributes-ms-service.ts +414 -0
  97. package/src/authorization-attributes-service.ts +34 -222
  98. package/src/authorization-attributes-sns-service.ts +257 -0
  99. package/src/base-attribute-assignment.ts +30 -0
  100. package/src/constants/sns.ts +19 -2
  101. package/src/entity-attribute-assignment.ts +33 -0
  102. package/src/entity-attributes-constants.ts +7 -0
  103. package/src/errors/argument-error.ts +6 -0
  104. package/src/resource-attribute-assignment.ts +36 -0
  105. package/src/resource-attributes-constants.ts +27 -0
  106. package/src/types/authorization-attributes-contracts.ts +34 -11
  107. package/src/types/authorization-attributes-service.interface.ts +70 -0
  108. package/src/types/general.ts +1 -1
  109. package/src/utils/assigment-schema.ts +29 -0
  110. package/src/utils/resource-schema.ts +21 -0
  111. package/src/utils/validation.ts +82 -0
@@ -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;AAErC,MAAM,WAAW,2BAA2B;IAC1C,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC/B,UAAU,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,yBAAyB;IACxC,UAAU,EAAE,2BAA2B,EAAE,CAAC;CAC3C;AAED,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;AACrC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAErE,MAAM,WAAW,mBAAmB;IAClC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf;AAGD,MAAM,WAAW,2BAA4B,SAAQ,mBAAmB;IACtE,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,YAAY,CAAC;CAC5B;AAID,MAAM,WAAW,yBAA0B,SAAQ,mBAAmB;IACpE,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,UAAU,CAAC;CACxB;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,kBAAkB;IAC5B,MAAM,WAAW;IACjB,MAAM,WAAW;CAClB;AAGD,MAAM,WAAW,yBAAyB;IACxC,UAAU,EAAE,2BAA2B,EAAE,CAAC;CAC3C;AAED,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,yBAAyB,EAAE,CAAC;CACzC;AAED,MAAM,WAAW,0BAA2B,SAAQ,2BAA2B;IAC7E,aAAa,EAAE,kBAAkB,CAAC;CACnC;AAED,MAAM,WAAW,wBAAyB,SAAQ,yBAAyB;IACzE,aAAa,EAAE,kBAAkB,CAAC;CACnC"}
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
- exports.ResourceAttributeOperationEnum = void 0;
4
- (function (ResourceAttributeOperationEnum) {
5
- ResourceAttributeOperationEnum["UPSERT"] = "upsert";
6
- ResourceAttributeOperationEnum["DELETE"] = "delete";
7
- })(exports.ResourceAttributeOperationEnum || (exports.ResourceAttributeOperationEnum = {}));
3
+ exports.AttributeOperation = void 0;
4
+ (function (AttributeOperation) {
5
+ AttributeOperation["UPSERT"] = "upsert";
6
+ AttributeOperation["DELETE"] = "delete";
7
+ })(exports.AttributeOperation || (exports.AttributeOperation = {}));
@@ -0,0 +1,43 @@
1
+ import { EntityType } from '../entity-attributes-constants';
2
+ import { ResourceAttributeOperation, EntityAttributeOperation } from './authorization-attributes-contracts';
3
+ import { Resource } from './general';
4
+ /**
5
+ * Resource type compatible with both MS and SNS services
6
+ */
7
+ export interface CompatibleResource {
8
+ resourceType?: string;
9
+ resourceId?: number;
10
+ type?: string;
11
+ id?: number;
12
+ }
13
+ /**
14
+ * Interface for authorization attributes operations.
15
+ * Both MS (direct) and SNS (async) services implement this interface.
16
+ */
17
+ export interface AuthorizationAttributesService {
18
+ /**
19
+ * Deletes resource attributes.
20
+ * For MS service: returns Promise<void>
21
+ * For SNS service: requires appName and callerActionIdentifier, returns Promise<ResourceAttributesOperation[]>
22
+ */
23
+ deleteResourceAttributes(accountId: number, resource: CompatibleResource | Resource, attributeKeys: string[], appName?: string, callerActionIdentifier?: string): Promise<void | ResourceAttributeOperation[]>;
24
+ /**
25
+ * Deletes entity attributes.
26
+ * For MS service: returns Promise<void>
27
+ * For SNS service: requires appName and callerActionIdentifier, returns Promise<EntityAttributesOperation[]>
28
+ */
29
+ deleteEntityAttributes(accountId: number, entityType: EntityType | string, entityId: number, attributeKeys: string[], appName?: string, callerActionIdentifier?: string): Promise<void | EntityAttributeOperation[]>;
30
+ /**
31
+ * Updates resource attributes (batch operations).
32
+ * For MS service: may throw error or delegate to upsert/delete
33
+ * For SNS service: returns Promise<ResourceAttributesOperation[]>
34
+ */
35
+ updateResourceAttributes(accountId: number, appName: string, callerActionIdentifier: string, resourceAttributeOperations: ResourceAttributeOperation[]): Promise<ResourceAttributeOperation[]>;
36
+ /**
37
+ * Updates entity attributes (batch operations).
38
+ * For MS service: may throw error or delegate to upsert/delete
39
+ * For SNS service: returns Promise<EntityAttributesOperation[]>
40
+ */
41
+ updateEntityAttributes(accountId: number, appName: string, callerActionIdentifier: string, entityAttributeOperations: EntityAttributeOperation[]): Promise<EntityAttributeOperation[]>;
42
+ }
43
+ //# sourceMappingURL=authorization-attributes-service.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorization-attributes-service.interface.d.ts","sourceRoot":"","sources":["../../src/types/authorization-attributes-service.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,0BAA0B,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAC5G,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED;;;GAGG;AACH,MAAM,WAAW,8BAA8B;IAC7C;;;;OAIG;IACH,wBAAwB,CACtB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,kBAAkB,GAAG,QAAQ,EACvC,aAAa,EAAE,MAAM,EAAE,EACvB,OAAO,CAAC,EAAE,MAAM,EAChB,sBAAsB,CAAC,EAAE,MAAM,GAC9B,OAAO,CAAC,IAAI,GAAG,0BAA0B,EAAE,CAAC,CAAC;IAEhD;;;;OAIG;IACH,sBAAsB,CACpB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,UAAU,GAAG,MAAM,EAC/B,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,EAAE,EACvB,OAAO,CAAC,EAAE,MAAM,EAChB,sBAAsB,CAAC,EAAE,MAAM,GAC9B,OAAO,CAAC,IAAI,GAAG,wBAAwB,EAAE,CAAC,CAAC;IAE9C;;;;OAIG;IACH,wBAAwB,CACtB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,sBAAsB,EAAE,MAAM,EAC9B,2BAA2B,EAAE,0BAA0B,EAAE,GACxD,OAAO,CAAC,0BAA0B,EAAE,CAAC,CAAC;IAEzC;;;;OAIG;IACH,sBAAsB,CACpB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,sBAAsB,EAAE,MAAM,EAC9B,yBAAyB,EAAE,wBAAwB,EAAE,GACpD,OAAO,CAAC,wBAAwB,EAAE,CAAC,CAAC;CACxC"}
@@ -1,6 +1,6 @@
1
1
  import type { Request, Response } from 'express';
2
2
  export interface Resource {
3
- id?: number;
3
+ id: number;
4
4
  type: string;
5
5
  wrapperData?: object;
6
6
  }
@@ -1 +1 @@
1
- {"version":3,"file":"general.d.ts","sourceRoot":"","sources":["../../src/types/general.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEjD,MAAM,WAAW,QAAQ;IACvB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AACD,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC;AAC5B,MAAM,WAAW,OAAO;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB;AACD,MAAM,WAAW,mBAAmB;IAClC,WAAW,CAAC,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC7B,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAChC,YAAY,CAAC,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC;IACvC,MAAM,EAAE,MAAM,CAAC;CAChB;AACD,MAAM,WAAW,mBAAmB;IAClC,oBAAoB,EAAE,mBAAmB,EAAE,CAAC;CAC7C;AAED,KAAK,WAAW,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC;AAE9C,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC;AACzC,MAAM,MAAM,gBAAgB,GAAG,WAAW,CAAC;AAC3C,MAAM,MAAM,kBAAkB,GAAG,WAAW,CAAC;AAC7C,MAAM,MAAM,mBAAmB,GAAG,WAAW,CAAC;AAC9C,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC,cAAc,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,mBAAmB,CAAC,CAAC;AAC7G,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC,gBAAgB,CAAC,CAAC;AACtD,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,WAAW,KAAK,QAAQ,EAAE,CAAC;AAClE,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,EAAE,WAAW,KAAK,OAAO,CAAC"}
1
+ {"version":3,"file":"general.d.ts","sourceRoot":"","sources":["../../src/types/general.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEjD,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AACD,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC;AAC5B,MAAM,WAAW,OAAO;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB;AACD,MAAM,WAAW,mBAAmB;IAClC,WAAW,CAAC,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC7B,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAChC,YAAY,CAAC,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC;IACvC,MAAM,EAAE,MAAM,CAAC;CAChB;AACD,MAAM,WAAW,mBAAmB;IAClC,oBAAoB,EAAE,mBAAmB,EAAE,CAAC;CAC7C;AAED,KAAK,WAAW,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC;AAE9C,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC;AACzC,MAAM,MAAM,gBAAgB,GAAG,WAAW,CAAC;AAC3C,MAAM,MAAM,kBAAkB,GAAG,WAAW,CAAC;AAC7C,MAAM,MAAM,mBAAmB,GAAG,WAAW,CAAC;AAC9C,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC,cAAc,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,mBAAmB,CAAC,CAAC;AAC7G,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC,gBAAgB,CAAC,CAAC;AACtD,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,WAAW,KAAK,QAAQ,EAAE,CAAC;AAClE,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,EAAE,WAAW,KAAK,OAAO,CAAC"}
@@ -0,0 +1,23 @@
1
+ export declare const entityAssignmentSchema: import("ajv").ValidateFunction<{
2
+ entityId: any;
3
+ entityType: any;
4
+ key: any;
5
+ } & {
6
+ entityId: any;
7
+ } & {
8
+ entityType: any;
9
+ } & {
10
+ key: any;
11
+ }>;
12
+ export declare const resourceAssignmentSchema: import("ajv").ValidateFunction<{
13
+ id: any;
14
+ type: any;
15
+ key: any;
16
+ } & {
17
+ id: any;
18
+ } & {
19
+ type: any;
20
+ } & {
21
+ key: any;
22
+ }>;
23
+ //# sourceMappingURL=assigment-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assigment-schema.d.ts","sourceRoot":"","sources":["../../src/utils/assigment-schema.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,sBAAsB;;;;;;;;;;EAUjC,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;;;;;;EAUnC,CAAC"}
@@ -0,0 +1,36 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const Ajv = require('ajv');
4
+ const entityAttributesConstants = require('../entity-attributes-constants.js');
5
+ const resourceAttributesConstants = require('../resource-attributes-constants.js');
6
+
7
+ const _interopDefault = e => e && e.__esModule ? e : { default: e };
8
+
9
+ const Ajv__default = /*#__PURE__*/_interopDefault(Ajv);
10
+
11
+ const ajv = new Ajv__default.default({ allErrors: true });
12
+ const entityAssignmentSchema = ajv.compile({
13
+ type: 'object',
14
+ properties: {
15
+ entityId: { type: 'number', multipleOf: 1 },
16
+ entityType: { type: 'string', enum: Object.values(entityAttributesConstants.EntityType) },
17
+ key: { type: 'string', minLength: 1 },
18
+ value: { type: 'string' },
19
+ },
20
+ required: ['entityId', 'entityType', 'key'],
21
+ additionalProperties: false,
22
+ });
23
+ const resourceAssignmentSchema = ajv.compile({
24
+ type: 'object',
25
+ properties: {
26
+ id: { type: 'number', multipleOf: 1 },
27
+ type: { type: 'string', enum: Object.values(resourceAttributesConstants.ResourceType) },
28
+ key: { type: 'string', minLength: 1 },
29
+ value: { type: 'string' },
30
+ },
31
+ required: ['id', 'type', 'key'],
32
+ additionalProperties: false,
33
+ });
34
+
35
+ exports.entityAssignmentSchema = entityAssignmentSchema;
36
+ exports.resourceAssignmentSchema = resourceAssignmentSchema;
@@ -0,0 +1,17 @@
1
+ export interface Resource {
2
+ id?: number;
3
+ type: string;
4
+ wrapperData?: object;
5
+ }
6
+ export declare const resourceSchema: import("ajv").ValidateFunction<{
7
+ id: any;
8
+ type: any;
9
+ wrapperData: any;
10
+ } & {
11
+ id: any;
12
+ } & {
13
+ type: any;
14
+ } & {
15
+ wrapperData: any;
16
+ }>;
17
+ //# sourceMappingURL=resource-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource-schema.d.ts","sourceRoot":"","sources":["../../src/utils/resource-schema.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,QAAQ;IACvB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,cAAc;;;;;;;;;;EASzB,CAAC"}
@@ -0,0 +1,22 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const Ajv = require('ajv');
4
+ const resourceAttributesConstants = require('../resource-attributes-constants.js');
5
+
6
+ const _interopDefault = e => e && e.__esModule ? e : { default: e };
7
+
8
+ const Ajv__default = /*#__PURE__*/_interopDefault(Ajv);
9
+
10
+ const ajv = new Ajv__default.default({ allErrors: true });
11
+ const resourceSchema = ajv.compile({
12
+ type: 'object',
13
+ properties: {
14
+ id: { type: 'number', multipleOf: 1 },
15
+ type: { type: 'string', enum: resourceAttributesConstants.RESOURCE_TYPES },
16
+ wrapperData: { type: 'string', minLength: 1 },
17
+ },
18
+ required: ['id', 'type', 'wrapperData'],
19
+ additionalProperties: false,
20
+ });
21
+
22
+ exports.resourceSchema = resourceSchema;
@@ -0,0 +1,26 @@
1
+ import { ResourceAttributeAssignment, EntityAttributeAssignment } from '../types/authorization-attributes-contracts';
2
+ import { Resource } from '../types/general';
3
+ /**
4
+ * Utility class for common validation operations using AJV
5
+ */
6
+ export declare class ValidationUtils {
7
+ private static ajv;
8
+ private static integerValidator;
9
+ private static stringValidator;
10
+ private static stringArrayValidator;
11
+ static validateInteger(value: number): void;
12
+ static validateString(value: string): void;
13
+ static validateStringArray(value: string[]): void;
14
+ static validateResource(resource: Resource): void;
15
+ /**
16
+ * Validates an attribute assignment object using a single AJV schema.
17
+ * Preserves legacy error messages for each field.
18
+ */
19
+ static validateResourceAssignment(resource: ResourceAttributeAssignment): void;
20
+ static validateEntityAssignment(entity: EntityAttributeAssignment): void;
21
+ /**
22
+ * Formats AJV validation errors into a readable error message
23
+ */
24
+ private static formatValidationErrors;
25
+ }
26
+ //# sourceMappingURL=validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,2BAA2B,EAAE,yBAAyB,EAAE,MAAM,6CAA6C,CAAC;AACrH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAI5C;;GAEG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAC,GAAG,CAAgC;IAElD,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAyE;IACxG,OAAO,CAAC,MAAM,CAAC,eAAe,CAAwE;IACtG,OAAO,CAAC,MAAM,CAAC,oBAAoB,CAGhC;WAEW,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;WAOpC,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;WAOnC,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI;WAO1C,gBAAgB,CAAC,QAAQ,EAAE,QAAQ;IAQjD;;;OAGG;IACH,MAAM,CAAC,0BAA0B,CAAC,QAAQ,EAAE,2BAA2B,GAAG,IAAI;IAY9E,MAAM,CAAC,wBAAwB,CAAC,MAAM,EAAE,yBAAyB,GAAG,IAAI;IAUxE;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,sBAAsB;CAGtC"}
@@ -0,0 +1,76 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const Ajv = require('ajv');
4
+ const errors_argumentError = require('../errors/argument-error.js');
5
+ const utils_assigmentSchema = require('./assigment-schema.js');
6
+ const utils_resourceSchema = require('./resource-schema.js');
7
+
8
+ const _interopDefault = e => e && e.__esModule ? e : { default: e };
9
+
10
+ const Ajv__default = /*#__PURE__*/_interopDefault(Ajv);
11
+
12
+ /**
13
+ * Utility class for common validation operations using AJV
14
+ */
15
+ class ValidationUtils {
16
+ static ajv = new Ajv__default.default({ allErrors: true });
17
+ static integerValidator = this.ajv.compile({ type: 'number', multipleOf: 1 });
18
+ static stringValidator = this.ajv.compile({ type: 'string', minLength: 1 });
19
+ static stringArrayValidator = this.ajv.compile({
20
+ type: 'array',
21
+ items: { type: 'string' },
22
+ });
23
+ static validateInteger(value) {
24
+ const valid = this.integerValidator(value);
25
+ if (!valid) {
26
+ throw new errors_argumentError.ArgumentError('Invalid integer');
27
+ }
28
+ }
29
+ static validateString(value) {
30
+ const valid = this.stringValidator(value);
31
+ if (!valid) {
32
+ throw new errors_argumentError.ArgumentError('Invalid string');
33
+ }
34
+ }
35
+ static validateStringArray(value) {
36
+ const valid = this.stringArrayValidator(value);
37
+ if (!valid) {
38
+ throw new errors_argumentError.ArgumentError('Invalid string array');
39
+ }
40
+ }
41
+ static validateResource(resource) {
42
+ const isValid = utils_resourceSchema.resourceSchema(resource);
43
+ if (!isValid) {
44
+ const errorMessage = this.formatValidationErrors(utils_resourceSchema.resourceSchema.errors);
45
+ throw new errors_argumentError.ArgumentError(errorMessage ? `Invalid resource: ${errorMessage}` : 'Invalid resource');
46
+ }
47
+ }
48
+ /**
49
+ * Validates an attribute assignment object using a single AJV schema.
50
+ * Preserves legacy error messages for each field.
51
+ */
52
+ static validateResourceAssignment(resource) {
53
+ const valid = utils_assigmentSchema.resourceAssignmentSchema(resource);
54
+ if (!valid) {
55
+ const errorMessage = this.formatValidationErrors(utils_assigmentSchema.resourceAssignmentSchema.errors);
56
+ throw new errors_argumentError.ArgumentError(errorMessage
57
+ ? `Invalid resource attribute assignment: ${errorMessage}`
58
+ : 'Invalid resource attribute assignment');
59
+ }
60
+ }
61
+ static validateEntityAssignment(entity) {
62
+ const valid = utils_assigmentSchema.entityAssignmentSchema(entity);
63
+ if (!valid) {
64
+ const errorMessage = this.formatValidationErrors(utils_assigmentSchema.entityAssignmentSchema.errors);
65
+ throw new errors_argumentError.ArgumentError(errorMessage ? `Invalid entity attribute assignment: ${errorMessage}` : 'Invalid entity attribute assignment');
66
+ }
67
+ }
68
+ /**
69
+ * Formats AJV validation errors into a readable error message
70
+ */
71
+ static formatValidationErrors(errors) {
72
+ return (errors || []).join();
73
+ }
74
+ }
75
+
76
+ exports.ValidationUtils = ValidationUtils;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mondaydotcomorg/monday-authorization",
3
- "version": "3.5.1",
3
+ "version": "3.5.2-feat-shaime-support-entity-attributes-3-6202ab7",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "license": "BSD-3-Clause",
@@ -28,6 +28,8 @@
28
28
  "@mondaydotcomorg/monday-observability-kit": "^1.5.3",
29
29
  "@mondaydotcomorg/monday-sns": "^1.2.1",
30
30
  "@mondaydotcomorg/trident-backend-api": "^0.24.3",
31
+ "ajv": "^8.17.1",
32
+ "ajv-keywords": "^5.1.0",
31
33
  "lodash": "^4.17.21",
32
34
  "node-fetch": "^2.6.7",
33
35
  "on-headers": "^1.0.2",