@defra/forms-model 3.0.649 → 3.0.650

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.
@@ -1,7 +1,13 @@
1
1
  export let FormMetricType = /*#__PURE__*/function (FormMetricType) {
2
- FormMetricType["HeadlineMetric"] = "headline-metric";
2
+ FormMetricType["TotalsMetric"] = "totals-metric";
3
3
  FormMetricType["OverviewMetric"] = "overview-metric";
4
4
  FormMetricType["TimelineMetric"] = "timeline-metric";
5
5
  return FormMetricType;
6
6
  }({});
7
+ export let FormMetricName = /*#__PURE__*/function (FormMetricName) {
8
+ FormMetricName["NewFormsCreated"] = "NewFormsCreated";
9
+ FormMetricName["FormsPublished"] = "FormsPublished";
10
+ FormMetricName["Submissions"] = "Submissions";
11
+ return FormMetricName;
12
+ }({});
7
13
  //# sourceMappingURL=enums.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"enums.js","names":["FormMetricType"],"sources":["../../../../src/form/form-metrics/enums.ts"],"sourcesContent":["export enum FormMetricType {\n HeadlineMetric = 'headline-metric',\n OverviewMetric = 'overview-metric',\n TimelineMetric = 'timeline-metric'\n}\n"],"mappings":"AAAA,WAAYA,cAAc,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"enums.js","names":["FormMetricType","FormMetricName"],"sources":["../../../../src/form/form-metrics/enums.ts"],"sourcesContent":["export enum FormMetricType {\n TotalsMetric = 'totals-metric',\n OverviewMetric = 'overview-metric',\n TimelineMetric = 'timeline-metric'\n}\n\nexport enum FormMetricName {\n NewFormsCreated = 'NewFormsCreated',\n FormsPublished = 'FormsPublished',\n Submissions = 'Submissions'\n}\n"],"mappings":"AAAA,WAAYA,cAAc,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA;AAM1B,WAAYC,cAAc,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../../src/form/form-metrics/types.ts"],"sourcesContent":["import { type FormStatus } from '~/src/common/enums.js'\nimport { type FormMetricType } from '~/src/form/form-metrics/enums.js'\n\nexport interface FormHeadlineDetail {\n count: number\n countSevenDaysAgo: number\n countThirtyDaysAgo: number\n countOneYearAgo: number\n}\n\nexport interface FormHeadlineMetric {\n type: FormMetricType.HeadlineMetric\n headlineCounts: Record<string, FormHeadlineDetail>\n updatedAt: Date\n}\n\nexport interface FormOverviewMetric {\n type: FormMetricType.OverviewMetric\n formId: string\n formStatus: FormStatus\n summaryMetrics: Record<string, number | string | string[]>\n featureCounts: Record<string, number>\n submissionsCount: number\n updatedAt: Date\n}\n\nexport interface FormTimelineMetric {\n type: FormMetricType.TimelineMetric\n formId: string\n formStatus: FormStatus\n metricName: string\n metricValue: number\n createdAt: Date\n}\n\nexport type FormMetric =\n | FormHeadlineMetric\n | FormOverviewMetric\n | FormTimelineMetric\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../../src/form/form-metrics/types.ts"],"sourcesContent":["import { type FormStatus } from '~/src/common/enums.js'\nimport {\n type FormMetricName,\n type FormMetricType\n} from '~/src/form/form-metrics/enums.js'\n\nexport interface FormTotalMetric {\n count?: number\n}\n\nexport interface FormTotalsMetric {\n type: FormMetricType.TotalsMetric\n last7Days?: Record<FormMetricName, FormTotalMetric>\n prev7Days?: Record<FormMetricName, FormTotalMetric>\n last30Days?: Record<FormMetricName, FormTotalMetric>\n prev30Days?: Record<FormMetricName, FormTotalMetric>\n lastYear?: Record<FormMetricName, FormTotalMetric>\n prevYear?: Record<FormMetricName, FormTotalMetric>\n allTime?: Record<FormMetricName, FormTotalMetric>\n submissions?: Record<string, number>\n updatedAt: Date\n}\n\nexport interface FormOverviewMetric {\n type: FormMetricType.OverviewMetric\n formId: string\n formStatus: FormStatus\n summaryMetrics: Record<string, number | string | string[]>\n featureMetrics: Record<string, Map<string, number>>\n submissionsCount: number\n updatedAt: Date\n}\n\nexport interface FormTimelineMetric {\n type: FormMetricType.TimelineMetric\n formId: string\n formStatus: FormStatus\n metricName: string\n metricValue: number\n createdAt: Date\n}\n\nexport type FormMetric =\n | FormTotalsMetric\n | FormOverviewMetric\n | FormTimelineMetric\n"],"mappings":"","ignoreList":[]}
