@lightdash/common 0.1930.2 → 0.1931.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 (70) hide show
  1. package/dist/cjs/authorization/parseScopes.d.ts +8 -0
  2. package/dist/cjs/authorization/parseScopes.d.ts.map +1 -0
  3. package/dist/cjs/authorization/parseScopes.js +27 -0
  4. package/dist/cjs/authorization/parseScopes.js.map +1 -0
  5. package/dist/cjs/authorization/parseScopes.test.d.ts +2 -0
  6. package/dist/cjs/authorization/parseScopes.test.d.ts.map +1 -0
  7. package/dist/cjs/authorization/parseScopes.test.js +109 -0
  8. package/dist/cjs/authorization/parseScopes.test.js.map +1 -0
  9. package/dist/cjs/authorization/scopeAbilityBuilder.d.ts +23 -0
  10. package/dist/cjs/authorization/scopeAbilityBuilder.d.ts.map +1 -0
  11. package/dist/cjs/authorization/scopeAbilityBuilder.js +58 -0
  12. package/dist/cjs/authorization/scopeAbilityBuilder.js.map +1 -0
  13. package/dist/cjs/authorization/scopeAbilityBuilder.test.d.ts +2 -0
  14. package/dist/cjs/authorization/scopeAbilityBuilder.test.d.ts.map +1 -0
  15. package/dist/cjs/authorization/scopeAbilityBuilder.test.js +955 -0
  16. package/dist/cjs/authorization/scopeAbilityBuilder.test.js.map +1 -0
  17. package/dist/cjs/authorization/scopes.d.ts +8 -0
  18. package/dist/cjs/authorization/scopes.d.ts.map +1 -0
  19. package/dist/cjs/authorization/scopes.js +633 -0
  20. package/dist/cjs/authorization/scopes.js.map +1 -0
  21. package/dist/cjs/types/scopes.d.ts +30 -3
  22. package/dist/cjs/types/scopes.d.ts.map +1 -1
  23. package/dist/cjs/types/scopes.js.map +1 -1
  24. package/dist/esm/authorization/parseScopes.d.ts +8 -0
  25. package/dist/esm/authorization/parseScopes.d.ts.map +1 -0
  26. package/dist/esm/authorization/parseScopes.js +22 -0
  27. package/dist/esm/authorization/parseScopes.js.map +1 -0
  28. package/dist/esm/authorization/parseScopes.test.d.ts +2 -0
  29. package/dist/esm/authorization/parseScopes.test.d.ts.map +1 -0
  30. package/dist/esm/authorization/parseScopes.test.js +107 -0
  31. package/dist/esm/authorization/parseScopes.test.js.map +1 -0
  32. package/dist/esm/authorization/scopeAbilityBuilder.d.ts +23 -0
  33. package/dist/esm/authorization/scopeAbilityBuilder.d.ts.map +1 -0
  34. package/dist/esm/authorization/scopeAbilityBuilder.js +54 -0
  35. package/dist/esm/authorization/scopeAbilityBuilder.js.map +1 -0
  36. package/dist/esm/authorization/scopeAbilityBuilder.test.d.ts +2 -0
  37. package/dist/esm/authorization/scopeAbilityBuilder.test.d.ts.map +1 -0
  38. package/dist/esm/authorization/scopeAbilityBuilder.test.js +953 -0
  39. package/dist/esm/authorization/scopeAbilityBuilder.test.js.map +1 -0
  40. package/dist/esm/authorization/scopes.d.ts +8 -0
  41. package/dist/esm/authorization/scopes.d.ts.map +1 -0
  42. package/dist/esm/authorization/scopes.js +628 -0
  43. package/dist/esm/authorization/scopes.js.map +1 -0
  44. package/dist/esm/types/scopes.d.ts +30 -3
  45. package/dist/esm/types/scopes.d.ts.map +1 -1
  46. package/dist/esm/types/scopes.js.map +1 -1
  47. package/dist/tsconfig.types.tsbuildinfo +1 -1
  48. package/dist/types/authorization/parseScopes.d.ts +8 -0
  49. package/dist/types/authorization/parseScopes.d.ts.map +1 -0
  50. package/dist/types/authorization/parseScopes.test.d.ts +2 -0
  51. package/dist/types/authorization/parseScopes.test.d.ts.map +1 -0
  52. package/dist/types/authorization/scopeAbilityBuilder.d.ts +23 -0
  53. package/dist/types/authorization/scopeAbilityBuilder.d.ts.map +1 -0
  54. package/dist/types/authorization/scopeAbilityBuilder.test.d.ts +2 -0
  55. package/dist/types/authorization/scopeAbilityBuilder.test.d.ts.map +1 -0
  56. package/dist/types/authorization/scopes.d.ts +8 -0
  57. package/dist/types/authorization/scopes.d.ts.map +1 -0
  58. package/dist/types/types/scopes.d.ts +30 -3
  59. package/dist/types/types/scopes.d.ts.map +1 -1
  60. package/package.json +1 -1
  61. package/dist/cjs/authorization/scopes/index.d.ts +0 -5
  62. package/dist/cjs/authorization/scopes/index.d.ts.map +0 -1
  63. package/dist/cjs/authorization/scopes/index.js +0 -372
  64. package/dist/cjs/authorization/scopes/index.js.map +0 -1
  65. package/dist/esm/authorization/scopes/index.d.ts +0 -5
  66. package/dist/esm/authorization/scopes/index.d.ts.map +0 -1
  67. package/dist/esm/authorization/scopes/index.js +0 -368
  68. package/dist/esm/authorization/scopes/index.js.map +0 -1
  69. package/dist/types/authorization/scopes/index.d.ts +0 -5
  70. package/dist/types/authorization/scopes/index.d.ts.map +0 -1
