@mondaydotcomorg/monday-authorization 3.3.0-feature-bashanye-navigate-can-action-in-scope-to-graph-2992133 → 3.3.0-feature-bashanye-navigate-can-action-in-scope-to-graph-36f311f

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 (37) hide show
  1. package/dist/authorization-service.d.ts.map +1 -1
  2. package/dist/authorization-service.js +7 -0
  3. package/dist/clients/graph-api.client.d.ts.map +1 -1
  4. package/dist/clients/graph-api.client.js +37 -2
  5. package/dist/clients/platform-api.client.d.ts.map +1 -1
  6. package/dist/esm/authorization-service.d.ts.map +1 -1
  7. package/dist/esm/authorization-service.mjs +7 -0
  8. package/dist/esm/clients/graph-api.client.d.ts.map +1 -1
  9. package/dist/esm/clients/graph-api.client.mjs +37 -2
  10. package/dist/esm/clients/platform-api.client.d.ts.map +1 -1
  11. package/dist/esm/types/graph-api.types.d.ts +9 -1
  12. package/dist/esm/types/graph-api.types.d.ts.map +1 -1
  13. package/dist/esm/utils/authorization.utils.d.ts.map +1 -1
  14. package/dist/types/graph-api.types.d.ts +9 -1
  15. package/dist/types/graph-api.types.d.ts.map +1 -1
  16. package/dist/utils/authorization.utils.d.ts.map +1 -1
  17. package/package.json +2 -3
  18. package/src/attributions-service.ts +0 -92
  19. package/src/authorization-attributes-service.ts +0 -234
  20. package/src/authorization-internal-service.ts +0 -129
  21. package/src/authorization-middleware.ts +0 -51
  22. package/src/authorization-service.ts +0 -357
  23. package/src/clients/graph-api.client.ts +0 -134
  24. package/src/clients/platform-api.client.ts +0 -118
  25. package/src/constants/sns.ts +0 -5
  26. package/src/constants.ts +0 -22
  27. package/src/index.ts +0 -46
  28. package/src/prometheus-service.ts +0 -147
  29. package/src/roles-service.ts +0 -125
  30. package/src/testKit/index.ts +0 -69
  31. package/src/types/authorization-attributes-contracts.ts +0 -33
  32. package/src/types/express.ts +0 -8
  33. package/src/types/general.ts +0 -32
  34. package/src/types/graph-api.types.ts +0 -19
  35. package/src/types/roles.ts +0 -42
  36. package/src/types/scoped-actions-contracts.ts +0 -48
  37. package/src/utils/authorization.utils.ts +0 -48
@@ -1,48 +0,0 @@
1
- export interface WorkspaceScope {
2
- workspaceId: number;
3
- }
4
-
5
- export interface BoardScope {
6
- boardId: number;
7
- }
8
-
9
- export interface PulseScope {
10
- pulseId: number;
11
- }
12
-
13
- export interface AccountProductScope {
14
- accountProductId: number;
15
- }
16
-
17
- export interface AccountScope {
18
- accountId: number;
19
- }
20
-
21
- export type ScopeOptions = WorkspaceScope | BoardScope | PulseScope | AccountProductScope | AccountScope;
22
-
23
- export interface Translation {
24
- key: string;
25
- [option: string]: string;
26
- }
27
-
28
- export enum PermitTechnicalReason {
29
- NO_REASON = 0,
30
- NOT_ELIGIBLE = 1,
31
- BY_ROLE_IN_SCOPE = 2,
32
- }
33
-
34
- export interface ScopedActionPermit {
35
- can: boolean;
36
- reason: Translation;
37
- technicalReason: PermitTechnicalReason;
38
- }
39
-
40
- export interface ScopedAction {
41
- action: string;
42
- scope: ScopeOptions;
43
- }
44
-
45
- export interface ScopedActionResponseObject {
46
- scopedAction: ScopedAction;
47
- permit: ScopedActionPermit;
48
- }
@@ -1,48 +0,0 @@
1
- import snakeCase from 'lodash/snakeCase.js';
2
- import camelCase from 'lodash/camelCase.js';
3
- import mapKeys from 'lodash/mapKeys.js';
4
- import { ScopeOptions } from '../types/scoped-actions-contracts';
5
- import { ResourceType, ResourceId } from '../types/graph-api.types';
6
-
7
- export type CamelCase<S extends string> = S extends `${infer F}_${infer R}` ? `${F}${Capitalize<CamelCase<R>>}` : S;
8
- export type CamelCaseKeys<T> = T extends object
9
- ? { [K in keyof T as K extends string ? CamelCase<K> : K]: CamelCaseKeys<T[K]> }
10
- : T;
11
-
12
- /**
13
- * Converts a scope object to resource type and resource ID
14
- */
15
- export function scopeToResource(scope: ScopeOptions): { resourceType: ResourceType; resourceId: ResourceId } {
16
-
17
- if ('workspaceId' in scope) {
18
- return { resourceType: 'workspace', resourceId: scope.workspaceId };
19
- }
20
- if ('boardId' in scope) {
21
- return { resourceType: 'board', resourceId: scope.boardId };
22
- }
23
- if ('pulseId' in scope) {
24
- return { resourceType: 'pulse', resourceId: scope.pulseId };
25
- }
26
- if ('accountProductId' in scope) {
27
- return { resourceType: 'account_product', resourceId: scope.accountProductId };
28
- }
29
- if ('accountId' in scope) {
30
- return { resourceType: 'account', resourceId: scope.accountId };
31
- }
32
-
33
- throw new Error('Unsupported scope provided');
34
- }
35
-
36
- /**
37
- * Converts object keys from snake_case to camelCase
38
- */
39
- export function toCamelCase<T extends object>(obj: T): CamelCaseKeys<T> {
40
- return mapKeys(obj, (_, key) => camelCase(key)) as CamelCaseKeys<T>;
41
- }
42
-
43
- /**
44
- * Converts object keys from camelCase to snake_case
45
- */
46
- export function toSnakeCase<T extends object>(obj: T): Record<string, any> {
47
- return mapKeys(obj, (_, key) => snakeCase(key));
48
- }