@mondaydotcomorg/monday-authorization 1.2.10 → 1.2.11

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 +25 -0
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -138,7 +138,10 @@ const canActionInScopeMultipleResponse: ScopedActionResponseObject[] =
138
138
  ```
139
139
 
140
140
  ### Authorization Attributes API
141
+ 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
141
143
 
144
+ #### Sync method
142
145
  Use `AuthorizationAttributesService.upsertResourceAttributesSync` to upsert multiple resource attributes in the authorization MS synchronously.
143
146
 
144
147
  ```ts
@@ -168,3 +171,25 @@ const attributeKeys: string[] = ['is_default_workspace', 'workspace_kind'];
168
171
  const response: ResourceAttributeResponse = await AuthorizationAttributesService.deleteResourceAttributesSync(accountId, userId, resource, attributeKeys);
169
172
  ```
170
173
 
174
+ #### Async method
175
+ use `AuthorizationAttributesService.updateResourceAttributesAsync` to upsert or delete multiple resource attributes at once.
176
+
177
+ ```ts
178
+ import { AuthorizationAttributesService, ResourceAttributeAssignment, ResourceAttributeResponse } from '@mondaydotcomorg/monday-authorization';
179
+
180
+ const accountId = 739630;
181
+ const appName = process.env.APP_NAME;
182
+ const callerActionIdentifier = "actions_v2";
183
+ const resourceAttributeOperations: ResourceAttributesOperation[] = [
184
+ { operationType: 'upsert', resourceId: 18, resourceType: 'workspace', key: 'is_default_workspace', value: 'true' },
185
+ { operationType: 'delete', resourceId: 23, resourceType: 'board', key: 'board_kind' }
186
+ ];
187
+
188
+ const response: ResourceAttributeResponse = await AuthorizationAttributesService.updateResourceAttributesAsync(accountId, appName, callerActionIdentifier, resourceAttributeOperations);
189
+ ```
190
+
191
+ Special notes for asynchronous operations:
192
+ 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
+ 2. To update an existing key, just use upsert operation, it'll override previous value.
194
+ 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.
195
+ 4. If your MS depends on the access to the asynchronous operation, you can use a health check operation `asyncResourceAttributesHealthCheck` that will return false if it can't reach to SNS or can't find the required topic. Note it doesn't check write permissions so make sure your MS have permissions to write to the SNS topic.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mondaydotcomorg/monday-authorization",
3
- "version": "1.2.10",
3
+ "version": "1.2.11",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "license": "BSD-3-Clause",
@@ -56,5 +56,5 @@
56
56
  "files": [
57
57
  "dist/"
58
58
  ],
59
- "gitHead": "122b40d8b959019a580bf5f72ede54da86738abb"
59
+ "gitHead": "4db8fcacd3fe976b0e3fbc8e76d556f20f757d41"
60
60
  }