roles-privileges-payload-plugin 1.1.2 → 1.2.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 +15 -0
- package/dist/collections/roles.d.ts +2 -2
- package/dist/collections/roles.js +27 -45
- package/dist/collections/roles.js.map +1 -1
- package/dist/components/PrivilegesSelect.d.ts +3 -3
- package/dist/components/PrivilegesSelect.js +89 -71
- package/dist/components/PrivilegesSelect.js.map +1 -1
- package/dist/exports/types.d.ts +1 -1
- package/dist/exports/types.js +0 -1
- package/dist/exports/types.js.map +1 -1
- package/dist/exports/utilities.d.ts +5 -4
- package/dist/exports/utilities.js +10 -8
- package/dist/exports/utilities.js.map +1 -1
- package/dist/fields/slug/SlugComponent.d.ts +9 -0
- package/dist/fields/slug/SlugComponent.js +83 -0
- package/dist/fields/slug/SlugComponent.js.map +1 -0
- package/dist/fields/slug/formatSlug.d.ts +3 -0
- package/dist/fields/slug/formatSlug.js +15 -0
- package/dist/fields/slug/formatSlug.js.map +1 -0
- package/dist/fields/slug/index.d.ts +8 -0
- package/dist/fields/slug/index.js +47 -0
- package/dist/fields/slug/index.js.map +1 -0
- package/dist/fields/slug/index.scss +12 -0
- package/dist/index.d.ts +17 -7
- package/dist/index.js +59 -10
- package/dist/index.js.map +1 -1
- package/dist/translations/index.js +4 -4
- package/dist/translations/index.js.map +1 -1
- package/dist/translations/languages/en.js +19 -18
- package/dist/translations/languages/en.js.map +1 -1
- package/dist/translations/languages/fr.js +19 -18
- package/dist/translations/languages/fr.js.map +1 -1
- package/dist/translations/types.d.ts +43 -42
- package/dist/translations/types.js.map +1 -1
- package/dist/utils/assignSuperAdminToFirstUser.d.ts +10 -0
- package/dist/utils/assignSuperAdminToFirstUser.js +70 -0
- package/dist/utils/assignSuperAdminToFirstUser.js.map +1 -0
- package/dist/utils/createCustomPrivilege.d.ts +9 -9
- package/dist/utils/createCustomPrivilege.js +4 -4
- package/dist/utils/createCustomPrivilege.js.map +1 -1
- package/dist/utils/generateGlobalPrivileges.d.ts +4 -4
- package/dist/utils/generateGlobalPrivileges.js +4 -4
- package/dist/utils/generateGlobalPrivileges.js.map +1 -1
- package/dist/utils/generatePrivileges.d.ts +6 -6
- package/dist/utils/generatePrivileges.js +6 -6
- package/dist/utils/generatePrivileges.js.map +1 -1
- package/dist/utils/seedSuperAdminRole.js +7 -7
- package/dist/utils/seedSuperAdminRole.js.map +1 -1
- package/package.json +9 -39
|
@@ -1,50 +1,51 @@
|
|
|
1
1
|
export const enTranslations = {
|
|
2
2
|
'plugin-roles-privileges': {
|
|
3
3
|
// Roles collection
|
|
4
|
-
'roles-collection-label-singular': 'Role',
|
|
5
4
|
'roles-collection-label-plural': 'Roles',
|
|
6
|
-
'roles-
|
|
7
|
-
'roles-field-slug-label': 'Slug',
|
|
8
|
-
'roles-field-slug-description': 'Unique identifier for this role',
|
|
9
|
-
'roles-field-privileges-label': 'Privileges',
|
|
10
|
-
'roles-field-privileges-description': 'Select the privileges this role should have',
|
|
11
|
-
'roles-field-description-label': 'Description',
|
|
5
|
+
'roles-collection-label-singular': 'Role',
|
|
12
6
|
'roles-field-description-description': 'Optional description of this role',
|
|
7
|
+
'roles-field-description-label': 'Description',
|
|
8
|
+
'roles-field-privileges-description': 'Select the privileges this role should have',
|
|
9
|
+
'roles-field-privileges-label': 'Privileges',
|
|
10
|
+
'roles-field-slug-description': 'Unique identifier for this role',
|
|
11
|
+
'roles-field-slug-label': 'Slug',
|
|
12
|
+
'roles-field-title-label': 'Role Title',
|
|
13
|
+
'user-roles-field-description': 'Roles assigned to this user',
|
|
13
14
|
// Privileges UI
|
|
14
15
|
'privileges-column-collections-globals': 'Collections & Globals',
|
|
15
|
-
'privileges-column-privileges': 'Privileges',
|
|
16
16
|
'privileges-column-description': 'Description',
|
|
17
|
+
'privileges-column-privileges': 'Privileges',
|
|
17
18
|
'privileges-select-placeholder': 'Select a collection or global to view privileges',
|
|
18
19
|
'privileges-select-privilege-placeholder': 'Select a privilege to view its description',
|
|
19
20
|
'privileges-selected-count': 'Selected Privileges',
|
|
20
21
|
// Privilege operations
|
|
21
22
|
'privilege-operation-create': 'Create',
|
|
23
|
+
'privilege-operation-delete': 'Delete',
|
|
22
24
|
'privilege-operation-read': 'Read',
|
|
23
25
|
'privilege-operation-update': 'Update',
|
|
24
|
-
'privilege-operation-delete': 'Delete',
|
|
25
26
|
// Collection privilege operation prefixes
|
|
26
27
|
'privilege-prefix-admin': 'Admin Access to',
|
|
27
28
|
'privilege-prefix-create': 'Create',
|
|
29
|
+
'privilege-prefix-delete': 'Delete',
|
|
28
30
|
'privilege-prefix-read': 'Read',
|
|
29
31
|
'privilege-prefix-readVersions': 'Read Versions:',
|
|
30
|
-
'privilege-prefix-update': 'Update',
|
|
31
|
-
'privilege-prefix-delete': 'Delete',
|
|
32
32
|
'privilege-prefix-unlock': 'Unlock',
|
|
33
|
+
'privilege-prefix-update': 'Update',
|
|
33
34
|
// Collection privilege description templates
|
|
34
35
|
'privilege-template-admin': 'Access the {label} admin panel and UI',
|
|
35
36
|
'privilege-template-admin-plural': 'true',
|
|
36
37
|
'privilege-template-create': 'Ability to create new {label}',
|
|
37
38
|
'privilege-template-create-plural': 'true',
|
|
39
|
+
'privilege-template-delete': 'Remove {label} from the system',
|
|
40
|
+
'privilege-template-delete-plural': 'true',
|
|
38
41
|
'privilege-template-read': 'View {label} content and information',
|
|
39
42
|
'privilege-template-read-plural': 'false',
|
|
40
43
|
'privilege-template-readVersions': 'Access and view previous versions of {label}',
|
|
41
44
|
'privilege-template-readVersions-plural': 'true',
|
|
42
|
-
'privilege-template-update': 'Modify existing {label} data',
|
|
43
|
-
'privilege-template-update-plural': 'false',
|
|
44
|
-
'privilege-template-delete': 'Remove {label} from the system',
|
|
45
|
-
'privilege-template-delete-plural': 'true',
|
|
46
45
|
'privilege-template-unlock': 'Unlock {label} that are being edited by other users',
|
|
47
46
|
'privilege-template-unlock-plural': 'true',
|
|
47
|
+
'privilege-template-update': 'Modify existing {label} data',
|
|
48
|
+
'privilege-template-update-plural': 'false',
|
|
48
49
|
// Global privilege operation prefixes
|
|
49
50
|
'privilege-prefix-global-read': 'Read',
|
|
50
51
|
'privilege-prefix-global-readDrafts': 'Read Drafts:',
|
|
@@ -60,13 +61,13 @@ export const enTranslations = {
|
|
|
60
61
|
'privilege-global-description': 'Manage {label} global settings',
|
|
61
62
|
// Privilege descriptions
|
|
62
63
|
'privilege-description-collection-create': 'Allows create operations on {{collection}} collection',
|
|
64
|
+
'privilege-description-collection-delete': 'Allows delete operations on {{collection}} collection',
|
|
65
|
+
'privilege-description-collection-info': 'Manage access privileges for this collection',
|
|
63
66
|
'privilege-description-collection-read': 'Allows read operations on {{collection}} collection',
|
|
64
67
|
'privilege-description-collection-update': 'Allows update operations on {{collection}} collection',
|
|
65
|
-
'privilege-description-
|
|
68
|
+
'privilege-description-global-info': 'Manage access privileges for this global',
|
|
66
69
|
'privilege-description-global-read': 'Allows read access to {{global}} global',
|
|
67
70
|
'privilege-description-global-update': 'Allows update access to {{global}} global',
|
|
68
|
-
'privilege-description-collection-info': 'Manage access privileges for this collection',
|
|
69
|
-
'privilege-description-global-info': 'Manage access privileges for this global',
|
|
70
71
|
// Errors
|
|
71
72
|
'error-cannot-delete-super-admin': 'Cannot delete the Super Admin role',
|
|
72
73
|
'error-cannot-modify-super-admin-slug': 'Cannot modify the Super Admin role slug'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/translations/languages/en.ts"],"sourcesContent":["import type { PluginTranslations } from '../types.js'\n\nexport const enTranslations: PluginTranslations = {\n 'plugin-roles-privileges': {\n // Roles collection\n 'roles-collection-label-
|
|
1
|
+
{"version":3,"sources":["../../../src/translations/languages/en.ts"],"sourcesContent":["import type { PluginTranslations } from '../types.js'\n\nexport const enTranslations: PluginTranslations = {\n 'plugin-roles-privileges': {\n // Roles collection\n 'roles-collection-label-plural': 'Roles',\n 'roles-collection-label-singular': 'Role',\n 'roles-field-description-description': 'Optional description of this role',\n 'roles-field-description-label': 'Description',\n 'roles-field-privileges-description': 'Select the privileges this role should have',\n 'roles-field-privileges-label': 'Privileges',\n 'roles-field-slug-description': 'Unique identifier for this role',\n 'roles-field-slug-label': 'Slug',\n 'roles-field-title-label': 'Role Title',\n 'user-roles-field-description': 'Roles assigned to this user',\n\n // Privileges UI\n 'privileges-column-collections-globals': 'Collections & Globals',\n 'privileges-column-description': 'Description',\n 'privileges-column-privileges': 'Privileges',\n 'privileges-select-placeholder': 'Select a collection or global to view privileges',\n 'privileges-select-privilege-placeholder': 'Select a privilege to view its description',\n 'privileges-selected-count': 'Selected Privileges',\n\n // Privilege operations\n 'privilege-operation-create': 'Create',\n 'privilege-operation-delete': 'Delete',\n 'privilege-operation-read': 'Read',\n 'privilege-operation-update': 'Update',\n\n // Collection privilege operation prefixes\n 'privilege-prefix-admin': 'Admin Access to',\n 'privilege-prefix-create': 'Create',\n 'privilege-prefix-delete': 'Delete',\n 'privilege-prefix-read': 'Read',\n 'privilege-prefix-readVersions': 'Read Versions:',\n 'privilege-prefix-unlock': 'Unlock',\n 'privilege-prefix-update': 'Update',\n\n // Collection privilege description templates\n 'privilege-template-admin': 'Access the {label} admin panel and UI',\n 'privilege-template-admin-plural': 'true',\n 'privilege-template-create': 'Ability to create new {label}',\n 'privilege-template-create-plural': 'true',\n 'privilege-template-delete': 'Remove {label} from the system',\n 'privilege-template-delete-plural': 'true',\n 'privilege-template-read': 'View {label} content and information',\n 'privilege-template-read-plural': 'false',\n 'privilege-template-readVersions': 'Access and view previous versions of {label}',\n 'privilege-template-readVersions-plural': 'true',\n 'privilege-template-unlock': 'Unlock {label} that are being edited by other users',\n 'privilege-template-unlock-plural': 'true',\n 'privilege-template-update': 'Modify existing {label} data',\n 'privilege-template-update-plural': 'false',\n\n // Global privilege operation prefixes\n 'privilege-prefix-global-read': 'Read',\n 'privilege-prefix-global-readDrafts': 'Read Drafts:',\n 'privilege-prefix-global-readVersions': 'Read Versions:',\n 'privilege-prefix-global-update': 'Update',\n\n // Global privilege description templates\n 'privilege-template-global-read': 'View {label} content and settings',\n 'privilege-template-global-readDrafts': 'Access and view draft versions of {label}',\n 'privilege-template-global-readVersions': 'Access and view previous versions of {label}',\n 'privilege-template-global-update': 'Modify {label} settings and data',\n\n // Collection/Global description templates\n 'privilege-collection-description': 'Manage {label} in the system',\n 'privilege-global-description': 'Manage {label} global settings',\n\n // Privilege descriptions\n 'privilege-description-collection-create':\n 'Allows create operations on {{collection}} collection',\n 'privilege-description-collection-delete':\n 'Allows delete operations on {{collection}} collection',\n 'privilege-description-collection-info': 'Manage access privileges for this collection',\n 'privilege-description-collection-read': 'Allows read operations on {{collection}} collection',\n 'privilege-description-collection-update':\n 'Allows update operations on {{collection}} collection',\n 'privilege-description-global-info': 'Manage access privileges for this global',\n 'privilege-description-global-read': 'Allows read access to {{global}} global',\n 'privilege-description-global-update': 'Allows update access to {{global}} global',\n\n // Errors\n 'error-cannot-delete-super-admin': 'Cannot delete the Super Admin role',\n 'error-cannot-modify-super-admin-slug': 'Cannot modify the Super Admin role slug',\n },\n}\n"],"names":["enTranslations"],"mappings":"AAEA,OAAO,MAAMA,iBAAqC;IAChD,2BAA2B;QACzB,mBAAmB;QACnB,iCAAiC;QACjC,mCAAmC;QACnC,uCAAuC;QACvC,iCAAiC;QACjC,sCAAsC;QACtC,gCAAgC;QAChC,gCAAgC;QAChC,0BAA0B;QAC1B,2BAA2B;QAC3B,gCAAgC;QAEhC,gBAAgB;QAChB,yCAAyC;QACzC,iCAAiC;QACjC,gCAAgC;QAChC,iCAAiC;QACjC,2CAA2C;QAC3C,6BAA6B;QAE7B,uBAAuB;QACvB,8BAA8B;QAC9B,8BAA8B;QAC9B,4BAA4B;QAC5B,8BAA8B;QAE9B,0CAA0C;QAC1C,0BAA0B;QAC1B,2BAA2B;QAC3B,2BAA2B;QAC3B,yBAAyB;QACzB,iCAAiC;QACjC,2BAA2B;QAC3B,2BAA2B;QAE3B,6CAA6C;QAC7C,4BAA4B;QAC5B,mCAAmC;QACnC,6BAA6B;QAC7B,oCAAoC;QACpC,6BAA6B;QAC7B,oCAAoC;QACpC,2BAA2B;QAC3B,kCAAkC;QAClC,mCAAmC;QACnC,0CAA0C;QAC1C,6BAA6B;QAC7B,oCAAoC;QACpC,6BAA6B;QAC7B,oCAAoC;QAEpC,sCAAsC;QACtC,gCAAgC;QAChC,sCAAsC;QACtC,wCAAwC;QACxC,kCAAkC;QAElC,yCAAyC;QACzC,kCAAkC;QAClC,wCAAwC;QACxC,0CAA0C;QAC1C,oCAAoC;QAEpC,0CAA0C;QAC1C,oCAAoC;QACpC,gCAAgC;QAEhC,yBAAyB;QACzB,2CACE;QACF,2CACE;QACF,yCAAyC;QACzC,yCAAyC;QACzC,2CACE;QACF,qCAAqC;QACrC,qCAAqC;QACrC,uCAAuC;QAEvC,SAAS;QACT,mCAAmC;QACnC,wCAAwC;IAC1C;AACF,EAAC"}
|
|
@@ -1,50 +1,51 @@
|
|
|
1
1
|
export const frTranslations = {
|
|
2
2
|
'plugin-roles-privileges': {
|
|
3
3
|
// Roles collection
|
|
4
|
-
'roles-collection-label-singular': 'Rôle',
|
|
5
4
|
'roles-collection-label-plural': 'Rôles',
|
|
6
|
-
'roles-
|
|
7
|
-
'roles-field-slug-label': 'Slug',
|
|
8
|
-
'roles-field-slug-description': 'Identifiant unique pour ce rôle',
|
|
9
|
-
'roles-field-privileges-label': 'Privilèges',
|
|
10
|
-
'roles-field-privileges-description': 'Sélectionnez les privilèges que ce rôle devrait avoir',
|
|
11
|
-
'roles-field-description-label': 'Description',
|
|
5
|
+
'roles-collection-label-singular': 'Rôle',
|
|
12
6
|
'roles-field-description-description': 'Description optionnelle de ce rôle',
|
|
7
|
+
'roles-field-description-label': 'Description',
|
|
8
|
+
'roles-field-privileges-description': 'Sélectionnez les privilèges que ce rôle devrait avoir',
|
|
9
|
+
'roles-field-privileges-label': 'Privilèges',
|
|
10
|
+
'roles-field-slug-description': 'Identifiant unique pour ce rôle',
|
|
11
|
+
'roles-field-slug-label': 'Slug',
|
|
12
|
+
'roles-field-title-label': 'Titre du rôle',
|
|
13
|
+
'user-roles-field-description': 'Rôles attribués à cet utilisateur',
|
|
13
14
|
// Privileges UI
|
|
14
15
|
'privileges-column-collections-globals': 'Collections & Globals',
|
|
15
|
-
'privileges-column-privileges': 'Privilèges',
|
|
16
16
|
'privileges-column-description': 'Description',
|
|
17
|
+
'privileges-column-privileges': 'Privilèges',
|
|
17
18
|
'privileges-select-placeholder': 'Sélectionnez une collection ou un global pour voir les privilèges',
|
|
18
19
|
'privileges-select-privilege-placeholder': 'Sélectionnez un privilège pour voir sa description',
|
|
19
20
|
'privileges-selected-count': 'Privilèges sélectionnés',
|
|
20
21
|
// Privilege operations
|
|
21
22
|
'privilege-operation-create': 'Créer',
|
|
23
|
+
'privilege-operation-delete': 'Supprimer',
|
|
22
24
|
'privilege-operation-read': 'Lire',
|
|
23
25
|
'privilege-operation-update': 'Mettre à jour',
|
|
24
|
-
'privilege-operation-delete': 'Supprimer',
|
|
25
26
|
// Collection privilege operation prefixes
|
|
26
27
|
'privilege-prefix-admin': 'Accès administrateur à',
|
|
27
28
|
'privilege-prefix-create': 'Créer',
|
|
29
|
+
'privilege-prefix-delete': 'Supprimer',
|
|
28
30
|
'privilege-prefix-read': 'Lire',
|
|
29
31
|
'privilege-prefix-readVersions': 'Lire les versions:',
|
|
30
|
-
'privilege-prefix-update': 'Modifier',
|
|
31
|
-
'privilege-prefix-delete': 'Supprimer',
|
|
32
32
|
'privilege-prefix-unlock': 'Déverrouiller',
|
|
33
|
+
'privilege-prefix-update': 'Modifier',
|
|
33
34
|
// Collection privilege description templates
|
|
34
35
|
'privilege-template-admin': "Accéder au panneau d'administration et à l'interface utilisateur des {label}",
|
|
35
36
|
'privilege-template-admin-plural': 'true',
|
|
36
37
|
'privilege-template-create': 'Possibilité de créer de nouveaux {label}',
|
|
37
38
|
'privilege-template-create-plural': 'true',
|
|
39
|
+
'privilege-template-delete': 'Supprimer {label} du système',
|
|
40
|
+
'privilege-template-delete-plural': 'true',
|
|
38
41
|
'privilege-template-read': 'Voir le contenu et les informations de {label}',
|
|
39
42
|
'privilege-template-read-plural': 'false',
|
|
40
43
|
'privilege-template-readVersions': 'Accéder et voir les versions précédentes des {label}',
|
|
41
44
|
'privilege-template-readVersions-plural': 'true',
|
|
42
|
-
'privilege-template-update': 'Modifier les données existantes de {label}',
|
|
43
|
-
'privilege-template-update-plural': 'false',
|
|
44
|
-
'privilege-template-delete': 'Supprimer {label} du système',
|
|
45
|
-
'privilege-template-delete-plural': 'true',
|
|
46
45
|
'privilege-template-unlock': "Déverrouiller {label} en cours de modification par d'autres utilisateurs",
|
|
47
46
|
'privilege-template-unlock-plural': 'true',
|
|
47
|
+
'privilege-template-update': 'Modifier les données existantes de {label}',
|
|
48
|
+
'privilege-template-update-plural': 'false',
|
|
48
49
|
// Global privilege operation prefixes
|
|
49
50
|
'privilege-prefix-global-read': 'Lire',
|
|
50
51
|
'privilege-prefix-global-readDrafts': 'Lire les brouillons:',
|
|
@@ -60,13 +61,13 @@ export const frTranslations = {
|
|
|
60
61
|
'privilege-global-description': 'Gérer les paramètres globaux de {label}',
|
|
61
62
|
// Privilege descriptions
|
|
62
63
|
'privilege-description-collection-create': 'Permet les opérations de création sur la collection {{collection}}',
|
|
64
|
+
'privilege-description-collection-delete': 'Permet les opérations de suppression sur la collection {{collection}}',
|
|
65
|
+
'privilege-description-collection-info': "Gérer les privilèges d'accès pour cette collection",
|
|
63
66
|
'privilege-description-collection-read': 'Permet les opérations de lecture sur la collection {{collection}}',
|
|
64
67
|
'privilege-description-collection-update': 'Permet les opérations de mise à jour sur la collection {{collection}}',
|
|
65
|
-
'privilege-description-
|
|
68
|
+
'privilege-description-global-info': "Gérer les privilèges d'accès pour ce global",
|
|
66
69
|
'privilege-description-global-read': "Permet l'accès en lecture au global {{global}}",
|
|
67
70
|
'privilege-description-global-update': "Permet l'accès en mise à jour au global {{global}}",
|
|
68
|
-
'privilege-description-collection-info': "Gérer les privilèges d'accès pour cette collection",
|
|
69
|
-
'privilege-description-global-info': "Gérer les privilèges d'accès pour ce global",
|
|
70
71
|
// Errors
|
|
71
72
|
'error-cannot-delete-super-admin': 'Impossible de supprimer le rôle Super Admin',
|
|
72
73
|
'error-cannot-modify-super-admin-slug': 'Impossible de modifier le slug du rôle Super Admin'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/translations/languages/fr.ts"],"sourcesContent":["import type { PluginTranslations } from '../types.js'\n\nexport const frTranslations: PluginTranslations = {\n 'plugin-roles-privileges': {\n // Roles collection\n 'roles-collection-label-
|
|
1
|
+
{"version":3,"sources":["../../../src/translations/languages/fr.ts"],"sourcesContent":["import type { PluginTranslations } from '../types.js'\n\nexport const frTranslations: PluginTranslations = {\n 'plugin-roles-privileges': {\n // Roles collection\n 'roles-collection-label-plural': 'Rôles',\n 'roles-collection-label-singular': 'Rôle',\n 'roles-field-description-description': 'Description optionnelle de ce rôle',\n 'roles-field-description-label': 'Description',\n 'roles-field-privileges-description': 'Sélectionnez les privilèges que ce rôle devrait avoir',\n 'roles-field-privileges-label': 'Privilèges',\n 'roles-field-slug-description': 'Identifiant unique pour ce rôle',\n 'roles-field-slug-label': 'Slug',\n 'roles-field-title-label': 'Titre du rôle',\n 'user-roles-field-description': 'Rôles attribués à cet utilisateur',\n\n // Privileges UI\n 'privileges-column-collections-globals': 'Collections & Globals',\n 'privileges-column-description': 'Description',\n 'privileges-column-privileges': 'Privilèges',\n 'privileges-select-placeholder':\n 'Sélectionnez une collection ou un global pour voir les privilèges',\n 'privileges-select-privilege-placeholder': 'Sélectionnez un privilège pour voir sa description',\n 'privileges-selected-count': 'Privilèges sélectionnés',\n\n // Privilege operations\n 'privilege-operation-create': 'Créer',\n 'privilege-operation-delete': 'Supprimer',\n 'privilege-operation-read': 'Lire',\n 'privilege-operation-update': 'Mettre à jour',\n\n // Collection privilege operation prefixes\n 'privilege-prefix-admin': 'Accès administrateur à',\n 'privilege-prefix-create': 'Créer',\n 'privilege-prefix-delete': 'Supprimer',\n 'privilege-prefix-read': 'Lire',\n 'privilege-prefix-readVersions': 'Lire les versions:',\n 'privilege-prefix-unlock': 'Déverrouiller',\n 'privilege-prefix-update': 'Modifier',\n\n // Collection privilege description templates\n 'privilege-template-admin':\n \"Accéder au panneau d'administration et à l'interface utilisateur des {label}\",\n 'privilege-template-admin-plural': 'true',\n 'privilege-template-create': 'Possibilité de créer de nouveaux {label}',\n 'privilege-template-create-plural': 'true',\n 'privilege-template-delete': 'Supprimer {label} du système',\n 'privilege-template-delete-plural': 'true',\n 'privilege-template-read': 'Voir le contenu et les informations de {label}',\n 'privilege-template-read-plural': 'false',\n 'privilege-template-readVersions': 'Accéder et voir les versions précédentes des {label}',\n 'privilege-template-readVersions-plural': 'true',\n 'privilege-template-unlock':\n \"Déverrouiller {label} en cours de modification par d'autres utilisateurs\",\n 'privilege-template-unlock-plural': 'true',\n 'privilege-template-update': 'Modifier les données existantes de {label}',\n 'privilege-template-update-plural': 'false',\n\n // Global privilege operation prefixes\n 'privilege-prefix-global-read': 'Lire',\n 'privilege-prefix-global-readDrafts': 'Lire les brouillons:',\n 'privilege-prefix-global-readVersions': 'Lire les versions:',\n 'privilege-prefix-global-update': 'Modifier',\n\n // Global privilege description templates\n 'privilege-template-global-read': 'Voir le contenu et les paramètres de {label}',\n 'privilege-template-global-readDrafts': 'Accéder et voir les brouillons de {label}',\n 'privilege-template-global-readVersions': 'Accéder et voir les versions précédentes de {label}',\n 'privilege-template-global-update': 'Modifier les paramètres et données de {label}',\n\n // Collection/Global description templates\n 'privilege-collection-description': 'Gérer {label} dans le système',\n 'privilege-global-description': 'Gérer les paramètres globaux de {label}',\n\n // Privilege descriptions\n 'privilege-description-collection-create':\n 'Permet les opérations de création sur la collection {{collection}}',\n 'privilege-description-collection-delete':\n 'Permet les opérations de suppression sur la collection {{collection}}',\n 'privilege-description-collection-info': \"Gérer les privilèges d'accès pour cette collection\",\n 'privilege-description-collection-read':\n 'Permet les opérations de lecture sur la collection {{collection}}',\n 'privilege-description-collection-update':\n 'Permet les opérations de mise à jour sur la collection {{collection}}',\n 'privilege-description-global-info': \"Gérer les privilèges d'accès pour ce global\",\n 'privilege-description-global-read': \"Permet l'accès en lecture au global {{global}}\",\n 'privilege-description-global-update': \"Permet l'accès en mise à jour au global {{global}}\",\n\n // Errors\n 'error-cannot-delete-super-admin': 'Impossible de supprimer le rôle Super Admin',\n 'error-cannot-modify-super-admin-slug': 'Impossible de modifier le slug du rôle Super Admin',\n },\n}\n"],"names":["frTranslations"],"mappings":"AAEA,OAAO,MAAMA,iBAAqC;IAChD,2BAA2B;QACzB,mBAAmB;QACnB,iCAAiC;QACjC,mCAAmC;QACnC,uCAAuC;QACvC,iCAAiC;QACjC,sCAAsC;QACtC,gCAAgC;QAChC,gCAAgC;QAChC,0BAA0B;QAC1B,2BAA2B;QAC3B,gCAAgC;QAEhC,gBAAgB;QAChB,yCAAyC;QACzC,iCAAiC;QACjC,gCAAgC;QAChC,iCACE;QACF,2CAA2C;QAC3C,6BAA6B;QAE7B,uBAAuB;QACvB,8BAA8B;QAC9B,8BAA8B;QAC9B,4BAA4B;QAC5B,8BAA8B;QAE9B,0CAA0C;QAC1C,0BAA0B;QAC1B,2BAA2B;QAC3B,2BAA2B;QAC3B,yBAAyB;QACzB,iCAAiC;QACjC,2BAA2B;QAC3B,2BAA2B;QAE3B,6CAA6C;QAC7C,4BACE;QACF,mCAAmC;QACnC,6BAA6B;QAC7B,oCAAoC;QACpC,6BAA6B;QAC7B,oCAAoC;QACpC,2BAA2B;QAC3B,kCAAkC;QAClC,mCAAmC;QACnC,0CAA0C;QAC1C,6BACE;QACF,oCAAoC;QACpC,6BAA6B;QAC7B,oCAAoC;QAEpC,sCAAsC;QACtC,gCAAgC;QAChC,sCAAsC;QACtC,wCAAwC;QACxC,kCAAkC;QAElC,yCAAyC;QACzC,kCAAkC;QAClC,wCAAwC;QACxC,0CAA0C;QAC1C,oCAAoC;QAEpC,0CAA0C;QAC1C,oCAAoC;QACpC,gCAAgC;QAEhC,yBAAyB;QACzB,2CACE;QACF,2CACE;QACF,yCAAyC;QACzC,yCACE;QACF,2CACE;QACF,qCAAqC;QACrC,qCAAqC;QACrC,uCAAuC;QAEvC,SAAS;QACT,mCAAmC;QACnC,wCAAwC;IAC1C;AACF,EAAC"}
|
|
@@ -1,65 +1,66 @@
|
|
|
1
1
|
export type PluginTranslations = {
|
|
2
2
|
'plugin-roles-privileges': {
|
|
3
|
-
'
|
|
4
|
-
'
|
|
5
|
-
'
|
|
6
|
-
'
|
|
7
|
-
'
|
|
8
|
-
'
|
|
9
|
-
'
|
|
10
|
-
'
|
|
11
|
-
'
|
|
12
|
-
'
|
|
13
|
-
'
|
|
14
|
-
'
|
|
15
|
-
'privileges-select-placeholder': string;
|
|
16
|
-
'privileges-select-privilege-placeholder': string;
|
|
17
|
-
'privileges-selected-count': string;
|
|
3
|
+
'error-cannot-delete-super-admin': string;
|
|
4
|
+
'error-cannot-modify-super-admin-slug': string;
|
|
5
|
+
'privilege-collection-description': string;
|
|
6
|
+
'privilege-description-collection-create': string;
|
|
7
|
+
'privilege-description-collection-delete': string;
|
|
8
|
+
'privilege-description-collection-info': string;
|
|
9
|
+
'privilege-description-collection-read': string;
|
|
10
|
+
'privilege-description-collection-update': string;
|
|
11
|
+
'privilege-description-global-info': string;
|
|
12
|
+
'privilege-description-global-read': string;
|
|
13
|
+
'privilege-description-global-update': string;
|
|
14
|
+
'privilege-global-description': string;
|
|
18
15
|
'privilege-operation-create': string;
|
|
16
|
+
'privilege-operation-delete': string;
|
|
19
17
|
'privilege-operation-read': string;
|
|
20
18
|
'privilege-operation-update': string;
|
|
21
|
-
'privilege-operation-delete': string;
|
|
22
19
|
'privilege-prefix-admin': string;
|
|
23
20
|
'privilege-prefix-create': string;
|
|
21
|
+
'privilege-prefix-delete': string;
|
|
22
|
+
'privilege-prefix-global-read': string;
|
|
23
|
+
'privilege-prefix-global-readDrafts': string;
|
|
24
|
+
'privilege-prefix-global-readVersions': string;
|
|
25
|
+
'privilege-prefix-global-update': string;
|
|
24
26
|
'privilege-prefix-read': string;
|
|
25
27
|
'privilege-prefix-readVersions': string;
|
|
26
|
-
'privilege-prefix-update': string;
|
|
27
|
-
'privilege-prefix-delete': string;
|
|
28
28
|
'privilege-prefix-unlock': string;
|
|
29
|
+
'privilege-prefix-update': string;
|
|
29
30
|
'privilege-template-admin': string;
|
|
30
31
|
'privilege-template-admin-plural': string;
|
|
31
32
|
'privilege-template-create': string;
|
|
32
33
|
'privilege-template-create-plural': string;
|
|
33
|
-
'privilege-template-read': string;
|
|
34
|
-
'privilege-template-read-plural': string;
|
|
35
|
-
'privilege-template-readVersions': string;
|
|
36
|
-
'privilege-template-readVersions-plural': string;
|
|
37
|
-
'privilege-template-update': string;
|
|
38
|
-
'privilege-template-update-plural': string;
|
|
39
34
|
'privilege-template-delete': string;
|
|
40
35
|
'privilege-template-delete-plural': string;
|
|
41
|
-
'privilege-template-unlock': string;
|
|
42
|
-
'privilege-template-unlock-plural': string;
|
|
43
|
-
'privilege-prefix-global-read': string;
|
|
44
|
-
'privilege-prefix-global-readDrafts': string;
|
|
45
|
-
'privilege-prefix-global-readVersions': string;
|
|
46
|
-
'privilege-prefix-global-update': string;
|
|
47
36
|
'privilege-template-global-read': string;
|
|
48
37
|
'privilege-template-global-readDrafts': string;
|
|
49
38
|
'privilege-template-global-readVersions': string;
|
|
50
39
|
'privilege-template-global-update': string;
|
|
51
|
-
'privilege-
|
|
52
|
-
'privilege-
|
|
53
|
-
'privilege-
|
|
54
|
-
'privilege-
|
|
55
|
-
'privilege-
|
|
56
|
-
'privilege-
|
|
57
|
-
'privilege-
|
|
58
|
-
'privilege-
|
|
59
|
-
'
|
|
60
|
-
'
|
|
61
|
-
'
|
|
62
|
-
'
|
|
40
|
+
'privilege-template-read': string;
|
|
41
|
+
'privilege-template-read-plural': string;
|
|
42
|
+
'privilege-template-readVersions': string;
|
|
43
|
+
'privilege-template-readVersions-plural': string;
|
|
44
|
+
'privilege-template-unlock': string;
|
|
45
|
+
'privilege-template-unlock-plural': string;
|
|
46
|
+
'privilege-template-update': string;
|
|
47
|
+
'privilege-template-update-plural': string;
|
|
48
|
+
'privileges-column-collections-globals': string;
|
|
49
|
+
'privileges-column-description': string;
|
|
50
|
+
'privileges-column-privileges': string;
|
|
51
|
+
'privileges-select-placeholder': string;
|
|
52
|
+
'privileges-select-privilege-placeholder': string;
|
|
53
|
+
'privileges-selected-count': string;
|
|
54
|
+
'roles-collection-label-plural': string;
|
|
55
|
+
'roles-collection-label-singular': string;
|
|
56
|
+
'roles-field-description-description': string;
|
|
57
|
+
'roles-field-description-label': string;
|
|
58
|
+
'roles-field-privileges-description': string;
|
|
59
|
+
'roles-field-privileges-label': string;
|
|
60
|
+
'roles-field-slug-description': string;
|
|
61
|
+
'roles-field-slug-label': string;
|
|
62
|
+
'roles-field-title-label': string;
|
|
63
|
+
'user-roles-field-description': string;
|
|
63
64
|
};
|
|
64
65
|
};
|
|
65
66
|
export type PluginDefaultTranslationsObject = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/translations/types.ts"],"sourcesContent":["export type PluginTranslations = {\n 'plugin-roles-privileges': {\n //
|
|
1
|
+
{"version":3,"sources":["../../src/translations/types.ts"],"sourcesContent":["export type PluginTranslations = {\n 'plugin-roles-privileges': {\n // Errors\n 'error-cannot-delete-super-admin': string\n 'error-cannot-modify-super-admin-slug': string\n // Collection/Global description templates\n 'privilege-collection-description': string\n // Privilege descriptions (legacy)\n 'privilege-description-collection-create': string\n 'privilege-description-collection-delete': string\n 'privilege-description-collection-info': string\n 'privilege-description-collection-read': string\n 'privilege-description-collection-update': string\n 'privilege-description-global-info': string\n\n 'privilege-description-global-read': string\n 'privilege-description-global-update': string\n 'privilege-global-description': string\n // Privilege operations\n 'privilege-operation-create': string\n 'privilege-operation-delete': string\n 'privilege-operation-read': string\n\n 'privilege-operation-update': string\n // Collection privilege operation prefixes\n 'privilege-prefix-admin': string\n 'privilege-prefix-create': string\n 'privilege-prefix-delete': string\n\n // Global privilege operation prefixes\n 'privilege-prefix-global-read': string\n 'privilege-prefix-global-readDrafts': string\n 'privilege-prefix-global-readVersions': string\n 'privilege-prefix-global-update': string\n 'privilege-prefix-read': string\n 'privilege-prefix-readVersions': string\n 'privilege-prefix-unlock': string\n\n 'privilege-prefix-update': string\n // Collection privilege description templates\n 'privilege-template-admin': string\n 'privilege-template-admin-plural': string\n 'privilege-template-create': string\n 'privilege-template-create-plural': string\n 'privilege-template-delete': string\n 'privilege-template-delete-plural': string\n // Global privilege description templates\n 'privilege-template-global-read': string\n 'privilege-template-global-readDrafts': string\n 'privilege-template-global-readVersions': string\n 'privilege-template-global-update': string\n 'privilege-template-read': string\n 'privilege-template-read-plural': string\n 'privilege-template-readVersions': string\n\n 'privilege-template-readVersions-plural': string\n 'privilege-template-unlock': string\n 'privilege-template-unlock-plural': string\n 'privilege-template-update': string\n\n 'privilege-template-update-plural': string\n // Privileges UI\n 'privileges-column-collections-globals': string\n 'privileges-column-description': string\n 'privileges-column-privileges': string\n\n 'privileges-select-placeholder': string\n 'privileges-select-privilege-placeholder': string\n\n 'privileges-selected-count': string\n // Roles collection\n 'roles-collection-label-plural': string\n 'roles-collection-label-singular': string\n 'roles-field-description-description': string\n 'roles-field-description-label': string\n 'roles-field-privileges-description': string\n 'roles-field-privileges-label': string\n 'roles-field-slug-description': string\n\n 'roles-field-slug-label': string\n 'roles-field-title-label': string\n 'user-roles-field-description': string\n }\n}\n\nexport type PluginDefaultTranslationsObject = {\n 'plugin-roles-privileges': PluginTranslations['plugin-roles-privileges']\n}\n"],"names":[],"mappings":"AAqFA,WAEC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CollectionAfterChangeHook, CollectionConfig } from 'payload';
|
|
2
|
+
/**
|
|
3
|
+
* Create a hook to assign the Super Admin role to the first user created in the system
|
|
4
|
+
* This ensures that the initial user has full access to configure the system
|
|
5
|
+
*/
|
|
6
|
+
export declare const createAssignSuperAdminToFirstUserHook: (rolesFieldName?: string) => CollectionAfterChangeHook;
|
|
7
|
+
/**
|
|
8
|
+
* Wrap a user collection config to add the first user super admin assignment hook
|
|
9
|
+
*/
|
|
10
|
+
export declare const wrapUserCollectionWithSuperAdminHook: (collection: CollectionConfig, rolesFieldName?: string) => CollectionConfig;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a hook to assign the Super Admin role to the first user created in the system
|
|
3
|
+
* This ensures that the initial user has full access to configure the system
|
|
4
|
+
*/ export const createAssignSuperAdminToFirstUserHook = (rolesFieldName = 'roles')=>async ({ collection, doc, operation, req })=>{
|
|
5
|
+
// Only process on user creation
|
|
6
|
+
if (operation !== 'create') {
|
|
7
|
+
return doc;
|
|
8
|
+
}
|
|
9
|
+
try {
|
|
10
|
+
// Check if this is the first user in the system
|
|
11
|
+
const users = await req.payload.find({
|
|
12
|
+
collection: collection.slug,
|
|
13
|
+
limit: 2
|
|
14
|
+
});
|
|
15
|
+
// If this is the first user (only 1 user exists), assign super admin role
|
|
16
|
+
if (users.totalDocs === 1) {
|
|
17
|
+
// Find the Super Admin role
|
|
18
|
+
const superAdminRole = await req.payload.find({
|
|
19
|
+
collection: 'roles',
|
|
20
|
+
limit: 1,
|
|
21
|
+
where: {
|
|
22
|
+
slug: {
|
|
23
|
+
equals: 'super-admin'
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
if (superAdminRole.docs.length > 0) {
|
|
28
|
+
const roleId = superAdminRole.docs[0].id;
|
|
29
|
+
// Update the user with the Super Admin role
|
|
30
|
+
const updatedUser = await req.payload.update({
|
|
31
|
+
id: doc.id,
|
|
32
|
+
collection: collection.slug,
|
|
33
|
+
data: {
|
|
34
|
+
...doc,
|
|
35
|
+
[rolesFieldName]: [
|
|
36
|
+
roleId
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
req.payload.logger.info(`✅ First user created - Super Admin role assigned to user: ${updatedUser.id}`);
|
|
41
|
+
return updatedUser;
|
|
42
|
+
} else {
|
|
43
|
+
req.payload.logger.warn('⚠️ Super Admin role not found. First user created without role assignment.');
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
} catch (error) {
|
|
47
|
+
req.payload.logger.error('❌ Error assigning Super Admin role to first user:', error);
|
|
48
|
+
}
|
|
49
|
+
return doc;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Wrap a user collection config to add the first user super admin assignment hook
|
|
53
|
+
*/ export const wrapUserCollectionWithSuperAdminHook = (collection, rolesFieldName = 'roles')=>{
|
|
54
|
+
const existingAfterChange = collection.hooks?.afterChange || [];
|
|
55
|
+
const afterChangeArray = Array.isArray(existingAfterChange) ? existingAfterChange : [
|
|
56
|
+
existingAfterChange
|
|
57
|
+
];
|
|
58
|
+
return {
|
|
59
|
+
...collection,
|
|
60
|
+
hooks: {
|
|
61
|
+
...collection.hooks,
|
|
62
|
+
afterChange: [
|
|
63
|
+
...afterChangeArray,
|
|
64
|
+
createAssignSuperAdminToFirstUserHook(rolesFieldName)
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
//# sourceMappingURL=assignSuperAdminToFirstUser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/assignSuperAdminToFirstUser.ts"],"sourcesContent":["import type { CollectionAfterChangeHook, CollectionConfig } from 'payload'\n\n/**\n * Create a hook to assign the Super Admin role to the first user created in the system\n * This ensures that the initial user has full access to configure the system\n */\nexport const createAssignSuperAdminToFirstUserHook =\n (rolesFieldName: string = 'roles'): CollectionAfterChangeHook =>\n async ({ collection, doc, operation, req }) => {\n // Only process on user creation\n if (operation !== 'create') {\n return doc\n }\n\n try {\n // Check if this is the first user in the system\n const users = await req.payload.find({\n collection: collection.slug,\n limit: 2, // We only need to know if there are 1 or 2+ users\n })\n\n // If this is the first user (only 1 user exists), assign super admin role\n if (users.totalDocs === 1) {\n // Find the Super Admin role\n const superAdminRole = await req.payload.find({\n collection: 'roles',\n limit: 1,\n where: {\n slug: {\n equals: 'super-admin',\n },\n },\n })\n\n if (superAdminRole.docs.length > 0) {\n const roleId = superAdminRole.docs[0].id\n\n // Update the user with the Super Admin role\n const updatedUser = await req.payload.update({\n id: doc.id,\n collection: collection.slug,\n data: {\n ...doc,\n [rolesFieldName]: [roleId],\n },\n })\n\n req.payload.logger.info(\n `✅ First user created - Super Admin role assigned to user: ${updatedUser.id}`,\n )\n\n return updatedUser\n } else {\n req.payload.logger.warn(\n '⚠️ Super Admin role not found. First user created without role assignment.',\n )\n }\n }\n } catch (error) {\n req.payload.logger.error('❌ Error assigning Super Admin role to first user:', error)\n }\n\n return doc\n }\n\n/**\n * Wrap a user collection config to add the first user super admin assignment hook\n */\nexport const wrapUserCollectionWithSuperAdminHook = (\n collection: CollectionConfig,\n rolesFieldName: string = 'roles',\n): CollectionConfig => {\n const existingAfterChange = collection.hooks?.afterChange || []\n const afterChangeArray = Array.isArray(existingAfterChange)\n ? existingAfterChange\n : [existingAfterChange]\n\n return {\n ...collection,\n hooks: {\n ...collection.hooks,\n afterChange: [...afterChangeArray, createAssignSuperAdminToFirstUserHook(rolesFieldName)],\n },\n }\n}\n"],"names":["createAssignSuperAdminToFirstUserHook","rolesFieldName","collection","doc","operation","req","users","payload","find","slug","limit","totalDocs","superAdminRole","where","equals","docs","length","roleId","id","updatedUser","update","data","logger","info","warn","error","wrapUserCollectionWithSuperAdminHook","existingAfterChange","hooks","afterChange","afterChangeArray","Array","isArray"],"mappings":"AAEA;;;CAGC,GACD,OAAO,MAAMA,wCACX,CAACC,iBAAyB,OAAO,GACjC,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAEC,SAAS,EAAEC,GAAG,EAAE;QACxC,gCAAgC;QAChC,IAAID,cAAc,UAAU;YAC1B,OAAOD;QACT;QAEA,IAAI;YACF,gDAAgD;YAChD,MAAMG,QAAQ,MAAMD,IAAIE,OAAO,CAACC,IAAI,CAAC;gBACnCN,YAAYA,WAAWO,IAAI;gBAC3BC,OAAO;YACT;YAEA,0EAA0E;YAC1E,IAAIJ,MAAMK,SAAS,KAAK,GAAG;gBACzB,4BAA4B;gBAC5B,MAAMC,iBAAiB,MAAMP,IAAIE,OAAO,CAACC,IAAI,CAAC;oBAC5CN,YAAY;oBACZQ,OAAO;oBACPG,OAAO;wBACLJ,MAAM;4BACJK,QAAQ;wBACV;oBACF;gBACF;gBAEA,IAAIF,eAAeG,IAAI,CAACC,MAAM,GAAG,GAAG;oBAClC,MAAMC,SAASL,eAAeG,IAAI,CAAC,EAAE,CAACG,EAAE;oBAExC,4CAA4C;oBAC5C,MAAMC,cAAc,MAAMd,IAAIE,OAAO,CAACa,MAAM,CAAC;wBAC3CF,IAAIf,IAAIe,EAAE;wBACVhB,YAAYA,WAAWO,IAAI;wBAC3BY,MAAM;4BACJ,GAAGlB,GAAG;4BACN,CAACF,eAAe,EAAE;gCAACgB;6BAAO;wBAC5B;oBACF;oBAEAZ,IAAIE,OAAO,CAACe,MAAM,CAACC,IAAI,CACrB,CAAC,0DAA0D,EAAEJ,YAAYD,EAAE,EAAE;oBAG/E,OAAOC;gBACT,OAAO;oBACLd,IAAIE,OAAO,CAACe,MAAM,CAACE,IAAI,CACrB;gBAEJ;YACF;QACF,EAAE,OAAOC,OAAO;YACdpB,IAAIE,OAAO,CAACe,MAAM,CAACG,KAAK,CAAC,qDAAqDA;QAChF;QAEA,OAAOtB;IACT,EAAC;AAEH;;CAEC,GACD,OAAO,MAAMuB,uCAAuC,CAClDxB,YACAD,iBAAyB,OAAO;IAEhC,MAAM0B,sBAAsBzB,WAAW0B,KAAK,EAAEC,eAAe,EAAE;IAC/D,MAAMC,mBAAmBC,MAAMC,OAAO,CAACL,uBACnCA,sBACA;QAACA;KAAoB;IAEzB,OAAO;QACL,GAAGzB,UAAU;QACb0B,OAAO;YACL,GAAG1B,WAAW0B,KAAK;YACnBC,aAAa;mBAAIC;gBAAkB9B,sCAAsCC;aAAgB;QAC3F;IACF;AACF,EAAC"}
|
|
@@ -5,29 +5,29 @@ import type { Privilege } from './generatePrivileges.js';
|
|
|
5
5
|
* Organized by collection/global slug
|
|
6
6
|
*/
|
|
7
7
|
export declare const customPrivilegesRegistry: Map<string, {
|
|
8
|
-
slug: string;
|
|
9
8
|
label: Record<string, string>;
|
|
9
|
+
privileges: Record<string, GlobalPrivilege | Privilege>;
|
|
10
|
+
slug: string;
|
|
10
11
|
type: "collection" | "global";
|
|
11
|
-
privileges: Record<string, Privilege | GlobalPrivilege>;
|
|
12
12
|
}>;
|
|
13
13
|
/**
|
|
14
14
|
* Configuration for creating a custom privilege
|
|
15
15
|
*/
|
|
16
16
|
export type CustomPrivilegeConfig = {
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
18
|
+
* Descriptions for the privilege in different languages
|
|
19
|
+
* @example { en: 'Ability to publish posts', fr: 'Capacité de publier des articles' }
|
|
19
20
|
*/
|
|
20
|
-
|
|
21
|
+
description: Record<string, string>;
|
|
21
22
|
/**
|
|
22
23
|
* Labels for the privilege in different languages
|
|
23
24
|
* @example { en: 'Publish Posts', fr: 'Publier les articles' }
|
|
24
25
|
*/
|
|
25
26
|
label: Record<string, string>;
|
|
26
27
|
/**
|
|
27
|
-
*
|
|
28
|
-
* @example { en: 'Ability to publish posts', fr: 'Capacité de publier des articles' }
|
|
28
|
+
* Unique key for the privilege (e.g., 'posts-publish', 'users-approve')
|
|
29
29
|
*/
|
|
30
|
-
|
|
30
|
+
privilegeKey: string;
|
|
31
31
|
};
|
|
32
32
|
/**
|
|
33
33
|
* Register a custom privilege to appear in the admin UI
|
|
@@ -52,8 +52,8 @@ export type CustomPrivilegeConfig = {
|
|
|
52
52
|
* ```
|
|
53
53
|
*/
|
|
54
54
|
export declare const registerCustomPrivilege: (collectionOrGlobalSlug: string, config: CustomPrivilegeConfig, options?: {
|
|
55
|
-
type?: "collection" | "global";
|
|
56
55
|
groupLabel?: Record<string, string>;
|
|
56
|
+
type?: "collection" | "global";
|
|
57
57
|
}) => Privilege;
|
|
58
58
|
/**
|
|
59
59
|
* Register multiple custom privileges at once to appear in the admin UI
|
|
@@ -80,8 +80,8 @@ export declare const registerCustomPrivilege: (collectionOrGlobalSlug: string, c
|
|
|
80
80
|
* ```
|
|
81
81
|
*/
|
|
82
82
|
export declare const registerCustomPrivileges: (collectionOrGlobalSlug: string, configs: CustomPrivilegeConfig[], options?: {
|
|
83
|
-
type?: "collection" | "global";
|
|
84
83
|
groupLabel?: Record<string, string>;
|
|
84
|
+
type?: "collection" | "global";
|
|
85
85
|
}) => Privilege[];
|
|
86
86
|
/**
|
|
87
87
|
* Type alias for GlobalPrivilege (for consistency)
|
|
@@ -25,20 +25,20 @@
|
|
|
25
25
|
* ```
|
|
26
26
|
*/ export const registerCustomPrivilege = (collectionOrGlobalSlug, config, options)=>{
|
|
27
27
|
const privilege = {
|
|
28
|
-
privilegeKey: config.privilegeKey,
|
|
29
|
-
label: config.label,
|
|
30
28
|
description: config.description,
|
|
31
|
-
isCustom: true
|
|
29
|
+
isCustom: true,
|
|
30
|
+
label: config.label,
|
|
31
|
+
privilegeKey: config.privilegeKey
|
|
32
32
|
};
|
|
33
33
|
// Get or create the group for this collection/global
|
|
34
34
|
let group = customPrivilegesRegistry.get(collectionOrGlobalSlug);
|
|
35
35
|
if (!group) {
|
|
36
36
|
group = {
|
|
37
37
|
slug: collectionOrGlobalSlug,
|
|
38
|
+
type: options?.type || 'collection',
|
|
38
39
|
label: options?.groupLabel || {
|
|
39
40
|
_default: collectionOrGlobalSlug
|
|
40
41
|
},
|
|
41
|
-
type: options?.type || 'collection',
|
|
42
42
|
privileges: {}
|
|
43
43
|
};
|
|
44
44
|
customPrivilegesRegistry.set(collectionOrGlobalSlug, group);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/createCustomPrivilege.ts"],"sourcesContent":["import type { GlobalPrivilege } from './generateGlobalPrivileges.js'\nimport type { Privilege } from './generatePrivileges.js'\n\n/**\n * Storage for custom privileges that should appear in the UI\n * Organized by collection/global slug\n */\nexport const customPrivilegesRegistry = new Map<\n string,\n {\n
|
|
1
|
+
{"version":3,"sources":["../../src/utils/createCustomPrivilege.ts"],"sourcesContent":["import type { GlobalPrivilege } from './generateGlobalPrivileges.js'\nimport type { Privilege } from './generatePrivileges.js'\n\n/**\n * Storage for custom privileges that should appear in the UI\n * Organized by collection/global slug\n */\nexport const customPrivilegesRegistry = new Map<\n string,\n {\n label: Record<string, string>\n privileges: Record<string, GlobalPrivilege | Privilege>\n slug: string\n type: 'collection' | 'global'\n }\n>()\n\n/**\n * Configuration for creating a custom privilege\n */\nexport type CustomPrivilegeConfig = {\n /**\n * Descriptions for the privilege in different languages\n * @example { en: 'Ability to publish posts', fr: 'Capacité de publier des articles' }\n */\n description: Record<string, string>\n /**\n * Labels for the privilege in different languages\n * @example { en: 'Publish Posts', fr: 'Publier les articles' }\n */\n label: Record<string, string>\n /**\n * Unique key for the privilege (e.g., 'posts-publish', 'users-approve')\n */\n privilegeKey: string\n}\n\n/**\n * Register a custom privilege to appear in the admin UI\n *\n * @param collectionOrGlobalSlug - The slug of the collection or global this privilege belongs to\n * @param config - The privilege configuration\n * @param options - Additional options\n *\n * @example\n * ```typescript\n * import { registerCustomPrivilege } from '@payload-enchants/roles-privileges-payload-plugin'\n *\n * // In your payload.config.ts, before the plugin initialization\n * registerCustomPrivilege('posts', {\n * privilegeKey: 'posts-publish',\n * label: { en: 'Publish Posts', fr: 'Publier les articles' },\n * description: { en: 'Ability to publish posts', fr: 'Capacité de publier des articles' },\n * }, {\n * type: 'collection',\n * groupLabel: { en: 'Posts', fr: 'Articles' },\n * })\n * ```\n */\nexport const registerCustomPrivilege = (\n collectionOrGlobalSlug: string,\n config: CustomPrivilegeConfig,\n options?: {\n groupLabel?: Record<string, string>\n type?: 'collection' | 'global'\n },\n): Privilege => {\n const privilege: Privilege = {\n description: config.description,\n isCustom: true,\n label: config.label,\n privilegeKey: config.privilegeKey,\n }\n\n // Get or create the group for this collection/global\n let group = customPrivilegesRegistry.get(collectionOrGlobalSlug)\n\n if (!group) {\n group = {\n slug: collectionOrGlobalSlug,\n type: options?.type || 'collection',\n label: options?.groupLabel || { _default: collectionOrGlobalSlug },\n privileges: {},\n }\n customPrivilegesRegistry.set(collectionOrGlobalSlug, group)\n }\n\n // Add the privilege to the group\n group.privileges[config.privilegeKey] = privilege\n\n return privilege\n}\n\n/**\n * Register multiple custom privileges at once to appear in the admin UI\n *\n * @example\n * ```typescript\n * import { registerCustomPrivileges } from '@payload-enchants/roles-privileges-payload-plugin'\n *\n * registerCustomPrivileges('posts', [\n * {\n * privilegeKey: 'posts-publish',\n * label: { en: 'Publish Posts', fr: 'Publier les articles' },\n * description: { en: 'Publish posts', fr: 'Publier des articles' },\n * },\n * {\n * privilegeKey: 'posts-feature',\n * label: { en: 'Feature Posts', fr: 'Mettre en vedette les articles' },\n * description: { en: 'Feature posts on homepage', fr: 'Mettre en vedette des articles' },\n * },\n * ], {\n * type: 'collection',\n * groupLabel: { en: 'Posts', fr: 'Articles' },\n * })\n * ```\n */\nexport const registerCustomPrivileges = (\n collectionOrGlobalSlug: string,\n configs: CustomPrivilegeConfig[],\n options?: {\n groupLabel?: Record<string, string>\n type?: 'collection' | 'global'\n },\n): Privilege[] => {\n return configs.map((config) => registerCustomPrivilege(collectionOrGlobalSlug, config, options))\n}\n\n/**\n * Type alias for GlobalPrivilege (for consistency)\n */\nexport type CustomGlobalPrivilege = GlobalPrivilege\n"],"names":["customPrivilegesRegistry","Map","registerCustomPrivilege","collectionOrGlobalSlug","config","options","privilege","description","isCustom","label","privilegeKey","group","get","slug","type","groupLabel","_default","privileges","set","registerCustomPrivileges","configs","map"],"mappings":"AAGA;;;CAGC,GACD,OAAO,MAAMA,2BAA2B,IAAIC,MAQzC;AAsBH;;;;;;;;;;;;;;;;;;;;;CAqBC,GACD,OAAO,MAAMC,0BAA0B,CACrCC,wBACAC,QACAC;IAKA,MAAMC,YAAuB;QAC3BC,aAAaH,OAAOG,WAAW;QAC/BC,UAAU;QACVC,OAAOL,OAAOK,KAAK;QACnBC,cAAcN,OAAOM,YAAY;IACnC;IAEA,qDAAqD;IACrD,IAAIC,QAAQX,yBAAyBY,GAAG,CAACT;IAEzC,IAAI,CAACQ,OAAO;QACVA,QAAQ;YACNE,MAAMV;YACNW,MAAMT,SAASS,QAAQ;YACvBL,OAAOJ,SAASU,cAAc;gBAAEC,UAAUb;YAAuB;YACjEc,YAAY,CAAC;QACf;QACAjB,yBAAyBkB,GAAG,CAACf,wBAAwBQ;IACvD;IAEA,iCAAiC;IACjCA,MAAMM,UAAU,CAACb,OAAOM,YAAY,CAAC,GAAGJ;IAExC,OAAOA;AACT,EAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;CAuBC,GACD,OAAO,MAAMa,2BAA2B,CACtChB,wBACAiB,SACAf;IAKA,OAAOe,QAAQC,GAAG,CAAC,CAACjB,SAAWF,wBAAwBC,wBAAwBC,QAAQC;AACzF,EAAC"}
|