@zap-studio/permit 0.3.1 → 0.3.3
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 +14 -4
- package/README.md +5 -3
- package/dist/errors.d.mts +13 -3
- package/dist/errors.d.mts.map +1 -1
- package/dist/errors.mjs +10 -0
- package/dist/errors.mjs.map +1 -1
- package/dist/helpers.d.mts +27 -22
- package/dist/helpers.d.mts.map +1 -1
- package/dist/helpers.mjs +7 -2
- package/dist/helpers.mjs.map +1 -1
- package/dist/index.d.mts +244 -239
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +79 -70
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.mts +105 -106
- package/dist/types.d.mts.map +1 -1
- package/package.json +6 -7
package/dist/index.d.mts
CHANGED
|
@@ -1,256 +1,261 @@
|
|
|
1
1
|
import { Actions, ConditionFn, Context, PermitConfig, Policy, PolicyFn, Resources, Role, RoleHierarchy } from "./types.mjs";
|
|
2
|
-
|
|
3
2
|
//#region src/index.d.ts
|
|
4
3
|
/**
|
|
5
|
-
* Returns a policy function that always allows the action.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```ts
|
|
9
|
-
* const policy = createPolicy({
|
|
10
|
-
* resources,
|
|
11
|
-
* actions,
|
|
12
|
-
* rules: {
|
|
13
|
-
* post: {
|
|
14
|
-
* read: allow(), // Always allow reading posts
|
|
15
|
-
* },
|
|
16
|
-
* },
|
|
17
|
-
* });
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
declare
|
|
4
|
+
* Returns a policy function that always allows the action.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* const policy = createPolicy({
|
|
9
|
+
* resources,
|
|
10
|
+
* actions,
|
|
11
|
+
* rules: {
|
|
12
|
+
* post: {
|
|
13
|
+
* read: allow(), // Always allow reading posts
|
|
14
|
+
* },
|
|
15
|
+
* },
|
|
16
|
+
* });
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
declare const allow: <TContext extends Context, TAction extends string = string, TResource = unknown>() => PolicyFn<TContext, TAction, TResource>;
|
|
21
20
|
/**
|
|
22
|
-
* Returns a policy function that always denies the action.
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```ts
|
|
26
|
-
* const policy = createPolicy({
|
|
27
|
-
* resources,
|
|
28
|
-
* actions,
|
|
29
|
-
* rules: {
|
|
30
|
-
* post: {
|
|
31
|
-
* delete: deny(), // Never allow deleting posts
|
|
32
|
-
* },
|
|
33
|
-
* },
|
|
34
|
-
* });
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
declare
|
|
21
|
+
* Returns a policy function that always denies the action.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* const policy = createPolicy({
|
|
26
|
+
* resources,
|
|
27
|
+
* actions,
|
|
28
|
+
* rules: {
|
|
29
|
+
* post: {
|
|
30
|
+
* delete: deny(), // Never allow deleting posts
|
|
31
|
+
* },
|
|
32
|
+
* },
|
|
33
|
+
* });
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
declare const deny: <TContext extends Context, TAction extends string = string, TResource = unknown>() => PolicyFn<TContext, TAction, TResource>;
|
|
38
37
|
/**
|
|
39
|
-
* Returns a policy function that allows or denies based on a condition.
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* ```ts
|
|
43
|
-
* const policy = createPolicy({
|
|
44
|
-
* resources,
|
|
45
|
-
* actions,
|
|
46
|
-
* rules: {
|
|
47
|
-
* post: {
|
|
48
|
-
* write: when((ctx, action, resource) => ctx.user.id === resource.authorId),
|
|
49
|
-
* },
|
|
50
|
-
* },
|
|
51
|
-
* });
|
|
52
|
-
* ```
|
|
53
|
-
*/
|
|
54
|
-
declare
|
|
38
|
+
* Returns a policy function that allows or denies based on a condition.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* const policy = createPolicy({
|
|
43
|
+
* resources,
|
|
44
|
+
* actions,
|
|
45
|
+
* rules: {
|
|
46
|
+
* post: {
|
|
47
|
+
* write: when((ctx, action, resource) => ctx.user.id === resource.authorId),
|
|
48
|
+
* },
|
|
49
|
+
* },
|
|
50
|
+
* });
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
declare const when: <TContext extends Context, TAction extends string = string, TResource = unknown>(condition: ConditionFn<TContext, TAction, TResource>) => PolicyFn<TContext, TAction, TResource>;
|
|
55
54
|
/**
|
|
56
|
-
* Returns a condition function that returns `true` if all conditions are met.
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
* ```ts
|
|
60
|
-
* const isOwnerAndPublished = and(
|
|
61
|
-
* (ctx, action, resource) => ctx.user.id === resource.authorId,
|
|
62
|
-
* (ctx, action, resource) => resource.status === "published"
|
|
63
|
-
* );
|
|
64
|
-
*
|
|
65
|
-
* rules: {
|
|
66
|
-
* post: {
|
|
67
|
-
* delete: when(isOwnerAndPublished),
|
|
68
|
-
* },
|
|
69
|
-
* }
|
|
70
|
-
* ```
|
|
71
|
-
*/
|
|
72
|
-
declare
|
|
55
|
+
* Returns a condition function that returns `true` if all conditions are met.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* const isOwnerAndPublished = and(
|
|
60
|
+
* (ctx, action, resource) => ctx.user.id === resource.authorId,
|
|
61
|
+
* (ctx, action, resource) => resource.status === "published"
|
|
62
|
+
* );
|
|
63
|
+
*
|
|
64
|
+
* rules: {
|
|
65
|
+
* post: {
|
|
66
|
+
* delete: when(isOwnerAndPublished),
|
|
67
|
+
* },
|
|
68
|
+
* }
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
declare const and: <TContext extends Context, TAction extends string = string, TResource = unknown>(...conditions: ConditionFn<TContext, TAction, TResource>[]) => ConditionFn<TContext, TAction, TResource>;
|
|
73
72
|
/**
|
|
74
|
-
* Returns a condition function that returns `true` if any condition is met.
|
|
75
|
-
*
|
|
76
|
-
* @example
|
|
77
|
-
* ```ts
|
|
78
|
-
* const isOwnerOrAdmin = or(
|
|
79
|
-
* (ctx, action, resource) => ctx.user.id === resource.authorId,
|
|
80
|
-
* (ctx, action, resource) => ctx.user.role === "admin"
|
|
81
|
-
* );
|
|
82
|
-
*
|
|
83
|
-
* rules: {
|
|
84
|
-
* post: {
|
|
85
|
-
* write: when(isOwnerOrAdmin),
|
|
86
|
-
* },
|
|
87
|
-
* }
|
|
88
|
-
* ```
|
|
89
|
-
*/
|
|
90
|
-
declare
|
|
73
|
+
* Returns a condition function that returns `true` if any condition is met.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* const isOwnerOrAdmin = or(
|
|
78
|
+
* (ctx, action, resource) => ctx.user.id === resource.authorId,
|
|
79
|
+
* (ctx, action, resource) => ctx.user.role === "admin"
|
|
80
|
+
* );
|
|
81
|
+
*
|
|
82
|
+
* rules: {
|
|
83
|
+
* post: {
|
|
84
|
+
* write: when(isOwnerOrAdmin),
|
|
85
|
+
* },
|
|
86
|
+
* }
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
declare const or: <TContext extends Context, TAction extends string = string, TResource = unknown>(...conditions: ConditionFn<TContext, TAction, TResource>[]) => ConditionFn<TContext, TAction, TResource>;
|
|
91
90
|
/**
|
|
92
|
-
* Returns a condition function that negates another condition.
|
|
93
|
-
*
|
|
94
|
-
* @example
|
|
95
|
-
* ```ts
|
|
96
|
-
* const isNotOwner = not((ctx, action, resource) => ctx.user.id === resource.authorId);
|
|
97
|
-
*
|
|
98
|
-
* rules: {
|
|
99
|
-
* post: {
|
|
100
|
-
* like: when(isNotOwner), // Can only like posts you don't own
|
|
101
|
-
* },
|
|
102
|
-
* }
|
|
103
|
-
* ```
|
|
104
|
-
*/
|
|
105
|
-
declare
|
|
91
|
+
* Returns a condition function that negates another condition.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```ts
|
|
95
|
+
* const isNotOwner = not((ctx, action, resource) => ctx.user.id === resource.authorId);
|
|
96
|
+
*
|
|
97
|
+
* rules: {
|
|
98
|
+
* post: {
|
|
99
|
+
* like: when(isNotOwner), // Can only like posts you don't own
|
|
100
|
+
* },
|
|
101
|
+
* }
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
declare const not: <TContext extends Context, TAction extends string = string, TResource = unknown>(condition: ConditionFn<TContext, TAction, TResource>) => ConditionFn<TContext, TAction, TResource>;
|
|
106
105
|
/**
|
|
107
|
-
* Returns a condition function that checks if a context property equals a value.
|
|
108
|
-
*
|
|
109
|
-
* @example
|
|
110
|
-
* ```ts
|
|
111
|
-
* rules: {
|
|
112
|
-
* post: {
|
|
113
|
-
* write: when(has("role", "admin")), // Only admins can write
|
|
114
|
-
* },
|
|
115
|
-
* }
|
|
116
|
-
* ```
|
|
117
|
-
*/
|
|
118
|
-
declare
|
|
106
|
+
* Returns a condition function that checks if a context property equals a value.
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```ts
|
|
110
|
+
* rules: {
|
|
111
|
+
* post: {
|
|
112
|
+
* write: when(has("role", "admin")), // Only admins can write
|
|
113
|
+
* },
|
|
114
|
+
* }
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
declare const has: <TContext extends Context, K extends keyof TContext>(key: K, value: TContext[K]) => ConditionFn<TContext>;
|
|
119
118
|
/**
|
|
120
|
-
* Collects all roles including inherited ones from a role hierarchy.
|
|
121
|
-
*
|
|
122
|
-
* @example
|
|
123
|
-
* ```ts
|
|
124
|
-
* type Role = "guest" | "user" | "admin";
|
|
125
|
-
*
|
|
126
|
-
* const hierarchy: RoleHierarchy<Role> = {
|
|
127
|
-
* guest: [],
|
|
128
|
-
* user: ["guest"],
|
|
129
|
-
* admin: ["user"],
|
|
130
|
-
* };
|
|
131
|
-
*
|
|
132
|
-
* collectInheritedRoles(["admin"], hierarchy);
|
|
133
|
-
* // Returns: Set { "admin", "user", "guest" }
|
|
134
|
-
* ```
|
|
135
|
-
*/
|
|
136
|
-
declare
|
|
119
|
+
* Collects all roles including inherited ones from a role hierarchy.
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```ts
|
|
123
|
+
* type Role = "guest" | "user" | "admin";
|
|
124
|
+
*
|
|
125
|
+
* const hierarchy: RoleHierarchy<Role> = {
|
|
126
|
+
* guest: [],
|
|
127
|
+
* user: ["guest"],
|
|
128
|
+
* admin: ["user"],
|
|
129
|
+
* };
|
|
130
|
+
*
|
|
131
|
+
* collectInheritedRoles(["admin"], hierarchy);
|
|
132
|
+
* // Returns: Set { "admin", "user", "guest" }
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
declare const collectInheritedRoles: <TRole extends Role = Role>(roles: TRole[], hierarchy: RoleHierarchy<TRole>) => Set<TRole>;
|
|
137
136
|
/**
|
|
138
|
-
*
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
* }
|
|
149
|
-
*
|
|
150
|
-
* // With hierarchy
|
|
151
|
-
* const hierarchy = {
|
|
152
|
-
* guest: [],
|
|
153
|
-
* user: ["guest"],
|
|
154
|
-
* admin: ["user"],
|
|
155
|
-
* };
|
|
156
|
-
*
|
|
157
|
-
* rules: {
|
|
158
|
-
* post: {
|
|
159
|
-
* read: when(hasRole("guest", hierarchy)), // Admins and users can also read
|
|
160
|
-
* },
|
|
161
|
-
* }
|
|
162
|
-
* ```
|
|
163
|
-
*/
|
|
164
|
-
declare function hasRole<TContext extends {
|
|
165
|
-
role: Role | Role[];
|
|
166
|
-
}, TAction extends string = string, TResource = unknown>(role: Role): ConditionFn<TContext, TAction, TResource>;
|
|
167
|
-
declare function hasRole<TContext extends {
|
|
168
|
-
role: TRole | TRole[];
|
|
169
|
-
}, TAction extends string = string, TResource = unknown, TRole extends Role = Role>(role: TRole, hierarchy: RoleHierarchy<TRole>): ConditionFn<TContext, TAction, TResource>;
|
|
137
|
+
* Call signatures for {@link hasRole}, preserving the with/without hierarchy overloads.
|
|
138
|
+
*/
|
|
139
|
+
interface HasRoleFn {
|
|
140
|
+
<TContext extends {
|
|
141
|
+
role: Role | Role[];
|
|
142
|
+
}, TAction extends string = string, TResource = unknown>(role: Role): ConditionFn<TContext, TAction, TResource>;
|
|
143
|
+
<TContext extends {
|
|
144
|
+
role: TRole | TRole[];
|
|
145
|
+
}, TAction extends string = string, TResource = unknown, TRole extends Role = Role>(role: TRole, hierarchy: RoleHierarchy<TRole>): ConditionFn<TContext, TAction, TResource>;
|
|
146
|
+
}
|
|
170
147
|
/**
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
*
|
|
199
|
-
* // Define context type
|
|
200
|
-
* type AppContext = { user: { id: string; role: string } };
|
|
201
|
-
*
|
|
202
|
-
* // Create the policy
|
|
203
|
-
* const policy = createPolicy<AppContext>({
|
|
204
|
-
* resources,
|
|
205
|
-
* actions,
|
|
206
|
-
* rules: {
|
|
207
|
-
* post: {
|
|
208
|
-
* read: when((ctx, action, resource) => resource.visibility === "public"),
|
|
209
|
-
* write: when((ctx, action, resource) => ctx.user.id === resource.authorId),
|
|
210
|
-
* delete: deny(),
|
|
211
|
-
* },
|
|
212
|
-
* comment: {
|
|
213
|
-
* read: allow(),
|
|
214
|
-
* write: when((ctx, action, resource) => ctx.user.id === resource.authorId),
|
|
215
|
-
* },
|
|
216
|
-
* },
|
|
217
|
-
* });
|
|
218
|
-
*
|
|
219
|
-
* // Check permissions
|
|
220
|
-
* const post = { id: "1", authorId: "user-1", visibility: "public" as const };
|
|
221
|
-
* await policy.can(ctx, "post:read", post); // true
|
|
222
|
-
* await policy.can(ctx, "post:write", post); // depends on ctx.user.id
|
|
223
|
-
* ```
|
|
224
|
-
*/
|
|
225
|
-
declare function createPolicy<TContext extends Context, TResources extends Resources = Resources, TActions extends Actions<TResources> = Actions<TResources>>(config: PermitConfig<TContext, TResources, TActions>): Policy<TContext, TResources, TActions>;
|
|
148
|
+
* Returns a condition function that checks if the user has a specific role.
|
|
149
|
+
* Supports role hierarchy for inherited permissions.
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```ts
|
|
153
|
+
* // Without hierarchy
|
|
154
|
+
* rules: {
|
|
155
|
+
* post: {
|
|
156
|
+
* delete: when(hasRole("admin")),
|
|
157
|
+
* },
|
|
158
|
+
* }
|
|
159
|
+
*
|
|
160
|
+
* // With hierarchy
|
|
161
|
+
* const hierarchy = {
|
|
162
|
+
* guest: [],
|
|
163
|
+
* user: ["guest"],
|
|
164
|
+
* admin: ["user"],
|
|
165
|
+
* };
|
|
166
|
+
*
|
|
167
|
+
* rules: {
|
|
168
|
+
* post: {
|
|
169
|
+
* read: when(hasRole("guest", hierarchy)), // Admins and users can also read
|
|
170
|
+
* },
|
|
171
|
+
* }
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
declare const hasRole: HasRoleFn;
|
|
226
175
|
/**
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
|
|
239
|
-
|
|
176
|
+
* Creates a type-safe policy from resource schemas, actions, and rules.
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```ts
|
|
180
|
+
* import { z } from "zod";
|
|
181
|
+
* import { createPolicy, allow, deny, when } from "@zap-studio/permit";
|
|
182
|
+
* import type { Resources, Actions } from "@zap-studio/permit/types";
|
|
183
|
+
*
|
|
184
|
+
* // Define resource schemas
|
|
185
|
+
* const resources = {
|
|
186
|
+
* post: z.object({
|
|
187
|
+
* id: z.string(),
|
|
188
|
+
* authorId: z.string(),
|
|
189
|
+
* visibility: z.enum(["public", "private"]),
|
|
190
|
+
* }),
|
|
191
|
+
* comment: z.object({
|
|
192
|
+
* id: z.string(),
|
|
193
|
+
* postId: z.string(),
|
|
194
|
+
* authorId: z.string(),
|
|
195
|
+
* }),
|
|
196
|
+
* } satisfies Resources;
|
|
197
|
+
*
|
|
198
|
+
* // Define actions per resource
|
|
199
|
+
* const actions = {
|
|
200
|
+
* post: ["read", "write", "delete"],
|
|
201
|
+
* comment: ["read", "write"],
|
|
202
|
+
* } as const satisfies Actions<typeof resources>;
|
|
203
|
+
*
|
|
204
|
+
* // Define context type
|
|
205
|
+
* type AppContext = { user: { id: string; role: string } };
|
|
206
|
+
*
|
|
207
|
+
* // Create the policy
|
|
208
|
+
* const policy = createPolicy<AppContext>({
|
|
209
|
+
* resources,
|
|
210
|
+
* actions,
|
|
211
|
+
* rules: {
|
|
212
|
+
* post: {
|
|
213
|
+
* read: when((ctx, action, resource) => resource.visibility === "public"),
|
|
214
|
+
* write: when((ctx, action, resource) => ctx.user.id === resource.authorId),
|
|
215
|
+
* delete: deny(),
|
|
216
|
+
* },
|
|
217
|
+
* comment: {
|
|
218
|
+
* read: allow(),
|
|
219
|
+
* write: when((ctx, action, resource) => ctx.user.id === resource.authorId),
|
|
220
|
+
* },
|
|
221
|
+
* },
|
|
222
|
+
* });
|
|
223
|
+
*
|
|
224
|
+
* // Check permissions
|
|
225
|
+
* const post = { id: "1", authorId: "user-1", visibility: "public" as const };
|
|
226
|
+
* await policy.can(ctx, "post:read", post); // true
|
|
227
|
+
* await policy.can(ctx, "post:write", post); // depends on ctx.user.id
|
|
228
|
+
* ```
|
|
229
|
+
*/
|
|
230
|
+
declare const createPolicy: <TContext extends Context, TResources extends Resources = Resources, TActions extends Actions<TResources> = Actions<TResources>>(config: PermitConfig<TContext, TResources, TActions>) => Policy<TContext, TResources, TActions>;
|
|
240
231
|
/**
|
|
241
|
-
* Merges multiple policies into one using "
|
|
242
|
-
* If any policy
|
|
243
|
-
*
|
|
244
|
-
* @example
|
|
245
|
-
* ```ts
|
|
246
|
-
* const
|
|
247
|
-
* const
|
|
248
|
-
*
|
|
249
|
-
* const merged =
|
|
250
|
-
* //
|
|
251
|
-
* ```
|
|
252
|
-
*/
|
|
253
|
-
declare
|
|
232
|
+
* Merges multiple policies into one using "deny-overrides" strategy.
|
|
233
|
+
* If any policy denies, the merged policy denies. All must allow for the result to allow.
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
* ```ts
|
|
237
|
+
* const basePolicy = createPolicy({ ... });
|
|
238
|
+
* const adminPolicy = createPolicy({ ... });
|
|
239
|
+
*
|
|
240
|
+
* const merged = mergePolicies(basePolicy, adminPolicy);
|
|
241
|
+
* // Both policies must allow for the action to be permitted
|
|
242
|
+
* ```
|
|
243
|
+
*/
|
|
244
|
+
declare const mergePolicies: <TContext extends Context, TResources extends Resources = Resources, TActions extends Actions<TResources> = Actions<TResources>>(...policies: Policy<TContext, TResources, TActions>[]) => Policy<TContext, TResources, TActions>;
|
|
245
|
+
/**
|
|
246
|
+
* Merges multiple policies into one using "allow-overrides" strategy.
|
|
247
|
+
* If any policy allows, the merged policy allows. All must deny for the result to deny.
|
|
248
|
+
*
|
|
249
|
+
* @example
|
|
250
|
+
* ```ts
|
|
251
|
+
* const guestPolicy = createPolicy({ ... });
|
|
252
|
+
* const memberPolicy = createPolicy({ ... });
|
|
253
|
+
*
|
|
254
|
+
* const merged = mergePoliciesAny(guestPolicy, memberPolicy);
|
|
255
|
+
* // If either policy allows, the action is permitted
|
|
256
|
+
* ```
|
|
257
|
+
*/
|
|
258
|
+
declare const mergePoliciesAny: <TContext extends Context, TResources extends Resources = Resources, TActions extends Actions<TResources> = Actions<TResources>>(...policies: Policy<TContext, TResources, TActions>[]) => Policy<TContext, TResources, TActions>;
|
|
254
259
|
//#endregion
|
|
255
260
|
export { allow, and, collectInheritedRoles, createPolicy, deny, has, hasRole, mergePolicies, mergePoliciesAny, not, or, when };
|
|
256
261
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;cAwCa,QAET,iBAAiB,SACjB,iCACA,0BACG,SAAS,UAAU,SAAS;;;;;;;;;;;;;;;;;cAoBtB,OAET,iBAAiB,SACjB,iCACA,0BACG,SAAS,UAAU,SAAS;;;;;;;;;;;;;;;;;cAoBtB,OAET,iBAAiB,SACjB,iCACA,qBAEA,WAAW,YAAY,UAAU,SAAS,eACzC,SAAS,UAAU,SAAS;;;;;;;;;;;;;;;;;;cAqBpB,MAET,iBAAiB,SACjB,iCACA,wBAEG,YAAY,YAAY,UAAU,SAAS,iBAC7C,YAAY,UAAU,SAAS;;;;;;;;;;;;;;;;;;cAqBvB,KAET,iBAAiB,SACjB,iCACA,wBAEG,YAAY,YAAY,UAAU,SAAS,iBAC7C,YAAY,UAAU,SAAS;;;;;;;;;;;;;;;cAkBvB,MAET,iBAAiB,SACjB,iCACA,qBAEA,WAAW,YAAY,UAAU,SAAS,eACzC,YAAY,UAAU,SAAS;;;;;;;;;;;;;cAgBvB,MACV,iBAAiB,SAAS,gBAAgB,UACzC,KAAK,GACL,OAAO,SAAS,OACf,YAAY;;;;;;;;;;;;;;;;;;cAqBJ,wBAAyB,cAAc,OAAO,MACzD,OAAO,SACP,WAAW,cAAc,WACxB,IAAI;;;;UAwBG;GAEN;IAAmB,MAAM,OAAO;KAChC,iCACA,qBAEA,MAAM,OACL,YAAY,UAAU,SAAS;GAEhC;IAAmB,MAAM,QAAQ;KACjC,iCACA,qBACA,cAAc,OAAO,MAErB,MAAM,OACN,WAAW,cAAc,SACxB,YAAY,UAAU,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA8BvB,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAsGT,eACX,iBAAiB,SACjB,mBAAmB,YAAY,WAC/B,iBAAiB,QAAQ,cAAc,QAAQ,aAE/C,QAAQ,aAAa,UAAU,YAAY,cAC1C,OAAO,UAAU,YAAY;;;;;;;;;;;;;;cA2InB,gBACX,iBAAiB,SACjB,mBAAmB,YAAY,WAC/B,iBAAiB,QAAQ,cAAc,QAAQ,gBAE5C,UAAU,OAAO,UAAU,YAAY,gBACzC,OAAO,UAAU,YAAY;;;;;;;;;;;;;;cAgBnB,mBACX,iBAAiB,SACjB,mBAAmB,YAAY,WAC/B,iBAAiB,QAAQ,cAAc,QAAQ,gBAE5C,UAAU,OAAO,UAAU,YAAY,gBACzC,OAAO,UAAU,YAAY"}
|