@mondaydotcomorg/monday-authorization 3.5.1-feat-shaime-support-entity-attributes-in-authorization-sdk-d2be13e → 3.5.1-fix-authorize-profile-picker-9fcaf6a

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 (114) hide show
  1. package/dist/attributions-service.d.ts.map +1 -1
  2. package/dist/attributions-service.js +0 -1
  3. package/dist/authorization-attributes-service.d.ts +54 -0
  4. package/dist/authorization-attributes-service.d.ts.map +1 -0
  5. package/dist/authorization-attributes-service.js +186 -0
  6. package/dist/authorization-service.d.ts.map +1 -1
  7. package/dist/authorization-service.js +34 -7
  8. package/dist/constants/sns.d.ts +2 -12
  9. package/dist/constants/sns.d.ts.map +1 -1
  10. package/dist/constants/sns.js +2 -22
  11. package/dist/esm/attributions-service.d.ts.map +1 -1
  12. package/dist/esm/attributions-service.mjs +0 -1
  13. package/dist/esm/authorization-attributes-service.d.ts +54 -0
  14. package/dist/esm/authorization-attributes-service.d.ts.map +1 -0
  15. package/dist/esm/authorization-attributes-service.mjs +180 -0
  16. package/dist/esm/authorization-service.d.ts.map +1 -1
  17. package/dist/esm/authorization-service.mjs +34 -7
  18. package/dist/esm/constants/sns.d.ts +2 -12
  19. package/dist/esm/constants/sns.d.ts.map +1 -1
  20. package/dist/esm/constants/sns.mjs +3 -17
  21. package/dist/esm/index.d.ts +1 -9
  22. package/dist/esm/index.d.ts.map +1 -1
  23. package/dist/esm/index.mjs +1 -7
  24. package/dist/esm/roles-service.d.ts +1 -1
  25. package/dist/esm/roles-service.mjs +1 -1
  26. package/dist/esm/types/authorization-attributes-contracts.d.ts +4 -36
  27. package/dist/esm/types/authorization-attributes-contracts.d.ts.map +1 -1
  28. package/dist/esm/types/authorization-attributes-contracts.mjs +1 -6
  29. package/dist/index.d.ts +1 -9
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +2 -15
  32. package/dist/roles-service.d.ts +1 -1
  33. package/dist/roles-service.js +1 -1
  34. package/dist/types/authorization-attributes-contracts.d.ts +4 -36
  35. package/dist/types/authorization-attributes-contracts.d.ts.map +1 -1
  36. package/dist/types/authorization-attributes-contracts.js +0 -5
  37. package/package.json +1 -1
  38. package/src/attributions-service.ts +0 -4
  39. package/src/authorization-attributes-service.ts +234 -0
  40. package/src/authorization-service.ts +71 -11
  41. package/src/constants/sns.ts +2 -19
  42. package/src/index.ts +1 -18
  43. package/src/roles-service.ts +1 -1
  44. package/src/types/authorization-attributes-contracts.ts +3 -56
  45. package/dist/authorization-attributes-ms-service.d.ts +0 -67
  46. package/dist/authorization-attributes-ms-service.d.ts.map +0 -1
  47. package/dist/authorization-attributes-ms-service.js +0 -256
  48. package/dist/authorization-attributes-sns-service.d.ts +0 -85
  49. package/dist/authorization-attributes-sns-service.d.ts.map +0 -1
  50. package/dist/authorization-attributes-sns-service.js +0 -203
  51. package/dist/base-attribute-assignment.d.ts +0 -18
  52. package/dist/base-attribute-assignment.d.ts.map +0 -1
  53. package/dist/base-attribute-assignment.js +0 -43
  54. package/dist/entity-attribute-assignment.d.ts +0 -24
  55. package/dist/entity-attribute-assignment.d.ts.map +0 -1
  56. package/dist/entity-attribute-assignment.js +0 -36
  57. package/dist/entity-attributes-constants.d.ts +0 -7
  58. package/dist/entity-attributes-constants.d.ts.map +0 -1
  59. package/dist/entity-attributes-constants.js +0 -9
  60. package/dist/errors/argument-error.d.ts +0 -4
  61. package/dist/errors/argument-error.d.ts.map +0 -1
  62. package/dist/errors/argument-error.js +0 -11
  63. package/dist/esm/authorization-attributes-ms-service.d.ts +0 -67
  64. package/dist/esm/authorization-attributes-ms-service.d.ts.map +0 -1
  65. package/dist/esm/authorization-attributes-ms-service.mjs +0 -254
  66. package/dist/esm/authorization-attributes-sns-service.d.ts +0 -85
  67. package/dist/esm/authorization-attributes-sns-service.d.ts.map +0 -1
  68. package/dist/esm/authorization-attributes-sns-service.mjs +0 -197
  69. package/dist/esm/base-attribute-assignment.d.ts +0 -18
  70. package/dist/esm/base-attribute-assignment.d.ts.map +0 -1
  71. package/dist/esm/base-attribute-assignment.mjs +0 -41
  72. package/dist/esm/entity-attribute-assignment.d.ts +0 -24
  73. package/dist/esm/entity-attribute-assignment.d.ts.map +0 -1
  74. package/dist/esm/entity-attribute-assignment.mjs +0 -34
  75. package/dist/esm/entity-attributes-constants.d.ts +0 -7
  76. package/dist/esm/entity-attributes-constants.d.ts.map +0 -1
  77. package/dist/esm/entity-attributes-constants.mjs +0 -7
  78. package/dist/esm/errors/argument-error.d.ts +0 -4
  79. package/dist/esm/errors/argument-error.d.ts.map +0 -1
  80. package/dist/esm/errors/argument-error.mjs +0 -9
  81. package/dist/esm/resource-attribute-assignment.d.ts +0 -24
  82. package/dist/esm/resource-attribute-assignment.d.ts.map +0 -1
  83. package/dist/esm/resource-attribute-assignment.mjs +0 -34
  84. package/dist/esm/resource-attributes-constants.d.ts +0 -25
  85. package/dist/esm/resource-attributes-constants.d.ts.map +0 -1
  86. package/dist/esm/resource-attributes-constants.mjs +0 -25
  87. package/dist/esm/utils/path-utils.d.ts +0 -8
  88. package/dist/esm/utils/path-utils.d.ts.map +0 -1
  89. package/dist/esm/utils/path-utils.mjs +0 -15
  90. package/dist/esm/utils/validation.d.ts +0 -45
  91. package/dist/esm/utils/validation.d.ts.map +0 -1
  92. package/dist/esm/utils/validation.mjs +0 -75
  93. package/dist/resource-attribute-assignment.d.ts +0 -24
  94. package/dist/resource-attribute-assignment.d.ts.map +0 -1
  95. package/dist/resource-attribute-assignment.js +0 -36
  96. package/dist/resource-attributes-constants.d.ts +0 -25
  97. package/dist/resource-attributes-constants.d.ts.map +0 -1
  98. package/dist/resource-attributes-constants.js +0 -28
  99. package/dist/utils/path-utils.d.ts +0 -8
  100. package/dist/utils/path-utils.d.ts.map +0 -1
  101. package/dist/utils/path-utils.js +0 -17
  102. package/dist/utils/validation.d.ts +0 -45
  103. package/dist/utils/validation.d.ts.map +0 -1
  104. package/dist/utils/validation.js +0 -77
  105. package/src/authorization-attributes-ms-service.ts +0 -400
  106. package/src/authorization-attributes-sns-service.ts +0 -290
  107. package/src/base-attribute-assignment.ts +0 -55
  108. package/src/entity-attribute-assignment.ts +0 -35
  109. package/src/entity-attributes-constants.ts +0 -7
  110. package/src/errors/argument-error.ts +0 -7
  111. package/src/resource-attribute-assignment.ts +0 -43
  112. package/src/resource-attributes-constants.ts +0 -26
  113. package/src/utils/path-utils.ts +0 -13
  114. package/src/utils/validation.ts +0 -77
