@defra/forms-model 3.0.624 → 3.0.625

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.
@@ -24,6 +24,12 @@ export const RoleScopes = {
24
24
  [Roles.FormPublisher]: [Scopes.FormDelete, Scopes.FormEdit, Scopes.FormRead, Scopes.FormPublish],
25
25
  [Roles.FormCreator]: [Scopes.FormRead, Scopes.FormEdit, Scopes.FormDelete]
26
26
  };
27
+ export const RoleNames = {
28
+ [Roles.Superadmin]: 'Superadmin',
29
+ [Roles.Admin]: 'Admin',
30
+ [Roles.FormPublisher]: 'Form publisher',
31
+ [Roles.FormCreator]: 'Form creator'
32
+ };
27
33
 
28
34
  /**
29
35
  * Return a unique list of scopes based on the array of roles passed in
@@ -1 +1 @@
1
- {"version":3,"file":"roles.js","names":["Roles","Scopes","RoleScopes","Superadmin","Object","values","Admin","FormDelete","FormEdit","FormRead","FormPublish","UserCreate","UserDelete","UserEdit","FormsFeedback","FormPublisher","FormCreator","mapScopesToRoles","roles","scopeSet","Set","forEach","role","scopes","scope","add","Array","from"],"sources":["../../../src/manage/roles.ts"],"sourcesContent":["export enum Roles {\n Superadmin = 'superadmin',\n Admin = 'admin',\n FormPublisher = 'form-publisher',\n FormCreator = 'form-creator'\n}\n\nexport enum Scopes {\n FormDelete = 'form-delete',\n FormEdit = 'form-edit',\n FormRead = 'form-read',\n FormPublish = 'form-publish',\n UserCreate = 'user-create',\n UserDelete = 'user-delete',\n UserEdit = 'user-edit',\n FormsFeedback = 'forms-feedback',\n FormsBackup = 'forms-backup',\n ResetSaveAndExit = 'reset-save-and-exit'\n}\n\nexport const RoleScopes = {\n [Roles.Superadmin]: Object.values(Scopes),\n [Roles.Admin]: [\n Scopes.FormDelete,\n Scopes.FormEdit,\n Scopes.FormRead,\n Scopes.FormPublish,\n Scopes.UserCreate,\n Scopes.UserDelete,\n Scopes.UserEdit,\n Scopes.FormsFeedback\n ],\n [Roles.FormPublisher]: [\n Scopes.FormDelete,\n Scopes.FormEdit,\n Scopes.FormRead,\n Scopes.FormPublish\n ],\n [Roles.FormCreator]: [Scopes.FormRead, Scopes.FormEdit, Scopes.FormDelete]\n}\n\n/**\n * Return a unique list of scopes based on the array of roles passed in\n */\nexport function mapScopesToRoles(roles: Roles[]) {\n const scopeSet = new Set<string>()\n roles.forEach((role) => {\n const scopes = RoleScopes[role]\n scopes.forEach((scope) => {\n scopeSet.add(scope)\n })\n })\n return Array.from(scopeSet)\n}\n"],"mappings":"AAAA,WAAYA,KAAK,0BAALA,KAAK;EAALA,KAAK;EAALA,KAAK;EAALA,KAAK;EAALA,KAAK;EAAA,OAALA,KAAK;AAAA;AAOjB,WAAYC,MAAM,0BAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAAA,OAANA,MAAM;AAAA;AAalB,OAAO,MAAMC,UAAU,GAAG;EACxB,CAACF,KAAK,CAACG,UAAU,GAAGC,MAAM,CAACC,MAAM,CAACJ,MAAM,CAAC;EACzC,CAACD,KAAK,CAACM,KAAK,GAAG,CACbL,MAAM,CAACM,UAAU,EACjBN,MAAM,CAACO,QAAQ,EACfP,MAAM,CAACQ,QAAQ,EACfR,MAAM,CAACS,WAAW,EAClBT,MAAM,CAACU,UAAU,EACjBV,MAAM,CAACW,UAAU,EACjBX,MAAM,CAACY,QAAQ,EACfZ,MAAM,CAACa,aAAa,CACrB;EACD,CAACd,KAAK,CAACe,aAAa,GAAG,CACrBd,MAAM,CAACM,UAAU,EACjBN,MAAM,CAACO,QAAQ,EACfP,MAAM,CAACQ,QAAQ,EACfR,MAAM,CAACS,WAAW,CACnB;EACD,CAACV,KAAK,CAACgB,WAAW,GAAG,CAACf,MAAM,CAACQ,QAAQ,EAAER,MAAM,CAACO,QAAQ,EAAEP,MAAM,CAACM,UAAU;AAC3E,CAAC;;AAED;AACA;AACA;AACA,OAAO,SAASU,gBAAgBA,CAACC,KAAc,EAAE;EAC/C,MAAMC,QAAQ,GAAG,IAAIC,GAAG,CAAS,CAAC;EAClCF,KAAK,CAACG,OAAO,CAAEC,IAAI,IAAK;IACtB,MAAMC,MAAM,GAAGrB,UAAU,CAACoB,IAAI,CAAC;IAC/BC,MAAM,CAACF,OAAO,CAAEG,KAAK,IAAK;MACxBL,QAAQ,CAACM,GAAG,CAACD,KAAK,CAAC;IACrB,CAAC,CAAC;EACJ,CAAC,CAAC;EACF,OAAOE,KAAK,CAACC,IAAI,CAACR,QAAQ,CAAC;AAC7B","ignoreList":[]}
1
+ {"version":3,"file":"roles.js","names":["Roles","Scopes","RoleScopes","Superadmin","Object","values","Admin","FormDelete","FormEdit","FormRead","FormPublish","UserCreate","UserDelete","UserEdit","FormsFeedback","FormPublisher","FormCreator","RoleNames","mapScopesToRoles","roles","scopeSet","Set","forEach","role","scopes","scope","add","Array","from"],"sources":["../../../src/manage/roles.ts"],"sourcesContent":["export enum Roles {\n Superadmin = 'superadmin',\n Admin = 'admin',\n FormPublisher = 'form-publisher',\n FormCreator = 'form-creator'\n}\n\nexport enum Scopes {\n FormDelete = 'form-delete',\n FormEdit = 'form-edit',\n FormRead = 'form-read',\n FormPublish = 'form-publish',\n UserCreate = 'user-create',\n UserDelete = 'user-delete',\n UserEdit = 'user-edit',\n FormsFeedback = 'forms-feedback',\n FormsBackup = 'forms-backup',\n ResetSaveAndExit = 'reset-save-and-exit'\n}\n\nexport const RoleScopes = {\n [Roles.Superadmin]: Object.values(Scopes),\n [Roles.Admin]: [\n Scopes.FormDelete,\n Scopes.FormEdit,\n Scopes.FormRead,\n Scopes.FormPublish,\n Scopes.UserCreate,\n Scopes.UserDelete,\n Scopes.UserEdit,\n Scopes.FormsFeedback\n ],\n [Roles.FormPublisher]: [\n Scopes.FormDelete,\n Scopes.FormEdit,\n Scopes.FormRead,\n Scopes.FormPublish\n ],\n [Roles.FormCreator]: [Scopes.FormRead, Scopes.FormEdit, Scopes.FormDelete]\n}\n\nexport const RoleNames = {\n [Roles.Superadmin]: 'Superadmin',\n [Roles.Admin]: 'Admin',\n [Roles.FormPublisher]: 'Form publisher',\n [Roles.FormCreator]: 'Form creator'\n}\n\n/**\n * Return a unique list of scopes based on the array of roles passed in\n */\nexport function mapScopesToRoles(roles: Roles[]) {\n const scopeSet = new Set<Scopes>()\n roles.forEach((role) => {\n const scopes = RoleScopes[role]\n scopes.forEach((scope) => {\n scopeSet.add(scope)\n })\n })\n return Array.from(scopeSet)\n}\n"],"mappings":"AAAA,WAAYA,KAAK,0BAALA,KAAK;EAALA,KAAK;EAALA,KAAK;EAALA,KAAK;EAALA,KAAK;EAAA,OAALA,KAAK;AAAA;AAOjB,WAAYC,MAAM,0BAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAAA,OAANA,MAAM;AAAA;AAalB,OAAO,MAAMC,UAAU,GAAG;EACxB,CAACF,KAAK,CAACG,UAAU,GAAGC,MAAM,CAACC,MAAM,CAACJ,MAAM,CAAC;EACzC,CAACD,KAAK,CAACM,KAAK,GAAG,CACbL,MAAM,CAACM,UAAU,EACjBN,MAAM,CAACO,QAAQ,EACfP,MAAM,CAACQ,QAAQ,EACfR,MAAM,CAACS,WAAW,EAClBT,MAAM,CAACU,UAAU,EACjBV,MAAM,CAACW,UAAU,EACjBX,MAAM,CAACY,QAAQ,EACfZ,MAAM,CAACa,aAAa,CACrB;EACD,CAACd,KAAK,CAACe,aAAa,GAAG,CACrBd,MAAM,CAACM,UAAU,EACjBN,MAAM,CAACO,QAAQ,EACfP,MAAM,CAACQ,QAAQ,EACfR,MAAM,CAACS,WAAW,CACnB;EACD,CAACV,KAAK,CAACgB,WAAW,GAAG,CAACf,MAAM,CAACQ,QAAQ,EAAER,MAAM,CAACO,QAAQ,EAAEP,MAAM,CAACM,UAAU;AAC3E,CAAC;AAED,OAAO,MAAMU,SAAS,GAAG;EACvB,CAACjB,KAAK,CAACG,UAAU,GAAG,YAAY;EAChC,CAACH,KAAK,CAACM,KAAK,GAAG,OAAO;EACtB,CAACN,KAAK,CAACe,aAAa,GAAG,gBAAgB;EACvC,CAACf,KAAK,CAACgB,WAAW,GAAG;AACvB,CAAC;;AAED;AACA;AACA;AACA,OAAO,SAASE,gBAAgBA,CAACC,KAAc,EAAE;EAC/C,MAAMC,QAAQ,GAAG,IAAIC,GAAG,CAAS,CAAC;EAClCF,KAAK,CAACG,OAAO,CAAEC,IAAI,IAAK;IACtB,MAAMC,MAAM,GAAGtB,UAAU,CAACqB,IAAI,CAAC;IAC/BC,MAAM,CAACF,OAAO,CAAEG,KAAK,IAAK;MACxBL,QAAQ,CAACM,GAAG,CAACD,KAAK,CAAC;IACrB,CAAC,CAAC;EACJ,CAAC,CAAC;EACF,OAAOE,KAAK,CAACC,IAAI,CAACR,QAAQ,CAAC;AAC7B","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../src/manage/types.ts"],"sourcesContent":["/**\n * Interface for `EntitlementRole`\n */\nexport interface EntitlementRole {\n /**\n * The display name\n */\n name: string\n\n /**\n * The code value\n */\n code: string\n\n /**\n * The description\n */\n description: string\n}\n\n/**\n * Interface for `ManageUser`\n */\nexport interface ManageUser {\n /**\n * The object id of the user\n */\n userId: string\n\n /**\n * The email address of the user\n */\n emailAddress: string\n\n /**\n * The role assigned to the user\n */\n userRole: string\n\n /**\n * The full name of the user for display\n */\n displayName?: string\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../src/manage/types.ts"],"sourcesContent":["import { type Roles } from '~/src/manage/roles.js'\n\n/**\n * Interface for `ManageUser`\n */\nexport interface ManageUser {\n /**\n * The object id of the user\n */\n userId: string\n\n /**\n * The email address of the user\n */\n emailAddress: string\n\n /**\n * The role assigned to the user\n */\n userRole: Roles\n\n /**\n * The full name of the user for display\n */\n displayName?: string\n}\n"],"mappings":"","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"users.js","names":[],"sources":["../../../src/manage/users.ts"],"sourcesContent":["export interface EntitlementUser {\n /**\n * The id of the user\n */\n userId: string\n\n /**\n * The display name (full name) of the user\n */\n displayName: string\n\n /**\n * The email addresss of the user\n */\n email: string\n\n /**\n * The roles assigned to the user\n */\n roles: string[]\n\n /**\n * The scopes assigned to the user\n */\n scopes: string[]\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"users.js","names":[],"sources":["../../../src/manage/users.ts"],"sourcesContent":["import { type Roles, type Scopes } from '~/src/manage/roles.js'\n\nexport interface EntitlementUser {\n /**\n * The id of the user\n */\n userId: string\n\n /**\n * The display name (full name) of the user\n */\n displayName: string\n\n /**\n * The email addresss of the user\n */\n email: string\n\n /**\n * The roles assigned to the user\n */\n roles: Roles[]\n\n /**\n * The scopes assigned to the user\n */\n scopes: Scopes[]\n}\n"],"mappings":"","ignoreList":[]}
@@ -22,8 +22,14 @@ export declare const RoleScopes: {
22
22
  "form-publisher": Scopes[];
23
23
  "form-creator": Scopes[];
24
24
  };
