@dwp/govuk-casa 7.0.8 → 7.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/middleware/page/journey-continue.js +5 -0
- package/package.json +15 -15
- package/dist/assets/css/casa-ie8.css +0 -1
- package/dist/assets/css/casa.css +0 -1
- package/dist/casa.d.ts +0 -11
- package/dist/casa.js +0 -46
- package/dist/lib/CasaTemplateLoader.d.ts +0 -29
- package/dist/lib/CasaTemplateLoader.js +0 -74
- package/dist/lib/JourneyContext.d.ts +0 -297
- package/dist/lib/JourneyContext.js +0 -581
- package/dist/lib/MutableRouter.d.ts +0 -155
- package/dist/lib/MutableRouter.js +0 -277
- package/dist/lib/Plan.d.ts +0 -154
- package/dist/lib/Plan.js +0 -442
- package/dist/lib/ValidationError.d.ts +0 -74
- package/dist/lib/ValidationError.js +0 -159
- package/dist/lib/ValidatorFactory.d.ts +0 -83
- package/dist/lib/ValidatorFactory.js +0 -106
- package/dist/lib/configuration-ingestor.d.ts +0 -262
- package/dist/lib/configuration-ingestor.js +0 -490
- package/dist/lib/configure.d.ts +0 -90
- package/dist/lib/configure.js +0 -192
- package/dist/lib/dirname.cjs +0 -1
- package/dist/lib/dirname.d.cts +0 -2
- package/dist/lib/end-session.d.ts +0 -13
- package/dist/lib/end-session.js +0 -43
- package/dist/lib/field.d.ts +0 -77
- package/dist/lib/field.js +0 -255
- package/dist/lib/index.d.ts +0 -14
- package/dist/lib/index.js +0 -54
- package/dist/lib/logger.d.ts +0 -9
- package/dist/lib/logger.js +0 -18
- package/dist/lib/nunjucks-filters.d.ts +0 -26
- package/dist/lib/nunjucks-filters.js +0 -90
- package/dist/lib/nunjucks.d.ts +0 -23
- package/dist/lib/nunjucks.js +0 -49
- package/dist/lib/utils.d.ts +0 -48
- package/dist/lib/utils.js +0 -111
- package/dist/lib/validators/dateObject.d.ts +0 -4
- package/dist/lib/validators/dateObject.js +0 -135
- package/dist/lib/validators/email.d.ts +0 -4
- package/dist/lib/validators/email.js +0 -46
- package/dist/lib/validators/inArray.d.ts +0 -4
- package/dist/lib/validators/inArray.js +0 -60
- package/dist/lib/validators/index.d.ts +0 -21
- package/dist/lib/validators/index.js +0 -47
- package/dist/lib/validators/nino.d.ts +0 -4
- package/dist/lib/validators/nino.js +0 -46
- package/dist/lib/validators/postalAddressObject.d.ts +0 -4
- package/dist/lib/validators/postalAddressObject.js +0 -123
- package/dist/lib/validators/regex.d.ts +0 -4
- package/dist/lib/validators/regex.js +0 -40
- package/dist/lib/validators/required.d.ts +0 -4
- package/dist/lib/validators/required.js +0 -56
- package/dist/lib/validators/strlen.d.ts +0 -4
- package/dist/lib/validators/strlen.js +0 -51
- package/dist/lib/validators/wordCount.d.ts +0 -5
- package/dist/lib/validators/wordCount.js +0 -54
- package/dist/lib/waypoint-url.d.ts +0 -23
- package/dist/lib/waypoint-url.js +0 -52
- package/dist/middleware/body-parser.d.ts +0 -1
- package/dist/middleware/body-parser.js +0 -24
- package/dist/middleware/csrf.d.ts +0 -1
- package/dist/middleware/csrf.js +0 -31
- package/dist/middleware/data.d.ts +0 -5
- package/dist/middleware/data.js +0 -53
- package/dist/middleware/dirname.cjs +0 -1
- package/dist/middleware/dirname.d.cts +0 -2
- package/dist/middleware/gather-fields.d.ts +0 -6
- package/dist/middleware/gather-fields.js +0 -48
- package/dist/middleware/i18n.d.ts +0 -4
- package/dist/middleware/i18n.js +0 -88
- package/dist/middleware/post.d.ts +0 -3
- package/dist/middleware/post.js +0 -57
- package/dist/middleware/pre.d.ts +0 -3
- package/dist/middleware/pre.js +0 -51
- package/dist/middleware/progress-journey.d.ts +0 -6
- package/dist/middleware/progress-journey.js +0 -80
- package/dist/middleware/sanitise-fields.d.ts +0 -5
- package/dist/middleware/sanitise-fields.js +0 -53
- package/dist/middleware/session.d.ts +0 -11
- package/dist/middleware/session.js +0 -121
- package/dist/middleware/skip-waypoint.d.ts +0 -5
- package/dist/middleware/skip-waypoint.js +0 -43
- package/dist/middleware/steer-journey.d.ts +0 -7
- package/dist/middleware/steer-journey.js +0 -62
- package/dist/middleware/validate-fields.d.ts +0 -7
- package/dist/middleware/validate-fields.js +0 -67
- package/dist/mjs/esm-wrapper.js +0 -11
- package/dist/mjs/package.json +0 -3
- package/dist/package.json +0 -3
- package/dist/routes/ancillary.d.ts +0 -11
- package/dist/routes/ancillary.js +0 -27
- package/dist/routes/dirname.cjs +0 -1
- package/dist/routes/dirname.d.cts +0 -2
- package/dist/routes/journey.d.ts +0 -8
- package/dist/routes/journey.js +0 -127
- package/dist/routes/static.d.ts +0 -26
- package/dist/routes/static.js +0 -68
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {import('nunjucks').FileSystemLoaderOptions} FileSystemLoaderOptions
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* @callback BlockModifier
|
|
6
|
-
* @param {string} templateName Path to the template being modified
|
|
7
|
-
* @returns {string} The modified template source
|
|
8
|
-
*/
|
|
9
|
-
export default class CasaTemplateLoader extends FileSystemLoader {
|
|
10
|
-
/**
|
|
11
|
-
* Constructor.
|
|
12
|
-
*
|
|
13
|
-
* @param {string[]} searchPaths Template directories
|
|
14
|
-
* @param {FileSystemLoaderOptions} opts Loader options
|
|
15
|
-
*/
|
|
16
|
-
constructor(searchPaths: string[], opts: FileSystemLoaderOptions);
|
|
17
|
-
/**
|
|
18
|
-
* Add a modification function to the loader.
|
|
19
|
-
*
|
|
20
|
-
* @param {string} block Block name, e.g. `bodyStart`
|
|
21
|
-
* @param {BlockModifier} modifier Modifier function
|
|
22
|
-
* @returns {void}
|
|
23
|
-
*/
|
|
24
|
-
modifyBlock(block: string, modifier: BlockModifier): void;
|
|
25
|
-
#private;
|
|
26
|
-
}
|
|
27
|
-
export type FileSystemLoaderOptions = import('nunjucks').FileSystemLoaderOptions;
|
|
28
|
-
export type BlockModifier = (templateName: string) => string;
|
|
29
|
-
import { FileSystemLoader } from "nunjucks";
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
-
};
|
|
8
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
-
};
|
|
13
|
-
var _CasaTemplateLoader_instances, _CasaTemplateLoader_blockModifiers, _CasaTemplateLoader_applyBlockModifiers;
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const nunjucks_1 = require("nunjucks");
|
|
16
|
-
/**
|
|
17
|
-
* @typedef {import('nunjucks').FileSystemLoaderOptions} FileSystemLoaderOptions
|
|
18
|
-
*/
|
|
19
|
-
/**
|
|
20
|
-
* @callback BlockModifier
|
|
21
|
-
* @param {string} templateName Path to the template being modified
|
|
22
|
-
* @returns {string} The modified template source
|
|
23
|
-
*/
|
|
24
|
-
class CasaTemplateLoader extends nunjucks_1.FileSystemLoader {
|
|
25
|
-
/**
|
|
26
|
-
* Constructor.
|
|
27
|
-
*
|
|
28
|
-
* @param {string[]} searchPaths Template directories
|
|
29
|
-
* @param {FileSystemLoaderOptions} opts Loader options
|
|
30
|
-
*/
|
|
31
|
-
constructor(searchPaths, opts) {
|
|
32
|
-
super(searchPaths, opts);
|
|
33
|
-
_CasaTemplateLoader_instances.add(this);
|
|
34
|
-
_CasaTemplateLoader_blockModifiers.set(this, void 0);
|
|
35
|
-
__classPrivateFieldSet(this, _CasaTemplateLoader_blockModifiers, [], "f");
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Extract the source from the given template file.
|
|
39
|
-
*
|
|
40
|
-
* @param {string} name Source file path
|
|
41
|
-
* @returns {string} Source contents of template
|
|
42
|
-
*/
|
|
43
|
-
getSource(name) {
|
|
44
|
-
const source = super.getSource(name);
|
|
45
|
-
return source ? __classPrivateFieldGet(this, _CasaTemplateLoader_instances, "m", _CasaTemplateLoader_applyBlockModifiers).call(this, name, source) : source;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Add a modification function to the loader.
|
|
49
|
-
*
|
|
50
|
-
* @param {string} block Block name, e.g. `bodyStart`
|
|
51
|
-
* @param {BlockModifier} modifier Modifier function
|
|
52
|
-
* @returns {void}
|
|
53
|
-
*/
|
|
54
|
-
modifyBlock(block, modifier) {
|
|
55
|
-
// TODO: Limit to only known block so the user can't do general string replacements
|
|
56
|
-
__classPrivateFieldGet(this, _CasaTemplateLoader_blockModifiers, "f").push({
|
|
57
|
-
block,
|
|
58
|
-
modifier,
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
exports.default = CasaTemplateLoader;
|
|
63
|
-
_CasaTemplateLoader_blockModifiers = new WeakMap(), _CasaTemplateLoader_instances = new WeakSet(), _CasaTemplateLoader_applyBlockModifiers = function _CasaTemplateLoader_applyBlockModifiers(name, source) {
|
|
64
|
-
// TODO: This is open to abuse by plugin authors, e,g
|
|
65
|
-
// `{% block bodyStart %}{% endblock %} <script src="evil.js"></script>`. Problem, or no?
|
|
66
|
-
for (let i = 0, l = __classPrivateFieldGet(this, _CasaTemplateLoader_blockModifiers, "f").length; i < l; i++) {
|
|
67
|
-
const { block, modifier } = __classPrivateFieldGet(this, _CasaTemplateLoader_blockModifiers, "f")[i];
|
|
68
|
-
if (source.src.indexOf(`block ${block}`) > -1) {
|
|
69
|
-
/* eslint-disable-next-line no-param-reassign */
|
|
70
|
-
source.src = source.src.replace(`block ${block} %}`, `block ${block} %}${modifier(name)}`);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return source;
|
|
74
|
-
};
|
|
@@ -1,297 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {import('./configuration-ingestor').Page} Page
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* @callback ContextEventHandler
|
|
6
|
-
* @param {JourneyContext} journeyContext Context including changes
|
|
7
|
-
* @param {JourneyContext} previousContext Context prior to changes
|
|
8
|
-
* @returns {void}
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* @typedef {object} ContextEvent
|
|
12
|
-
* @property {string} waypoint Waypoint to watch for changes
|
|
13
|
-
* @property {string} [field] Field to watch for changes
|
|
14
|
-
* @property {ContextEventHandler} handler Handler to invoke when change happens
|
|
15
|
-
*/
|
|
16
|
-
export default class JourneyContext {
|
|
17
|
-
static DEFAULT_CONTEXT_ID: string;
|
|
18
|
-
/**
|
|
19
|
-
* Create a new JourneyContext using the plain object.
|
|
20
|
-
*
|
|
21
|
-
* @param {object} obj Object.
|
|
22
|
-
* @param {object} obj.data Data
|
|
23
|
-
* @param {object} obj.validation Validation state
|
|
24
|
-
* @param {object} obj.nav Navigation meta
|
|
25
|
-
* @param {object} obj.identity Identity meta
|
|
26
|
-
* @returns {JourneyContext} Instance.
|
|
27
|
-
*/
|
|
28
|
-
static fromObject({ data, validation, nav, identity, }?: {
|
|
29
|
-
data: object;
|
|
30
|
-
validation: object;
|
|
31
|
-
nav: object;
|
|
32
|
-
identity: object;
|
|
33
|
-
}): JourneyContext;
|
|
34
|
-
/**
|
|
35
|
-
* Construct a new JourneyContext instance frmo another instance.
|
|
36
|
-
*
|
|
37
|
-
* @param {JourneyContext} context Context to copy from
|
|
38
|
-
* @returns {JourneyContext} Constructed JourneyContext instance
|
|
39
|
-
* @throws {TypeError} When context is not a valid type
|
|
40
|
-
*/
|
|
41
|
-
static fromContext(context: JourneyContext): JourneyContext;
|
|
42
|
-
/**
|
|
43
|
-
* Initialise session with an empty entry for the "default" context.
|
|
44
|
-
*
|
|
45
|
-
* @param {object} session Request session
|
|
46
|
-
* @returns {void}
|
|
47
|
-
*/
|
|
48
|
-
static initContextStore(session: object): void;
|
|
49
|
-
/**
|
|
50
|
-
* Validate the format of a context ID, i.e. "default" or a uuid
|
|
51
|
-
* eg 00000000-0000-0000-0000-000000000000
|
|
52
|
-
* eg 123e4567-e89b-12d3-a456-426614174000
|
|
53
|
-
*
|
|
54
|
-
* @param {string} id Context ID
|
|
55
|
-
* @returns {string} Original ID if it's valid
|
|
56
|
-
* @throws {TypeError} When id is not a valid type
|
|
57
|
-
* @throws {SyntaxError} When id is not a valid uuid format
|
|
58
|
-
*/
|
|
59
|
-
static validateContextId(id: string): string;
|
|
60
|
-
/**
|
|
61
|
-
* Lookup context from session using the ID.
|
|
62
|
-
*
|
|
63
|
-
* @param {object} session Request session
|
|
64
|
-
* @param {string} id Context ID
|
|
65
|
-
* @returns {JourneyContext} The discovered JourneyContext instance
|
|
66
|
-
*/
|
|
67
|
-
static getContextById(session: object, id: string): JourneyContext;
|
|
68
|
-
/**
|
|
69
|
-
* Lookup context from session using the name.
|
|
70
|
-
*
|
|
71
|
-
* @param {object} session Request session
|
|
72
|
-
* @param {string} name Context name
|
|
73
|
-
* @returns {JourneyContext} The discovered JourneyContext instance
|
|
74
|
-
*/
|
|
75
|
-
static getContextByName(session: object, name: string): JourneyContext;
|
|
76
|
-
/**
|
|
77
|
-
* Lookup contexts from session using the tag.
|
|
78
|
-
*
|
|
79
|
-
* @param {object} session Request session
|
|
80
|
-
* @param {string} tag Context tag
|
|
81
|
-
* @returns {Array<JourneyContext>} The discovered JourneyContext instance
|
|
82
|
-
*/
|
|
83
|
-
static getContextsByTag(session: object, tag: string): Array<JourneyContext>;
|
|
84
|
-
/**
|
|
85
|
-
* Return all contexts currently stored in the session.
|
|
86
|
-
*
|
|
87
|
-
* @param {object} session Request session
|
|
88
|
-
* @returns {Array} Array of contexts
|
|
89
|
-
*/
|
|
90
|
-
static getContexts(session: object): any[];
|
|
91
|
-
/**
|
|
92
|
-
* Put context back into the session store.
|
|
93
|
-
*
|
|
94
|
-
* @param {object} session Request session
|
|
95
|
-
* @param {JourneyContext} context Context
|
|
96
|
-
* @returns {void}
|
|
97
|
-
* @throws {TypeError} When isession is not a valid type, or context has no ID
|
|
98
|
-
*/
|
|
99
|
-
static putContext(session: object, context: JourneyContext): void;
|
|
100
|
-
/**
|
|
101
|
-
* Remove a context from the session store.
|
|
102
|
-
*
|
|
103
|
-
* @param {object} session Request session
|
|
104
|
-
* @param {JourneyContext} context Context
|
|
105
|
-
* @returns {void}
|
|
106
|
-
*/
|
|
107
|
-
static removeContext(session: object, context: JourneyContext): void;
|
|
108
|
-
static removeContextById(session: any, id: any): void;
|
|
109
|
-
static removeContextByName(session: any, name: any): void;
|
|
110
|
-
static removeContextsByTag(session: any, tag: any): void;
|
|
111
|
-
static removeContexts(session: any): void;
|
|
112
|
-
static extractContextFromRequest(req: any): JourneyContext;
|
|
113
|
-
/**
|
|
114
|
-
* Constructor.
|
|
115
|
-
*
|
|
116
|
-
* `data` is the "single source of truth" for all data gathered during the
|
|
117
|
-
* user's journey. This is referred to as the "canonical data model".
|
|
118
|
-
* Page-specific "views" of this data are generated at runtime in order to
|
|
119
|
-
* populate/validate specific form fields.
|
|
120
|
-
*
|
|
121
|
-
* `validation` holds the results of form field validation carried out when
|
|
122
|
-
* page forms are POSTed. These results are mapped directly to per-page,
|
|
123
|
-
* per-field.
|
|
124
|
-
*
|
|
125
|
-
* `nav` holds information about the current navigation state. Currently this
|
|
126
|
-
* comprises of the language in which the user is navigating the service.
|
|
127
|
-
*
|
|
128
|
-
* `identity` holds information that helps uniquely identify this context
|
|
129
|
-
* among a group of contexts stored in the session.
|
|
130
|
-
*
|
|
131
|
-
* @param {object} data Entire journey data.
|
|
132
|
-
* @param {object} validation Page errors (indexed by waypoint id).
|
|
133
|
-
* @param {object} nav Navigation context.
|
|
134
|
-
* @param {object} identity Some metadata for identifying this context among others.
|
|
135
|
-
*/
|
|
136
|
-
constructor(data?: object, validation?: object, nav?: object, identity?: object);
|
|
137
|
-
/**
|
|
138
|
-
* Clone into an object that can be stringified.
|
|
139
|
-
*
|
|
140
|
-
* @returns {object} Plain object.
|
|
141
|
-
*/
|
|
142
|
-
toObject(): object;
|
|
143
|
-
set data(arg: object);
|
|
144
|
-
get data(): object;
|
|
145
|
-
get validation(): object;
|
|
146
|
-
get nav(): object;
|
|
147
|
-
get identity(): object;
|
|
148
|
-
/**
|
|
149
|
-
* Get data context for a specific a specific page.
|
|
150
|
-
*
|
|
151
|
-
* @param {string | Page} page Page waypoint ID, or Page object.
|
|
152
|
-
* @returns {object} Page data.
|
|
153
|
-
* @throws {TypeError} When page is invalid.
|
|
154
|
-
*/
|
|
155
|
-
getDataForPage(page: string | Page): object;
|
|
156
|
-
getData(): object;
|
|
157
|
-
/**
|
|
158
|
-
* Overwrite the data context with a new object.
|
|
159
|
-
*
|
|
160
|
-
* @param {object} data Data that will overwrite all existing data.
|
|
161
|
-
* @returns {JourneyContext} Chain.
|
|
162
|
-
*/
|
|
163
|
-
setData(data: object): JourneyContext;
|
|
164
|
-
/**
|
|
165
|
-
* Write field form data from a page HTML form, into the `data` model.
|
|
166
|
-
*
|
|
167
|
-
* By default this will store the data as-is, keyed against the page's
|
|
168
|
-
* waypoint ID. However, when passing a `Page` instance, its
|
|
169
|
-
* `fieldWriter()` method will be called to transform the provided formData
|
|
170
|
-
* before storing in `data`
|
|
171
|
-
*
|
|
172
|
-
* @param {string | Page} page Page waypoint ID, or Page object
|
|
173
|
-
* @param {object} webFormData Data to overwrite with
|
|
174
|
-
* @returns {JourneyContext} Chain
|
|
175
|
-
* @throws {TypeError} When page is invalid.
|
|
176
|
-
*/
|
|
177
|
-
setDataForPage(page: string | Page, webFormData: object): JourneyContext;
|
|
178
|
-
/**
|
|
179
|
-
* Return validation errors for all pages.
|
|
180
|
-
*
|
|
181
|
-
* @returns {object} All page validation errors.
|
|
182
|
-
*/
|
|
183
|
-
getValidationErrors(): object;
|
|
184
|
-
/**
|
|
185
|
-
* Removes any validation state for the given page. Clearing validation state
|
|
186
|
-
* completely will, by default, prevent onward traversal from this page. See
|
|
187
|
-
* the traversal logic in Plan class.
|
|
188
|
-
*
|
|
189
|
-
* @param {string} pageId Page ID.
|
|
190
|
-
* @returns {JourneyContext} Chain.
|
|
191
|
-
*/
|
|
192
|
-
removeValidationStateForPage(pageId: string): JourneyContext;
|
|
193
|
-
/**
|
|
194
|
-
* Clear any validation errors for the given page. This effectively declares
|
|
195
|
-
* that this page has been successfully validated, and so can be traversed. If
|
|
196
|
-
* you want to remove any knowledge of validation success/failure, use
|
|
197
|
-
* `removeValidationStateForPage()` instead.
|
|
198
|
-
*
|
|
199
|
-
* @param {string} pageId Page ID.
|
|
200
|
-
* @returns {JourneyContext} Chain.
|
|
201
|
-
*/
|
|
202
|
-
clearValidationErrorsForPage(pageId: string): JourneyContext;
|
|
203
|
-
/**
|
|
204
|
-
* Set validation errors for a page.
|
|
205
|
-
*
|
|
206
|
-
* @param {string} pageId Page ID.
|
|
207
|
-
* @param {ValidationError[]} errors Errors
|
|
208
|
-
* @returns {JourneyContext} Chain.
|
|
209
|
-
* @throws {SyntaxError} When errors are invalid.
|
|
210
|
-
*/
|
|
211
|
-
setValidationErrorsForPage(pageId: string, errors?: ValidationError[]): JourneyContext;
|
|
212
|
-
/**
|
|
213
|
-
* Return the validation errors associated with the page's currently held data
|
|
214
|
-
* context (if any).
|
|
215
|
-
*
|
|
216
|
-
* @param {string} pageId Page ID.
|
|
217
|
-
* @returns {ValidationError[]} An array of errors
|
|
218
|
-
*/
|
|
219
|
-
getValidationErrorsForPage(pageId: string): ValidationError[];
|
|
220
|
-
getValidationErrorsForPageByField(pageId: any): any;
|
|
221
|
-
/**
|
|
222
|
-
* Determine whether the specified page has any errors in its validation
|
|
223
|
-
* context.
|
|
224
|
-
*
|
|
225
|
-
* @param {string} pageId Page ID.
|
|
226
|
-
* @returns {boolean} Result.
|
|
227
|
-
*/
|
|
228
|
-
hasValidationErrorsForPage(pageId: string): boolean;
|
|
229
|
-
/**
|
|
230
|
-
* Set language of the context.
|
|
231
|
-
*
|
|
232
|
-
* @param {string} language Language to set (ISO 639-1 2-letter code).
|
|
233
|
-
* @returns {JourneyContext} Chain.
|
|
234
|
-
*/
|
|
235
|
-
setNavigationLanguage(language?: string): JourneyContext;
|
|
236
|
-
/**
|
|
237
|
-
* Convenience function to test if page is valid.
|
|
238
|
-
*
|
|
239
|
-
* @param {string} pageId Page ID.
|
|
240
|
-
* @returns {boolean} True if the page is valid.
|
|
241
|
-
*/
|
|
242
|
-
isPageValid(pageId: string): boolean;
|
|
243
|
-
/**
|
|
244
|
-
* Remove information about these waypoints.
|
|
245
|
-
*
|
|
246
|
-
* @param {string[]} waypoints Waypoints to be removed
|
|
247
|
-
*/
|
|
248
|
-
purge(waypoints?: string[]): void;
|
|
249
|
-
/**
|
|
250
|
-
* Remove validation state from these waypoints. This is useful to quickly
|
|
251
|
-
* force the user to revisit some waypoints.
|
|
252
|
-
*
|
|
253
|
-
* @param {string[]} waypoints Waypoints to be invalidated
|
|
254
|
-
* @returns {void}
|
|
255
|
-
*/
|
|
256
|
-
invalidate(waypoints?: string[]): void;
|
|
257
|
-
/**
|
|
258
|
-
* Event listeners are transient. They are not stored in session, and generally
|
|
259
|
-
* only apply for the current request.
|
|
260
|
-
*
|
|
261
|
-
* They also only act on a fixed snapshot of this context's state, which is
|
|
262
|
-
* taken at the point of attaching the listeners (in the "data" middleware).
|
|
263
|
-
* This is important because JourneyContext.putContext()` could be called many
|
|
264
|
-
* times during a request, so the context will be constantly changing.
|
|
265
|
-
*
|
|
266
|
-
* @param {ContextEvent[]} events Event listeners
|
|
267
|
-
* @returns {JourneyContext} Chain
|
|
268
|
-
*/
|
|
269
|
-
addEventListeners(events: ContextEvent[]): JourneyContext;
|
|
270
|
-
applyEventListeners({ event }: {
|
|
271
|
-
event: any;
|
|
272
|
-
}): JourneyContext;
|
|
273
|
-
/**
|
|
274
|
-
* Convenience method to determine if this is the default context.
|
|
275
|
-
*
|
|
276
|
-
* @returns {boolean} True if this is the "default" journey context
|
|
277
|
-
*/
|
|
278
|
-
isDefault(): boolean;
|
|
279
|
-
#private;
|
|
280
|
-
}
|
|
281
|
-
export type Page = import('./configuration-ingestor').Page;
|
|
282
|
-
export type ContextEventHandler = (journeyContext: JourneyContext, previousContext: JourneyContext) => void;
|
|
283
|
-
export type ContextEvent = {
|
|
284
|
-
/**
|
|
285
|
-
* Waypoint to watch for changes
|
|
286
|
-
*/
|
|
287
|
-
waypoint: string;
|
|
288
|
-
/**
|
|
289
|
-
* Field to watch for changes
|
|
290
|
-
*/
|
|
291
|
-
field?: string | undefined;
|
|
292
|
-
/**
|
|
293
|
-
* Handler to invoke when change happens
|
|
294
|
-
*/
|
|
295
|
-
handler: ContextEventHandler;
|
|
296
|
-
};
|
|
297
|
-
import ValidationError from "./ValidationError.js";
|