@@ -19,11 +19,12 @@ export let Scopes = /*#__PURE__*/function (Scopes) {
19
19
  Scopes["ResetSaveAndExit"] = "reset-save-and-exit";
20
20
  Scopes["DeadLetterQueues"] = "dead-letter-queues";
21
21
  Scopes["FormsInspect"] = "forms-inspect";
22
+ Scopes["FormsReport"] = "forms-report";
22
23
  return Scopes;
23
24
  }({});
24
25
  export const RoleScopes = {
25
26
  [Roles.Superadmin]: Object.values(Scopes),
26
- [Roles.Admin]: [Scopes.FormDelete, Scopes.FormEdit, Scopes.FormRead, Scopes.FormPublish, Scopes.UserCreate, Scopes.UserDelete, Scopes.UserEdit, Scopes.FormsFeedback, Scopes.FormsFeedbackAllForms],
27
+ [Roles.Admin]: [Scopes.FormDelete, Scopes.FormEdit, Scopes.FormRead, Scopes.FormPublish, Scopes.UserCreate, Scopes.UserDelete, Scopes.UserEdit, Scopes.FormsFeedback, Scopes.FormsFeedbackAllForms, Scopes.FormsReport],
27
28
  [Roles.FormPublisher]: [Scopes.FormDelete, Scopes.FormEdit, Scopes.FormRead, Scopes.FormPublish, Scopes.FormsFeedback],
28
29
  [Roles.FormCreator]: [Scopes.FormRead, Scopes.FormEdit, Scopes.FormDelete, Scopes.FormsFeedback]
29
30
  };
