@rokt/dcui-orchestrator 1.2.1-rc.51 → 1.2.1-rc.53
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/dist/index.cjs +32 -32
- package/dist/index.js +38 -38
- package/dist/libraries/dcui-components/src/failure-codes.d.ts +1 -0
- package/dist/libraries/domain/src/models/form-state.d.ts +85 -0
- package/dist/libraries/domain/src/models/global-state.d.ts +15 -1
- package/dist/libraries/module-utils/src/sagas/child-layouts/sagas.d.ts +12 -4
- package/dist/modules/instant-purchase/src/selectors/catalog-selection/index.d.ts +1 -0
- package/dist/modules/instant-purchase/src/selectors/catalog-selection/selectors.d.ts +7 -0
- package/dist/modules/instant-purchase/src/selectors/index.d.ts +1 -0
- package/dist/modules/instant-purchase/src/utils/compute-selections-for-item.d.ts +7 -0
- package/package.json +1 -1
|
@@ -6,3 +6,4 @@ export declare const FAILED_TO_MAP_STATIC_DATA = "FAILED_TO_MAP_STATIC_DATA";
|
|
|
6
6
|
export declare const FAILED_SANITISING_HTML = "FAILED_SANITISING_HTML";
|
|
7
7
|
export declare const UNRESOLVED_FORM_VALIDATION_TARGET = "UNRESOLVED_FORM_VALIDATION_TARGET";
|
|
8
8
|
export declare const MISSING_LEAD_IDENTITY = "MISSING_LEAD_IDENTITY";
|
|
9
|
+
export declare const UNSAFE_FORM_VALIDATION_PATTERN = "UNSAFE_FORM_VALIDATION_PATTERN";
|
|
@@ -83,3 +83,88 @@ export interface FormFieldRef {
|
|
|
83
83
|
* ActionButton (to gate dispatch) so both resolve entries identically.
|
|
84
84
|
*/
|
|
85
85
|
export declare function resolveFormFieldRefs(formStates: FormStatesState, entries: string[]): FormFieldRef[];
|
|
86
|
+
/**
|
|
87
|
+
* The longest `Pattern` a layout may register. A longer one is refused by
|
|
88
|
+
* {@link scanPattern}: the form-state reducer drops it at registration and
|
|
89
|
+
* {@link matchesPattern} treats it as non-blocking.
|
|
90
|
+
*/
|
|
91
|
+
export declare const MAX_PATTERN_LENGTH = 256;
|
|
92
|
+
/**
|
|
93
|
+
* The longest value a `Pattern` validation tests, whatever the pattern. A
|
|
94
|
+
* longer value fails the validation with its message, untested. The rules of
|
|
95
|
+
* {@link scanPattern} bound the engine's work on a value of this length and
|
|
96
|
+
* on no other.
|
|
97
|
+
*/
|
|
98
|
+
export declare const MAX_PATTERN_VALUE_LENGTH = 512;
|
|
99
|
+
/** Why {@link scanPattern} refused a pattern: the first rule it broke. */
|
|
100
|
+
export type PatternRefusal = 'too-long' | 'backreference' | 'nested-quantifier' | 'repeated-alternation' | 'quantified-lookaround' | 'too-many-repetitions' | 'count-too-wide' | 'too-many-ways' | 'too-many-steps' | 'invalid';
|
|
101
|
+
/** What {@link scanPattern} read: the verdict, with a refusal's reason. */
|
|
102
|
+
export type PatternScan = {
|
|
103
|
+
safe: true;
|
|
104
|
+
} | {
|
|
105
|
+
safe: false;
|
|
106
|
+
reason: PatternRefusal;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* The walk behind {@link isSafePattern}: one pass over the pattern's syntax,
|
|
110
|
+
* with no reading of what the atoms match. Escapes and `[...]` classes are
|
|
111
|
+
* one token each, so a `(`, `|` or `*` inside them is literal. The rules are
|
|
112
|
+
* blunt by design: each refuses a shape that can backtrack past the value
|
|
113
|
+
* cap, and with it the safe patterns of the same shape. The check that reads
|
|
114
|
+
* a pattern's real cost belongs at publish time, in the service that stores
|
|
115
|
+
* the layout. Refused, in the order the rules are read:
|
|
116
|
+
*
|
|
117
|
+
* 1. a pattern longer than {@link MAX_PATTERN_LENGTH};
|
|
118
|
+
* 2. a backreference, `\1` or `\k<name>`;
|
|
119
|
+
* 3. a repeated group that holds a quantifier of its own, at any depth:
|
|
120
|
+
* `(a+)+`, `(\d{3}-?)+`, `(a+){3}`. A `?` or a `{1}` on the group takes
|
|
121
|
+
* it whole or not at all, so `(a+)?` is accepted. A fixed count is copies
|
|
122
|
+
* of the group in sequence, so `(\d{4}[- ]?){3}` is accepted;
|
|
123
|
+
* 4. a repeated group that holds a `|`, at any depth: `(a|ab)+`. A fixed
|
|
124
|
+
* count is copies here too, so `(?:a|ab){3}` is accepted;
|
|
125
|
+
* 5. a quantifier on a lookaround, inside one, or on a group that holds
|
|
126
|
+
* one: `(?=a)+`, `(?=.*\d)`, `(?:(?=a)b){3}`;
|
|
127
|
+
* 6. more than {@link MAX_REPETITIONS} repetitions that can run on in the
|
|
128
|
+
* whole pattern, or more than {@link MAX_ANCHORED_REPETITIONS} in one
|
|
129
|
+
* anchored at `^`: `\w*\w*\w*-`, `^\w*\w*\w*\w*$`, where `^\w*\w*\w*$`
|
|
130
|
+
* and `^[^\s@]+@[^\s@]+\.[^\s@]+$` are accepted;
|
|
131
|
+
* 7. a count past {@link MAX_PATTERN_VALUE_LENGTH}, on its own or multiplied
|
|
132
|
+
* through the counts of the groups that hold it: `\w{513}`, `.{0,1000}`,
|
|
133
|
+
* `(?:\b){999}`, `(?:(?:\b){512}){512}`;
|
|
134
|
+
* 8. {@link MAX_WAYS_STEPS} steps or more from the ways alone: each atom's
|
|
135
|
+
* count, once per way of the atoms before it. Thirty `a?`, eight
|
|
136
|
+
* `\d{1,9}`, `^(?:\d{1,9}){5}\w{467}$` and sixteen `a?` before `\w{495}$`
|
|
137
|
+
* are refused, where a phone, card, IPv4 or optional-scheme URL pattern
|
|
138
|
+
* is accepted;
|
|
139
|
+
* 9. {@link MAX_PATTERN_STEPS} steps or more from the ways and the runs
|
|
140
|
+
* together: the same sum, each run multiplying the paths to the atoms
|
|
141
|
+
* after it by the cap over the run's rank on its own path (its branch
|
|
142
|
+
* and the branches of the groups that hold it, never a sibling `|`
|
|
143
|
+
* alternative, so the branches of a `|` add up), and a pattern with no
|
|
144
|
+
* `^` running from every position. Twelve `a?` before `\w*\w*$`,
|
|
145
|
+
* `\w*\w*-`, `^\w*\w*\w{511}$` and `^\w*!|^` with nine `a?` before
|
|
146
|
+
* `\w*\w*!` are refused, where `^\w*\w*\w*!`, `\S+@\S+` and `^\S+@\S+$`
|
|
147
|
+
* are accepted;
|
|
148
|
+
* 10. a pattern RegExp rejects, as `(`.
|
|
149
|
+
*
|
|
150
|
+
* An accepted pattern is tested on a value of {@link MAX_PATTERN_VALUE_LENGTH}
|
|
151
|
+
* characters at most; {@link matchesPattern} fails a longer value untested.
|
|
152
|
+
*/
|
|
153
|
+
export declare function scanPattern(pattern: string): PatternScan;
|
|
154
|
+
/**
|
|
155
|
+
* Whether a layout author's `Pattern` can be tested without hanging the
|
|
156
|
+
* plugin. The regular expression runs synchronously on the UI thread, inside
|
|
157
|
+
* a reducer, on every keystroke, and cannot be interrupted, so the only
|
|
158
|
+
* control is on the pattern's shape before it runs: the rules of
|
|
159
|
+
* {@link scanPattern}. A `pattern` that is no string is not refused, so a
|
|
160
|
+
* layout no schema checked still registers, but {@link matchesPattern}
|
|
161
|
+
* never compiles it.
|
|
162
|
+
*/
|
|
163
|
+
export declare function isSafePattern(pattern: string): boolean;
|
|
164
|
+
/**
|
|
165
|
+
* Whether a validation may be registered on a field: every validation but a
|
|
166
|
+
* `Pattern` that {@link isSafePattern} refuses. Shared by the form-state
|
|
167
|
+
* reducer, which drops the refused ones, and the TextInput, which reports
|
|
168
|
+
* them, so the two never disagree on what was dropped.
|
|
169
|
+
*/
|
|
170
|
+
export declare function isSafeInputValidation(validation: InputValidation): boolean;
|
|
@@ -16,10 +16,24 @@ export interface GlobalState {
|
|
|
16
16
|
firedEvents: Partial<Record<LayoutEvent, boolean>>;
|
|
17
17
|
formStates: FormStatesState;
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* The catalog choice a host module has made, synced so a child layout can
|
|
21
|
+
* show it. The child already holds the offer, so only identifiers travel.
|
|
22
|
+
*/
|
|
23
|
+
export interface SyncedCatalogSelection {
|
|
24
|
+
/** The selected item, or a stacked selector's preview of one; `null` before any choice. */
|
|
25
|
+
catalogItemId: string | null;
|
|
26
|
+
/** Chosen option label per attribute id, partial while the shopper is choosing. */
|
|
27
|
+
attributeSelections: Record<string, string>;
|
|
28
|
+
}
|
|
19
29
|
/**
|
|
20
30
|
* The GlobalState slices a host syncs down to a child layout; `breakpoint`
|
|
21
31
|
* is absent because the child computes its own from its iframe width.
|
|
32
|
+
* `catalogSelection` is module state, present only when the launching module
|
|
33
|
+
* has a catalog selection to share.
|
|
22
34
|
*/
|
|
23
|
-
export type SyncedGlobalState = Pick<GlobalState, 'progression' | 'customStates' | 'domainStates' | 'firedEvents' | 'formStates'
|
|
35
|
+
export type SyncedGlobalState = Pick<GlobalState, 'progression' | 'customStates' | 'domainStates' | 'firedEvents' | 'formStates'> & {
|
|
36
|
+
catalogSelection?: SyncedCatalogSelection;
|
|
37
|
+
};
|
|
24
38
|
export declare function makeSyncedGlobalState(state?: Partial<SyncedGlobalState>): SyncedGlobalState;
|
|
25
39
|
export declare function makeGlobalState(state?: Partial<GlobalState>): GlobalState;
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import { LaunchChildLayout } from '../../../../domain/src/behaviors';
|
|
2
|
-
import { CallEffect, CancelledEffect, ChannelTakeEffect, ForkEffect, PutEffect, RaceEffect, SelectEffect } from 'redux-saga/effects';
|
|
2
|
+
import { CallEffect, CancelEffect, CancelledEffect, ChannelTakeEffect, ForkEffect, PutEffect, RaceEffect, SelectEffect } from 'redux-saga/effects';
|
|
3
3
|
import { GlobalGateway } from '../../../../module-connector/src/main';
|
|
4
|
-
import { Log, PluginOffer } from '../../../../domain/src/models';
|
|
4
|
+
import { Log, PluginOffer, SyncedCatalogSelection } from '../../../../domain/src/models';
|
|
5
5
|
import { BasicObject, ChildPluginInterface } from '@rokt/plugin';
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Reads a module's catalog selection from its own store. Re-read after every
|
|
8
|
+
* module action; an unchanged result is not re-sent.
|
|
9
|
+
*/
|
|
10
|
+
export type SelectCatalogSelection = {
|
|
11
|
+
bivarianceHack(state: unknown): SyncedCatalogSelection;
|
|
12
|
+
}['bivarianceHack'];
|
|
13
|
+
export declare function launchChildLayout(gateway: GlobalGateway, logger: (log: Log) => void, action: LaunchChildLayout, selectCatalogSelection?: SelectCatalogSelection): Generator<PutEffect | CallEffect | SelectEffect | ForkEffect, void, never>;
|
|
7
14
|
type BridgeChannelMessage = {
|
|
8
15
|
kind: 'ready';
|
|
9
16
|
} | {
|
|
@@ -15,5 +22,6 @@ export declare function childLayoutBridge(gateway: GlobalGateway, logger: (log:
|
|
|
15
22
|
offerPositionIndex: number | undefined;
|
|
16
23
|
childInstanceGuid: string;
|
|
17
24
|
advanceOnDismiss?: boolean;
|
|
18
|
-
|
|
25
|
+
selectCatalogSelection?: SelectCatalogSelection;
|
|
26
|
+
}): Generator<PutEffect | CallEffect | CancelledEffect | CancelEffect | ForkEffect | SelectEffect | RaceEffect<ChannelTakeEffect<BridgeChannelMessage> | CallEffect>, void, never>;
|
|
19
27
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './selectors';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SyncedCatalogSelection } from '../../../../../libraries/domain/src/models';
|
|
2
|
+
import { AppState } from '../../reducers';
|
|
3
|
+
/**
|
|
4
|
+
* The selection a child layout mirrors. A full-item choice (a dropdown or the
|
|
5
|
+
* default item) has no recorded attribute choices, so they are derived from it.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getSyncedCatalogSelection(state: AppState): SyncedCatalogSelection;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CatalogItemGroupAttribute } from '../../../../libraries/domain/src/models';
|
|
2
|
+
/**
|
|
3
|
+
* Derives the per-attribute option labels that resolve to a catalog item: for
|
|
4
|
+
* each attribute, the option whose catalogItemIds contains the item. Used to
|
|
5
|
+
* pre-fill stacked dropdowns and to describe a full-item selection.
|
|
6
|
+
*/
|
|
7
|
+
export declare function computeSelectionsForItem(attributes: CatalogItemGroupAttribute[], catalogItemId: string): Record<string, string>;
|