@shuffl/api-contracts 0.3.0 → 0.5.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.
- package/dist/base.d.ts +5 -3
- package/dist/base.js +8 -4
- package/dist/company.d.ts +235 -0
- package/dist/company.js +177 -0
- package/dist/index.d.ts +7527 -3354
- package/dist/index.js +23 -3
- package/dist/management-operations.d.ts +1 -1
- package/dist/management-operations.js +497 -79
- package/dist/management.generated.d.ts +6071 -2091
- package/dist/management.generated.js +4808 -753
- package/dist/permissions.d.ts +179 -57
- package/dist/permissions.js +23 -18
- package/dist/schemas.d.ts +7 -0
- package/dist/schemas.js +20 -3
- package/dist/webhooks.d.ts +373 -0
- package/dist/webhooks.js +429 -0
- package/openapi.json +99305 -54947
- package/package.json +13 -1
package/dist/base.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export declare const scopes: readonly ['users:read', 'programs:read', 'programs:write', 'runs:write', 'runs:read', 'knowledge:read', 'manager:read', 'users:write', 'participation:write', 'profile:write', 'access:read', 'access:write', 'identities:read', 'identities:write', 'knowledge:manage', 'knowledge:write', 'integrations:read', 'integrations:write', 'hr:read', 'hr:write', 'support:read', 'support:write', 'operations:read', 'operations:write', 'operator:read', 'operator:write', 'reports:read', 'team:read', 'team:write', 'credentials:read', 'credentials:write', 'exports:read', 'assistant:read', 'assistant:write', '
|
|
2
|
+
export declare const scopes: readonly ['users:read', 'programs:read', 'programs:write', 'runs:write', 'runs:read', 'knowledge:read', 'manager:read', 'users:write', 'participation:write', 'profile:write', 'access:read', 'access:write', 'identities:read', 'identities:write', 'knowledge:manage', 'knowledge:write', 'integrations:read', 'integrations:write', 'hr:read', 'hr:write', 'support:read', 'support:write', 'operations:read', 'operations:write', 'operator:read', 'operator:write', 'reports:read', 'team:read', 'team:write', 'credentials:read', 'credentials:write', 'exports:read', 'assistant:read', 'assistant:write', 'playbooks:read', 'playbooks:write', 'celebrations:read', 'celebrations:write', 'self:read', 'self:write', 'pulse:read', 'pulse:write', 'praise:read', 'praise:write', 'webhooks:read', 'webhooks:write'];
|
|
3
3
|
export declare const scopeSchema: z.ZodEnum<{
|
|
4
4
|
"access:read": "access:read";
|
|
5
5
|
"access:write": "access:write";
|
|
@@ -20,13 +20,13 @@ export declare const scopeSchema: z.ZodEnum<{
|
|
|
20
20
|
"knowledge:read": "knowledge:read";
|
|
21
21
|
"knowledge:write": "knowledge:write";
|
|
22
22
|
"manager:read": "manager:read";
|
|
23
|
-
"onboarding:read": "onboarding:read";
|
|
24
|
-
"onboarding:write": "onboarding:write";
|
|
25
23
|
"operations:read": "operations:read";
|
|
26
24
|
"operations:write": "operations:write";
|
|
27
25
|
"operator:read": "operator:read";
|
|
28
26
|
"operator:write": "operator:write";
|
|
29
27
|
"participation:write": "participation:write";
|
|
28
|
+
"playbooks:read": "playbooks:read";
|
|
29
|
+
"playbooks:write": "playbooks:write";
|
|
30
30
|
"praise:read": "praise:read";
|
|
31
31
|
"praise:write": "praise:write";
|
|
32
32
|
"profile:write": "profile:write";
|
|
@@ -45,6 +45,8 @@ export declare const scopeSchema: z.ZodEnum<{
|
|
|
45
45
|
"team:write": "team:write";
|
|
46
46
|
"users:read": "users:read";
|
|
47
47
|
"users:write": "users:write";
|
|
48
|
+
"webhooks:read": "webhooks:read";
|
|
49
|
+
"webhooks:write": "webhooks:write";
|
|
48
50
|
}>;
|
|
49
51
|
export type Scope = z.infer<typeof scopeSchema>;
|
|
50
52
|
export declare const base: import("@orpc/contract").ContractBuilder<import("@orpc/contract").Schema<unknown, unknown>, import("@orpc/contract").Schema<unknown, unknown>, import("@orpc/contract").MergedErrorMap<Record<never, never>, {
|
package/dist/base.js
CHANGED
|
@@ -35,8 +35,8 @@ export const scopes = [
|
|
|
35
35
|
'exports:read',
|
|
36
36
|
'assistant:read',
|
|
37
37
|
'assistant:write',
|
|
38
|
-
'
|
|
39
|
-
'
|
|
38
|
+
'playbooks:read',
|
|
39
|
+
'playbooks:write',
|
|
40
40
|
'celebrations:read',
|
|
41
41
|
'celebrations:write',
|
|
42
42
|
'self:read',
|
|
@@ -45,6 +45,8 @@ export const scopes = [
|
|
|
45
45
|
'pulse:write',
|
|
46
46
|
'praise:read',
|
|
47
47
|
'praise:write',
|
|
48
|
+
'webhooks:read',
|
|
49
|
+
'webhooks:write',
|
|
48
50
|
];
|
|
49
51
|
export const scopeSchema = z.enum(scopes);
|
|
50
52
|
export const base = oc.$meta({ scope: null }).errors({
|
|
@@ -77,12 +79,14 @@ export const adminScopes = [
|
|
|
77
79
|
'team:write',
|
|
78
80
|
'team:read',
|
|
79
81
|
'exports:read',
|
|
80
|
-
'
|
|
81
|
-
'
|
|
82
|
+
'playbooks:read',
|
|
83
|
+
'playbooks:write',
|
|
82
84
|
'celebrations:read',
|
|
83
85
|
'celebrations:write',
|
|
84
86
|
'pulse:read',
|
|
85
87
|
'pulse:write',
|
|
86
88
|
'praise:read',
|
|
87
89
|
'praise:write',
|
|
90
|
+
'webhooks:read',
|
|
91
|
+
'webhooks:write',
|
|
88
92
|
];
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const companyPermissionCatalog: readonly [{
|
|
3
|
+
readonly access: 'read';
|
|
4
|
+
readonly description: 'Read the company name, logo and default workspace';
|
|
5
|
+
readonly id: 'company.details';
|
|
6
|
+
}, {
|
|
7
|
+
readonly access: 'read';
|
|
8
|
+
readonly description: "List the company's workspaces";
|
|
9
|
+
readonly id: 'company.workspaces.list';
|
|
10
|
+
}, {
|
|
11
|
+
readonly access: 'read';
|
|
12
|
+
readonly description: 'List company members and their company roles';
|
|
13
|
+
readonly id: 'company.members.list';
|
|
14
|
+
}, {
|
|
15
|
+
readonly access: 'read';
|
|
16
|
+
readonly description: "List the company's email domains and their verification";
|
|
17
|
+
readonly id: 'company.emailDomains.list';
|
|
18
|
+
}, {
|
|
19
|
+
readonly access: 'read';
|
|
20
|
+
readonly description: 'List the Slack workspaces connected to the company';
|
|
21
|
+
readonly id: 'company.slack.list';
|
|
22
|
+
}, {
|
|
23
|
+
readonly access: 'write';
|
|
24
|
+
readonly description: 'Rename the company';
|
|
25
|
+
readonly id: 'company.rename';
|
|
26
|
+
}, {
|
|
27
|
+
readonly access: 'write';
|
|
28
|
+
readonly description: 'Choose the workspace new email domain and single sign-on members join';
|
|
29
|
+
readonly id: 'company.workspaces.setDefault';
|
|
30
|
+
}, {
|
|
31
|
+
readonly access: 'write';
|
|
32
|
+
readonly description: 'Remove someone from the company (administrators only with an owner’s key)';
|
|
33
|
+
readonly id: 'company.members.remove';
|
|
34
|
+
}];
|
|
35
|
+
export type CompanyPermission = (typeof companyPermissionCatalog)[number]['id'];
|
|
36
|
+
export type CompanyPermissionDefinition = (typeof companyPermissionCatalog)[number];
|
|
37
|
+
export declare const companyPermissionIds: [CompanyPermission, ...CompanyPermission[]];
|
|
38
|
+
export declare const companyIndexOperation = "company.current";
|
|
39
|
+
export declare const companyKeyPrefix = "shuffl_company_";
|
|
40
|
+
export declare const companyCursorSchema: z.ZodString;
|
|
41
|
+
export declare const companyDetailsSchema: z.ZodObject<{
|
|
42
|
+
defaultTeamId: z.ZodNullable<z.ZodString>;
|
|
43
|
+
deleteAfter: z.ZodNullable<z.ZodISODateTime>;
|
|
44
|
+
deletionRequestedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
45
|
+
id: z.ZodString;
|
|
46
|
+
logo: z.ZodNullable<z.ZodString>;
|
|
47
|
+
name: z.ZodString;
|
|
48
|
+
role: z.ZodEnum<{
|
|
49
|
+
admin: "admin";
|
|
50
|
+
member: "member";
|
|
51
|
+
owner: "owner";
|
|
52
|
+
}>;
|
|
53
|
+
}, z.core.$strip>;
|
|
54
|
+
export declare const companyWorkspaceSchema: z.ZodObject<{
|
|
55
|
+
accessible: z.ZodBoolean;
|
|
56
|
+
default: z.ZodBoolean;
|
|
57
|
+
id: z.ZodString;
|
|
58
|
+
logo: z.ZodNullable<z.ZodString>;
|
|
59
|
+
member: z.ZodBoolean;
|
|
60
|
+
name: z.ZodString;
|
|
61
|
+
status: z.ZodNullable<z.ZodEnum<{
|
|
62
|
+
active: "active";
|
|
63
|
+
archived: "archived";
|
|
64
|
+
paused: "paused";
|
|
65
|
+
uninstalled: "uninstalled";
|
|
66
|
+
}>>;
|
|
67
|
+
}, z.core.$strip>;
|
|
68
|
+
export declare const companyMemberSchema: z.ZodObject<{
|
|
69
|
+
email: z.ZodString;
|
|
70
|
+
id: z.ZodString;
|
|
71
|
+
name: z.ZodString;
|
|
72
|
+
role: z.ZodEnum<{
|
|
73
|
+
admin: "admin";
|
|
74
|
+
member: "member";
|
|
75
|
+
owner: "owner";
|
|
76
|
+
}>;
|
|
77
|
+
userId: z.ZodString;
|
|
78
|
+
}, z.core.$strip>;
|
|
79
|
+
export declare const companyEmailDomainSchema: z.ZodObject<{
|
|
80
|
+
dnsRecord: z.ZodNullable<z.ZodObject<{
|
|
81
|
+
name: z.ZodString;
|
|
82
|
+
value: z.ZodString;
|
|
83
|
+
}, z.core.$strip>>;
|
|
84
|
+
domain: z.ZodString;
|
|
85
|
+
id: z.ZodString;
|
|
86
|
+
verifiedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
87
|
+
}, z.core.$strip>;
|
|
88
|
+
export declare const companySlackSchema: z.ZodObject<{
|
|
89
|
+
installation: z.ZodNullable<z.ZodObject<{
|
|
90
|
+
enterpriseId: z.ZodNullable<z.ZodString>;
|
|
91
|
+
gridOrganizationId: z.ZodNullable<z.ZodString>;
|
|
92
|
+
revokedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
93
|
+
slackTeamId: z.ZodString;
|
|
94
|
+
}, z.core.$strip>>;
|
|
95
|
+
teamId: z.ZodString;
|
|
96
|
+
teamName: z.ZodString;
|
|
97
|
+
}, z.core.$strip>;
|
|
98
|
+
export declare const companyContract: {
|
|
99
|
+
current: import("@orpc/contract").ContractProcedureBuilderWithOutput<import("@orpc/contract").Schema<unknown, unknown>, z.ZodObject<{
|
|
100
|
+
catalog: z.ZodArray<z.ZodObject<{
|
|
101
|
+
access: z.ZodEnum<{
|
|
102
|
+
read: "read";
|
|
103
|
+
write: "write";
|
|
104
|
+
}>;
|
|
105
|
+
description: z.ZodString;
|
|
106
|
+
granted: z.ZodBoolean;
|
|
107
|
+
id: z.ZodEnum<{
|
|
108
|
+
"company.details": "company.details";
|
|
109
|
+
"company.emailDomains.list": "company.emailDomains.list";
|
|
110
|
+
"company.members.list": "company.members.list";
|
|
111
|
+
"company.members.remove": "company.members.remove";
|
|
112
|
+
"company.rename": "company.rename";
|
|
113
|
+
"company.slack.list": "company.slack.list";
|
|
114
|
+
"company.workspaces.list": "company.workspaces.list";
|
|
115
|
+
"company.workspaces.setDefault": "company.workspaces.setDefault";
|
|
116
|
+
}>;
|
|
117
|
+
}, z.core.$strip>>;
|
|
118
|
+
organizationId: z.ZodString;
|
|
119
|
+
permissions: z.ZodArray<z.ZodEnum<{
|
|
120
|
+
"company.details": "company.details";
|
|
121
|
+
"company.emailDomains.list": "company.emailDomains.list";
|
|
122
|
+
"company.members.list": "company.members.list";
|
|
123
|
+
"company.members.remove": "company.members.remove";
|
|
124
|
+
"company.rename": "company.rename";
|
|
125
|
+
"company.slack.list": "company.slack.list";
|
|
126
|
+
"company.workspaces.list": "company.workspaces.list";
|
|
127
|
+
"company.workspaces.setDefault": "company.workspaces.setDefault";
|
|
128
|
+
}>>;
|
|
129
|
+
}, z.core.$strip>, Record<never, never>, {
|
|
130
|
+
permission: CompanyPermission | null;
|
|
131
|
+
} & Record<never, never>>;
|
|
132
|
+
details: import("@orpc/contract").ContractProcedureBuilderWithOutput<import("@orpc/contract").Schema<unknown, unknown>, z.ZodObject<{
|
|
133
|
+
defaultTeamId: z.ZodNullable<z.ZodString>;
|
|
134
|
+
deleteAfter: z.ZodNullable<z.ZodISODateTime>;
|
|
135
|
+
deletionRequestedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
136
|
+
id: z.ZodString;
|
|
137
|
+
logo: z.ZodNullable<z.ZodString>;
|
|
138
|
+
name: z.ZodString;
|
|
139
|
+
role: z.ZodEnum<{
|
|
140
|
+
admin: "admin";
|
|
141
|
+
member: "member";
|
|
142
|
+
owner: "owner";
|
|
143
|
+
}>;
|
|
144
|
+
}, z.core.$strip>, Record<never, never>, {
|
|
145
|
+
permission: CompanyPermission | null;
|
|
146
|
+
} & Record<never, never>>;
|
|
147
|
+
emailDomains: {
|
|
148
|
+
list: import("@orpc/contract").ContractProcedureBuilderWithOutput<import("@orpc/contract").Schema<unknown, unknown>, z.ZodArray<z.ZodObject<{
|
|
149
|
+
dnsRecord: z.ZodNullable<z.ZodObject<{
|
|
150
|
+
name: z.ZodString;
|
|
151
|
+
value: z.ZodString;
|
|
152
|
+
}, z.core.$strip>>;
|
|
153
|
+
domain: z.ZodString;
|
|
154
|
+
id: z.ZodString;
|
|
155
|
+
verifiedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
156
|
+
}, z.core.$strip>>, Record<never, never>, {
|
|
157
|
+
permission: CompanyPermission | null;
|
|
158
|
+
} & Record<never, never>>;
|
|
159
|
+
};
|
|
160
|
+
members: {
|
|
161
|
+
list: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
|
|
162
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
163
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
164
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
165
|
+
items: z.ZodArray<z.ZodObject<{
|
|
166
|
+
email: z.ZodString;
|
|
167
|
+
id: z.ZodString;
|
|
168
|
+
name: z.ZodString;
|
|
169
|
+
role: z.ZodEnum<{
|
|
170
|
+
admin: "admin";
|
|
171
|
+
member: "member";
|
|
172
|
+
owner: "owner";
|
|
173
|
+
}>;
|
|
174
|
+
userId: z.ZodString;
|
|
175
|
+
}, z.core.$strip>>;
|
|
176
|
+
nextCursor: z.ZodNullable<z.ZodString>;
|
|
177
|
+
}, z.core.$strip>, Record<never, never>, {
|
|
178
|
+
permission: CompanyPermission | null;
|
|
179
|
+
} & Record<never, never>>;
|
|
180
|
+
remove: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
|
|
181
|
+
userId: z.ZodString;
|
|
182
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
183
|
+
removed: z.ZodBoolean;
|
|
184
|
+
}, z.core.$strip>, Record<never, never>, {
|
|
185
|
+
permission: CompanyPermission | null;
|
|
186
|
+
} & Record<never, never>>;
|
|
187
|
+
};
|
|
188
|
+
rename: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
|
|
189
|
+
name: z.ZodString;
|
|
190
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
191
|
+
name: z.ZodString;
|
|
192
|
+
}, z.core.$strip>, Record<never, never>, {
|
|
193
|
+
permission: CompanyPermission | null;
|
|
194
|
+
} & Record<never, never>>;
|
|
195
|
+
slack: {
|
|
196
|
+
list: import("@orpc/contract").ContractProcedureBuilderWithOutput<import("@orpc/contract").Schema<unknown, unknown>, z.ZodArray<z.ZodObject<{
|
|
197
|
+
installation: z.ZodNullable<z.ZodObject<{
|
|
198
|
+
enterpriseId: z.ZodNullable<z.ZodString>;
|
|
199
|
+
gridOrganizationId: z.ZodNullable<z.ZodString>;
|
|
200
|
+
revokedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
201
|
+
slackTeamId: z.ZodString;
|
|
202
|
+
}, z.core.$strip>>;
|
|
203
|
+
teamId: z.ZodString;
|
|
204
|
+
teamName: z.ZodString;
|
|
205
|
+
}, z.core.$strip>>, Record<never, never>, {
|
|
206
|
+
permission: CompanyPermission | null;
|
|
207
|
+
} & Record<never, never>>;
|
|
208
|
+
};
|
|
209
|
+
workspaces: {
|
|
210
|
+
list: import("@orpc/contract").ContractProcedureBuilderWithOutput<import("@orpc/contract").Schema<unknown, unknown>, z.ZodArray<z.ZodObject<{
|
|
211
|
+
accessible: z.ZodBoolean;
|
|
212
|
+
default: z.ZodBoolean;
|
|
213
|
+
id: z.ZodString;
|
|
214
|
+
logo: z.ZodNullable<z.ZodString>;
|
|
215
|
+
member: z.ZodBoolean;
|
|
216
|
+
name: z.ZodString;
|
|
217
|
+
status: z.ZodNullable<z.ZodEnum<{
|
|
218
|
+
active: "active";
|
|
219
|
+
archived: "archived";
|
|
220
|
+
paused: "paused";
|
|
221
|
+
uninstalled: "uninstalled";
|
|
222
|
+
}>>;
|
|
223
|
+
}, z.core.$strip>>, Record<never, never>, {
|
|
224
|
+
permission: CompanyPermission | null;
|
|
225
|
+
} & Record<never, never>>;
|
|
226
|
+
setDefault: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
|
|
227
|
+
teamId: z.ZodString;
|
|
228
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
229
|
+
teamId: z.ZodString;
|
|
230
|
+
}, z.core.$strip>, Record<never, never>, {
|
|
231
|
+
permission: CompanyPermission | null;
|
|
232
|
+
} & Record<never, never>>;
|
|
233
|
+
};
|
|
234
|
+
};
|
|
235
|
+
export type ShufflCompanyContract = typeof companyContract;
|
package/dist/company.js
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { oc } from '@orpc/contract';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
// #1192, #1692: the company API. A company key (shuffl_company_) manages one
|
|
4
|
+
// company's settings and never reaches a workspace; a workspace key never
|
|
5
|
+
// reaches this API. Its operations are served under /api/v1/company, outside
|
|
6
|
+
// the workspace contract and its permission catalog, so a workspace key can
|
|
7
|
+
// never be granted one. OpenAPI, the SDK's createShufflCompany client, the CLI's
|
|
8
|
+
// `shuffl company` commands and the REST reference are all generated from this
|
|
9
|
+
// file. A permission is one company settings action, run as the key's issuer
|
|
10
|
+
// with that person's current company role.
|
|
11
|
+
//
|
|
12
|
+
// Kept in the browser on purpose, for every credential: deleting or restoring
|
|
13
|
+
// the company, transferring ownership, changing company roles, email domains,
|
|
14
|
+
// single sign-on, SCIM, Slack Grid mapping, billing and product analytics. A
|
|
15
|
+
// key never adds access, so nothing here can widen who reaches the company.
|
|
16
|
+
export const companyPermissionCatalog = [
|
|
17
|
+
{
|
|
18
|
+
access: 'read',
|
|
19
|
+
description: 'Read the company name, logo and default workspace',
|
|
20
|
+
id: 'company.details',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
access: 'read',
|
|
24
|
+
description: "List the company's workspaces",
|
|
25
|
+
id: 'company.workspaces.list',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
access: 'read',
|
|
29
|
+
description: 'List company members and their company roles',
|
|
30
|
+
id: 'company.members.list',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
access: 'read',
|
|
34
|
+
description: "List the company's email domains and their verification",
|
|
35
|
+
id: 'company.emailDomains.list',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
access: 'read',
|
|
39
|
+
description: 'List the Slack workspaces connected to the company',
|
|
40
|
+
id: 'company.slack.list',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
access: 'write',
|
|
44
|
+
description: 'Rename the company',
|
|
45
|
+
id: 'company.rename',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
access: 'write',
|
|
49
|
+
description: 'Choose the workspace new email domain and single sign-on members join',
|
|
50
|
+
id: 'company.workspaces.setDefault',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
access: 'write',
|
|
54
|
+
description: 'Remove someone from the company (administrators only with an owner’s key)',
|
|
55
|
+
id: 'company.members.remove',
|
|
56
|
+
},
|
|
57
|
+
];
|
|
58
|
+
export const companyPermissionIds = companyPermissionCatalog.map((permission) => permission.id);
|
|
59
|
+
// Readable by every valid company key, like teams.current for a workspace key.
|
|
60
|
+
export const companyIndexOperation = 'company.current';
|
|
61
|
+
export const companyKeyPrefix = 'shuffl_company_';
|
|
62
|
+
const companyBase = oc.$meta({
|
|
63
|
+
permission: null,
|
|
64
|
+
});
|
|
65
|
+
const read = (permission, path) => companyBase.meta({ permission }).route({ method: 'GET', path });
|
|
66
|
+
const write = (permission, path) => companyBase.meta({ permission }).route({ method: 'POST', path });
|
|
67
|
+
const id = z.string().min(1).max(128);
|
|
68
|
+
const time = z.iso.datetime();
|
|
69
|
+
const companyRole = z.enum(['owner', 'admin', 'member']);
|
|
70
|
+
export const companyCursorSchema = z.string().min(1).max(1024);
|
|
71
|
+
export const companyDetailsSchema = z.object({
|
|
72
|
+
defaultTeamId: id
|
|
73
|
+
.nullable()
|
|
74
|
+
.describe('The workspace new email domain and single sign-on members join.'),
|
|
75
|
+
deleteAfter: time
|
|
76
|
+
.nullable()
|
|
77
|
+
.describe('When a deleted company is erased, or null.'),
|
|
78
|
+
deletionRequestedAt: time
|
|
79
|
+
.nullable()
|
|
80
|
+
.describe('When someone deleted the company, or null.'),
|
|
81
|
+
id,
|
|
82
|
+
logo: z.string().nullable(),
|
|
83
|
+
name: z.string(),
|
|
84
|
+
role: companyRole.describe('The company role of the person who made the key.'),
|
|
85
|
+
});
|
|
86
|
+
export const companyWorkspaceSchema = z.object({
|
|
87
|
+
accessible: z
|
|
88
|
+
.boolean()
|
|
89
|
+
.describe('Whether the person who made the key can open the workspace.'),
|
|
90
|
+
default: z.boolean().describe('Whether this is the default workspace.'),
|
|
91
|
+
id,
|
|
92
|
+
logo: z.string().nullable(),
|
|
93
|
+
member: z
|
|
94
|
+
.boolean()
|
|
95
|
+
.describe('Whether the person who made the key is a member of it.'),
|
|
96
|
+
name: z.string(),
|
|
97
|
+
status: z.enum(['active', 'paused', 'uninstalled', 'archived']).nullable(),
|
|
98
|
+
});
|
|
99
|
+
export const companyMemberSchema = z.object({
|
|
100
|
+
email: z.string(),
|
|
101
|
+
id: id.describe('The company membership id.'),
|
|
102
|
+
name: z.string(),
|
|
103
|
+
role: companyRole,
|
|
104
|
+
userId: id.describe('The person’s user id. members.remove takes this.'),
|
|
105
|
+
});
|
|
106
|
+
export const companyEmailDomainSchema = z.object({
|
|
107
|
+
dnsRecord: z
|
|
108
|
+
.object({ name: z.string(), value: z.string() })
|
|
109
|
+
.nullable()
|
|
110
|
+
.describe('The TXT record that proves the domain, until it is verified.'),
|
|
111
|
+
domain: z.string(),
|
|
112
|
+
id,
|
|
113
|
+
verifiedAt: time.nullable(),
|
|
114
|
+
});
|
|
115
|
+
export const companySlackSchema = z.object({
|
|
116
|
+
installation: z
|
|
117
|
+
.object({
|
|
118
|
+
enterpriseId: z.string().nullable(),
|
|
119
|
+
gridOrganizationId: z.string().nullable(),
|
|
120
|
+
revokedAt: time
|
|
121
|
+
.nullable()
|
|
122
|
+
.describe('When the connection stopped working, or null.'),
|
|
123
|
+
slackTeamId: z.string(),
|
|
124
|
+
})
|
|
125
|
+
.nullable()
|
|
126
|
+
.describe('The Slack connection, or null when the workspace has none.'),
|
|
127
|
+
teamId: id,
|
|
128
|
+
teamName: z.string(),
|
|
129
|
+
});
|
|
130
|
+
export const companyContract = {
|
|
131
|
+
current: read(null, '/company')
|
|
132
|
+
.route({
|
|
133
|
+
summary: 'Read the company this key belongs to and the permissions it was granted',
|
|
134
|
+
})
|
|
135
|
+
.output(z.object({
|
|
136
|
+
catalog: z.array(z.object({
|
|
137
|
+
access: z.enum(['read', 'write']),
|
|
138
|
+
description: z.string(),
|
|
139
|
+
granted: z.boolean(),
|
|
140
|
+
id: z.enum(companyPermissionIds),
|
|
141
|
+
})),
|
|
142
|
+
organizationId: id,
|
|
143
|
+
permissions: z.array(z.enum(companyPermissionIds)),
|
|
144
|
+
})),
|
|
145
|
+
details: read('company.details', '/company/details').output(companyDetailsSchema),
|
|
146
|
+
emailDomains: {
|
|
147
|
+
list: read('company.emailDomains.list', '/company/emailDomains.list').output(z.array(companyEmailDomainSchema)),
|
|
148
|
+
},
|
|
149
|
+
members: {
|
|
150
|
+
list: read('company.members.list', '/company/members.list')
|
|
151
|
+
.input(z.object({
|
|
152
|
+
cursor: companyCursorSchema
|
|
153
|
+
.optional()
|
|
154
|
+
.describe('nextCursor from the previous page.'),
|
|
155
|
+
limit: z.number().int().min(1).max(100).default(25),
|
|
156
|
+
}))
|
|
157
|
+
.output(z.object({
|
|
158
|
+
items: z.array(companyMemberSchema),
|
|
159
|
+
nextCursor: companyCursorSchema.nullable(),
|
|
160
|
+
})),
|
|
161
|
+
remove: write('company.members.remove', '/company/members.remove')
|
|
162
|
+
.input(z.object({ userId: id }))
|
|
163
|
+
.output(z.object({ removed: z.boolean() })),
|
|
164
|
+
},
|
|
165
|
+
rename: write('company.rename', '/company/rename')
|
|
166
|
+
.input(z.object({ name: z.string().trim().min(1).max(100) }))
|
|
167
|
+
.output(z.object({ name: z.string() })),
|
|
168
|
+
slack: {
|
|
169
|
+
list: read('company.slack.list', '/company/slack.list').output(z.array(companySlackSchema)),
|
|
170
|
+
},
|
|
171
|
+
workspaces: {
|
|
172
|
+
list: read('company.workspaces.list', '/company/workspaces.list').output(z.array(companyWorkspaceSchema)),
|
|
173
|
+
setDefault: write('company.workspaces.setDefault', '/company/workspaces.setDefault')
|
|
174
|
+
.input(z.object({ teamId: id }))
|
|
175
|
+
.output(z.object({ teamId: id })),
|
|
176
|
+
},
|
|
177
|
+
};
|