@mondaydotcomorg/monday-authorization 1.1.7-technical-reason.433 → 1.1.7-technical-reason.501

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.
@@ -22,7 +22,6 @@ export declare class AuthorizationService {
22
22
  private static fetchIsUserGrantedWithFeature;
23
23
  private static getCachedKeyName;
24
24
  static canActionInScope(accountId: number, userId: number, action: string, scope: ScopeOptions): Promise<ScopedActionPermit>;
25
- static getResponse(accountId: number, userId: number, action: string, scope: ScopeOptions): Promise<String>;
26
25
  static canActionInScopeMultiple(accountId: number, userId: number, scopedActions: ScopedAction[]): Promise<ScopedActionResponseObject[]>;
27
26
  private static isAuthorizedSingular;
28
27
  private static isAuthorizedMultiple;
@@ -115,27 +115,6 @@ class AuthorizationService {
115
115
  return scopedActionResponseObjects[0].permit;
116
116
  });
117
117
  }
118
- static getResponse(accountId, userId, action, scope) {
119
- return __awaiter(this, void 0, void 0, function* () {
120
- const scopedActions = [{ action, scope }];
121
- const internalAuthToken = (0, monday_jwt_1.signAuthorizationHeader)({ appName: INTERNAL_APP_NAME, accountId, userId });
122
- const scopedActionsPayload = scopedActions.map(scopedAction => {
123
- return Object.assign(Object.assign({}, scopedAction), { scope: (0, lodash_1.mapKeys)(scopedAction.scope, (_, key) => (0, lodash_1.snakeCase)(key)) }); // for example: { workspaceId: 1 } => { workspace_id: 1 }
124
- });
125
- const response = yield (0, monday_fetch_1.fetch)(getCanActionsInScopesUrl(), {
126
- method: 'POST',
127
- headers: { Authorization: internalAuthToken, 'Content-Type': 'application/json' },
128
- timeout: getRequestTimeout(),
129
- body: JSON.stringify({
130
- user_id: userId,
131
- scoped_actions: scopedActionsPayload,
132
- }),
133
- }, mondayFetchOptions);
134
- throwOnHttpErrorIfNeeded(response, 'canActionInScopeMultiple');
135
- const responseBody = yield response.json();
136
- return JSON.stringify(responseBody);
137
- });
138
- }
139
118
  static canActionInScopeMultiple(accountId, userId, scopedActions) {
140
119
  return __awaiter(this, void 0, void 0, function* () {
141
120
  const internalAuthToken = (0, monday_jwt_1.signAuthorizationHeader)({ appName: INTERNAL_APP_NAME, accountId, userId });
@@ -153,10 +132,12 @@ class AuthorizationService {
153
132
  }, mondayFetchOptions);
154
133
  throwOnHttpErrorIfNeeded(response, 'canActionInScopeMultiple');
155
134
  const responseBody = yield response.json();
135
+ const camelCaseKeys = (obj) => Object.fromEntries(Object.entries(obj).map(([key, value]) => [(0, lodash_1.camelCase)(key), value]));
156
136
  const scopedActionsResponseObjects = responseBody.result.map(responseObject => {
157
137
  const { scopedAction, permit } = responseObject;
158
138
  const { scope } = scopedAction;
159
- return Object.assign(Object.assign({}, responseObject), { scopedAction: Object.assign(Object.assign({}, scopedAction), { scope: (0, lodash_1.mapKeys)(scope, (_, key) => (0, lodash_1.camelCase)(key)) }), permit: Object.assign(Object.assign({}, (0, lodash_1.omit)(permit, ['technical_reason'])), { technicalReason: parseInt(permit.technical_reason) }) });
139
+ const transformKeys = (obj) => camelCaseKeys(obj);
140
+ return Object.assign(Object.assign({}, responseObject), { scopedAction: Object.assign(Object.assign({}, scopedAction), { scope: transformKeys(scope) }), permit: transformKeys(permit || {}) });
160
141
  });
161
142
  return scopedActionsResponseObjects;
162
143
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mondaydotcomorg/monday-authorization",
3
- "version": "1.1.7-technical-reason.433+e2a99ea14",
3
+ "version": "1.1.7-technical-reason.501+6e93abbf2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "license": "BSD-3-Clause",
@@ -32,5 +32,5 @@
32
32
  "files": [
33
33
  "dist/"
34
34
  ],
35
- "gitHead": "e2a99ea14b7b859a2941df577dbc1fbf50fc282e"
35
+ "gitHead": "6e93abbf293622fc3ab0576a3ee1a96defea0aa7"
36
36
  }