@zealamic/payload-auth-rbac-plugin 1.0.0-beta.1 → 1.0.0-beta.9

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.
Files changed (41) hide show
  1. package/dist/collections/permission-actions/default-data.d.ts +2 -0
  2. package/dist/collections/permission-actions/index.d.ts +3 -0
  3. package/dist/collections/permission-actions/types.d.ts +51 -0
  4. package/dist/collections/permission-features/default-data.d.ts +2 -0
  5. package/dist/collections/permission-features/index.d.ts +3 -0
  6. package/dist/collections/permission-features/types.d.ts +43 -0
  7. package/dist/collections/permissions/default-data.d.ts +2 -0
  8. package/dist/collections/permissions/index.d.ts +3 -0
  9. package/dist/collections/permissions/types.d.ts +54 -0
  10. package/dist/collections/roles/default-data.d.ts +2 -0
  11. package/dist/collections/roles/hooks/sync-permission-matrix-draft.d.ts +6 -0
  12. package/dist/collections/roles/index.d.ts +3 -0
  13. package/dist/collections/roles/types.d.ts +53 -0
  14. package/dist/collections/roles-permissions/default-data.d.ts +2 -0
  15. package/dist/collections/roles-permissions/index.d.ts +3 -0
  16. package/dist/collections/roles-permissions/types.d.ts +39 -0
  17. package/dist/collections/users/default-data.d.ts +2 -0
  18. package/dist/collections/users/index.d.ts +3 -0
  19. package/dist/collections/users/parent-path.d.ts +31 -0
  20. package/dist/collections/users/types.d.ts +23 -0
  21. package/dist/components/role-permission-matrix-client/default-data.d.ts +2 -0
  22. package/dist/components/role-permission-matrix-client/index.d.ts +1 -0
  23. package/dist/components/role-permission-matrix-client/types.d.ts +18 -0
  24. package/dist/endpoints/customEndpointHandler.d.ts +2 -0
  25. package/dist/exports/client.d.ts +1 -0
  26. package/dist/exports/rsc.d.ts +1 -0
  27. package/dist/index.d.ts +5 -0
  28. package/dist/lib/constants/general.d.ts +1 -0
  29. package/dist/lib/constants/index.d.ts +14 -0
  30. package/dist/lib/constants/permission-action.d.ts +8 -0
  31. package/dist/lib/constants/permission-feature.d.ts +4 -0
  32. package/dist/lib/constants/permission.d.ts +4 -0
  33. package/dist/lib/constants/role.d.ts +9 -0
  34. package/dist/lib/constants/user.d.ts +1 -0
  35. package/dist/lib/utils/access.d.ts +76 -0
  36. package/dist/lib/utils/data.d.ts +6 -0
  37. package/dist/lib/utils/fields.d.ts +18 -0
  38. package/dist/lib/utils/index.d.ts +4 -0
  39. package/dist/lib/utils/localization.d.ts +27 -0
  40. package/dist/types.d.ts +38 -0
  41. package/package.json +17 -2
