@stackframe/stack-shared 2.7.30 → 2.8.1
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/CHANGELOG.md +8 -0
- package/dist/interface/adminInterface.d.ts +9 -4
- package/dist/interface/adminInterface.js +33 -4
- package/dist/interface/clientInterface.d.ts +4 -0
- package/dist/interface/clientInterface.js +5 -0
- package/dist/interface/crud/project-permissions.d.ts +155 -0
- package/dist/interface/crud/project-permissions.js +100 -0
- package/dist/interface/crud/projects.d.ts +24 -0
- package/dist/interface/crud/projects.js +2 -0
- package/dist/interface/crud/team-permissions.js +7 -7
- package/dist/interface/serverInterface.d.ts +5 -0
- package/dist/interface/serverInterface.js +8 -0
- package/dist/known-errors.d.ts +3 -0
- package/dist/known-errors.js +9 -0
- package/dist/schema-fields.d.ts +2 -2
- package/dist/schema-fields.js +3 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,7 @@ import { InternalSession } from "../sessions";
|
|
|
2
2
|
import { ApiKeysCrud } from "./crud/api-keys";
|
|
3
3
|
import { EmailTemplateCrud, EmailTemplateType } from "./crud/email-templates";
|
|
4
4
|
import { InternalEmailsCrud } from "./crud/emails";
|
|
5
|
+
import { ProjectPermissionDefinitionsCrud } from "./crud/project-permissions";
|
|
5
6
|
import { ProjectsCrud } from "./crud/projects";
|
|
6
7
|
import { SvixTokenCrud } from "./crud/svix-token";
|
|
7
8
|
import { TeamPermissionDefinitionsCrud } from "./crud/team-permissions";
|
|
@@ -41,10 +42,14 @@ export declare class StackAdminInterface extends StackServerInterface {
|
|
|
41
42
|
listEmailTemplates(): Promise<EmailTemplateCrud['Admin']['Read'][]>;
|
|
42
43
|
updateEmailTemplate(type: EmailTemplateType, data: EmailTemplateCrud['Admin']['Update']): Promise<EmailTemplateCrud['Admin']['Read']>;
|
|
43
44
|
resetEmailTemplate(type: EmailTemplateType): Promise<void>;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
listTeamPermissionDefinitions(): Promise<TeamPermissionDefinitionsCrud['Admin']['Read'][]>;
|
|
46
|
+
createTeamPermissionDefinition(data: TeamPermissionDefinitionsCrud['Admin']['Create']): Promise<TeamPermissionDefinitionsCrud['Admin']['Read']>;
|
|
47
|
+
updateTeamPermissionDefinition(permissionId: string, data: TeamPermissionDefinitionsCrud['Admin']['Update']): Promise<TeamPermissionDefinitionsCrud['Admin']['Read']>;
|
|
48
|
+
deleteTeamPermissionDefinition(permissionId: string): Promise<void>;
|
|
49
|
+
listProjectPermissionDefinitions(): Promise<ProjectPermissionDefinitionsCrud['Admin']['Read'][]>;
|
|
50
|
+
createProjectPermissionDefinition(data: ProjectPermissionDefinitionsCrud['Admin']['Create']): Promise<ProjectPermissionDefinitionsCrud['Admin']['Read']>;
|
|
51
|
+
updateProjectPermissionDefinition(permissionId: string, data: ProjectPermissionDefinitionsCrud['Admin']['Update']): Promise<ProjectPermissionDefinitionsCrud['Admin']['Read']>;
|
|
52
|
+
deleteProjectPermissionDefinition(permissionId: string): Promise<void>;
|
|
48
53
|
getSvixToken(): Promise<SvixTokenCrud["Admin"]["Read"]>;
|
|
49
54
|
deleteProject(): Promise<void>;
|
|
50
55
|
getMetrics(): Promise<any>;
|
|
@@ -77,12 +77,13 @@ export class StackAdminInterface extends StackServerInterface {
|
|
|
77
77
|
async resetEmailTemplate(type) {
|
|
78
78
|
await this.sendAdminRequest(`/email-templates/${type}`, { method: "DELETE" }, null);
|
|
79
79
|
}
|
|
80
|
-
|
|
80
|
+
// Team permission definitions methods
|
|
81
|
+
async listTeamPermissionDefinitions() {
|
|
81
82
|
const response = await this.sendAdminRequest(`/team-permission-definitions`, {}, null);
|
|
82
83
|
const result = await response.json();
|
|
83
84
|
return result.items;
|
|
84
85
|
}
|
|
85
|
-
async
|
|
86
|
+
async createTeamPermissionDefinition(data) {
|
|
86
87
|
const response = await this.sendAdminRequest("/team-permission-definitions", {
|
|
87
88
|
method: "POST",
|
|
88
89
|
headers: {
|
|
@@ -92,7 +93,7 @@ export class StackAdminInterface extends StackServerInterface {
|
|
|
92
93
|
}, null);
|
|
93
94
|
return await response.json();
|
|
94
95
|
}
|
|
95
|
-
async
|
|
96
|
+
async updateTeamPermissionDefinition(permissionId, data) {
|
|
96
97
|
const response = await this.sendAdminRequest(`/team-permission-definitions/${permissionId}`, {
|
|
97
98
|
method: "PATCH",
|
|
98
99
|
headers: {
|
|
@@ -102,9 +103,37 @@ export class StackAdminInterface extends StackServerInterface {
|
|
|
102
103
|
}, null);
|
|
103
104
|
return await response.json();
|
|
104
105
|
}
|
|
105
|
-
async
|
|
106
|
+
async deleteTeamPermissionDefinition(permissionId) {
|
|
106
107
|
await this.sendAdminRequest(`/team-permission-definitions/${permissionId}`, { method: "DELETE" }, null);
|
|
107
108
|
}
|
|
109
|
+
async listProjectPermissionDefinitions() {
|
|
110
|
+
const response = await this.sendAdminRequest(`/project-permission-definitions`, {}, null);
|
|
111
|
+
const result = await response.json();
|
|
112
|
+
return result.items;
|
|
113
|
+
}
|
|
114
|
+
async createProjectPermissionDefinition(data) {
|
|
115
|
+
const response = await this.sendAdminRequest("/project-permission-definitions", {
|
|
116
|
+
method: "POST",
|
|
117
|
+
headers: {
|
|
118
|
+
"content-type": "application/json",
|
|
119
|
+
},
|
|
120
|
+
body: JSON.stringify(data),
|
|
121
|
+
}, null);
|
|
122
|
+
return await response.json();
|
|
123
|
+
}
|
|
124
|
+
async updateProjectPermissionDefinition(permissionId, data) {
|
|
125
|
+
const response = await this.sendAdminRequest(`/project-permission-definitions/${permissionId}`, {
|
|
126
|
+
method: "PATCH",
|
|
127
|
+
headers: {
|
|
128
|
+
"content-type": "application/json",
|
|
129
|
+
},
|
|
130
|
+
body: JSON.stringify(data),
|
|
131
|
+
}, null);
|
|
132
|
+
return await response.json();
|
|
133
|
+
}
|
|
134
|
+
async deleteProjectPermissionDefinition(permissionId) {
|
|
135
|
+
await this.sendAdminRequest(`/project-permission-definitions/${permissionId}`, { method: "DELETE" }, null);
|
|
136
|
+
}
|
|
108
137
|
async getSvixToken() {
|
|
109
138
|
const response = await this.sendAdminRequest("/webhooks/svix-token", {
|
|
110
139
|
method: "POST",
|
|
@@ -10,6 +10,7 @@ import { InternalProjectsCrud, ProjectsCrud } from './crud/projects';
|
|
|
10
10
|
import { SessionsCrud } from './crud/sessions';
|
|
11
11
|
import { TeamInvitationCrud } from './crud/team-invitation';
|
|
12
12
|
import { TeamMemberProfilesCrud } from './crud/team-member-profiles';
|
|
13
|
+
import { ProjectPermissionsCrud } from './crud/project-permissions';
|
|
13
14
|
import { TeamPermissionsCrud } from './crud/team-permissions';
|
|
14
15
|
import { TeamsCrud } from './crud/teams';
|
|
15
16
|
export type ClientInterfaceOptions = {
|
|
@@ -187,6 +188,9 @@ export declare class StackClientInterface {
|
|
|
187
188
|
teamId: string;
|
|
188
189
|
recursive: boolean;
|
|
189
190
|
}, session: InternalSession): Promise<TeamPermissionsCrud['Client']['Read'][]>;
|
|
191
|
+
listCurrentUserProjectPermissions(options: {
|
|
192
|
+
recursive: boolean;
|
|
193
|
+
}, session: InternalSession): Promise<ProjectPermissionsCrud['Client']['Read'][]>;
|
|
190
194
|
listCurrentUserTeams(session: InternalSession): Promise<TeamsCrud["Client"]["Read"][]>;
|
|
191
195
|
getClientProject(): Promise<Result<ProjectsCrud['Client']['Read'], KnownErrors["ProjectNotFound"]>>;
|
|
192
196
|
updateClientUser(update: CurrentUserCrud["Client"]["Update"], session: InternalSession): Promise<void>;
|
|
@@ -790,6 +790,11 @@ export class StackClientInterface {
|
|
|
790
790
|
const result = await response.json();
|
|
791
791
|
return result.items;
|
|
792
792
|
}
|
|
793
|
+
async listCurrentUserProjectPermissions(options, session) {
|
|
794
|
+
const response = await this.sendClientRequest(`/project-permissions?user_id=me&recursive=${options.recursive}`, {}, session);
|
|
795
|
+
const result = await response.json();
|
|
796
|
+
return result.items;
|
|
797
|
+
}
|
|
793
798
|
async listCurrentUserTeams(session) {
|
|
794
799
|
const response = await this.sendClientRequest("/teams?user_id=me", {}, session);
|
|
795
800
|
const result = await response.json();
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { CrudTypeOf } from "../../crud";
|
|
2
|
+
export declare const projectPermissionsCrudClientReadSchema: import("yup").ObjectSchema<{
|
|
3
|
+
id: string;
|
|
4
|
+
user_id: string;
|
|
5
|
+
}, import("yup").AnyObject, {
|
|
6
|
+
id: undefined;
|
|
7
|
+
user_id: undefined;
|
|
8
|
+
}, "">;
|
|
9
|
+
export declare const projectPermissionsCrudServerCreateSchema: import("yup").ObjectSchema<{}, import("yup").AnyObject, {}, "">;
|
|
10
|
+
export declare const projectPermissionsCrudServerDeleteSchema: import("yup").MixedSchema<{} | undefined, import("yup").AnyObject, undefined, "">;
|
|
11
|
+
export declare const projectPermissionsCrud: import("../../crud").CrudSchemaFromOptions<{
|
|
12
|
+
clientReadSchema: import("yup").ObjectSchema<{
|
|
13
|
+
id: string;
|
|
14
|
+
user_id: string;
|
|
15
|
+
}, import("yup").AnyObject, {
|
|
16
|
+
id: undefined;
|
|
17
|
+
user_id: undefined;
|
|
18
|
+
}, "">;
|
|
19
|
+
serverCreateSchema: import("yup").ObjectSchema<{}, import("yup").AnyObject, {}, "">;
|
|
20
|
+
serverDeleteSchema: import("yup").MixedSchema<{} | undefined, import("yup").AnyObject, undefined, "">;
|
|
21
|
+
docs: {
|
|
22
|
+
clientList: {
|
|
23
|
+
summary: string;
|
|
24
|
+
description: string;
|
|
25
|
+
tags: string[];
|
|
26
|
+
};
|
|
27
|
+
serverList: {
|
|
28
|
+
summary: string;
|
|
29
|
+
description: string;
|
|
30
|
+
tags: string[];
|
|
31
|
+
};
|
|
32
|
+
serverCreate: {
|
|
33
|
+
summary: string;
|
|
34
|
+
description: string;
|
|
35
|
+
tags: string[];
|
|
36
|
+
};
|
|
37
|
+
serverDelete: {
|
|
38
|
+
summary: string;
|
|
39
|
+
description: string;
|
|
40
|
+
tags: string[];
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
}>;
|
|
44
|
+
export type ProjectPermissionsCrud = CrudTypeOf<typeof projectPermissionsCrud>;
|
|
45
|
+
export declare const projectPermissionCreatedWebhookEvent: {
|
|
46
|
+
type: string;
|
|
47
|
+
schema: import("yup").ObjectSchema<{
|
|
48
|
+
id: string;
|
|
49
|
+
user_id: string;
|
|
50
|
+
}, import("yup").AnyObject, {
|
|
51
|
+
id: undefined;
|
|
52
|
+
user_id: undefined;
|
|
53
|
+
}, "">;
|
|
54
|
+
metadata: {
|
|
55
|
+
summary: string;
|
|
56
|
+
description: string;
|
|
57
|
+
tags: string[];
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
export declare const projectPermissionDeletedWebhookEvent: {
|
|
61
|
+
type: string;
|
|
62
|
+
schema: import("yup").ObjectSchema<{
|
|
63
|
+
id: string;
|
|
64
|
+
user_id: string;
|
|
65
|
+
}, import("yup").AnyObject, {
|
|
66
|
+
id: undefined;
|
|
67
|
+
user_id: undefined;
|
|
68
|
+
}, "">;
|
|
69
|
+
metadata: {
|
|
70
|
+
summary: string;
|
|
71
|
+
description: string;
|
|
72
|
+
tags: string[];
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
export declare const projectPermissionDefinitionsCrudAdminReadSchema: import("yup").ObjectSchema<{
|
|
76
|
+
id: string;
|
|
77
|
+
description: string | undefined;
|
|
78
|
+
contained_permission_ids: string[];
|
|
79
|
+
}, import("yup").AnyObject, {
|
|
80
|
+
id: undefined;
|
|
81
|
+
description: undefined;
|
|
82
|
+
contained_permission_ids: undefined;
|
|
83
|
+
}, "">;
|
|
84
|
+
export declare const projectPermissionDefinitionsCrudAdminCreateSchema: import("yup").ObjectSchema<{
|
|
85
|
+
id: string;
|
|
86
|
+
description: string | undefined;
|
|
87
|
+
contained_permission_ids: string[] | undefined;
|
|
88
|
+
}, import("yup").AnyObject, {
|
|
89
|
+
id: undefined;
|
|
90
|
+
description: undefined;
|
|
91
|
+
contained_permission_ids: undefined;
|
|
92
|
+
}, "">;
|
|
93
|
+
export declare const projectPermissionDefinitionsCrudAdminUpdateSchema: import("yup").ObjectSchema<{
|
|
94
|
+
id: string | undefined;
|
|
95
|
+
description: string | undefined;
|
|
96
|
+
contained_permission_ids: string[] | undefined;
|
|
97
|
+
}, import("yup").AnyObject, {
|
|
98
|
+
id: undefined;
|
|
99
|
+
description: undefined;
|
|
100
|
+
contained_permission_ids: undefined;
|
|
101
|
+
}, "">;
|
|
102
|
+
export declare const projectPermissionDefinitionsCrudAdminDeleteSchema: import("yup").MixedSchema<{} | undefined, import("yup").AnyObject, undefined, "">;
|
|
103
|
+
export declare const projectPermissionDefinitionsCrud: import("../../crud").CrudSchemaFromOptions<{
|
|
104
|
+
adminReadSchema: import("yup").ObjectSchema<{
|
|
105
|
+
id: string;
|
|
106
|
+
description: string | undefined;
|
|
107
|
+
contained_permission_ids: string[];
|
|
108
|
+
}, import("yup").AnyObject, {
|
|
109
|
+
id: undefined;
|
|
110
|
+
description: undefined;
|
|
111
|
+
contained_permission_ids: undefined;
|
|
112
|
+
}, "">;
|
|
113
|
+
adminCreateSchema: import("yup").ObjectSchema<{
|
|
114
|
+
id: string;
|
|
115
|
+
description: string | undefined;
|
|
116
|
+
contained_permission_ids: string[] | undefined;
|
|
117
|
+
}, import("yup").AnyObject, {
|
|
118
|
+
id: undefined;
|
|
119
|
+
description: undefined;
|
|
120
|
+
contained_permission_ids: undefined;
|
|
121
|
+
}, "">;
|
|
122
|
+
adminUpdateSchema: import("yup").ObjectSchema<{
|
|
123
|
+
id: string | undefined;
|
|
124
|
+
description: string | undefined;
|
|
125
|
+
contained_permission_ids: string[] | undefined;
|
|
126
|
+
}, import("yup").AnyObject, {
|
|
127
|
+
id: undefined;
|
|
128
|
+
description: undefined;
|
|
129
|
+
contained_permission_ids: undefined;
|
|
130
|
+
}, "">;
|
|
131
|
+
adminDeleteSchema: import("yup").MixedSchema<{} | undefined, import("yup").AnyObject, undefined, "">;
|
|
132
|
+
docs: {
|
|
133
|
+
adminList: {
|
|
134
|
+
summary: string;
|
|
135
|
+
description: string;
|
|
136
|
+
tags: string[];
|
|
137
|
+
};
|
|
138
|
+
adminCreate: {
|
|
139
|
+
summary: string;
|
|
140
|
+
description: string;
|
|
141
|
+
tags: string[];
|
|
142
|
+
};
|
|
143
|
+
adminUpdate: {
|
|
144
|
+
summary: string;
|
|
145
|
+
description: string;
|
|
146
|
+
tags: string[];
|
|
147
|
+
};
|
|
148
|
+
adminDelete: {
|
|
149
|
+
summary: string;
|
|
150
|
+
description: string;
|
|
151
|
+
tags: string[];
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
}>;
|
|
155
|
+
export type ProjectPermissionDefinitionsCrud = CrudTypeOf<typeof projectPermissionDefinitionsCrud>;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { createCrud } from "../../crud";
|
|
2
|
+
import * as schemaFields from "../../schema-fields";
|
|
3
|
+
import { yupMixed, yupObject } from "../../schema-fields";
|
|
4
|
+
// =============== Project permissions =================
|
|
5
|
+
export const projectPermissionsCrudClientReadSchema = yupObject({
|
|
6
|
+
id: schemaFields.permissionDefinitionIdSchema.defined(),
|
|
7
|
+
user_id: schemaFields.userIdSchema.defined(),
|
|
8
|
+
}).defined();
|
|
9
|
+
export const projectPermissionsCrudServerCreateSchema = yupObject({}).defined();
|
|
10
|
+
export const projectPermissionsCrudServerDeleteSchema = yupMixed();
|
|
11
|
+
export const projectPermissionsCrud = createCrud({
|
|
12
|
+
clientReadSchema: projectPermissionsCrudClientReadSchema,
|
|
13
|
+
serverCreateSchema: projectPermissionsCrudServerCreateSchema,
|
|
14
|
+
serverDeleteSchema: projectPermissionsCrudServerDeleteSchema,
|
|
15
|
+
docs: {
|
|
16
|
+
clientList: {
|
|
17
|
+
summary: "List project permissions",
|
|
18
|
+
description: "List global permissions of the current user. `user_id=me` must be set for client requests. `(user_id, permission_id)` together uniquely identify a permission.",
|
|
19
|
+
tags: ["Permissions"],
|
|
20
|
+
},
|
|
21
|
+
serverList: {
|
|
22
|
+
summary: "List project permissions",
|
|
23
|
+
description: "Query and filter the permission with `user_id` and `permission_id`. `(user_id, permission_id)` together uniquely identify a permission.",
|
|
24
|
+
tags: ["Permissions"],
|
|
25
|
+
},
|
|
26
|
+
serverCreate: {
|
|
27
|
+
summary: "Grant a global permission to a user",
|
|
28
|
+
description: "Grant a global permission to a user (the permission must be created first on the Stack dashboard)",
|
|
29
|
+
tags: ["Permissions"],
|
|
30
|
+
},
|
|
31
|
+
serverDelete: {
|
|
32
|
+
summary: "Revoke a global permission from a user",
|
|
33
|
+
description: "Revoke a global permission from a user",
|
|
34
|
+
tags: ["Permissions"],
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
export const projectPermissionCreatedWebhookEvent = {
|
|
39
|
+
type: "project_permission.created",
|
|
40
|
+
schema: projectPermissionsCrud.server.readSchema,
|
|
41
|
+
metadata: {
|
|
42
|
+
summary: "Project Permission Created",
|
|
43
|
+
description: "This event is triggered when a project permission is created.",
|
|
44
|
+
tags: ["Users"],
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
export const projectPermissionDeletedWebhookEvent = {
|
|
48
|
+
type: "project_permission.deleted",
|
|
49
|
+
schema: projectPermissionsCrud.server.readSchema,
|
|
50
|
+
metadata: {
|
|
51
|
+
summary: "Project Permission Deleted",
|
|
52
|
+
description: "This event is triggered when a project permission is deleted.",
|
|
53
|
+
tags: ["Users"],
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
// =============== Project permission definitions =================
|
|
57
|
+
export const projectPermissionDefinitionsCrudAdminReadSchema = yupObject({
|
|
58
|
+
id: schemaFields.permissionDefinitionIdSchema.defined(),
|
|
59
|
+
description: schemaFields.teamPermissionDescriptionSchema.optional(),
|
|
60
|
+
contained_permission_ids: schemaFields.containedPermissionIdsSchema.defined(),
|
|
61
|
+
}).defined();
|
|
62
|
+
export const projectPermissionDefinitionsCrudAdminCreateSchema = yupObject({
|
|
63
|
+
id: schemaFields.customPermissionDefinitionIdSchema.defined(),
|
|
64
|
+
description: schemaFields.teamPermissionDescriptionSchema.optional(),
|
|
65
|
+
contained_permission_ids: schemaFields.containedPermissionIdsSchema.optional(),
|
|
66
|
+
}).defined();
|
|
67
|
+
export const projectPermissionDefinitionsCrudAdminUpdateSchema = yupObject({
|
|
68
|
+
id: schemaFields.customPermissionDefinitionIdSchema.optional(),
|
|
69
|
+
description: schemaFields.teamPermissionDescriptionSchema.optional(),
|
|
70
|
+
contained_permission_ids: schemaFields.containedPermissionIdsSchema.optional(),
|
|
71
|
+
}).defined();
|
|
72
|
+
export const projectPermissionDefinitionsCrudAdminDeleteSchema = yupMixed();
|
|
73
|
+
export const projectPermissionDefinitionsCrud = createCrud({
|
|
74
|
+
adminReadSchema: projectPermissionDefinitionsCrudAdminReadSchema,
|
|
75
|
+
adminCreateSchema: projectPermissionDefinitionsCrudAdminCreateSchema,
|
|
76
|
+
adminUpdateSchema: projectPermissionDefinitionsCrudAdminUpdateSchema,
|
|
77
|
+
adminDeleteSchema: projectPermissionDefinitionsCrudAdminDeleteSchema,
|
|
78
|
+
docs: {
|
|
79
|
+
adminList: {
|
|
80
|
+
summary: "List project permission definitions",
|
|
81
|
+
description: "Query and filter project permission definitions (the equivalent of listing permissions on the Stack dashboard)",
|
|
82
|
+
tags: ["Permissions"],
|
|
83
|
+
},
|
|
84
|
+
adminCreate: {
|
|
85
|
+
summary: "Create a new project permission definition",
|
|
86
|
+
description: "Create a new project permission definition (the equivalent of creating a new permission on the Stack dashboard)",
|
|
87
|
+
tags: ["Permissions"],
|
|
88
|
+
},
|
|
89
|
+
adminUpdate: {
|
|
90
|
+
summary: "Update a project permission definition",
|
|
91
|
+
description: "Update a project permission definition (the equivalent of updating a permission on the Stack dashboard)",
|
|
92
|
+
tags: ["Permissions"],
|
|
93
|
+
},
|
|
94
|
+
adminDelete: {
|
|
95
|
+
summary: "Delete a project permission definition",
|
|
96
|
+
description: "Delete a project permission definition (the equivalent of deleting a permission on the Stack dashboard)",
|
|
97
|
+
tags: ["Permissions"],
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
});
|
|
@@ -80,6 +80,9 @@ export declare const projectsCrudAdminReadSchema: import("yup").ObjectSchema<{
|
|
|
80
80
|
team_member_default_permissions: {
|
|
81
81
|
id: string;
|
|
82
82
|
}[];
|
|
83
|
+
user_default_permissions: {
|
|
84
|
+
id: string;
|
|
85
|
+
}[];
|
|
83
86
|
oauth_account_merge_strategy: "link_method" | "raise_error" | "allow_duplicates";
|
|
84
87
|
};
|
|
85
88
|
}, import("yup").AnyObject, {
|
|
@@ -113,6 +116,7 @@ export declare const projectsCrudAdminReadSchema: import("yup").ObjectSchema<{
|
|
|
113
116
|
create_team_on_sign_up: undefined;
|
|
114
117
|
team_creator_default_permissions: undefined;
|
|
115
118
|
team_member_default_permissions: undefined;
|
|
119
|
+
user_default_permissions: undefined;
|
|
116
120
|
oauth_account_merge_strategy: undefined;
|
|
117
121
|
};
|
|
118
122
|
}, "">;
|
|
@@ -184,6 +188,9 @@ export declare const projectsCrudAdminUpdateSchema: import("yup").ObjectSchema<{
|
|
|
184
188
|
team_member_default_permissions?: {
|
|
185
189
|
id: string;
|
|
186
190
|
}[] | undefined;
|
|
191
|
+
user_default_permissions?: {
|
|
192
|
+
id: string;
|
|
193
|
+
}[] | undefined;
|
|
187
194
|
oauth_account_merge_strategy?: "link_method" | "raise_error" | "allow_duplicates" | undefined;
|
|
188
195
|
} | undefined;
|
|
189
196
|
}, import("yup").AnyObject, {
|
|
@@ -233,6 +240,9 @@ export declare const projectsCrudAdminCreateSchema: import("yup").ObjectSchema<{
|
|
|
233
240
|
team_member_default_permissions?: {
|
|
234
241
|
id: string;
|
|
235
242
|
}[] | undefined;
|
|
243
|
+
user_default_permissions?: {
|
|
244
|
+
id: string;
|
|
245
|
+
}[] | undefined;
|
|
236
246
|
oauth_account_merge_strategy?: "link_method" | "raise_error" | "allow_duplicates" | undefined;
|
|
237
247
|
} | undefined;
|
|
238
248
|
} & {
|
|
@@ -320,6 +330,9 @@ export declare const projectsCrud: import("../../crud").CrudSchemaFromOptions<{
|
|
|
320
330
|
team_member_default_permissions: {
|
|
321
331
|
id: string;
|
|
322
332
|
}[];
|
|
333
|
+
user_default_permissions: {
|
|
334
|
+
id: string;
|
|
335
|
+
}[];
|
|
323
336
|
oauth_account_merge_strategy: "link_method" | "raise_error" | "allow_duplicates";
|
|
324
337
|
};
|
|
325
338
|
}, import("yup").AnyObject, {
|
|
@@ -353,6 +366,7 @@ export declare const projectsCrud: import("../../crud").CrudSchemaFromOptions<{
|
|
|
353
366
|
create_team_on_sign_up: undefined;
|
|
354
367
|
team_creator_default_permissions: undefined;
|
|
355
368
|
team_member_default_permissions: undefined;
|
|
369
|
+
user_default_permissions: undefined;
|
|
356
370
|
oauth_account_merge_strategy: undefined;
|
|
357
371
|
};
|
|
358
372
|
}, "">;
|
|
@@ -397,6 +411,9 @@ export declare const projectsCrud: import("../../crud").CrudSchemaFromOptions<{
|
|
|
397
411
|
team_member_default_permissions?: {
|
|
398
412
|
id: string;
|
|
399
413
|
}[] | undefined;
|
|
414
|
+
user_default_permissions?: {
|
|
415
|
+
id: string;
|
|
416
|
+
}[] | undefined;
|
|
400
417
|
oauth_account_merge_strategy?: "link_method" | "raise_error" | "allow_duplicates" | undefined;
|
|
401
418
|
} | undefined;
|
|
402
419
|
}, import("yup").AnyObject, {
|
|
@@ -479,6 +496,9 @@ export declare const internalProjectsCrud: import("../../crud").CrudSchemaFromOp
|
|
|
479
496
|
team_member_default_permissions: {
|
|
480
497
|
id: string;
|
|
481
498
|
}[];
|
|
499
|
+
user_default_permissions: {
|
|
500
|
+
id: string;
|
|
501
|
+
}[];
|
|
482
502
|
oauth_account_merge_strategy: "link_method" | "raise_error" | "allow_duplicates";
|
|
483
503
|
};
|
|
484
504
|
}, import("yup").AnyObject, {
|
|
@@ -512,6 +532,7 @@ export declare const internalProjectsCrud: import("../../crud").CrudSchemaFromOp
|
|
|
512
532
|
create_team_on_sign_up: undefined;
|
|
513
533
|
team_creator_default_permissions: undefined;
|
|
514
534
|
team_member_default_permissions: undefined;
|
|
535
|
+
user_default_permissions: undefined;
|
|
515
536
|
oauth_account_merge_strategy: undefined;
|
|
516
537
|
};
|
|
517
538
|
}, "">;
|
|
@@ -556,6 +577,9 @@ export declare const internalProjectsCrud: import("../../crud").CrudSchemaFromOp
|
|
|
556
577
|
team_member_default_permissions?: {
|
|
557
578
|
id: string;
|
|
558
579
|
}[] | undefined;
|
|
580
|
+
user_default_permissions?: {
|
|
581
|
+
id: string;
|
|
582
|
+
}[] | undefined;
|
|
559
583
|
oauth_account_merge_strategy?: "link_method" | "raise_error" | "allow_duplicates" | undefined;
|
|
560
584
|
} | undefined;
|
|
561
585
|
} & {
|
|
@@ -75,6 +75,7 @@ export const projectsCrudAdminReadSchema = yupObject({
|
|
|
75
75
|
create_team_on_sign_up: schemaFields.projectCreateTeamOnSignUpSchema.defined(),
|
|
76
76
|
team_creator_default_permissions: yupArray(teamPermissionSchema.defined()).defined(),
|
|
77
77
|
team_member_default_permissions: yupArray(teamPermissionSchema.defined()).defined(),
|
|
78
|
+
user_default_permissions: yupArray(teamPermissionSchema.defined()).defined(),
|
|
78
79
|
oauth_account_merge_strategy: schemaFields.oauthAccountMergeStrategySchema.defined(),
|
|
79
80
|
}).defined(),
|
|
80
81
|
}).defined();
|
|
@@ -109,6 +110,7 @@ export const projectsCrudAdminUpdateSchema = yupObject({
|
|
|
109
110
|
create_team_on_sign_up: schemaFields.projectCreateTeamOnSignUpSchema.optional(),
|
|
110
111
|
team_creator_default_permissions: yupArray(teamPermissionSchema.defined()).optional(),
|
|
111
112
|
team_member_default_permissions: yupArray(teamPermissionSchema.defined()).optional(),
|
|
113
|
+
user_default_permissions: yupArray(teamPermissionSchema.defined()).optional(),
|
|
112
114
|
oauth_account_merge_strategy: schemaFields.oauthAccountMergeStrategySchema.optional(),
|
|
113
115
|
}).optional().default(undefined),
|
|
114
116
|
}).defined();
|
|
@@ -3,7 +3,7 @@ import * as schemaFields from "../../schema-fields";
|
|
|
3
3
|
import { yupMixed, yupObject } from "../../schema-fields";
|
|
4
4
|
// =============== Team permissions =================
|
|
5
5
|
export const teamPermissionsCrudClientReadSchema = yupObject({
|
|
6
|
-
id: schemaFields.
|
|
6
|
+
id: schemaFields.permissionDefinitionIdSchema.defined(),
|
|
7
7
|
user_id: schemaFields.userIdSchema.defined(),
|
|
8
8
|
team_id: schemaFields.teamIdSchema.defined(),
|
|
9
9
|
}).defined();
|
|
@@ -56,19 +56,19 @@ export const teamPermissionDeletedWebhookEvent = {
|
|
|
56
56
|
};
|
|
57
57
|
// =============== Team permission definitions =================
|
|
58
58
|
export const teamPermissionDefinitionsCrudAdminReadSchema = yupObject({
|
|
59
|
-
id: schemaFields.
|
|
59
|
+
id: schemaFields.permissionDefinitionIdSchema.defined(),
|
|
60
60
|
description: schemaFields.teamPermissionDescriptionSchema.optional(),
|
|
61
|
-
contained_permission_ids: schemaFields.containedPermissionIdsSchema.defined()
|
|
61
|
+
contained_permission_ids: schemaFields.containedPermissionIdsSchema.defined(),
|
|
62
62
|
}).defined();
|
|
63
63
|
export const teamPermissionDefinitionsCrudAdminCreateSchema = yupObject({
|
|
64
|
-
id: schemaFields.
|
|
64
|
+
id: schemaFields.customPermissionDefinitionIdSchema.defined(),
|
|
65
65
|
description: schemaFields.teamPermissionDescriptionSchema.optional(),
|
|
66
|
-
contained_permission_ids: schemaFields.containedPermissionIdsSchema.optional()
|
|
66
|
+
contained_permission_ids: schemaFields.containedPermissionIdsSchema.optional(),
|
|
67
67
|
}).defined();
|
|
68
68
|
export const teamPermissionDefinitionsCrudAdminUpdateSchema = yupObject({
|
|
69
|
-
id: schemaFields.
|
|
69
|
+
id: schemaFields.customPermissionDefinitionIdSchema.optional(),
|
|
70
70
|
description: schemaFields.teamPermissionDescriptionSchema.optional(),
|
|
71
|
-
contained_permission_ids: schemaFields.containedPermissionIdsSchema.optional()
|
|
71
|
+
contained_permission_ids: schemaFields.containedPermissionIdsSchema.optional(),
|
|
72
72
|
}).defined();
|
|
73
73
|
export const teamPermissionDefinitionsCrudAdminDeleteSchema = yupMixed();
|
|
74
74
|
export const teamPermissionDefinitionsCrud = createCrud({
|
|
@@ -9,6 +9,7 @@ import { SessionsCrud } from "./crud/sessions";
|
|
|
9
9
|
import { TeamInvitationCrud } from "./crud/team-invitation";
|
|
10
10
|
import { TeamMemberProfilesCrud } from "./crud/team-member-profiles";
|
|
11
11
|
import { TeamMembershipsCrud } from "./crud/team-memberships";
|
|
12
|
+
import { ProjectPermissionsCrud } from "./crud/project-permissions";
|
|
12
13
|
import { TeamPermissionsCrud } from "./crud/team-permissions";
|
|
13
14
|
import { TeamsCrud } from "./crud/teams";
|
|
14
15
|
import { UsersCrud } from "./crud/users";
|
|
@@ -51,6 +52,10 @@ export declare class StackServerInterface extends StackClientInterface {
|
|
|
51
52
|
teamId?: string;
|
|
52
53
|
recursive: boolean;
|
|
53
54
|
}, session: InternalSession | null): Promise<TeamPermissionsCrud['Server']['Read'][]>;
|
|
55
|
+
listServerProjectPermissions(options: {
|
|
56
|
+
userId?: string;
|
|
57
|
+
recursive: boolean;
|
|
58
|
+
}, session: InternalSession | null): Promise<ProjectPermissionsCrud['Server']['Read'][]>;
|
|
54
59
|
listServerUsers(options: {
|
|
55
60
|
cursor?: string;
|
|
56
61
|
limit?: number;
|
|
@@ -91,6 +91,14 @@ export class StackServerInterface extends StackClientInterface {
|
|
|
91
91
|
const result = await response.json();
|
|
92
92
|
return result.items;
|
|
93
93
|
}
|
|
94
|
+
async listServerProjectPermissions(options, session) {
|
|
95
|
+
const response = await this.sendServerRequest(`/project-permissions?${new URLSearchParams(filterUndefined({
|
|
96
|
+
user_id: options.userId,
|
|
97
|
+
recursive: options.recursive.toString(),
|
|
98
|
+
}))}`, {}, session);
|
|
99
|
+
const result = await response.json();
|
|
100
|
+
return result.items;
|
|
101
|
+
}
|
|
94
102
|
async listServerUsers(options) {
|
|
95
103
|
const searchParams = new URLSearchParams(filterUndefined({
|
|
96
104
|
cursor: options.cursor,
|
package/dist/known-errors.d.ts
CHANGED
|
@@ -373,6 +373,9 @@ export declare const KnownErrors: {
|
|
|
373
373
|
TeamMembershipAlreadyExists: KnownErrorConstructor<KnownError & KnownErrorBrand<"TEAM_MEMBERSHIP_ALREADY_EXISTS">, []> & {
|
|
374
374
|
errorCode: "TEAM_MEMBERSHIP_ALREADY_EXISTS";
|
|
375
375
|
};
|
|
376
|
+
ProjectPermissionRequired: KnownErrorConstructor<KnownError & KnownErrorBrand<"PROJECT_PERMISSION_REQUIRED">, [any, any]> & {
|
|
377
|
+
errorCode: "PROJECT_PERMISSION_REQUIRED";
|
|
378
|
+
};
|
|
376
379
|
TeamPermissionRequired: KnownErrorConstructor<KnownError & KnownErrorBrand<"TEAM_PERMISSION_REQUIRED">, [any, any, any]> & {
|
|
377
380
|
errorCode: "TEAM_PERMISSION_REQUIRED";
|
|
378
381
|
};
|
package/dist/known-errors.js
CHANGED
|
@@ -510,6 +510,14 @@ const TeamMembershipAlreadyExists = createKnownErrorConstructor(KnownError, "TEA
|
|
|
510
510
|
409,
|
|
511
511
|
"Team membership already exists.",
|
|
512
512
|
], () => []);
|
|
513
|
+
const ProjectPermissionRequired = createKnownErrorConstructor(KnownError, "PROJECT_PERMISSION_REQUIRED", (userId, permissionId) => [
|
|
514
|
+
401,
|
|
515
|
+
`User ${userId} does not have permission ${permissionId}.`,
|
|
516
|
+
{
|
|
517
|
+
user_id: userId,
|
|
518
|
+
permission_id: permissionId,
|
|
519
|
+
},
|
|
520
|
+
], (json) => [json.user_id, json.permission_id]);
|
|
513
521
|
const TeamPermissionRequired = createKnownErrorConstructor(KnownError, "TEAM_PERMISSION_REQUIRED", (teamId, userId, permissionId) => [
|
|
514
522
|
401,
|
|
515
523
|
`User ${userId} does not have permission ${permissionId} in team ${teamId}.`,
|
|
@@ -648,6 +656,7 @@ export const KnownErrors = {
|
|
|
648
656
|
InvalidTotpCode,
|
|
649
657
|
UserAuthenticationRequired,
|
|
650
658
|
TeamMembershipAlreadyExists,
|
|
659
|
+
ProjectPermissionRequired,
|
|
651
660
|
TeamPermissionRequired,
|
|
652
661
|
InvalidSharedOAuthProviderId,
|
|
653
662
|
InvalidStandardOAuthProviderId,
|
package/dist/schema-fields.d.ts
CHANGED
|
@@ -131,8 +131,8 @@ export declare const signInResponseSchema: yup.ObjectSchema<{
|
|
|
131
131
|
user_id: undefined;
|
|
132
132
|
}, "">;
|
|
133
133
|
export declare const teamSystemPermissions: readonly ["$update_team", "$delete_team", "$read_members", "$remove_members", "$invite_members"];
|
|
134
|
-
export declare const
|
|
135
|
-
export declare const
|
|
134
|
+
export declare const permissionDefinitionIdSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
|
|
135
|
+
export declare const customPermissionDefinitionIdSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
|
|
136
136
|
export declare const teamPermissionDescriptionSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
|
|
137
137
|
export declare const containedPermissionIdsSchema: yup.ArraySchema<string[] | undefined, yup.AnyObject, undefined, "">;
|
|
138
138
|
export declare const teamIdSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
|
package/dist/schema-fields.js
CHANGED
|
@@ -327,7 +327,7 @@ export const teamSystemPermissions = [
|
|
|
327
327
|
'$remove_members',
|
|
328
328
|
'$invite_members',
|
|
329
329
|
];
|
|
330
|
-
export const
|
|
330
|
+
export const permissionDefinitionIdSchema = yupString()
|
|
331
331
|
.matches(/^\$?[a-z0-9_:]+$/, 'Only lowercase letters, numbers, ":", "_" and optional "$" at the beginning are allowed')
|
|
332
332
|
.test('is-system-permission', 'System permissions must start with a dollar sign', (value, ctx) => {
|
|
333
333
|
if (!value)
|
|
@@ -338,11 +338,11 @@ export const teamPermissionDefinitionIdSchema = yupString()
|
|
|
338
338
|
return true;
|
|
339
339
|
})
|
|
340
340
|
.meta({ openapiField: { description: `The permission ID used to uniquely identify a permission. Can either be a custom permission with lowercase letters, numbers, \`:\`, and \`_\` characters, or one of the system permissions: ${teamSystemPermissions.map(x => `\`${x}\``).join(', ')}`, exampleValue: 'read_secret_info' } });
|
|
341
|
-
export const
|
|
341
|
+
export const customPermissionDefinitionIdSchema = yupString()
|
|
342
342
|
.matches(/^[a-z0-9_:]+$/, 'Only lowercase letters, numbers, ":", "_" are allowed')
|
|
343
343
|
.meta({ openapiField: { description: 'The permission ID used to uniquely identify a permission. Can only contain lowercase letters, numbers, ":", and "_" characters', exampleValue: 'read_secret_info' } });
|
|
344
344
|
export const teamPermissionDescriptionSchema = yupString().meta({ openapiField: { description: 'A human-readable description of the permission', exampleValue: 'Read secret information' } });
|
|
345
|
-
export const containedPermissionIdsSchema = yupArray(
|
|
345
|
+
export const containedPermissionIdsSchema = yupArray(permissionDefinitionIdSchema.defined()).meta({ openapiField: { description: 'The IDs of the permissions that are contained in this permission', exampleValue: ['read_public_info'] } });
|
|
346
346
|
// Teams
|
|
347
347
|
export const teamIdSchema = yupString().uuid().meta({ openapiField: { description: _idDescription('team'), exampleValue: 'ad962777-8244-496a-b6a2-e0c6a449c79e' } });
|
|
348
348
|
export const teamDisplayNameSchema = yupString().meta({ openapiField: { description: _displayNameDescription('team'), exampleValue: 'My Team' } });
|