@@ -1,4 +1,3 @@
1
- import { type SnakeCase } from 'type-fest';
2
1
  import { type AbilityAction, type CaslSubjectNames } from '../authorization/types';
3
2
  /**
4
3
  * Scope groups to organize permissions in the UI for admins.
@@ -12,14 +11,38 @@ export declare enum ScopeGroup {
12
11
  AI = "ai",
13
12
  SPOTLIGHT = "spotlight"
14
13
  }
14
+ /**
15
+ * Context given to scope getCondition functions
16
+ */
17
+ export type ScopeContext = {
18
+ organizationUuid: string;
19
+ projectUuid: string;
20
+ userUuid?: string;
21
+ /** The scopes available to the current user */
22
+ scopes: Set<ScopeName>;
23
+ isEnterprise: boolean;
24
+ /** The user's role name in the organization (for dynamic permission logic) */
25
+ organizationRole: string;
26
+ /** Configuration for dynamic permissions like PAT */
27
+ permissionsConfig?: {
28
+ pat: {
29
+ enabled: boolean;
30
+ allowedOrgRoles: string[];
31
+ };
32
+ };
33
+ };
34
+ /**
35
+ * The name of the scope, based on ability and subject (e.g. "create:project")
36
+ */
37
+ export type ScopeName = `${AbilityAction}:${CaslSubjectNames}`;
15
38
  /**
16
39
  * A scope defines a specific permission in the system
17
40
  */
18
41
  export type Scope = {
19
42
  /**
20
- * The name of the scope, based on ability and subject (e.g. "create:project")
43
+ * The name of the scope, based on ability and subject (e.g. "create:Project")
21
44
  */
22
- name: Lowercase<`${AbilityAction}:${SnakeCase<CaslSubjectNames>}`>;
45
+ name: ScopeName;
23
46
  /**
24
47
  * A helpful description of the permission
25
48
  */
@@ -32,5 +55,9 @@ export type Scope = {
32
55
  * The grouping from the ScopeGroup enum
33
56
  */
34
57
  group: ScopeGroup;
58
+ /**
59
+ * Get the conditions to be applied to the CASL ability derived from the scope
60
+ */
61
+ getConditions?: (context: ScopeContext) => Record<string, unknown>[];
35
62
  };
36
63
  //# sourceMappingURL=scopes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"scopes.d.ts","sourceRoot":"","sources":["../../../src/types/scopes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EACH,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACxB,MAAM,wBAAwB,CAAC;AAEhC;;GAEG;AACH,oBAAY,UAAU;IAClB,OAAO,YAAY;IACnB,kBAAkB,uBAAuB;IACzC,uBAAuB,4BAA4B;IACnD,IAAI,SAAS;IACb,OAAO,YAAY;IACnB,EAAE,OAAO;IACT,SAAS,cAAc;CAC1B;AAED;;GAEG;AACH,MAAM,MAAM,KAAK,GAAG;IAChB;;OAEG;IACH,IAAI,EAAE,SAAS,CAAC,GAAG,aAAa,IAAI,SAAS,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;IACnE;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,YAAY,EAAE,OAAO,CAAC;IACtB;;OAEG;IACH,KAAK,EAAE,UAAU,CAAC;CACrB,CAAC"}
1
+ {"version":3,"file":"scopes.d.ts","sourceRoot":"","sources":["../../../src/types/scopes.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACxB,MAAM,wBAAwB,CAAC;AAEhC;;GAEG;AACH,oBAAY,UAAU;IAClB,OAAO,YAAY;IACnB,kBAAkB,uBAAuB;IACzC,uBAAuB,4BAA4B;IACnD,IAAI,SAAS;IACb,OAAO,YAAY;IACnB,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"version":3,"file":"scopes.js","sourceRoot":"","sources":["../../../src/types/scopes.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,MAAM,CAAN,IAAY,UAQX;AARD,WAAY,UAAU;IAClB,iCAAmB,CAAA;IACnB,uDAAyC,CAAA;IACzC,iEAAmD,CAAA;IACnD,2BAAa,CAAA;IACb,iCAAmB,CAAA;IACnB,uBAAS,CAAA;IACT,qCAAuB,CAAA;AAC3B,CAAC,EARW,UAAU,KAAV,UAAU,QAQrB"}