@mondaydotcomorg/monday-authorization 3.7.0-feat-shaime-support-entity-attributes-4-49e1de0 → 3.7.1

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 (115) hide show
  1. package/README.md +7 -1
  2. package/dist/authorization-attributes-ms-service.d.ts +20 -40
  3. package/dist/authorization-attributes-ms-service.d.ts.map +1 -1
  4. package/dist/authorization-attributes-ms-service.js +48 -103
  5. package/dist/authorization-attributes-service.d.ts +12 -10
  6. package/dist/authorization-attributes-service.d.ts.map +1 -1
  7. package/dist/authorization-attributes-service.js +17 -15
  8. package/dist/authorization-attributes-sns-service.d.ts +37 -44
  9. package/dist/authorization-attributes-sns-service.d.ts.map +1 -1
  10. package/dist/authorization-attributes-sns-service.js +53 -90
  11. package/dist/authorization-service.d.ts +0 -1
  12. package/dist/authorization-service.d.ts.map +1 -1
  13. package/dist/authorization-service.js +2 -22
  14. package/dist/base-attribute-assignment.d.ts +6 -7
  15. package/dist/base-attribute-assignment.d.ts.map +1 -1
  16. package/dist/base-attribute-assignment.js +5 -7
  17. package/dist/base-authorization-attributes-service.d.ts +32 -0
  18. package/dist/base-authorization-attributes-service.d.ts.map +1 -0
  19. package/dist/base-authorization-attributes-service.js +63 -0
  20. package/dist/entity-attribute-assignment.d.ts +4 -8
  21. package/dist/entity-attribute-assignment.d.ts.map +1 -1
  22. package/dist/entity-attribute-assignment.js +3 -4
  23. package/dist/esm/authorization-attributes-ms-service.d.ts +20 -40
  24. package/dist/esm/authorization-attributes-ms-service.d.ts.map +1 -1
  25. package/dist/esm/authorization-attributes-ms-service.mjs +48 -103
  26. package/dist/esm/authorization-attributes-service.d.ts +12 -10
  27. package/dist/esm/authorization-attributes-service.d.ts.map +1 -1
  28. package/dist/esm/authorization-attributes-service.mjs +17 -15
  29. package/dist/esm/authorization-attributes-sns-service.d.ts +37 -44
  30. package/dist/esm/authorization-attributes-sns-service.d.ts.map +1 -1
  31. package/dist/esm/authorization-attributes-sns-service.mjs +53 -90
  32. package/dist/esm/authorization-service.d.ts +0 -1
  33. package/dist/esm/authorization-service.d.ts.map +1 -1
  34. package/dist/esm/authorization-service.mjs +3 -23
  35. package/dist/esm/base-attribute-assignment.d.ts +6 -7
  36. package/dist/esm/base-attribute-assignment.d.ts.map +1 -1
  37. package/dist/esm/base-attribute-assignment.mjs +5 -7
  38. package/dist/esm/base-authorization-attributes-service.d.ts +32 -0
  39. package/dist/esm/base-authorization-attributes-service.d.ts.map +1 -0
  40. package/dist/esm/base-authorization-attributes-service.mjs +61 -0
  41. package/dist/esm/entity-attribute-assignment.d.ts +4 -8
  42. package/dist/esm/entity-attribute-assignment.d.ts.map +1 -1
  43. package/dist/esm/entity-attribute-assignment.mjs +3 -4
  44. package/dist/esm/index.d.ts +6 -0
  45. package/dist/esm/index.d.ts.map +1 -1
  46. package/dist/esm/index.mjs +6 -0
  47. package/dist/esm/resource-attribute-assignment.d.ts +3 -7
  48. package/dist/esm/resource-attribute-assignment.d.ts.map +1 -1
  49. package/dist/esm/resource-attribute-assignment.mjs +8 -2
  50. package/dist/esm/resource-attributes-constants.d.ts +12 -10
  51. package/dist/esm/resource-attributes-constants.d.ts.map +1 -1
  52. package/dist/esm/resource-attributes-constants.mjs +4 -2
  53. package/dist/esm/testKit/index.d.ts +4 -4
  54. package/dist/esm/testKit/index.d.ts.map +1 -1
  55. package/dist/esm/types/authorization-attributes-contracts.d.ts +7 -21
  56. package/dist/esm/types/authorization-attributes-contracts.d.ts.map +1 -1
  57. package/dist/esm/types/general.d.ts +4 -3
  58. package/dist/esm/types/general.d.ts.map +1 -1
  59. package/dist/esm/utils/assignment-schema.d.ts +51 -0
  60. package/dist/esm/utils/assignment-schema.d.ts.map +1 -0
  61. package/dist/esm/utils/assignment-schema.mjs +54 -0
  62. package/dist/esm/utils/resource-schema.d.ts +9 -0
  63. package/dist/esm/utils/resource-schema.d.ts.map +1 -0
  64. package/dist/esm/utils/resource-schema.mjs +16 -0
  65. package/dist/esm/utils/validation.d.ts +11 -28
  66. package/dist/esm/utils/validation.d.ts.map +1 -1
  67. package/dist/esm/utils/validation.mjs +61 -118
  68. package/dist/index.d.ts +6 -0
  69. package/dist/index.d.ts.map +1 -1
  70. package/dist/index.js +24 -0
  71. package/dist/resource-attribute-assignment.d.ts +3 -7
  72. package/dist/resource-attribute-assignment.d.ts.map +1 -1
  73. package/dist/resource-attribute-assignment.js +8 -2
  74. package/dist/resource-attributes-constants.d.ts +12 -10
  75. package/dist/resource-attributes-constants.d.ts.map +1 -1
  76. package/dist/resource-attributes-constants.js +4 -2
  77. package/dist/testKit/index.d.ts +4 -4
  78. package/dist/testKit/index.d.ts.map +1 -1
  79. package/dist/types/authorization-attributes-contracts.d.ts +7 -21
  80. package/dist/types/authorization-attributes-contracts.d.ts.map +1 -1
  81. package/dist/types/general.d.ts +4 -3
  82. package/dist/types/general.d.ts.map +1 -1
  83. package/dist/utils/assignment-schema.d.ts +51 -0
  84. package/dist/utils/assignment-schema.d.ts.map +1 -0
  85. package/dist/utils/assignment-schema.js +63 -0
  86. package/dist/utils/resource-schema.d.ts +9 -0
  87. package/dist/utils/resource-schema.d.ts.map +1 -0
  88. package/dist/utils/resource-schema.js +22 -0
  89. package/dist/utils/validation.d.ts +11 -28
  90. package/dist/utils/validation.d.ts.map +1 -1
  91. package/dist/utils/validation.js +61 -118
  92. package/package.json +2 -3
  93. package/src/authorization-attributes-ms-service.ts +92 -154
  94. package/src/authorization-attributes-service.ts +18 -16
  95. package/src/authorization-attributes-sns-service.ts +132 -131
  96. package/src/authorization-service.ts +3 -28
  97. package/src/base-attribute-assignment.ts +10 -26
  98. package/src/base-authorization-attributes-service.ts +90 -0
  99. package/src/entity-attribute-assignment.ts +7 -6
  100. package/src/index.ts +17 -0
  101. package/src/resource-attribute-assignment.ts +13 -10
  102. package/src/resource-attributes-constants.ts +4 -2
  103. package/src/testKit/index.ts +5 -5
  104. package/src/types/authorization-attributes-contracts.ts +7 -27
  105. package/src/types/general.ts +4 -3
  106. package/src/utils/assignment-schema.ts +56 -0
  107. package/src/utils/resource-schema.ts +16 -0
  108. package/src/utils/validation.ts +90 -137
  109. package/dist/esm/types/authorization-attributes-service.interface.d.ts +0 -57
  110. package/dist/esm/types/authorization-attributes-service.interface.d.ts.map +0 -1
  111. package/dist/esm/types/authorization-attributes-service.interface.mjs +0 -1
  112. package/dist/types/authorization-attributes-service.interface.d.ts +0 -57
  113. package/dist/types/authorization-attributes-service.interface.d.ts.map +0 -1
  114. package/dist/types/authorization-attributes-service.interface.js +0 -1
  115. package/src/types/authorization-attributes-service.interface.ts +0 -101
