@zealamic/payload-auth-rbac-plugin 1.0.0-beta.1 → 1.0.0-beta.11
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 +27 -31
- package/assets/cover-photo.jpg +0 -0
- package/dist/collections/permission-actions/default-data.d.ts +2 -0
- package/dist/collections/permission-actions/index.d.ts +3 -0
- package/dist/collections/permission-actions/types.d.ts +51 -0
- package/dist/collections/permission-features/default-data.d.ts +2 -0
- package/dist/collections/permission-features/index.d.ts +3 -0
- package/dist/collections/permission-features/types.d.ts +43 -0
- package/dist/collections/permissions/default-data.d.ts +2 -0
- package/dist/collections/permissions/index.d.ts +3 -0
- package/dist/collections/permissions/types.d.ts +54 -0
- package/dist/collections/roles/default-data.d.ts +2 -0
- package/dist/collections/roles/hooks/sync-permission-matrix-draft.d.ts +6 -0
- package/dist/collections/roles/index.d.ts +3 -0
- package/dist/collections/roles/types.d.ts +53 -0
- package/dist/collections/roles-permissions/default-data.d.ts +2 -0
- package/dist/collections/roles-permissions/index.d.ts +3 -0
- package/dist/collections/roles-permissions/types.d.ts +39 -0
- package/dist/collections/users/default-data.d.ts +2 -0
- package/dist/collections/users/index.d.ts +3 -0
- package/dist/collections/users/parent-path.d.ts +31 -0
- package/dist/collections/users/types.d.ts +23 -0
- package/dist/components/role-permission-matrix-client/default-data.d.ts +2 -0
- package/dist/components/role-permission-matrix-client/default-data.js +2 -1
- package/dist/components/role-permission-matrix-client/default-data.js.map +1 -1
- package/dist/components/role-permission-matrix-client/index.d.ts +1 -0
- package/dist/components/role-permission-matrix-client/index.js +18 -68
- package/dist/components/role-permission-matrix-client/index.js.map +1 -1
- package/dist/components/role-permission-matrix-client/matrix.module.scss +69 -0
- package/dist/components/role-permission-matrix-client/types.d.ts +18 -0
- package/dist/endpoints/customEndpointHandler.d.ts +2 -0
- package/dist/exports/client.d.ts +1 -0
- package/dist/exports/rsc.d.ts +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/lib/constants/general.d.ts +1 -0
- package/dist/lib/constants/index.d.ts +14 -0
- package/dist/lib/constants/permission-action.d.ts +8 -0
- package/dist/lib/constants/permission-feature.d.ts +4 -0
- package/dist/lib/constants/permission.d.ts +4 -0
- package/dist/lib/constants/role.d.ts +9 -0
- package/dist/lib/constants/user.d.ts +1 -0
- package/dist/lib/utils/access.d.ts +76 -0
- package/dist/lib/utils/data.d.ts +6 -0
- package/dist/lib/utils/fields.d.ts +18 -0
- package/dist/lib/utils/index.d.ts +4 -0
- package/dist/lib/utils/localization.d.ts +27 -0
- package/dist/styles/variables.scss +1 -0
- package/dist/types.d.ts +38 -0
- package/docs/COLLECTIONS.md +440 -0
- package/docs/TRANSLATIONS.md +462 -0
- package/docs/UTILS.md +226 -0
- package/package.json +21 -4
package/README.md
CHANGED
|
@@ -10,13 +10,13 @@ Permissions live in the database (feature + action), are assigned to roles, and
|
|
|
10
10
|
|
|
11
11
|
## Documentation
|
|
12
12
|
|
|
13
|
-
| Guide
|
|
14
|
-
|
|
|
15
|
-
| **[COLLECTIONS](
|
|
16
|
-
| **[UTILS](
|
|
17
|
-
| **[TRANSLATIONS](
|
|
13
|
+
| Guide | Read when you need to… |
|
|
14
|
+
| ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
|
|
15
|
+
| **[COLLECTIONS](https://github.com/zealamic/payload-auth-rbac-plugin/blob/main/docs/COLLECTIONS.md)** | Understand plugin collections, users augmentation, `dataScope`, permission matrix, and **customize** fields/access/admin |
|
|
16
|
+
| **[UTILS](https://github.com/zealamic/payload-auth-rbac-plugin/blob/main/docs/UTILS.md)** | Wire **access helpers** on your app collections (`getPermissionAccess`, data-scope filters, examples) |
|
|
17
|
+
| **[TRANSLATIONS](https://github.com/zealamic/payload-auth-rbac-plugin/blob/main/docs/TRANSLATIONS.md)** | Localize Admin labels, select options, and permission-matrix UI (`en`, `vi`, …) |
|
|
18
18
|
|
|
19
|
-
**Typical flow:** install → register plugin → seed RBAC data ([COLLECTIONS](
|
|
19
|
+
**Typical flow:** install → register plugin → seed RBAC data ([COLLECTIONS](https://github.com/zealamic/payload-auth-rbac-plugin/blob/main/docs/COLLECTIONS.md)) → protect app collections ([UTILS](https://github.com/zealamic/payload-auth-rbac-plugin/blob/main/docs/UTILS.md)) → translate Admin UI ([TRANSLATIONS](https://github.com/zealamic/payload-auth-rbac-plugin/blob/main/docs/TRANSLATIONS.md)).
|
|
20
20
|
|
|
21
21
|
Demo: `dev/rbac.ts`, `dev/collections/posts.ts`.
|
|
22
22
|
|
|
@@ -24,13 +24,13 @@ Demo: `dev/rbac.ts`, `dev/collections/posts.ts`.
|
|
|
24
24
|
|
|
25
25
|
## Key features
|
|
26
26
|
|
|
27
|
-
- **Five RBAC collections** — features, actions, permissions, roles, join table ([details](
|
|
27
|
+
- **Five RBAC collections** — features, actions, permissions, roles, join table ([details](https://github.com/zealamic/payload-auth-rbac-plugin/blob/main/docs/COLLECTIONS.md))
|
|
28
28
|
- **Multi-role users** — union of enabled grants across assigned roles
|
|
29
|
-
- **Granular permissions** — any `featureCode` + `actionCode` pair ([helpers](
|
|
30
|
-
- **Data scope** — per-role `own` / `hierarchy` / `all` for row-level filtering (`[dataScope` vs `isSuperAdmin](
|
|
29
|
+
- **Granular permissions** — any `featureCode` + `actionCode` pair ([helpers](https://github.com/zealamic/payload-auth-rbac-plugin/blob/main/docs/UTILS.md))
|
|
30
|
+
- **Data scope** — per-role `own` / `hierarchy` / `all` for row-level filtering (`[dataScope` vs `isSuperAdmin](https://github.com/zealamic/payload-auth-rbac-plugin/blob/main/docs/COLLECTIONS.md#what-is-datascope)`)
|
|
31
31
|
- **Permission matrix** — role edit UI; syncs to `roles-permissions` on save
|
|
32
32
|
- **TypeScript** — typed plugin options and exports (`/types`)
|
|
33
|
-
- **i18n** — plugin-owned translations merged into Payload i18n ([guide](
|
|
33
|
+
- **i18n** — plugin-owned translations merged into Payload i18n ([guide](https://github.com/zealamic/payload-auth-rbac-plugin/blob/main/docs/TRANSLATIONS.md))
|
|
34
34
|
|
|
35
35
|
---
|
|
36
36
|
|
|
@@ -66,17 +66,15 @@ export default buildConfig({
|
|
|
66
66
|
1. **permission-features** — e.g. `posts`, `users` (`code` = `featureCode` in access helpers)
|
|
67
67
|
2. **permission-actions** — e.g. `create`, `read`, `update`, `delete`
|
|
68
68
|
3. **permissions** — one row per feature + action pair
|
|
69
|
-
4. **roles** — set `[dataScope](
|
|
70
|
-
5. **users** — assign roles; bootstrap `[isSuperAdmin](
|
|
69
|
+
4. **roles** — set `[dataScope](https://github.com/zealamic/payload-auth-rbac-plugin/blob/main/docs/COLLECTIONS.md#what-is-datascope)`; configure matrix on update screen → Save
|
|
70
|
+
5. **users** — assign roles; bootstrap `[isSuperAdmin](https://github.com/zealamic/payload-auth-rbac-plugin/blob/main/docs/COLLECTIONS.md#bootstrap-super-admin)` via seed/API
|
|
71
71
|
|
|
72
|
-
→ Full collection reference: **[COLLECTIONS](
|
|
72
|
+
→ Full collection reference: **[COLLECTIONS](https://github.com/zealamic/payload-auth-rbac-plugin/blob/main/docs/COLLECTIONS.md)**
|
|
73
73
|
|
|
74
74
|
### 3. Protect app collections
|
|
75
75
|
|
|
76
76
|
```ts
|
|
77
|
-
import {
|
|
78
|
-
getPermissionAccess,
|
|
79
|
-
} from "@zealamic/payload-auth-rbac-plugin";
|
|
77
|
+
import { getPermissionAccess } from "@zealamic/payload-auth-rbac-plugin";
|
|
80
78
|
|
|
81
79
|
export const Posts: CollectionConfig = {
|
|
82
80
|
slug: "posts",
|
|
@@ -121,18 +119,18 @@ export const Posts: CollectionConfig = {
|
|
|
121
119
|
|
|
122
120
|
**Access order:** anonymous → deny · super admin → allow · else → matrix permission (+ data scope when using scope helpers).
|
|
123
121
|
|
|
124
|
-
→ All helpers with examples: **[UTILS](
|
|
122
|
+
→ All helpers with examples: **[UTILS](https://github.com/zealamic/payload-auth-rbac-plugin/blob/main/docs/UTILS.md)**
|
|
125
123
|
|
|
126
124
|
---
|
|
127
125
|
|
|
128
126
|
## Plugin options
|
|
129
127
|
|
|
130
|
-
| Option | Default | Description
|
|
131
|
-
| --------------------------- | ------- |
|
|
132
|
-
| `disabled` | `false` | Skip runtime wiring; schema still registers
|
|
133
|
-
| `autoModifyUsersCollection` | `true` | Add RBAC fields + access on users collection
|
|
134
|
-
| `translations` | — | Admin / matrix i18n → **[TRANSLATIONS](
|
|
135
|
-
| `collections` | — | Per-collection overrides → **[COLLECTIONS](
|
|
128
|
+
| Option | Default | Description |
|
|
129
|
+
| --------------------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
130
|
+
| `disabled` | `false` | Skip runtime wiring; schema still registers |
|
|
131
|
+
| `autoModifyUsersCollection` | `true` | Add RBAC fields + access on users collection |
|
|
132
|
+
| `translations` | — | Admin / matrix i18n → **[TRANSLATIONS](https://github.com/zealamic/payload-auth-rbac-plugin/blob/main/docs/TRANSLATIONS.md)** |
|
|
133
|
+
| `collections` | — | Per-collection overrides → **[COLLECTIONS](https://github.com/zealamic/payload-auth-rbac-plugin/blob/main/docs/COLLECTIONS.md#customizing-collections)** |
|
|
136
134
|
|
|
137
135
|
Types: `@zealamic/payload-auth-rbac-plugin/types`
|
|
138
136
|
|
|
@@ -140,14 +138,14 @@ Types: `@zealamic/payload-auth-rbac-plugin/types`
|
|
|
140
138
|
|
|
141
139
|
## Exported helpers (summary)
|
|
142
140
|
|
|
143
|
-
Full reference: **[UTILS](
|
|
141
|
+
Full reference: **[UTILS](https://github.com/zealamic/payload-auth-rbac-plugin/blob/main/docs/UTILS.md)**
|
|
144
142
|
|
|
145
|
-
| Function | Purpose
|
|
146
|
-
| ----------------------------------------------------- |
|
|
143
|
+
| Function | Purpose |
|
|
144
|
+
| ----------------------------------------------------- | ------------------------------------------------------ |
|
|
147
145
|
| `getPermissionAccess` | Unified helper: permission / read scope / modify scope |
|
|
148
|
-
| `getSuperAdminAccess` | Super admin only (RBAC collections default)
|
|
149
|
-
| `canAccessDocumentByDataScope` | Single-document scope check
|
|
150
|
-
| `resolveEffectiveDataScope` / `getDataScopeReadWhere` | Scope resolution & query filters
|
|
146
|
+
| `getSuperAdminAccess` | Super admin only (RBAC collections default) |
|
|
147
|
+
| `canAccessDocumentByDataScope` | Single-document scope check |
|
|
148
|
+
| `resolveEffectiveDataScope` / `getDataScopeReadWhere` | Scope resolution & query filters |
|
|
151
149
|
|
|
152
150
|
Constants: `CONSTANTS.ROLE.DATA_SCOPE`, etc.
|
|
153
151
|
|
|
@@ -171,5 +169,3 @@ MIT
|
|
|
171
169
|
---
|
|
172
170
|
|
|
173
171
|
> _If this plugin helps your team ship safer access control with less friction, thank you for giving it a place in your stack._
|
|
174
|
-
|
|
175
|
-
|
|
Binary file
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { CollectionConfig, Field } from "payload";
|
|
2
|
+
import { STATUS, TYPE } from "../../lib/constants/permission-action.js";
|
|
3
|
+
export type PermissionActionsCollectionTranslations = {
|
|
4
|
+
[locale: string]: {
|
|
5
|
+
labels?: {
|
|
6
|
+
singular?: string;
|
|
7
|
+
plural?: string;
|
|
8
|
+
};
|
|
9
|
+
admin?: {
|
|
10
|
+
group?: string;
|
|
11
|
+
};
|
|
12
|
+
fields?: {
|
|
13
|
+
code?: {
|
|
14
|
+
label?: string;
|
|
15
|
+
placeholder?: string;
|
|
16
|
+
};
|
|
17
|
+
type?: {
|
|
18
|
+
label?: string;
|
|
19
|
+
placeholder?: string;
|
|
20
|
+
mainLabel?: string;
|
|
21
|
+
subLabel?: string;
|
|
22
|
+
};
|
|
23
|
+
sortOrder?: {
|
|
24
|
+
label?: string;
|
|
25
|
+
placeholder?: string;
|
|
26
|
+
};
|
|
27
|
+
status?: {
|
|
28
|
+
label?: string;
|
|
29
|
+
placeholder?: string;
|
|
30
|
+
activeLabel?: string;
|
|
31
|
+
inactiveLabel?: string;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
export type PermissionActionsCollectionParams = {
|
|
37
|
+
translations?: PermissionActionsCollectionTranslations;
|
|
38
|
+
fields?: Field[];
|
|
39
|
+
access?: CollectionConfig["access"];
|
|
40
|
+
labels?: CollectionConfig["labels"];
|
|
41
|
+
admin?: CollectionConfig["admin"];
|
|
42
|
+
};
|
|
43
|
+
export type PermissionActionStatus = (typeof STATUS)[keyof typeof STATUS];
|
|
44
|
+
export type PermissionActionType = (typeof TYPE)[keyof typeof TYPE];
|
|
45
|
+
export type PermissionAction = {
|
|
46
|
+
id: string | number;
|
|
47
|
+
code?: string | null;
|
|
48
|
+
sortOrder?: number | null;
|
|
49
|
+
type?: PermissionActionType | null;
|
|
50
|
+
status?: PermissionActionStatus | null;
|
|
51
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { CollectionConfig, Field } from "payload";
|
|
2
|
+
import { STATUS } from "../../lib/constants/permission-feature.js";
|
|
3
|
+
export type PermissionFeaturesCollectionTranslations = {
|
|
4
|
+
[locale: string]: {
|
|
5
|
+
labels?: {
|
|
6
|
+
singular?: string;
|
|
7
|
+
plural?: string;
|
|
8
|
+
};
|
|
9
|
+
admin?: {
|
|
10
|
+
group?: string;
|
|
11
|
+
};
|
|
12
|
+
fields?: {
|
|
13
|
+
code?: {
|
|
14
|
+
label?: string;
|
|
15
|
+
placeholder?: string;
|
|
16
|
+
};
|
|
17
|
+
sortOrder?: {
|
|
18
|
+
label?: string;
|
|
19
|
+
placeholder?: string;
|
|
20
|
+
};
|
|
21
|
+
status?: {
|
|
22
|
+
label?: string;
|
|
23
|
+
placeholder?: string;
|
|
24
|
+
activeLabel?: string;
|
|
25
|
+
inactiveLabel?: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export type PermissionFeaturesCollectionParams = {
|
|
31
|
+
translations?: PermissionFeaturesCollectionTranslations;
|
|
32
|
+
fields?: Field[];
|
|
33
|
+
access?: CollectionConfig["access"];
|
|
34
|
+
labels?: CollectionConfig["labels"];
|
|
35
|
+
admin?: CollectionConfig["admin"];
|
|
36
|
+
};
|
|
37
|
+
export type PermissionFeatureStatus = (typeof STATUS)[keyof typeof STATUS];
|
|
38
|
+
export type PermissionFeature = {
|
|
39
|
+
id: string | number;
|
|
40
|
+
code?: string | null;
|
|
41
|
+
sortOrder?: number | null;
|
|
42
|
+
status?: PermissionFeatureStatus | null;
|
|
43
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { CollectionConfig, Field } from "payload";
|
|
2
|
+
import { STATUS } from "src/lib/constants/permission.js";
|
|
3
|
+
export type PermissionsCollectionTranslations = {
|
|
4
|
+
[locale: string]: {
|
|
5
|
+
labels?: {
|
|
6
|
+
singular?: string;
|
|
7
|
+
plural?: string;
|
|
8
|
+
};
|
|
9
|
+
admin?: {
|
|
10
|
+
group?: string;
|
|
11
|
+
};
|
|
12
|
+
fields?: {
|
|
13
|
+
name?: {
|
|
14
|
+
label?: string;
|
|
15
|
+
placeholder?: string;
|
|
16
|
+
};
|
|
17
|
+
permissionFeature?: {
|
|
18
|
+
label?: string;
|
|
19
|
+
placeholder?: string;
|
|
20
|
+
};
|
|
21
|
+
permissionAction?: {
|
|
22
|
+
label?: string;
|
|
23
|
+
placeholder?: string;
|
|
24
|
+
};
|
|
25
|
+
sortOrder?: {
|
|
26
|
+
label?: string;
|
|
27
|
+
placeholder?: string;
|
|
28
|
+
};
|
|
29
|
+
status?: {
|
|
30
|
+
label?: string;
|
|
31
|
+
placeholder?: string;
|
|
32
|
+
activeLabel?: string;
|
|
33
|
+
inactiveLabel?: string;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export type PermissionsCollectionParams = {
|
|
39
|
+
translations?: PermissionsCollectionTranslations;
|
|
40
|
+
fields?: Field[];
|
|
41
|
+
access?: CollectionConfig["access"];
|
|
42
|
+
labels?: CollectionConfig["labels"];
|
|
43
|
+
admin?: CollectionConfig["admin"];
|
|
44
|
+
};
|
|
45
|
+
export type PermissionItemRef = string | number | {
|
|
46
|
+
id?: string | number;
|
|
47
|
+
};
|
|
48
|
+
export type PermissionStatus = (typeof STATUS)[keyof typeof STATUS];
|
|
49
|
+
export type Permission = {
|
|
50
|
+
id: string | number;
|
|
51
|
+
permissionFeature?: PermissionItemRef;
|
|
52
|
+
permissionAction?: PermissionItemRef;
|
|
53
|
+
status?: PermissionStatus | null;
|
|
54
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CollectionAfterChangeHook } from "payload";
|
|
2
|
+
/**
|
|
3
|
+
* Persists `permissionMatrixDraft` on the role document into `roles-permissions` rows.
|
|
4
|
+
* RBAC checks use `roles-permissions`, not the JSON draft field.
|
|
5
|
+
*/
|
|
6
|
+
export declare const syncPermissionMatrixDraftAfterChange: CollectionAfterChangeHook;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { CollectionConfig, Field } from "payload";
|
|
2
|
+
import type { DATA_SCOPE, STATUS } from "../../lib/constants/role.js";
|
|
3
|
+
export type DataScope = (typeof DATA_SCOPE)[keyof typeof DATA_SCOPE];
|
|
4
|
+
export type RoleStatus = (typeof STATUS)[keyof typeof STATUS];
|
|
5
|
+
export type RolesCollectionTranslations = {
|
|
6
|
+
[locale: string]: {
|
|
7
|
+
labels?: {
|
|
8
|
+
singular?: string;
|
|
9
|
+
plural?: string;
|
|
10
|
+
};
|
|
11
|
+
admin?: {
|
|
12
|
+
group?: string;
|
|
13
|
+
};
|
|
14
|
+
fields?: {
|
|
15
|
+
code?: {
|
|
16
|
+
label?: string;
|
|
17
|
+
placeholder?: string;
|
|
18
|
+
};
|
|
19
|
+
name?: {
|
|
20
|
+
label?: string;
|
|
21
|
+
placeholder?: string;
|
|
22
|
+
};
|
|
23
|
+
description?: {
|
|
24
|
+
label?: string;
|
|
25
|
+
placeholder?: string;
|
|
26
|
+
};
|
|
27
|
+
status?: {
|
|
28
|
+
label?: string;
|
|
29
|
+
placeholder?: string;
|
|
30
|
+
activeLabel?: string;
|
|
31
|
+
inactiveLabel?: string;
|
|
32
|
+
};
|
|
33
|
+
dataScope?: {
|
|
34
|
+
label?: string;
|
|
35
|
+
placeholder?: string;
|
|
36
|
+
allLabel?: string;
|
|
37
|
+
ownLabel?: string;
|
|
38
|
+
hierarchyLabel?: string;
|
|
39
|
+
};
|
|
40
|
+
permissionMatrix?: {
|
|
41
|
+
label?: string;
|
|
42
|
+
placeholder?: string;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
export type RolesCollectionParams = {
|
|
48
|
+
translations?: RolesCollectionTranslations;
|
|
49
|
+
fields?: Field[];
|
|
50
|
+
access?: CollectionConfig["access"];
|
|
51
|
+
labels?: CollectionConfig["labels"];
|
|
52
|
+
admin?: CollectionConfig["admin"];
|
|
53
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { CollectionConfig, Field } from "payload";
|
|
2
|
+
export type RolesPermissionsCollectionTranslations = {
|
|
3
|
+
[locale: string]: {
|
|
4
|
+
labels?: {
|
|
5
|
+
singular?: string;
|
|
6
|
+
plural?: string;
|
|
7
|
+
};
|
|
8
|
+
admin?: {
|
|
9
|
+
group?: string;
|
|
10
|
+
};
|
|
11
|
+
fields?: {
|
|
12
|
+
role?: {
|
|
13
|
+
label?: string;
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
};
|
|
16
|
+
permission?: {
|
|
17
|
+
label?: string;
|
|
18
|
+
placeholder?: string;
|
|
19
|
+
};
|
|
20
|
+
enabled?: {
|
|
21
|
+
label?: string;
|
|
22
|
+
placeholder?: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export type RolesPermissionsCollectionParams = {
|
|
28
|
+
translations?: RolesPermissionsCollectionTranslations;
|
|
29
|
+
fields?: Field[];
|
|
30
|
+
access?: CollectionConfig["access"];
|
|
31
|
+
labels?: CollectionConfig["labels"];
|
|
32
|
+
admin?: CollectionConfig["admin"];
|
|
33
|
+
};
|
|
34
|
+
export type RolePermission = {
|
|
35
|
+
id: string | number;
|
|
36
|
+
role?: string | number;
|
|
37
|
+
permission?: string | number;
|
|
38
|
+
enabled?: boolean;
|
|
39
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { CollectionAfterChangeHook, CollectionAfterDeleteHook, CollectionBeforeChangeHook, PayloadRequest } from "payload";
|
|
2
|
+
type UserDoc = {
|
|
3
|
+
id?: string | number;
|
|
4
|
+
parent?: ItemRef;
|
|
5
|
+
parentPath?: string | null;
|
|
6
|
+
};
|
|
7
|
+
/** Ancestor IDs from root to parent (exclusive of self), e.g. `"1,2"`. */
|
|
8
|
+
export declare const buildParentPathFromParentDoc: (parent: UserDoc | null | undefined) => string;
|
|
9
|
+
export declare const computeParentPath: ({ parentId, req, userSlug, }: {
|
|
10
|
+
parentId?: string;
|
|
11
|
+
req: PayloadRequest;
|
|
12
|
+
userSlug: string;
|
|
13
|
+
}) => Promise<string>;
|
|
14
|
+
export declare const createUserParentPathHooks: (userSlug: string) => {
|
|
15
|
+
beforeChange: CollectionBeforeChangeHook;
|
|
16
|
+
afterChange: CollectionAfterChangeHook;
|
|
17
|
+
afterDelete: CollectionAfterDeleteHook;
|
|
18
|
+
};
|
|
19
|
+
export declare const mergeUserCollectionHooks: ({ existingHooks, userSlug, }: {
|
|
20
|
+
existingHooks?: {
|
|
21
|
+
beforeChange?: CollectionBeforeChangeHook[] | CollectionBeforeChangeHook;
|
|
22
|
+
afterChange?: CollectionAfterChangeHook[] | CollectionAfterChangeHook;
|
|
23
|
+
afterDelete?: CollectionAfterDeleteHook[] | CollectionAfterDeleteHook;
|
|
24
|
+
};
|
|
25
|
+
userSlug: string;
|
|
26
|
+
}) => {
|
|
27
|
+
beforeChange: CollectionBeforeChangeHook[];
|
|
28
|
+
afterChange: CollectionAfterChangeHook[];
|
|
29
|
+
afterDelete: CollectionAfterDeleteHook[];
|
|
30
|
+
};
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Field } from "payload";
|
|
2
|
+
export type UsersModificationTranslations = {
|
|
3
|
+
[locale: string]: {
|
|
4
|
+
fields?: {
|
|
5
|
+
isSuperAdmin?: {
|
|
6
|
+
label?: string;
|
|
7
|
+
};
|
|
8
|
+
roles?: {
|
|
9
|
+
label?: string;
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
};
|
|
12
|
+
parent?: {
|
|
13
|
+
label?: string;
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export type UsersModificationParams = {
|
|
20
|
+
translations?: UsersModificationTranslations;
|
|
21
|
+
fields?: Field[];
|
|
22
|
+
rolesSlug?: string;
|
|
23
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/role-permission-matrix-client/default-data.ts"],"sourcesContent":["import type { RolePermissionMatrixClientTranslations } from \"./types.js\"
|
|
1
|
+
{"version":3,"sources":["../../../src/components/role-permission-matrix-client/default-data.ts"],"sourcesContent":["import type { RolePermissionMatrixClientTranslations } from \"./types.js\";\n\nexport const rolePermissionMatrixClientDefaultTranslations: RolePermissionMatrixClientTranslations =\n {\n en: {\n viewInUpdateScreenOnly: {\n label: \"View permission matrix in update screen only\",\n },\n loading: {\n placeholder: \"Loading permission matrix...\",\n },\n title: \"Permission Matrix\",\n features: {\n label: \"Features\",\n users: \"Users\",\n },\n actions: {\n label: \"Actions\",\n create: \"Create\",\n read: \"Read\",\n update: \"Update\",\n delete: \"Delete\",\n },\n },\n };\n"],"names":["rolePermissionMatrixClientDefaultTranslations","en","viewInUpdateScreenOnly","label","loading","placeholder","title","features","users","actions","create","read","update","delete"],"mappings":"AAEA,OAAO,MAAMA,gDACX;IACEC,IAAI;QACFC,wBAAwB;YACtBC,OAAO;QACT;QACAC,SAAS;YACPC,aAAa;QACf;QACAC,OAAO;QACPC,UAAU;YACRJ,OAAO;YACPK,OAAO;QACT;QACAC,SAAS;YACPN,OAAO;YACPO,QAAQ;YACRC,MAAM;YACNC,QAAQ;YACRC,QAAQ;QACV;IACF;AACF,EAAE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const RolePermissionMatrixClient: () => import("react/jsx-runtime").JSX.Element;
|