@@ -1,197 +0,0 @@
1
- import chunk from 'lodash/chunk.js';
2
- import { sendToSns, getTopicAttributes } from '@mondaydotcomorg/monday-sns';
3
- import { ResourceAttributeOperationEnum, EntityAttributeOperationEnum } from './types/authorization-attributes-contracts.mjs';
4
- import { EntityAttributeAssignment } from './entity-attribute-assignment.mjs';
5
- import { logger } from './authorization-internal-service.mjs';
6
- import { SnsTopicType, ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE, RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND, ASYNC_ENTITY_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE, ENTITY_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND, RESOURCE_SNS_ARN_ENV_VAR_NAME, RESOURCE_SNS_DEV_TEST_NAME, ENTITY_SNS_ARN_ENV_VAR_NAME, ENTITY_SNS_DEV_TEST_NAME } from './constants/sns.mjs';
7
-
8
- class AuthorizationAttributesSnsService {
9
- static LOG_TAG = 'authorization_attributes';
10
- resourceSnsArn;
11
- entitySnsArn;
12
- /**
13
- * Public constructor to create the AuthorizationAttributesSnsService instance.
14
- */
15
- constructor() {
16
- this.resourceSnsArn = AuthorizationAttributesSnsService.getSnsTopicArn(SnsTopicType.RESOURCE);
17
- this.entitySnsArn = AuthorizationAttributesSnsService.getSnsTopicArn(SnsTopicType.ENTITY);
18
- }
19
- /**
20
- * Async function to upsert resource attributes using SNS.
21
- * Sends the updates request to SNS and returns before the change actually took place.
22
- * @param accountId The account ID
23
- * @param appName App name of the calling app
24
- * @param callerActionIdentifier Action identifier
25
- * @param resourceAttributeAssignments Array of resource attribute assignments to upsert
26
- * @return Promise with array of sent operations
27
- */
28
- async upsertResourceAttributesAsync(accountId, appName, callerActionIdentifier, resourceAttributeAssignments) {
29
- const operations = resourceAttributeAssignments.map(assignment => ({
30
- ...assignment,
31
- operationType: ResourceAttributeOperationEnum.UPSERT,
32
- }));
33
- return this.updateResourceAttributesAsync(accountId, appName, callerActionIdentifier, operations);
34
- }
35
- /**
36
- * Async function to delete resource attributes using SNS.
37
- * Sends the updates request to SNS and returns before the change actually took place.
38
- * @param accountId The account ID
39
- * @param appName App name of the calling app
40
- * @param callerActionIdentifier Action identifier
41
- * @param resource The resource (resourceType, resourceId)
42
- * @param attributeKeys Array of attribute keys to delete
43
- * @return Promise with array of sent operations
44
- */
45
- async deleteResourceAttributesAsync(accountId, appName, callerActionIdentifier, resource, attributeKeys) {
46
- const operations = attributeKeys.map(key => ({
47
- resourceType: resource.type,
48
- resourceId: resource.id,
49
- key,
50
- operationType: ResourceAttributeOperationEnum.DELETE,
51
- }));
52
- return this.updateResourceAttributesAsync(accountId, appName, callerActionIdentifier, operations);
53
- }
54
- /**
55
- * Async function to upsert entity attributes using SNS.
56
- * Sends the updates request to SNS and returns before the change actually took place.
57
- * @param accountId The account ID
58
- * @param appName App name of the calling app
59
- * @param callerActionIdentifier Action identifier
60
- * @param entityAttributeAssignments Array of entity attribute assignments to upsert
61
- * @return Promise with array of sent operations
62
- */
63
- async upsertEntityAttributesAsync(accountId, appName, callerActionIdentifier, entityAttributeAssignments) {
64
- const operations = entityAttributeAssignments.map(assignment => {
65
- const assignmentData = assignment instanceof EntityAttributeAssignment ? assignment.toH() : assignment;
66
- return {
67
- entityId: assignmentData.entityId,
68
- entityType: assignmentData.entityType,
69
- key: assignmentData.key,
70
- value: assignmentData.value,
71
- operationType: EntityAttributeOperationEnum.UPSERT,
72
- };
73
- });
74
- return this.updateEntityAttributesAsync(accountId, appName, callerActionIdentifier, operations);
75
- }
76
- /**
77
- * Async function to delete entity attributes using SNS.
78
- * Sends the updates request to SNS and returns before the change actually took place.
79
- * @param accountId The account ID
80
- * @param appName App name of the calling app
81
- * @param callerActionIdentifier Action identifier
82
- * @param entityType The entity type
83
- * @param entityId The entity ID
84
- * @param attributeKeys Array of attribute keys to delete
85
- * @return Promise with array of sent operations
86
- */
87
- async deleteEntityAttributesAsync(accountId, appName, callerActionIdentifier, entityType, entityId, attributeKeys) {
88
- const operations = attributeKeys.map(key => ({
89
- entityType: entityType,
90
- entityId,
91
- key,
92
- operationType: EntityAttributeOperationEnum.DELETE,
93
- }));
94
- return this.updateEntityAttributesAsync(accountId, appName, callerActionIdentifier, operations);
95
- }
96
- /**
97
- * Async function, this function only send the updates request to SNS and return before the change actually took place
98
- * @param accountId
99
- * @param appName - App name of the calling app
100
- * @param callerActionIdentifier - action identifier
101
- * @param resourceAttributeOperations - Array of operations to do on resource attributes.
102
- * @return {Promise<ResourceAttributesOperation[]>} Array of sent operations
103
- * */
104
- async updateResourceAttributesAsync(accountId, appName, callerActionIdentifier, resourceAttributeOperations) {
105
- const topicArn = this.resourceSnsArn;
106
- const sendToSnsPromises = [];
107
- const operationChucks = chunk(resourceAttributeOperations, ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE);
108
- for (const operationsChunk of operationChucks) {
109
- sendToSnsPromises.push(this.sendSingleSnsMessage(topicArn, accountId, appName, callerActionIdentifier, operationsChunk, RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND, 'Authorization resource attributes async update: failed to send operations to SNS'));
110
- }
111
- return (await Promise.all(sendToSnsPromises)).flat();
112
- }
113
- /**
114
- * Async function, this function only send the updates request to SNS and return before the change actually took place
115
- * @param accountId
116
- * @param appName - App name of the calling app
117
- * @param callerActionIdentifier - action identifier
118
- * @param entityAttributeOperations - Array of operations to do on entity attributes.
119
- * @return {Promise<EntityAttributesOperation[]>} Array of sent operations
120
- * */
121
- async updateEntityAttributesAsync(accountId, appName, callerActionIdentifier, entityAttributeOperations) {
122
- const topicArn = this.entitySnsArn;
123
- const sendToSnsPromises = [];
124
- const operationChucks = chunk(entityAttributeOperations, ASYNC_ENTITY_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE);
125
- for (const operationsChunk of operationChucks) {
126
- sendToSnsPromises.push(this.sendSingleSnsMessage(topicArn, accountId, appName, callerActionIdentifier, operationsChunk, ENTITY_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND, 'Authorization entity attributes async update: failed to send operations to SNS'));
127
- }
128
- return (await Promise.all(sendToSnsPromises)).flat();
129
- }
130
- async sendSingleSnsMessage(topicArn, accountId, appName, callerActionIdentifier, operations, kind, errorLogMessage) {
131
- const payload = {
132
- kind,
133
- payload: {
134
- accountId: accountId,
135
- callerAppName: appName,
136
- callerActionIdentifier: callerActionIdentifier,
137
- operations: operations,
138
- },
139
- };
140
- try {
141
- await sendToSns(payload, topicArn);
142
- return operations;
143
- }
144
- catch (error) {
145
- logger.error({ error, tag: AuthorizationAttributesSnsService.LOG_TAG }, errorLogMessage);
146
- return [];
147
- }
148
- }
149
- static getSnsTopicArn(type) {
150
- let envVarName;
151
- let devTestName;
152
- switch (type) {
153
- case SnsTopicType.ENTITY:
154
- envVarName = ENTITY_SNS_ARN_ENV_VAR_NAME;
155
- devTestName = ENTITY_SNS_DEV_TEST_NAME;
156
- break;
157
- default:
158
- // Default to resource SNS constants
159
- envVarName = RESOURCE_SNS_ARN_ENV_VAR_NAME;
160
- devTestName = RESOURCE_SNS_DEV_TEST_NAME;
161
- break;
162
- }
163
- const arnFromEnv = process.env[envVarName];
164
- if (arnFromEnv) {
165
- return arnFromEnv;
166
- }
167
- if (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') {
168
- return devTestName;
169
- }
170
- throw new Error(`Unable to get ${type} sns topic arn from env variable`);
171
- }
172
- /**
173
- * Checks we can contact the required SNS topic that used to send attribute updates to Authorization MS.
174
- * This function can be used as health check for services that updating resource attributes in async is crucial.
175
- * Note this function only verify the POD can contact AWS SDK and the topic exists, but the user still might get
176
- * errors when pushing for the SNS (e.g: in case the AWS role of the POD don't have permissions to push messages).
177
- * However, this is the best we can do without actually push dummy messages to the SNS.
178
- * @return {Promise<boolean>} - true if succeeded
179
- */
180
- async asyncResourceAttributesHealthCheck() {
181
- try {
182
- const requestedTopicArn = this.resourceSnsArn;
183
- const attributes = await getTopicAttributes(requestedTopicArn);
184
- const isHealthy = !(!attributes || !('TopicArn' in attributes) || attributes.TopicArn !== requestedTopicArn);
185
- if (!isHealthy) {
186
- logger.error({ requestedTopicArn, snsReturnedAttributes: attributes, tag: AuthorizationAttributesSnsService.LOG_TAG }, 'authorization-attributes-service failed in health check');
187
- }
188
- return isHealthy;
189
- }
190
- catch (error) {
191
- logger.error({ error, tag: AuthorizationAttributesSnsService.LOG_TAG }, 'authorization-attributes-service got error during health check');
192
- return false;
193
- }
194
- }
195
- }
196
-
197
- export { AuthorizationAttributesSnsService };
@@ -1,18 +0,0 @@
1
- /**
2
- * Base class for attribute assignments (Resource or Entity)
3
- * Provides common validation and functionality
4
- */
5
- export declare abstract class BaseAttributeAssignment<TId extends number, TType extends string> {
6
- readonly id: TId;
7
- readonly type: TType;
8
- readonly attributeKey: string;
9
- readonly attributeValue: string;
10
- constructor(id: TId, type: string, attributeKey: string, attributeValue: string, validTypes: readonly string[], idFieldName: string, typeFieldName: string);
11
- /**
12
- * Compares two assignments for equality
13
- * @param other Another assignment instance
14
- * @returns true if all properties are equal
15
- */
16
- equals(other: BaseAttributeAssignment<TId, TType>): boolean;
17
- }
18
- //# sourceMappingURL=base-attribute-assignment.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"base-attribute-assignment.d.ts","sourceRoot":"","sources":["../../src/base-attribute-assignment.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,8BAAsB,uBAAuB,CAAC,GAAG,SAAS,MAAM,EAAE,KAAK,SAAS,MAAM;IACpF,SAAgB,EAAE,EAAE,GAAG,CAAC;IACxB,SAAgB,IAAI,EAAE,KAAK,CAAC;IAC5B,SAAgB,YAAY,EAAE,MAAM,CAAC;IACrC,SAAgB,cAAc,EAAE,MAAM,CAAC;gBAGrC,EAAE,EAAE,GAAG,EACP,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,SAAS,MAAM,EAAE,EAC7B,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,MAAM;IAmBvB;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,uBAAuB,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,OAAO;CAW5D"}
@@ -1,41 +0,0 @@
1
- import { ValidationUtils } from './utils/validation.mjs';
2
-
3
- /**
4
- * Base class for attribute assignments (Resource or Entity)
5
- * Provides common validation and functionality
6
- */
7
- class BaseAttributeAssignment {
8
- id;
9
- type;
10
- attributeKey;
11
- attributeValue;
12
- constructor(id, type, attributeKey, attributeValue, validTypes, idFieldName, typeFieldName) {
13
- // Validate id
14
- ValidationUtils.validateInteger(id, idFieldName);
15
- // Validate type
16
- this.type = ValidationUtils.validateEnum(type, validTypes, typeFieldName);
17
- // Validate attributeKey
18
- ValidationUtils.validateString(attributeKey, 'attributeKey');
19
- // Validate attributeValue
20
- ValidationUtils.validateString(attributeValue, 'attributeValue');
21
- this.id = id;
22
- this.attributeKey = attributeKey;
23
- this.attributeValue = attributeValue;
24
- }
25
- /**
26
- * Compares two assignments for equality
27
- * @param other Another assignment instance
28
- * @returns true if all properties are equal
29
- */
30
- equals(other) {
31
- if (!(other instanceof this.constructor)) {
32
- return false;
33
- }
34
- return (this.id === other.id &&
35
- this.type === other.type &&
36
- this.attributeKey === other.attributeKey &&
37
- this.attributeValue === other.attributeValue);
38
- }
39
- }
40
-
41
- export { BaseAttributeAssignment };
@@ -1,24 +0,0 @@
1
- import { EntityType } from './entity-attributes-constants';
2
- import { BaseAttributeAssignment } from './base-attribute-assignment';
3
- export declare class EntityAttributeAssignment extends BaseAttributeAssignment<number, EntityType> {
4
- readonly entityId: number;
5
- readonly entityType: EntityType;
6
- constructor(entityId: number, entityType: string, attributeKey: string, attributeValue: string);
7
- /**
8
- * Converts the assignment to hash format with camelCase keys
9
- * @returns Object with camelCase keys: { entityId, entityType, key, value }
10
- */
11
- toH(): {
12
- entityId: number;
13
- entityType: string;
14
- key: string;
15
- value: string;
16
- };
17
- /**
18
- * Compares two assignments for equality
19
- * @param other Another EntityAttributeAssignment instance
20
- * @returns true if all properties are equal
21
- */
22
- equals(other: EntityAttributeAssignment): boolean;
23
- }
24
- //# sourceMappingURL=entity-attribute-assignment.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"entity-attribute-assignment.d.ts","sourceRoot":"","sources":["../../src/entity-attribute-assignment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,UAAU,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAEtE,qBAAa,yBAA0B,SAAQ,uBAAuB,CAAC,MAAM,EAAE,UAAU,CAAC;IACxF,SAAgB,QAAQ,EAAE,MAAM,CAAC;IACjC,SAAgB,UAAU,EAAE,UAAU,CAAC;gBAE3B,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;IAM9F;;;OAGG;IACH,GAAG,IAAI;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE;IAS3E;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO;CAGlD"}
@@ -1,34 +0,0 @@
1
- import { ENTITY_TYPES } from './entity-attributes-constants.mjs';
2
- import { BaseAttributeAssignment } from './base-attribute-assignment.mjs';
3
-
4
- class EntityAttributeAssignment extends BaseAttributeAssignment {
5
- entityId;
6
- entityType;
7
- constructor(entityId, entityType, attributeKey, attributeValue) {
8
- super(entityId, entityType, attributeKey, attributeValue, Object.values(ENTITY_TYPES), 'entityId', 'entityType');
9
- this.entityId = entityId;
10
- this.entityType = this.type;
11
- }
12
- /**
13
- * Converts the assignment to hash format with camelCase keys
14
- * @returns Object with camelCase keys: { entityId, entityType, key, value }
15
- */
16
- toH() {
17
- return {
18
- entityId: this.entityId,
19
- entityType: this.entityType,
20
- key: this.attributeKey,
21
- value: this.attributeValue,
22
- };
23
- }
24
- /**
25
- * Compares two assignments for equality
26
- * @param other Another EntityAttributeAssignment instance
27
- * @returns true if all properties are equal
28
- */
29
- equals(other) {
30
- return super.equals(other);
31
- }
32
- }
33
-
34
- export { EntityAttributeAssignment };
@@ -1,7 +0,0 @@
1
- export declare const ENTITY_TYPES: {
2
- readonly USER: "user";
3
- readonly TEAM: "team";
4
- readonly ACCOUNT: "account";
5
- };
6
- export type EntityType = (typeof ENTITY_TYPES)[keyof typeof ENTITY_TYPES];
7
- //# sourceMappingURL=entity-attributes-constants.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"entity-attributes-constants.d.ts","sourceRoot":"","sources":["../../src/entity-attributes-constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY;;;;CAIf,CAAC;AAEX,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC"}
@@ -1,7 +0,0 @@
1
- const ENTITY_TYPES = {
2
- USER: 'user',
3
- TEAM: 'team',
4
- ACCOUNT: 'account',
5
- };
6
-
7
- export { ENTITY_TYPES };
@@ -1,4 +0,0 @@
1
- export declare class ArgumentError extends Error {
2
- constructor(message: string);
3
- }
4
- //# sourceMappingURL=argument-error.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"argument-error.d.ts","sourceRoot":"","sources":["../../../src/errors/argument-error.ts"],"names":[],"mappings":"AAAA,qBAAa,aAAc,SAAQ,KAAK;gBAC1B,OAAO,EAAE,MAAM;CAK5B"}
@@ -1,9 +0,0 @@
1
- class ArgumentError extends Error {
2
- constructor(message) {
3
- super(message);
4
- this.name = 'ArgumentError';
5
- Object.setPrototypeOf(this, ArgumentError.prototype);
6
- }
7
- }
8
-
9
- export { ArgumentError };
@@ -1,24 +0,0 @@
1
- import { ResourceType } from './resource-attributes-constants';
2
- import { BaseAttributeAssignment } from './base-attribute-assignment';
3
- export declare class ResourceAttributeAssignment extends BaseAttributeAssignment<number, ResourceType> {
4
- readonly resourceId: number;
5
- readonly resourceType: ResourceType;
6
- constructor(resourceId: number, resourceType: string, attributeKey: string, attributeValue: string);
7
- /**
8
- * Converts the assignment to hash format with camelCase keys
9
- * @returns Object with camelCase keys: { resourceId, resourceType, key, value }
10
- */
11
- toH(): {
12
- resourceId: number;
13
- resourceType: string;
14
- key: string;
15
- value: string;
16
- };
17
- /**
18
- * Compares two assignments for equality
19
- * @param other Another ResourceAttributeAssignment instance
20
- * @returns true if all properties are equal
21
- */
22
- equals(other: ResourceAttributeAssignment): boolean;
23
- }
24
- //# sourceMappingURL=resource-attribute-assignment.d.ts.map
@@ -1 +0,0 @@
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,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;IAclG;;;OAGG;IACH,GAAG,IAAI;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE;IAS/E;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,2BAA2B,GAAG,OAAO;CAGpD"}
@@ -1,34 +0,0 @@
1
- import { RESOURCE_TYPES } from './resource-attributes-constants.mjs';
2
- import { BaseAttributeAssignment } from './base-attribute-assignment.mjs';
3
-
4
- class ResourceAttributeAssignment extends BaseAttributeAssignment {
5
- resourceId;
6
- resourceType;
7
- constructor(resourceId, resourceType, attributeKey, attributeValue) {
8
- super(resourceId, resourceType, attributeKey, attributeValue, Object.values(RESOURCE_TYPES), 'resourceId', 'resourceType');
9
- this.resourceId = resourceId;
10
- this.resourceType = this.type;
11
- }
12
- /**
13
- * Converts the assignment to hash format with camelCase keys
14
- * @returns Object with camelCase keys: { resourceId, resourceType, key, value }
15
- */
16
- toH() {
17
- return {
18
- resourceId: this.resourceId,
19
- resourceType: this.resourceType,
20
- key: this.attributeKey,
21
- value: this.attributeValue,
22
- };
23
- }
24
- /**
25
- * Compares two assignments for equality
26
- * @param other Another ResourceAttributeAssignment instance
27
- * @returns true if all properties are equal
28
- */
29
- equals(other) {
30
- return super.equals(other);
31
- }
32
- }
33
-
34
- export { ResourceAttributeAssignment };
@@ -1,25 +0,0 @@
1
- export declare const RESOURCE_TYPES: {
2
- readonly ACCOUNT: "account";
3
- readonly ACCOUNT_PRODUCT: "account_product";
4
- readonly WORKSPACE: "workspace";
5
- readonly BOARD: "board";
6
- readonly ITEM: "item";
7
- readonly TEAM: "team";
8
- readonly OVERVIEW: "overview";
9
- readonly DOCUMENT: "document";
10
- readonly CRM: "crm";
11
- };
12
- export declare const RESOURCE_ATTRIBUTES_CONSTANTS: {
13
- readonly ACCOUNT_RESOURCE_ATTRIBUTES: {
14
- readonly ENABLE_MEMBERS_INVITE_FROM_NON_AUTH_DOMAIN: "enable_members_invite_from_non_auth_domain";
15
- };
16
- readonly WORKSPACE_RESOURCE_ATTRIBUTES: {
17
- readonly IS_DEFAULT_WORKSPACE: "is_default_workspace";
18
- };
19
- readonly BOARD_RESOURCE_ATTRIBUTES: {
20
- readonly IS_SYNCABLE_CHILD_ENTITY: "is_syncable_child_entity";
21
- readonly SYSTEM_ENTITY_TYPE: "system_entity_type";
22
- };
23
- };
24
- export type ResourceType = (typeof RESOURCE_TYPES)[keyof typeof RESOURCE_TYPES];
25
- //# sourceMappingURL=resource-attributes-constants.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resource-attributes-constants.d.ts","sourceRoot":"","sources":["../../src/resource-attributes-constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc;;;;;;;;;;CAUjB,CAAC;AAEX,eAAO,MAAM,6BAA6B;;;;;;;;;;;CAWhC,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC"}
@@ -1,25 +0,0 @@
1
- const RESOURCE_TYPES = {
2
- ACCOUNT: 'account',
3
- ACCOUNT_PRODUCT: 'account_product',
4
- WORKSPACE: 'workspace',
5
- BOARD: 'board',
6
- ITEM: 'item',
7
- TEAM: 'team',
8
- OVERVIEW: 'overview',
9
- DOCUMENT: 'document',
10
- CRM: 'crm',
11
- };
12
- const RESOURCE_ATTRIBUTES_CONSTANTS = {
13
- ACCOUNT_RESOURCE_ATTRIBUTES: {
14
- ENABLE_MEMBERS_INVITE_FROM_NON_AUTH_DOMAIN: 'enable_members_invite_from_non_auth_domain',
15
- },
16
- WORKSPACE_RESOURCE_ATTRIBUTES: {
17
- IS_DEFAULT_WORKSPACE: 'is_default_workspace',
18
- },
19
- BOARD_RESOURCE_ATTRIBUTES: {
20
- IS_SYNCABLE_CHILD_ENTITY: 'is_syncable_child_entity',
21
- SYSTEM_ENTITY_TYPE: 'system_entity_type',
22
- },
23
- };
24
-
25
- export { RESOURCE_ATTRIBUTES_CONSTANTS, RESOURCE_TYPES };
@@ -1,8 +0,0 @@
1
- /**
2
- * Replaces path template parameters with actual values
3
- * @param template Path template with placeholders like {accountId}
4
- * @param params Object with parameter names and values
5
- * @returns Path with all placeholders replaced
6
- */
7
- export declare function replacePathParams(template: string, params: Record<string, string | number>): string;
8
- //# sourceMappingURL=path-utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"path-utils.d.ts","sourceRoot":"","sources":["../../../src/utils/path-utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,GAAG,MAAM,CAMnG"}
@@ -1,15 +0,0 @@
1
- /**
2
- * Replaces path template parameters with actual values
3
- * @param template Path template with placeholders like {accountId}
4
- * @param params Object with parameter names and values
5
- * @returns Path with all placeholders replaced
6
- */
7
- function replacePathParams(template, params) {
8
- let path = template;
9
- for (const [key, value] of Object.entries(params)) {
10
- path = path.replace(`{${key}}`, String(value));
11
- }
12
- return path;
13
- }
14
-
15
- export { replacePathParams };
@@ -1,45 +0,0 @@
1
- /**
2
- * Utility class for common validation operations
3
- */
4
- export declare class ValidationUtils {
5
- /**
6
- * Validates that a value is an integer
7
- * @param value The value to validate
8
- * @param fieldName The name of the field for error messages
9
- * @throws ArgumentError if value is not an integer
10
- */
11
- static validateInteger(value: any, fieldName: string): void;
12
- /**
13
- * Validates that a value is a string
14
- * @param value The value to validate
15
- * @param fieldName The name of the field for error messages
16
- * @throws ArgumentError if value is not a string
17
- */
18
- static validateString(value: any, fieldName: string): void;
19
- /**
20
- * Validates that a value is an array and optionally checks minimum length
21
- * @param value The value to validate
22
- * @param fieldName The name of the field for error messages
23
- * @param minLength Minimum required length (default: 0)
24
- * @returns The validated array
25
- * @throws ArgumentError if value is not an array or doesn't meet minimum length
26
- */
27
- static validateArray<T>(value: any, fieldName: string, minLength?: number): T[];
28
- /**
29
- * Validates that a value is one of the allowed enum values
30
- * @param value The value to validate
31
- * @param validValues Array of valid values
32
- * @param fieldName The name of the field for error messages
33
- * @returns The validated value as the enum type
34
- * @throws ArgumentError if value is not in validValues
35
- */
36
- static validateEnum<T extends string>(value: string, validValues: readonly T[], fieldName: string): T;
37
- /**
38
- * Validates that all items in an array are strings
39
- * @param value Array to validate
40
- * @param fieldName The name of the field for error messages
41
- * @throws ArgumentError if any item is not a string
42
- */
43
- static validateStringArray(value: any[], fieldName: string): void;
44
- }
45
- //# sourceMappingURL=validation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../src/utils/validation.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,qBAAa,eAAe;IAC1B;;;;;OAKG;IACH,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;IAM3D;;;;;OAKG;IACH,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;IAM1D;;;;;;;OAOG;IACH,MAAM,CAAC,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,SAAI,GAAG,CAAC,EAAE;IAU1E;;;;;;;OAOG;IACH,MAAM,CAAC,YAAY,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,CAAC;IAOrG;;;;;OAKG;IACH,MAAM,CAAC,mBAAmB,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;CAOlE"}
@@ -1,75 +0,0 @@
1
- import { ArgumentError } from '../errors/argument-error.mjs';
2
-
3
- /**
4
- * Utility class for common validation operations
5
- */
6
- class ValidationUtils {
7
- /**
8
- * Validates that a value is an integer
9
- * @param value The value to validate
10
- * @param fieldName The name of the field for error messages
11
- * @throws ArgumentError if value is not an integer
12
- */
13
- static validateInteger(value, fieldName) {
14
- if (!Number.isInteger(value)) {
15
- throw new ArgumentError(`${fieldName} must be an integer, got: ${value}`);
16
- }
17
- }
18
- /**
19
- * Validates that a value is a string
20
- * @param value The value to validate
21
- * @param fieldName The name of the field for error messages
22
- * @throws ArgumentError if value is not a string
23
- */
24
- static validateString(value, fieldName) {
25
- if (typeof value !== 'string') {
26
- throw new ArgumentError(`${fieldName} must be a string, got: ${typeof value}`);
27
- }
28
- }
29
- /**
30
- * Validates that a value is an array and optionally checks minimum length
31
- * @param value The value to validate
32
- * @param fieldName The name of the field for error messages
33
- * @param minLength Minimum required length (default: 0)
34
- * @returns The validated array
35
- * @throws ArgumentError if value is not an array or doesn't meet minimum length
36
- */
37
- static validateArray(value, fieldName, minLength = 0) {
38
- if (!Array.isArray(value)) {
39
- throw new ArgumentError(`${fieldName} must be an array`);
40
- }
41
- if (value.length < minLength) {
42
- throw new ArgumentError(`${fieldName} must have at least ${minLength} items`);
43
- }
44
- return value;
45
- }
46
- /**
47
- * Validates that a value is one of the allowed enum values
48
- * @param value The value to validate
49
- * @param validValues Array of valid values
50
- * @param fieldName The name of the field for error messages
51
- * @returns The validated value as the enum type
52
- * @throws ArgumentError if value is not in validValues
53
- */
54
- static validateEnum(value, validValues, fieldName) {
55
- if (!validValues.includes(value)) {
56
- throw new ArgumentError(`${fieldName} must be one of [${validValues.join(', ')}], got: ${value}`);
57
- }
58
- return value;
59
- }
60
- /**
61
- * Validates that all items in an array are strings
62
- * @param value Array to validate
63
- * @param fieldName The name of the field for error messages
64
- * @throws ArgumentError if any item is not a string
65
- */
66
- static validateStringArray(value, fieldName) {
67
- for (let i = 0; i < value.length; i++) {
68
- if (typeof value[i] !== 'string') {
69
- throw new ArgumentError(`All ${fieldName} must be strings, but item at index ${i} is not`);
70
- }
71
- }
72
- }
73
- }
74
-
75
- export { ValidationUtils };