Skip to content

Commit 691f1eb

Browse files
committed
feat(permissions): Support read-all and write-all
1 parent 00c27ce commit 691f1eb

File tree

3 files changed

+25
-18
lines changed

3 files changed

+25
-18
lines changed

lib/internal/permissions.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import { type Permissions } from "../package/permissions";
33
import { permissionsJSON } from "./permissions";
44

55
describe("permissionsJSON", () => {
6-
test.each<[Permissions, Record<string, unknown>]>([
6+
test.each<[Permissions, Record<string, unknown> | string]>([
7+
["read-all", "read-all"],
8+
["write-all", "write-all"],
79
[{}, {}],
810
[{ actions: "read" }, { actions: "read" }],
911
[

lib/internal/permissions.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import type { Permissions } from "../package/permissions";
22

33
export function permissionsJSON(
44
permissions: Permissions,
5-
): Record<string, unknown> {
5+
): Record<string, unknown> | string {
6+
if (typeof permissions === "string") return permissions;
7+
68
return {
79
...(permissions.actions && { actions: permissions.actions }),
810
...(permissions.attestations && { attestations: permissions.attestations }),

lib/package/permissions.ts

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
export type Permission = "read" | "write" | "none";
22

3-
export type Permissions = {
4-
actions?: Permission;
5-
attestations?: Permission;
6-
checks?: Permission;
7-
contents?: Permission;
8-
deployments?: Permission;
9-
discussions?: Permission;
10-
idToken?: Permission;
11-
issues?: Permission;
12-
packages?: Permission;
13-
pages?: Permission;
14-
pullRequests?: Permission;
15-
repositoryProjects?: Permission;
16-
securityEvents?: Permission;
17-
statuses?: Permission;
18-
};
3+
export type Permissions =
4+
| "read-all"
5+
| "write-all"
6+
| {
7+
actions?: Permission;
8+
attestations?: Permission;
9+
checks?: Permission;
10+
contents?: Permission;
11+
deployments?: Permission;
12+
discussions?: Permission;
13+
idToken?: Permission;
14+
issues?: Permission;
15+
packages?: Permission;
16+
pages?: Permission;
17+
pullRequests?: Permission;
18+
repositoryProjects?: Permission;
19+
securityEvents?: Permission;
20+
statuses?: Permission;
21+
};

0 commit comments

Comments
 (0)