25
+ export declare const RoleNames: {
26
+ superadmin: string;
27
+ admin: string;
28
+ "form-publisher": string;
29
+ "form-creator": string;
30
+ };
25
31
  /**
26
32
  * Return a unique list of scopes based on the array of roles passed in
27
33
  */
28
- export declare function mapScopesToRoles(roles: Roles[]): string[];
34
+ export declare function mapScopesToRoles(roles: Roles[]): Scopes[];
29
35
  //# sourceMappingURL=roles.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"roles.d.ts","sourceRoot":"","sources":["../../../src/manage/roles.ts"],"names":[],"mappings":"AAAA,oBAAY,KAAK;IACf,UAAU,eAAe;IACzB,KAAK,UAAU;IACf,aAAa,mBAAmB;IAChC,WAAW,iBAAiB;CAC7B;AAED,oBAAY,MAAM;IAChB,UAAU,gBAAgB;IAC1B,QAAQ,cAAc;IACtB,QAAQ,cAAc;IACtB,WAAW,iBAAiB;IAC5B,UAAU,gBAAgB;IAC1B,UAAU,gBAAgB;IAC1B,QAAQ,cAAc;IACtB,aAAa,mBAAmB;IAChC,WAAW,iBAAiB;IAC5B,gBAAgB,wBAAwB;CACzC;AAED,eAAO,MAAM,UAAU;;;;;CAmBtB,CAAA;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,KAAK,EAAE,YAS9C"}