@@ -1,15 +1,11 @@
1
1
  import { ResourceType } from './resource-attributes-constants';
2
2
  import { BaseAttributeAssignment } from './base-attribute-assignment';
3
- export declare class ResourceAttributeAssignment extends BaseAttributeAssignment<number, ResourceType> {
3
+ import { ResourceAttributeAssignment as ResourceAttributeAssignmentContract } from './types/authorization-attributes-contracts';
4
+ export declare class ResourceAttributeAssignment extends BaseAttributeAssignment<ResourceType, ResourceAttributeAssignmentContract> {
4
5
  readonly resourceId: number;
5
6
  readonly resourceType: ResourceType;
6
7
  constructor(resourceId: number, resourceType: ResourceType, attributeKey: string, attributeValue: string);
7
- toDataTransferObject(): {
8
- resourceId: number;
9
- resourceType: ResourceType;
10
- key: string;
11
- value: string;
12
- };
8
+ toDataTransferObject(): ResourceAttributeAssignmentContract;
13
9
  /**
14
10
  * Compares two assignments for equality
15
11
  * @param other Another ResourceAttributeAssignment instance
@@ -1 +1 @@
1
- {"version":3,"file":"resource-attribute-assignment.d.ts","sourceRoot":"","sources":["../src/resource-attribute-assignment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/E,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAEtE,qBAAa,2BAA4B,SAAQ,uBAAuB,CAAC,MAAM,EAAE,YAAY,CAAC;IAC5F,SAAgB,UAAU,EAAE,MAAM,CAAC;IACnC,SAAgB,YAAY,EAAE,YAAY,CAAC;gBAE/B,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;IAcxG,oBAAoB;;;;;;IAQpB;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,2BAA2B,GAAG,OAAO;CAGpD"}
1
+ {"version":3,"file":"resource-attribute-assignment.d.ts","sourceRoot":"","sources":["../src/resource-attribute-assignment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,2BAA2B,IAAI,mCAAmC,EAAE,MAAM,4CAA4C,CAAC;AAGhI,qBAAa,2BAA4B,SAAQ,uBAAuB,CACtE,YAAY,EACZ,mCAAmC,CACpC;IACC,SAAgB,UAAU,EAAE,MAAM,CAAC;IACnC,SAAgB,YAAY,EAAE,YAAY,CAAC;gBAE/B,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;IAYxG,oBAAoB,IAAI,mCAAmC;IAQ3D;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,2BAA2B,GAAG,OAAO;CAGpD"}
@@ -1,13 +1,19 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
- const resourceAttributesConstants = require('./resource-attributes-constants.js');
4
3
  const baseAttributeAssignment = require('./base-attribute-assignment.js');
4
+ const utils_validation = require('./utils/validation.js');
5
5
 
6
6
  class ResourceAttributeAssignment extends baseAttributeAssignment.BaseAttributeAssignment {
7
7
  resourceId;
8
8
  resourceType;
9
9
  constructor(resourceId, resourceType, attributeKey, attributeValue) {
10
- super(resourceId, resourceType, attributeKey, attributeValue, Object.values(resourceAttributesConstants.RESOURCE_TYPES), 'resourceId', 'resourceType');
10
+ utils_validation.ValidationUtils.validatUpsertResourceAssignment({
11
+ resourceId,
12
+ resourceType,
13
+ key: attributeKey,
14
+ value: attributeValue,
15
+ });
16
+ super(resourceId, resourceType, attributeKey, attributeValue);
11
17
  this.resourceId = resourceId;
12
18
  this.resourceType = this.type;
13
19
  }
@@ -1,15 +1,15 @@
1
- export declare const RESOURCE_ATTRIBUTES_CONSTANTS: {
2
- readonly ACCOUNT_RESOURCE_ATTRIBUTES: {
3
- readonly ENABLE_MEMBERS_INVITE_FROM_NON_AUTH_DOMAIN: "enable_members_invite_from_non_auth_domain";
1
+ export declare const RESOURCE_ATTRIBUTES_CONSTANTS: Readonly<{
2
+ ACCOUNT_RESOURCE_ATTRIBUTES: {
3
+ ENABLE_MEMBERS_INVITE_FROM_NON_AUTH_DOMAIN: string;
4
4
  };
5
- readonly WORKSPACE_RESOURCE_ATTRIBUTES: {
6
- readonly IS_DEFAULT_WORKSPACE: "is_default_workspace";
5
+ WORKSPACE_RESOURCE_ATTRIBUTES: {
6
+ IS_DEFAULT_WORKSPACE: string;
7
7
  };
8
- readonly BOARD_RESOURCE_ATTRIBUTES: {
9
- readonly IS_SYNCABLE_CHILD_ENTITY: "is_syncable_child_entity";
10
- readonly SYSTEM_ENTITY_TYPE: "system_entity_type";
8
+ BOARD_RESOURCE_ATTRIBUTES: {
9
+ IS_SYNCABLE_CHILD_ENTITY: string;
10
+ SYSTEM_ENTITY_TYPE: string;
11
11
  };
12
- };
12
+ }>;
13
13
  export declare enum ResourceType {
14
14
  Account = "account",
15
15
  AccountProduct = "account_product",
@@ -19,7 +19,9 @@ export declare enum ResourceType {
19
19
  Team = "team",
20
20
  Overview = "overview",
21
21
  Document = "document",
22
- Crm = "crm"
22
+ Crm = "crm",
23
+ Feature = "feature",
24
+ POST = "post"
23
25
  }
24
26
  export declare const RESOURCE_TYPES: readonly ResourceType[];
25
27
  //# sourceMappingURL=resource-attributes-constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resource-attributes-constants.d.ts","sourceRoot":"","sources":["../src/resource-attributes-constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,6BAA6B;;;;;;;;;;;CAWhC,CAAC;AAEX,oBAAY,YAAY;IACtB,OAAO,YAAY;IACnB,cAAc,oBAAoB;IAClC,SAAS,cAAc;IACvB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,IAAI,SAAS;IACb,QAAQ,aAAa;IACrB,QAAQ,aAAa;IACrB,GAAG,QAAQ;CACZ;AAGD,eAAO,MAAM,cAAc,yBAA6C,CAAC"}
1
+ {"version":3,"file":"resource-attributes-constants.d.ts","sourceRoot":"","sources":["../src/resource-attributes-constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,6BAA6B;;;;;;;;;;;EAWxC,CAAC;AAEH,oBAAY,YAAY;IACtB,OAAO,YAAY;IACnB,cAAc,oBAAoB;IAClC,SAAS,cAAc;IACvB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,IAAI,SAAS;IACb,QAAQ,aAAa;IACrB,QAAQ,aAAa;IACrB,GAAG,QAAQ;IACX,OAAO,YAAY;IACnB,IAAI,SAAS;CACd;AAGD,eAAO,MAAM,cAAc,yBAA6C,CAAC"}
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
- const RESOURCE_ATTRIBUTES_CONSTANTS = {
3
+ const RESOURCE_ATTRIBUTES_CONSTANTS = Object.freeze({
4
4
  ACCOUNT_RESOURCE_ATTRIBUTES: {
5
5
  ENABLE_MEMBERS_INVITE_FROM_NON_AUTH_DOMAIN: 'enable_members_invite_from_non_auth_domain',
6
6
  },
@@ -11,7 +11,7 @@ const RESOURCE_ATTRIBUTES_CONSTANTS = {
11
11
  IS_SYNCABLE_CHILD_ENTITY: 'is_syncable_child_entity',
12
12
  SYSTEM_ENTITY_TYPE: 'system_entity_type',
13
13
  },
14
- };
14
+ });
15
15
  exports.ResourceType = void 0;
16
16
  (function (ResourceType) {
17
17
  ResourceType["Account"] = "account";
@@ -23,6 +23,8 @@ exports.ResourceType = void 0;
23
23
  ResourceType["Overview"] = "overview";
24
24
  ResourceType["Document"] = "document";
25
25
  ResourceType["Crm"] = "crm";
26
+ ResourceType["Feature"] = "feature";
27
+ ResourceType["POST"] = "post";
26
28
  })(exports.ResourceType || (exports.ResourceType = {}));
27
29
  // Define the array of strings and use 'as const' to make its contents literal types
28
30
  const RESOURCE_TYPES = Object.freeze(Object.values(exports.ResourceType));
@@ -1,12 +1,12 @@
1
- import { BaseRequest, BaseResponse, ContextGetter, Resource, ResourceGetter } from '../types/general';
1
+ import { Action, BaseRequest, BaseResponse, ContextGetter, Resource, ResourceGetter } from '../types/general';
2
2
  import type { NextFunction } from 'express';
3
3
  export type TestPermittedAction = {
4
4
  accountId: number;
5
5
  userId: number;
6
6
  resources: Resource[];
7
- action: string;
7
+ action: Action;
8
8
  };
9
- export declare const addTestPermittedAction: (accountId: number, userId: number, resources: Resource[], action: string) => void;
9
+ export declare const addTestPermittedAction: (accountId: number, userId: number, resources: Resource[], action: Action) => void;
10
10
  export declare const clearTestPermittedActions: () => void;
11
- export declare const getTestAuthorizationMiddleware: (action: string, resourceGetter: ResourceGetter, contextGetter?: ContextGetter) => (request: BaseRequest, response: BaseResponse, next: NextFunction) => Promise<void>;
11
+ export declare const getTestAuthorizationMiddleware: (action: Action, resourceGetter: ResourceGetter, contextGetter?: ContextGetter) => (request: BaseRequest, response: BaseResponse, next: NextFunction) => Promise<void>;
12
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testKit/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGtG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,MAAM,mBAAmB,GAAG;IACh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@ -1,7 +1,6 @@
1
- import { Resource } from './general';
2
1
  import type { EntityType } from '../entity-attributes-constants';
3
2
  import type { ResourceType } from '../resource-attributes-constants';
4
- interface AttributeAssignment {
3
+ export interface AttributeAssignment {
5
4
  key: string;
6
5
  value: string;
7
6
  }
@@ -9,35 +8,22 @@ export interface ResourceAttributeAssignment extends AttributeAssignment {
9
8
  resourceId: number;
10
9
  resourceType: ResourceType;
11
10
  }
11
+ export type ResourceAttributeDeleteAssignment = Omit<ResourceAttributeAssignment, 'value'>;
12
12
  export interface EntityAttributeAssignment extends AttributeAssignment {
13
13
  entityId: number;
14
14
  entityType: EntityType;
15
15
  }
16
- export interface ResourceAttributeDelete {
17
- resourceType: Resource['type'];
18
- resourceId: Resource['id'];
19
- key: string;
20
- }
21
- export interface EntityAttributeDelete {
22
- entityType: EntityType;
23
- entityId: number;
24
- key: string;
25
- }
16
+ export type EntityAttributeDeleteAssignment = Omit<EntityAttributeAssignment, 'value'>;
26
17
  export declare enum AttributeOperation {
27
18
  UPSERT = "upsert",
28
19
  DELETE = "delete"
29
20
  }
30
- export interface ResourceAttributeResponse {
31
- attributes: ResourceAttributeAssignment[];
32
- }
33
- export interface EntityAttributeResponse {
34
- attributes: EntityAttributeAssignment[];
35
- }
36
- export interface ResourceAttributeOperation extends ResourceAttributeAssignment {
21
+ export interface ResourceAttributeUpsertOperation extends ResourceAttributeAssignment {
37
22
  operationType: AttributeOperation;
38
23
  }
39
- export interface EntityAttributeOperation extends EntityAttributeAssignment {
24
+ export type ResourceAttributeDeleteOperation = Omit<ResourceAttributeUpsertOperation, 'value'>;
25
+ export interface EntityAttributeUpsertOperation extends EntityAttributeAssignment {
40
26
  operationType: AttributeOperation;
41
27
  }
42
- export {};
28
+ export type EntityAttributeDeleteOperation = Omit<EntityAttributeUpsertOperation, 'value'>;
43
29
  //# 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;AACrC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAErE,UAAU,mBAAmB;IAC3B,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
+ {"version":3,"file":"authorization-attributes-contracts.d.ts","sourceRoot":"","sources":["../../src/types/authorization-attributes-contracts.ts"],"names":[],"mappings":"AAAA,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;AACD,MAAM,MAAM,iCAAiC,GAAG,IAAI,CAAC,2BAA2B,EAAE,OAAO,CAAC,CAAC;AAI3F,MAAM,WAAW,yBAA0B,SAAQ,mBAAmB;IACpE,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,UAAU,CAAC;CACxB;AACD,MAAM,MAAM,+BAA+B,GAAG,IAAI,CAAC,yBAAyB,EAAE,OAAO,CAAC,CAAC;AAEvF,oBAAY,kBAAkB;IAC5B,MAAM,WAAW;IACjB,MAAM,WAAW;CAClB;AACD,MAAM,WAAW,gCAAiC,SAAQ,2BAA2B;IACnF,aAAa,EAAE,kBAAkB,CAAC;CACnC;AACD,MAAM,MAAM,gCAAgC,GAAG,IAAI,CAAC,gCAAgC,EAAE,OAAO,CAAC,CAAC;AAE/F,MAAM,WAAW,8BAA+B,SAAQ,yBAAyB;IAC/E,aAAa,EAAE,kBAAkB,CAAC;CACnC;AACD,MAAM,MAAM,8BAA8B,GAAG,IAAI,CAAC,8BAA8B,EAAE,OAAO,CAAC,CAAC"}
@@ -1,7 +1,8 @@
1
1
  import type { Request, Response } from 'express';
2
+ import type { ResourceType } from '../resource-attributes-constants';
2
3
  export interface Resource {
3
- id?: number;
4
- type: string;
4
+ id: number;
5
+ type: ResourceType;
5
6
  wrapperData?: object;
6
7
  }
7
8
  export type Action = string;
@@ -11,7 +12,7 @@ export interface Context {
11
12
  }
12
13
  export interface AuthorizationObject {
13
14
  resource_id?: Resource['id'];
14
- resource_type: Resource['type'];
15
+ resource_type: string;
15
16
  wrapper_data?: Resource['wrapperData'];
16
17
  action: Action;
17
18
  }
@@ -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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AE,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,51 @@
1
+ export declare const entityUpsertAssignmentSchema: import("ajv").ValidateFunction<{
2
+ value: any;
3
+ key: any;
4
+ entityId: any;
5
+ entityType: any;
6
+ } & {
7
+ value: any;
8
+ } & {
9
+ key: any;
10
+ } & {
11
+ entityId: any;
12
+ } & {
13
+ entityType: any;
14
+ }>;
15
+ export declare const entityDeleteAssignmentSchema: import("ajv").ValidateFunction<{
16
+ key: any;
17
+ entityId: any;
18
+ entityType: any;
19
+ } & {
20
+ key: any;
21
+ } & {
22
+ entityId: any;
23
+ } & {
24
+ entityType: any;
25
+ }>;
26
+ export declare const resourceDeleteAssignmentSchema: import("ajv").ValidateFunction<{
27
+ resourceId: any;
28
+ resourceType: any;
29
+ key: any;
30
+ } & {
31
+ resourceId: any;
32
+ } & {
33
+ resourceType: any;
34
+ } & {
35
+ key: any;
36
+ }>;
37
+ export declare const resourceUpsertAssignmentSchema: import("ajv").ValidateFunction<{
38
+ value: any;
39
+ resourceId: any;
40
+ resourceType: any;
41
+ key: any;
42
+ } & {
43
+ value: any;
44
+ } & {
45
+ resourceId: any;
46
+ } & {
47
+ resourceType: any;
48
+ } & {
49
+ key: any;
50
+ }>;
51
+ //# sourceMappingURL=assignment-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assignment-schema.d.ts","sourceRoot":"","sources":["../../src/utils/assignment-schema.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;EAWvC,CAAC;AAEH,eAAO,MAAM,4BAA4B;;;;;;;;;;EAUvC,CAAC;AAEH,eAAO,MAAM,8BAA8B;;;;;;;;;;EAUzC,CAAC;AAEH,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;EAWzC,CAAC"}
@@ -0,0 +1,63 @@
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
+ const types_authorizationAttributesContracts = require('../types/authorization-attributes-contracts.js');
7
+
8
+ const _interopDefault = e => e && e.__esModule ? e : { default: e };
9
+
10
+ const Ajv__default = /*#__PURE__*/_interopDefault(Ajv);
11
+
12
+ const ajv = new Ajv__default.default({ allErrors: true });
13
+ const entityUpsertAssignmentSchema = ajv.compile({
14
+ type: 'object',
15
+ properties: {
16
+ entityId: { type: 'number', multipleOf: 1 },
17
+ entityType: { type: 'string', enum: Object.values(entityAttributesConstants.EntityType) },
18
+ key: { type: 'string', minLength: 1 },
19
+ value: { type: 'string', minLength: 1 },
20
+ operationType: { type: 'string', enum: Object.values(types_authorizationAttributesContracts.AttributeOperation) },
21
+ },
22
+ required: ['entityId', 'entityType', 'key', 'value'],
23
+ additionalProperties: false,
24
+ });
25
+ const entityDeleteAssignmentSchema = ajv.compile({
26
+ type: 'object',
27
+ properties: {
28
+ entityId: { type: 'number', multipleOf: 1 },
29
+ entityType: { type: 'string', enum: Object.values(entityAttributesConstants.EntityType) },
30
+ key: { type: 'string', minLength: 1 },
31
+ operationType: { type: 'string', enum: Object.values(types_authorizationAttributesContracts.AttributeOperation) },
32
+ },
33
+ required: ['entityId', 'entityType', 'key'],
34
+ additionalProperties: false,
35
+ });
36
+ const resourceDeleteAssignmentSchema = ajv.compile({
37
+ type: 'object',
38
+ properties: {
39
+ resourceId: { type: 'number', multipleOf: 1 },
40
+ resourceType: { type: 'string', enum: Object.values(resourceAttributesConstants.ResourceType) },
41
+ key: { type: 'string', minLength: 1 },
42
+ operationType: { type: 'string', enum: Object.values(types_authorizationAttributesContracts.AttributeOperation) },
43
+ },
44
+ required: ['resourceId', 'resourceType', 'key'],
45
+ additionalProperties: false,
46
+ });
47
+ const resourceUpsertAssignmentSchema = ajv.compile({
48
+ type: 'object',
49
+ properties: {
50
+ resourceId: { type: 'number', multipleOf: 1 },
51
+ resourceType: { type: 'string', enum: Object.values(resourceAttributesConstants.ResourceType) },
52
+ key: { type: 'string', minLength: 1 },
53
+ value: { type: 'string', minLength: 1 },
54
+ operationType: { type: 'string', enum: Object.values(types_authorizationAttributesContracts.AttributeOperation) },
55
+ },
56
+ required: ['resourceId', 'resourceType', 'key', 'value'],
57
+ additionalProperties: false,
58
+ });
59
+
60
+ exports.entityDeleteAssignmentSchema = entityDeleteAssignmentSchema;
61
+ exports.entityUpsertAssignmentSchema = entityUpsertAssignmentSchema;
62
+ exports.resourceDeleteAssignmentSchema = resourceDeleteAssignmentSchema;
63
+ exports.resourceUpsertAssignmentSchema = resourceUpsertAssignmentSchema;
@@ -0,0 +1,9 @@
1
+ export declare const resourceSchema: import("ajv").ValidateFunction<{
2
+ id: any;
3
+ type: any;
4
+ } & {
5
+ id: any;
6
+ } & {
7
+ type: any;
8
+ }>;
9
+ //# 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,eAAO,MAAM,cAAc;;;;;;;EAUzB,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: 'object' },
17
+ },
18
+ required: ['id', 'type'],
19
+ additionalProperties: false,
20
+ });
21
+
22
+ exports.resourceSchema = resourceSchema;
@@ -1,45 +1,28 @@
1
+ import { ResourceAttributeAssignment, EntityAttributeAssignment, ResourceAttributeDeleteAssignment, EntityAttributeDeleteAssignment } from '../types/authorization-attributes-contracts';
1
2
  import { Resource } from '../types/general';
