@wise/dynamic-flow-client 3.28.9 → 3.29.1
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/build/i18n/zh_CN.json +1 -1
- package/build/main.js +193 -164
- package/build/main.min.js +1 -1
- package/build/main.mjs +193 -164
- package/build/types/legacy/dynamic-flow-types.d.ts +1 -1
- package/build/types/revamp/domain/features/events.d.ts +1 -1
- package/build/types/revamp/flow/executePoll.d.ts +2 -0
- package/build/types/revamp/flow/executeRefresh.d.ts +1 -0
- package/build/types/revamp/flow/executeSubmission.d.ts +1 -0
- package/package.json +7 -7
package/build/main.mjs
CHANGED
|
@@ -138,12 +138,12 @@ var init_clsx = __esm({
|
|
|
138
138
|
}
|
|
139
139
|
});
|
|
140
140
|
|
|
141
|
-
// ../../node_modules/.pnpm/@wise+art@2.
|
|
141
|
+
// ../../node_modules/.pnpm/@wise+art@2.19.0_@transferwise+neptune-css@14.20.1_@types+react@18.3.18_react-dom@18.3.1_reac_mzw7cg6j4wc7ddwlhxck7linn4/node_modules/@wise/art/dist/index-8Fxev6OI.esm.js
|
|
142
142
|
import { useState, useEffect, forwardRef, Suspense, lazy } from "react";
|
|
143
143
|
import { jsx as jsx11, jsxs as jsxs3, Fragment } from "react/jsx-runtime";
|
|
144
144
|
var unknownFlagName, Flag, Sizes, ImageSizes, imageSizes, Assets, RenderMode;
|
|
145
|
-
var
|
|
146
|
-
"../../node_modules/.pnpm/@wise+art@2.
|
|
145
|
+
var init_index_8Fxev6OI_esm = __esm({
|
|
146
|
+
"../../node_modules/.pnpm/@wise+art@2.19.0_@transferwise+neptune-css@14.20.1_@types+react@18.3.18_react-dom@18.3.1_reac_mzw7cg6j4wc7ddwlhxck7linn4/node_modules/@wise/art/dist/index-8Fxev6OI.esm.js"() {
|
|
147
147
|
"use strict";
|
|
148
148
|
init_clsx();
|
|
149
149
|
unknownFlagName = "wise";
|
|
@@ -187,76 +187,76 @@ var init_index_213daaa3_esm = __esm({
|
|
|
187
187
|
[Sizes.LARGE]: 500
|
|
188
188
|
};
|
|
189
189
|
(function(Assets2) {
|
|
190
|
-
Assets2["
|
|
191
|
-
Assets2["
|
|
192
|
-
Assets2["
|
|
193
|
-
Assets2["
|
|
194
|
-
Assets2["
|
|
195
|
-
Assets2["
|
|
196
|
-
Assets2["
|
|
197
|
-
Assets2["
|
|
198
|
-
Assets2["
|
|
199
|
-
Assets2["
|
|
200
|
-
Assets2["
|
|
201
|
-
Assets2["
|
|
202
|
-
Assets2["
|
|
203
|
-
Assets2["
|
|
204
|
-
Assets2["
|
|
205
|
-
Assets2["
|
|
206
|
-
Assets2["
|
|
207
|
-
Assets2["
|
|
208
|
-
Assets2["
|
|
209
|
-
Assets2["
|
|
210
|
-
Assets2["
|
|
211
|
-
Assets2["
|
|
212
|
-
Assets2["
|
|
213
|
-
Assets2["
|
|
214
|
-
Assets2["GLOBE"] = "globe";
|
|
215
|
-
Assets2["GRAPH"] = "graph";
|
|
216
|
-
Assets2["HEART_2"] = "heart-2";
|
|
217
|
-
Assets2["HEART_3"] = "heart-3";
|
|
218
|
-
Assets2["HEART_4"] = "heart-4";
|
|
219
|
-
Assets2["HEART_5"] = "heart-5";
|
|
220
|
-
Assets2["HEART"] = "heart";
|
|
221
|
-
Assets2["HOUSE"] = "house";
|
|
222
|
-
Assets2["ID_CARD"] = "id-card";
|
|
223
|
-
Assets2["INFINITE"] = "infinite";
|
|
224
|
-
Assets2["INTEREST"] = "interest";
|
|
225
|
-
Assets2["INVITE_LETTER"] = "invite-letter";
|
|
226
|
-
Assets2["JARS"] = "jars";
|
|
227
|
-
Assets2["KEY"] = "key";
|
|
228
|
-
Assets2["LIGHT_BULB"] = "light-bulb";
|
|
229
|
-
Assets2["LOCK_PLATFORM"] = "lock-platform";
|
|
230
|
-
Assets2["LOCK"] = "lock";
|
|
231
|
-
Assets2["MAGNIFYING_GLASS"] = "magnifying-glass";
|
|
232
|
-
Assets2["MAP"] = "map";
|
|
190
|
+
Assets2["WALLET"] = "wallet";
|
|
191
|
+
Assets2["TWO_INVITE_LETTERS_OPENED"] = "two-invite-letters-opened";
|
|
192
|
+
Assets2["TOOL"] = "tool";
|
|
193
|
+
Assets2["TARGET_PLATFORM"] = "target-platform";
|
|
194
|
+
Assets2["STOPWATCH_PLATFORM"] = "stopwatch-platform";
|
|
195
|
+
Assets2["SPEECH_BUBBLE"] = "speech-bubble";
|
|
196
|
+
Assets2["SKIP_AUTHENTICATION"] = "skip-authentication";
|
|
197
|
+
Assets2["SHOPPING_BAG"] = "shopping-bag";
|
|
198
|
+
Assets2["SATELLITE_PLATFORM"] = "satellite-platform";
|
|
199
|
+
Assets2["SAND_TIMER"] = "sand-timer";
|
|
200
|
+
Assets2["REMINDER_LETTER"] = "reminder-letter";
|
|
201
|
+
Assets2["RECEIVE"] = "receive";
|
|
202
|
+
Assets2["QUESTION_MARK"] = "question-mark";
|
|
203
|
+
Assets2["PUZZLE_PIECES"] = "puzzle-pieces";
|
|
204
|
+
Assets2["PLANE_2"] = "plane-2";
|
|
205
|
+
Assets2["PLANE"] = "plane";
|
|
206
|
+
Assets2["PIE_CHART"] = "pie-chart";
|
|
207
|
+
Assets2["PHONES"] = "phones";
|
|
208
|
+
Assets2["PERSONAL_CARD"] = "personal-card";
|
|
209
|
+
Assets2["PERCENTAGE"] = "percentage";
|
|
210
|
+
Assets2["PALM_TREE"] = "palm-tree";
|
|
211
|
+
Assets2["ONE_INVITE_LETTER_OPENED"] = "one-invite-letter-opened";
|
|
212
|
+
Assets2["MULTI_CURRENCY"] = "multi-currency";
|
|
213
|
+
Assets2["MEGAPHONE"] = "megaphone";
|
|
233
214
|
Assets2["MARBLE_CARD_BUSINESS"] = "marble-card-business";
|
|
234
215
|
Assets2["MARBLE_CARD"] = "marble-card";
|
|
235
216
|
Assets2["MARBLE"] = "marble";
|
|
236
|
-
Assets2["
|
|
237
|
-
Assets2["
|
|
238
|
-
Assets2["
|
|
239
|
-
Assets2["
|
|
240
|
-
Assets2["
|
|
241
|
-
Assets2["
|
|
242
|
-
Assets2["
|
|
243
|
-
Assets2["
|
|
244
|
-
Assets2["
|
|
245
|
-
Assets2["
|
|
246
|
-
Assets2["
|
|
247
|
-
Assets2["
|
|
248
|
-
Assets2["
|
|
249
|
-
Assets2["
|
|
250
|
-
Assets2["
|
|
251
|
-
Assets2["
|
|
252
|
-
Assets2["
|
|
253
|
-
Assets2["
|
|
254
|
-
Assets2["
|
|
255
|
-
Assets2["
|
|
256
|
-
Assets2["
|
|
257
|
-
Assets2["
|
|
258
|
-
Assets2["
|
|
259
|
-
Assets2["
|
|
217
|
+
Assets2["MAP"] = "map";
|
|
218
|
+
Assets2["MAGNIFYING_GLASS"] = "magnifying-glass";
|
|
219
|
+
Assets2["LOCK_PLATFORM"] = "lock-platform";
|
|
220
|
+
Assets2["LOCK"] = "lock";
|
|
221
|
+
Assets2["LIGHT_BULB"] = "light-bulb";
|
|
222
|
+
Assets2["KEY"] = "key";
|
|
223
|
+
Assets2["JARS"] = "jars";
|
|
224
|
+
Assets2["INVITE_LETTER"] = "invite-letter";
|
|
225
|
+
Assets2["INTEREST"] = "interest";
|
|
226
|
+
Assets2["INFINITE"] = "infinite";
|
|
227
|
+
Assets2["ID_CARD"] = "id-card";
|
|
228
|
+
Assets2["HOUSE"] = "house";
|
|
229
|
+
Assets2["HEART_5"] = "heart-5";
|
|
230
|
+
Assets2["HEART_4"] = "heart-4";
|
|
231
|
+
Assets2["HEART_3"] = "heart-3";
|
|
232
|
+
Assets2["HEART_2"] = "heart-2";
|
|
233
|
+
Assets2["HEART"] = "heart";
|
|
234
|
+
Assets2["GRAPH"] = "graph";
|
|
235
|
+
Assets2["GLOBE"] = "globe";
|
|
236
|
+
Assets2["GEAR"] = "gear";
|
|
237
|
+
Assets2["FLOWER"] = "flower";
|
|
238
|
+
Assets2["FLAG"] = "flag";
|
|
239
|
+
Assets2["EXCLAMATION_MARK"] = "exclamation-mark";
|
|
240
|
+
Assets2["EMAIL_SUCCESS"] = "email-success";
|
|
241
|
+
Assets2["EMAIL"] = "email";
|
|
242
|
+
Assets2["ELECTRIC_PLUG"] = "electric-plug";
|
|
243
|
+
Assets2["ECO_CARD"] = "eco-card";
|
|
244
|
+
Assets2["DOOR"] = "door";
|
|
245
|
+
Assets2["DOCUMENTS"] = "documents";
|
|
246
|
+
Assets2["DIGITAL_CARD_2"] = "digital-card-2";
|
|
247
|
+
Assets2["DIGITAL_CARD"] = "digital-card";
|
|
248
|
+
Assets2["COOKIE"] = "cookie";
|
|
249
|
+
Assets2["CONVERT"] = "convert";
|
|
250
|
+
Assets2["CONSTRUCTION_FENCE"] = "construction-fence";
|
|
251
|
+
Assets2["CONFETTI"] = "confetti";
|
|
252
|
+
Assets2["COIN_PILE_UP"] = "coin-pile-up";
|
|
253
|
+
Assets2["COIN_PILE_DOWN"] = "coin-pile-down";
|
|
254
|
+
Assets2["CLOSED_WINDOW"] = "closed-window";
|
|
255
|
+
Assets2["CHECK_MARK"] = "check-mark";
|
|
256
|
+
Assets2["CALENDAR"] = "calendar";
|
|
257
|
+
Assets2["BUSINESS_CARD"] = "business-card";
|
|
258
|
+
Assets2["BRIEFCASE"] = "briefcase";
|
|
259
|
+
Assets2["BELL"] = "bell";
|
|
260
260
|
})(Assets || (Assets = {}));
|
|
261
261
|
(function(RenderMode2) {
|
|
262
262
|
RenderMode2[RenderMode2["INIT"] = 0] = "INIT";
|
|
@@ -1236,7 +1236,7 @@ var zh_CN_default = {
|
|
|
1236
1236
|
"dynamicFlows.ExternalConfirmation.open": "\u5728\u65B0\u6807\u7B7E\u9875\u4E2D\u6253\u5F00",
|
|
1237
1237
|
"dynamicFlows.ExternalConfirmation.title": "\u8BF7\u786E\u8BA4",
|
|
1238
1238
|
"dynamicFlows.FileUploadSchema.maxFileSizeError": "\u62B1\u6B49\uFF0C\u8BE5\u6587\u4EF6\u592A\u5927\u3002\u8BF7\u4E0A\u4F20\u4E00\u4E2A\u66F4\u5C0F\u7684\u6587\u4EF6\u3002",
|
|
1239
|
-
"dynamicFlows.FileUploadSchema.wrongFileTypeError": "
|
|
1239
|
+
"dynamicFlows.FileUploadSchema.wrongFileTypeError": "\u62B1\u6B49\uFF0C\u4E0D\u652F\u6301\u8BE5\u6587\u4EF6\u683C\u5F0F\u3002\u8BF7\u4E0A\u4F20\u5176\u4ED6\u6587\u4EF6\u3002",
|
|
1240
1240
|
"dynamicFlows.Help.ariaLabel": "\u70B9\u51FB\u6B64\u5904\u83B7\u53D6\u66F4\u591A\u4FE1\u606F\u3002",
|
|
1241
1241
|
"dynamicFlows.MultiSelect.summary": "{first} \u548C\u5176\u4ED6 {count} \u4E2A",
|
|
1242
1242
|
"dynamicFlows.MultipleFileUploadSchema.maxFileSizeError": "\u62B1\u6B49\uFF0C\u8BE5\u6587\u4EF6\u592A\u5927\u3002\u8BF7\u4E0A\u4F20\u4E00\u4E2A\u66F4\u5C0F\u7684\u6587\u4EF6\u3002",
|
|
@@ -1754,8 +1754,8 @@ var DateInputRenderer_default = DateInputRenderer;
|
|
|
1754
1754
|
// ../renderers/src/DecisionRenderer.tsx
|
|
1755
1755
|
import { NavigationOptionsList, NavigationOption, Header } from "@transferwise/components";
|
|
1756
1756
|
|
|
1757
|
-
// ../../node_modules/.pnpm/@wise+art@2.
|
|
1758
|
-
|
|
1757
|
+
// ../../node_modules/.pnpm/@wise+art@2.19.0_@transferwise+neptune-css@14.20.1_@types+react@18.3.18_react-dom@18.3.1_reac_mzw7cg6j4wc7ddwlhxck7linn4/node_modules/@wise/art/dist/index.esm.js
|
|
1758
|
+
init_index_8Fxev6OI_esm();
|
|
1759
1759
|
init_clsx();
|
|
1760
1760
|
import "react";
|
|
1761
1761
|
import "react/jsx-runtime";
|
|
@@ -11257,6 +11257,7 @@ var createUploadInputComponent = (uploadInputProps, updateComponent) => {
|
|
|
11257
11257
|
draft.persistedState.lastSubmitted = null;
|
|
11258
11258
|
draft.persistedState.submission = Promise.resolve(null);
|
|
11259
11259
|
draft.errors = [];
|
|
11260
|
+
draft.value = null;
|
|
11260
11261
|
});
|
|
11261
11262
|
throw error;
|
|
11262
11263
|
});
|
|
@@ -13120,6 +13121,83 @@ var mapStepToComponent = (_a) => {
|
|
|
13120
13121
|
return stepComponent;
|
|
13121
13122
|
};
|
|
13122
13123
|
|
|
13124
|
+
// src/revamp/flow/getResponseType.ts
|
|
13125
|
+
var responseTypes = ["step", "action", "exit"];
|
|
13126
|
+
var getResponseType = async (response) => {
|
|
13127
|
+
assertResponseIsValid(response);
|
|
13128
|
+
const headerResponseType = getResponseTypeFromHeader(response);
|
|
13129
|
+
if (headerResponseType) {
|
|
13130
|
+
return headerResponseType;
|
|
13131
|
+
}
|
|
13132
|
+
const jsonBody = await parseResponseBodyAsJsonElement(response.clone());
|
|
13133
|
+
if (isObject(jsonBody) && jsonBody.action) {
|
|
13134
|
+
return "action";
|
|
13135
|
+
}
|
|
13136
|
+
return "step";
|
|
13137
|
+
};
|
|
13138
|
+
var getResponseTypeFromHeader = (response) => {
|
|
13139
|
+
var _a, _b;
|
|
13140
|
+
if ((_a = response.headers) == null ? void 0 : _a.has("X-Df-Response-Type")) {
|
|
13141
|
+
const type = response.headers.get("X-Df-Response-Type");
|
|
13142
|
+
assertDFResponseType(type);
|
|
13143
|
+
return type;
|
|
13144
|
+
}
|
|
13145
|
+
if ((_b = response.headers) == null ? void 0 : _b.has("X-Df-Exit")) {
|
|
13146
|
+
return "exit";
|
|
13147
|
+
}
|
|
13148
|
+
return void 0;
|
|
13149
|
+
};
|
|
13150
|
+
function assertDFResponseType(type) {
|
|
13151
|
+
if (!responseTypes.includes(type)) {
|
|
13152
|
+
throw new Error(
|
|
13153
|
+
"Unsupported X-Df-Response-Type. Allowed values are 'step', 'action', 'exit', 'error'."
|
|
13154
|
+
);
|
|
13155
|
+
}
|
|
13156
|
+
}
|
|
13157
|
+
|
|
13158
|
+
// src/revamp/flow/executePoll.ts
|
|
13159
|
+
var executePoll = async (props) => {
|
|
13160
|
+
const { errorAction, signal, url, httpClient, trackEvent } = props;
|
|
13161
|
+
try {
|
|
13162
|
+
const response = await httpClient(url != null ? url : "", {
|
|
13163
|
+
method: "GET",
|
|
13164
|
+
signal
|
|
13165
|
+
});
|
|
13166
|
+
if (!response.ok) {
|
|
13167
|
+
trackEvent("Polling Failed", { url, statusCode: response.status, variant: "revamp" });
|
|
13168
|
+
return { type: "action", action: errorAction };
|
|
13169
|
+
}
|
|
13170
|
+
const responseType = getResponseTypeFromHeader(response);
|
|
13171
|
+
const body = await parseResponseBodyAsJsonElement(response);
|
|
13172
|
+
try {
|
|
13173
|
+
switch (responseType) {
|
|
13174
|
+
case "step": {
|
|
13175
|
+
const etag = response.headers.get("etag") || null;
|
|
13176
|
+
assertStepResponseBody(body);
|
|
13177
|
+
return { type: "replace-step", step: body, etag };
|
|
13178
|
+
}
|
|
13179
|
+
case "exit": {
|
|
13180
|
+
return { type: "complete", result: body };
|
|
13181
|
+
}
|
|
13182
|
+
case "action": {
|
|
13183
|
+
assertActionResponseBody(body);
|
|
13184
|
+
return { type: "action", action: body.action };
|
|
13185
|
+
}
|
|
13186
|
+
default: {
|
|
13187
|
+
if (isActionResponseBody(body)) {
|
|
13188
|
+
return { type: "action", action: body.action };
|
|
13189
|
+
}
|
|
13190
|
+
return { type: "continue" };
|
|
13191
|
+
}
|
|
13192
|
+
}
|
|
13193
|
+
} catch (error) {
|
|
13194
|
+
return { type: "action", action: errorAction };
|
|
13195
|
+
}
|
|
13196
|
+
} catch (error) {
|
|
13197
|
+
return { type: "continue" };
|
|
13198
|
+
}
|
|
13199
|
+
};
|
|
13200
|
+
|
|
13123
13201
|
// src/revamp/flow/executeRefresh.ts
|
|
13124
13202
|
var executeRefresh = async (props) => {
|
|
13125
13203
|
const { abortSignal, url, model, schemaId, etag, httpClient, trackEvent } = props;
|
|
@@ -13140,8 +13218,11 @@ var executeRefresh = async (props) => {
|
|
|
13140
13218
|
if (!response.ok) {
|
|
13141
13219
|
const responseBody = await parseResponseBodyAsJsonElement(response).catch(() => ({}));
|
|
13142
13220
|
const body2 = isErrorResponseBody(responseBody) ? responseBody : {};
|
|
13143
|
-
trackEvent("Refresh Failed", __spreadValues({
|
|
13144
|
-
|
|
13221
|
+
trackEvent("Refresh Failed", __spreadProps(__spreadValues({}, body2.analytics), {
|
|
13222
|
+
schema: schemaId,
|
|
13223
|
+
statusCode: response.status
|
|
13224
|
+
}));
|
|
13225
|
+
return { type: "error", body: body2, statusCode: response.status };
|
|
13145
13226
|
}
|
|
13146
13227
|
const newEtag = response.headers.get("etag") || null;
|
|
13147
13228
|
const body = await parseResponseBodyAsJsonElement(response);
|
|
@@ -13158,40 +13239,6 @@ var executeRefresh = async (props) => {
|
|
|
13158
13239
|
}
|
|
13159
13240
|
};
|
|
13160
13241
|
|
|
13161
|
-
// src/revamp/flow/getResponseType.ts
|
|
13162
|
-
var responseTypes = ["step", "action", "exit"];
|
|
13163
|
-
var getResponseType = async (response) => {
|
|
13164
|
-
assertResponseIsValid(response);
|
|
13165
|
-
const headerResponseType = getResponseTypeFromHeader(response);
|
|
13166
|
-
if (headerResponseType) {
|
|
13167
|
-
return headerResponseType;
|
|
13168
|
-
}
|
|
13169
|
-
const jsonBody = await parseResponseBodyAsJsonElement(response.clone());
|
|
13170
|
-
if (isObject(jsonBody) && jsonBody.action) {
|
|
13171
|
-
return "action";
|
|
13172
|
-
}
|
|
13173
|
-
return "step";
|
|
13174
|
-
};
|
|
13175
|
-
var getResponseTypeFromHeader = (response) => {
|
|
13176
|
-
var _a, _b;
|
|
13177
|
-
if ((_a = response.headers) == null ? void 0 : _a.has("X-Df-Response-Type")) {
|
|
13178
|
-
const type = response.headers.get("X-Df-Response-Type");
|
|
13179
|
-
assertDFResponseType(type);
|
|
13180
|
-
return type;
|
|
13181
|
-
}
|
|
13182
|
-
if ((_b = response.headers) == null ? void 0 : _b.has("X-Df-Exit")) {
|
|
13183
|
-
return "exit";
|
|
13184
|
-
}
|
|
13185
|
-
return void 0;
|
|
13186
|
-
};
|
|
13187
|
-
function assertDFResponseType(type) {
|
|
13188
|
-
if (!responseTypes.includes(type)) {
|
|
13189
|
-
throw new Error(
|
|
13190
|
-
"Unsupported X-Df-Response-Type. Allowed values are 'step', 'action', 'exit', 'error'."
|
|
13191
|
-
);
|
|
13192
|
-
}
|
|
13193
|
-
}
|
|
13194
|
-
|
|
13195
13242
|
// src/revamp/flow/executeSubmission.ts
|
|
13196
13243
|
var executeSubmission = async (props) => {
|
|
13197
13244
|
const { httpClient, trackEvent } = props;
|
|
@@ -13260,12 +13307,12 @@ var executeSubmission = async (props) => {
|
|
|
13260
13307
|
if (isErrorResponseBody(body)) {
|
|
13261
13308
|
const refreshUrl = body.refreshUrl || body.refreshFormUrl;
|
|
13262
13309
|
const { error, validation, analytics } = body;
|
|
13263
|
-
trackEvent("Action Failed", __spreadValues({
|
|
13310
|
+
trackEvent("Action Failed", __spreadProps(__spreadValues({}, analytics), { actionId, statusCode: response.status }));
|
|
13264
13311
|
const errors = { error, validation };
|
|
13265
|
-
return refreshUrl ? { type: "refresh", body: { refreshUrl, errors } } : { type: "error", body: { errors, analytics } };
|
|
13312
|
+
return refreshUrl ? { type: "refresh", body: { refreshUrl, errors } } : { type: "error", body: { errors, analytics }, statusCode: response.status };
|
|
13266
13313
|
}
|
|
13267
|
-
trackEvent("Action Failed", { actionId });
|
|
13268
|
-
return { type: "error", body: {} };
|
|
13314
|
+
trackEvent("Action Failed", { actionId, statusCode: response.status });
|
|
13315
|
+
return { type: "error", body: {}, statusCode: response.status };
|
|
13269
13316
|
};
|
|
13270
13317
|
return triggerAction(props.action, props.model, props.isInitial);
|
|
13271
13318
|
};
|
|
@@ -13507,48 +13554,6 @@ function useStableCallback(handler) {
|
|
|
13507
13554
|
return useCallback((...args) => ref.current ? ref.current(...args) : null, []);
|
|
13508
13555
|
}
|
|
13509
13556
|
|
|
13510
|
-
// src/revamp/flow/executePoll.ts
|
|
13511
|
-
var executePoll = async (props) => {
|
|
13512
|
-
const { errorAction, signal, url, httpClient } = props;
|
|
13513
|
-
try {
|
|
13514
|
-
const response = await httpClient(url != null ? url : "", {
|
|
13515
|
-
method: "GET",
|
|
13516
|
-
signal
|
|
13517
|
-
});
|
|
13518
|
-
if (!response.ok) {
|
|
13519
|
-
return { type: "action", action: errorAction };
|
|
13520
|
-
}
|
|
13521
|
-
const responseType = getResponseTypeFromHeader(response);
|
|
13522
|
-
const body = await parseResponseBodyAsJsonElement(response);
|
|
13523
|
-
try {
|
|
13524
|
-
switch (responseType) {
|
|
13525
|
-
case "step": {
|
|
13526
|
-
const etag = response.headers.get("etag") || null;
|
|
13527
|
-
assertStepResponseBody(body);
|
|
13528
|
-
return { type: "replace-step", step: body, etag };
|
|
13529
|
-
}
|
|
13530
|
-
case "exit": {
|
|
13531
|
-
return { type: "complete", result: body };
|
|
13532
|
-
}
|
|
13533
|
-
case "action": {
|
|
13534
|
-
assertActionResponseBody(body);
|
|
13535
|
-
return { type: "action", action: body.action };
|
|
13536
|
-
}
|
|
13537
|
-
default: {
|
|
13538
|
-
if (isActionResponseBody(body)) {
|
|
13539
|
-
return { type: "action", action: body.action };
|
|
13540
|
-
}
|
|
13541
|
-
return { type: "continue" };
|
|
13542
|
-
}
|
|
13543
|
-
}
|
|
13544
|
-
} catch (error) {
|
|
13545
|
-
return { type: "action", action: errorAction };
|
|
13546
|
-
}
|
|
13547
|
-
} catch (error) {
|
|
13548
|
-
return { type: "continue" };
|
|
13549
|
-
}
|
|
13550
|
-
};
|
|
13551
|
-
|
|
13552
13557
|
// src/revamp/useDynamicFlowCore.tsx
|
|
13553
13558
|
function useDynamicFlowCore(props) {
|
|
13554
13559
|
const _a = props, { flowId, initialAction, initialStep, displayStepTitle = true } = _a, rest = __objRest(_a, ["flowId", "initialAction", "initialStep", "displayStepTitle"]);
|
|
@@ -13665,9 +13670,9 @@ function useDynamicFlowCore(props) {
|
|
|
13665
13670
|
[]
|
|
13666
13671
|
);
|
|
13667
13672
|
const closeWithError = useCallback2(
|
|
13668
|
-
(error, analytics) => {
|
|
13673
|
+
(error, analytics, statusCode) => {
|
|
13669
13674
|
trackCoreEvent("Failed", __spreadValues({}, analytics));
|
|
13670
|
-
onError(error);
|
|
13675
|
+
onError(error, statusCode);
|
|
13671
13676
|
},
|
|
13672
13677
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
13673
13678
|
[]
|
|
@@ -13700,9 +13705,22 @@ function useDynamicFlowCore(props) {
|
|
|
13700
13705
|
const genericErrorMessage = getErrorMessageFunctions().genericErrorWithRetry();
|
|
13701
13706
|
const { errors = { error: genericErrorMessage } } = command.body;
|
|
13702
13707
|
if (stepRef.current) {
|
|
13703
|
-
initialiseWithStep(
|
|
13708
|
+
initialiseWithStep(
|
|
13709
|
+
__spreadProps(__spreadValues({}, stepRef.current), {
|
|
13710
|
+
// the existing step
|
|
13711
|
+
errors,
|
|
13712
|
+
// but with the new errors
|
|
13713
|
+
model,
|
|
13714
|
+
// and the model that was submitted
|
|
13715
|
+
polling: void 0,
|
|
13716
|
+
// and no polling, to avoid restarting it
|
|
13717
|
+
external: void 0
|
|
13718
|
+
// and no external, to avoid retriggering it
|
|
13719
|
+
}),
|
|
13720
|
+
etagRef.current
|
|
13721
|
+
);
|
|
13704
13722
|
} else {
|
|
13705
|
-
closeWithError(new Error("Initial request failed"), {});
|
|
13723
|
+
closeWithError(new Error("Initial request failed"), {}, command.statusCode);
|
|
13706
13724
|
}
|
|
13707
13725
|
break;
|
|
13708
13726
|
}
|
|
@@ -13739,7 +13757,11 @@ function useDynamicFlowCore(props) {
|
|
|
13739
13757
|
}
|
|
13740
13758
|
break;
|
|
13741
13759
|
case "error": {
|
|
13742
|
-
closeWithError(
|
|
13760
|
+
closeWithError(
|
|
13761
|
+
new Error("Failed to refresh"),
|
|
13762
|
+
command.body.analytics,
|
|
13763
|
+
command.statusCode
|
|
13764
|
+
);
|
|
13743
13765
|
break;
|
|
13744
13766
|
}
|
|
13745
13767
|
case "noop":
|
|
@@ -13759,7 +13781,8 @@ function useDynamicFlowCore(props) {
|
|
|
13759
13781
|
httpClient,
|
|
13760
13782
|
url,
|
|
13761
13783
|
errorAction,
|
|
13762
|
-
signal
|
|
13784
|
+
signal,
|
|
13785
|
+
trackEvent: trackCoreEvent
|
|
13763
13786
|
});
|
|
13764
13787
|
switch (command.type) {
|
|
13765
13788
|
case "replace-step":
|
|
@@ -19467,12 +19490,18 @@ import { useCallback as useCallback8, useMemo as useMemo19 } from "react";
|
|
|
19467
19490
|
function useStepPolling(polling, onAction) {
|
|
19468
19491
|
var _a, _b;
|
|
19469
19492
|
const httpClient = useHttpClient();
|
|
19493
|
+
const onEvent = useEventDispatcher();
|
|
19470
19494
|
const asyncFn = useMemo19(() => {
|
|
19471
19495
|
if (polling) {
|
|
19472
19496
|
return () => httpClient(polling.url).then((response) => {
|
|
19473
19497
|
if (response.ok) {
|
|
19474
|
-
return response.json().then((pollingResponse) => pollingResponse).catch((
|
|
19498
|
+
return response.json().then((pollingResponse) => pollingResponse).catch(() => null);
|
|
19475
19499
|
}
|
|
19500
|
+
onEvent("Dynamic Flow - Polling Failed", {
|
|
19501
|
+
url: polling.url,
|
|
19502
|
+
statusCode: response.status,
|
|
19503
|
+
variant: "legacy"
|
|
19504
|
+
});
|
|
19476
19505
|
throw new Error("failed");
|
|
19477
19506
|
}).catch((error) => {
|
|
19478
19507
|
throw new Error(error.message === "failed" ? "failed" : "network failed");
|
|
@@ -20795,13 +20824,13 @@ var DynamicFlowComponent = ({
|
|
|
20795
20824
|
}
|
|
20796
20825
|
setLoadingState("idle");
|
|
20797
20826
|
};
|
|
20798
|
-
const completeWithError = (error, message, fetchType,
|
|
20827
|
+
const completeWithError = (error, message, fetchType, statusCode) => {
|
|
20799
20828
|
logCritical("Error fetching", message);
|
|
20800
20829
|
if (fetchType === "refresh") {
|
|
20801
20830
|
dispatchEvent("Dynamic Flow - Step Refreshed", { status: "failure" });
|
|
20802
20831
|
}
|
|
20803
20832
|
dispatchEvent("Dynamic Flow - Flow Finished", { status: "failure" });
|
|
20804
|
-
onError(error,
|
|
20833
|
+
onError(error, statusCode);
|
|
20805
20834
|
setLoadingState("idle");
|
|
20806
20835
|
};
|
|
20807
20836
|
const onModelChange = (onModelChangeProps) => {
|
|
@@ -11,7 +11,7 @@ export type DynamicFlowPropsWithInitialStep = DynamicFlowPropsBasic & {
|
|
|
11
11
|
};
|
|
12
12
|
export type HttpClient = typeof fetch;
|
|
13
13
|
export type EventHandler = (eventName: EventName, properties: Record<string, unknown>) => void;
|
|
14
|
-
export type EventName = 'Dynamic Flow - Flow Started' | 'Dynamic Flow - Flow Finished' | 'Dynamic Flow - Step Started' | 'Dynamic Flow - Step Submitted' | 'Dynamic Flow - Step Refreshed' | 'Dynamic Flow - OneOf Selected' | 'Dynamic Flow - PersistAsync' | 'Dynamic Flow - ValidationAsync' | 'Dynamic Flow - Search Started' | 'Dynamic Flow - Search Result Selected' | 'Dynamic Flow - invalid submission response' | 'Dynamic Flow - onAction supressed' | 'Dynamic Flow - OneOf Searched' | CameraEventName;
|
|
14
|
+
export type EventName = 'Dynamic Flow - Flow Started' | 'Dynamic Flow - Flow Finished' | 'Dynamic Flow - Step Started' | 'Dynamic Flow - Step Submitted' | 'Dynamic Flow - Step Refreshed' | 'Dynamic Flow - OneOf Selected' | 'Dynamic Flow - PersistAsync' | 'Dynamic Flow - Polling Failed' | 'Dynamic Flow - ValidationAsync' | 'Dynamic Flow - Search Started' | 'Dynamic Flow - Search Result Selected' | 'Dynamic Flow - invalid submission response' | 'Dynamic Flow - onAction supressed' | 'Dynamic Flow - OneOf Searched' | CameraEventName;
|
|
15
15
|
export type LogLevel = 'debug' | 'info' | 'warning' | 'error' | 'critical';
|
|
16
16
|
export type LogEventHandler = (level: LogLevel, message: string, extra: Record<string, unknown>) => void;
|
|
17
17
|
export type Feature = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type AnalyticsEventHandler = (eventName: string, properties?: Record<string, unknown>) => void;
|
|
2
2
|
export type AnalyticsEventDispatcher<E extends string = EventName> = (eventName: E, properties?: Record<string, unknown>) => void;
|
|
3
|
-
export type EventName = 'Initiated' | 'Succeeded' | 'Failed' | 'Step Shown' | 'Action Triggered' | 'Action Succeeded' | 'Action Aborted' | 'Action Failed' | 'Refresh Triggered' | 'Refresh Succeeded' | 'Refresh Aborted' | 'Refresh Failed' | 'OneOf Selected' | 'PersistAsync Triggered' | 'PersistAsync Succeeded' | 'PersistAsync Failed' | 'ValidationAsync Triggered' | 'ValidationAsync Succeeded' | 'ValidationAsync Failed' | 'Value Changed';
|
|
3
|
+
export type EventName = 'Initiated' | 'Succeeded' | 'Failed' | 'Step Shown' | 'Action Triggered' | 'Action Succeeded' | 'Action Aborted' | 'Action Failed' | 'Refresh Triggered' | 'Refresh Succeeded' | 'Refresh Aborted' | 'Refresh Failed' | 'OneOf Selected' | 'PersistAsync Triggered' | 'PersistAsync Succeeded' | 'PersistAsync Failed' | 'Polling Failed' | 'ValidationAsync Triggered' | 'ValidationAsync Succeeded' | 'ValidationAsync Failed' | 'Value Changed';
|
|
4
4
|
export type LogLevel = 'info' | 'warning' | 'error';
|
|
5
5
|
export type LoggingEventHandler = (level: LogLevel, message: string, extra: Record<string, unknown>) => void;
|
|
6
6
|
export type LoggingEventDispatcher = (level: LogLevel, message: string, extra?: Record<string, unknown>) => void;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Action, Model, Step } from '@wise/dynamic-flow-types/build/next';
|
|
2
|
+
import { AnalyticsEventDispatcher } from '../domain/features/events';
|
|
2
3
|
type Command = {
|
|
3
4
|
type: 'complete';
|
|
4
5
|
result: Model;
|
|
@@ -17,5 +18,6 @@ export declare const executePoll: (props: {
|
|
|
17
18
|
url: string;
|
|
18
19
|
errorAction: Action;
|
|
19
20
|
signal: AbortSignal;
|
|
21
|
+
trackEvent: AnalyticsEventDispatcher;
|
|
20
22
|
}) => Promise<Command>;
|
|
21
23
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wise/dynamic-flow-client",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.29.1",
|
|
4
4
|
"description": "Dynamic Flow web client",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./build/main.min.js",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@babel/preset-env": "7.26.0",
|
|
37
37
|
"@babel/preset-react": "7.26.3",
|
|
38
38
|
"@babel/preset-typescript": "7.26.0",
|
|
39
|
-
"@chromatic-com/storybook": "3.2.
|
|
39
|
+
"@chromatic-com/storybook": "3.2.3",
|
|
40
40
|
"@formatjs/cli": "^6.3.14",
|
|
41
41
|
"@storybook/addon-a11y": "^8.4.7",
|
|
42
42
|
"@storybook/addon-actions": "^8.4.7",
|
|
@@ -53,16 +53,16 @@
|
|
|
53
53
|
"@testing-library/jest-dom": "6.6.3",
|
|
54
54
|
"@testing-library/react": "16.1.0",
|
|
55
55
|
"@testing-library/user-event": "14.5.2",
|
|
56
|
-
"@transferwise/components": "46.84.
|
|
56
|
+
"@transferwise/components": "46.84.1",
|
|
57
57
|
"@transferwise/formatting": "^2.13.0",
|
|
58
|
-
"@transferwise/icons": "3.
|
|
58
|
+
"@transferwise/icons": "3.18.0",
|
|
59
59
|
"@transferwise/neptune-css": "14.20.1",
|
|
60
60
|
"@types/node": "22.10.2",
|
|
61
61
|
"@types/jest": "29.5.14",
|
|
62
|
-
"@types/react": "18.3.
|
|
62
|
+
"@types/react": "18.3.18",
|
|
63
63
|
"@types/react-dom": "18.3.5",
|
|
64
64
|
"@types/react-intl": "3.0.0",
|
|
65
|
-
"@wise/art": "2.
|
|
65
|
+
"@wise/art": "2.19.0",
|
|
66
66
|
"@wise/components-theming": "^1.6.1",
|
|
67
67
|
"babel-jest": "29.7.0",
|
|
68
68
|
"esbuild": "0.24.0",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"jest-environment-jsdom": "29.7.0",
|
|
71
71
|
"jest-fetch-mock": "^3.0.3",
|
|
72
72
|
"jest-watch-typeahead": "^2.2.2",
|
|
73
|
-
"npm-run-all2": "7.0.
|
|
73
|
+
"npm-run-all2": "7.0.2",
|
|
74
74
|
"postcss": "^8.4.49",
|
|
75
75
|
"postcss-cli": "^11.0.0",
|
|
76
76
|
"postcss-import": "^15.1.0",
|