@twinfinity/permission 6.0.1 → 6.0.2

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/src/errors.ts CHANGED
@@ -1,55 +1,55 @@
1
- import type { PermissionErrorBody } from './types';
2
-
3
- export class PermissionValidationError extends Error {
4
- public readonly body: PermissionErrorBody | undefined;
5
-
6
- constructor(message: string, body?: PermissionErrorBody) {
7
- super(message);
8
- this.name = 'PermissionValidationError';
9
- this.body = body;
10
- }
11
- }
12
-
13
- export class PermissionError extends Error {
14
- public readonly status: number;
15
- public readonly statusText: string;
16
-
17
- constructor(message: string, status: number, statusText: string) {
18
- super(message);
19
- this.name = 'PermissionError';
20
- this.status = status;
21
- this.statusText = statusText;
22
- }
23
- }
24
-
25
- export class PermissionNotFoundError extends Error {
26
- public readonly body: PermissionErrorBody | undefined;
27
-
28
- constructor(message: string, body?: PermissionErrorBody) {
29
- super(message);
30
- this.name = 'PermissionNotFoundError';
31
- this.body = body;
32
- }
33
- }
34
-
35
- export class PermissionForbiddenError extends Error {
36
- public readonly body: PermissionErrorBody | undefined;
37
-
38
- constructor(message: string, body?: PermissionErrorBody) {
39
- super(message);
40
- this.name = 'PermissionForbiddenError';
41
- this.body = body;
42
- }
43
- }
44
-
45
- export class PermissionConflictError<T = unknown> extends Error {
46
- public readonly data: T | undefined;
47
- public readonly body: PermissionErrorBody | undefined;
48
-
49
- constructor(message: string, data: T | undefined, body?: PermissionErrorBody) {
50
- super(message);
51
- this.name = 'PermissionConflictError';
52
- this.data = data;
53
- this.body = body;
54
- }
55
- }
1
+ import type { PermissionErrorBody } from './types';
2
+
3
+ export class PermissionValidationError extends Error {
4
+ public readonly body: PermissionErrorBody | undefined;
5
+
6
+ constructor(message: string, body?: PermissionErrorBody) {
7
+ super(message);
8
+ this.name = 'PermissionValidationError';
9
+ this.body = body;
10
+ }
11
+ }
12
+
13
+ export class PermissionError extends Error {
14
+ public readonly status: number;
15
+ public readonly statusText: string;
16
+
17
+ constructor(message: string, status: number, statusText: string) {
18
+ super(message);
19
+ this.name = 'PermissionError';
20
+ this.status = status;
21
+ this.statusText = statusText;
22
+ }
23
+ }
24
+
25
+ export class PermissionNotFoundError extends Error {
26
+ public readonly body: PermissionErrorBody | undefined;
27
+
28
+ constructor(message: string, body?: PermissionErrorBody) {
29
+ super(message);
30
+ this.name = 'PermissionNotFoundError';
31
+ this.body = body;
32
+ }
33
+ }
34
+
35
+ export class PermissionForbiddenError extends Error {
36
+ public readonly body: PermissionErrorBody | undefined;
37
+
38
+ constructor(message: string, body?: PermissionErrorBody) {
39
+ super(message);
40
+ this.name = 'PermissionForbiddenError';
41
+ this.body = body;
42
+ }
43
+ }
44
+
45
+ export class PermissionConflictError<T = unknown> extends Error {
46
+ public readonly data: T | undefined;
47
+ public readonly body: PermissionErrorBody | undefined;
48
+
49
+ constructor(message: string, data: T | undefined, body?: PermissionErrorBody) {
50
+ super(message);
51
+ this.name = 'PermissionConflictError';
52
+ this.data = data;
53
+ this.body = body;
54
+ }
55
+ }
package/src/index.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { type IPermissionClient, PermissionClient } from './PermissionClient';
2
- export * from './types';
3
- export * from './errors';
1
+ export { type IPermissionClient, PermissionClient } from './PermissionClient';
2
+ export * from './types';
3
+ export * from './errors';
package/src/types.ts CHANGED
@@ -1,87 +1,87 @@
1
- export interface Pagination {
2
- limit: number;
3
- maxLimit: number;
4
- nextPage: string | null;
5
- }
6
-
7
- export interface PaginatedResponse<T> {
8
- data: T[];
9
- pagination: Pagination;
10
- /**
11
- * The caller's effective permissions on the parent resource that governs every item in the
12
- * page — populated by endpoints where the authorization subject is shared across all rows
13
- * (currently `GET /groups/{id}/members`, where this reflects the caller's mask on the
14
- * group's management scope). Absent for endpoints whose items each have their own
15
- * authorization subject.
16
- */
17
- callerPermissions?: PrincipalPermission[];
18
- }
19
-
20
- export interface User {
21
- id: string;
22
- username: string;
23
- email: string;
24
- firstName: string | null;
25
- lastName: string | null;
26
- }
27
-
28
- /**
29
- * A user returned from group-membership endpoints. Extends {@link User} with the target user's
30
- * effective permissions on the containing group's management scope, reflecting the post-mutation
31
- * state after an add/remove.
32
- */
33
- export interface GroupMember extends User {
34
- permissions: PrincipalPermission[];
35
- }
36
-
37
- export enum PrincipalType {
38
- Unknown = 'Unknown',
39
- DomainGroup = 'DomainGroup',
40
- Group = 'Group'
41
- }
42
-
43
- /**
44
- * The permission bits a subject can hold on a group's management scope.
45
- *
46
- * - `View` — can see the group and its basic metadata (title, description, display name).
47
- * - `Edit` — can create and modify groups.
48
- * - `Delete` — can delete the group.
49
- * - `ViewMembers` — can list the group's members.
50
- * - `ManagePermissions` — can update permissions connected to the group (e.g. grant another user Edit on it).
51
- */
52
- export type PrincipalPermission = 'View' | 'Edit' | 'Delete' | 'ViewMembers' | 'ManagePermissions';
53
-
54
- export interface Group {
55
- id: string;
56
- ownerSystem: string;
57
- principalType: PrincipalType;
58
- title: string;
59
- displayName: string | null;
60
- description: string | null;
61
- etag: string;
62
- isEditable: boolean;
63
- /**
64
- * The effective permission bits the relevant subject holds on this group's management scope.
65
- * The subject is the caller on most endpoints, and the target user on `GET /users/{id}/groups`.
66
- * An empty array means no permissions are granted.
67
- */
68
- permissions: PrincipalPermission[];
69
- }
70
-
71
- export interface PutGroupRequest {
72
- /** Title for the group. Used on create; ignored on update (title is immutable). */
73
- title: string;
74
- displayName?: string | null;
75
- description?: string | null;
76
- etag?: string | null;
77
- }
78
-
79
- export interface DeleteGroupRequest {
80
- etag: string;
81
- }
82
-
83
- export interface PermissionErrorBody {
84
- detail: string;
85
- cause: string;
86
- item?: { kind: string; id?: string } | null;
87
- }
1
+ export interface Pagination {
2
+ limit: number;
3
+ maxLimit: number;
4
+ nextPage: string | null;
5
+ }
6
+
7
+ export interface PaginatedResponse<T> {
8
+ data: T[];
9
+ pagination: Pagination;
10
+ /**
11
+ * The caller's effective permissions on the parent resource that governs every item in the
12
+ * page — populated by endpoints where the authorization subject is shared across all rows
13
+ * (currently `GET /groups/{id}/members`, where this reflects the caller's mask on the
14
+ * group's management scope). Absent for endpoints whose items each have their own
15
+ * authorization subject.
16
+ */
17
+ callerPermissions?: PrincipalPermission[];
18
+ }
19
+
20
+ export interface User {
21
+ id: string;
22
+ username: string;
23
+ email: string;
24
+ firstName: string | null;
25
+ lastName: string | null;
26
+ }
27
+
28
+ /**
29
+ * A user returned from group-membership endpoints. Extends {@link User} with the target user's
30
+ * effective permissions on the containing group's management scope, reflecting the post-mutation
31
+ * state after an add/remove.
32
+ */
33
+ export interface GroupMember extends User {
34
+ permissions: PrincipalPermission[];
35
+ }
36
+
37
+ export enum PrincipalType {
38
+ Unknown = 'Unknown',
39
+ DomainGroup = 'DomainGroup',
40
+ Group = 'Group'
41
+ }
42
+
43
+ /**
44
+ * The permission bits a subject can hold on a group's management scope.
45
+ *
46
+ * - `View` — can see the group and its basic metadata (title, description, display name).
47
+ * - `Edit` — can create and modify groups.
48
+ * - `Delete` — can delete the group.
49
+ * - `ViewMembers` — can list the group's members.
50
+ * - `ManagePermissions` — can update permissions connected to the group (e.g. grant another user Edit on it).
51
+ */
52
+ export type PrincipalPermission = 'View' | 'Edit' | 'Delete' | 'ViewMembers' | 'ManagePermissions';
53
+
54
+ export interface Group {
55
+ id: string;
56
+ ownerSystem: string;
57
+ principalType: PrincipalType;
58
+ title: string;
59
+ displayName: string | null;
60
+ description: string | null;
61
+ etag: string;
62
+ isEditable: boolean;
63
+ /**
64
+ * The effective permission bits the relevant subject holds on this group's management scope.
65
+ * The subject is the caller on most endpoints, and the target user on `GET /users/{id}/groups`.
66
+ * An empty array means no permissions are granted.
67
+ */
68
+ permissions: PrincipalPermission[];
69
+ }
70
+
71
+ export interface PutGroupRequest {
72
+ /** Title for the group. Used on create; ignored on update (title is immutable). */
73
+ title: string;
74
+ displayName?: string | null;
75
+ description?: string | null;
76
+ etag?: string | null;
77
+ }
78
+
79
+ export interface DeleteGroupRequest {
80
+ etag: string;
81
+ }
82
+
83
+ export interface PermissionErrorBody {
84
+ detail: string;
85
+ cause: string;
86
+ item?: { kind: string; id?: string } | null;
87
+ }