2
3
  /**
3
4
  * Utility class for common validation operations using AJV
4
5
  */
5
6
  export declare class ValidationUtils {
6
7
  private static ajv;
7
- /**
8
- * Validates that a value is an integer. Throws ArgumentError with a descriptive message on failure.
9
- */
8
+ private static integerValidator;
9
+ private static stringValidator;
10
+ private static stringArrayValidator;
10
11
  static validateInteger(value: number): void;
11
- /**
12
- * Validates that a value is a non-empty string. Throws ArgumentError on failure.
13
- */
14
12
  static validateString(value: string): void;
15
- /**
16
- * Validates that a value is an array of non-empty strings. Throws ArgumentError on failure.
17
- * Allows empty arrays - caller should handle early return.
18
- */
19
13
  static validateStringArray(value: string[]): void;
14
+ static validateResource(resource: Resource): void;
20
15
  /**
21
16
  * Validates an attribute assignment object using a single AJV schema.
22
17
  * Preserves legacy error messages for each field.
23
18
  */
24
- static validateAssignment<TType extends string>(data: {
25
- id: any;
26
- type: string;
27
- attributeKey: any;
28
- attributeValue: any;
29
- }, validTypes: readonly TType[], fieldNames: {
30
- id: string;
31
- type: string;
32
- }): {
33
- id: number;
34
- type: TType;
35
- attributeKey: string;
36
- attributeValue: string;
37
- };
19
+ static validatUpsertResourceAssignment(resource: ResourceAttributeAssignment): void;
20
+ static validatDeleteResourceAssignment(resource: ResourceAttributeDeleteAssignment): void;
21
+ static validatUpsertEntityAssignment(entity: EntityAttributeAssignment): void;
22
+ static validatDeleteEntityAssignment(entity: EntityAttributeDeleteAssignment): void;
38
23
  /**
39
- * Validates a Resource-like object shape: { id: number; type: string }.
40
- * Throws ArgumentError with legacy-compatible messages.
24
+ * Formats AJV validation errors into a readable error message
41
25
  */
42
- static validateResource(resource: Resource): void;
43
- static validateArrayTypeOf<T>(attributesMessages: T[], messageClass: abstract new (...args: any[]) => T): void;
26
+ private static formatValidationErrors;
44
27
  }
45
28
  //# sourceMappingURL=validation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C;;GAEG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAC,GAAG,CAAgC;IAClD;;OAEG;IACH,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAS3C;;OAEG;IACH,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAa1C;;;OAGG;IACH,MAAM,CAAC,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI;IAkBjD;;;OAGG;IACH,MAAM,CAAC,kBAAkB,CAAC,KAAK,SAAS,MAAM,EAC5C,IAAI,EAAE;QAAE,EAAE,EAAE,GAAG,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,GAAG,CAAC;QAAC,cAAc,EAAE,GAAG,CAAA;KAAE,EACvE,UAAU,EAAE,SAAS,KAAK,EAAE,EAC5B,UAAU,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GACvC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,KAAK,CAAC;QAAC,YAAY,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,MAAM,CAAA;KAAE;IA0D5E;;;OAGG;IACH,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAqBjD,MAAM,CAAC,mBAAmB,CAAC,CAAC,EAAE,kBAAkB,EAAE,CA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