@dwp/govuk-casa 8.0.0-alpha1 → 8.0.0
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/CHANGELOG.md +22 -0
- package/README.md +1 -1
- package/dist/assets/css/casa-ie8.css +1 -1
- package/dist/assets/css/casa.css +1 -1
- package/dist/casa.d.ts +2 -1
- package/dist/casa.js +3 -1
- package/dist/lib/CasaTemplateLoader.d.ts +11 -3
- package/dist/lib/CasaTemplateLoader.js +38 -2
- package/dist/lib/JourneyContext.d.ts +51 -8
- package/dist/lib/JourneyContext.js +73 -147
- package/dist/lib/MutableRouter.d.ts +19 -19
- package/dist/lib/MutableRouter.js +30 -23
- package/dist/lib/Plan.d.ts +41 -6
- package/dist/lib/Plan.js +84 -17
- package/dist/lib/ValidationError.d.ts +6 -2
- package/dist/lib/ValidationError.js +7 -0
- package/dist/lib/ValidatorFactory.d.ts +72 -13
- package/dist/lib/ValidatorFactory.js +33 -14
- package/dist/lib/configuration-ingestor.d.ts +262 -0
- package/dist/lib/configuration-ingestor.js +464 -0
- package/dist/lib/configure.d.ts +39 -154
- package/dist/lib/configure.js +35 -59
- package/dist/lib/dirname.cjs +1 -1
- package/dist/lib/dirname.d.cts +2 -0
- package/dist/lib/end-session.d.ts +4 -3
- package/dist/lib/end-session.js +30 -8
- package/dist/lib/field.d.ts +53 -55
- package/dist/lib/field.js +96 -54
- package/dist/lib/index.d.ts +14 -0
- package/dist/lib/index.js +54 -0
- package/dist/lib/logger.d.ts +2 -1
- package/dist/lib/logger.js +3 -4
- package/dist/lib/nunjucks-filters.d.ts +11 -11
- package/dist/lib/nunjucks-filters.js +22 -36
- package/dist/lib/nunjucks.d.ts +7 -6
- package/dist/lib/nunjucks.js +6 -6
- package/dist/lib/utils.d.ts +26 -0
- package/dist/lib/utils.js +70 -1
- package/dist/lib/validators/dateObject.js +1 -1
- package/dist/lib/validators/email.js +1 -1
- package/dist/lib/validators/inArray.js +1 -1
- package/dist/lib/validators/index.js +0 -22
- package/dist/lib/validators/postalAddressObject.js +7 -3
- package/dist/lib/validators/required.js +1 -1
- package/dist/lib/waypoint-url.d.ts +13 -7
- package/dist/lib/waypoint-url.js +13 -7
- package/dist/middleware/body-parser.d.ts +2 -1
- package/dist/middleware/body-parser.js +20 -11
- package/dist/middleware/csrf.d.ts +1 -1
- package/dist/middleware/csrf.js +2 -2
- package/dist/middleware/data.d.ts +1 -2
- package/dist/middleware/data.js +19 -15
- package/dist/middleware/dirname.cjs +1 -1
- package/dist/middleware/dirname.d.cts +2 -0
- package/dist/middleware/gather-fields.d.ts +3 -2
- package/dist/middleware/gather-fields.js +14 -7
- package/dist/middleware/i18n.d.ts +1 -1
- package/dist/middleware/i18n.js +16 -11
- package/dist/middleware/post.d.ts +3 -1
- package/dist/middleware/post.js +24 -9
- package/dist/middleware/pre.js +15 -2
- package/dist/middleware/progress-journey.js +15 -17
- package/dist/middleware/sanitise-fields.js +15 -10
- package/dist/middleware/session.d.ts +2 -1
- package/dist/middleware/session.js +65 -52
- package/dist/middleware/skip-waypoint.js +10 -7
- package/dist/middleware/steer-journey.d.ts +3 -2
- package/dist/middleware/steer-journey.js +26 -8
- package/dist/middleware/validate-fields.js +15 -21
- package/dist/mjs/esm-wrapper.js +18 -7
- package/dist/routes/ancillary.d.ts +8 -1
- package/dist/routes/ancillary.js +7 -1
- package/dist/routes/dirname.cjs +1 -1
- package/dist/routes/dirname.d.cts +2 -0
- package/dist/routes/journey.js +20 -24
- package/dist/routes/static.js +10 -9
- package/package.json +41 -22
- package/views/casa/errors/static.njk +11 -0
- package/views/casa/layouts/main.njk +3 -3
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('./ValidatorFactory').ValidateContext} ValidateContext
|
|
3
|
+
*/
|
|
1
4
|
export default class ValidationError {
|
|
2
5
|
/**
|
|
3
6
|
* Make a ValidationError instance from a primitive object (or a function that
|
|
@@ -61,10 +64,11 @@ export default class ValidationError {
|
|
|
61
64
|
* @param {ValidateContext} context See structure above
|
|
62
65
|
* @returns {ValidationError} Chain
|
|
63
66
|
*/
|
|
64
|
-
withContext(context:
|
|
67
|
+
withContext(context: ValidateContext): ValidationError;
|
|
65
68
|
variables: any;
|
|
66
|
-
field:
|
|
69
|
+
field: string | undefined;
|
|
67
70
|
fieldHref: string | undefined;
|
|
68
71
|
focusSuffix: any;
|
|
69
72
|
validator: any;
|
|
70
73
|
}
|
|
74
|
+
export type ValidateContext = import('./ValidatorFactory').ValidateContext;
|
|
@@ -6,6 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const lodash_1 = __importDefault(require("lodash"));
|
|
7
7
|
const { isPlainObject } = lodash_1.default; // CommonJS
|
|
8
8
|
const params = new WeakMap();
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {import('./ValidatorFactory').ValidateContext} ValidateContext
|
|
11
|
+
*/
|
|
9
12
|
class ValidationError {
|
|
10
13
|
/**
|
|
11
14
|
* Make a ValidationError instance from a primitive object (or a function that
|
|
@@ -111,11 +114,15 @@ class ValidationError {
|
|
|
111
114
|
// the values that will be readable, and reflect any context that may have
|
|
112
115
|
// been applied
|
|
113
116
|
Object.keys(originals).forEach((o) => {
|
|
117
|
+
// ESLint disabled as `o` is an "own" property of `originals`, which is
|
|
118
|
+
// dev-controlled
|
|
119
|
+
/* eslint-disable security/detect-object-injection */
|
|
114
120
|
Object.defineProperty(this, o, {
|
|
115
121
|
value: originals[o],
|
|
116
122
|
enumerable: true,
|
|
117
123
|
writable: true,
|
|
118
124
|
});
|
|
125
|
+
/* eslint-enable security/detect-object-injection */
|
|
119
126
|
});
|
|
120
127
|
}
|
|
121
128
|
/**
|
|
@@ -1,24 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('./index').ProcessorFunction} ProcessorFunction
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {import('./index').JourneyContext} JourneyContext
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {import('./index').ValidationError} ValidationError
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {object} Validator
|
|
12
|
+
* @property {ValidateFunction} validate Validation function
|
|
13
|
+
* @property {ProcessorFunction} sanitise Sanitise a given value prior to validation
|
|
14
|
+
* @property {object} config Configuration
|
|
15
|
+
* @property {string} name Validator name
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* @callback ValidateFunction
|
|
19
|
+
* @param {any} value
|
|
20
|
+
* @param {ValidateContext} context
|
|
21
|
+
* @returns {ValidationError[]}
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* @typedef {object} ValidateContext Context passed to validate function
|
|
25
|
+
* @property {JourneyContext} journeyContext Journey context
|
|
26
|
+
* @property {string} waypoint Waypoint
|
|
27
|
+
* @property {string} fieldName Name of field being processed
|
|
28
|
+
*/
|
|
1
29
|
export default class ValidatorFactory {
|
|
2
30
|
/**
|
|
3
|
-
* This is a convenience method that will
|
|
4
|
-
*
|
|
5
|
-
* method. i.e.
|
|
31
|
+
* This is a convenience method that will return a consistently object
|
|
32
|
+
* structure containing validation and sanitisation methods.
|
|
6
33
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* (new MyValidator()).validate('value to validate')
|
|
10
|
-
*
|
|
11
|
-
* It also attaches the `sanitise()` method as a static property to that
|
|
12
|
-
* function.
|
|
13
|
-
*
|
|
14
|
-
* @param {object} config Validator config
|
|
15
|
-
* @returns {object} Validator object
|
|
34
|
+
* @param {object} config Validator config (custom to the validator being created)
|
|
35
|
+
* @returns {Validator} Validator object
|
|
16
36
|
* @throws {TypeError} When configurarion is invalid.
|
|
17
37
|
*/
|
|
18
|
-
static make(config?: object):
|
|
38
|
+
static make(config?: object): Validator;
|
|
19
39
|
static coerceToValidatorObject(input: any): any;
|
|
20
40
|
constructor(config?: {});
|
|
21
41
|
config: {};
|
|
22
42
|
validate(fieldValue: any, context: any): void;
|
|
23
43
|
sanitise(fieldValue: any): any;
|
|
24
44
|
}
|
|
45
|
+
export type ProcessorFunction = import('./index').ProcessorFunction;
|
|
46
|
+
export type JourneyContext = import('./index').JourneyContext;
|
|
47
|
+
export type ValidationError = import('./index').ValidationError;
|
|
48
|
+
export type Validator = {
|
|
49
|
+
/**
|
|
50
|
+
* Validation function
|
|
51
|
+
*/
|
|
52
|
+
validate: ValidateFunction;
|
|
53
|
+
/**
|
|
54
|
+
* Sanitise a given value prior to validation
|
|
55
|
+
*/
|
|
56
|
+
sanitise: any;
|
|
57
|
+
/**
|
|
58
|
+
* Configuration
|
|
59
|
+
*/
|
|
60
|
+
config: object;
|
|
61
|
+
/**
|
|
62
|
+
* Validator name
|
|
63
|
+
*/
|
|
64
|
+
name: string;
|
|
65
|
+
};
|
|
66
|
+
export type ValidateFunction = (value: any, context: ValidateContext) => ValidationError[];
|
|
67
|
+
/**
|
|
68
|
+
* Context passed to validate function
|
|
69
|
+
*/
|
|
70
|
+
export type ValidateContext = {
|
|
71
|
+
/**
|
|
72
|
+
* Journey context
|
|
73
|
+
*/
|
|
74
|
+
journeyContext: JourneyContext;
|
|
75
|
+
/**
|
|
76
|
+
* Waypoint
|
|
77
|
+
*/
|
|
78
|
+
waypoint: string;
|
|
79
|
+
/**
|
|
80
|
+
* Name of field being processed
|
|
81
|
+
*/
|
|
82
|
+
fieldName: string;
|
|
83
|
+
};
|
|
@@ -4,24 +4,43 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
/* eslint-disable class-methods-use-this */
|
|
7
|
-
// const { isPlainObject } = require('../Util.js');
|
|
8
7
|
const lodash_1 = __importDefault(require("lodash"));
|
|
9
8
|
const { isPlainObject } = lodash_1.default; // CommonJS
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {import('./index').ProcessorFunction} ProcessorFunction
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* @typedef {import('./index').JourneyContext} JourneyContext
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* @typedef {import('./index').ValidationError} ValidationError
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* @typedef {object} Validator
|
|
20
|
+
* @property {ValidateFunction} validate Validation function
|
|
21
|
+
* @property {ProcessorFunction} sanitise Sanitise a given value prior to validation
|
|
22
|
+
* @property {object} config Configuration
|
|
23
|
+
* @property {string} name Validator name
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* @callback ValidateFunction
|
|
27
|
+
* @param {any} value
|
|
28
|
+
* @param {ValidateContext} context
|
|
29
|
+
* @returns {ValidationError[]}
|
|
30
|
+
*/
|
|
31
|
+
/**
|
|
32
|
+
* @typedef {object} ValidateContext Context passed to validate function
|
|
33
|
+
* @property {JourneyContext} journeyContext Journey context
|
|
34
|
+
* @property {string} waypoint Waypoint
|
|
35
|
+
* @property {string} fieldName Name of field being processed
|
|
36
|
+
*/
|
|
10
37
|
class ValidatorFactory {
|
|
11
38
|
/**
|
|
12
|
-
* This is a convenience method that will
|
|
13
|
-
*
|
|
14
|
-
* method. i.e.
|
|
39
|
+
* This is a convenience method that will return a consistently object
|
|
40
|
+
* structure containing validation and sanitisation methods.
|
|
15
41
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* (new MyValidator()).validate('value to validate')
|
|
19
|
-
*
|
|
20
|
-
* It also attaches the `sanitise()` method as a static property to that
|
|
21
|
-
* function.
|
|
22
|
-
*
|
|
23
|
-
* @param {object} config Validator config
|
|
24
|
-
* @returns {object} Validator object
|
|
42
|
+
* @param {object} config Validator config (custom to the validator being created)
|
|
43
|
+
* @returns {Validator} Validator object
|
|
25
44
|
* @throws {TypeError} When configurarion is invalid.
|
|
26
45
|
*/
|
|
27
46
|
static make(config = {}) {
|
|
@@ -31,7 +50,7 @@ class ValidatorFactory {
|
|
|
31
50
|
const validator = Reflect.construct(this, [config]);
|
|
32
51
|
/* eslint-disable-next-line sonarjs/prefer-object-literal */
|
|
33
52
|
const instance = {};
|
|
34
|
-
instance.name = validator.name ||
|
|
53
|
+
instance.name = validator.name || 'unknown';
|
|
35
54
|
instance.config = config;
|
|
36
55
|
instance.validate = validator.validate.bind(instance);
|
|
37
56
|
instance.sanitise = validator.sanitise.bind(instance);
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validates and sanitises i18n obejct.
|
|
3
|
+
*
|
|
4
|
+
* @param {object} i18n Object to validate.
|
|
5
|
+
* @param {Function} cb Callback function that receives the validated value.
|
|
6
|
+
* @throws {TypeError} For invalid object.
|
|
7
|
+
* @returns {object} Sanitised i18n object.
|
|
8
|
+
*/
|
|
9
|
+
export function validateI18nObject(i18n: object, cb?: Function): object;
|
|
10
|
+
/**
|
|
11
|
+
* Validates and sanitises i18n directory.
|
|
12
|
+
*
|
|
13
|
+
* @param {Array} dirs Array of directories.
|
|
14
|
+
* @throws {SyntaxError} For invalid directories.
|
|
15
|
+
* @throws {TypeError} For invalid type.
|
|
16
|
+
* @returns {Array} Array of directories.
|
|
17
|
+
*/
|
|
18
|
+
export function validateI18nDirs(dirs: any[]): any[];
|
|
19
|
+
/**
|
|
20
|
+
* Validates and sanitises i18n locales.
|
|
21
|
+
*
|
|
22
|
+
* @param {Array} locales Array of locales.
|
|
23
|
+
* @throws {SyntaxError} For invalid locales.
|
|
24
|
+
* @throws {TypeError} For invalid type.
|
|
25
|
+
* @returns {Array} Array of locales.
|
|
26
|
+
*/
|
|
27
|
+
export function validateI18nLocales(locales: any[]): any[];
|
|
28
|
+
/**
|
|
29
|
+
* Validates and sanitises mount url.
|
|
30
|
+
*
|
|
31
|
+
* @param {string} mountUrl URL from which Express app will be served.
|
|
32
|
+
* @param {string} name Name of the URL type (Mount URL, or Proxy Mount URL).
|
|
33
|
+
* @throws {SyntaxError} For invalid URL.
|
|
34
|
+
* @returns {string} Sanitised URL.
|
|
35
|
+
*/
|
|
36
|
+
export function validateMountUrl(mountUrl: string, name?: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* Validates and sanitises sessions object.
|
|
39
|
+
*
|
|
40
|
+
* @param {object} session Object to validate.
|
|
41
|
+
* @param {Function} cb Callback function that receives the validated value.
|
|
42
|
+
* @throws {TypeError} For invalid object.
|
|
43
|
+
* @returns {object} Sanitised sessions object.
|
|
44
|
+
*/
|
|
45
|
+
export function validateSessionObject(session: object, cb?: Function): object;
|
|
46
|
+
/**
|
|
47
|
+
* Validates and sanitises view directory.
|
|
48
|
+
*
|
|
49
|
+
* @param {Array} dirs Array of directories.
|
|
50
|
+
* @throws {SyntaxError} For invalid directories.
|
|
51
|
+
* @throws {TypeError} For invalid type.
|
|
52
|
+
* @returns {Array} Array of directories.
|
|
53
|
+
*/
|
|
54
|
+
export function validateViews(dirs: any[]): any[];
|
|
55
|
+
/**
|
|
56
|
+
* Validates and sanitises sessions secret.
|
|
57
|
+
*
|
|
58
|
+
* @param {string} secret Session secret.
|
|
59
|
+
* @throws {ReferenceError} For missing value type.
|
|
60
|
+
* @throws {TypeError} For invalid value.
|
|
61
|
+
* @returns {string} Secret.
|
|
62
|
+
*/
|
|
63
|
+
export function validateSessionSecret(secret: string): string;
|
|
64
|
+
/**
|
|
65
|
+
* Validates and sanitises sessions ttl.
|
|
66
|
+
*
|
|
67
|
+
* @param {number} ttl Session ttl (seconds).
|
|
68
|
+
* @throws {ReferenceError} For missing value type.
|
|
69
|
+
* @throws {TypeError} For invalid value.
|
|
70
|
+
* @returns {number} Ttl.
|
|
71
|
+
*/
|
|
72
|
+
export function validateSessionTtl(ttl: number): number;
|
|
73
|
+
/**
|
|
74
|
+
* Validates and sanitises sessions name.
|
|
75
|
+
*
|
|
76
|
+
* @param {string} name Session name.
|
|
77
|
+
* @throws {ReferenceError} For missing value type.
|
|
78
|
+
* @throws {TypeError} For invalid value.
|
|
79
|
+
* @returns {string} Name.
|
|
80
|
+
*/
|
|
81
|
+
export function validateSessionName(name: string): string;
|
|
82
|
+
/**
|
|
83
|
+
* Validates and sanitises sessions secure flag.
|
|
84
|
+
*
|
|
85
|
+
* @param {boolean} secure Session secure flag.
|
|
86
|
+
* @throws {ReferenceError} For missing value type.
|
|
87
|
+
* @throws {TypeError} For invalid value.
|
|
88
|
+
* @returns {string} Name.
|
|
89
|
+
*/
|
|
90
|
+
export function validateSessionSecure(secure: boolean): string;
|
|
91
|
+
/**
|
|
92
|
+
* Validates and sanitises sessions store.
|
|
93
|
+
*
|
|
94
|
+
* @param {Function} store Session store.
|
|
95
|
+
* @returns {Function} Store.
|
|
96
|
+
*/
|
|
97
|
+
export function validateSessionStore(store: Function): Function;
|
|
98
|
+
/**
|
|
99
|
+
* Validates and sanitises sessions cookie url path.
|
|
100
|
+
*
|
|
101
|
+
* @param {string} cookiePath Session cookie url path.
|
|
102
|
+
* @param {string} defaultPath Default path if none specified.
|
|
103
|
+
* @returns {string} Cookie path.
|
|
104
|
+
*/
|
|
105
|
+
export function validateSessionCookiePath(cookiePath: string, defaultPath?: string): string;
|
|
106
|
+
/**
|
|
107
|
+
* Validates and sanitises sessions cookie "sameSite" flag. One of:
|
|
108
|
+
* true (Strict)
|
|
109
|
+
* false (will not set the flag at all)
|
|
110
|
+
* Strict
|
|
111
|
+
* Lax
|
|
112
|
+
* None
|
|
113
|
+
*
|
|
114
|
+
* @param {any} cookieSameSite Session cookie "sameSite" flag
|
|
115
|
+
* @param {any} defaultFlag Default path if none specified
|
|
116
|
+
* @returns {boolean} cookie path
|
|
117
|
+
* @throws {TypeError} When invalid arguments are provided
|
|
118
|
+
*/
|
|
119
|
+
export function validateSessionCookieSameSite(cookieSameSite: any, defaultFlag: any): boolean;
|
|
120
|
+
export function validatePageHooks(hooks: any): any[];
|
|
121
|
+
export function validateFields(fields: any): any[];
|
|
122
|
+
export function validatePages(pages: any): any[];
|
|
123
|
+
export function validatePlan(plan: any): any;
|
|
124
|
+
export function validateGlobalHooks(hooks: any): any[];
|
|
125
|
+
export function validatePlugins(plugins: any): any;
|
|
126
|
+
export function validateEvents(events: any): any;
|
|
127
|
+
/**
|
|
128
|
+
* Ingest, validate, sanitise and manipulate configuration parameters.
|
|
129
|
+
*
|
|
130
|
+
* @param {ConfigurationOptions} config Config to ingest.
|
|
131
|
+
* @throws {Error|SyntaxError|TypeError} For invalid config values.
|
|
132
|
+
* @returns {object} Immutable config object.
|
|
133
|
+
*/
|
|
134
|
+
export default function ingest(config?: ConfigurationOptions): object;
|
|
135
|
+
export type ContextEvent = import('./index').ContextEvent;
|
|
136
|
+
export type SessionOptions = {
|
|
137
|
+
/**
|
|
138
|
+
* Session name
|
|
139
|
+
*/
|
|
140
|
+
name?: string | undefined;
|
|
141
|
+
/**
|
|
142
|
+
* Encryption secret
|
|
143
|
+
*/
|
|
144
|
+
secret?: string | undefined;
|
|
145
|
+
/**
|
|
146
|
+
* Session ttl (seconds)
|
|
147
|
+
*/
|
|
148
|
+
ttl?: number | undefined;
|
|
149
|
+
/**
|
|
150
|
+
* Whether to use secure session cookies
|
|
151
|
+
*/
|
|
152
|
+
secure?: boolean | undefined;
|
|
153
|
+
/**
|
|
154
|
+
* SameSite (true = Strict)
|
|
155
|
+
*/
|
|
156
|
+
cookieSameSite?: string | boolean | undefined;
|
|
157
|
+
/**
|
|
158
|
+
* Session store (default MemoryStore)
|
|
159
|
+
*/
|
|
160
|
+
store?: object | undefined;
|
|
161
|
+
};
|
|
162
|
+
export type I18nOptions = {
|
|
163
|
+
/**
|
|
164
|
+
* Directories to search for locale dictionaries
|
|
165
|
+
*/
|
|
166
|
+
dirs: string[];
|
|
167
|
+
/**
|
|
168
|
+
* Supported locales
|
|
169
|
+
*/
|
|
170
|
+
locales?: string[] | undefined;
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* Hook configuration
|
|
174
|
+
*/
|
|
175
|
+
export type GlobalHook = {
|
|
176
|
+
/**
|
|
177
|
+
* Hook name in format `<router>.<hook>`
|
|
178
|
+
*/
|
|
179
|
+
hook: string;
|
|
180
|
+
/**
|
|
181
|
+
* Middleware function to insert at the hook point
|
|
182
|
+
*/
|
|
183
|
+
middleware: Function;
|
|
184
|
+
/**
|
|
185
|
+
* Only run if route path matches this string/regexp
|
|
186
|
+
*/
|
|
187
|
+
path?: string | RegExp | undefined;
|
|
188
|
+
};
|
|
189
|
+
/**
|
|
190
|
+
* (extends GlobalHook)
|
|
191
|
+
*/
|
|
192
|
+
export type PageHook = {
|
|
193
|
+
/**
|
|
194
|
+
* Hook name (without a scope prefix)
|
|
195
|
+
*/
|
|
196
|
+
hook: string;
|
|
197
|
+
/**
|
|
198
|
+
* Middleware function to insert at the hook point
|
|
199
|
+
*/
|
|
200
|
+
middleware: Function;
|
|
201
|
+
};
|
|
202
|
+
/**
|
|
203
|
+
* Page configuration. A Page is the interactive representation of a waypoint
|
|
204
|
+
*/
|
|
205
|
+
export type Page = {
|
|
206
|
+
/**
|
|
207
|
+
* The waypoint with which this page is associated
|
|
208
|
+
*/
|
|
209
|
+
waypoint: string;
|
|
210
|
+
/**
|
|
211
|
+
* Template path
|
|
212
|
+
*/
|
|
213
|
+
view: string;
|
|
214
|
+
/**
|
|
215
|
+
* Page-specific hooks (optional, default [])
|
|
216
|
+
*/
|
|
217
|
+
hooks?: PageHook[] | undefined;
|
|
218
|
+
/**
|
|
219
|
+
* Fields to be managed on this page (optional, default [])
|
|
220
|
+
*/
|
|
221
|
+
fields?: PageField[] | undefined;
|
|
222
|
+
};
|
|
223
|
+
/**
|
|
224
|
+
* Configuration options
|
|
225
|
+
*/
|
|
226
|
+
export type ConfigurationOptions = {
|
|
227
|
+
mountUrl?: string | undefined;
|
|
228
|
+
/**
|
|
229
|
+
* Template directories
|
|
230
|
+
*/
|
|
231
|
+
views?: string[] | undefined;
|
|
232
|
+
/**
|
|
233
|
+
* Session configuration
|
|
234
|
+
*/
|
|
235
|
+
session?: SessionOptions | undefined;
|
|
236
|
+
/**
|
|
237
|
+
* Pages the represent waypoints
|
|
238
|
+
*/
|
|
239
|
+
pages?: Page[] | undefined;
|
|
240
|
+
/**
|
|
241
|
+
* Hooks to apply
|
|
242
|
+
*/
|
|
243
|
+
hooks?: GlobalHook[] | undefined;
|
|
244
|
+
/**
|
|
245
|
+
* Plugins
|
|
246
|
+
*/
|
|
247
|
+
plugins?: object[] | undefined;
|
|
248
|
+
/**
|
|
249
|
+
* I18n configuration
|
|
250
|
+
*/
|
|
251
|
+
i18n?: I18nOptions[] | undefined;
|
|
252
|
+
/**
|
|
253
|
+
* CASA Plan
|
|
254
|
+
*/
|
|
255
|
+
plan: Plan;
|
|
256
|
+
/**
|
|
257
|
+
* Handlers for JourneyContext events
|
|
258
|
+
*/
|
|
259
|
+
events?: any[] | undefined;
|
|
260
|
+
};
|
|
261
|
+
import { PageField } from "./field.js";
|
|
262
|
+
import Plan from "./Plan.js";
|