@wise/dynamic-flow-client 3.18.1 → 3.19.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.mjs CHANGED
@@ -1598,6 +1598,8 @@ var instructionsComponentToProps = ({
1598
1598
 
1599
1599
  // src/revamp/renderers/mappers/integerInputComponentToProps.ts
1600
1600
  var integerInputComponentToProps = (component) => __spreadProps(__spreadValues({}, inputComponentToProps(component, "input-integer")), {
1601
+ maximum: component.maximum,
1602
+ minimum: component.minimum,
1601
1603
  onChange: component.onChange.bind(component)
1602
1604
  });
1603
1605
 
@@ -1661,6 +1663,8 @@ var multiUploadInputComponentToProps = (component) => {
1661
1663
 
1662
1664
  // src/revamp/renderers/mappers/numberInputComponentToProps.ts
1663
1665
  var numberInputComponentToProps = (component) => __spreadProps(__spreadValues({}, inputComponentToProps(component, "input-number")), {
1666
+ maximum: component.maximum,
1667
+ minimum: component.minimum,
1664
1668
  onChange: component.onChange.bind(component)
1665
1669
  });
1666
1670
 
@@ -1697,6 +1701,8 @@ var repeatableComponentToProps = (component, children, editableItemChildren) =>
1697
1701
  description,
1698
1702
  editItemTitle,
1699
1703
  errors,
1704
+ maxItems,
1705
+ minItems,
1700
1706
  summaryDefaults,
1701
1707
  title = "",
1702
1708
  onEdit,
@@ -1719,13 +1725,15 @@ var repeatableComponentToProps = (component, children, editableItemChildren) =>
1719
1725
  return {
1720
1726
  type: "repeatable",
1721
1727
  children,
1728
+ addItemTitle,
1722
1729
  control,
1723
- items: itemProps,
1724
- editableItem: editableItemChildren,
1725
- title,
1726
1730
  description,
1727
- addItemTitle,
1731
+ editableItem: editableItemChildren,
1728
1732
  editItemTitle,
1733
+ items: itemProps,
1734
+ maxItems,
1735
+ minItems,
1736
+ title,
1729
1737
  error: errors[0],
1730
1738
  onAdd: onAdd.bind(component),
1731
1739
  onEdit: onEdit.bind(component),
@@ -1834,14 +1842,18 @@ var statusListComponentToProps = ({
1834
1842
  // src/revamp/renderers/mappers/textInputComponentToProps.ts
1835
1843
  var textInputComponentToProps = (component) => __spreadProps(__spreadValues({}, inputComponentToProps(component, "input-text")), {
1836
1844
  displayFormat: component.displayFormat,
1845
+ maxLength: component.maxLength,
1846
+ minLength: component.minLength,
1837
1847
  onChange: component.onChange.bind(component)
1838
1848
  });
1839
1849
 
1840
1850
  // src/revamp/renderers/mappers/multiSelectComponentToProps.ts
1841
1851
  var multiSelectInputComponentToProps = (component) => {
1842
- const { options, selectedIndices, onSelect } = component;
1843
- const _a = inputComponentToProps(component, "input-multi-select"), { value } = _a, props = __objRest(_a, ["value"]);
1852
+ const { maxItems, minItems, options, selectedIndices, onSelect } = component;
1853
+ const _a = inputComponentToProps(component, "input-multi-select"), { required, value } = _a, props = __objRest(_a, ["required", "value"]);
1844
1854
  return __spreadProps(__spreadValues({}, props), {
1855
+ maxItems,
1856
+ minItems,
1845
1857
  options,
1846
1858
  selectedIndices,
1847
1859
  onSelect: onSelect.bind(component)
@@ -6784,84 +6796,34 @@ var createStepComponent = (stepProps) => {
6784
6796
  });
6785
6797
  };
6786
6798
 
6787
- // src/revamp/flow/response-utils.ts
6788
- var assertResponseIsValid = (response) => {
6789
- if (!isResponse(response)) {
6790
- throw new Error("Incorrect type of response from fetch. Expected object of type Response.");
6791
- }
6792
- if (response.bodyUsed) {
6793
- throw new Error(
6794
- "The body of the provided Response object has already been used. Every request must respond with a new Response object."
6795
- );
6796
- }
6797
- };
6798
- var isResponse = (response) => typeof response === "object" && response !== null && "clone" in response && "bodyUsed" in response;
6799
- var parseResponseBodyAsJsonElement = async (response) => {
6800
- try {
6801
- return await response.json();
6802
- } catch (e) {
6803
- return null;
6804
- }
6805
- };
6806
- function isActionResponseBody(body) {
6807
- return validateActionResponse(body).valid;
6808
- }
6809
- function assertActionResponseBody(body) {
6810
- if (!isObject(body) || !isObject(body.action)) {
6811
- throw new Error(
6812
- "Incorrect response body in action response. Expected an object satisfying the type { action: Action }."
6813
- );
6814
- }
6815
- }
6816
- function isErrorResponseBody(body) {
6817
- return Boolean(
6818
- isObject(body) && (body.refreshFormUrl || body.refreshUrl || body.validation || body.error || body.analytics)
6819
- );
6820
- }
6821
- function assertStepResponseBody(body) {
6822
- if (!isObject(body)) {
6823
- throw new Error("Incorrect response body in step response. Expected an object.");
6824
- }
6825
- }
6826
-
6827
6799
  // src/revamp/domain/features/polling/getStepPolling.ts
6828
6800
  var getStepPolling = ({
6829
- httpClient,
6830
6801
  pollingConfig,
6831
- onAction
6802
+ onAction,
6803
+ onPoll
6832
6804
  }) => {
6833
6805
  const { interval, delay = interval, maxAttempts, url, onError } = pollingConfig;
6834
6806
  let abortController = new AbortController();
6835
6807
  if (delay == null) {
6836
6808
  throw new Error("Polling configuration must include delay or interval");
6837
6809
  }
6838
- const onFailure = () => {
6839
- stop();
6840
- void onAction(onError.action);
6841
- };
6842
6810
  let attempts = 0;
6843
6811
  const poll = () => {
6844
6812
  attempts += 1;
6845
6813
  abortController.abort();
6846
6814
  abortController = new AbortController();
6847
6815
  const { signal } = abortController;
6848
- httpClient(url, { signal }).then(async (response) => {
6849
- if (!response.ok) {
6850
- onFailure();
6816
+ onPoll(url, onError.action, signal).then((result) => {
6817
+ if (result) {
6818
+ stop();
6851
6819
  return;
6852
6820
  }
6853
- response.json().then((body) => {
6854
- if (isActionResponseBody(body)) {
6855
- void onAction(body.action);
6856
- stop();
6857
- }
6858
- }).catch(() => {
6859
- });
6821
+ if (attempts >= maxAttempts && !signal.aborted) {
6822
+ void onAction(onError.action);
6823
+ stop();
6824
+ }
6860
6825
  }).catch(() => {
6861
6826
  });
6862
- if (attempts >= maxAttempts && !signal.aborted) {
6863
- onFailure();
6864
- }
6865
6827
  };
6866
6828
  poll();
6867
6829
  const intervalRef = setInterval(poll, delay * 1e3);
@@ -7636,6 +7598,46 @@ var autocompleteTokenMap = {
7636
7598
  pager: "pager"
7637
7599
  };
7638
7600
 
7601
+ // src/revamp/flow/response-utils.ts
7602
+ var assertResponseIsValid = (response) => {
7603
+ if (!isResponse(response)) {
7604
+ throw new Error("Incorrect type of response from fetch. Expected object of type Response.");
7605
+ }
7606
+ if (response.bodyUsed) {
7607
+ throw new Error(
7608
+ "The body of the provided Response object has already been used. Every request must respond with a new Response object."
7609
+ );
7610
+ }
7611
+ };
7612
+ var isResponse = (response) => typeof response === "object" && response !== null && "clone" in response && "bodyUsed" in response;
7613
+ var parseResponseBodyAsJsonElement = async (response) => {
7614
+ try {
7615
+ return await response.json();
7616
+ } catch (e) {
7617
+ return null;
7618
+ }
7619
+ };
7620
+ function isActionResponseBody(body) {
7621
+ return validateActionResponse(body).valid;
7622
+ }
7623
+ function assertActionResponseBody(body) {
7624
+ if (!isObject(body) || !isObject(body.action)) {
7625
+ throw new Error(
7626
+ "Incorrect response body in action response. Expected an object satisfying the type { action: Action }."
7627
+ );
7628
+ }
7629
+ }
7630
+ function isErrorResponseBody(body) {
7631
+ return Boolean(
7632
+ isObject(body) && (body.refreshFormUrl || body.refreshUrl || body.validation || body.error || body.analytics)
7633
+ );
7634
+ }
7635
+ function assertStepResponseBody(body) {
7636
+ if (!isObject(body)) {
7637
+ throw new Error("Incorrect response body in step response. Expected an object.");
7638
+ }
7639
+ }
7640
+
7639
7641
  // src/revamp/domain/features/utils/response-utils.ts
7640
7642
  var getAnalyticsFromErrorResponse = (json) => {
7641
7643
  if (!isErrorResponseBody(json)) {
@@ -7836,7 +7838,7 @@ var schemaHasValidationAsync = (schema) => Boolean("validationAsync" in schema &
7836
7838
  // src/revamp/domain/mappers/schema/numberSchemaToComponent.ts
7837
7839
  var numberSchemaToComponent = (schemaMapperProps, mapperProps) => {
7838
7840
  const { schema, model, localValue, required = false } = schemaMapperProps;
7839
- const { autocompleteHint, validationMessages, default: defaultValue } = schema;
7841
+ const { autocompleteHint, validationMessages, default: defaultValue, maximum, minimum } = schema;
7840
7842
  const { getErrorMessageFunctions, updateComponent, onRefresh, onValueChange } = mapperProps;
7841
7843
  const errorMessageFunctions = getErrorMessageFunctions(validationMessages);
7842
7844
  const { performPersistAsync, persistedState } = getPersistAsyncInitialState(
@@ -7859,6 +7861,8 @@ var numberSchemaToComponent = (schemaMapperProps, mapperProps) => {
7859
7861
  getAboveMaximumCheck(schema, errorMessageFunctions)
7860
7862
  ],
7861
7863
  value,
7864
+ maximum,
7865
+ minimum,
7862
7866
  persistedState,
7863
7867
  validationState,
7864
7868
  performPersistAsync,
@@ -8183,7 +8187,7 @@ var createIntegerInputComponent = (integerInputProps, updateComponent) => {
8183
8187
  // src/revamp/domain/mappers/schema/integerSchemaToComponent.ts
8184
8188
  var integerSchemaToComponent = (schemaMapperProps, mapperProps) => {
8185
8189
  const { schema, localValue, model, required = false } = schemaMapperProps;
8186
- const { autocompleteHint, validationMessages, default: defaultValue } = schema;
8190
+ const { autocompleteHint, validationMessages, default: defaultValue, maximum, minimum } = schema;
8187
8191
  const { getErrorMessageFunctions, updateComponent, onRefresh, onValueChange } = mapperProps;
8188
8192
  const errorMessageFunctions = getErrorMessageFunctions(validationMessages);
8189
8193
  const { performPersistAsync, persistedState } = getPersistAsyncInitialState(
@@ -8206,6 +8210,8 @@ var integerSchemaToComponent = (schemaMapperProps, mapperProps) => {
8206
8210
  __spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
8207
8211
  autoComplete: getAutocompleteString(autocompleteHint),
8208
8212
  checks,
8213
+ maximum,
8214
+ minimum,
8209
8215
  persistedState,
8210
8216
  value,
8211
8217
  validationState,
@@ -8784,6 +8790,8 @@ var stringSchemaToTextInputComponent = (schemaMapperProps, mapperProps) => {
8784
8790
  default: defaultValue,
8785
8791
  displayFormat,
8786
8792
  format,
8793
+ maxLength,
8794
+ minLength,
8787
8795
  validationMessages
8788
8796
  } = schema;
8789
8797
  const { getErrorMessageFunctions, updateComponent, onRefresh, onValueChange } = mapperProps;
@@ -8811,6 +8819,8 @@ var stringSchemaToTextInputComponent = (schemaMapperProps, mapperProps) => {
8811
8819
  ],
8812
8820
  control: control != null ? control : controlForLegacyFormat,
8813
8821
  displayFormat,
8822
+ maxLength,
8823
+ minLength,
8814
8824
  value,
8815
8825
  persistedState,
8816
8826
  validationState,
@@ -8989,7 +8999,7 @@ var arraySchemaToRepeatableComponent = (schemaMapperProps, mapperProps) => {
8989
8999
  required = false,
8990
9000
  validationErrors
8991
9001
  } = schemaMapperProps;
8992
- const { items, addItemTitle, editItemTitle, summary } = schema;
9002
+ const { items, addItemTitle, editItemTitle, maxItems, minItems, summary } = schema;
8993
9003
  const value = isArray(localValue) ? localValue : [];
8994
9004
  const components = initialModel == null ? void 0 : initialModel.map(
8995
9005
  (item, index) => mapSchemaToComponent(
@@ -9026,6 +9036,8 @@ var arraySchemaToRepeatableComponent = (schemaMapperProps, mapperProps) => {
9026
9036
  ],
9027
9037
  components: components != null ? components : [],
9028
9038
  editItemTitle,
9039
+ maxItems,
9040
+ minItems,
9029
9041
  summary,
9030
9042
  createEditableComponent,
9031
9043
  onValueChange
@@ -9338,7 +9350,7 @@ var arraySchemaToMultiSelectComponent = (schemaMapperProps, mapperProps) => {
9338
9350
  )
9339
9351
  };
9340
9352
  });
9341
- const { title, validationMessages } = schema;
9353
+ const { maxItems, minItems, title, validationMessages } = schema;
9342
9354
  const { getErrorMessageFunctions, onRefresh, onValueChange, updateComponent } = mapperProps;
9343
9355
  const errorMessageFunctions = getErrorMessageFunctions(validationMessages);
9344
9356
  const { performValidationAsync, validationState } = getValidationAsyncInitialState(
@@ -9355,6 +9367,8 @@ var arraySchemaToMultiSelectComponent = (schemaMapperProps, mapperProps) => {
9355
9367
  getBelowMinItemsCheck(schema, errorMessageFunctions)
9356
9368
  ],
9357
9369
  initialValue,
9370
+ maxItems,
9371
+ minItems,
9358
9372
  options,
9359
9373
  required,
9360
9374
  title,
@@ -10215,14 +10229,16 @@ var mapStepToComponent = (_a) => {
10215
10229
  var _b = _a, {
10216
10230
  loadingState,
10217
10231
  displayStepTitle,
10218
- trackEvent
10232
+ trackEvent,
10233
+ onPoll
10219
10234
  } = _b, restProps = __objRest(_b, [
10220
10235
  "loadingState",
10221
10236
  "displayStepTitle",
10222
- "trackEvent"
10237
+ "trackEvent",
10238
+ "onPoll"
10223
10239
  ]);
10224
10240
  var _a2, _b2;
10225
- const { httpClient, step, updateComponent } = restProps;
10241
+ const { step, updateComponent } = restProps;
10226
10242
  const { id, description, errors, external, key, layout = [], navigation, polling, title } = step;
10227
10243
  const backNavigation = (_a2 = navigation == null ? void 0 : navigation.back) != null ? _a2 : navigation == null ? void 0 : navigation.backButton;
10228
10244
  const back = backNavigation ? {
@@ -10252,7 +10268,7 @@ var mapStepToComponent = (_a) => {
10252
10268
  }
10253
10269
  };
10254
10270
  const onRefresh = async (schemaId, url) => restProps.onRefresh(schemaId, url != null ? url : refreshUrl);
10255
- const stepPolling = polling ? getStepPolling({ httpClient, pollingConfig: polling, onAction: restProps.onAction }) : void 0;
10271
+ const stepPolling = polling ? getStepPolling({ pollingConfig: polling, onAction: restProps.onAction, onPoll }) : void 0;
10256
10272
  const mapperProps = __spreadProps(__spreadValues({}, restProps), { trackEvent, onAction, onRefresh });
10257
10273
  const unreferencedSchemaFormComponents = mapUnreferencedSchemas(mapperProps);
10258
10274
  const layoutComponents = layout.map(
@@ -10318,8 +10334,19 @@ var executeRefresh = async (props) => {
10318
10334
  // src/revamp/flow/getResponseType.ts
10319
10335
  var responseTypes = ["step", "action", "exit"];
10320
10336
  var getResponseType = async (response) => {
10321
- var _a, _b;
10322
10337
  assertResponseIsValid(response);
10338
+ const headerResponseType = getResponseTypeFromHeader(response);
10339
+ if (headerResponseType) {
10340
+ return headerResponseType;
10341
+ }
10342
+ const jsonBody = await parseResponseBodyAsJsonElement(response.clone());
10343
+ if (isObject(jsonBody) && jsonBody.action) {
10344
+ return "action";
10345
+ }
10346
+ return "step";
10347
+ };
10348
+ var getResponseTypeFromHeader = (response) => {
10349
+ var _a, _b;
10323
10350
  if ((_a = response.headers) == null ? void 0 : _a.has("X-Df-Response-Type")) {
10324
10351
  const type = response.headers.get("X-Df-Response-Type");
10325
10352
  assertDFResponseType(type);
@@ -10328,11 +10355,7 @@ var getResponseType = async (response) => {
10328
10355
  if ((_b = response.headers) == null ? void 0 : _b.has("X-Df-Exit")) {
10329
10356
  return "exit";
10330
10357
  }
10331
- const jsonBody = await parseResponseBodyAsJsonElement(response.clone());
10332
- if (isObject(jsonBody) && jsonBody.action) {
10333
- return "action";
10334
- }
10335
- return "step";
10358
+ return void 0;
10336
10359
  };
10337
10360
  function assertDFResponseType(type) {
10338
10361
  if (!responseTypes.includes(type)) {
@@ -10623,6 +10646,48 @@ function useStableCallback(handler) {
10623
10646
  return useCallback((...args) => ref.current ? ref.current(...args) : null, []);
10624
10647
  }
10625
10648
 
10649
+ // src/revamp/flow/executePoll.ts
10650
+ var executePoll = async (props) => {
10651
+ const { errorAction, signal, url, httpClient } = props;
10652
+ try {
10653
+ const response = await httpClient(url != null ? url : "", {
10654
+ method: "GET",
10655
+ signal
10656
+ });
10657
+ if (!response.ok) {
10658
+ return { type: "action", action: errorAction };
10659
+ }
10660
+ const responseType = getResponseTypeFromHeader(response);
10661
+ const body = await parseResponseBodyAsJsonElement(response);
10662
+ try {
10663
+ switch (responseType) {
10664
+ case "step": {
10665
+ const etag = response.headers.get("etag") || null;
10666
+ assertStepResponseBody(body);
10667
+ return { type: "replace-step", step: body, etag };
10668
+ }
10669
+ case "exit": {
10670
+ return { type: "complete", result: body };
10671
+ }
10672
+ case "action": {
10673
+ assertActionResponseBody(body);
10674
+ return { type: "action", action: body.action };
10675
+ }
10676
+ default: {
10677
+ if (isActionResponseBody(body)) {
10678
+ return { type: "action", action: body.action };
10679
+ }
10680
+ return { type: "continue" };
10681
+ }
10682
+ }
10683
+ } catch (error) {
10684
+ return { type: "action", action: errorAction };
10685
+ }
10686
+ } catch (error) {
10687
+ return { type: "continue" };
10688
+ }
10689
+ };
10690
+
10626
10691
  // src/revamp/useDynamicFlowCore.tsx
10627
10692
  function useDynamicFlowCore(props) {
10628
10693
  const _a = props, { flowId, initialAction, initialStep, displayStepTitle = true } = _a, rest = __objRest(_a, ["flowId", "initialAction", "initialStep", "displayStepTitle"]);
@@ -10691,6 +10756,7 @@ function useDynamicFlowCore(props) {
10691
10756
  httpClient,
10692
10757
  onAction,
10693
10758
  onRefresh,
10759
+ onPoll,
10694
10760
  onValueChange
10695
10761
  });
10696
10762
  setStepComponent(() => {
@@ -10824,6 +10890,31 @@ function useDynamicFlowCore(props) {
10824
10890
  // eslint-disable-next-line react-hooks/exhaustive-deps
10825
10891
  []
10826
10892
  );
10893
+ const onPoll = useCallback2(
10894
+ async (url, errorAction, signal) => {
10895
+ const command = await executePoll({
10896
+ httpClient,
10897
+ url,
10898
+ errorAction,
10899
+ signal
10900
+ });
10901
+ switch (command.type) {
10902
+ case "replace-step":
10903
+ initialiseWithStep(command.step, command.etag);
10904
+ return true;
10905
+ case "action":
10906
+ void onAction(command.action);
10907
+ return true;
10908
+ case "complete":
10909
+ onCompletion(command.result);
10910
+ return true;
10911
+ case "continue":
10912
+ return false;
10913
+ }
10914
+ },
10915
+ // eslint-disable-next-line react-hooks/exhaustive-deps
10916
+ []
10917
+ );
10827
10918
  return { stepComponentRef };
10828
10919
  }
10829
10920
 
@@ -12580,6 +12671,8 @@ var TextInputRenderer = {
12580
12671
  description,
12581
12672
  help,
12582
12673
  error,
12674
+ maxLength,
12675
+ minLength,
12583
12676
  type,
12584
12677
  value: initialValue
12585
12678
  } = _a, rest = __objRest(_a, [
@@ -12589,6 +12682,8 @@ var TextInputRenderer = {
12589
12682
  "description",
12590
12683
  "help",
12591
12684
  "error",
12685
+ "maxLength",
12686
+ "minLength",
12592
12687
  "type",
12593
12688
  "value"
12594
12689
  ]);
@@ -5,11 +5,13 @@ import { type PerformRefresh } from '../features/refresh/getPerformRefresh';
5
5
  import type { PerformValidationAsync } from '../features/validationAsync/getPerformValidationAsync';
6
6
  export type IntegerInputComponent = InputComponent<number | null> & {
7
7
  type: 'integer';
8
+ maximum?: number;
9
+ minimum?: number;
8
10
  persistedState: PersistedState;
9
11
  validationState: ValidationState;
10
12
  onChange: (value: number | null) => void;
11
13
  };
12
- export declare const createIntegerInputComponent: (integerInputProps: Pick<IntegerInputComponent, "uid" | "id" | "analyticsId" | "autoComplete" | "control" | "description" | "disabled" | "errors" | "help" | "hidden" | "persistedState" | "placeholder" | "required" | "title" | "value" | "validationState"> & {
14
+ export declare const createIntegerInputComponent: (integerInputProps: Pick<IntegerInputComponent, "uid" | "id" | "analyticsId" | "autoComplete" | "control" | "description" | "disabled" | "errors" | "help" | "hidden" | "maximum" | "minimum" | "persistedState" | "placeholder" | "required" | "title" | "value" | "validationState"> & {
13
15
  checks: IsInvalidCheck<number | null>[];
14
16
  performPersistAsync: PerformPersistAsync | undefined;
15
17
  performRefresh: PerformRefresh | undefined;
@@ -6,6 +6,8 @@ import type { SelectInputOption } from './SelectInputComponent';
6
6
  export type MultiSelectComponent = InputComponent<LocalValueArray | null> & {
7
7
  type: 'multi-select';
8
8
  children: DomainComponent[];
9
+ maxItems?: number;
10
+ minItems?: number;
9
11
  options: SelectInputOption[];
10
12
  validationState: ValidationState;
11
13
  selectedIndices: number[];
@@ -13,7 +15,7 @@ export type MultiSelectComponent = InputComponent<LocalValueArray | null> & {
13
15
  getSelectedChildren: () => DomainComponent[] | null;
14
16
  onSelect: (indices: number[]) => void;
15
17
  };
16
- export declare const createMultiSelectComponent: (multiSelectProps: Pick<MultiSelectComponent, "uid" | "id" | "analyticsId" | "autoComplete" | "control" | "description" | "disabled" | "errors" | "hidden" | "required" | "title" | "validationState"> & {
18
+ export declare const createMultiSelectComponent: (multiSelectProps: Pick<MultiSelectComponent, "uid" | "id" | "analyticsId" | "autoComplete" | "control" | "description" | "disabled" | "errors" | "hidden" | "maxItems" | "minItems" | "required" | "title" | "validationState"> & {
17
19
  checks: IsInvalidCheck<LocalValueArray | null>[];
18
20
  initialValue: LocalValue;
19
21
  options: (SelectInputOption & {
@@ -5,11 +5,13 @@ import type { PerformValidationAsync } from '../features/validationAsync/getPerf
5
5
  import type { InputComponent, OnValueChange, PersistedState, RepeatableSummary, UpdateComponent, ValidationState } from '../types';
6
6
  export type NumberInputComponent = InputComponent<number | null> & {
7
7
  type: 'number';
8
+ maximum?: number;
9
+ minimum?: number;
8
10
  persistedState: PersistedState;
9
11
  validationState: ValidationState;
10
12
  onChange: (value: number | null) => void;
11
13
  };
12
- export declare const createNumberInputComponent: (numberInputProps: Pick<NumberInputComponent, "uid" | "id" | "analyticsId" | "autoComplete" | "control" | "description" | "disabled" | "errors" | "help" | "hidden" | "persistedState" | "placeholder" | "required" | "title" | "value" | "validationState"> & {
14
+ export declare const createNumberInputComponent: (numberInputProps: Pick<NumberInputComponent, "uid" | "id" | "analyticsId" | "autoComplete" | "control" | "description" | "disabled" | "errors" | "help" | "hidden" | "maximum" | "minimum" | "persistedState" | "placeholder" | "required" | "title" | "value" | "validationState"> & {
13
15
  checks: IsInvalidCheck<number | null>[];
14
16
  performPersistAsync: PerformPersistAsync | undefined;
15
17
  performRefresh: PerformRefresh | undefined;
@@ -6,11 +6,13 @@ import type { InputComponent, OnValueChange, PersistedState, RepeatableSummary,
6
6
  export type TextInputComponent = InputComponent<string | null> & {
7
7
  type: 'text';
8
8
  displayFormat?: string;
9
+ maxLength?: number;
10
+ minLength?: number;
9
11
  persistedState: PersistedState;
10
12
  validationState: ValidationState;
11
13
  onChange: (value: string | null) => void;
12
14
  };
13
- export declare const createTextInputComponent: (textInputProps: Pick<TextInputComponent, "uid" | "id" | "analyticsId" | "autoComplete" | "control" | "errors" | "description" | "disabled" | "displayFormat" | "help" | "hidden" | "persistedState" | "placeholder" | "required" | "title" | "value" | "validationState"> & {
15
+ export declare const createTextInputComponent: (textInputProps: Pick<TextInputComponent, "uid" | "id" | "analyticsId" | "autoComplete" | "control" | "errors" | "description" | "disabled" | "displayFormat" | "help" | "hidden" | "maxLength" | "minLength" | "persistedState" | "placeholder" | "required" | "title" | "value" | "validationState"> & {
14
16
  checks: IsInvalidCheck<string | null>[];
15
17
  performPersistAsync: PerformPersistAsync | undefined;
16
18
  performValidationAsync: PerformValidationAsync | undefined;
@@ -10,6 +10,8 @@ export type RepeatableComponent = ComponentWithTitle & {
10
10
  editableIndex: number | null;
11
11
  editItemTitle: string;
12
12
  errors: string[];
13
+ maxItems?: number;
14
+ minItems?: number;
13
15
  summaryDefaults: RepeatableSummary;
14
16
  getChildren: () => DomainComponent[];
15
17
  getLocalValue: () => LocalValueArray;
@@ -18,7 +20,7 @@ export type RepeatableComponent = ComponentWithTitle & {
18
20
  onRemove: () => void;
19
21
  onSave: () => boolean;
20
22
  };
21
- export declare const createRepeatableComponent: (repeatableProps: Pick<RepeatableComponent, "uid" | "id" | "addItemTitle" | "components" | "control" | "description" | "editItemTitle" | "errors" | "hidden" | "title"> & {
23
+ export declare const createRepeatableComponent: (repeatableProps: Pick<RepeatableComponent, "uid" | "id" | "addItemTitle" | "components" | "control" | "description" | "editItemTitle" | "errors" | "hidden" | "maxItems" | "minItems" | "title"> & {
22
24
  analyticsId?: string;
23
25
  checks: IsInvalidCheck<LocalValueArray | null>[];
24
26
  summary?: SummarySummariser;
@@ -1,12 +1,11 @@
1
1
  import type { Polling } from '@wise/dynamic-flow-types/build/next';
2
- import type { HttpClient } from '../../../types';
3
- import type { OnAction } from '../../types';
2
+ import type { OnAction, OnPoll } from '../../types';
4
3
  export type StepPollingProps = {
5
- httpClient: HttpClient;
6
4
  pollingConfig: Polling;
7
5
  onAction: OnAction;
6
+ onPoll: OnPoll;
8
7
  };
9
8
  export type StepPolling = {
10
9
  stop: () => void;
11
10
  };
12
- export declare const getStepPolling: ({ httpClient, pollingConfig, onAction, }: StepPollingProps) => StepPolling;
11
+ export declare const getStepPolling: ({ pollingConfig, onAction, onPoll, }: StepPollingProps) => StepPolling;
@@ -1,9 +1,10 @@
1
1
  import type { AnalyticsEventDispatcher } from '../features/events';
2
- import type { LoadingState } from '../types';
2
+ import type { LoadingState, OnPoll } from '../types';
3
3
  import type { MapperProps } from './schema/types';
4
4
  export type StepMapperProps = Omit<MapperProps, 'trackEvent'> & {
5
5
  displayStepTitle: boolean;
6
6
  loadingState: LoadingState;
7
7
  trackEvent: AnalyticsEventDispatcher<string>;
8
+ onPoll: OnPoll;
8
9
  };
9
- export declare const mapStepToComponent: ({ loadingState, displayStepTitle, trackEvent, ...restProps }: StepMapperProps) => import("../components/StepDomainComponent").StepDomainComponent;
10
+ export declare const mapStepToComponent: ({ loadingState, displayStepTitle, trackEvent, onPoll, ...restProps }: StepMapperProps) => import("../components/StepDomainComponent").StepDomainComponent;
@@ -76,6 +76,7 @@ export type InputComponent<V extends LocalValue> = ComponentWithTitle & {
76
76
  };
77
77
  export type UpdateComponent = (id: string, update: (component: DomainComponent) => void) => void;
78
78
  export type OnAction = (action: Action) => Promise<void>;
79
+ export type OnPoll = (url: string, errorAction: Action, signal: AbortSignal) => Promise<boolean>;
79
80
  export type OnRefresh = (schemaId: string | undefined, url?: string) => Promise<void> | void;
80
81
  export type OnValueChange = () => void;
81
82
  export type Align = 'start' | 'center' | 'end';
@@ -0,0 +1,21 @@
1
+ import { Action, Model, Step } from '@wise/dynamic-flow-types/build/next';
2
+ type Command = {
3
+ type: 'complete';
4
+ result: Model;
5
+ } | {
6
+ type: 'replace-step';
7
+ step: Step;
8
+ etag: string | null;
9
+ } | {
10
+ type: 'continue';
11
+ } | {
12
+ type: 'action';
13
+ action: Action;
14
+ };
15
+ export declare const executePoll: (props: {
16
+ httpClient: typeof fetch;
17
+ url: string;
18
+ errorAction: Action;
19
+ signal: AbortSignal;
20
+ }) => Promise<Command>;
21
+ export {};
@@ -7,4 +7,5 @@ export type ResponseType = (typeof responseTypes)[number];
7
7
  * Ideally it should just be a matter of checking the "X-Df-Response-Type" response header.
8
8
  */
9
9
  export declare const getResponseType: (response: Response) => Promise<ResponseType>;
10
+ export declare const getResponseTypeFromHeader: (response: Response) => ResponseType | undefined;
10
11
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wise/dynamic-flow-client",
3
- "version": "3.18.1",
3
+ "version": "3.19.0",
4
4
  "description": "Dynamic Flow web client",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./build/main.min.js",
@@ -104,7 +104,7 @@
104
104
  "nanoid": "5.0.7",
105
105
  "react-webcam": "^7.2.0",
106
106
  "screenfull": "^5.2.0",
107
- "@wise/dynamic-flow-types": "2.21.0"
107
+ "@wise/dynamic-flow-types": "2.22.0"
108
108
  },
109
109
  "scripts": {
110
110
  "dev": "pnpm build:visual-tests && storybook dev -p 3003",