@mondaydotcomorg/monday-authorization 2.0.1 → 2.1.0

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 (2) hide show
  1. package/README.md +41 -12
  2. package/package.json +6 -1
package/README.md CHANGED
@@ -138,57 +138,86 @@ const canActionInScopeMultipleResponse: ScopedActionResponseObject[] =
138
138
  ```
139
139
 
140
140
  ### Authorization Attributes API
141
+
141
142
  Authorization attributes have 2 options to get called: sync (http request) and async (send to SNS and consumed asynchronously).
142
- When you have to make sure the change in the attributes applied before the function return, please use the sync method, otherwise use the async
143
+ When you have to make sure the change in the attributes applied before the function return, please use the sync method, otherwise use the async
143
144
 
144
145
  #### Sync method
146
+
145
147
  Use `AuthorizationAttributesService.upsertResourceAttributesSync` to upsert multiple resource attributes in the authorization MS synchronously.
146
148
 
147
149
  ```ts
148
- import { AuthorizationAttributesService, ResourceAttributeAssignment, ResourceAttributeResponse } from '@mondaydotcomorg/monday-authorization';
150
+ import {
151
+ AuthorizationAttributesService,
152
+ ResourceAttributeAssignment,
153
+ ResourceAttributeResponse,
154
+ } from '@mondaydotcomorg/monday-authorization';
149
155
 
150
156
  const accountId = 739630;
151
157
  const userId = 4;
152
158
  const resourceAttributesAssignments: ResourceAttributeAssignment[] = [
153
159
  { resourceId: 18, resourceType: 'workspace', key: 'is_default_workspace', value: 'true' },
154
- { resourceId: 23, resourceType: 'board', key: 'board_kind', value: 'private' }
160
+ { resourceId: 23, resourceType: 'board', key: 'board_kind', value: 'private' },
155
161
  ];
156
162
 
157
- const response: ResourceAttributeResponse = await AuthorizationAttributesService.upsertResourceAttributesSync(accountId, userId, resourceAttributesAssignments);
163
+ const response: ResourceAttributeResponse = await AuthorizationAttributesService.upsertResourceAttributesSync(
164
+ accountId,
165
+ userId,
166
+ resourceAttributesAssignments
167
+ );
158
168
  ```
159
169
 
160
170
  Use `AuthorizationAttributesService.deleteResourceAttributesSync` to delete single resource's attributes in the authorization MS synchronously.
161
171
 
162
-
163
172
  ```ts
164
- import { AuthorizationAttributesService, ResourceAttributeResponse, Resource } from '@mondaydotcomorg/monday-authorization';
173
+ import {
174
+ AuthorizationAttributesService,
175
+ ResourceAttributeResponse,
176
+ Resource,
177
+ } from '@mondaydotcomorg/monday-authorization';
165
178
 
166
179
  const accountId = 739630;
167
180
  const userId = 4;
168
181
  const resource: Resource = { type: 'workspace', id: 18 };
169
182
  const attributeKeys: string[] = ['is_default_workspace', 'workspace_kind'];
170
183
 
171
- const response: ResourceAttributeResponse = await AuthorizationAttributesService.deleteResourceAttributesSync(accountId, userId, resource, attributeKeys);
184
+ const response: ResourceAttributeResponse = await AuthorizationAttributesService.deleteResourceAttributesSync(
185
+ accountId,
186
+ userId,
187
+ resource,
188
+ attributeKeys
189
+ );
172
190
  ```
173
191
 
174
192
  #### Async method
193
+
175
194
  use `AuthorizationAttributesService.updateResourceAttributesAsync` to upsert or delete multiple resource attributes at once.
176
195
 
177
196
  ```ts
178
- import { AuthorizationAttributesService, ResourceAttributeAssignment, ResourceAttributeResponse } from '@mondaydotcomorg/monday-authorization';
197
+ import {
198
+ AuthorizationAttributesService,
199
+ ResourceAttributeAssignment,
200
+ ResourceAttributeResponse,
201
+ } from '@mondaydotcomorg/monday-authorization';
179
202
 
180
203
  const accountId = 739630;
181
- const appName = process.env.APP_NAME;
182
- const callerActionIdentifier = "actions_v2";
204
+ const appName = process.env.APP_NAME;
205
+ const callerActionIdentifier = 'actions_v2';
183
206
  const resourceAttributeOperations: ResourceAttributesOperation[] = [
184
207
  { operationType: 'upsert', resourceId: 18, resourceType: 'workspace', key: 'is_default_workspace', value: 'true' },
185
- { operationType: 'delete', resourceId: 23, resourceType: 'board', key: 'board_kind' }
208
+ { operationType: 'delete', resourceId: 23, resourceType: 'board', key: 'board_kind' },
186
209
  ];
187
210
 
188
- const response: ResourceAttributeResponse = await AuthorizationAttributesService.updateResourceAttributesAsync(accountId, appName, callerActionIdentifier, resourceAttributeOperations);
211
+ const response: ResourceAttributeResponse = await AuthorizationAttributesService.updateResourceAttributesAsync(
212
+ accountId,
213
+ appName,
214
+ callerActionIdentifier,
215
+ resourceAttributeOperations
216
+ );
189
217
  ```
190
218
 
191
219
  Special notes for asynchronous operations:
220
+
192
221
  1. There is no guarantee about the order of the updates, so don't do multiple operations on the same key in the same resource.
193
222
  2. To update an existing key, just use upsert operation, it'll override previous value.
194
223
  3. Requests with a lot of operations might split to chunks that will be consumed either sequence or in parallel, so there might be a timeframe where some of the operations already applied and some not. Eventually all of them will be applied.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mondaydotcomorg/monday-authorization",
3
- "version": "2.0.1",
3
+ "version": "2.1.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "license": "BSD-3-Clause",
@@ -55,5 +55,10 @@
55
55
  "build": {
56
56
  "esmMjsRename": true
57
57
  }
58
+ },
59
+ "repository": {
60
+ "type": "git",
61
+ "url": "https://github.com/DaPulse/authorization-domain.git",
62
+ "directory": "packages/monday-authorization"
58
63
  }
59
64
  }