@mondaydotcomorg/monday-authorization 3.5.0-feat-use-profile-for-graph-can-action-in-scope-f1451ab → 3.5.0-feat-shaime-support-entity-attributes-in-authorization-sdk-c9e4cfc
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/attributions-service.d.ts.map +1 -1
- package/dist/attributions-service.js +1 -0
- package/dist/authorization-attributes-ms-service.d.ts +37 -0
- package/dist/authorization-attributes-ms-service.d.ts.map +1 -0
- package/dist/authorization-attributes-ms-service.js +232 -0
- package/dist/authorization-attributes-service.d.ts +45 -1
- package/dist/authorization-attributes-service.d.ts.map +1 -1
- package/dist/authorization-attributes-service.js +262 -0
- package/dist/clients/graph-api.d.ts.map +1 -1
- package/dist/clients/graph-api.js +0 -1
- package/dist/constants.d.ts +0 -3
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +0 -4
- package/dist/errors/argument-error.d.ts +4 -0
- package/dist/errors/argument-error.d.ts.map +1 -0
- package/dist/errors/argument-error.js +11 -0
- package/dist/esm/attributions-service.d.ts.map +1 -1
- package/dist/esm/attributions-service.mjs +1 -0
- package/dist/esm/authorization-attributes-ms-service.d.ts +37 -0
- package/dist/esm/authorization-attributes-ms-service.d.ts.map +1 -0
- package/dist/esm/authorization-attributes-ms-service.mjs +230 -0
- package/dist/esm/authorization-attributes-service.d.ts +45 -1
- package/dist/esm/authorization-attributes-service.d.ts.map +1 -1
- package/dist/esm/authorization-attributes-service.mjs +263 -1
- package/dist/esm/clients/graph-api.d.ts.map +1 -1
- package/dist/esm/clients/graph-api.mjs +1 -2
- package/dist/esm/constants.d.ts +0 -3
- package/dist/esm/constants.d.ts.map +1 -1
- package/dist/esm/constants.mjs +1 -5
- package/dist/esm/errors/argument-error.d.ts +4 -0
- package/dist/esm/errors/argument-error.d.ts.map +1 -0
- package/dist/esm/errors/argument-error.mjs +9 -0
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.mjs +4 -0
- package/dist/esm/resource-attribute-assignment.d.ts +25 -0
- package/dist/esm/resource-attribute-assignment.d.ts.map +1 -0
- package/dist/esm/resource-attribute-assignment.mjs +60 -0
- package/dist/esm/resource-attributes-constants.d.ts +25 -0
- package/dist/esm/resource-attributes-constants.d.ts.map +1 -0
- package/dist/esm/resource-attributes-constants.mjs +25 -0
- package/dist/esm/types/authorization-attributes-contracts.d.ts +19 -3
- package/dist/esm/types/authorization-attributes-contracts.d.ts.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -0
- package/dist/resource-attribute-assignment.d.ts +25 -0
- package/dist/resource-attribute-assignment.d.ts.map +1 -0
- package/dist/resource-attribute-assignment.js +62 -0
- package/dist/resource-attributes-constants.d.ts +25 -0
- package/dist/resource-attributes-constants.d.ts.map +1 -0
- package/dist/resource-attributes-constants.js +28 -0
- package/dist/types/authorization-attributes-contracts.d.ts +19 -3
- package/dist/types/authorization-attributes-contracts.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/attributions-service.ts +4 -0
- package/src/authorization-attributes-ms-service.ts +327 -0
- package/src/authorization-attributes-service.ts +325 -0
- package/src/clients/graph-api.ts +1 -2
- package/src/constants.ts +0 -4
- package/src/errors/argument-error.ts +8 -0
- package/src/index.ts +16 -0
- package/src/resource-attribute-assignment.ts +70 -0
- package/src/resource-attributes-constants.ts +27 -0
- package/src/types/authorization-attributes-contracts.ts +49 -3
package/dist/constants.js
CHANGED
|
@@ -2,10 +2,6 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2
2
|
|
|
3
3
|
const APP_NAME = 'authorization';
|
|
4
4
|
const GRAPH_APP_NAME = 'authorization-graph';
|
|
5
|
-
exports.GraphProfile = void 0;
|
|
6
|
-
(function (GraphProfile) {
|
|
7
|
-
GraphProfile["PERMISSION"] = "authorization-graph-permission";
|
|
8
|
-
})(exports.GraphProfile || (exports.GraphProfile = {}));
|
|
9
5
|
const ERROR_MESSAGES = {
|
|
10
6
|
HTTP_CLIENT_NOT_INITIALIZED: 'MondayAuthorization: HTTP client is not initialized',
|
|
11
7
|
REQUEST_FAILED: (method, status, reason) => `MondayAuthorization: [${method}] request failed with status ${status} with reason: ${reason}`,
|
|
@@ -0,0 +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;CAK5B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
class ArgumentError extends Error {
|
|
4
|
+
constructor(message) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.name = 'ArgumentError';
|
|
7
|
+
Object.setPrototypeOf(this, ArgumentError.prototype);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
exports.ArgumentError = ArgumentError;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attributions-service.d.ts","sourceRoot":"","sources":["../../src/attributions-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAStF,oBAAY,eAAe;IACzB,YAAY,iBAAiB;IAC7B,IAAI,SAAS;IACb,QAAQ,aAAa;IACrB,GAAG,QAAQ;CACZ;AAED,wBAAgB,UAAU,mFAiBzB;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,gBAAgB,CAEtE;AAED,wBAAgB,sBAAsB,IAAI;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"attributions-service.d.ts","sourceRoot":"","sources":["../../src/attributions-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAStF,oBAAY,eAAe;IACzB,YAAY,iBAAiB;IAC7B,IAAI,SAAS;IACb,QAAQ,aAAa;IACrB,GAAG,QAAQ;CACZ;AAED,wBAAgB,UAAU,mFAiBzB;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,gBAAgB,CAEtE;AAED,wBAAgB,sBAAsB,IAAI;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAyClE"}
|
|
@@ -44,6 +44,7 @@ function getAttributionsFromApi() {
|
|
|
44
44
|
const { runtimeAttributions } = tridentContext;
|
|
45
45
|
const runtimeAttributionsOutgoingHeaders = runtimeAttributions?.buildOutgoingHeaders('HTTP_INTERNAL');
|
|
46
46
|
if (!runtimeAttributionsOutgoingHeaders) {
|
|
47
|
+
logger.info({ tag: 'authorization-service', runtimeAttributionsOutgoingHeaders }, 'No runtime attributions outgoing headers');
|
|
47
48
|
return callerAppNameFromSdk;
|
|
48
49
|
}
|
|
49
50
|
const attributionsHeaders = Object.fromEntries(runtimeAttributionsOutgoingHeaders);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ResourceAttributeAssignment } from './resource-attribute-assignment';
|
|
2
|
+
interface Resource {
|
|
3
|
+
resourceType: string;
|
|
4
|
+
resourceId: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Service class for managing resource attributes in the authorization microservice.
|
|
8
|
+
* Provides synchronous HTTP operations to create/update and delete attributes on resources.
|
|
9
|
+
*/
|
|
10
|
+
export declare class AuthorizationAttributesMsService {
|
|
11
|
+
private static LOG_TAG;
|
|
12
|
+
/**
|
|
13
|
+
* Gets request headers including Authorization, Content-Type, and optional attribution headers
|
|
14
|
+
*/
|
|
15
|
+
private static getRequestHeaders;
|
|
16
|
+
/**
|
|
17
|
+
* Validates that all messages are instances of the specified message class
|
|
18
|
+
*/
|
|
19
|
+
private static validateMessages;
|
|
20
|
+
/**
|
|
21
|
+
* Creates or updates resource attributes synchronously.
|
|
22
|
+
* @param accountId The account ID
|
|
23
|
+
* @param resourceAttributeAssignments Array of ResourceAttributeAssignment objects
|
|
24
|
+
* @returns Promise<void>
|
|
25
|
+
*/
|
|
26
|
+
static upsertResourceAttributesSync(accountId: number, resourceAttributeAssignments: ResourceAttributeAssignment[]): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Deletes specific attributes from a resource synchronously.
|
|
29
|
+
* @param accountId The account ID
|
|
30
|
+
* @param resource Object with resourceType (string) and resourceId (number)
|
|
31
|
+
* @param attributeKeys Array of attribute key strings to delete
|
|
32
|
+
* @returns Promise<void>
|
|
33
|
+
*/
|
|
34
|
+
static deleteResourceAttributesSync(accountId: number, resource: Resource, attributeKeys: string[]): Promise<void>;
|
|
35
|
+
}
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=authorization-attributes-ms-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorization-attributes-ms-service.d.ts","sourceRoot":"","sources":["../../src/authorization-attributes-ms-service.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AAW9E,UAAU,QAAQ;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB;AAeD;;;GAGG;AACH,qBAAa,gCAAgC;IAC3C,OAAO,CAAC,MAAM,CAAC,OAAO,CAAiC;IAEvD;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,iBAAiB;IA+ChC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAsB/B;;;;;OAKG;WACU,4BAA4B,CACvC,SAAS,EAAE,MAAM,EACjB,4BAA4B,EAAE,2BAA2B,EAAE,GAC1D,OAAO,CAAC,IAAI,CAAC;IAwFhB;;;;;;OAMG;WACU,4BAA4B,CACvC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,QAAQ,EAClB,aAAa,EAAE,MAAM,EAAE,GACtB,OAAO,CAAC,IAAI,CAAC;CAuGjB"}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { Api } from '@mondaydotcomorg/trident-backend-api';
|
|
2
|
+
import { signAuthorizationHeader } from '@mondaydotcomorg/monday-jwt';
|
|
3
|
+
import { HttpFetcherError } from '@mondaydotcomorg/monday-fetch-api';
|
|
4
|
+
import { ResourceAttributeAssignment } from './resource-attribute-assignment.mjs';
|
|
5
|
+
import { ArgumentError } from './errors/argument-error.mjs';
|
|
6
|
+
import { logger, AuthorizationInternalService } from './authorization-internal-service.mjs';
|
|
7
|
+
import { getAttributionsFromApi } from './attributions-service.mjs';
|
|
8
|
+
import { APP_NAME } from './constants.mjs';
|
|
9
|
+
|
|
10
|
+
const INTERNAL_APP_NAME = 'internal_ms';
|
|
11
|
+
const UPSERT_RESOURCE_ATTRIBUTES_PATH = '/attributes/{accountId}/resource';
|
|
12
|
+
const DELETE_RESOURCE_ATTRIBUTES_PATH = '/attributes/{accountId}/resource/{resourceType}/{resourceId}';
|
|
13
|
+
/**
|
|
14
|
+
* Service class for managing resource attributes in the authorization microservice.
|
|
15
|
+
* Provides synchronous HTTP operations to create/update and delete attributes on resources.
|
|
16
|
+
*/
|
|
17
|
+
class AuthorizationAttributesMsService {
|
|
18
|
+
static LOG_TAG = 'authorization_attributes_ms';
|
|
19
|
+
/**
|
|
20
|
+
* Gets request headers including Authorization, Content-Type, and optional attribution headers
|
|
21
|
+
*/
|
|
22
|
+
static getRequestHeaders(accountId, userId) {
|
|
23
|
+
const headers = {
|
|
24
|
+
'Content-Type': 'application/json',
|
|
25
|
+
};
|
|
26
|
+
// Generate Authorization token
|
|
27
|
+
const authToken = signAuthorizationHeader({
|
|
28
|
+
appName: INTERNAL_APP_NAME,
|
|
29
|
+
accountId,
|
|
30
|
+
userId,
|
|
31
|
+
});
|
|
32
|
+
headers.Authorization = authToken;
|
|
33
|
+
// Add attribution headers if available
|
|
34
|
+
const attributionHeaders = getAttributionsFromApi();
|
|
35
|
+
for (const key in attributionHeaders) {
|
|
36
|
+
if (attributionHeaders.hasOwnProperty(key)) {
|
|
37
|
+
headers[key] = attributionHeaders[key];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// Add X-REQUEST-ID if available from context
|
|
41
|
+
try {
|
|
42
|
+
const tridentContext = Api.getPart('context');
|
|
43
|
+
if (tridentContext?.runtimeAttributions) {
|
|
44
|
+
const outgoingHeaders = tridentContext.runtimeAttributions.buildOutgoingHeaders('HTTP_INTERNAL');
|
|
45
|
+
if (outgoingHeaders) {
|
|
46
|
+
const attributionHeadersMap = {};
|
|
47
|
+
for (const [key, value] of outgoingHeaders) {
|
|
48
|
+
attributionHeadersMap[key] = value;
|
|
49
|
+
}
|
|
50
|
+
if (attributionHeadersMap['x-request-id']) {
|
|
51
|
+
headers['X-REQUEST-ID'] = attributionHeadersMap['x-request-id'];
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
// Silently fail if context is not available
|
|
58
|
+
logger.debug({ tag: this.LOG_TAG, error }, 'Failed to get request ID from context');
|
|
59
|
+
}
|
|
60
|
+
// Add X-REQUEST-START timestamp
|
|
61
|
+
headers['X-REQUEST-START'] = Math.floor(Date.now() / 1000).toString();
|
|
62
|
+
return headers;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Validates that all messages are instances of the specified message class
|
|
66
|
+
*/
|
|
67
|
+
static validateMessages(attributesMessages, messageClass) {
|
|
68
|
+
if (typeof messageClass !== 'function') {
|
|
69
|
+
throw new ArgumentError('messageClass must be a class/constructor function');
|
|
70
|
+
}
|
|
71
|
+
if (!Array.isArray(attributesMessages)) {
|
|
72
|
+
throw new ArgumentError('attributesMessages must be an array');
|
|
73
|
+
}
|
|
74
|
+
for (let i = 0; i < attributesMessages.length; i++) {
|
|
75
|
+
if (!(attributesMessages[i] instanceof messageClass)) {
|
|
76
|
+
const className = messageClass.name || 'ResourceAttributeAssignment';
|
|
77
|
+
throw new ArgumentError(`All attributesMessages must be instances of ${className}, but item at index ${i} is not`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Creates or updates resource attributes synchronously.
|
|
83
|
+
* @param accountId The account ID
|
|
84
|
+
* @param resourceAttributeAssignments Array of ResourceAttributeAssignment objects
|
|
85
|
+
* @returns Promise<void>
|
|
86
|
+
*/
|
|
87
|
+
static async upsertResourceAttributesSync(accountId, resourceAttributeAssignments) {
|
|
88
|
+
// Skip HTTP requests in test environment
|
|
89
|
+
if (process.env.NODE_ENV === 'test') {
|
|
90
|
+
logger.debug({ tag: this.LOG_TAG, accountId, count: resourceAttributeAssignments.length }, 'Skipping upsertResourceAttributesSync in test environment');
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
// Validate inputs
|
|
94
|
+
if (!Number.isInteger(accountId)) {
|
|
95
|
+
throw new ArgumentError(`accountId must be an integer, got: ${accountId}`);
|
|
96
|
+
}
|
|
97
|
+
if (!Array.isArray(resourceAttributeAssignments)) {
|
|
98
|
+
throw new ArgumentError('resourceAttributeAssignments must be an array');
|
|
99
|
+
}
|
|
100
|
+
if (resourceAttributeAssignments.length === 0) {
|
|
101
|
+
logger.warn({ tag: this.LOG_TAG, accountId }, 'upsertResourceAttributesSync called with empty array');
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
// Validate all assignments are instances of ResourceAttributeAssignment
|
|
105
|
+
this.validateMessages(resourceAttributeAssignments, ResourceAttributeAssignment);
|
|
106
|
+
// Convert assignments to hash format
|
|
107
|
+
const assignmentsHash = resourceAttributeAssignments.map(assignment => assignment.toH());
|
|
108
|
+
// Build request body
|
|
109
|
+
const requestBody = {
|
|
110
|
+
resourceAttributeAssignments: assignmentsHash,
|
|
111
|
+
};
|
|
112
|
+
const httpClient = Api.getPart('httpClient');
|
|
113
|
+
if (!httpClient) {
|
|
114
|
+
throw new Error('AuthorizationAttributesMsService: HTTP client is not initialized');
|
|
115
|
+
}
|
|
116
|
+
const path = UPSERT_RESOURCE_ATTRIBUTES_PATH.replace('{accountId}', accountId.toString());
|
|
117
|
+
const headers = this.getRequestHeaders(accountId);
|
|
118
|
+
try {
|
|
119
|
+
logger.info({ tag: this.LOG_TAG, accountId, count: resourceAttributeAssignments.length }, 'Upserting resource attributes');
|
|
120
|
+
await httpClient.fetch({
|
|
121
|
+
url: {
|
|
122
|
+
appName: APP_NAME,
|
|
123
|
+
path,
|
|
124
|
+
},
|
|
125
|
+
method: 'POST',
|
|
126
|
+
headers,
|
|
127
|
+
body: JSON.stringify(requestBody),
|
|
128
|
+
}, {
|
|
129
|
+
timeout: AuthorizationInternalService.getRequestTimeout(),
|
|
130
|
+
retryPolicy: AuthorizationInternalService.getRetriesPolicy(),
|
|
131
|
+
});
|
|
132
|
+
logger.info({ tag: this.LOG_TAG, accountId, count: resourceAttributeAssignments.length }, 'Successfully upserted resource attributes');
|
|
133
|
+
}
|
|
134
|
+
catch (err) {
|
|
135
|
+
logger.error({
|
|
136
|
+
tag: this.LOG_TAG,
|
|
137
|
+
accountId,
|
|
138
|
+
method: 'upsertResourceAttributesSync',
|
|
139
|
+
error: err instanceof Error ? err.message : String(err),
|
|
140
|
+
}, 'Failed to upsert resource attributes');
|
|
141
|
+
if (err instanceof HttpFetcherError) {
|
|
142
|
+
throw new Error(`AuthorizationAttributesMsService: [upsertResourceAttributesSync] request failed with status ${err.status}: ${err.message}`);
|
|
143
|
+
}
|
|
144
|
+
throw err;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Deletes specific attributes from a resource synchronously.
|
|
149
|
+
* @param accountId The account ID
|
|
150
|
+
* @param resource Object with resourceType (string) and resourceId (number)
|
|
151
|
+
* @param attributeKeys Array of attribute key strings to delete
|
|
152
|
+
* @returns Promise<void>
|
|
153
|
+
*/
|
|
154
|
+
static async deleteResourceAttributesSync(accountId, resource, attributeKeys) {
|
|
155
|
+
// Skip HTTP requests in test environment
|
|
156
|
+
if (process.env.NODE_ENV === 'test') {
|
|
157
|
+
logger.debug({ tag: this.LOG_TAG, accountId, resource, attributeKeys }, 'Skipping deleteResourceAttributesSync in test environment');
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
// Validate inputs
|
|
161
|
+
if (!Number.isInteger(accountId)) {
|
|
162
|
+
throw new ArgumentError(`accountId must be an integer, got: ${accountId}`);
|
|
163
|
+
}
|
|
164
|
+
if (!resource || typeof resource !== 'object') {
|
|
165
|
+
throw new ArgumentError('resource must be an object');
|
|
166
|
+
}
|
|
167
|
+
if (!Number.isInteger(resource.resourceId)) {
|
|
168
|
+
throw new ArgumentError(`resource.resourceId must be an integer, got: ${resource.resourceId}`);
|
|
169
|
+
}
|
|
170
|
+
if (typeof resource.resourceType !== 'string') {
|
|
171
|
+
throw new ArgumentError(`resource.resourceType must be a string, got: ${typeof resource.resourceType}`);
|
|
172
|
+
}
|
|
173
|
+
if (!Array.isArray(attributeKeys)) {
|
|
174
|
+
throw new ArgumentError('attributeKeys must be an array');
|
|
175
|
+
}
|
|
176
|
+
if (attributeKeys.length === 0) {
|
|
177
|
+
logger.warn({ tag: this.LOG_TAG, accountId, resource }, 'deleteResourceAttributesSync called with empty keys array');
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
// Validate all keys are strings
|
|
181
|
+
for (let i = 0; i < attributeKeys.length; i++) {
|
|
182
|
+
if (typeof attributeKeys[i] !== 'string') {
|
|
183
|
+
throw new ArgumentError(`All attributeKeys must be strings, but item at index ${i} is not`);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
// Build request body
|
|
187
|
+
const requestBody = {
|
|
188
|
+
keys: attributeKeys,
|
|
189
|
+
};
|
|
190
|
+
const httpClient = Api.getPart('httpClient');
|
|
191
|
+
if (!httpClient) {
|
|
192
|
+
throw new Error('AuthorizationAttributesMsService: HTTP client is not initialized');
|
|
193
|
+
}
|
|
194
|
+
const path = DELETE_RESOURCE_ATTRIBUTES_PATH.replace('{accountId}', accountId.toString())
|
|
195
|
+
.replace('{resourceType}', resource.resourceType)
|
|
196
|
+
.replace('{resourceId}', resource.resourceId.toString());
|
|
197
|
+
const headers = this.getRequestHeaders(accountId);
|
|
198
|
+
try {
|
|
199
|
+
logger.info({ tag: this.LOG_TAG, accountId, resource, keys: attributeKeys }, 'Deleting resource attributes');
|
|
200
|
+
await httpClient.fetch({
|
|
201
|
+
url: {
|
|
202
|
+
appName: APP_NAME,
|
|
203
|
+
path,
|
|
204
|
+
},
|
|
205
|
+
method: 'DELETE',
|
|
206
|
+
headers,
|
|
207
|
+
body: JSON.stringify(requestBody),
|
|
208
|
+
}, {
|
|
209
|
+
timeout: AuthorizationInternalService.getRequestTimeout(),
|
|
210
|
+
retryPolicy: AuthorizationInternalService.getRetriesPolicy(),
|
|
211
|
+
});
|
|
212
|
+
logger.info({ tag: this.LOG_TAG, accountId, resource, keys: attributeKeys }, 'Successfully deleted resource attributes');
|
|
213
|
+
}
|
|
214
|
+
catch (err) {
|
|
215
|
+
logger.error({
|
|
216
|
+
tag: this.LOG_TAG,
|
|
217
|
+
accountId,
|
|
218
|
+
method: 'deleteResourceAttributesSync',
|
|
219
|
+
resource,
|
|
220
|
+
error: err instanceof Error ? err.message : String(err),
|
|
221
|
+
}, 'Failed to delete resource attributes');
|
|
222
|
+
if (err instanceof HttpFetcherError) {
|
|
223
|
+
throw new Error(`AuthorizationAttributesMsService: [deleteResourceAttributesSync] request failed with status ${err.status}: ${err.message}`);
|
|
224
|
+
}
|
|
225
|
+
throw err;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export { AuthorizationAttributesMsService };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FetcherConfig, HttpClient } from '@mondaydotcomorg/trident-backend-api';
|
|
2
2
|
import { RecursivePartial } from '@mondaydotcomorg/monday-fetch-api';
|
|
3
|
-
import { ResourceAttributeAssignment, ResourceAttributeResponse, ResourceAttributesOperation } from './types/authorization-attributes-contracts';
|
|
3
|
+
import { ResourceAttributeAssignment, ResourceAttributeResponse, ResourceAttributesOperation, EntityAttributeAssignment, EntityAttributeResponse, ResourceType, EntityType, ResourceAttributeKeyType, EntityAttributeKeyType } from './types/authorization-attributes-contracts';
|
|
4
4
|
import { Resource } from './types/general';
|
|
5
5
|
export declare class AuthorizationAttributesService {
|
|
6
6
|
private static LOG_TAG;
|
|
@@ -50,5 +50,49 @@ export declare class AuthorizationAttributesService {
|
|
|
50
50
|
* @return {Promise<boolean>} - true if succeeded
|
|
51
51
|
*/
|
|
52
52
|
asyncResourceAttributesHealthCheck(): Promise<boolean>;
|
|
53
|
+
/**
|
|
54
|
+
* Validates resource attribute assignments array
|
|
55
|
+
*/
|
|
56
|
+
private static validateResourceAttributeAssignments;
|
|
57
|
+
/**
|
|
58
|
+
* Validates entity attribute assignments array
|
|
59
|
+
*/
|
|
60
|
+
private static validateEntityAttributeAssignments;
|
|
61
|
+
/**
|
|
62
|
+
* Upsert resource attributes synchronously.
|
|
63
|
+
* Matches API endpoint: POST /attributes/:accountId/resource
|
|
64
|
+
* @param accountId The account ID
|
|
65
|
+
* @param resourceAttributeAssignments Array of ResourceAttributeAssignment objects (1-100 items)
|
|
66
|
+
* @returns Promise with response containing affected attributes
|
|
67
|
+
*/
|
|
68
|
+
static upsertResourceAttributesSync(accountId: number, resourceAttributeAssignments: ResourceAttributeAssignment[]): Promise<ResourceAttributeResponse>;
|
|
69
|
+
/**
|
|
70
|
+
* Delete resource attributes synchronously.
|
|
71
|
+
* Matches API endpoint: DELETE /attributes/:accountId/resource/:resourceType/:resourceId
|
|
72
|
+
* @param accountId The account ID
|
|
73
|
+
* @param resourceType The resource type
|
|
74
|
+
* @param resourceId The resource ID
|
|
75
|
+
* @param keys Array of attribute keys to delete
|
|
76
|
+
* @returns Promise with response containing affected attributes
|
|
77
|
+
*/
|
|
78
|
+
static deleteResourceAttributesSync(accountId: number, resourceType: ResourceType, resourceId: number, keys: ResourceAttributeKeyType[]): Promise<ResourceAttributeResponse>;
|
|
79
|
+
/**
|
|
80
|
+
* Upsert entity attributes synchronously.
|
|
81
|
+
* Matches API endpoint: POST /attributes/:accountId/entity
|
|
82
|
+
* @param accountId The account ID
|
|
83
|
+
* @param entityAttributeAssignments Array of EntityAttributeAssignment objects (1-100 items)
|
|
84
|
+
* @returns Promise with response containing affected attributes
|
|
85
|
+
*/
|
|
86
|
+
static upsertEntityAttributesSync(accountId: number, entityAttributeAssignments: EntityAttributeAssignment[]): Promise<EntityAttributeResponse>;
|
|
87
|
+
/**
|
|
88
|
+
* Delete entity attributes synchronously.
|
|
89
|
+
* Matches API endpoint: DELETE /attributes/:accountId/entity/:entityType/:entityId
|
|
90
|
+
* @param accountId The account ID
|
|
91
|
+
* @param entityType The entity type
|
|
92
|
+
* @param entityId The entity ID
|
|
93
|
+
* @param keys Array of attribute keys to delete
|
|
94
|
+
* @returns Promise with response containing affected attributes
|
|
95
|
+
*/
|
|
96
|
+
static deleteEntityAttributesSync(accountId: number, entityType: EntityType, entityId: number, keys: EntityAttributeKeyType[]): Promise<EntityAttributeResponse>;
|
|
53
97
|
}
|
|
54
98
|
//# sourceMappingURL=authorization-attributes-service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization-attributes-service.d.ts","sourceRoot":"","sources":["../../src/authorization-attributes-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAO,aAAa,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AAEtF,OAAO,EAAoB,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACvF,OAAO,EACL,2BAA2B,EAC3B,yBAAyB,EACzB,2BAA2B,
|
|
1
|
+
{"version":3,"file":"authorization-attributes-service.d.ts","sourceRoot":"","sources":["../../src/authorization-attributes-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAO,aAAa,EAAE,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