1
+ {"version":3,"file":"roles.d.ts","sourceRoot":"","sources":["../../../src/manage/roles.ts"],"names":[],"mappings":"AAAA,oBAAY,KAAK;IACf,UAAU,eAAe;IACzB,KAAK,UAAU;IACf,aAAa,mBAAmB;IAChC,WAAW,iBAAiB;CAC7B;AAED,oBAAY,MAAM;IAChB,UAAU,gBAAgB;IAC1B,QAAQ,cAAc;IACtB,QAAQ,cAAc;IACtB,WAAW,iBAAiB;IAC5B,UAAU,gBAAgB;IAC1B,UAAU,gBAAgB;IAC1B,QAAQ,cAAc;IACtB,aAAa,mBAAmB;IAChC,WAAW,iBAAiB;IAC5B,gBAAgB,wBAAwB;CACzC;AAED,eAAO,MAAM,UAAU;;;;;CAmBtB,CAAA;AAED,eAAO,MAAM,SAAS;;;;;CAKrB,CAAA;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,KAAK,EAAE,YAS9C"}
@@ -1,20 +1,4 @@
1
- /**
2
- * Interface for `EntitlementRole`
3
- */
4
- export interface EntitlementRole {
5
- /**
6
- * The display name
7
- */
8
- name: string;
9
- /**
10
- * The code value
11
- */
12
- code: string;
13
- /**
14
- * The description
15
- */
16
- description: string;
17
- }
1
+ import { type Roles } from '../manage/roles.js';
18
2
  /**
19
3
  * Interface for `ManageUser`
20
4
  */
