forked from clerk/javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorganizationMembership.ts
More file actions
91 lines (79 loc) · 2.95 KB
/
Copy pathorganizationMembership.ts
File metadata and controls
91 lines (79 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import type { OrganizationMembershipJSONSnapshot } from 'snapshots';
import type { OrganizationResource } from './organization';
import type { ClerkResource } from './resource';
import type { PublicUserData } from './session';
import type { Autocomplete } from './utils';
interface Base {
permission: string;
role: string;
}
interface Placeholder {
permission: unknown;
role: unknown;
}
declare global {
interface ClerkAuthorization {}
}
declare global {
/**
* If you want to provide custom types for the organizationMembership.publicMetadata
* object, simply redeclare this rule in the global namespace.
* Every organizationMembership object will use the provided type.
*/
interface OrganizationMembershipPublicMetadata {
[k: string]: unknown;
}
/**
* If you want to provide custom types for the organizationMembership.publicMetadata
* object, simply redeclare this rule in the global namespace.
* Every organizationMembership object will use the provided type.
*/
interface OrganizationMembershipPrivateMetadata {
[k: string]: unknown;
}
}
export interface OrganizationMembershipResource extends ClerkResource {
id: string;
organization: OrganizationResource;
permissions: OrganizationPermissionKey[];
publicMetadata: OrganizationMembershipPublicMetadata;
publicUserData: PublicUserData;
role: OrganizationCustomRoleKey;
createdAt: Date;
updatedAt: Date;
destroy: () => Promise<OrganizationMembershipResource>;
update: (updateParams: UpdateOrganizationMembershipParams) => Promise<OrganizationMembershipResource>;
__internal_toSnapshot: () => OrganizationMembershipJSONSnapshot;
}
export type OrganizationCustomPermissionKey = ClerkAuthorization extends Placeholder
? ClerkAuthorization['permission'] extends string
? ClerkAuthorization['permission']
: Base['permission']
: Base['permission'];
/**
* OrganizationCustomRoleKey will be string unless the developer has provided their own types through `ClerkAuthorization`
*/
export type OrganizationCustomRoleKey = ClerkAuthorization extends Placeholder
? ClerkAuthorization['role'] extends string
? ClerkAuthorization['role']
: Base['role']
: Base['role'];
export type OrganizationSystemPermissionKey =
| 'org:sys_domains:manage'
| 'org:sys_profile:manage'
| 'org:sys_profile:delete'
| 'org:sys_memberships:read'
| 'org:sys_memberships:manage'
| 'org:sys_domains:read';
/**
* OrganizationPermissionKey is a combination of system and custom permissions.
* System permissions are only accessible from FAPI and client-side operations/utils
*/
export type OrganizationPermissionKey = ClerkAuthorization extends Placeholder
? ClerkAuthorization['permission'] extends string
? ClerkAuthorization['permission'] | OrganizationSystemPermissionKey
: Autocomplete<OrganizationSystemPermissionKey>
: Autocomplete<OrganizationSystemPermissionKey>;
export type UpdateOrganizationMembershipParams = {
role: OrganizationCustomRoleKey;
};