@wise/dynamic-flow-client 4.0.4 → 4.1.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/build/main.js
CHANGED
|
@@ -6468,7 +6468,7 @@ var getInputUpdateFunction = (uid, updateComponent) => (updateFn) => {
|
|
|
6468
6468
|
|
|
6469
6469
|
// src/revamp/domain/components/StepDomainComponent.ts
|
|
6470
6470
|
var createStepComponent = (stepProps) => {
|
|
6471
|
-
const _a = stepProps, { uid, stepPolling, updateComponent } = _a, rest = __objRest(_a, ["uid", "stepPolling", "updateComponent"]);
|
|
6471
|
+
const _a = stepProps, { uid, stepPolling, stepRefreshAfter, updateComponent } = _a, rest = __objRest(_a, ["uid", "stepPolling", "stepRefreshAfter", "updateComponent"]);
|
|
6472
6472
|
const update = getInputUpdateFunction(uid, updateComponent);
|
|
6473
6473
|
return __spreadProps(__spreadValues({
|
|
6474
6474
|
uid
|
|
@@ -6499,6 +6499,7 @@ var createStepComponent = (stepProps) => {
|
|
|
6499
6499
|
},
|
|
6500
6500
|
stop() {
|
|
6501
6501
|
stepPolling == null ? void 0 : stepPolling.stop();
|
|
6502
|
+
stepRefreshAfter == null ? void 0 : stepRefreshAfter.stop();
|
|
6502
6503
|
}
|
|
6503
6504
|
});
|
|
6504
6505
|
};
|
|
@@ -10471,6 +10472,22 @@ var getUnreferencedSchemas = (step) => {
|
|
|
10471
10472
|
);
|
|
10472
10473
|
};
|
|
10473
10474
|
|
|
10475
|
+
// src/revamp/domain/features/refreshAfter/getStepRefreshAfter.ts
|
|
10476
|
+
var ONE_SECOND = 1e3;
|
|
10477
|
+
var getStepRefreshAfter = ({ refreshAfter, onRefresh }) => {
|
|
10478
|
+
const targetTime = new Date(refreshAfter).getTime();
|
|
10479
|
+
if (typeof refreshAfter !== "string" || Number.isNaN(targetTime)) {
|
|
10480
|
+
throw new Error(`Invalid refreshAfter value: ${String(refreshAfter)}`);
|
|
10481
|
+
}
|
|
10482
|
+
const timeLeft = Math.max(targetTime - Date.now(), ONE_SECOND);
|
|
10483
|
+
const timeout = setTimeout(() => {
|
|
10484
|
+
void onRefresh("refreshAfter");
|
|
10485
|
+
}, timeLeft);
|
|
10486
|
+
return {
|
|
10487
|
+
stop: () => clearTimeout(timeout)
|
|
10488
|
+
};
|
|
10489
|
+
};
|
|
10490
|
+
|
|
10474
10491
|
// src/revamp/domain/mappers/mapStepToComponent.ts
|
|
10475
10492
|
var mapStepToComponent = (_a) => {
|
|
10476
10493
|
var _b = _a, {
|
|
@@ -10498,6 +10515,7 @@ var mapStepToComponent = (_a) => {
|
|
|
10498
10515
|
layout = [],
|
|
10499
10516
|
navigation,
|
|
10500
10517
|
polling,
|
|
10518
|
+
refreshAfter,
|
|
10501
10519
|
title
|
|
10502
10520
|
} = step;
|
|
10503
10521
|
const backNavigation = (_a2 = navigation == null ? void 0 : navigation.back) != null ? _a2 : navigation == null ? void 0 : navigation.backButton;
|
|
@@ -10529,6 +10547,7 @@ var mapStepToComponent = (_a) => {
|
|
|
10529
10547
|
};
|
|
10530
10548
|
const onRefresh = async (schemaId, url) => restProps.onRefresh(schemaId, url != null ? url : refreshUrl);
|
|
10531
10549
|
const stepPolling = polling ? getStepPolling({ pollingConfig: polling, onAction: restProps.onAction, onPoll }) : void 0;
|
|
10550
|
+
const stepRefreshAfter = refreshAfter ? getStepRefreshAfter({ refreshAfter, onRefresh }) : void 0;
|
|
10532
10551
|
const mapperProps = __spreadProps(__spreadValues({}, restProps), { trackEvent, onAction, onRefresh });
|
|
10533
10552
|
const unreferencedSchemaFormComponents = mapUnreferencedSchemas(mapperProps);
|
|
10534
10553
|
const layoutComponents = layout.map(
|
|
@@ -10545,6 +10564,7 @@ var mapStepToComponent = (_a) => {
|
|
|
10545
10564
|
external,
|
|
10546
10565
|
loadingState,
|
|
10547
10566
|
stepPolling,
|
|
10567
|
+
stepRefreshAfter,
|
|
10548
10568
|
title: displayStepTitle ? title : void 0,
|
|
10549
10569
|
step,
|
|
10550
10570
|
updateComponent,
|
|
@@ -14875,10 +14895,9 @@ var getSafeStringValue = (value, options = {}) => {
|
|
|
14875
14895
|
if (coerceValue) {
|
|
14876
14896
|
logInvalidTypeCoercedWarning({ received: typeof value, expected: "string" });
|
|
14877
14897
|
return String(value);
|
|
14878
|
-
} else {
|
|
14879
|
-
logInvalidTypeFallbackWarning({ received: typeof value, expected: "string" });
|
|
14880
|
-
return void 0;
|
|
14881
14898
|
}
|
|
14899
|
+
logInvalidTypeFallbackWarning({ received: typeof value, expected: "string" });
|
|
14900
|
+
return void 0;
|
|
14882
14901
|
}
|
|
14883
14902
|
return value;
|
|
14884
14903
|
};
|
|
@@ -14899,10 +14918,9 @@ var getSafeStringOrNumberValue = (value, options = {}) => {
|
|
|
14899
14918
|
if (coerceValue) {
|
|
14900
14919
|
logInvalidTypeCoercedWarning(logProps);
|
|
14901
14920
|
return String(value);
|
|
14902
|
-
} else {
|
|
14903
|
-
logInvalidTypeFallbackWarning(logProps);
|
|
14904
|
-
return void 0;
|
|
14905
14921
|
}
|
|
14922
|
+
logInvalidTypeFallbackWarning(logProps);
|
|
14923
|
+
return void 0;
|
|
14906
14924
|
}
|
|
14907
14925
|
return value;
|
|
14908
14926
|
};
|
|
@@ -14915,10 +14933,9 @@ var getSafeBooleanValue = (value, options = {}) => {
|
|
|
14915
14933
|
if (coerceValue) {
|
|
14916
14934
|
logInvalidTypeCoercedWarning({ received: typeof value, expected: "boolean" });
|
|
14917
14935
|
return Boolean(value);
|
|
14918
|
-
} else {
|
|
14919
|
-
logInvalidTypeFallbackWarning({ received: typeof value, expected: "boolean" });
|
|
14920
|
-
return void 0;
|
|
14921
14936
|
}
|
|
14937
|
+
logInvalidTypeFallbackWarning({ received: typeof value, expected: "boolean" });
|
|
14938
|
+
return void 0;
|
|
14922
14939
|
}
|
|
14923
14940
|
return value;
|
|
14924
14941
|
};
|
package/build/main.mjs
CHANGED
|
@@ -6445,7 +6445,7 @@ var getInputUpdateFunction = (uid, updateComponent) => (updateFn) => {
|
|
|
6445
6445
|
|
|
6446
6446
|
// src/revamp/domain/components/StepDomainComponent.ts
|
|
6447
6447
|
var createStepComponent = (stepProps) => {
|
|
6448
|
-
const _a = stepProps, { uid, stepPolling, updateComponent } = _a, rest = __objRest(_a, ["uid", "stepPolling", "updateComponent"]);
|
|
6448
|
+
const _a = stepProps, { uid, stepPolling, stepRefreshAfter, updateComponent } = _a, rest = __objRest(_a, ["uid", "stepPolling", "stepRefreshAfter", "updateComponent"]);
|
|
6449
6449
|
const update = getInputUpdateFunction(uid, updateComponent);
|
|
6450
6450
|
return __spreadProps(__spreadValues({
|
|
6451
6451
|
uid
|
|
@@ -6476,6 +6476,7 @@ var createStepComponent = (stepProps) => {
|
|
|
6476
6476
|
},
|
|
6477
6477
|
stop() {
|
|
6478
6478
|
stepPolling == null ? void 0 : stepPolling.stop();
|
|
6479
|
+
stepRefreshAfter == null ? void 0 : stepRefreshAfter.stop();
|
|
6479
6480
|
}
|
|
6480
6481
|
});
|
|
6481
6482
|
};
|
|
@@ -10448,6 +10449,22 @@ var getUnreferencedSchemas = (step) => {
|
|
|
10448
10449
|
);
|
|
10449
10450
|
};
|
|
10450
10451
|
|
|
10452
|
+
// src/revamp/domain/features/refreshAfter/getStepRefreshAfter.ts
|
|
10453
|
+
var ONE_SECOND = 1e3;
|
|
10454
|
+
var getStepRefreshAfter = ({ refreshAfter, onRefresh }) => {
|
|
10455
|
+
const targetTime = new Date(refreshAfter).getTime();
|
|
10456
|
+
if (typeof refreshAfter !== "string" || Number.isNaN(targetTime)) {
|
|
10457
|
+
throw new Error(`Invalid refreshAfter value: ${String(refreshAfter)}`);
|
|
10458
|
+
}
|
|
10459
|
+
const timeLeft = Math.max(targetTime - Date.now(), ONE_SECOND);
|
|
10460
|
+
const timeout = setTimeout(() => {
|
|
10461
|
+
void onRefresh("refreshAfter");
|
|
10462
|
+
}, timeLeft);
|
|
10463
|
+
return {
|
|
10464
|
+
stop: () => clearTimeout(timeout)
|
|
10465
|
+
};
|
|
10466
|
+
};
|
|
10467
|
+
|
|
10451
10468
|
// src/revamp/domain/mappers/mapStepToComponent.ts
|
|
10452
10469
|
var mapStepToComponent = (_a) => {
|
|
10453
10470
|
var _b = _a, {
|
|
@@ -10475,6 +10492,7 @@ var mapStepToComponent = (_a) => {
|
|
|
10475
10492
|
layout = [],
|
|
10476
10493
|
navigation,
|
|
10477
10494
|
polling,
|
|
10495
|
+
refreshAfter,
|
|
10478
10496
|
title
|
|
10479
10497
|
} = step;
|
|
10480
10498
|
const backNavigation = (_a2 = navigation == null ? void 0 : navigation.back) != null ? _a2 : navigation == null ? void 0 : navigation.backButton;
|
|
@@ -10506,6 +10524,7 @@ var mapStepToComponent = (_a) => {
|
|
|
10506
10524
|
};
|
|
10507
10525
|
const onRefresh = async (schemaId, url) => restProps.onRefresh(schemaId, url != null ? url : refreshUrl);
|
|
10508
10526
|
const stepPolling = polling ? getStepPolling({ pollingConfig: polling, onAction: restProps.onAction, onPoll }) : void 0;
|
|
10527
|
+
const stepRefreshAfter = refreshAfter ? getStepRefreshAfter({ refreshAfter, onRefresh }) : void 0;
|
|
10509
10528
|
const mapperProps = __spreadProps(__spreadValues({}, restProps), { trackEvent, onAction, onRefresh });
|
|
10510
10529
|
const unreferencedSchemaFormComponents = mapUnreferencedSchemas(mapperProps);
|
|
10511
10530
|
const layoutComponents = layout.map(
|
|
@@ -10522,6 +10541,7 @@ var mapStepToComponent = (_a) => {
|
|
|
10522
10541
|
external,
|
|
10523
10542
|
loadingState,
|
|
10524
10543
|
stepPolling,
|
|
10544
|
+
stepRefreshAfter,
|
|
10525
10545
|
title: displayStepTitle ? title : void 0,
|
|
10526
10546
|
step,
|
|
10527
10547
|
updateComponent,
|
|
@@ -14867,10 +14887,9 @@ var getSafeStringValue = (value, options = {}) => {
|
|
|
14867
14887
|
if (coerceValue) {
|
|
14868
14888
|
logInvalidTypeCoercedWarning({ received: typeof value, expected: "string" });
|
|
14869
14889
|
return String(value);
|
|
14870
|
-
} else {
|
|
14871
|
-
logInvalidTypeFallbackWarning({ received: typeof value, expected: "string" });
|
|
14872
|
-
return void 0;
|
|
14873
14890
|
}
|
|
14891
|
+
logInvalidTypeFallbackWarning({ received: typeof value, expected: "string" });
|
|
14892
|
+
return void 0;
|
|
14874
14893
|
}
|
|
14875
14894
|
return value;
|
|
14876
14895
|
};
|
|
@@ -14891,10 +14910,9 @@ var getSafeStringOrNumberValue = (value, options = {}) => {
|
|
|
14891
14910
|
if (coerceValue) {
|
|
14892
14911
|
logInvalidTypeCoercedWarning(logProps);
|
|
14893
14912
|
return String(value);
|
|
14894
|
-
} else {
|
|
14895
|
-
logInvalidTypeFallbackWarning(logProps);
|
|
14896
|
-
return void 0;
|
|
14897
14913
|
}
|
|
14914
|
+
logInvalidTypeFallbackWarning(logProps);
|
|
14915
|
+
return void 0;
|
|
14898
14916
|
}
|
|
14899
14917
|
return value;
|
|
14900
14918
|
};
|
|
@@ -14907,10 +14925,9 @@ var getSafeBooleanValue = (value, options = {}) => {
|
|
|
14907
14925
|
if (coerceValue) {
|
|
14908
14926
|
logInvalidTypeCoercedWarning({ received: typeof value, expected: "boolean" });
|
|
14909
14927
|
return Boolean(value);
|
|
14910
|
-
} else {
|
|
14911
|
-
logInvalidTypeFallbackWarning({ received: typeof value, expected: "boolean" });
|
|
14912
|
-
return void 0;
|
|
14913
14928
|
}
|
|
14929
|
+
logInvalidTypeFallbackWarning({ received: typeof value, expected: "boolean" });
|
|
14930
|
+
return void 0;
|
|
14914
14931
|
}
|
|
14915
14932
|
return value;
|
|
14916
14933
|
};
|
|
@@ -2,6 +2,7 @@ import type { BaseComponent, DomainComponent, LoadingState, LocalValue, OnAction
|
|
|
2
2
|
import type { Step } from '@wise/dynamic-flow-types/build/next';
|
|
3
3
|
import type { AnalyticsEventDispatcher } from '../features/events';
|
|
4
4
|
import type { StepPolling } from '../features/polling/getStepPolling';
|
|
5
|
+
import { StepRefreshAfter } from '../features/refreshAfter/getStepRefreshAfter';
|
|
5
6
|
export type StepDomainComponent = BaseComponent & {
|
|
6
7
|
type: 'step';
|
|
7
8
|
back?: BackNavigation;
|
|
@@ -26,6 +27,7 @@ type BackNavigation = {
|
|
|
26
27
|
};
|
|
27
28
|
export declare const createStepComponent: (stepProps: Pick<StepDomainComponent, "uid" | "back" | "components" | "control" | "description" | "error" | "external" | "loadingState" | "step" | "title" | "trackEvent" | "onAction"> & {
|
|
28
29
|
stepPolling?: StepPolling;
|
|
30
|
+
stepRefreshAfter?: StepRefreshAfter;
|
|
29
31
|
updateComponent: UpdateComponent;
|
|
30
32
|
}) => StepDomainComponent;
|
|
31
33
|
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { OnRefresh } from '../../types';
|
|
2
|
+
export type StepRefreshAfter = {
|
|
3
|
+
stop: () => void;
|
|
4
|
+
};
|
|
5
|
+
type Props = {
|
|
6
|
+
refreshAfter: string;
|
|
7
|
+
onRefresh: OnRefresh;
|
|
8
|
+
};
|
|
9
|
+
export declare const getStepRefreshAfter: ({ refreshAfter, onRefresh }: Props) => StepRefreshAfter;
|
|
10
|
+
export {};
|