@mondaydotcomorg/monday-authorization 3.5.3-feat-shaime-support-entity-attributes-in-authorization-sdk-ade64f6 → 3.7.0-feat-shaime-support-entity-attributes-4-49e1de0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/authorization-attributes-ms-service.d.ts +6 -8
- package/dist/authorization-attributes-ms-service.d.ts.map +1 -1
- package/dist/authorization-attributes-ms-service.js +16 -95
- package/dist/authorization-attributes-service.d.ts +1 -2
- package/dist/authorization-attributes-service.d.ts.map +1 -1
- package/dist/authorization-attributes-service.js +0 -1
- package/dist/authorization-attributes-sns-service.d.ts +4 -3
- package/dist/authorization-attributes-sns-service.d.ts.map +1 -1
- package/dist/authorization-middleware.d.ts +2 -2
- package/dist/authorization-middleware.d.ts.map +1 -1
- package/dist/authorization-service.d.ts +3 -3
- package/dist/authorization-service.d.ts.map +1 -1
- package/dist/base-attribute-assignment.d.ts +2 -0
- package/dist/base-attribute-assignment.d.ts.map +1 -1
- package/dist/base-attribute-assignment.js +11 -18
- package/dist/entity-attribute-assignment.d.ts +6 -0
- package/dist/entity-attribute-assignment.d.ts.map +1 -1
- package/dist/entity-attribute-assignment.js +9 -1
- package/dist/entity-attributes-constants.d.ts +6 -6
- package/dist/entity-attributes-constants.d.ts.map +1 -1
- package/dist/entity-attributes-constants.js +7 -5
- package/dist/errors/argument-error.d.ts.map +1 -1
- package/dist/errors/argument-error.js +0 -1
- package/dist/esm/authorization-attributes-ms-service.d.ts +6 -8
- package/dist/esm/authorization-attributes-ms-service.d.ts.map +1 -1
- package/dist/esm/authorization-attributes-ms-service.mjs +16 -95
- package/dist/esm/authorization-attributes-service.d.ts +1 -2
- package/dist/esm/authorization-attributes-service.d.ts.map +1 -1
- package/dist/esm/authorization-attributes-service.mjs +0 -1
- package/dist/esm/authorization-attributes-sns-service.d.ts +4 -3
- package/dist/esm/authorization-attributes-sns-service.d.ts.map +1 -1
- package/dist/esm/authorization-middleware.d.ts +2 -2
- package/dist/esm/authorization-middleware.d.ts.map +1 -1
- package/dist/esm/authorization-service.d.ts +3 -3
- package/dist/esm/authorization-service.d.ts.map +1 -1
- package/dist/esm/base-attribute-assignment.d.ts +2 -0
- package/dist/esm/base-attribute-assignment.d.ts.map +1 -1
- package/dist/esm/base-attribute-assignment.mjs +7 -18
- package/dist/esm/entity-attribute-assignment.d.ts +6 -0
- package/dist/esm/entity-attribute-assignment.d.ts.map +1 -1
- package/dist/esm/entity-attribute-assignment.mjs +9 -1
- package/dist/esm/entity-attributes-constants.d.ts +6 -6
- package/dist/esm/entity-attributes-constants.d.ts.map +1 -1
- package/dist/esm/entity-attributes-constants.mjs +8 -6
- package/dist/esm/errors/argument-error.d.ts.map +1 -1
- package/dist/esm/errors/argument-error.mjs +0 -1
- package/dist/esm/index.d.ts +0 -9
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.mjs +0 -7
- package/dist/esm/prometheus-service.d.ts +2 -1
- package/dist/esm/prometheus-service.d.ts.map +1 -1
- package/dist/esm/resource-attribute-assignment.d.ts +7 -1
- package/dist/esm/resource-attribute-assignment.d.ts.map +1 -1
- package/dist/esm/resource-attribute-assignment.mjs +8 -0
- package/dist/esm/resource-attributes-constants.d.ts +12 -2
- package/dist/esm/resource-attributes-constants.d.ts.map +1 -1
- package/dist/esm/resource-attributes-constants.mjs +15 -12
- package/dist/esm/types/authorization-attributes-contracts.d.ts +1 -1
- package/dist/esm/types/authorization-attributes-contracts.d.ts.map +1 -1
- package/dist/esm/types/authorization-attributes-service.interface.d.ts +4 -3
- package/dist/esm/types/authorization-attributes-service.interface.d.ts.map +1 -1
- package/dist/esm/types/general.d.ts +2 -1
- package/dist/esm/types/general.d.ts.map +1 -1
- package/dist/esm/utils/validation.d.ts +30 -30
- package/dist/esm/utils/validation.d.ts.map +1 -1
- package/dist/esm/utils/validation.mjs +121 -86
- package/dist/index.d.ts +0 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -15
- package/dist/prometheus-service.d.ts +2 -1
- package/dist/prometheus-service.d.ts.map +1 -1
- package/dist/resource-attribute-assignment.d.ts +7 -1
- package/dist/resource-attribute-assignment.d.ts.map +1 -1
- package/dist/resource-attribute-assignment.js +8 -0
- package/dist/resource-attributes-constants.d.ts +12 -2
- package/dist/resource-attributes-constants.d.ts.map +1 -1
- package/dist/resource-attributes-constants.js +14 -11
- package/dist/types/authorization-attributes-contracts.d.ts +1 -1
- package/dist/types/authorization-attributes-contracts.d.ts.map +1 -1
- package/dist/types/authorization-attributes-service.interface.d.ts +4 -3
- package/dist/types/authorization-attributes-service.interface.d.ts.map +1 -1
- package/dist/types/general.d.ts +2 -1
- package/dist/types/general.d.ts.map +1 -1
- package/dist/utils/validation.d.ts +30 -30
- package/dist/utils/validation.d.ts.map +1 -1
- package/dist/utils/validation.js +125 -86
- package/package.json +4 -3
- package/src/authorization-attributes-ms-service.ts +23 -117
- package/src/authorization-attributes-service.ts +1 -2
- package/src/authorization-attributes-sns-service.ts +3 -3
- package/src/authorization-middleware.ts +2 -2
- package/src/authorization-service.ts +4 -4
- package/src/base-attribute-assignment.ts +14 -23
- package/src/entity-attribute-assignment.ts +10 -1
- package/src/entity-attributes-constants.ts +6 -6
- package/src/errors/argument-error.ts +0 -1
- package/src/index.ts +0 -9
- package/src/prometheus-service.ts +3 -1
- package/src/resource-attribute-assignment.ts +10 -1
- package/src/resource-attributes-constants.ts +13 -21
- package/src/types/authorization-attributes-contracts.ts +0 -2
- package/src/types/authorization-attributes-service.interface.ts +3 -3
- package/src/types/general.ts +2 -3
- package/src/utils/validation.ts +139 -82
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Api } from '@mondaydotcomorg/trident-backend-api';
|
|
2
2
|
import { signAuthorizationHeader } from '@mondaydotcomorg/monday-jwt';
|
|
3
|
-
import { z } from 'zod';
|
|
4
3
|
import { ResourceAttributeAssignment } from './resource-attribute-assignment.mjs';
|
|
5
4
|
import { EntityAttributeAssignment } from './entity-attribute-assignment.mjs';
|
|
6
5
|
import { AttributeOperation } from './types/authorization-attributes-contracts.mjs';
|
|
@@ -21,7 +20,10 @@ const DELETE_ENTITY_ATTRIBUTES_PATH = '/attributes/{accountId}/entity/{entityTyp
|
|
|
21
20
|
*/
|
|
22
21
|
class AuthorizationAttributesMsService {
|
|
23
22
|
static LOG_TAG = 'authorization_attributes_ms';
|
|
24
|
-
static httpClient = Api.getPart('httpClient');
|
|
23
|
+
static httpClient = Api.getPart('httpClient') ?? null;
|
|
24
|
+
static destroyHttpClient() {
|
|
25
|
+
AuthorizationAttributesMsService.httpClient = null;
|
|
26
|
+
}
|
|
25
27
|
/**
|
|
26
28
|
* Creates or updates resource attributes synchronously.
|
|
27
29
|
* @param accountId The account ID
|
|
@@ -39,15 +41,8 @@ class AuthorizationAttributesMsService {
|
|
|
39
41
|
* @returns Promise<void>
|
|
40
42
|
*/
|
|
41
43
|
async deleteResourceAttributes(accountId, resource, attributeKeys, _appName, _callerActionIdentifier) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
throw new ArgumentError('resource must be an object');
|
|
45
|
-
}
|
|
46
|
-
if (!resource.id) {
|
|
47
|
-
throw new ArgumentError('resource.id is required');
|
|
48
|
-
}
|
|
49
|
-
ValidationUtils.validateInteger(resource.id, 'resource.id');
|
|
50
|
-
ValidationUtils.validateString(resource.type, 'resource.type');
|
|
44
|
+
ValidationUtils.validateResource(resource);
|
|
45
|
+
ValidationUtils.validateStringArray(attributeKeys);
|
|
51
46
|
return AuthorizationAttributesMsService.executeDeleteRequest(accountId, DELETE_RESOURCE_ATTRIBUTES_PATH, {
|
|
52
47
|
resourceType: resource.type,
|
|
53
48
|
resourceId: resource.id,
|
|
@@ -74,7 +69,7 @@ class AuthorizationAttributesMsService {
|
|
|
74
69
|
if (!entityType || typeof entityType !== 'string' || entityType.trim() === '') {
|
|
75
70
|
throw new ArgumentError(`entityType must be a non-empty string, got: ${entityType}`);
|
|
76
71
|
}
|
|
77
|
-
ValidationUtils.validateInteger(entityId
|
|
72
|
+
ValidationUtils.validateInteger(entityId);
|
|
78
73
|
return AuthorizationAttributesMsService.executeDeleteRequest(accountId, DELETE_ENTITY_ATTRIBUTES_PATH, {
|
|
79
74
|
entityType,
|
|
80
75
|
entityId,
|
|
@@ -159,18 +154,13 @@ class AuthorizationAttributesMsService {
|
|
|
159
154
|
*/
|
|
160
155
|
static async executeDeleteRequest(accountId, pathTemplate, pathParams, keys, logPrefix, methodName, context = {}) {
|
|
161
156
|
// Validate inputs
|
|
162
|
-
ValidationUtils.validateInteger(accountId
|
|
163
|
-
ValidationUtils.
|
|
157
|
+
ValidationUtils.validateInteger(accountId);
|
|
158
|
+
ValidationUtils.validateStringArray(keys);
|
|
164
159
|
if (!keys.length) {
|
|
165
160
|
logger.warn({ tag: this.LOG_TAG, accountId, ...pathParams }, `${methodName} called with empty keys array`);
|
|
166
161
|
return;
|
|
167
162
|
}
|
|
168
|
-
|
|
169
|
-
ValidationUtils.validateStringArray(keys, 'attributeKeys');
|
|
170
|
-
// Build request body
|
|
171
|
-
const requestBody = {
|
|
172
|
-
keys,
|
|
173
|
-
};
|
|
163
|
+
const requestBody = { keys };
|
|
174
164
|
if (!AuthorizationAttributesMsService.httpClient) {
|
|
175
165
|
throw new Error('AuthorizationAttributesMsService: HTTP client is not initialized');
|
|
176
166
|
}
|
|
@@ -190,7 +180,7 @@ class AuthorizationAttributesMsService {
|
|
|
190
180
|
timeout: AuthorizationInternalService.getRequestTimeout(),
|
|
191
181
|
retryPolicy: AuthorizationInternalService.getRetriesPolicy(),
|
|
192
182
|
});
|
|
193
|
-
logger.
|
|
183
|
+
logger.debug({ tag: AuthorizationAttributesMsService.LOG_TAG, accountId, ...pathParams, keys }, `Successfully deleted ${logPrefix} attributes`);
|
|
194
184
|
}
|
|
195
185
|
catch (err) {
|
|
196
186
|
logger.error({
|
|
@@ -249,88 +239,19 @@ class AuthorizationAttributesMsService {
|
|
|
249
239
|
headers['X-REQUEST-START'] = Math.floor(Date.now() / 1000).toString();
|
|
250
240
|
return headers;
|
|
251
241
|
}
|
|
252
|
-
/**
|
|
253
|
-
* Validates that all messages are instances of the specified message class
|
|
254
|
-
*/
|
|
255
|
-
static validateMessages(attributesMessages, messageClass) {
|
|
256
|
-
// Validate messageClass is a function using Zod
|
|
257
|
-
const classSchema = z.custom(value => typeof value === 'function', {
|
|
258
|
-
message: 'messageClass must be a class/constructor function',
|
|
259
|
-
});
|
|
260
|
-
try {
|
|
261
|
-
classSchema.parse(messageClass);
|
|
262
|
-
}
|
|
263
|
-
catch (error) {
|
|
264
|
-
if (error instanceof z.ZodError) {
|
|
265
|
-
const firstError = error.issues[0];
|
|
266
|
-
throw new ArgumentError(firstError.message);
|
|
267
|
-
}
|
|
268
|
-
throw error;
|
|
269
|
-
}
|
|
270
|
-
const className = messageClass.name || 'ResourceAttributeAssignment';
|
|
271
|
-
// First validate it's an array
|
|
272
|
-
ValidationUtils.validateArray(attributesMessages, 'attributesMessages');
|
|
273
|
-
// Then use Zod to validate each item is an instance of the class
|
|
274
|
-
const schema = z.array(z.any()).refine(items => {
|
|
275
|
-
for (let i = 0; i < items.length; i++) {
|
|
276
|
-
if (!(items[i] instanceof messageClass)) {
|
|
277
|
-
return false;
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
return true;
|
|
281
|
-
}, {
|
|
282
|
-
message: `All attributesMessages must be instances of ${className}`,
|
|
283
|
-
});
|
|
284
|
-
try {
|
|
285
|
-
schema.parse(attributesMessages);
|
|
286
|
-
}
|
|
287
|
-
catch (error) {
|
|
288
|
-
if (error instanceof z.ZodError) {
|
|
289
|
-
// Find the first invalid index for a more specific error message
|
|
290
|
-
const invalidIndex = attributesMessages.findIndex(item => !(item instanceof messageClass));
|
|
291
|
-
if (invalidIndex !== -1) {
|
|
292
|
-
throw new ArgumentError(`All attributesMessages must be instances of ${className}, but item at index ${invalidIndex} is not`);
|
|
293
|
-
}
|
|
294
|
-
const firstError = error.issues[0];
|
|
295
|
-
throw new ArgumentError(firstError.message);
|
|
296
|
-
}
|
|
297
|
-
throw error;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
242
|
/**
|
|
301
243
|
* Generic helper for executing upsert requests
|
|
302
244
|
*/
|
|
303
245
|
static async executeUpsertRequest(accountId, assignments, pathTemplate, requestBodyKey, assignmentClass, logPrefix, methodName) {
|
|
304
|
-
|
|
305
|
-
ValidationUtils.
|
|
306
|
-
ValidationUtils.validateArray(assignments, 'assignments');
|
|
246
|
+
ValidationUtils.validateInteger(accountId);
|
|
247
|
+
ValidationUtils.validateArrayTypeOf(assignments, assignmentClass);
|
|
307
248
|
if (!assignments.length) {
|
|
308
|
-
logger.warn({ tag: AuthorizationAttributesMsService.LOG_TAG, accountId }, `${methodName} called with empty array`);
|
|
309
249
|
return;
|
|
310
250
|
}
|
|
311
|
-
|
|
312
|
-
AuthorizationAttributesMsService.validateMessages(assignments, assignmentClass);
|
|
313
|
-
const compatibileAssignments = assignments.map(assignment => {
|
|
314
|
-
if (assignment instanceof ResourceAttributeAssignment) {
|
|
315
|
-
return {
|
|
316
|
-
resourceId: assignment.resourceId,
|
|
317
|
-
resourceType: assignment.resourceType,
|
|
318
|
-
key: assignment.attributeKey,
|
|
319
|
-
value: assignment.attributeValue,
|
|
320
|
-
};
|
|
321
|
-
}
|
|
322
|
-
else {
|
|
323
|
-
return {
|
|
324
|
-
entityId: assignment.entityId,
|
|
325
|
-
entityType: assignment.entityType,
|
|
326
|
-
key: assignment.attributeKey,
|
|
327
|
-
value: assignment.attributeValue,
|
|
328
|
-
};
|
|
329
|
-
}
|
|
330
|
-
});
|
|
251
|
+
const assignmentDto = assignments.map(assignment => assignment.toDataTransferObject());
|
|
331
252
|
const requestBody = requestBodyKey === 'resourceAttributeAssignments'
|
|
332
|
-
? { resourceAttributeAssignments:
|
|
333
|
-
: { entityAttributeAssignments:
|
|
253
|
+
? { resourceAttributeAssignments: assignmentDto }
|
|
254
|
+
: { entityAttributeAssignments: assignmentDto };
|
|
334
255
|
if (!AuthorizationAttributesMsService.httpClient) {
|
|
335
256
|
throw new Error('AuthorizationAttributesMsService: HTTP client is not initialized');
|
|
336
257
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { IAuthorizationAttributesService } from './types/authorization-attributes-service.interface';
|
|
1
|
+
import { AuthorizationAttributesService as IAuthorizationAttributesService } from './types/authorization-attributes-service.interface';
|
|
2
2
|
/**
|
|
3
3
|
* Main service class for managing resource and entity attributes.
|
|
4
4
|
* Provides access to both direct (MS) and SNS operations.
|
|
5
5
|
*
|
|
6
6
|
* @example
|
|
7
|
-
* ```typescript
|
|
8
7
|
* const service = new AuthorizationAttributesService();
|
|
9
8
|
*
|
|
10
9
|
* // Use direct operations
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization-attributes-service.d.ts","sourceRoot":"","sources":["../../src/authorization-attributes-service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,+BAA+B,EAAE,MAAM,oDAAoD,CAAC;
|
|
1
|
+
{"version":3,"file":"authorization-attributes-service.d.ts","sourceRoot":"","sources":["../../src/authorization-attributes-service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,8BAA8B,IAAI,+BAA+B,EAAE,MAAM,oDAAoD,CAAC;AAEvI;;;;;;;;;;;;;GAaG;AACH,qBAAa,8BAA8B;IACzC,OAAO,CAAC,cAAc,CAAiD;IACvE,OAAO,CAAC,WAAW,CAAkD;IAErE;;;;OAIG;IACH,MAAM,IAAI,+BAA+B;IAOzC;;;;OAIG;IACH,GAAG,IAAI,+BAA+B;CAMvC"}
|
|
@@ -6,7 +6,6 @@ import { AuthorizationAttributesSnsService } from './authorization-attributes-sn
|
|
|
6
6
|
* Provides access to both direct (MS) and SNS operations.
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
|
-
* ```typescript
|
|
10
9
|
* const service = new AuthorizationAttributesService();
|
|
11
10
|
*
|
|
12
11
|
* // Use direct operations
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { ResourceAttributeAssignment, ResourceAttributeOperation, EntityAttributeOperation
|
|
1
|
+
import { ResourceAttributeAssignment, ResourceAttributeOperation, EntityAttributeOperation } from './types/authorization-attributes-contracts';
|
|
2
2
|
import { EntityAttributeAssignment } from './entity-attribute-assignment';
|
|
3
3
|
import { Resource } from './types/general';
|
|
4
|
-
import {
|
|
4
|
+
import { AuthorizationAttributesService } from './types/authorization-attributes-service.interface';
|
|
5
|
+
import { EntityType } from './entity-attributes-constants';
|
|
5
6
|
/**
|
|
6
7
|
* Service class for managing resource attributes asynchronously via SNS.
|
|
7
8
|
* Provides asynchronous operations to create/update and delete attributes on resources.
|
|
8
9
|
*/
|
|
9
|
-
export declare class AuthorizationAttributesSnsService implements
|
|
10
|
+
export declare class AuthorizationAttributesSnsService implements AuthorizationAttributesService {
|
|
10
11
|
private static LOG_TAG;
|
|
11
12
|
private resourceSnsArn;
|
|
12
13
|
private entitySnsArn;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization-attributes-sns-service.d.ts","sourceRoot":"","sources":["../../src/authorization-attributes-sns-service.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,EAC1B,wBAAwB,
|
|
1
|
+
{"version":3,"file":"authorization-attributes-sns-service.d.ts","sourceRoot":"","sources":["../../src/authorization-attributes-sns-service.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,EAC1B,wBAAwB,EAEzB,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAc3C,OAAO,EAAE,8BAA8B,EAAE,MAAM,oDAAoD,CAAC;AACpG,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D;;;GAGG;AACH,qBAAa,iCAAkC,YAAW,8BAA8B;IACtF,OAAO,CAA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O,EAAE,MAAM,EACf,sBAAsB,EAAE,MAAM,EAC9B,yBAAyB,EAAE,wBAAwB,EAAE,GACpD,OAAO,CAAC,wBAAwB,EAAE,CAAC;YAoBxB,oBAAoB;IA2BlC,OAAO,CAAC,MAAM,CAAC,cAAc;IA0B7B;;;;;;;OAOG;IACG,kCAAkC,IAAI,OAAO,CAAC,OAAO,CAAC;CAoB7D"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BaseRequest, BaseResponse, Context, ContextGetter, ResourceGetter } from './types/general';
|
|
1
|
+
import { Action, BaseRequest, BaseResponse, Context, ContextGetter, ResourceGetter } from './types/general';
|
|
2
2
|
import type { NextFunction } from 'express';
|
|
3
|
-
export declare function getAuthorizationMiddleware(action:
|
|
3
|
+
export declare function getAuthorizationMiddleware(action: Action, resourceGetter: ResourceGetter, contextGetter?: ContextGetter): (request: BaseRequest, response: BaseResponse, next: NextFunction) => Promise<void>;
|
|
4
4
|
export declare function skipAuthorizationMiddleware(request: BaseRequest, response: BaseResponse, next: NextFunction): void;
|
|
5
5
|
export declare function authorizationCheckMiddleware(request: BaseRequest, response: BaseResponse, next: NextFunction): void;
|
|
6
6
|
export declare function defaultContextGetter(request: BaseRequest): Context;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization-middleware.d.ts","sourceRoot":"","sources":["../../src/authorization-middleware.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"authorization-middleware.d.ts","sourceRoot":"","sources":["../../src/authorization-middleware.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC5G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAI5C,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,cAAc,EAC9B,aAAa,CAAC,EAAE,aAAa,IAG3B,SAAS,WAAW,EACpB,UAAU,YAAY,EACtB,MAAM,YAAY,KACjB,OAAO,CAAC,IAAI,CAAC,CAajB;AAED,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY,GAAG,IAAI,CAGlH;AAED,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY,GAAG,IAAI,CASnH;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAElE"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MondayFetchOptions } from '@mondaydotcomorg/monday-fetch';
|
|
2
2
|
import { IgniteClient } from '@mondaydotcomorg/ignite-sdk';
|
|
3
|
-
import { AuthorizationObject, AuthorizationParams, Resource } from './types/general';
|
|
3
|
+
import { Action, AuthorizationObject, AuthorizationParams, Resource } from './types/general';
|
|
4
4
|
import { ScopedAction, ScopedActionPermit, ScopedActionResponseObject, ScopeOptions } from './types/scoped-actions-contracts';
|
|
5
5
|
export interface AuthorizeResponse {
|
|
6
6
|
isAuthorized: boolean;
|
|
@@ -21,7 +21,7 @@ export declare class AuthorizationService {
|
|
|
21
21
|
* @deprecated use the second form with authorizationRequestObjects instead,
|
|
22
22
|
* support of this function will be dropped gradually
|
|
23
23
|
*/
|
|
24
|
-
static isAuthorized(accountId: number, userId: number, resources: Resource[], action:
|
|
24
|
+
static isAuthorized(accountId: number, userId: number, resources: Resource[], action: Action): Promise<AuthorizeResponse>;
|
|
25
25
|
static isAuthorized(accountId: number, userId: number, authorizationRequestObjects: AuthorizationObject[]): Promise<AuthorizeResponse>;
|
|
26
26
|
/**
|
|
27
27
|
* @deprecated - Please use Ignite instead: https://github.com/DaPulse/ignite-monorepo/blob/master/packages/ignite-sdk/README.md
|
|
@@ -40,5 +40,5 @@ export declare class AuthorizationService {
|
|
|
40
40
|
}
|
|
41
41
|
export declare function setRedisClient(client: any, grantedFeatureRedisExpirationInSeconds?: number): void;
|
|
42
42
|
export declare function setIgniteClient(): Promise<void>;
|
|
43
|
-
export declare function createAuthorizationParams(resources: Resource[], action:
|
|
43
|
+
export declare function createAuthorizationParams(resources: Resource[], action: Action): AuthorizationParams;
|
|
44
44
|
//# sourceMappingURL=authorization-service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization-service.d.ts","sourceRoot":"","sources":["../../src/authorization-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAGnE,OAAO,EAAmB,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"authorization-service.d.ts","sourceRoot":"","sources":["../../src/authorization-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAGnE,OAAO,EAAmB,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG7F,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,0BAA0B,EAC1B,YAAY,EACb,MAAM,kCAAkC,CAAC;AAe1C,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,OAAO,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,mBAAmB,CAAC,EAAE,mBAAmB,EAAE,CAAC;CAC7C;AAED,wBAAgB,sBAAsB,CAAC,wBAAwB,EAAE,kBAAkB,QAElF;AAMD,qBAAa,oBAAoB;IAC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AoB;CAmF1C;AAED,wBAAgB,cAAc,CAC5B,MAAM,KAAA,EACN,sCAAsC,GAAE,MAAiD,QAY1F;AAED,wBAAsB,eAAe,kBAMpC;AAED,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,mBAAmB,CAepG"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { EntityAttributeAssignment, ResourceAttributeDelete } from './types/authorization-attributes-contracts';
|
|
1
2
|
/**
|
|
2
3
|
* Base class for attribute assignments (Resource or Entity)
|
|
3
4
|
* Provides common validation and functionality
|
|
@@ -14,5 +15,6 @@ export declare abstract class BaseAttributeAssignment<TId extends number, TType
|
|
|
14
15
|
* @returns true if all properties are equal
|
|
15
16
|
*/
|
|
16
17
|
equals(other: BaseAttributeAssignment<TId, TType>): boolean;
|
|
18
|
+
abstract toDataTransferObject(): EntityAttributeAssignment | ResourceAttributeDelete;
|
|
17
19
|
}
|
|
18
20
|
//# sourceMappingURL=base-attribute-assignment.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
1
|
+
{"version":3,"file":"base-attribute-assignment.d.ts","sourceRoot":"","sources":["../../src/base-attribute-assignment.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,4CAA4C,CAAC;AAEhH;;;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;IAcvB;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,uBAAuB,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,OAAO;IAI3D,QAAQ,CAAC,oBAAoB,IAAI,yBAAyB,GAAG,uBAAuB;CACrF"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ValidationUtils } from './utils/validation.mjs';
|
|
2
|
+
import isEqual from 'lodash/isEqual.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Base class for attribute assignments (Resource or Entity)
|
|
@@ -10,17 +11,11 @@ class BaseAttributeAssignment {
|
|
|
10
11
|
attributeKey;
|
|
11
12
|
attributeValue;
|
|
12
13
|
constructor(id, type, attributeKey, attributeValue, validTypes, idFieldName, typeFieldName) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
this.
|
|
17
|
-
|
|
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;
|
|
14
|
+
const validated = ValidationUtils.validateAssignment({ id, type, attributeKey, attributeValue }, validTypes, { id: idFieldName, type: typeFieldName });
|
|
15
|
+
this.id = validated.id;
|
|
16
|
+
this.type = validated.type;
|
|
17
|
+
this.attributeKey = validated.attributeKey;
|
|
18
|
+
this.attributeValue = validated.attributeValue;
|
|
24
19
|
}
|
|
25
20
|
/**
|
|
26
21
|
* Compares two assignments for equality
|
|
@@ -28,13 +23,7 @@ class BaseAttributeAssignment {
|
|
|
28
23
|
* @returns true if all properties are equal
|
|
29
24
|
*/
|
|
30
25
|
equals(other) {
|
|
31
|
-
|
|
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);
|
|
26
|
+
return isEqual(this, other);
|
|
38
27
|
}
|
|
39
28
|
}
|
|
40
29
|
|
|
@@ -4,6 +4,12 @@ export declare class EntityAttributeAssignment extends BaseAttributeAssignment<n
|
|
|
4
4
|
readonly entityId: number;
|
|
5
5
|
readonly entityType: EntityType;
|
|
6
6
|
constructor(entityId: number, entityType: string, attributeKey: string, attributeValue: string);
|
|
7
|
+
toDataTransferObject(): {
|
|
8
|
+
entityId: number;
|
|
9
|
+
entityType: EntityType;
|
|
10
|
+
key: string;
|
|
11
|
+
value: string;
|
|
12
|
+
};
|
|
7
13
|
/**
|
|
8
14
|
* Compares two assignments for equality
|
|
9
15
|
* @param other Another EntityAttributeAssignment instance
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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,oBAAoB;;;;;;IAQpB;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO;CAGlD"}
|
|
@@ -5,10 +5,18 @@ class EntityAttributeAssignment extends BaseAttributeAssignment {
|
|
|
5
5
|
entityId;
|
|
6
6
|
entityType;
|
|
7
7
|
constructor(entityId, entityType, attributeKey, attributeValue) {
|
|
8
|
-
super(entityId, entityType, attributeKey, attributeValue,
|
|
8
|
+
super(entityId, entityType, attributeKey, attributeValue, ENTITY_TYPES, 'entityId', 'entityType');
|
|
9
9
|
this.entityId = entityId;
|
|
10
10
|
this.entityType = this.type;
|
|
11
11
|
}
|
|
12
|
+
toDataTransferObject() {
|
|
13
|
+
return {
|
|
14
|
+
entityId: this.entityId,
|
|
15
|
+
entityType: this.entityType,
|
|
16
|
+
key: this.attributeKey,
|
|
17
|
+
value: this.attributeValue,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
12
20
|
/**
|
|
13
21
|
* Compares two assignments for equality
|
|
14
22
|
* @param other Another EntityAttributeAssignment instance
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export declare
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
export
|
|
1
|
+
export declare enum EntityType {
|
|
2
|
+
User = "user",
|
|
3
|
+
Team = "team",
|
|
4
|
+
Account = "account"
|
|
5
|
+
}
|
|
6
|
+
export declare const ENTITY_TYPES: readonly EntityType[];
|
|
7
7
|
//# sourceMappingURL=entity-attributes-constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-attributes-constants.d.ts","sourceRoot":"","sources":["../../src/entity-attributes-constants.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"entity-attributes-constants.d.ts","sourceRoot":"","sources":["../../src/entity-attributes-constants.ts"],"names":[],"mappings":"AAAA,oBAAY,UAAU;IACpB,IAAI,SAAS;IACb,IAAI,SAAS;IACb,OAAO,YAAY;CACpB;AAED,eAAO,MAAM,YAAY,uBAA2C,CAAC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
var EntityType;
|
|
2
|
+
(function (EntityType) {
|
|
3
|
+
EntityType["User"] = "user";
|
|
4
|
+
EntityType["Team"] = "team";
|
|
5
|
+
EntityType["Account"] = "account";
|
|
6
|
+
})(EntityType || (EntityType = {}));
|
|
7
|
+
const ENTITY_TYPES = Object.freeze(Object.values(EntityType));
|
|
6
8
|
|
|
7
|
-
export { ENTITY_TYPES };
|
|
9
|
+
export { ENTITY_TYPES, EntityType };
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;CAI5B"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -19,15 +19,6 @@ export declare function init(options?: InitOptions): Promise<void>;
|
|
|
19
19
|
export { authorizationCheckMiddleware, getAuthorizationMiddleware, skipAuthorizationMiddleware, } from './authorization-middleware';
|
|
20
20
|
export { AuthorizationService, AuthorizeResponse } from './authorization-service';
|
|
21
21
|
export { AuthorizationAttributesService } from './authorization-attributes-service';
|
|
22
|
-
export { AuthorizationAttributesSnsService } from './authorization-attributes-sns-service';
|
|
23
|
-
export { AuthorizationAttributesMsService } from './authorization-attributes-ms-service';
|
|
24
|
-
export { IAuthorizationAttributesService } from './types/authorization-attributes-service.interface';
|
|
25
|
-
export { ResourceAttributeAssignment } from './resource-attribute-assignment';
|
|
26
|
-
export { RESOURCE_TYPES, RESOURCE_ATTRIBUTES_CONSTANTS } from './resource-attributes-constants';
|
|
27
|
-
export { EntityAttributeAssignment } from './entity-attribute-assignment';
|
|
28
|
-
export { ENTITY_TYPES } from './entity-attributes-constants';
|
|
29
|
-
export { ArgumentError } from './errors/argument-error';
|
|
30
|
-
export type { EntityType } from './entity-attributes-constants';
|
|
31
22
|
export { RolesService } from './roles-service';
|
|
32
23
|
export { MembershipsService } from './memberships';
|
|
33
24
|
export { AuthorizationObject, Resource, BaseRequest, ResourceGetter, ContextGetter } from './types/general';
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAGnE,OAAO,EAAqB,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO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BAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,sCAAsC,CAAC,EAAE,MAAM,CAAC;IAChD,OAAO,CAAC,EAAE,kBAAkB,CAAC;CAC9B;AAED,wBAAsB,IAAI,CAAC,OAAO,GAAE,WAAgB,iBA6BnD;AAED,OAAO,EACL,4BAA4B,EAC5B,0BAA0B,EAC1B,2BAA2B,GAC5B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAClF,OAAO,EAAE,8BAA8B,EAAE,MAAM,oCAAoC,CAAC;AACpF,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC5G,OAAO,EACL,WAAW,EACX,YAAY,EACZ,0BAA0B,EAC1B,kBAAkB,GACnB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAErH,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -6,13 +6,6 @@ import * as testKit_index from './testKit/index.mjs';
|
|
|
6
6
|
export { testKit_index as TestKit };
|
|
7
7
|
export { authorizationCheckMiddleware, getAuthorizationMiddleware, skipAuthorizationMiddleware } from './authorization-middleware.mjs';
|
|
8
8
|
export { AuthorizationAttributesService } from './authorization-attributes-service.mjs';
|
|
9
|
-
export { AuthorizationAttributesSnsService } from './authorization-attributes-sns-service.mjs';
|
|
10
|
-
export { AuthorizationAttributesMsService } from './authorization-attributes-ms-service.mjs';
|
|
11
|
-
export { ResourceAttributeAssignment } from './resource-attribute-assignment.mjs';
|
|
12
|
-
export { RESOURCE_ATTRIBUTES_CONSTANTS, RESOURCE_TYPES } from './resource-attributes-constants.mjs';
|
|
13
|
-
export { EntityAttributeAssignment } from './entity-attribute-assignment.mjs';
|
|
14
|
-
export { ENTITY_TYPES } from './entity-attributes-constants.mjs';
|
|
15
|
-
export { ArgumentError } from './errors/argument-error.mjs';
|
|
16
9
|
export { RolesService } from './roles-service.mjs';
|
|
17
10
|
export { MembershipsService } from './memberships.mjs';
|
|
18
11
|
export { RoleType } from './types/roles.mjs';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Action } from './types/general';
|
|
1
2
|
export declare const METRICS: {
|
|
2
3
|
AUTHORIZATION_CHECK: string;
|
|
3
4
|
AUTHORIZATION_CHECKS_PER_REQUEST: string;
|
|
@@ -5,5 +6,5 @@ export declare const METRICS: {
|
|
|
5
6
|
};
|
|
6
7
|
export declare function setPrometheus(customPrometheus: any): void;
|
|
7
8
|
export declare function getMetricsManager(): any;
|
|
8
|
-
export declare function sendAuthorizationCheckResponseTimeMetric(resourceType: string, action:
|
|
9
|
+
export declare function sendAuthorizationCheckResponseTimeMetric(resourceType: string, action: Action, isAuthorized: boolean, responseStatus: number, time: number): void;
|
|
9
10
|
//# sourceMappingURL=prometheus-service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prometheus-service.d.ts","sourceRoot":"","sources":["../../src/prometheus-service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prometheus-service.d.ts","sourceRoot":"","sources":["../../src/prometheus-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAKzC,eAAO,MAAM,OAAO;;;;CAInB,CAAC;AAQF,wBAAgB,aAAa,CAAC,gBAAgB,KAAA,QAa7C;AAED,wBAAgB,iBAAiB,QAEhC;AAED,wBAAgB,wCAAwC,CACtD,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,OAAO,EACrB,cAAc,EAAE,MAAM,EACtB,IAAI,EAAE,MAAM,QASb"}
|
|
@@ -3,7 +3,13 @@ import { BaseAttributeAssignment } from './base-attribute-assignment';
|
|
|
3
3
|
export declare class ResourceAttributeAssignment extends BaseAttributeAssignment<number, ResourceType> {
|
|
4
4
|
readonly resourceId: number;
|
|
5
5
|
readonly resourceType: ResourceType;
|
|
6
|
-
constructor(resourceId: number, resourceType:
|
|
6
|
+
constructor(resourceId: number, resourceType: ResourceType, attributeKey: string, attributeValue: string);
|
|
7
|
+
toDataTransferObject(): {
|
|
8
|
+
resourceId: number;
|
|
9
|
+
resourceType: ResourceType;
|
|
10
|
+
key: string;
|
|
11
|
+
value: string;
|
|
12
|
+
};
|
|
7
13
|
/**
|
|
8
14
|
* Compares two assignments for equality
|
|
9
15
|
* @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,
|
|
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"}
|
|
@@ -9,6 +9,14 @@ class ResourceAttributeAssignment extends BaseAttributeAssignment {
|
|
|
9
9
|
this.resourceId = resourceId;
|
|
10
10
|
this.resourceType = this.type;
|
|
11
11
|
}
|
|
12
|
+
toDataTransferObject() {
|
|
13
|
+
return {
|
|
14
|
+
resourceId: this.resourceId,
|
|
15
|
+
resourceType: this.resourceType,
|
|
16
|
+
key: this.attributeKey,
|
|
17
|
+
value: this.attributeValue,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
12
20
|
/**
|
|
13
21
|
* Compares two assignments for equality
|
|
14
22
|
* @param other Another ResourceAttributeAssignment instance
|
|
@@ -10,6 +10,16 @@ export declare const RESOURCE_ATTRIBUTES_CONSTANTS: {
|
|
|
10
10
|
readonly SYSTEM_ENTITY_TYPE: "system_entity_type";
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
|
-
export
|
|
14
|
-
|
|
13
|
+
export declare enum ResourceType {
|
|
14
|
+
Account = "account",
|
|
15
|
+
AccountProduct = "account_product",
|
|
16
|
+
Workspace = "workspace",
|
|
17
|
+
Board = "board",
|
|
18
|
+
Item = "item",
|
|
19
|
+
Team = "team",
|
|
20
|
+
Overview = "overview",
|
|
21
|
+
Document = "document",
|
|
22
|
+
Crm = "crm"
|
|
23
|
+
}
|
|
24
|
+
export declare const RESOURCE_TYPES: readonly ResourceType[];
|
|
15
25
|
//# 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,
|
|
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"}
|
|
@@ -10,16 +10,19 @@ const RESOURCE_ATTRIBUTES_CONSTANTS = {
|
|
|
10
10
|
SYSTEM_ENTITY_TYPE: 'system_entity_type',
|
|
11
11
|
},
|
|
12
12
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
var ResourceType;
|
|
14
|
+
(function (ResourceType) {
|
|
15
|
+
ResourceType["Account"] = "account";
|
|
16
|
+
ResourceType["AccountProduct"] = "account_product";
|
|
17
|
+
ResourceType["Workspace"] = "workspace";
|
|
18
|
+
ResourceType["Board"] = "board";
|
|
19
|
+
ResourceType["Item"] = "item";
|
|
20
|
+
ResourceType["Team"] = "team";
|
|
21
|
+
ResourceType["Overview"] = "overview";
|
|
22
|
+
ResourceType["Document"] = "document";
|
|
23
|
+
ResourceType["Crm"] = "crm";
|
|
24
|
+
})(ResourceType || (ResourceType = {}));
|
|
25
|
+
// Define the array of strings and use 'as const' to make its contents literal types
|
|
26
|
+
const RESOURCE_TYPES = Object.freeze(Object.values(ResourceType));
|
|
24
27
|
|
|
25
|
-
export { RESOURCE_ATTRIBUTES_CONSTANTS, RESOURCE_TYPES };
|
|
28
|
+
export { RESOURCE_ATTRIBUTES_CONSTANTS, RESOURCE_TYPES, ResourceType };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Resource } from './general';
|
|
2
2
|
import type { EntityType } from '../entity-attributes-constants';
|
|
3
3
|
import type { ResourceType } from '../resource-attributes-constants';
|
|
4
|
-
export type { EntityType, ResourceType };
|
|
5
4
|
interface AttributeAssignment {
|
|
6
5
|
key: string;
|
|
7
6
|
value: string;
|
|
@@ -40,4 +39,5 @@ export interface ResourceAttributeOperation extends ResourceAttributeAssignment
|
|
|
40
39
|
export interface EntityAttributeOperation extends EntityAttributeAssignment {
|
|
41
40
|
operationType: AttributeOperation;
|
|
42
41
|
}
|
|
42
|
+
export {};
|
|
43
43
|
//# 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,
|
|
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"}
|