@@ -0,0 +1,2 @@
1
+ import type { PermissionActionsCollectionTranslations } from "./types.js";
2
+ export declare const permissionActionsDefaultTranslations: PermissionActionsCollectionTranslations;
@@ -0,0 +1,3 @@
1
+ import type { CollectionConfig } from "payload";
2
+ import type { PermissionActionsCollectionParams } from "./types.js";
3
+ export declare const getPermissionActionsCollection: (params: PermissionActionsCollectionParams) => CollectionConfig;
@@ -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,2 @@
1
+ import type { PermissionFeaturesCollectionTranslations } from "./types.js";
2
+ export declare const permissionFeaturesDefaultTranslations: PermissionFeaturesCollectionTranslations;
@@ -0,0 +1,3 @@
1
+ import type { CollectionConfig } from "payload";
2
+ import type { PermissionFeaturesCollectionParams } from "./types.js";
3
+ export declare const getPermissionFeaturesCollection: (params: PermissionFeaturesCollectionParams) => CollectionConfig;
@@ -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,2 @@
1
+ import type { PermissionsCollectionTranslations } from "./types.js";
2
+ export declare const permissionsDefaultTranslations: PermissionsCollectionTranslations;
@@ -0,0 +1,3 @@
1
+ import type { CollectionConfig } from "payload";
2
+ import type { PermissionsCollectionParams } from "./types.js";
3
+ export declare const getPermissionsCollection: (params: PermissionsCollectionParams) => CollectionConfig;
@@ -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,2 @@
1
+ import type { RolesCollectionTranslations } from "./types.js";
2
+ export declare const rolesDefaultTranslations: RolesCollectionTranslations;
@@ -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,3 @@
1
+ import type { CollectionConfig } from "payload";
2
+ import type { RolesCollectionParams } from "./types.js";
3
+ export declare const getRolesCollection: (params: RolesCollectionParams) => CollectionConfig;
@@ -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,2 @@
1
+ import type { RolesPermissionsCollectionTranslations } from "./types.js";
2
+ export declare const rolesPermissionsDefaultTranslations: RolesPermissionsCollectionTranslations;
@@ -0,0 +1,3 @@
1
+ import type { CollectionConfig } from "payload";
2
+ import type { RolesPermissionsCollectionParams } from "./types.js";
3
+ export declare const getRolesPermissionsCollection: (params: RolesPermissionsCollectionParams) => CollectionConfig;
@@ -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,2 @@
1
+ import { UsersModificationTranslations } from "./types.js";
2
+ export declare const usersDefaultTranslations: UsersModificationTranslations;
@@ -0,0 +1,3 @@
1
+ import type { Config } from "payload";
2
+ import type { UsersModificationParams } from "./types.js";
3
+ export declare const modifyUsersCollection: (params?: UsersModificationParams) => (incomingConfig: Config) => Config;
@@ -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
+ };
@@ -0,0 +1,2 @@
1
+ import type { RolePermissionMatrixClientTranslations } from "./types.js";
2
+ export declare const rolePermissionMatrixClientDefaultTranslations: RolePermissionMatrixClientTranslations;
@@ -0,0 +1 @@
1
+ export declare const RolePermissionMatrixClient: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,18 @@
1
+ export type RolePermissionMatrixClientTranslations = {
2
+ [locale: string]: {
3
+ viewInUpdateScreenOnly?: {
4
+ label?: string;
5
+ placeholder?: string;
6
+ };
7
+ loading?: {
8
+ placeholder?: string;
9
+ };
10
+ title?: string;
11
+ features?: {
12
+ label?: string;
13
+ } | Record<string, string>;
14
+ actions?: {
15
+ label?: string;
16
+ } | Record<string, string>;
17
+ };
18
+ };
@@ -0,0 +1,2 @@
1
+ import type { PayloadHandler } from "payload";
2
+ export declare const customEndpointHandler: PayloadHandler;
@@ -0,0 +1 @@
1
+ export { RolePermissionMatrixClient } from "../components/role-permission-matrix-client/index.js";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import type { Config } from "payload";
2
+ import type { PayloadAuthRbacPluginConfig } from "./types.js";
3
+ export * from "./lib/constants/index.js";
4
+ export * from "./lib/utils/index.js";
5
+ export declare const payloadAuthRbacPlugin: (pluginOptions: PayloadAuthRbacPluginConfig) => (config: Config) => Config;
@@ -0,0 +1 @@
1
+ export declare const NAMESPACE: "plugin-rbac";
@@ -0,0 +1,14 @@
1
+ import * as general from "./general.js";
2
+ import * as permission from "./permission.js";
3
+ import * as permissionAction from "./permission-action.js";
4
+ import * as permissionFeature from "./permission-feature.js";
5
+ import * as role from "./role.js";
6
+ import * as user from "./user.js";
7
+ export declare const CONSTANTS: {
8
+ readonly GENERAL: typeof general;
9
+ readonly PERMISSION: typeof permission;
10
+ readonly PERMISSION_FEATURE: typeof permissionFeature;
11
+ readonly PERMISSION_ACTION: typeof permissionAction;
12
+ readonly ROLE: typeof role;
13
+ readonly USER: typeof user;
14
+ };
@@ -0,0 +1,8 @@
1
+ export declare const STATUS: {
2
+ readonly ACTIVE: "active";
3
+ readonly INACTIVE: "inactive";
4
+ };
5
+ export declare const TYPE: {
6
+ readonly MAIN: "main";
7
+ readonly SUB: "sub";
8
+ };
@@ -0,0 +1,4 @@
1
+ export declare const STATUS: {
2
+ readonly ACTIVE: "active";
3
+ readonly INACTIVE: "inactive";
4
+ };
@@ -0,0 +1,4 @@
1
+ export declare const STATUS: {
2
+ readonly ACTIVE: "active";
3
+ readonly INACTIVE: "inactive";
4
+ };
@@ -0,0 +1,9 @@
1
+ export declare const STATUS: {
2
+ readonly ACTIVE: "active";
3
+ readonly INACTIVE: "inactive";
4
+ };
5
+ export declare const DATA_SCOPE: {
6
+ readonly ALL: "all";
7
+ readonly OWN: "own";
8
+ readonly HIERARCHY: "hierarchy";
9
+ };
@@ -0,0 +1 @@
1
+ export declare const PARENT_PATH_SEPARATOR: ",";
@@ -0,0 +1,76 @@
1
+ import { Access, type PayloadRequest, type Where } from "payload";
2
+ import type { DataScope } from "../../collections/roles/types.js";
3
+ export type DataScopeOptions = {
4
+ /** Field on business collections storing the creator user id. Default: `createdBy`. */
5
+ createdByField?: string;
6
+ /** Users collection slug. Default: `users`. */
7
+ usersCollectionSlug?: string;
8
+ };
9
+ /**
10
+ * Access helper: allow only super admins.
11
+ * Check session first, then persisted users data.
12
+ */
13
+ export declare const getSuperAdminAccess: ({ req }: {
14
+ req: PayloadRequest;
15
+ }) => Promise<boolean>;
16
+ /**
17
+ * Access helper: allow current document owner or super admin.
18
+ */
19
+ export declare const getAuthenticatedOrSuperAdminAccess: Access | Promise<boolean>;
20
+ /**
21
+ * Resolve effective data scope from active roles.
22
+ * Widest scope wins: `all` > `hierarchy` > `own`.
23
+ */
24
+ export declare const resolveEffectiveDataScope: (req: PayloadRequest, options?: DataScopeOptions) => Promise<DataScope>;
25
+ /**
26
+ * Collect visible user IDs for hierarchy scope:
27
+ * current user + direct/indirect descendants from `parent` / `parentPath`.
28
+ */
29
+ export declare const getHierarchyVisibleUserIds: (req: PayloadRequest, options?: DataScopeOptions) => Promise<string[]>;
30
+ /**
31
+ * Build a read `Where` filter from data scope.
32
+ * Returns `true` when no extra filtering is required (`all` scope / super admin).
33
+ */
34
+ export declare const getDataScopeReadWhere: (req: PayloadRequest, options?: DataScopeOptions) => Promise<Where | true>;
35
+ /**
36
+ * Guard for privileged user documents.
37
+ * Non-super-admins cannot mutate users where `isSuperAdmin === true`.
38
+ */
39
+ export declare const isProtectedSuperAdminUserDoc: (doc: Record<string, unknown>) => boolean;
40
+ /**
41
+ * Document-level access check:
42
+ * RBAC permission (`featureCode` + `actionCode`) + data-scope evaluation.
43
+ * Super admins bypass.
44
+ */
45
+ export declare const canAccessDocumentByDataScope: ({ req, doc, featureCode, actionCode, collectionSlug, options, }: {
46
+ req: PayloadRequest;
47
+ doc: Record<string, unknown>;
48
+ featureCode: string;
49
+ actionCode: string;
50
+ collectionSlug: string;
51
+ options?: DataScopeOptions;
52
+ }) => Promise<boolean>;
53
+ /**
54
+ * Merge an existing `where` with scope-derived constraints.
55
+ */
56
+ export declare const mergeDataScopeWhere: (base: Where | undefined, scopeWhere: Where | true) => Where;
57
+ /**
58
+ * Unified access entrypoint.
59
+ *
60
+ * Modes:
61
+ * - `none`: permission-only (boolean)
62
+ * - `modify`: per-document mutation check (requires `collectionSlug` + runtime `id`)
63
+ * - implicit read mode: pass `options` to get a read `Where` filter after permission check
64
+ */
65
+ export declare const getPermissionAccess: ({ featureCode, actionCode, mode, collectionSlug, options, }: {
66
+ featureCode: string;
67
+ actionCode: string;
68
+ mode?: "none" | "modify";
69
+ collectionSlug?: string;
70
+ options?: DataScopeOptions;
71
+ }) => (({ req }: {
72
+ req: PayloadRequest;
73
+ }) => Promise<boolean | Where>) | (({ req, id }: {
74
+ req: PayloadRequest;
75
+ id?: string | number;
76
+ }) => Promise<boolean>);
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Converts a value to an ID string.
3
+ * @param value - The value to convert.
4
+ * @returns The ID string.
5
+ */
6
+ export declare const toID: (value?: ItemRef) => string;
@@ -0,0 +1,18 @@
1
+ import type { Field } from "payload";
2
+ /**
3
+ * Merges one plugin default field with a host override that shares the same `name`.
4
+ * Custom properties win (`{ ...defaultField, ...customField }`). Non-data fields
5
+ * (e.g. tabs, unnamed layout fields) are returned unchanged.
6
+ */
7
+ export declare const getMergedFieldAffectingData: ({ fields, defaultField, }: {
8
+ fields: Field[];
9
+ defaultField: Field;
10
+ }) => Field;
11
+ /**
12
+ * Builds the final `fields` array for a collection: each default is merged by name,
13
+ * then host-only fields are appended (data fields with new names, plus layout fields).
14
+ */
15
+ export declare const getArrayOfMergedFieldAffectingData: ({ fields, defaultFields, }: {
16
+ fields: Field[];
17
+ defaultFields: Field[];
18
+ }) => Field[];
@@ -0,0 +1,4 @@
1
+ export * from "./access.js";
2
+ export * from "./data.js";
3
+ export * from "./fields.js";
4
+ export * from "./localization.js";
@@ -0,0 +1,27 @@
1
+ import type { SelectField } from "payload";
2
+ /** Builds `{ [locale]: string }` from `getValue`, skipping empty values. */
3
+ export declare const toLocaleRecord: (locales: string[], getValue: (locale: string) => string | undefined) => Record<string, string>;
4
+ /**
5
+ * Select placeholder as per-locale strings (not `LabelFunction`) so it survives
6
+ * Next.js server → client serialization; Payload resolves it at render time.
7
+ */
8
+ export declare const toSelectPlaceholder: (locales: string[], getValue: (locale: string) => string | undefined) => NonNullable<SelectField["admin"]>["placeholder"];
9
+ type TranslationObject = {
10
+ [key: string]: TranslationValue;
11
+ };
12
+ type TranslationValue = TranslationObject | string | undefined;
13
+ /** Plugin defaults merged with host `translations` overrides. */
14
+ export declare const getMergedTranslations: <T extends Record<string, TranslationValue>>({ defaultTranslations, translations, }: {
15
+ defaultTranslations: T;
16
+ translations: Partial<T>;
17
+ }) => T;
18
+ /**
19
+ * Picks a nested branch from each locale, e.g. path `"collections.roles"`.
20
+ * Use `locales: "all"` or `["en", "vi"]`.
21
+ */
22
+ export declare const getAllTranslationsOfSpecificObject: <T = unknown>({ translations, path, locales, }: {
23
+ translations: Record<string, Record<string, unknown>>;
24
+ path: string;
25
+ locales?: "all" | string[];
26
+ }) => Record<string, T>;
27
+ export {};
@@ -0,0 +1,38 @@
1
+ import type * as PermissionActionTypes from "./collections/permission-actions/types.js";
2
+ import type * as PermissionFeatureTypes from "./collections/permission-features/types.js";
3
+ import type * as PermissionTypes from "./collections/permissions/types.js";
4
+ import type * as RoleTypes from "./collections/roles/types.js";
5
+ import type * as RolePermissionTypes from "./collections/roles-permissions/types.js";
6
+ import type * as UsersTypes from "./collections/users/types.js";
7
+ import type * as RolePermissionMatrixClientTypes from "./components/role-permission-matrix-client/types.js";
8
+ export * from "./collections/permission-actions/types.js";
9
+ export * from "./collections/permission-features/types.js";
10
+ export * from "./collections/permissions/types.js";
11
+ export * from "./collections/roles/types.js";
12
+ export * from "./collections/roles-permissions/types.js";
13
+ export * from "./collections/users/types.js";
14
+ export * from "./components/role-permission-matrix-client/types.js";
15
+ export type RBACTranslations = {
16
+ [locale: string]: {
17
+ collections?: {
18
+ permissionActions?: PermissionActionTypes.PermissionActionsCollectionTranslations[string];
19
+ permissionFeatures?: PermissionFeatureTypes.PermissionFeaturesCollectionTranslations[string];
20
+ permissions?: PermissionTypes.PermissionsCollectionTranslations[string];
21
+ roles?: RoleTypes.RolesCollectionTranslations[string];
22
+ rolesPermissions?: RolePermissionTypes.RolesPermissionsCollectionTranslations[string];
23
+ users?: UsersTypes.UsersModificationTranslations[string];
24
+ };
25
+ components?: {
26
+ rolePermissionMatrix?: RolePermissionMatrixClientTypes.RolePermissionMatrixClientTranslations[string];
27
+ };
28
+ };
29
+ };
30
+ export type PayloadAuthRbacPluginConfig = {
31
+ /**
32
+ * Collection slugs to augment (may include plugin-only collections absent from generated `CollectionSlug`).
33
+ */
34
+ collections?: Partial<Record<string, Omit<PermissionActionTypes.PermissionActionsCollectionParams, "translations"> | Omit<PermissionFeatureTypes.PermissionFeaturesCollectionParams, "translations"> | Omit<PermissionTypes.PermissionsCollectionParams, "translations"> | Omit<RoleTypes.RolesCollectionParams, "translations"> | Omit<RolePermissionTypes.RolesPermissionsCollectionParams, "translations">>>;
35
+ disabled?: boolean;
36
+ translations?: RBACTranslations;
37
+ autoModifyUsersCollection?: boolean;
38
+ };
package/package.json CHANGED
@@ -1,15 +1,29 @@
1
1
  {
2
2
  "name": "@zealamic/payload-auth-rbac-plugin",
3
- "version": "1.0.0-beta.1",
3
+ "version": "1.0.0-beta.9",
4
4
  "description": "A plugin for Payload CMS to manage authentication and authorization",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/zealamic/payload-auth-rbac-plugin.git"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/zealamic/payload-auth-rbac-plugin/issues"
13
+ },
14
+ "homepage": "https://github.com/zealamic/payload-auth-rbac-plugin#readme",
7
15
  "keywords": [
8
16
  "payload",
9
17
  "plugin",
10
18
  "rbac",
11
19
  "authentication",
12
- "authorization"
20
+ "authorization",
21
+ "payloadcms",
22
+ "payload-plugin",
23
+ "payload-rbac",
24
+ "payload-auth",
25
+ "payload-auth-rbac",
26
+ "payload-auth-rbac-plugin"
13
27
  ],
14
28
  "exports": {
15
29
  ".": {
@@ -64,6 +78,7 @@
64
78
  "@playwright/test": "1.58.2",
65
79
  "@swc-node/register": "1.10.9",
66
80
  "@swc/cli": "0.6.0",
81
+ "@swc/core": "^1.15.40",
67
82
  "@types/node": "22.19.9",
68
83
  "@types/react": "19.2.14",
69
84
  "@types/react-dom": "19.2.3",