@foundrykit/permissions-plugin 0.0.0-stage → 0.1.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/README.md +107 -2
- package/dist/access.d.ts +38 -0
- package/dist/access.js +119 -0
- package/dist/access.js.map +1 -0
- package/dist/audit.d.ts +25 -0
- package/dist/audit.js +95 -0
- package/dist/audit.js.map +1 -0
- package/dist/collections/PermissionOverrides.d.ts +6 -0
- package/dist/collections/PermissionOverrides.js +152 -0
- package/dist/collections/PermissionOverrides.js.map +1 -0
- package/dist/collections/Roles.d.ts +6 -0
- package/dist/collections/Roles.js +106 -0
- package/dist/collections/Roles.js.map +1 -0
- package/dist/components/NavLinks.d.ts +3 -0
- package/dist/components/NavLinks.js +20 -0
- package/dist/components/NavLinks.js.map +1 -0
- package/dist/components/PublishButtonGate.d.ts +6 -0
- package/dist/components/PublishButtonGate.js +12 -0
- package/dist/components/PublishButtonGate.js.map +1 -0
- package/dist/components/RolesMatrix.d.ts +3 -0
- package/dist/components/RolesMatrix.js +324 -0
- package/dist/components/RolesMatrix.js.map +1 -0
- package/dist/components/UsersTable.d.ts +3 -0
- package/dist/components/UsersTable.js +390 -0
- package/dist/components/UsersTable.js.map +1 -0
- package/dist/components/api.d.ts +2 -0
- package/dist/components/api.js +17 -0
- package/dist/components/api.js.map +1 -0
- package/dist/components/index.scss +335 -0
- package/dist/endpoints/resetToRole.d.ts +4 -0
- package/dist/endpoints/resetToRole.js +53 -0
- package/dist/endpoints/resetToRole.js.map +1 -0
- package/dist/exports/client.d.ts +1 -0
- package/dist/exports/client.js +3 -0
- package/dist/exports/client.js.map +1 -0
- package/dist/exports/rsc.d.ts +4 -0
- package/dist/exports/rsc.js +6 -0
- package/dist/exports/rsc.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +194 -0
- package/dist/index.js.map +1 -0
- package/dist/registry.d.ts +5 -0
- package/dist/registry.js +87 -0
- package/dist/registry.js.map +1 -0
- package/dist/registry.test.d.ts +1 -0
- package/dist/resolve.d.ts +21 -0
- package/dist/resolve.js +33 -0
- package/dist/resolve.js.map +1 -0
- package/dist/resolve.test.d.ts +1 -0
- package/dist/rules.d.ts +5 -0
- package/dist/rules.js +20 -0
- package/dist/rules.js.map +1 -0
- package/dist/types.d.ts +59 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/users.d.ts +3 -0
- package/dist/users.js +142 -0
- package/dist/users.js.map +1 -0
- package/dist/views/PermissionsLayout.d.ts +11 -0
- package/dist/views/PermissionsLayout.js +69 -0
- package/dist/views/PermissionsLayout.js.map +1 -0
- package/dist/views/RolesView.d.ts +2 -0
- package/dist/views/RolesView.js +20 -0
- package/dist/views/RolesView.js.map +1 -0
- package/dist/views/UsersView.d.ts +2 -0
- package/dist/views/UsersView.js +14 -0
- package/dist/views/UsersView.js.map +1 -0
- package/dist/views/data.d.ts +36 -0
- package/dist/views/data.js +58 -0
- package/dist/views/data.js.map +1 -0
- package/package.json +107 -4
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
// Uses the admin theme's variables so it follows light/dark mode.
|
|
2
|
+
|
|
3
|
+
.perm {
|
|
4
|
+
padding-bottom: calc(var(--base) * 4);
|
|
5
|
+
|
|
6
|
+
table {
|
|
7
|
+
border-collapse: collapse;
|
|
8
|
+
width: 100%;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
th,
|
|
12
|
+
td {
|
|
13
|
+
border-bottom: 1px solid var(--theme-elevation-100);
|
|
14
|
+
padding: calc(var(--base) * 0.4) calc(var(--base) * 0.5);
|
|
15
|
+
text-align: left;
|
|
16
|
+
vertical-align: middle;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
thead th {
|
|
20
|
+
color: var(--theme-elevation-500);
|
|
21
|
+
font-weight: 500;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
code {
|
|
25
|
+
color: var(--theme-elevation-500);
|
|
26
|
+
font-size: 0.85em;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
input[type='checkbox'] {
|
|
30
|
+
accent-color: var(--theme-success-500);
|
|
31
|
+
cursor: pointer;
|
|
32
|
+
height: 16px;
|
|
33
|
+
width: 16px;
|
|
34
|
+
|
|
35
|
+
&:disabled {
|
|
36
|
+
cursor: not-allowed;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
select,
|
|
41
|
+
input:not([type]) {
|
|
42
|
+
background: var(--theme-input-bg);
|
|
43
|
+
border: 1px solid var(--theme-elevation-150);
|
|
44
|
+
border-radius: var(--style-radius-s);
|
|
45
|
+
color: var(--theme-text);
|
|
46
|
+
padding: calc(var(--base) * 0.3) calc(var(--base) * 0.5);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.perm-matrix button:not(.btn),
|
|
51
|
+
.perm-users__name,
|
|
52
|
+
.perm-side__header button {
|
|
53
|
+
background: none;
|
|
54
|
+
border: 0;
|
|
55
|
+
color: inherit;
|
|
56
|
+
cursor: pointer;
|
|
57
|
+
font: inherit;
|
|
58
|
+
padding: 0;
|
|
59
|
+
|
|
60
|
+
&:disabled {
|
|
61
|
+
cursor: not-allowed;
|
|
62
|
+
opacity: 0.5;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.perm__tabs {
|
|
67
|
+
border-bottom: 1px solid var(--theme-elevation-100);
|
|
68
|
+
display: flex;
|
|
69
|
+
gap: calc(var(--base) * 1.5);
|
|
70
|
+
margin-bottom: calc(var(--base) * 1.5);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.perm__tab {
|
|
74
|
+
border-bottom: 2px solid transparent;
|
|
75
|
+
color: var(--theme-elevation-500);
|
|
76
|
+
padding: calc(var(--base) * 0.5) 0;
|
|
77
|
+
text-decoration: none;
|
|
78
|
+
|
|
79
|
+
&[aria-current='page'] {
|
|
80
|
+
border-color: var(--theme-text);
|
|
81
|
+
color: var(--theme-text);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.perm-matrix__add {
|
|
86
|
+
align-items: center;
|
|
87
|
+
display: flex;
|
|
88
|
+
gap: calc(var(--base) * 0.5);
|
|
89
|
+
margin-bottom: var(--base);
|
|
90
|
+
|
|
91
|
+
.btn {
|
|
92
|
+
margin: 0;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.perm-matrix__scroll {
|
|
97
|
+
overflow-x: auto;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.perm-matrix {
|
|
101
|
+
td {
|
|
102
|
+
text-align: center;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
thead th:not(:first-child) {
|
|
106
|
+
min-width: 140px;
|
|
107
|
+
text-align: center;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
tbody th {
|
|
111
|
+
font-weight: 400;
|
|
112
|
+
padding-left: calc(var(--base) * 1.5);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.perm-matrix__area {
|
|
117
|
+
background: var(--theme-elevation-50);
|
|
118
|
+
|
|
119
|
+
th {
|
|
120
|
+
font-weight: 600 !important;
|
|
121
|
+
padding-left: calc(var(--base) * 0.5) !important;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.perm-matrix__role-name {
|
|
126
|
+
font-weight: 600;
|
|
127
|
+
text-align: center;
|
|
128
|
+
width: 100%;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.perm-matrix__role-meta {
|
|
132
|
+
font-size: 0.85em;
|
|
133
|
+
margin-top: calc(var(--base) * 0.25);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.perm-matrix__role-actions {
|
|
137
|
+
display: flex;
|
|
138
|
+
font-size: 0.85em;
|
|
139
|
+
gap: calc(var(--base) * 0.5);
|
|
140
|
+
justify-content: center;
|
|
141
|
+
margin-top: calc(var(--base) * 0.25);
|
|
142
|
+
|
|
143
|
+
button {
|
|
144
|
+
text-decoration: underline;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.perm-matrix__save {
|
|
149
|
+
align-items: center;
|
|
150
|
+
background: var(--theme-elevation-0);
|
|
151
|
+
border: 1px solid var(--theme-elevation-150);
|
|
152
|
+
border-radius: var(--style-radius-m);
|
|
153
|
+
bottom: var(--base);
|
|
154
|
+
box-shadow: 0 4px 16px rgb(0 0 0 / 12%);
|
|
155
|
+
display: flex;
|
|
156
|
+
gap: var(--base);
|
|
157
|
+
justify-content: space-between;
|
|
158
|
+
margin-top: var(--base);
|
|
159
|
+
padding: calc(var(--base) * 0.75) var(--base);
|
|
160
|
+
position: sticky;
|
|
161
|
+
|
|
162
|
+
ul {
|
|
163
|
+
margin: 0;
|
|
164
|
+
padding-left: var(--base);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.btn {
|
|
168
|
+
margin: 0;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.perm-matrix__save-actions {
|
|
173
|
+
display: flex;
|
|
174
|
+
flex-shrink: 0;
|
|
175
|
+
gap: calc(var(--base) * 0.5);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.perm-users__filters {
|
|
179
|
+
align-items: center;
|
|
180
|
+
display: flex;
|
|
181
|
+
gap: calc(var(--base) * 1.5);
|
|
182
|
+
margin-bottom: var(--base);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.perm-users__name {
|
|
186
|
+
align-items: center;
|
|
187
|
+
display: inline-flex;
|
|
188
|
+
font-weight: 500;
|
|
189
|
+
gap: calc(var(--base) * 0.5);
|
|
190
|
+
text-align: left;
|
|
191
|
+
|
|
192
|
+
&:hover {
|
|
193
|
+
text-decoration: underline;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.perm-users__avatar {
|
|
198
|
+
align-items: center;
|
|
199
|
+
background: var(--theme-elevation-150);
|
|
200
|
+
border-radius: 50%;
|
|
201
|
+
display: inline-flex;
|
|
202
|
+
flex-shrink: 0;
|
|
203
|
+
font-size: 0.75em;
|
|
204
|
+
height: 28px;
|
|
205
|
+
justify-content: center;
|
|
206
|
+
width: 28px;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.perm-users__selected {
|
|
210
|
+
background: var(--theme-elevation-50);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.perm-side {
|
|
214
|
+
background: var(--theme-bg);
|
|
215
|
+
border-left: 1px solid var(--theme-elevation-150);
|
|
216
|
+
bottom: 0;
|
|
217
|
+
box-shadow: -8px 0 24px rgb(0 0 0 / 10%);
|
|
218
|
+
overflow-y: auto;
|
|
219
|
+
padding: 0 calc(var(--base) * 1.5);
|
|
220
|
+
position: fixed;
|
|
221
|
+
right: 0;
|
|
222
|
+
top: 0;
|
|
223
|
+
width: min(560px, 100vw);
|
|
224
|
+
z-index: 30;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
.perm-side__header {
|
|
228
|
+
align-items: center;
|
|
229
|
+
background: var(--theme-bg);
|
|
230
|
+
border-bottom: 1px solid var(--theme-elevation-100);
|
|
231
|
+
display: flex;
|
|
232
|
+
justify-content: space-between;
|
|
233
|
+
padding: var(--base) 0;
|
|
234
|
+
position: sticky;
|
|
235
|
+
top: 0;
|
|
236
|
+
z-index: 1;
|
|
237
|
+
|
|
238
|
+
h3 {
|
|
239
|
+
margin: 0;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
.perm-panel {
|
|
244
|
+
padding: var(--base) 0 calc(var(--base) * 2);
|
|
245
|
+
|
|
246
|
+
select {
|
|
247
|
+
background: var(--theme-input-bg);
|
|
248
|
+
border: 1px solid var(--theme-elevation-150);
|
|
249
|
+
border-radius: var(--style-radius-s);
|
|
250
|
+
color: var(--theme-text);
|
|
251
|
+
margin-left: calc(var(--base) * 0.5);
|
|
252
|
+
padding: calc(var(--base) * 0.3) calc(var(--base) * 0.5);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
h4 {
|
|
256
|
+
margin: calc(var(--base) * 1.5) 0 calc(var(--base) * 0.5);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.btn {
|
|
260
|
+
margin: 0;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
.perm-panel__toolbar {
|
|
265
|
+
align-items: center;
|
|
266
|
+
display: flex;
|
|
267
|
+
flex-wrap: wrap;
|
|
268
|
+
gap: var(--base);
|
|
269
|
+
justify-content: space-between;
|
|
270
|
+
margin-top: var(--base);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
.perm-panel__row {
|
|
274
|
+
align-items: center;
|
|
275
|
+
border-bottom: 1px solid var(--theme-elevation-100);
|
|
276
|
+
display: flex;
|
|
277
|
+
gap: var(--base);
|
|
278
|
+
justify-content: space-between;
|
|
279
|
+
padding: calc(var(--base) * 0.4) 0;
|
|
280
|
+
|
|
281
|
+
small {
|
|
282
|
+
color: var(--theme-elevation-500);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
.perm-panel__row--inherited > div:first-child {
|
|
287
|
+
color: var(--theme-elevation-500);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
.perm-panel__states {
|
|
291
|
+
border: 1px solid var(--theme-elevation-150);
|
|
292
|
+
border-radius: var(--style-radius-s);
|
|
293
|
+
display: inline-flex;
|
|
294
|
+
flex-shrink: 0;
|
|
295
|
+
overflow: hidden;
|
|
296
|
+
|
|
297
|
+
button {
|
|
298
|
+
background: none;
|
|
299
|
+
border: 0;
|
|
300
|
+
color: var(--theme-elevation-600);
|
|
301
|
+
cursor: pointer;
|
|
302
|
+
font: inherit;
|
|
303
|
+
padding: calc(var(--base) * 0.25) calc(var(--base) * 0.6);
|
|
304
|
+
|
|
305
|
+
& + button {
|
|
306
|
+
border-left: 1px solid var(--theme-elevation-150);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
&[aria-pressed='true'] {
|
|
310
|
+
background: var(--theme-elevation-800);
|
|
311
|
+
color: var(--theme-elevation-0);
|
|
312
|
+
opacity: 1;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
&:disabled:not([aria-pressed='true']) {
|
|
316
|
+
cursor: not-allowed;
|
|
317
|
+
opacity: 0.4;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
.perm-panel__history ul {
|
|
323
|
+
list-style: none;
|
|
324
|
+
margin: 0;
|
|
325
|
+
padding: 0;
|
|
326
|
+
|
|
327
|
+
li {
|
|
328
|
+
border-bottom: 1px solid var(--theme-elevation-100);
|
|
329
|
+
padding: calc(var(--base) * 0.4) 0;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
small {
|
|
333
|
+
color: var(--theme-elevation-500);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { getOverrides, hasPermission, OVERRIDES_SLUG } from '../access.js';
|
|
2
|
+
import { PART_OF_CHANGE, writeAudit } from '../audit.js';
|
|
3
|
+
import { MANAGE_PERMISSION } from '../registry.js';
|
|
4
|
+
import { assertCanGrant, assertNotSelf } from '../rules.js';
|
|
5
|
+
export const RESET_PATH = '/permissions/reset/:id';
|
|
6
|
+
/** Clears every override on a user, logged as one "Reset to role" entry. */ export const resetToRoleHandler = async (req)=>{
|
|
7
|
+
if (!await hasPermission(req, MANAGE_PERMISSION)) {
|
|
8
|
+
return Response.json({
|
|
9
|
+
errors: [
|
|
10
|
+
{
|
|
11
|
+
message: 'Forbidden'
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
}, {
|
|
15
|
+
status: 403
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
const id = req.routeParams?.id;
|
|
19
|
+
assertNotSelf(req, id);
|
|
20
|
+
const overrides = await getOverrides(req.payload, id, req);
|
|
21
|
+
// Lifting a deny can hand the permission back, which counts as granting it.
|
|
22
|
+
await assertCanGrant(req, overrides.filter((o)=>o.effect === 'deny').map((o)=>o.permission));
|
|
23
|
+
if (overrides.length) {
|
|
24
|
+
await req.payload.delete({
|
|
25
|
+
collection: OVERRIDES_SLUG,
|
|
26
|
+
context: {
|
|
27
|
+
[PART_OF_CHANGE]: true
|
|
28
|
+
},
|
|
29
|
+
overrideAccess: true,
|
|
30
|
+
req,
|
|
31
|
+
where: {
|
|
32
|
+
user: {
|
|
33
|
+
equals: id
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
await writeAudit(req, {
|
|
38
|
+
action: 'user.reset',
|
|
39
|
+
after: [],
|
|
40
|
+
before: overrides.map(({ effect, permission })=>({
|
|
41
|
+
effect,
|
|
42
|
+
permission
|
|
43
|
+
})),
|
|
44
|
+
summary: `Reset to role: ${overrides.length} override${overrides.length === 1 ? '' : 's'} cleared`,
|
|
45
|
+
user: id
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return Response.json({
|
|
49
|
+
removed: overrides.length
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=resetToRole.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/endpoints/resetToRole.ts"],"sourcesContent":["import type { PayloadHandler } from 'payload'\n\nimport { getOverrides, hasPermission, OVERRIDES_SLUG } from '../access.js'\nimport { PART_OF_CHANGE, writeAudit } from '../audit.js'\nimport { MANAGE_PERMISSION } from '../registry.js'\nimport { assertCanGrant, assertNotSelf } from '../rules.js'\n\nexport const RESET_PATH = '/permissions/reset/:id'\n\n/** Clears every override on a user, logged as one \"Reset to role\" entry. */\nexport const resetToRoleHandler: PayloadHandler = async (req) => {\n if (!(await hasPermission(req, MANAGE_PERMISSION))) {\n return Response.json({ errors: [{ message: 'Forbidden' }] }, { status: 403 })\n }\n const id = req.routeParams?.id as string\n assertNotSelf(req, id)\n\n const overrides = await getOverrides(req.payload, id, req)\n // Lifting a deny can hand the permission back, which counts as granting it.\n await assertCanGrant(\n req,\n overrides.filter((o) => o.effect === 'deny').map((o) => o.permission),\n )\n if (overrides.length) {\n await req.payload.delete({\n collection: OVERRIDES_SLUG,\n context: { [PART_OF_CHANGE]: true },\n overrideAccess: true,\n req,\n where: { user: { equals: id } },\n })\n await writeAudit(req, {\n action: 'user.reset',\n after: [],\n before: overrides.map(({ effect, permission }) => ({ effect, permission })),\n summary: `Reset to role: ${overrides.length} override${overrides.length === 1 ? '' : 's'} cleared`,\n user: id,\n })\n }\n return Response.json({ removed: overrides.length })\n}\n"],"names":["getOverrides","hasPermission","OVERRIDES_SLUG","PART_OF_CHANGE","writeAudit","MANAGE_PERMISSION","assertCanGrant","assertNotSelf","RESET_PATH","resetToRoleHandler","req","Response","json","errors","message","status","id","routeParams","overrides","payload","filter","o","effect","map","permission","length","delete","collection","context","overrideAccess","where","user","equals","action","after","before","summary","removed"],"mappings":"AAEA,SAASA,YAAY,EAAEC,aAAa,EAAEC,cAAc,QAAQ,eAAc;AAC1E,SAASC,cAAc,EAAEC,UAAU,QAAQ,cAAa;AACxD,SAASC,iBAAiB,QAAQ,iBAAgB;AAClD,SAASC,cAAc,EAAEC,aAAa,QAAQ,cAAa;AAE3D,OAAO,MAAMC,aAAa,yBAAwB;AAElD,0EAA0E,GAC1E,OAAO,MAAMC,qBAAqC,OAAOC;IACvD,IAAI,CAAE,MAAMT,cAAcS,KAAKL,oBAAqB;QAClD,OAAOM,SAASC,IAAI,CAAC;YAAEC,QAAQ;gBAAC;oBAAEC,SAAS;gBAAY;aAAE;QAAC,GAAG;YAAEC,QAAQ;QAAI;IAC7E;IACA,MAAMC,KAAKN,IAAIO,WAAW,EAAED;IAC5BT,cAAcG,KAAKM;IAEnB,MAAME,YAAY,MAAMlB,aAAaU,IAAIS,OAAO,EAAEH,IAAIN;IACtD,4EAA4E;IAC5E,MAAMJ,eACJI,KACAQ,UAAUE,MAAM,CAAC,CAACC,IAAMA,EAAEC,MAAM,KAAK,QAAQC,GAAG,CAAC,CAACF,IAAMA,EAAEG,UAAU;IAEtE,IAAIN,UAAUO,MAAM,EAAE;QACpB,MAAMf,IAAIS,OAAO,CAACO,MAAM,CAAC;YACvBC,YAAYzB;YACZ0B,SAAS;gBAAE,CAACzB,eAAe,EAAE;YAAK;YAClC0B,gBAAgB;YAChBnB;YACAoB,OAAO;gBAAEC,MAAM;oBAAEC,QAAQhB;gBAAG;YAAE;QAChC;QACA,MAAMZ,WAAWM,KAAK;YACpBuB,QAAQ;YACRC,OAAO,EAAE;YACTC,QAAQjB,UAAUK,GAAG,CAAC,CAAC,EAAED,MAAM,EAAEE,UAAU,EAAE,GAAM,CAAA;oBAAEF;oBAAQE;gBAAW,CAAA;YACxEY,SAAS,CAAC,eAAe,EAAElB,UAAUO,MAAM,CAAC,SAAS,EAAEP,UAAUO,MAAM,KAAK,IAAI,KAAK,IAAI,QAAQ,CAAC;YAClGM,MAAMf;QACR;IACF;IACA,OAAOL,SAASC,IAAI,CAAC;QAAEyB,SAASnB,UAAUO,MAAM;IAAC;AACnD,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/exports/client.ts"],"sourcesContent":["export {}\n"],"names":[],"mappings":"AAAA,WAAS"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/exports/rsc.ts"],"sourcesContent":["export { NavLinks } from '../components/NavLinks.js'\nexport { PublishButtonGate } from '../components/PublishButtonGate.js'\nexport { RolesView } from '../views/RolesView.js'\nexport { UsersView } from '../views/UsersView.js'\n"],"names":["NavLinks","PublishButtonGate","RolesView","UsersView"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,4BAA2B;AACpD,SAASC,iBAAiB,QAAQ,qCAAoC;AACtE,SAASC,SAAS,QAAQ,wBAAuB;AACjD,SAASC,SAAS,QAAQ,wBAAuB"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Config } from 'payload';
|
|
2
|
+
import type { PermissionsPluginConfig } from './types.js';
|
|
3
|
+
export { AUDIT_SLUG, computePermissions, getPermissions, hasPermission, OVERRIDES_SLUG, requirePermission, ROLES_SLUG, } from './access.js';
|
|
4
|
+
export { MANAGE_PERMISSION } from './registry.js';
|
|
5
|
+
export { redundantOverrides, resolvePermission, resolvePermissions } from './resolve.js';
|
|
6
|
+
export type { Area, AreaConfig, Permission, PermissionsPluginConfig, StandardAction, } from './types.js';
|
|
7
|
+
export declare const permissionsPlugin: (pluginOptions?: PermissionsPluginConfig) => (config: Config) => Config;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { APIError } from 'payload';
|
|
2
|
+
import { AUDIT_SLUG, gateAccess, hasPermission, isCMSUser, markActive, OVERRIDES_SLUG, ROLES_SLUG } from './access.js';
|
|
3
|
+
import { createAuditCollection } from './audit.js';
|
|
4
|
+
import { createOverridesCollection } from './collections/PermissionOverrides.js';
|
|
5
|
+
import { createRolesCollection } from './collections/Roles.js';
|
|
6
|
+
import { RESET_PATH, resetToRoleHandler } from './endpoints/resetToRole.js';
|
|
7
|
+
import { buildRegistry } from './registry.js';
|
|
8
|
+
import { extendUsersCollection } from './users.js';
|
|
9
|
+
export { AUDIT_SLUG, computePermissions, getPermissions, hasPermission, OVERRIDES_SLUG, requirePermission, ROLES_SLUG } from './access.js';
|
|
10
|
+
export { MANAGE_PERMISSION } from './registry.js';
|
|
11
|
+
export { redundantOverrides, resolvePermission, resolvePermissions } from './resolve.js';
|
|
12
|
+
/** Publishing (moving `_status` to published) needs `area.publish` on top of create/edit. */ const guardPublish = (key)=>async ({ data, originalDoc, req })=>{
|
|
13
|
+
// Payload marks every draft save `_status: 'draft'` before hooks run, so anything else that
|
|
14
|
+
// asks to publish, or lands on a published document, changes what's live.
|
|
15
|
+
const publishing = data._status !== 'draft' && (data._status === 'published' || originalDoc?._status === 'published');
|
|
16
|
+
// Draft saves also send `_status: 'draft'`; only REST and GraphQL say which is which.
|
|
17
|
+
// ponytail: local API unpublishes aren't checked, since hooks can't tell them from draft saves
|
|
18
|
+
const unpublishing = data._status === 'draft' && originalDoc?._status === 'published' && req.payloadAPI !== 'local' && req.query?.draft !== 'true';
|
|
19
|
+
if (!publishing && !unpublishing) {
|
|
20
|
+
return data;
|
|
21
|
+
}
|
|
22
|
+
if (isCMSUser(req.payload, req.user) && !await hasPermission(req, key)) {
|
|
23
|
+
const verb = publishing ? 'publish' : 'unpublish';
|
|
24
|
+
throw new APIError(`You don't have permission to ${verb} this.`, 403, undefined, true);
|
|
25
|
+
}
|
|
26
|
+
return data;
|
|
27
|
+
};
|
|
28
|
+
const hasKey = (area, key)=>area.permissions.some((p)=>p.key === key);
|
|
29
|
+
const RSC = '@foundrykit/permissions-plugin/rsc';
|
|
30
|
+
/** Server component that hides the (un)publish button from people without `key`. */ const publishButton = (key, kind = 'publish')=>({
|
|
31
|
+
path: `${RSC}#PublishButtonGate`,
|
|
32
|
+
serverProps: {
|
|
33
|
+
kind,
|
|
34
|
+
permission: key
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
const gateCollection = (collection, area)=>({
|
|
38
|
+
...collection,
|
|
39
|
+
access: {
|
|
40
|
+
...collection.access,
|
|
41
|
+
create: gateAccess(`${area.slug}.create`, collection.access?.create),
|
|
42
|
+
delete: gateAccess(`${area.slug}.delete`, collection.access?.delete),
|
|
43
|
+
read: gateAccess(`${area.slug}.read`, collection.access?.read),
|
|
44
|
+
update: gateAccess(`${area.slug}.edit`, collection.access?.update)
|
|
45
|
+
},
|
|
46
|
+
admin: hasKey(area, `${area.slug}.publish`) ? {
|
|
47
|
+
...collection.admin,
|
|
48
|
+
components: {
|
|
49
|
+
...collection.admin?.components,
|
|
50
|
+
edit: {
|
|
51
|
+
PublishButton: publishButton(`${area.slug}.publish`),
|
|
52
|
+
UnpublishButton: publishButton(`${area.slug}.publish`, 'unpublish'),
|
|
53
|
+
...collection.admin?.components?.edit
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
} : collection.admin,
|
|
57
|
+
hooks: {
|
|
58
|
+
...collection.hooks,
|
|
59
|
+
afterChange: [
|
|
60
|
+
...collection.hooks?.afterChange ?? [],
|
|
61
|
+
({ req })=>markActive(req)
|
|
62
|
+
],
|
|
63
|
+
afterDelete: [
|
|
64
|
+
...collection.hooks?.afterDelete ?? [],
|
|
65
|
+
({ req })=>markActive(req)
|
|
66
|
+
],
|
|
67
|
+
beforeChange: hasKey(area, `${area.slug}.publish`) ? [
|
|
68
|
+
...collection.hooks?.beforeChange ?? [],
|
|
69
|
+
guardPublish(`${area.slug}.publish`)
|
|
70
|
+
] : collection.hooks?.beforeChange
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
const gateGlobal = (global, area)=>({
|
|
74
|
+
...global,
|
|
75
|
+
access: {
|
|
76
|
+
...global.access,
|
|
77
|
+
read: gateAccess(`${area.slug}.read`, global.access?.read),
|
|
78
|
+
update: gateAccess(`${area.slug}.edit`, global.access?.update)
|
|
79
|
+
},
|
|
80
|
+
admin: hasKey(area, `${area.slug}.publish`) ? {
|
|
81
|
+
...global.admin,
|
|
82
|
+
components: {
|
|
83
|
+
...global.admin?.components,
|
|
84
|
+
elements: {
|
|
85
|
+
PublishButton: publishButton(`${area.slug}.publish`),
|
|
86
|
+
UnpublishButton: publishButton(`${area.slug}.publish`, 'unpublish'),
|
|
87
|
+
...global.admin?.components?.elements
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
} : global.admin,
|
|
91
|
+
hooks: {
|
|
92
|
+
...global.hooks,
|
|
93
|
+
afterChange: [
|
|
94
|
+
...global.hooks?.afterChange ?? [],
|
|
95
|
+
({ req })=>markActive(req)
|
|
96
|
+
],
|
|
97
|
+
beforeChange: hasKey(area, `${area.slug}.publish`) ? [
|
|
98
|
+
...global.hooks?.beforeChange ?? [],
|
|
99
|
+
guardPublish(`${area.slug}.publish`)
|
|
100
|
+
] : global.hooks?.beforeChange
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
export const permissionsPlugin = (pluginOptions = {})=>(config)=>{
|
|
104
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion -- a union once a site generates types
|
|
105
|
+
const usersSlug = config.admin?.user ?? 'users';
|
|
106
|
+
const collections = config.collections ?? [];
|
|
107
|
+
const globals = config.globals ?? [];
|
|
108
|
+
const areas = pluginOptions.areas ?? [];
|
|
109
|
+
if (!collections.some((c)=>c.slug === usersSlug)) {
|
|
110
|
+
throw new Error(`permissions: users collection "${usersSlug}" not found`);
|
|
111
|
+
}
|
|
112
|
+
for (const slug of [
|
|
113
|
+
ROLES_SLUG,
|
|
114
|
+
OVERRIDES_SLUG,
|
|
115
|
+
AUDIT_SLUG
|
|
116
|
+
]){
|
|
117
|
+
if (collections.some((c)=>c.slug === slug)) {
|
|
118
|
+
throw new Error(`permissions: a "${slug}" collection already exists`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const registry = buildRegistry(areas, collections, globals);
|
|
122
|
+
const areaFor = (key, slug)=>{
|
|
123
|
+
const configured = areas.find((a)=>a[key] === slug);
|
|
124
|
+
return configured && registry.find((a)=>a.slug === configured.slug);
|
|
125
|
+
};
|
|
126
|
+
config.custom = {
|
|
127
|
+
...config.custom,
|
|
128
|
+
permissions: {
|
|
129
|
+
isSuperAdmin: pluginOptions.isSuperAdmin ?? (()=>false),
|
|
130
|
+
keys: registry.flatMap((a)=>a.permissions.map((p)=>p.key)),
|
|
131
|
+
registry,
|
|
132
|
+
usersSlug
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
config.collections = [
|
|
136
|
+
...collections.map((collection)=>{
|
|
137
|
+
if (collection.slug === usersSlug) {
|
|
138
|
+
return extendUsersCollection(collection);
|
|
139
|
+
}
|
|
140
|
+
const area = !pluginOptions.disabled && areaFor('collection', collection.slug);
|
|
141
|
+
return area ? gateCollection(collection, area) : collection;
|
|
142
|
+
}),
|
|
143
|
+
createRolesCollection({
|
|
144
|
+
registry,
|
|
145
|
+
usersSlug
|
|
146
|
+
}),
|
|
147
|
+
createOverridesCollection({
|
|
148
|
+
registry,
|
|
149
|
+
usersSlug
|
|
150
|
+
}),
|
|
151
|
+
createAuditCollection(usersSlug)
|
|
152
|
+
];
|
|
153
|
+
if (pluginOptions.disabled) {
|
|
154
|
+
return config;
|
|
155
|
+
}
|
|
156
|
+
config.globals = globals.map((global)=>{
|
|
157
|
+
const area = areaFor('global', global.slug);
|
|
158
|
+
return area ? gateGlobal(global, area) : global;
|
|
159
|
+
});
|
|
160
|
+
config.admin = {
|
|
161
|
+
...config.admin,
|
|
162
|
+
components: {
|
|
163
|
+
...config.admin?.components,
|
|
164
|
+
afterNavLinks: [
|
|
165
|
+
...config.admin?.components?.afterNavLinks ?? [],
|
|
166
|
+
`${RSC}#NavLinks`
|
|
167
|
+
],
|
|
168
|
+
views: {
|
|
169
|
+
...config.admin?.components?.views,
|
|
170
|
+
permissionsRoles: {
|
|
171
|
+
Component: `${RSC}#RolesView`,
|
|
172
|
+
exact: true,
|
|
173
|
+
path: '/permissions'
|
|
174
|
+
},
|
|
175
|
+
permissionsUsers: {
|
|
176
|
+
Component: `${RSC}#UsersView`,
|
|
177
|
+
exact: true,
|
|
178
|
+
path: '/permissions/users'
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
config.endpoints = [
|
|
184
|
+
...config.endpoints ?? [],
|
|
185
|
+
{
|
|
186
|
+
handler: resetToRoleHandler,
|
|
187
|
+
method: 'post',
|
|
188
|
+
path: RESET_PATH
|
|
189
|
+
}
|
|
190
|
+
];
|
|
191
|
+
return config;
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type {\n CollectionConfig,\n CollectionSlug,\n Config,\n GlobalConfig,\n PayloadRequest,\n} from 'payload'\n\nimport { APIError } from 'payload'\n\nimport type { Area, PermissionsPluginConfig } from './types.js'\n\nimport {\n AUDIT_SLUG,\n gateAccess,\n hasPermission,\n isCMSUser,\n markActive,\n OVERRIDES_SLUG,\n ROLES_SLUG,\n} from './access.js'\nimport { createAuditCollection } from './audit.js'\nimport { createOverridesCollection } from './collections/PermissionOverrides.js'\nimport { createRolesCollection } from './collections/Roles.js'\nimport { RESET_PATH, resetToRoleHandler } from './endpoints/resetToRole.js'\nimport { buildRegistry } from './registry.js'\nimport { extendUsersCollection } from './users.js'\n\nexport {\n AUDIT_SLUG,\n computePermissions,\n getPermissions,\n hasPermission,\n OVERRIDES_SLUG,\n requirePermission,\n ROLES_SLUG,\n} from './access.js'\nexport { MANAGE_PERMISSION } from './registry.js'\nexport { redundantOverrides, resolvePermission, resolvePermissions } from './resolve.js'\nexport type {\n Area,\n AreaConfig,\n Permission,\n PermissionsPluginConfig,\n StandardAction,\n} from './types.js'\n\n/** Publishing (moving `_status` to published) needs `area.publish` on top of create/edit. */\nconst guardPublish =\n (key: string) =>\n async ({\n data,\n originalDoc,\n req,\n }: {\n data: Record<string, unknown>\n originalDoc?: Record<string, unknown>\n req: PayloadRequest\n }) => {\n // Payload marks every draft save `_status: 'draft'` before hooks run, so anything else that\n // asks to publish, or lands on a published document, changes what's live.\n const publishing =\n data._status !== 'draft' &&\n (data._status === 'published' || originalDoc?._status === 'published')\n // Draft saves also send `_status: 'draft'`; only REST and GraphQL say which is which.\n // ponytail: local API unpublishes aren't checked, since hooks can't tell them from draft saves\n const unpublishing =\n data._status === 'draft' &&\n originalDoc?._status === 'published' &&\n req.payloadAPI !== 'local' &&\n req.query?.draft !== 'true'\n if (!publishing && !unpublishing) {\n return data\n }\n if (isCMSUser(req.payload, req.user) && !(await hasPermission(req, key))) {\n const verb = publishing ? 'publish' : 'unpublish'\n throw new APIError(`You don't have permission to ${verb} this.`, 403, undefined, true)\n }\n return data\n }\n\nconst hasKey = (area: Area, key: string) => area.permissions.some((p) => p.key === key)\n\nconst RSC = '@foundrykit/permissions-plugin/rsc'\n\n/** Server component that hides the (un)publish button from people without `key`. */\nconst publishButton = (key: string, kind: 'publish' | 'unpublish' = 'publish') => ({\n path: `${RSC}#PublishButtonGate`,\n serverProps: { kind, permission: key },\n})\n\nconst gateCollection = (collection: CollectionConfig, area: Area): CollectionConfig => ({\n ...collection,\n access: {\n ...collection.access,\n create: gateAccess(`${area.slug}.create`, collection.access?.create),\n delete: gateAccess(`${area.slug}.delete`, collection.access?.delete),\n read: gateAccess(`${area.slug}.read`, collection.access?.read),\n update: gateAccess(`${area.slug}.edit`, collection.access?.update),\n },\n admin: hasKey(area, `${area.slug}.publish`)\n ? {\n ...collection.admin,\n components: {\n ...collection.admin?.components,\n edit: {\n PublishButton: publishButton(`${area.slug}.publish`),\n UnpublishButton: publishButton(`${area.slug}.publish`, 'unpublish'),\n ...collection.admin?.components?.edit,\n },\n },\n }\n : collection.admin,\n hooks: {\n ...collection.hooks,\n afterChange: [...(collection.hooks?.afterChange ?? []), ({ req }) => markActive(req)],\n afterDelete: [...(collection.hooks?.afterDelete ?? []), ({ req }) => markActive(req)],\n beforeChange: hasKey(area, `${area.slug}.publish`)\n ? [...(collection.hooks?.beforeChange ?? []), guardPublish(`${area.slug}.publish`)]\n : collection.hooks?.beforeChange,\n },\n})\n\nconst gateGlobal = (global: GlobalConfig, area: Area): GlobalConfig => ({\n ...global,\n access: {\n ...global.access,\n read: gateAccess(`${area.slug}.read`, global.access?.read),\n update: gateAccess(`${area.slug}.edit`, global.access?.update),\n },\n admin: hasKey(area, `${area.slug}.publish`)\n ? {\n ...global.admin,\n components: {\n ...global.admin?.components,\n elements: {\n PublishButton: publishButton(`${area.slug}.publish`),\n UnpublishButton: publishButton(`${area.slug}.publish`, 'unpublish'),\n ...global.admin?.components?.elements,\n },\n },\n }\n : global.admin,\n hooks: {\n ...global.hooks,\n afterChange: [...(global.hooks?.afterChange ?? []), ({ req }) => markActive(req)],\n beforeChange: hasKey(area, `${area.slug}.publish`)\n ? [...(global.hooks?.beforeChange ?? []), guardPublish(`${area.slug}.publish`)]\n : global.hooks?.beforeChange,\n },\n})\n\nexport const permissionsPlugin =\n (pluginOptions: PermissionsPluginConfig = {}) =>\n (config: Config): Config => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion -- a union once a site generates types\n const usersSlug = (config.admin?.user ?? 'users') as CollectionSlug\n const collections = config.collections ?? []\n const globals = config.globals ?? []\n const areas = pluginOptions.areas ?? []\n\n if (!collections.some((c) => c.slug === usersSlug)) {\n throw new Error(`permissions: users collection \"${usersSlug}\" not found`)\n }\n for (const slug of [ROLES_SLUG, OVERRIDES_SLUG, AUDIT_SLUG]) {\n if (collections.some((c) => c.slug === slug)) {\n throw new Error(`permissions: a \"${slug}\" collection already exists`)\n }\n }\n\n const registry = buildRegistry(areas, collections, globals)\n const areaFor = (key: 'collection' | 'global', slug: string) => {\n const configured = areas.find((a) => a[key] === slug)\n return configured && registry.find((a) => a.slug === configured.slug)\n }\n\n config.custom = {\n ...config.custom,\n permissions: {\n isSuperAdmin: pluginOptions.isSuperAdmin ?? (() => false),\n keys: registry.flatMap((a) => a.permissions.map((p) => p.key)),\n registry,\n usersSlug,\n },\n }\n\n config.collections = [\n ...collections.map((collection) => {\n if (collection.slug === usersSlug) {\n return extendUsersCollection(collection)\n }\n const area = !pluginOptions.disabled && areaFor('collection', collection.slug)\n return area ? gateCollection(collection, area) : collection\n }),\n createRolesCollection({ registry, usersSlug }),\n createOverridesCollection({ registry, usersSlug }),\n createAuditCollection(usersSlug),\n ]\n\n if (pluginOptions.disabled) {\n return config\n }\n\n config.globals = globals.map((global) => {\n const area = areaFor('global', global.slug)\n return area ? gateGlobal(global, area) : global\n })\n\n config.admin = {\n ...config.admin,\n components: {\n ...config.admin?.components,\n afterNavLinks: [...(config.admin?.components?.afterNavLinks ?? []), `${RSC}#NavLinks`],\n views: {\n ...config.admin?.components?.views,\n permissionsRoles: { Component: `${RSC}#RolesView`, exact: true, path: '/permissions' },\n permissionsUsers: {\n Component: `${RSC}#UsersView`,\n exact: true,\n path: '/permissions/users',\n },\n },\n },\n }\n\n config.endpoints = [\n ...(config.endpoints ?? []),\n { handler: resetToRoleHandler, method: 'post', path: RESET_PATH },\n ]\n\n return config\n }\n"],"names":["APIError","AUDIT_SLUG","gateAccess","hasPermission","isCMSUser","markActive","OVERRIDES_SLUG","ROLES_SLUG","createAuditCollection","createOverridesCollection","createRolesCollection","RESET_PATH","resetToRoleHandler","buildRegistry","extendUsersCollection","computePermissions","getPermissions","requirePermission","MANAGE_PERMISSION","redundantOverrides","resolvePermission","resolvePermissions","guardPublish","key","data","originalDoc","req","publishing","_status","unpublishing","payloadAPI","query","draft","payload","user","verb","undefined","hasKey","area","permissions","some","p","RSC","publishButton","kind","path","serverProps","permission","gateCollection","collection","access","create","slug","delete","read","update","admin","components","edit","PublishButton","UnpublishButton","hooks","afterChange","afterDelete","beforeChange","gateGlobal","global","elements","permissionsPlugin","pluginOptions","config","usersSlug","collections","globals","areas","c","Error","registry","areaFor","configured","find","a","custom","isSuperAdmin","keys","flatMap","map","disabled","afterNavLinks","views","permissionsRoles","Component","exact","permissionsUsers","endpoints","handler","method"],"mappings":"AAQA,SAASA,QAAQ,QAAQ,UAAS;AAIlC,SACEC,UAAU,EACVC,UAAU,EACVC,aAAa,EACbC,SAAS,EACTC,UAAU,EACVC,cAAc,EACdC,UAAU,QACL,cAAa;AACpB,SAASC,qBAAqB,QAAQ,aAAY;AAClD,SAASC,yBAAyB,QAAQ,uCAAsC;AAChF,SAASC,qBAAqB,QAAQ,yBAAwB;AAC9D,SAASC,UAAU,EAAEC,kBAAkB,QAAQ,6BAA4B;AAC3E,SAASC,aAAa,QAAQ,gBAAe;AAC7C,SAASC,qBAAqB,QAAQ,aAAY;AAElD,SACEb,UAAU,EACVc,kBAA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AWG,IAAI;gBAC7E,OAAOd,OAAOU,eAAeC,YAAYX,QAAQW;YACnD;YACAvC,sBAAsB;gBAAEmE;gBAAUN;YAAU;YAC5C9D,0BAA0B;gBAAEoE;gBAAUN;YAAU;YAChD/D,sBAAsB+D;SACvB;QAED,IAAIF,cAAckB,QAAQ,EAAE;YAC1B,OAAOjB;QACT;QAEAA,OAAOG,OAAO,GAAGA,QAAQa,GAAG,CAAC,CAACpB;YAC5B,MAAM5B,OAAOwC,QAAQ,UAAUZ,OAAOd,IAAI;YAC1C,OAAOd,OAAO2B,WAAWC,QAAQ5B,QAAQ4B;QAC3C;QAEAI,OAAOd,KAAK,GAAG;YACb,GAAGc,OAAOd,KAAK;YACfC,YAAY;gBACV,GAAGa,OAAOd,KAAK,EAAEC,UAAU;gBAC3B+B,eAAe;uBAAKlB,OAAOd,KAAK,EAAEC,YAAY+B,iBAAiB,EAAE;oBAAG,GAAG9C,IAAI,SAAS,CAAC;iBAAC;gBACtF+C,OAAO;oBACL,GAAGnB,OAAOd,KAAK,EAAEC,YAAYgC,KAAK;oBAClCC,kBAAkB;wBAAEC,WAAW,GAAGjD,IAAI,UAAU,CAAC;wBAAEkD,OAAO;wBAAM/C,MAAM;oBAAe;oBACrFgD,kBAAkB;wBAChBF,WAAW,GAAGjD,IAAI,UAAU,CAAC;wBAC7BkD,OAAO;wBACP/C,MAAM;oBACR;gBACF;YACF;QACF;QAEAyB,OAAOwB,SAAS,GAAG;eACbxB,OAAOwB,SAAS,IAAI,EAAE;YAC1B;gBAAEC,SAASnF;gBAAoBoF,QAAQ;gBAAQnD,MAAMlC;YAAW;SACjE;QAED,OAAO2D;IACT,EAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CollectionConfig, GlobalConfig } from 'payload';
|
|
2
|
+
import type { Area, AreaConfig } from './types.js';
|
|
3
|
+
export declare const MANAGE_PERMISSION = "permissions.manage";
|
|
4
|
+
/** Turn the site's area config into the full list of `area.action` permissions. */
|
|
5
|
+
export declare const buildRegistry: (areas: AreaConfig[], collections: CollectionConfig[], globals: GlobalConfig[]) => Area[];
|