@@ -1 +1 @@
1
- {"version":3,"file":"roles.js","names":["Roles","Scopes","RoleScopes","Superadmin","Object","values","Admin","FormDelete","FormEdit","FormRead","FormPublish","UserCreate","UserDelete","UserEdit","FormsFeedback","FormsFeedbackAllForms","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 FormsFeedbackAllForms = 'forms-feedback-all-forms',\n FormsBackup = 'forms-backup',\n ResetSaveAndExit = 'reset-save-and-exit',\n DeadLetterQueues = 'dead-letter-queues',\n FormsInspect = 'forms-inspect'\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 Scopes.FormsFeedbackAllForms\n ],\n [Roles.FormPublisher]: [\n Scopes.FormDelete,\n Scopes.FormEdit,\n Scopes.FormRead,\n Scopes.FormPublish,\n Scopes.FormsFeedback\n ],\n [Roles.FormCreator]: [\n Scopes.FormRead,\n Scopes.FormEdit,\n Scopes.FormDelete,\n Scopes.FormsFeedback\n ]\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,KA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SAASE,gBAAgBA,CAACC,KAAc,EAAE;EAC/C,MAAMC,QAAQ,GAAG,IAAIC,GAAG,CAAS,CAAC;EAClCF,KAAK,CAACG,OAAO,CAAEC,IAAI,IAAK;IACtB,MAAMC,MAAM,GAAGvB,UAAU,CAACsB,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","FormsFeedbackAllForms","FormsReport","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 FormsFeedbackAllForms = 'forms-feedback-all-forms',\n FormsBackup = 'forms-backup',\n ResetSaveAndExit = 'reset-save-and-exit',\n DeadLetterQueues = 'dead-letter-queues',\n FormsInspect = 'forms-inspect',\n FormsReport = 'forms-report'\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 Scopes.FormsFeedbackAllForms,\n Scopes.FormsReport\n ],\n [Roles.FormPublisher]: [\n Scopes.FormDelete,\n Scopes.FormEdit,\n Scopes.FormRead,\n Scopes.FormPublish,\n Scopes.FormsFeedback\n ],\n [Roles.FormCreator]: [\n Scopes.FormRead,\n Scopes.FormEdit,\n Scopes.FormDelete,\n Scopes.FormsFeedback\n ]\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;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAAA,OAANA,MAAM;AAAA;AAiBlB,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,EACpBb,MAAM,CAACc,qBAAqB,EAC5Bd,MAAM,CAACe,WAAW,CACnB;EACD,CAAChB,KAAK,CAACiB,aAAa,GAAG,CACrBhB,MAAM,CAACM,UAAU,EACjBN,MAAM,CAACO,QAAQ,EACfP,MAAM,CAACQ,QAAQ,EACfR,MAAM,CAACS,WAAW,EAClBT,MAAM,CAACa,aAAa,CACrB;EACD,CAACd,KAAK,CAACkB,WAAW,GAAG,CACnBjB,MAAM,CAACQ,QAAQ,EACfR,MAAM,CAACO,QAAQ,EACfP,MAAM,CAACM,UAAU,EACjBN,MAAM,CAACa,aAAa;AAExB,CAAC;AAED,OAAO,MAAMK,SAAS,GAAG;EACvB,CAACnB,KAAK,CAACG,UAAU,GAAG,YAAY;EAChC,CAACH,KAAK,CAACM,KAAK,GAAG,OAAO;EACtB,CAACN,KAAK,CAACiB,aAAa,GAAG,gBAAgB;EACvC,CAACjB,KAAK,CAACkB,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,GAAGxB,UAAU,CAACuB,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,6 +1,11 @@
1
1
  export declare enum FormMetricType {
2
- HeadlineMetric = "headline-metric",
2
+ TotalsMetric = "totals-metric",
3
3
  OverviewMetric = "overview-metric",
4
4
  TimelineMetric = "timeline-metric"
5
5
  }
6
+ export declare enum FormMetricName {
7
+ NewFormsCreated = "NewFormsCreated",
8
+ FormsPublished = "FormsPublished",
9
+ Submissions = "Submissions"
10
+ }
6
11
  //# sourceMappingURL=enums.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../../../../src/form/form-metrics/enums.ts"],"names":[],"mappings":"AAAA,oBAAY,cAAc;IACxB,cAAc,oBAAoB;IAClC,cAAc,oBAAoB;IAClC,cAAc,oBAAoB;CACnC"}
1
+ {"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../../../../src/form/form-metrics/enums.ts"],"names":[],"mappings":"AAAA,oBAAY,cAAc;IACxB,YAAY,kBAAkB;IAC9B,cAAc,oBAAoB;IAClC,cAAc,oBAAoB;CACnC;AAED,oBAAY,cAAc;IACxB,eAAe,oBAAoB;IACnC,cAAc,mBAAmB;IACjC,WAAW,gBAAgB;CAC5B"}
@@ -1,14 +1,18 @@
1
1
  import { type FormStatus } from '../../common/enums.js';
2
- import { type FormMetricType } from '../../form/form-metrics/enums.js';
3
- export interface FormHeadlineDetail {
4
- count: number;
5
- countSevenDaysAgo: number;
6
- countThirtyDaysAgo: number;
7
- countOneYearAgo: number;
2
+ import { type FormMetricName, type FormMetricType } from '../../form/form-metrics/enums.js';
3
+ export interface FormTotalMetric {
4
+ count?: number;
8
5
  }
9
- export interface FormHeadlineMetric {
10
- type: FormMetricType.HeadlineMetric;
11
- headlineCounts: Record<string, FormHeadlineDetail>;
6
+ export interface FormTotalsMetric {
7
+ type: FormMetricType.TotalsMetric;
8
+ last7Days?: Record<FormMetricName, FormTotalMetric>;
9
+ prev7Days?: Record<FormMetricName, FormTotalMetric>;
10
+ last30Days?: Record<FormMetricName, FormTotalMetric>;
11
+ prev30Days?: Record<FormMetricName, FormTotalMetric>;
12
+ lastYear?: Record<FormMetricName, FormTotalMetric>;
13
+ prevYear?: Record<FormMetricName, FormTotalMetric>;
14
+ allTime?: Record<FormMetricName, FormTotalMetric>;
15
+ submissions?: Record<string, number>;
12
16
  updatedAt: Date;
13
17
  }
14
18
  export interface FormOverviewMetric {
@@ -16,7 +20,7 @@ export interface FormOverviewMetric {
16
20
  formId: string;
17
21
  formStatus: FormStatus;
18
22
  summaryMetrics: Record<string, number | string | string[]>;
19
- featureCounts: Record<string, number>;
23
+ featureMetrics: Record<string, Map<string, number>>;
20
24
  submissionsCount: number;
21
25
  updatedAt: Date;
22
26
  }
@@ -28,5 +32,5 @@ export interface FormTimelineMetric {
28
32
  metricValue: number;
29
33
  createdAt: Date;
30
34
  }
31
- export type FormMetric = FormHeadlineMetric | FormOverviewMetric | FormTimelineMetric;
35
+ export type FormMetric = FormTotalsMetric | FormOverviewMetric | FormTimelineMetric;
32
36
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/form/form-metrics/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,kCAAkC,CAAA;AAEtE,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAA;IACb,iBAAiB,EAAE,MAAM,CAAA;IACzB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,eAAe,EAAE,MAAM,CAAA;CACxB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,cAAc,CAAC,cAAc,CAAA;IACnC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAA;IAClD,SAAS,EAAE,IAAI,CAAA;CAChB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,cAAc,CAAC,cAAc,CAAA;IACnC,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,UAAU,CAAA;IACtB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC,CAAA;IAC1D,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACrC,gBAAgB,EAAE,MAAM,CAA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AI,CAAA;CAChB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,cAAc,CAAC,cAAc,CAAA;IACnC,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,UAAU,CAAA;IACtB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC,CAAA;IAC1D,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IACnD,gBAAgB,EAAE,MAAM,CAAA;IACxB,SAAS,EAAE,IAAI,CAAA;CAChB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,cAAc,CAAC,cAAc,CAAA;IACnC,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,UAAU,CAAA;IACtB,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,IAAI,CAAA;CAChB;AAED,MAAM,MAAM,UAAU,GAClB,gBAAgB,GAChB,kBAAkB,GAClB,kBAAkB,CAAA"}
@@ -17,7 +17,8 @@ export declare enum Scopes {
17
17
  FormsBackup = "forms-backup",
18
18
  ResetSaveAndExit = "reset-save-and-exit",
19
19
  DeadLetterQueues = "dead-letter-queues",
20
- FormsInspect = "forms-inspect"
20
+ FormsInspect = "forms-inspect",
21
+ FormsReport = "forms-report"
21
22
  }
22
23
  export declare const RoleScopes: {
23
24
  superadmin: Scopes[];
@@ -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,qBAAqB,6BAA6B;IAClD,WAAW,iBAAiB;IAC5B,gBAAgB,wBAAwB;IACxC,gBAAgB,uBAAuB;IACvC,YAAY,kBAAkB;CAC/B;AAED,eAAO,MAAM,UAAU;;;;;CA0BtB,CAAA;AAED,eAAO,MAAM,SAAS;;;;;CAKrB,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,qBAAqB,6BAA6B;IAClD,WAAW,iBAAiB;IAC5B,gBAAgB,wBAAwB;IACxC,gBAAgB,uBAAuB;IACvC,YAAY,kBAAkB;IAC9B,WAAW,iBAAiB;CAC7B;AAED,eAAO,MAAM,UAAU;;;;;CA2BtB,CAAA;AAED,eAAO,MAAM,SAAS;;;;;CAKrB,CAAA;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,KAAK,EAAE,YAS9C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defra/forms-model",
3
- "version": "3.0.649",
3
+ "version": "3.0.650",
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",
@@ -1,5 +1,11 @@
1
1
  export enum FormMetricType {
2
- HeadlineMetric = 'headline-metric',
2
+ TotalsMetric = 'totals-metric',
3
3
  OverviewMetric = 'overview-metric',
4
4
  TimelineMetric = 'timeline-metric'
5
5
  }
6
+
7
+ export enum FormMetricName {
8
+ NewFormsCreated = 'NewFormsCreated',
9
+ FormsPublished = 'FormsPublished',
10
+ Submissions = 'Submissions'
11
+ }
@@ -1,16 +1,23 @@
1
1
  import { type FormStatus } from '~/src/common/enums.js'
2
- import { type FormMetricType } from '~/src/form/form-metrics/enums.js'
2
+ import {
3
+ type FormMetricName,
4
+ type FormMetricType
5
+ } from '~/src/form/form-metrics/enums.js'
3
6
 
4
- export interface FormHeadlineDetail {
5
- count: number
6
- countSevenDaysAgo: number
7
- countThirtyDaysAgo: number
8
- countOneYearAgo: number
7
+ export interface FormTotalMetric {
8
+ count?: number
9
9
  }
10
10
 
11
- export interface FormHeadlineMetric {
12
- type: FormMetricType.HeadlineMetric
13
- headlineCounts: Record<string, FormHeadlineDetail>
11
+ export interface FormTotalsMetric {
12
+ type: FormMetricType.TotalsMetric
13
+ last7Days?: Record<FormMetricName, FormTotalMetric>
14
+ prev7Days?: Record<FormMetricName, FormTotalMetric>
15
+ last30Days?: Record<FormMetricName, FormTotalMetric>
16
+ prev30Days?: Record<FormMetricName, FormTotalMetric>
17
+ lastYear?: Record<FormMetricName, FormTotalMetric>
18
+ prevYear?: Record<FormMetricName, FormTotalMetric>
19
+ allTime?: Record<FormMetricName, FormTotalMetric>
20
+ submissions?: Record<string, number>
14
21
  updatedAt: Date
15
22
  }
16
23
 
@@ -19,7 +26,7 @@ export interface FormOverviewMetric {
19
26
  formId: string
20
27
  formStatus: FormStatus
21
28
  summaryMetrics: Record<string, number | string | string[]>
22
- featureCounts: Record<string, number>
29
+ featureMetrics: Record<string, Map<string, number>>
23
30
  submissionsCount: number
24
31
  updatedAt: Date
25
32
  }
@@ -34,6 +41,6 @@ export interface FormTimelineMetric {
34
41
  }
35
42
 
36
43
  export type FormMetric =
37
- | FormHeadlineMetric
44
+ | FormTotalsMetric
38
45
  | FormOverviewMetric
39
46
  | FormTimelineMetric
@@ -18,7 +18,8 @@ export enum Scopes {
18
18
  FormsBackup = 'forms-backup',
19
19
  ResetSaveAndExit = 'reset-save-and-exit',
20
20
  DeadLetterQueues = 'dead-letter-queues',
21
- FormsInspect = 'forms-inspect'
21
+ FormsInspect = 'forms-inspect',
22
+ FormsReport = 'forms-report'
22
23
  }
23
24
 
24
25
  export const RoleScopes = {
@@ -32,7 +33,8 @@ export const RoleScopes = {
32
33
  Scopes.UserDelete,
33
34
  Scopes.UserEdit,
34
35
  Scopes.FormsFeedback,
35
- Scopes.FormsFeedbackAllForms
36
+ Scopes.FormsFeedbackAllForms,
37
+ Scopes.FormsReport
36
38
  ],
37
39
  [Roles.FormPublisher]: [
38
40
  Scopes.FormDelete,