@@ -30,7 +14,7 @@ export interface ManageUser {
30
14
  /**
31
15
  * The role assigned to the user
32
16
  */
33
- userRole: string;
17
+ userRole: Roles;
34
18
  /**
35
19
  * The full name of the user for display
36
20
  */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/manage/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IAEZ;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IAEZ;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IAEd;;OAEG;IACH,YAAY,EAAE,MAAM,CAAA;IAEpB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAEhB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/manage/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAElD;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IAEd;;OAEG;IACH,YAAY,EAAE,MAAM,CAAA;IAEpB;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAA;IAEf;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB"}
@@ -1,3 +1,4 @@
1
+ import { type Roles, type Scopes } from '../manage/roles.js';
1
2
  export interface EntitlementUser {
2
3
  /**
3
4
  * The id of the user
@@ -14,10 +15,10 @@ export interface EntitlementUser {
14
15
  /**
15
16
  * The roles assigned to the user
16
17
  */
17
- roles: string[];
18
+ roles: Roles[];
18
19
  /**
19
20
  * The scopes assigned to the user
20
21
  */
21
- scopes: string[];
22
+ scopes: Scopes[];
22
23
  }
23
24
  //# sourceMappingURL=users.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../../../src/manage/users.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IAEd;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IAEnB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;IAEb;;OAEG;IACH,KAAK,EAAE,MAAM,EAAE,CAAA;IAEf;;OAEG;IACH,MAAM,EAAE,MAAM,EAAE,CAAA;CACjB"}
1
+ {"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../../../src/manage/users.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAE/D,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IAEd;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IAEnB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;IAEb;;OAEG;IACH,KAAK,EAAE,KAAK,EAAE,CAAA;IAEd;;OAEG;IACH,MAAM,EAAE,MAAM,EAAE,CAAA;CACjB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defra/forms-model",
3
- "version": "3.0.624",
3
+ "version": "3.0.625",
4
4
  "description": "A hapi plugin providing the model for Defra forms",
5
5
  "homepage": "https://github.com/DEFRA/forms-designer/tree/main/model#readme",
6
6
  "types": "dist/types/index.d.ts",
@@ -39,11 +39,18 @@ export const RoleScopes = {
39
39
  [Roles.FormCreator]: [Scopes.FormRead, Scopes.FormEdit, Scopes.FormDelete]
40
40
  }
41
41
 
42
+ export const RoleNames = {
43
+ [Roles.Superadmin]: 'Superadmin',
44
+ [Roles.Admin]: 'Admin',
45
+ [Roles.FormPublisher]: 'Form publisher',
46
+ [Roles.FormCreator]: 'Form creator'
47
+ }
48
+
42
49
  /**
43
50
  * Return a unique list of scopes based on the array of roles passed in
44
51
  */
45
52
  export function mapScopesToRoles(roles: Roles[]) {
46
- const scopeSet = new Set<string>()
53
+ const scopeSet = new Set<Scopes>()
47
54
  roles.forEach((role) => {
48
55
  const scopes = RoleScopes[role]
49
56
  scopes.forEach((scope) => {
@@ -1,22 +1,4 @@
1
- /**
2
- * Interface for `EntitlementRole`
3
- */
4
- export interface EntitlementRole {
5
- /**
6
- * The display name
7
- */
8
- name: string
9
-
10
- /**
11
- * The code value
12
- */
13
- code: string
14
-
15
- /**
16
- * The description
17
- */
18
- description: string
19
- }
1
+ import { type Roles } from '~/src/manage/roles.js'
20
2
 
21
3
  /**
22
4
  * Interface for `ManageUser`
@@ -35,7 +17,7 @@ export interface ManageUser {
35
17
  /**
36
18
  * The role assigned to the user
37
19
  */
38
- userRole: string
20
+ userRole: Roles
39
21
 
40
22
  /**
41
23
  * The full name of the user for display
@@ -1,3 +1,5 @@
1
+ import { type Roles, type Scopes } from '~/src/manage/roles.js'
2
+
1
3
  export interface EntitlementUser {
2
4
  /**
3
5
  * The id of the user
@@ -17,10 +19,10 @@ export interface EntitlementUser {
17
19
  /**
18
20
  * The roles assigned to the user
19
21
  */
20
- roles: string[]
22
+ roles: Roles[]
21
23
 
22
24
  /**
23
25
  * The scopes assigned to the user
24
26
  */
25
- scopes: string[]
27
+ scopes: Scopes[]
26
28
  }