@oneblink/apps-react 13.0.0-beta.1 → 13.0.0-beta.10

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.
Files changed (119) hide show
  1. package/dist/OneBlinkFormBase.d.ts +23 -3
  2. package/dist/OneBlinkFormBase.js +350 -193
  3. package/dist/OneBlinkFormBase.js.map +1 -1
  4. package/dist/OneBlinkReadOnlyForm.d.ts +17 -7
  5. package/dist/OneBlinkReadOnlyForm.js +24 -8
  6. package/dist/OneBlinkReadOnlyForm.js.map +1 -1
  7. package/dist/apps/approvals-service.d.ts +1 -0
  8. package/dist/apps/approvals-service.js.map +1 -1
  9. package/dist/apps/services/api/submissions.d.ts +3 -2
  10. package/dist/apps/services/api/submissions.js +3 -6
  11. package/dist/apps/services/api/submissions.js.map +1 -1
  12. package/dist/apps/submission-service.d.ts +11 -5
  13. package/dist/apps/submission-service.js +9 -4
  14. package/dist/apps/submission-service.js.map +1 -1
  15. package/dist/components/renderer/LookupButton.d.ts +1 -2
  16. package/dist/components/renderer/LookupButton.js +7 -6
  17. package/dist/components/renderer/LookupButton.js.map +1 -1
  18. package/dist/components/renderer/LookupNotification.js +31 -24
  19. package/dist/components/renderer/LookupNotification.js.map +1 -1
  20. package/dist/components/renderer/OneBlinkFormElements.d.ts +5 -7
  21. package/dist/components/renderer/OneBlinkFormElements.js +10 -35
  22. package/dist/components/renderer/OneBlinkFormElements.js.map +1 -1
  23. package/dist/components/renderer/PageFormElements.js +8 -3
  24. package/dist/components/renderer/PageFormElements.js.map +1 -1
  25. package/dist/components/renderer/ReverseGeocode.js +6 -11
  26. package/dist/components/renderer/ReverseGeocode.js.map +1 -1
  27. package/dist/form-elements/FormElementABN.js +1 -1
  28. package/dist/form-elements/FormElementABN.js.map +1 -1
  29. package/dist/form-elements/FormElementBSB.js +1 -1
  30. package/dist/form-elements/FormElementBSB.js.map +1 -1
  31. package/dist/form-elements/FormElementBarcodeScanner.js +1 -1
  32. package/dist/form-elements/FormElementBarcodeScanner.js.map +1 -1
  33. package/dist/form-elements/FormElementCalculation.js +1 -0
  34. package/dist/form-elements/FormElementCalculation.js.map +1 -1
  35. package/dist/form-elements/FormElementCheckBoxes.js +1 -1
  36. package/dist/form-elements/FormElementCheckBoxes.js.map +1 -1
  37. package/dist/form-elements/FormElementDate.js +1 -1
  38. package/dist/form-elements/FormElementDate.js.map +1 -1
  39. package/dist/form-elements/FormElementDateTime.js +1 -1
  40. package/dist/form-elements/FormElementDateTime.js.map +1 -1
  41. package/dist/form-elements/FormElementEmail.js +1 -1
  42. package/dist/form-elements/FormElementEmail.js.map +1 -1
  43. package/dist/form-elements/FormElementForm.d.ts +8 -9
  44. package/dist/form-elements/FormElementForm.js +4 -3
  45. package/dist/form-elements/FormElementForm.js.map +1 -1
  46. package/dist/form-elements/FormElementLookupButton.js +4 -3
  47. package/dist/form-elements/FormElementLookupButton.js.map +1 -1
  48. package/dist/form-elements/FormElementNumber.js +1 -1
  49. package/dist/form-elements/FormElementNumber.js.map +1 -1
  50. package/dist/form-elements/FormElementRepeatableSet.d.ts +4 -4
  51. package/dist/form-elements/FormElementRepeatableSet.js +6 -4
  52. package/dist/form-elements/FormElementRepeatableSet.js.map +1 -1
  53. package/dist/form-elements/FormElementSection.d.ts +3 -3
  54. package/dist/form-elements/FormElementSection.js +2 -2
  55. package/dist/form-elements/FormElementSection.js.map +1 -1
  56. package/dist/form-elements/FormElementSelect.js +1 -1
  57. package/dist/form-elements/FormElementSelect.js.map +1 -1
  58. package/dist/form-elements/FormElementSummary.js +2 -0
  59. package/dist/form-elements/FormElementSummary.js.map +1 -1
  60. package/dist/form-elements/FormElementTelephone.js +1 -1
  61. package/dist/form-elements/FormElementTelephone.js.map +1 -1
  62. package/dist/form-elements/FormElementText.js +1 -1
  63. package/dist/form-elements/FormElementText.js.map +1 -1
  64. package/dist/form-elements/FormElementTextarea.js +1 -1
  65. package/dist/form-elements/FormElementTextarea.js.map +1 -1
  66. package/dist/form-elements/FormElementTime.js +1 -1
  67. package/dist/form-elements/FormElementTime.js.map +1 -1
  68. package/dist/hooks/useAreLookupsDisallowed.d.ts +2 -0
  69. package/dist/hooks/useAreLookupsDisallowed.js +12 -0
  70. package/dist/hooks/useAreLookupsDisallowed.js.map +1 -0
  71. package/dist/hooks/useEditableFormElementIds.d.ts +3 -0
  72. package/dist/hooks/useEditableFormElementIds.js +6 -0
  73. package/dist/hooks/useEditableFormElementIds.js.map +1 -0
  74. package/dist/hooks/useFormElementOptions.js +2 -0
  75. package/dist/hooks/useFormElementOptions.js.map +1 -1
  76. package/dist/hooks/useFormIsDirty.d.ts +38 -0
  77. package/dist/hooks/useFormIsDirty.js +78 -0
  78. package/dist/hooks/useFormIsDirty.js.map +1 -0
  79. package/dist/hooks/useFormSubmissionAttempt.d.ts +88 -0
  80. package/dist/hooks/useFormSubmissionAttempt.js +103 -0
  81. package/dist/hooks/useFormSubmissionAttempt.js.map +1 -0
  82. package/dist/hooks/useFormSubmissionAutoSaveState.d.ts +2 -9
  83. package/dist/hooks/useFormSubmissionAutoSaveState.js +4 -2
  84. package/dist/hooks/useFormSubmissionAutoSaveState.js.map +1 -1
  85. package/dist/hooks/useFormValidation.d.ts +1 -1
  86. package/dist/hooks/useFormValidation.js +2 -1
  87. package/dist/hooks/useFormValidation.js.map +1 -1
  88. package/dist/hooks/useInjectPages.d.ts +2 -1
  89. package/dist/hooks/useInjectPages.js.map +1 -1
  90. package/dist/hooks/useIsFormElementReadOnly.d.ts +2 -0
  91. package/dist/hooks/useIsFormElementReadOnly.js +13 -0
  92. package/dist/hooks/useIsFormElementReadOnly.js.map +1 -0
  93. package/dist/hooks/useLookupNotification.d.ts +23 -2
  94. package/dist/hooks/useLookupNotification.js +2 -1
  95. package/dist/hooks/useLookupNotification.js.map +1 -1
  96. package/dist/hooks/useLookups.d.ts +3 -3
  97. package/dist/hooks/useLookups.js +7 -4
  98. package/dist/hooks/useLookups.js.map +1 -1
  99. package/dist/index.d.ts +2 -0
  100. package/dist/index.js +2 -0
  101. package/dist/index.js.map +1 -1
  102. package/dist/services/form-validation/extensions.d.ts +2 -1
  103. package/dist/services/form-validation/extensions.js +2 -1
  104. package/dist/services/form-validation/extensions.js.map +1 -1
  105. package/dist/services/form-validation/validateSubmission.d.ts +2 -1
  106. package/dist/services/form-validation/validateSubmission.js +14 -9
  107. package/dist/services/form-validation/validateSubmission.js.map +1 -1
  108. package/dist/types/form.d.ts +17 -3
  109. package/dist/types/form.js.map +1 -1
  110. package/dist/utils/read-only-form-elements.d.ts +37 -0
  111. package/dist/utils/read-only-form-elements.js +63 -0
  112. package/dist/utils/read-only-form-elements.js.map +1 -0
  113. package/package.json +4 -3
  114. package/dist/services/isElementReadOnlyForAudience.d.ts +0 -20
  115. package/dist/services/isElementReadOnlyForAudience.js +0 -46
  116. package/dist/services/isElementReadOnlyForAudience.js.map +0 -1
  117. package/dist/services/resolveFormElementReadOnly.d.ts +0 -10
  118. package/dist/services/resolveFormElementReadOnly.js +0 -17
  119. package/dist/services/resolveFormElementReadOnly.js.map +0 -1
@@ -2,15 +2,23 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import * as React from 'react';
3
3
  import OneBlinkFormBase from './OneBlinkFormBase';
4
4
  import useFormSubmissionState from './hooks/useFormSubmissionState';
5
- function OneBlinkReadOnlyForm({ form, initialSubmission, ...rest }) {
5
+ const noop = () => { };
6
+ function UncontrolledOneBlinkReadOnlyForm({ form, initialSubmission, ...rest }) {
6
7
  const [{ submission, definition, executedLookups }, setFormSubmission] = useFormSubmissionState(form, initialSubmission);
7
- const noop = React.useCallback(() => { }, []);
8
- return (_jsx(OneBlinkFormBase, { definition: definition, submission: submission, disabled: true, isReadOnly: true, onCancel: noop, onSubmit: noop, setFormSubmission: setFormSubmission, isPendingQueueEnabled: false, executedLookups: executedLookups, sectionState: [], ...rest }));
8
+ return (_jsx(OneBlinkFormBase, { ...rest, definition: definition, submission: submission, disabled: true, isReadOnly: true, onCancel: noop, onSubmit: noop, setFormSubmission: setFormSubmission, isPendingQueueEnabled: false, executedLookups: executedLookups, sectionState: [] }));
9
+ }
10
+ function OneBlinkReadOnlyForm(props) {
11
+ if (props.editableFormElementIds) {
12
+ return (_jsx(OneBlinkFormBase, { ...props, disabled: false, isReadOnly: true, onCancel: noop, onSubmit: noop, isPendingQueueEnabled: false }));
13
+ }
14
+ return _jsx(UncontrolledOneBlinkReadOnlyForm, { ...props });
9
15
  }
10
16
  /**
11
- * Component for rendering a OneBlink Form in read-only mode. This component
12
- * will render the form with all inputs disabled but will **not** render the
13
- * submit, cancel and save draft buttons.
17
+ * Component for rendering a OneBlink Form in read-only mode. By default, all
18
+ * inputs are read-only. Pass `editableFormElementIds` with controlled
19
+ * submission props (`definition`, `submission`, `setFormSubmission`,
20
+ * `executedLookups`) to keep selected inputs editable. This component does
21
+ * **not** render the submit, cancel or save draft buttons.
14
22
  *
15
23
  * It is also recommended to import the `css` from this library as well.
16
24
  *
@@ -28,6 +36,7 @@ function OneBlinkReadOnlyForm({ form, initialSubmission, ...rest }) {
28
36
  * FormTypes
29
37
  * IsOfflineContextProvider,
30
38
  * OneBlinkReadOnlyForm,
39
+ * useFormSubmissionState,
31
40
  * useIsMounted,
32
41
  * } from '@oneblink/apps-react'
33
42
  * import '@oneblink/apps-react/dist/styles.css'
@@ -54,6 +63,10 @@ function OneBlinkReadOnlyForm({ form, initialSubmission, ...rest }) {
54
63
  *
55
64
  * function FormContainer() {
56
65
  * const isMounted = useIsMounted()
66
+ * const [
67
+ * { definition, submission, executedLookups },
68
+ * setFormSubmission,
69
+ * ] = useFormSubmissionState(form)
57
70
  *
58
71
  * const handleFormError = React.useCallback(() => {
59
72
  * // handle form rendering error caused by a misconfigured form here...
@@ -62,9 +75,12 @@ function OneBlinkReadOnlyForm({ form, initialSubmission, ...rest }) {
62
75
  * return (
63
76
  * <OneBlinkReadOnlyForm
64
77
  * googleMapsApiKey={googleMapsApiKey}
65
- * initialSubmission={null}
66
- * form={form}
78
+ * definition={definition}
79
+ * submission={submission}
80
+ * setFormSubmission={setFormSubmission}
81
+ * executedLookups={executedLookups}
67
82
  * audience="APPROVER"
83
+ * editableFormElementIds={['element-id']}
68
84
  * />
69
85
  * )
70
86
  * }
@@ -1 +1 @@
1
- {"version":3,"file":"OneBlinkReadOnlyForm.js","sourceRoot":"","sources":["../src/OneBlinkReadOnlyForm.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,gBAGN,MAAM,oBAAoB,CAAA;AAC3B,OAAO,sBAAsB,MAAM,gCAAgC,CAAA;AAEnE,SAAS,oBAAoB,CAAC,EAC5B,IAAI,EACJ,iBAAiB,EACjB,GAAG,IAAI,EACmD;IAC1D,MAAM,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,EAAE,iBAAiB,CAAC,GACpE,sBAAsB,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAA;IAEjD,MAAM,IAAI,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,GAAE,CAAC,EAAE,EAAE,CAAC,CAAA;IAE5C,OAAO,CACL,KAAC,gBAAgB,IACf,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,IAAI,EACd,UAAU,EAAE,IAAI,EAChB,QAAQ,EAAE,IAAI,EACd,QAAQ,EAAE,IAAI,EACd,iBAAiB,EAAE,iBAAiB,EACpC,qBAAqB,EAAE,KAAK,EAC5B,eAAe,EAAE,eAAe,EAChC,YAAY,EAAE,EAAE,KACZ,IAAI,GACR,CACH,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+EG;AACH,eAAe,KAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAA","sourcesContent":["import * as React from 'react'\nimport OneBlinkFormBase, {\n OneBlinkFormUncontrolledProps,\n OneBlinkReadOnlyFormProps,\n} from './OneBlinkFormBase'\nimport useFormSubmissionState from './hooks/useFormSubmissionState'\n\nfunction OneBlinkReadOnlyForm({\n form,\n initialSubmission,\n ...rest\n}: OneBlinkReadOnlyFormProps & OneBlinkFormUncontrolledProps) {\n const [{ submission, definition, executedLookups }, setFormSubmission] =\n useFormSubmissionState(form, initialSubmission)\n\n const noop = React.useCallback(() => {}, [])\n\n return (\n <OneBlinkFormBase\n definition={definition}\n submission={submission}\n disabled={true}\n isReadOnly={true}\n onCancel={noop}\n onSubmit={noop}\n setFormSubmission={setFormSubmission}\n isPendingQueueEnabled={false}\n executedLookups={executedLookups}\n sectionState={[]}\n {...rest}\n />\n )\n}\n\n/**\n * Component for rendering a OneBlink Form in read-only mode. This component\n * will render the form with all inputs disabled but will **not** render the\n * submit, cancel and save draft buttons.\n *\n * It is also recommended to import the `css` from this library as well.\n *\n * ```js\n * import { OneBlinkReadOnlyForm } from '@oneblink/apps-react'\n * import '@oneblink/apps-react/dist/styles.css'\n * ```\n *\n * #### Example\n *\n * ```tsx\n * import React from 'react'\n * import ReactDOM from 'react-dom'\n * import {\n * FormTypes\n * IsOfflineContextProvider,\n * OneBlinkReadOnlyForm,\n * useIsMounted,\n * } from '@oneblink/apps-react'\n * import '@oneblink/apps-react/dist/styles.css'\n *\n * const googleMapsApiKey = 'ENTER_YOUR_MAPS_API_KEY_HERE'\n * const formsAppId = 1\n * const form: FormTypes.Form = {\n * id: 1,\n * name: 'Name of Form',\n * description: '',\n * organisationId: 'abc123',\n * formsAppEnvironmentId: 1,\n * formsAppIds: [],\n * elements: [],\n * isAuthenticated: false,\n * isMultiPage: false,\n * isInfoPage: false,\n * publishStartDate: null,\n * publishEndDate: null,\n * postSubmissionAction: 'FORMS_LIBRARY',\n * submissionEvents: [],\n * tags: [],\n * }\n *\n * function FormContainer() {\n * const isMounted = useIsMounted()\n *\n * const handleFormError = React.useCallback(() => {\n * // handle form rendering error caused by a misconfigured form here...\n * }, [isMounted])\n *\n * return (\n * <OneBlinkReadOnlyForm\n * googleMapsApiKey={googleMapsApiKey}\n * initialSubmission={null}\n * form={form}\n * audience=\"APPROVER\"\n * />\n * )\n * }\n *\n * function App() {\n * return (\n * <IsOfflineContextProvider>\n * <FormContainer />\n * </IsOfflineContextProvider>\n * )\n * }\n *\n * const root = document.getElementById('root')\n * if (root) {\n * ReactDOM.render(<App />, root)\n * }\n * ```\n *\n * @param props\n * @returns\n * @group Components\n */\nexport default React.memo(OneBlinkReadOnlyForm)\n"]}
1
+ {"version":3,"file":"OneBlinkReadOnlyForm.js","sourceRoot":"","sources":["../src/OneBlinkReadOnlyForm.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,gBAEN,MAAM,oBAAoB,CAAA;AAC3B,OAAO,sBAAsB,MAAM,gCAAgC,CAAA;AAGnE,MAAM,IAAI,GAAG,GAAG,EAAE,GAAE,CAAC,CAAA;AAErB,SAAS,gCAAgC,CAAC,EACxC,IAAI,EACJ,iBAAiB,EACjB,GAAG,IAAI,EACsD;IAC7D,MAAM,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,EAAE,iBAAiB,CAAC,GACpE,sBAAsB,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAA;IAEjD,OAAO,CACL,KAAC,gBAAgB,OACX,IAAI,EACR,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,IAAI,EACd,UAAU,EAAE,IAAI,EAChB,QAAQ,EAAE,IAAI,EACd,QAAQ,EAAE,IAAI,EACd,iBAAiB,EAAE,iBAAiB,EACpC,qBAAqB,EAAE,KAAK,EAC5B,eAAe,EAAE,eAAe,EAChC,YAAY,EAAE,EAAE,GAChB,CACH,CAAA;AACH,CAAC;AAED,SAAS,oBAAoB,CAAC,KAAgC;IAC5D,IAAI,KAAK,CAAC,sBAAsB,EAAE,CAAC;QACjC,OAAO,CACL,KAAC,gBAAgB,OACX,KAAK,EACT,QAAQ,EAAE,KAAK,EACf,UAAU,EAAE,IAAI,EAChB,QAAQ,EAAE,IAAI,EACd,QAAQ,EAAE,IAAI,EACd,qBAAqB,EAAE,KAAK,GAC5B,CACH,CAAA;IACH,CAAC;IAED,OAAO,KAAC,gCAAgC,OAAK,KAAK,GAAI,CAAA;AACxD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyFG;AACH,eAAe,KAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAA","sourcesContent":["import * as React from 'react'\nimport OneBlinkFormBase, {\n OneBlinkReadOnlyFormProps,\n} from './OneBlinkFormBase'\nimport useFormSubmissionState from './hooks/useFormSubmissionState'\nimport { FormTypes } from '@oneblink/types'\n\nconst noop = () => {}\n\nfunction UncontrolledOneBlinkReadOnlyForm({\n form,\n initialSubmission,\n ...rest\n}: Extract<OneBlinkReadOnlyFormProps, { form: FormTypes.Form }>) {\n const [{ submission, definition, executedLookups }, setFormSubmission] =\n useFormSubmissionState(form, initialSubmission)\n\n return (\n <OneBlinkFormBase\n {...rest}\n definition={definition}\n submission={submission}\n disabled={true}\n isReadOnly={true}\n onCancel={noop}\n onSubmit={noop}\n setFormSubmission={setFormSubmission}\n isPendingQueueEnabled={false}\n executedLookups={executedLookups}\n sectionState={[]}\n />\n )\n}\n\nfunction OneBlinkReadOnlyForm(props: OneBlinkReadOnlyFormProps) {\n if (props.editableFormElementIds) {\n return (\n <OneBlinkFormBase\n {...props}\n disabled={false}\n isReadOnly={true}\n onCancel={noop}\n onSubmit={noop}\n isPendingQueueEnabled={false}\n />\n )\n }\n\n return <UncontrolledOneBlinkReadOnlyForm {...props} />\n}\n\n/**\n * Component for rendering a OneBlink Form in read-only mode. By default, all\n * inputs are read-only. Pass `editableFormElementIds` with controlled\n * submission props (`definition`, `submission`, `setFormSubmission`,\n * `executedLookups`) to keep selected inputs editable. This component does\n * **not** render the submit, cancel or save draft buttons.\n *\n * It is also recommended to import the `css` from this library as well.\n *\n * ```js\n * import { OneBlinkReadOnlyForm } from '@oneblink/apps-react'\n * import '@oneblink/apps-react/dist/styles.css'\n * ```\n *\n * #### Example\n *\n * ```tsx\n * import React from 'react'\n * import ReactDOM from 'react-dom'\n * import {\n * FormTypes\n * IsOfflineContextProvider,\n * OneBlinkReadOnlyForm,\n * useFormSubmissionState,\n * useIsMounted,\n * } from '@oneblink/apps-react'\n * import '@oneblink/apps-react/dist/styles.css'\n *\n * const googleMapsApiKey = 'ENTER_YOUR_MAPS_API_KEY_HERE'\n * const formsAppId = 1\n * const form: FormTypes.Form = {\n * id: 1,\n * name: 'Name of Form',\n * description: '',\n * organisationId: 'abc123',\n * formsAppEnvironmentId: 1,\n * formsAppIds: [],\n * elements: [],\n * isAuthenticated: false,\n * isMultiPage: false,\n * isInfoPage: false,\n * publishStartDate: null,\n * publishEndDate: null,\n * postSubmissionAction: 'FORMS_LIBRARY',\n * submissionEvents: [],\n * tags: [],\n * }\n *\n * function FormContainer() {\n * const isMounted = useIsMounted()\n * const [\n * { definition, submission, executedLookups },\n * setFormSubmission,\n * ] = useFormSubmissionState(form)\n *\n * const handleFormError = React.useCallback(() => {\n * // handle form rendering error caused by a misconfigured form here...\n * }, [isMounted])\n *\n * return (\n * <OneBlinkReadOnlyForm\n * googleMapsApiKey={googleMapsApiKey}\n * definition={definition}\n * submission={submission}\n * setFormSubmission={setFormSubmission}\n * executedLookups={executedLookups}\n * audience=\"APPROVER\"\n * editableFormElementIds={['element-id']}\n * />\n * )\n * }\n *\n * function App() {\n * return (\n * <IsOfflineContextProvider>\n * <FormContainer />\n * </IsOfflineContextProvider>\n * )\n * }\n *\n * const root = document.getElementById('root')\n * if (root) {\n * ReactDOM.render(<App />, root)\n * }\n * ```\n *\n * @param props\n * @returns\n * @group Components\n */\nexport default React.memo(OneBlinkReadOnlyForm)\n"]}
@@ -10,6 +10,7 @@ export type FormSubmissionApprovalsResponse = {
10
10
  export type FormApprovalFlowInstanceHistory = {
11
11
  formApprovalFlowInstance: ApprovalTypes.FormApprovalFlowInstance;
12
12
  formSubmissionMeta: SubmissionTypes.FormSubmissionMeta;
13
+ formSubmissionMetaEdits: SubmissionTypes.FormSubmissionMetaEdit[];
13
14
  formSubmissionApprovals: ApprovalTypes.FormSubmissionApproval[];
14
15
  successfulFormSubmissionPayment?: SubmissionTypes.FormSubmissionPayment;
15
16
  };
@@ -1 +1 @@
1
- {"version":3,"file":"approvals-service.js","sourceRoot":"","sources":["../../src/apps/approvals-service.ts"],"names":[],"mappings":"AACA,OAAO,iBAAiB,MAAM,qCAAqC,CAAA;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EACL,aAAa,EACb,UAAU,EACV,UAAU,EACV,aAAa,EACb,WAAW,GAEZ,MAAM,kBAAkB,CAAA;AACzB,OAAO,OAAO,MAAM,WAAW,CAAA;AAC/B,OAAO,MAAM,MAAM,UAAU,CAAA;AA0C7B;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,UAAkB,EAClB,WAAyB;IAEzB,IAAI,CAAC;QACH,OAAO,MAAM,UAAU,CACrB,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,eAAe,UAAU,eAAe,EACpE,WAAW,CACZ,CAAA;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAA;QAC5B,OAAO,CAAC,KAAK,CAAC,4CAA4C,EAAE,GAAG,CAAC,CAAA;QAChE,MAAM,KAAK,GAAG,GAAgB,CAAA;QAC9B,IAAI,SAAS,EAAE,EAAE,CAAC;YAChB,MAAM,IAAI,iBAAiB,CACzB,4HAA4H,EAC5H;gBACE,aAAa,EAAE,KAAK;gBACpB,SAAS,EAAE,IAAI;aAChB,CACF,CAAA;QACH,CAAC;Q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K,QAAQ,EAAE,CAAC;YAC/B,QAAQ,GAAG,IAAI,CAAA;QACjB,CAAC;QAED,MAAM,gCAAgC,GAAG,uBAAuB,CAAA;QAChE,IAAI,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,MAAK,wBAAwB,EAAE,CAAC;YAC/C,uBAAuB,GAAG,IAAI,CAAA;QAChC,CAAC;QAED,IAAI,WAAW,GAAG,6BAA6B,CAAA;QAC/C,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,WAAW,GAAG,kCAAkC,CAAA;QAClD,CAAC;aAAM,IAAI,MAAM,EAAE,CAAC;YAClB,MAAM,aAAa,GAAG,CAAA,kBAAkB,aAAlB,kBAAkB,uBAAlB,kBAAkB,CAAE,SAAS;gBACjD,CAAC,CAAC,OAAO,kBAAkB,CAAC,SAAS,EAAE;gBACvC,CAAC,CAAC,EAAE,CAAA;YACN,WAAW,GAAG,GAAG,MAAM,CAAC,KAAK,GAAG,aAAa,EAAE,CAAA;QACjD,CAAC;aAAM,IAAI,iBAAiB,EAAE,CAAC;YAC7B,WAAW,GAAG,2BAA2B,CAAA;QAC3C,CAAC;aAAM,IAAI,gCAAgC,EAAE,CAAC;YAC5C,WAAW,GAAG,2CAA2C,CAAA;QAC3D,CAAC;QAED,OAAO;YACL,GAAG,IAAI;YACP,MAAM;YACN,wBAAwB;YACxB,iBAAiB;YACjB,uCAAuC;YACvC,gCAAgC;YAChC,WAAW;SACZ,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { SubmissionTypes, ApprovalTypes, FormTypes } from '@oneblink/types'\nimport OneBlinkAppsError from './services/errors/oneBlinkAppsError'\nimport { isOffline } from './offline-service'\nimport {\n deleteRequest,\n getRequest,\n putRequest,\n searchRequest,\n postRequest,\n HTTPError,\n} from './services/fetch'\nimport tenants from './tenants'\nimport Sentry from './Sentry'\n\nexport type FormSubmissionApprovalsResponse = {\n approvals: Array<{\n formSubmissionApproval: ApprovalTypes.FormSubmissionApproval\n formApprovalFlowInstance: ApprovalTypes.FormApprovalFlowInstance\n formSubmissionMeta: SubmissionTypes.FormSubmissionMeta\n latestSuccessfulFormSubmissionPayment:\n | SubmissionTypes.FormSubmissionPayment\n | undefined\n }>\n}\n\nexport type FormApprovalFlowInstanceHistory = {\n formApprovalFlowInstance: ApprovalTypes.FormApprovalFlowInstance\n formSubmissionMeta: SubmissionTypes.FormSubmissionMeta\n formSubmissionApprovals: ApprovalTypes.FormSubmissionApproval[]\n successfulFormSubmissionPayment?: SubmissionTypes.FormSubmissionPayment\n}\n\nexport type FormSubmissionApprovalResponse = {\n formSubmissionMeta: SubmissionTypes.FormSubmissionMeta\n formApprovalFlowInstance: ApprovalTypes.FormApprovalFlowInstance\n formSubmissionApproval: ApprovalTypes.FormSubmissionApproval\n form: FormTypes.Form\n successfulFormSubmissionPayment?: SubmissionTypes.FormSubmissionPayment\n history: FormApprovalFlowInstanceHistory[]\n}\n\nexport type FormSubmissionsAdministrationApprovalsResponse = {\n approvals: Array<\n FormApprovalFlowInstanceHistory & {\n history: Array<FormApprovalFlowInstanceHistory>\n }\n >\n meta: {\n limit: number\n offset: number\n nextOffset?: number\n }\n}\n\n/**\n * Get an Object containing FormSubmissionApprovals assigned to the current user\n * and the Form definitions in those approvals.\n *\n * #### Example\n *\n * ```js\n * const formsAppId = 1\n * const {\n * formSubmissionApprovals,\n * formApprovalFlowInstances,\n * forms,\n * formSubmissionMeta,\n * } = await approvalsService.getFormSubmissionApprovals(formAppId)\n * ```\n *\n * @param formsAppId\n * @param abortSignal\n * @returns\n */\nexport async function getFormSubmissionApprovals(\n formsAppId: number,\n abortSignal?: AbortSignal,\n): Promise<FormSubmissionApprovalsResponse> {\n try {\n return await getRequest<FormSubmissionApprovalsResponse>(\n `${tenants.current.apiOrigin}/forms-apps/${formsAppId}/my-approvals`,\n abortSignal,\n )\n } catch (err) {\n Sentry.captureException(err)\n console.error('Error retrieving form submission approvals', err)\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline and do not have a local copy of this app available, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot view your pending approvals without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this application. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\n/**\n * Get a single FormSubmissionApproval belonging to the given id.\n *\n * #### Example\n *\n * ```js\n * const formSubmissionApprovalId = 'd27966cc-128d-48a2-b681-6ad52012e113'\n * const {\n * formSubmissionApproval,\n * formApprovalFlowInstance,\n * formSubmissionMeta,\n * form,\n * history,\n * } = await approvalsService.getFormSubmissionApproval(\n * formSubmissionApprovalId,\n * )\n * ```\n *\n * @param formSubmissionApprovalId\n * @param abortSignal\n * @returns\n */\nexport async function getFormSubmissionApproval(\n formSubmissionApprovalId: string,\n abortSignal?: AbortSignal,\n): Promise<FormSubmissionApprovalResponse> {\n try {\n const result = await getRequest<FormSubmissionApprovalResponse>(\n `${tenants.current.apiOrigin}/form-submission-approvals/${formSubmissionApprovalId}`,\n abortSignal,\n )\n return result\n } catch (err) {\n Sentry.captureException(err)\n console.error('Error retrieving form submission approval', err)\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline and do not have a local copy of this app available, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot action this pending submission without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this application. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\n/**\n * Update a single FormSubmissionApproval assigned to the current user.\n *\n * #### Example\n *\n * ```js\n * const formSubmissionApproval = {\n * id: 'd27966cc-128d-48a2-b681-6ad52012e113',\n * status: 'APPROVED',\n * username: 'email@example.com',\n * formApprovalFlowInstanceId: 1,\n * notificationEmailAddress: 'email@example.com',\n * notes: 'Great work!!!',\n * internalNotes: 'It was not really that great...',\n * cannedResponseKey: 'my_canned_response_key',\n * createdAt: '2021-02-21T22:57:56.257Z',\n * updatedAt: '2021-02-21T22:57:56.257Z',\n * }\n * const updatedFormSubmissionApproval =\n * await approvalsService.updateFormSubmissionApproval(\n * formSubmissionApproval,\n * )\n * ```\n *\n * @param formSubmissionApproval\n * @param abortSignal\n * @returns\n */\nexport async function updateFormSubmissionApproval(\n formSubmissionApproval: ApprovalTypes.FormSubmissionApproval,\n abortSignal?: AbortSignal,\n): Promise<ApprovalTypes.FormSubmissionApproval> {\n try {\n return await putRequest<ApprovalTypes.FormSubmissionApproval>(\n `${tenants.current.apiOrigin}/form-submission-approvals/${formSubmissionApproval.id}`,\n formSubmissionApproval,\n abortSignal,\n )\n } catch (err) {\n Sentry.captureException(err)\n console.error('Error updating form submission approval', err)\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot action this pending submission without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this application. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404:\n case 409: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\n/**\n * @deprecated Use \"reopenFormApprovalFlowInstance()\" instead\n * @internal\n */\nexport const reopenFormSubmissionApproval = reopenFormApprovalFlowInstance\n\n/**\n * As an administrator, reopen a submission that has been approved or denied.\n *\n * #### Example\n *\n * ```js\n * await approvalsService.reopenFormApprovalFlowInstance({\n * formApprovalFlowInstanceId: 1,\n * notificationEmailAddress: 'email@example.com',\n * notes: 'Great work!!!',\n * internalNotes: 'It was not really that great...',\n * cannedResponseKey: 'my_canned_response_key',\n * })\n * ```\n *\n * @param options\n * @param abortSignal\n * @returns\n */\nexport async function reopenFormApprovalFlowInstance(\n {\n formApprovalFlowInstanceId,\n ...payload\n }: {\n formApprovalFlowInstanceId: number\n notificationEmailAddress: string\n notes: string\n internalNotes?: string\n cannedResponseKey?: string\n },\n abortSignal?: AbortSignal,\n): Promise<ApprovalTypes.FormSubmissionApproval> {\n console.log('Reopening form approval flow instance', {\n formApprovalFlowInstanceId,\n ...payload,\n })\n try {\n return await postRequest<ApprovalTypes.FormSubmissionApproval>(\n `${tenants.current.apiOrigin}/form-approval-flow-instances/${formApprovalFlowInstanceId}/reopen`,\n payload,\n abortSignal,\n )\n } catch (err) {\n console.error('Error reopening form approval flow instance', err)\n Sentry.captureException(err)\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot reopen this approval without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this approval. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404:\n case 409: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\n/**\n * As an administrator, close a submission that has been approved.\n *\n * #### Example\n *\n * ```js\n * await approvalsService.closeFormApprovalFlowInstance({\n * formApprovalFlowInstanceId: 1,\n * notificationEmailAddress: ['email@example.com'],\n * notes: 'Great work!!!',\n * internalNotes: 'It was not really that great...',\n * cannedResponseKey: 'my_canned_response_key',\n * })\n * ```\n *\n * @param options\n * @param abortSignal\n * @returns\n */\nexport async function closeFormApprovalFlowInstance(\n {\n formApprovalFlowInstanceId,\n ...payload\n }: {\n formApprovalFlowInstanceId: number\n notificationEmailAddress?: string[]\n notes?: string\n internalNotes?: string\n cannedResponseKey?: string\n },\n abortSignal?: AbortSignal,\n): Promise<ApprovalTypes.FormSubmissionApproval> {\n console.log('Closing form approval flow instance', {\n formApprovalFlowInstanceId,\n ...payload,\n })\n try {\n return await postRequest<ApprovalTypes.FormSubmissionApproval>(\n `${tenants.current.apiOrigin}/form-approval-flow-instances/${formApprovalFlowInstanceId}/close`,\n payload,\n abortSignal,\n )\n } catch (err) {\n console.log('Error closing form approval flow instance', err)\n Sentry.captureException(err)\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot close this approval without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this approval. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404:\n case 409: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\nexport type FormApprovalFlowResponse = {\n forms: FormTypes.Form[]\n}\n\nexport async function getFormApprovalFlows(\n formsAppId: number,\n abortSignal?: AbortSignal,\n): Promise<FormApprovalFlowResponse> {\n try {\n return await getRequest<FormApprovalFlowResponse>(\n `${tenants.current.apiOrigin}/forms-apps/${formsAppId}/form-approval-flows`,\n abortSignal,\n )\n } catch (err) {\n Sentry.captureException(err)\n console.error('Error retrieving form approval flows', err)\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot access form approval flows without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this application. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\n/**\n * Get an Object containing approvals for the app regardless of approval groups\n * and meta for paging. Must be an Approvals Administrator.\n *\n * #### Example\n *\n * ```js\n * const formsAppId = 1\n * const limit = 50\n * const offset = 0\n * const { approvals, meta } =\n * await approvalsService.getFormSubmissionAdministrationApprovals({\n * formAppId,\n * limit,\n * offset,\n * })\n * ```\n *\n * @param options\n * @param abortSignal\n * @returns\n */\nexport async function getFormSubmissionAdministrationApprovals(\n {\n formsAppId,\n ...rest\n }: {\n formsAppId: number\n formId?: number\n externalId?: string\n submissionId?: string\n formApprovalFlowInstanceId?: number\n submittedAfterDateTime?: string\n submittedBeforeDateTime?: string\n limit: number\n offset: number\n statuses?: string[]\n updatedAfterDateTime?: string\n updatedBeforeDateTime?: string\n lastUpdatedBy?: string[]\n submissionTitle?: string\n },\n abortSignal?: AbortSignal,\n): Promise<FormSubmissionsAdministrationApprovalsResponse> {\n try {\n return await searchRequest<FormSubmissionsAdministrationApprovalsResponse>(\n `${tenants.current.apiOrigin}/forms-apps/${formsAppId}/approvals`,\n {\n ...rest,\n },\n abortSignal,\n )\n } catch (err) {\n Sentry.captureException(err)\n console.error(\n 'Error retrieving administrator form submission approvals',\n err,\n )\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline and do not have a local copy of this app available, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot view approvals without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this application. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\nexport type FormApprovalUsernamesResponse = {\n usernames: Array<{ username: string }>\n}\n/**\n * Get an array containing usernames that have updated approvals in the within\n * the formsAppId associated with the passed `formsAppId`. Must be an Approvals\n * Administrator.\n *\n * #### Example\n *\n * ```js\n * const formsAppId = 1\n * const { usernames } =\n * await approvalsService.getFormApprovalUsernames(formsAppId)\n * ```\n *\n * @param formsAppId\n * @param abortSignal\n * @returns\n */\nexport async function getFormApprovalUsernames(\n formsAppId: number,\n abortSignal?: AbortSignal,\n): Promise<FormApprovalUsernamesResponse> {\n try {\n return await getRequest<FormApprovalUsernamesResponse>(\n `${tenants.current.apiOrigin}/forms-apps/${formsAppId}/approvals/usernames`,\n abortSignal,\n )\n } catch (err) {\n Sentry.captureException(err)\n console.error('Error retrieving form approval usernames', err)\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot access form approval usernames without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this application. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\n/**\n * Create an additional note for a form submission approval.\n *\n * #### Example\n *\n * ```js\n * const formSubmissionApprovalId = 'd96ff812-f263-4a66-868d-e259a1fe4157'\n * const newFormSubmissionApprovalNote = {\n * note: 'this is my note',\n * }\n * const createdFormSubmissionApprovalNote =\n * await approvalsService.createApprovalAdditionalNote({\n * formSubmissionApprovalId,\n * newFormSubmissionApprovalNote,\n * })\n * ```\n *\n * @param options\n * @returns\n */\nexport async function createApprovalAdditionalNote({\n formSubmissionApprovalId,\n newFormSubmissionApprovalNote,\n abortSignal,\n}: {\n formSubmissionApprovalId: string\n newFormSubmissionApprovalNote: ApprovalTypes.NewFormSubmissionApprovalNote\n abortSignal?: AbortSignal\n}): Promise<ApprovalTypes.FormSubmissionApprovalNote> {\n try {\n return await postRequest<ApprovalTypes.FormSubmissionApprovalNote>(\n `${tenants.current.apiOrigin}/form-submission-approvals/${formSubmissionApprovalId}/additional-notes`,\n newFormSubmissionApprovalNote,\n abortSignal,\n )\n } catch (err) {\n console.error('Error creating form submission approval note', err)\n if (abortSignal?.aborted) {\n throw err\n }\n\n Sentry.captureException(err)\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot create additional notes without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this application. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\n/**\n * Update an additional note for a form submission approval.\n *\n * #### Example\n *\n * ```js\n * const formSubmissionApprovalId = 'd96ff812-f263-4a66-868d-e259a1fe4157'\n * const formSubmissionApprovalNote = {\n * id: '1e84dee3-0dc0-4abe-b2cf-d15d62fd9d0b',\n * note: 'this is my note',\n * createdAt: '2022-06-24T03:16:34.696Z',\n * createdBy: {\n * username: 'user@domain.com',\n * },\n * updatedAt: '2022-06-24T03:16:34.696Z',\n * lastUpdatedBy: {\n * username: 'user@domain.com',\n * },\n * }\n * const updatedFormSubmissionApprovalNote =\n * await approvalsService.updateApprovalAdditionalNote({\n * formSubmissionApprovalId,\n * formSubmissionApprovalNote,\n * })\n * ```\n *\n * @param options\n * @returns\n */\nexport async function updateApprovalAdditionalNote({\n formSubmissionApprovalId,\n formSubmissionApprovalNote,\n abortSignal,\n}: {\n formSubmissionApprovalId: string\n formSubmissionApprovalNote: ApprovalTypes.FormSubmissionApprovalNote\n abortSignal?: AbortSignal\n}): Promise<ApprovalTypes.FormSubmissionApprovalNote> {\n try {\n return await putRequest<ApprovalTypes.FormSubmissionApprovalNote>(\n `${tenants.current.apiOrigin}/form-submission-approvals/${formSubmissionApprovalId}/additional-notes/${formSubmissionApprovalNote.id}`,\n formSubmissionApprovalNote,\n abortSignal,\n )\n } catch (err) {\n console.error('Error updating form submission approval note', err)\n if (abortSignal?.aborted) {\n throw err\n }\n\n Sentry.captureException(err)\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot update additional notes without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this application. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\n/**\n * Delete an additional note for a form submission approval.\n *\n * #### Example\n *\n * ```js\n * const formSubmissionApprovalId = 'd96ff812-f263-4a66-868d-e259a1fe4157'\n * const formSubmissionApprovalNoteId = '1e84dee3-0dc0-4abe-b2cf-d15d62fd9d0b',\n * const updatedFormSubmissionApprovalNote =\n * await approvalsService.deleteApprovalAdditionalNote({\n * formSubmissionApprovalId,\n * formSubmissionApprovalNoteId,\n * })\n * ```\n *\n * @param options\n * @returns\n */\nexport async function deleteApprovalAdditionalNote({\n formSubmissionApprovalId,\n formSubmissionApprovalNoteId,\n abortSignal,\n}: {\n formSubmissionApprovalId: string\n formSubmissionApprovalNoteId: string\n abortSignal?: AbortSignal\n}): Promise<void> {\n try {\n return await deleteRequest(\n `${tenants.current.apiOrigin}/form-submission-approvals/${formSubmissionApprovalId}/additional-notes/${formSubmissionApprovalNoteId}`,\n abortSignal,\n )\n } catch (err) {\n console.error('Error updating form submission approval note', err)\n if (abortSignal?.aborted) {\n throw err\n }\n\n Sentry.captureException(err)\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot delete additional notes without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this application. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\n/**\n * Get the status of a single FormSubmissionApproval for the given id.\n *\n * #### Example\n *\n * ```js\n * const formSubmissionApprovalId = 'd27966cc-128d-48a2-b681-6ad52012e113'\n * const { status } =\n * await approvalsService.getFormSubmissionApprovalStatus(\n * formSubmissionApprovalId,\n * )\n * ```\n *\n * @param formSubmissionApprovalId\n * @param abortSignal\n * @returns\n */\nexport async function getFormSubmissionApprovalStatus(\n formSubmissionApprovalId: string,\n abortSignal?: AbortSignal,\n): Promise<{ status: ApprovalTypes.NewFormSubmissionApproval['status'] }> {\n try {\n const result = await getRequest<{\n status: ApprovalTypes.NewFormSubmissionApproval['status']\n }>(\n `${tenants.current.apiOrigin}/form-submission-approvals/${formSubmissionApprovalId}/status`,\n abortSignal,\n )\n return result\n } catch (err) {\n Sentry.captureException(err)\n console.error('Error retrieving form submission approval status', err)\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline and do not have a local copy of this app available, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot action this pending submission without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this application. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\nconst possibleStatuses = [\n {\n label: 'Awaiting Approval',\n value: 'PENDING',\n },\n {\n label: 'Approved',\n value: 'APPROVED',\n },\n {\n label: 'Clarification Requested',\n value: 'CLARIFICATION_REQUIRED',\n },\n {\n label: 'Clarification Received',\n value: 'CLARIFICATION_RECEIVED',\n },\n {\n label: 'Denied',\n value: 'CLOSED',\n },\n]\n\nfunction findLatestFormSubmissionApproval(\n flowInstanceNode: ReturnType<typeof getFormApprovalFlowInstanceNodes>[0],\n formSubmissionApprovals: ApprovalTypes.FormSubmissionApproval[],\n) {\n return formSubmissionApprovals.reduce<\n ApprovalTypes.FormSubmissionApproval | undefined\n >((lastUpdatedFormSubmissionApproval, formSubmissionApproval) => {\n if (\n formSubmissionApproval.stepLabel === flowInstanceNode.label &&\n (!lastUpdatedFormSubmissionApproval ||\n lastUpdatedFormSubmissionApproval.updatedAt <\n formSubmissionApproval.updatedAt)\n ) {\n return formSubmissionApproval\n }\n return lastUpdatedFormSubmissionApproval\n }, undefined)\n}\n\nfunction getFormApprovalFlowInstanceNodes(\n steps: ApprovalTypes.FormApprovalFlowInstanceStep[],\n) {\n return steps.reduce<\n Array<\n ApprovalTypes.FormApprovalFlowInstanceNode &\n Pick<\n ApprovalTypes.FlowInstanceNodeMeta,\n | 'parentStepLabelsId'\n | 'isConcurrentWithPrevious'\n | 'isConcurrentWithNext'\n >\n >\n >((memo, step) => {\n switch (step.type) {\n case 'CONCURRENT': {\n const parentStepLabelsId = step.nodes\n .map(({ label }) => label)\n .join('_')\n for (const node of step.nodes) {\n const index = step.nodes.indexOf(node)\n memo.push({\n ...node,\n parentStepLabelsId,\n isConcurrentWithPrevious: index !== 0,\n isConcurrentWithNext: index < step.nodes.length - 1,\n })\n }\n break\n }\n case 'STANDARD':\n default: {\n memo.push({\n ...step,\n isConcurrentWithPrevious: false,\n isConcurrentWithNext: false,\n parentStepLabelsId: step.label,\n })\n break\n }\n }\n return memo\n }, [])\n}\n\n/**\n * Inputs a form approval flow instance and set of form submission approvals and\n * returns a flattened array of nodes/steps with inlcuded metadata.\n *\n * #### Example\n *\n * ```js\n * const formApprovalFlowInstance = {\n * steps: [\n * {\n * type: 'STANDARD',\n * group: 'oneblink:administrator',\n * isSkipped: false,\n * label: 'Manager Approval',\n * approvalFormId: '1234',\n * },\n * {\n * type: 'CONCURRENT',\n * nodes: [\n * {\n * label: 'HR Review',\n * group: 'oneblink:administrator',\n * isSkipped: false,\n * approvalFormId: '1234',\n * },\n * {\n * label: 'Finance Review',\n * group: 'oneblink:administrator',\n * isSkipped: false,\n * approvalFormId: '1234',\n * },\n * ],\n * },\n * ],\n * }\n *\n * const formSubmissionApprovals = [\n * {\n * id: 'approval1',\n * stepLabel: 'Manager Approval',\n * status: 'APPROVED',\n * createdAt: '2024-03-20T10:00:00Z',\n * updatedAt: '2024-03-20T10:00:00Z',\n * updatedBy: 'fake@fake.com',\n * group: 'oneblink:administrator',\n * approvalFormId: '1234',\n * },\n * ]\n *\n * const nodesWithMeta = getFlowInstanceNodesWithMeta(\n * formApprovalFlowInstance,\n * formSubmissionApprovals,\n * )\n * ```\n *\n * @param formApprovalFlowInstance\n * @param formSubmissionApprovals\n * @returns ApprovalTypes.FlowInstanceNodeWithMeta[]\n */\nexport function getFlowInstanceNodesWithMeta(\n formApprovalFlowInstance: ApprovalTypes.FormApprovalFlowInstance,\n formSubmissionApprovals: ApprovalTypes.FormSubmissionApproval[],\n): ApprovalTypes.FlowInstanceNodeWithMeta[] {\n const formApprovalFlowInstanceNodes = getFormApprovalFlowInstanceNodes(\n formApprovalFlowInstance.steps,\n )\n let isDenied = false\n let isClarificationRequired = false\n return formApprovalFlowInstanceNodes.map((step) => {\n const associatedApproval = findLatestFormSubmissionApproval(\n step,\n formSubmissionApprovals,\n )\n const status = possibleStatuses.find(\n ({ value }) => value === associatedApproval?.status,\n )\n\n let isDeniedInConcurrentStep = false\n let isClarificationRequiredInConcurrentStep = false\n if (status?.value === 'PENDING') {\n const siblingNodes = formApprovalFlowInstanceNodes.filter(\n ({ parentStepLabelsId, label }) =>\n parentStepLabelsId === step.parentStepLabelsId &&\n label !== step.label,\n )\n for (const siblingNode of siblingNodes) {\n const formSubmissionApproval = findLatestFormSubmissionApproval(\n siblingNode,\n formSubmissionApprovals,\n )\n if (formSubmissionApproval?.status === 'CLOSED') {\n isDeniedInConcurrentStep = true\n }\n if (formSubmissionApproval?.status === 'CLARIFICATION_REQUIRED') {\n isClarificationRequiredInConcurrentStep = true\n }\n }\n }\n\n const isAfterDeniedStep = isDenied\n if (status?.value === 'CLOSED') {\n isDenied = true\n }\n\n const isAfterClarificationRequiredStep = isClarificationRequired\n if (status?.value === 'CLARIFICATION_REQUIRED') {\n isClarificationRequired = true\n }\n\n let description = 'Awaiting previous approvals'\n if (step.isSkipped) {\n description = 'Skipped based on form submission'\n } else if (status) {\n const updatedByText = associatedApproval?.updatedBy\n ? ` by ${associatedApproval.updatedBy}`\n : ''\n description = `${status.label}${updatedByText}`\n } else if (isAfterDeniedStep) {\n description = 'Denied in a previous step'\n } else if (isAfterClarificationRequiredStep) {\n description = 'Sent for clarification in a previous step'\n }\n\n return {\n ...step,\n status,\n isDeniedInConcurrentStep,\n isAfterDeniedStep,\n isClarificationRequiredInConcurrentStep,\n isAfterClarificationRequiredStep,\n description,\n }\n })\n}\n"]}
1
+ {"version":3,"file":"approvals-service.js","sourceRoot":"","sources":["../../src/apps/approvals-service.ts"],"names":[],"mappings":"AACA,OAAO,iBAAiB,MAAM,qCAAqC,CAAA;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EACL,aAAa,EACb,UAAU,EACV,UAAU,EACV,aAAa,EACb,WAAW,GAEZ,MAAM,kBAAkB,CAAA;AACzB,OAAO,OAAO,MAAM,WAAW,CAAA;AAC/B,OAAO,MAAM,MAAM,UAAU,CAAA;AA2C7B;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,KAAK,UAAU,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C;aAAM,IAAI,gCAAgC,EAAE,CAAC;YAC5C,WAAW,GAAG,2CAA2C,CAAA;QAC3D,CAAC;QAED,OAAO;YACL,GAAG,IAAI;YACP,MAAM;YACN,wBAAwB;YACxB,iBAAiB;YACjB,uCAAuC;YACvC,gCAAgC;YAChC,WAAW;SACZ,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { SubmissionTypes, ApprovalTypes, FormTypes } from '@oneblink/types'\nimport OneBlinkAppsError from './services/errors/oneBlinkAppsError'\nimport { isOffline } from './offline-service'\nimport {\n deleteRequest,\n getRequest,\n putRequest,\n searchRequest,\n postRequest,\n HTTPError,\n} from './services/fetch'\nimport tenants from './tenants'\nimport Sentry from './Sentry'\n\nexport type FormSubmissionApprovalsResponse = {\n approvals: Array<{\n formSubmissionApproval: ApprovalTypes.FormSubmissionApproval\n formApprovalFlowInstance: ApprovalTypes.FormApprovalFlowInstance\n formSubmissionMeta: SubmissionTypes.FormSubmissionMeta\n latestSuccessfulFormSubmissionPayment:\n | SubmissionTypes.FormSubmissionPayment\n | undefined\n }>\n}\n\nexport type FormApprovalFlowInstanceHistory = {\n formApprovalFlowInstance: ApprovalTypes.FormApprovalFlowInstance\n formSubmissionMeta: SubmissionTypes.FormSubmissionMeta\n formSubmissionMetaEdits: SubmissionTypes.FormSubmissionMetaEdit[]\n formSubmissionApprovals: ApprovalTypes.FormSubmissionApproval[]\n successfulFormSubmissionPayment?: SubmissionTypes.FormSubmissionPayment\n}\n\nexport type FormSubmissionApprovalResponse = {\n formSubmissionMeta: SubmissionTypes.FormSubmissionMeta\n formApprovalFlowInstance: ApprovalTypes.FormApprovalFlowInstance\n formSubmissionApproval: ApprovalTypes.FormSubmissionApproval\n form: FormTypes.Form\n successfulFormSubmissionPayment?: SubmissionTypes.FormSubmissionPayment\n history: FormApprovalFlowInstanceHistory[]\n}\n\nexport type FormSubmissionsAdministrationApprovalsResponse = {\n approvals: Array<\n FormApprovalFlowInstanceHistory & {\n history: Array<FormApprovalFlowInstanceHistory>\n }\n >\n meta: {\n limit: number\n offset: number\n nextOffset?: number\n }\n}\n\n/**\n * Get an Object containing FormSubmissionApprovals assigned to the current user\n * and the Form definitions in those approvals.\n *\n * #### Example\n *\n * ```js\n * const formsAppId = 1\n * const {\n * formSubmissionApprovals,\n * formApprovalFlowInstances,\n * forms,\n * formSubmissionMeta,\n * } = await approvalsService.getFormSubmissionApprovals(formAppId)\n * ```\n *\n * @param formsAppId\n * @param abortSignal\n * @returns\n */\nexport async function getFormSubmissionApprovals(\n formsAppId: number,\n abortSignal?: AbortSignal,\n): Promise<FormSubmissionApprovalsResponse> {\n try {\n return await getRequest<FormSubmissionApprovalsResponse>(\n `${tenants.current.apiOrigin}/forms-apps/${formsAppId}/my-approvals`,\n abortSignal,\n )\n } catch (err) {\n Sentry.captureException(err)\n console.error('Error retrieving form submission approvals', err)\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline and do not have a local copy of this app available, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot view your pending approvals without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this application. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\n/**\n * Get a single FormSubmissionApproval belonging to the given id.\n *\n * #### Example\n *\n * ```js\n * const formSubmissionApprovalId = 'd27966cc-128d-48a2-b681-6ad52012e113'\n * const {\n * formSubmissionApproval,\n * formApprovalFlowInstance,\n * formSubmissionMeta,\n * form,\n * history,\n * } = await approvalsService.getFormSubmissionApproval(\n * formSubmissionApprovalId,\n * )\n * ```\n *\n * @param formSubmissionApprovalId\n * @param abortSignal\n * @returns\n */\nexport async function getFormSubmissionApproval(\n formSubmissionApprovalId: string,\n abortSignal?: AbortSignal,\n): Promise<FormSubmissionApprovalResponse> {\n try {\n const result = await getRequest<FormSubmissionApprovalResponse>(\n `${tenants.current.apiOrigin}/form-submission-approvals/${formSubmissionApprovalId}`,\n abortSignal,\n )\n return result\n } catch (err) {\n Sentry.captureException(err)\n console.error('Error retrieving form submission approval', err)\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline and do not have a local copy of this app available, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot action this pending submission without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this application. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\n/**\n * Update a single FormSubmissionApproval assigned to the current user.\n *\n * #### Example\n *\n * ```js\n * const formSubmissionApproval = {\n * id: 'd27966cc-128d-48a2-b681-6ad52012e113',\n * status: 'APPROVED',\n * username: 'email@example.com',\n * formApprovalFlowInstanceId: 1,\n * notificationEmailAddress: 'email@example.com',\n * notes: 'Great work!!!',\n * internalNotes: 'It was not really that great...',\n * cannedResponseKey: 'my_canned_response_key',\n * createdAt: '2021-02-21T22:57:56.257Z',\n * updatedAt: '2021-02-21T22:57:56.257Z',\n * }\n * const updatedFormSubmissionApproval =\n * await approvalsService.updateFormSubmissionApproval(\n * formSubmissionApproval,\n * )\n * ```\n *\n * @param formSubmissionApproval\n * @param abortSignal\n * @returns\n */\nexport async function updateFormSubmissionApproval(\n formSubmissionApproval: ApprovalTypes.FormSubmissionApproval,\n abortSignal?: AbortSignal,\n): Promise<ApprovalTypes.FormSubmissionApproval> {\n try {\n return await putRequest<ApprovalTypes.FormSubmissionApproval>(\n `${tenants.current.apiOrigin}/form-submission-approvals/${formSubmissionApproval.id}`,\n formSubmissionApproval,\n abortSignal,\n )\n } catch (err) {\n Sentry.captureException(err)\n console.error('Error updating form submission approval', err)\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot action this pending submission without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this application. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404:\n case 409: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\n/**\n * @deprecated Use \"reopenFormApprovalFlowInstance()\" instead\n * @internal\n */\nexport const reopenFormSubmissionApproval = reopenFormApprovalFlowInstance\n\n/**\n * As an administrator, reopen a submission that has been approved or denied.\n *\n * #### Example\n *\n * ```js\n * await approvalsService.reopenFormApprovalFlowInstance({\n * formApprovalFlowInstanceId: 1,\n * notificationEmailAddress: 'email@example.com',\n * notes: 'Great work!!!',\n * internalNotes: 'It was not really that great...',\n * cannedResponseKey: 'my_canned_response_key',\n * })\n * ```\n *\n * @param options\n * @param abortSignal\n * @returns\n */\nexport async function reopenFormApprovalFlowInstance(\n {\n formApprovalFlowInstanceId,\n ...payload\n }: {\n formApprovalFlowInstanceId: number\n notificationEmailAddress: string\n notes: string\n internalNotes?: string\n cannedResponseKey?: string\n },\n abortSignal?: AbortSignal,\n): Promise<ApprovalTypes.FormSubmissionApproval> {\n console.log('Reopening form approval flow instance', {\n formApprovalFlowInstanceId,\n ...payload,\n })\n try {\n return await postRequest<ApprovalTypes.FormSubmissionApproval>(\n `${tenants.current.apiOrigin}/form-approval-flow-instances/${formApprovalFlowInstanceId}/reopen`,\n payload,\n abortSignal,\n )\n } catch (err) {\n console.error('Error reopening form approval flow instance', err)\n Sentry.captureException(err)\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot reopen this approval without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this approval. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404:\n case 409: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\n/**\n * As an administrator, close a submission that has been approved.\n *\n * #### Example\n *\n * ```js\n * await approvalsService.closeFormApprovalFlowInstance({\n * formApprovalFlowInstanceId: 1,\n * notificationEmailAddress: ['email@example.com'],\n * notes: 'Great work!!!',\n * internalNotes: 'It was not really that great...',\n * cannedResponseKey: 'my_canned_response_key',\n * })\n * ```\n *\n * @param options\n * @param abortSignal\n * @returns\n */\nexport async function closeFormApprovalFlowInstance(\n {\n formApprovalFlowInstanceId,\n ...payload\n }: {\n formApprovalFlowInstanceId: number\n notificationEmailAddress?: string[]\n notes?: string\n internalNotes?: string\n cannedResponseKey?: string\n },\n abortSignal?: AbortSignal,\n): Promise<ApprovalTypes.FormSubmissionApproval> {\n console.log('Closing form approval flow instance', {\n formApprovalFlowInstanceId,\n ...payload,\n })\n try {\n return await postRequest<ApprovalTypes.FormSubmissionApproval>(\n `${tenants.current.apiOrigin}/form-approval-flow-instances/${formApprovalFlowInstanceId}/close`,\n payload,\n abortSignal,\n )\n } catch (err) {\n console.log('Error closing form approval flow instance', err)\n Sentry.captureException(err)\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot close this approval without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this approval. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404:\n case 409: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\nexport type FormApprovalFlowResponse = {\n forms: FormTypes.Form[]\n}\n\nexport async function getFormApprovalFlows(\n formsAppId: number,\n abortSignal?: AbortSignal,\n): Promise<FormApprovalFlowResponse> {\n try {\n return await getRequest<FormApprovalFlowResponse>(\n `${tenants.current.apiOrigin}/forms-apps/${formsAppId}/form-approval-flows`,\n abortSignal,\n )\n } catch (err) {\n Sentry.captureException(err)\n console.error('Error retrieving form approval flows', err)\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot access form approval flows without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this application. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\n/**\n * Get an Object containing approvals for the app regardless of approval groups\n * and meta for paging. Must be an Approvals Administrator.\n *\n * #### Example\n *\n * ```js\n * const formsAppId = 1\n * const limit = 50\n * const offset = 0\n * const { approvals, meta } =\n * await approvalsService.getFormSubmissionAdministrationApprovals({\n * formAppId,\n * limit,\n * offset,\n * })\n * ```\n *\n * @param options\n * @param abortSignal\n * @returns\n */\nexport async function getFormSubmissionAdministrationApprovals(\n {\n formsAppId,\n ...rest\n }: {\n formsAppId: number\n formId?: number\n externalId?: string\n submissionId?: string\n formApprovalFlowInstanceId?: number\n submittedAfterDateTime?: string\n submittedBeforeDateTime?: string\n limit: number\n offset: number\n statuses?: string[]\n updatedAfterDateTime?: string\n updatedBeforeDateTime?: string\n lastUpdatedBy?: string[]\n submissionTitle?: string\n },\n abortSignal?: AbortSignal,\n): Promise<FormSubmissionsAdministrationApprovalsResponse> {\n try {\n return await searchRequest<FormSubmissionsAdministrationApprovalsResponse>(\n `${tenants.current.apiOrigin}/forms-apps/${formsAppId}/approvals`,\n {\n ...rest,\n },\n abortSignal,\n )\n } catch (err) {\n Sentry.captureException(err)\n console.error(\n 'Error retrieving administrator form submission approvals',\n err,\n )\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline and do not have a local copy of this app available, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot view approvals without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this application. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\nexport type FormApprovalUsernamesResponse = {\n usernames: Array<{ username: string }>\n}\n/**\n * Get an array containing usernames that have updated approvals in the within\n * the formsAppId associated with the passed `formsAppId`. Must be an Approvals\n * Administrator.\n *\n * #### Example\n *\n * ```js\n * const formsAppId = 1\n * const { usernames } =\n * await approvalsService.getFormApprovalUsernames(formsAppId)\n * ```\n *\n * @param formsAppId\n * @param abortSignal\n * @returns\n */\nexport async function getFormApprovalUsernames(\n formsAppId: number,\n abortSignal?: AbortSignal,\n): Promise<FormApprovalUsernamesResponse> {\n try {\n return await getRequest<FormApprovalUsernamesResponse>(\n `${tenants.current.apiOrigin}/forms-apps/${formsAppId}/approvals/usernames`,\n abortSignal,\n )\n } catch (err) {\n Sentry.captureException(err)\n console.error('Error retrieving form approval usernames', err)\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot access form approval usernames without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this application. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\n/**\n * Create an additional note for a form submission approval.\n *\n * #### Example\n *\n * ```js\n * const formSubmissionApprovalId = 'd96ff812-f263-4a66-868d-e259a1fe4157'\n * const newFormSubmissionApprovalNote = {\n * note: 'this is my note',\n * }\n * const createdFormSubmissionApprovalNote =\n * await approvalsService.createApprovalAdditionalNote({\n * formSubmissionApprovalId,\n * newFormSubmissionApprovalNote,\n * })\n * ```\n *\n * @param options\n * @returns\n */\nexport async function createApprovalAdditionalNote({\n formSubmissionApprovalId,\n newFormSubmissionApprovalNote,\n abortSignal,\n}: {\n formSubmissionApprovalId: string\n newFormSubmissionApprovalNote: ApprovalTypes.NewFormSubmissionApprovalNote\n abortSignal?: AbortSignal\n}): Promise<ApprovalTypes.FormSubmissionApprovalNote> {\n try {\n return await postRequest<ApprovalTypes.FormSubmissionApprovalNote>(\n `${tenants.current.apiOrigin}/form-submission-approvals/${formSubmissionApprovalId}/additional-notes`,\n newFormSubmissionApprovalNote,\n abortSignal,\n )\n } catch (err) {\n console.error('Error creating form submission approval note', err)\n if (abortSignal?.aborted) {\n throw err\n }\n\n Sentry.captureException(err)\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot create additional notes without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this application. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\n/**\n * Update an additional note for a form submission approval.\n *\n * #### Example\n *\n * ```js\n * const formSubmissionApprovalId = 'd96ff812-f263-4a66-868d-e259a1fe4157'\n * const formSubmissionApprovalNote = {\n * id: '1e84dee3-0dc0-4abe-b2cf-d15d62fd9d0b',\n * note: 'this is my note',\n * createdAt: '2022-06-24T03:16:34.696Z',\n * createdBy: {\n * username: 'user@domain.com',\n * },\n * updatedAt: '2022-06-24T03:16:34.696Z',\n * lastUpdatedBy: {\n * username: 'user@domain.com',\n * },\n * }\n * const updatedFormSubmissionApprovalNote =\n * await approvalsService.updateApprovalAdditionalNote({\n * formSubmissionApprovalId,\n * formSubmissionApprovalNote,\n * })\n * ```\n *\n * @param options\n * @returns\n */\nexport async function updateApprovalAdditionalNote({\n formSubmissionApprovalId,\n formSubmissionApprovalNote,\n abortSignal,\n}: {\n formSubmissionApprovalId: string\n formSubmissionApprovalNote: ApprovalTypes.FormSubmissionApprovalNote\n abortSignal?: AbortSignal\n}): Promise<ApprovalTypes.FormSubmissionApprovalNote> {\n try {\n return await putRequest<ApprovalTypes.FormSubmissionApprovalNote>(\n `${tenants.current.apiOrigin}/form-submission-approvals/${formSubmissionApprovalId}/additional-notes/${formSubmissionApprovalNote.id}`,\n formSubmissionApprovalNote,\n abortSignal,\n )\n } catch (err) {\n console.error('Error updating form submission approval note', err)\n if (abortSignal?.aborted) {\n throw err\n }\n\n Sentry.captureException(err)\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot update additional notes without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this application. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\n/**\n * Delete an additional note for a form submission approval.\n *\n * #### Example\n *\n * ```js\n * const formSubmissionApprovalId = 'd96ff812-f263-4a66-868d-e259a1fe4157'\n * const formSubmissionApprovalNoteId = '1e84dee3-0dc0-4abe-b2cf-d15d62fd9d0b',\n * const updatedFormSubmissionApprovalNote =\n * await approvalsService.deleteApprovalAdditionalNote({\n * formSubmissionApprovalId,\n * formSubmissionApprovalNoteId,\n * })\n * ```\n *\n * @param options\n * @returns\n */\nexport async function deleteApprovalAdditionalNote({\n formSubmissionApprovalId,\n formSubmissionApprovalNoteId,\n abortSignal,\n}: {\n formSubmissionApprovalId: string\n formSubmissionApprovalNoteId: string\n abortSignal?: AbortSignal\n}): Promise<void> {\n try {\n return await deleteRequest(\n `${tenants.current.apiOrigin}/form-submission-approvals/${formSubmissionApprovalId}/additional-notes/${formSubmissionApprovalNoteId}`,\n abortSignal,\n )\n } catch (err) {\n console.error('Error updating form submission approval note', err)\n if (abortSignal?.aborted) {\n throw err\n }\n\n Sentry.captureException(err)\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot delete additional notes without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this application. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\n/**\n * Get the status of a single FormSubmissionApproval for the given id.\n *\n * #### Example\n *\n * ```js\n * const formSubmissionApprovalId = 'd27966cc-128d-48a2-b681-6ad52012e113'\n * const { status } =\n * await approvalsService.getFormSubmissionApprovalStatus(\n * formSubmissionApprovalId,\n * )\n * ```\n *\n * @param formSubmissionApprovalId\n * @param abortSignal\n * @returns\n */\nexport async function getFormSubmissionApprovalStatus(\n formSubmissionApprovalId: string,\n abortSignal?: AbortSignal,\n): Promise<{ status: ApprovalTypes.NewFormSubmissionApproval['status'] }> {\n try {\n const result = await getRequest<{\n status: ApprovalTypes.NewFormSubmissionApproval['status']\n }>(\n `${tenants.current.apiOrigin}/form-submission-approvals/${formSubmissionApprovalId}/status`,\n abortSignal,\n )\n return result\n } catch (err) {\n Sentry.captureException(err)\n console.error('Error retrieving form submission approval status', err)\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline and do not have a local copy of this app available, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot action this pending submission without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this application. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\nconst possibleStatuses = [\n {\n label: 'Awaiting Approval',\n value: 'PENDING',\n },\n {\n label: 'Approved',\n value: 'APPROVED',\n },\n {\n label: 'Clarification Requested',\n value: 'CLARIFICATION_REQUIRED',\n },\n {\n label: 'Clarification Received',\n value: 'CLARIFICATION_RECEIVED',\n },\n {\n label: 'Denied',\n value: 'CLOSED',\n },\n]\n\nfunction findLatestFormSubmissionApproval(\n flowInstanceNode: ReturnType<typeof getFormApprovalFlowInstanceNodes>[0],\n formSubmissionApprovals: ApprovalTypes.FormSubmissionApproval[],\n) {\n return formSubmissionApprovals.reduce<\n ApprovalTypes.FormSubmissionApproval | undefined\n >((lastUpdatedFormSubmissionApproval, formSubmissionApproval) => {\n if (\n formSubmissionApproval.stepLabel === flowInstanceNode.label &&\n (!lastUpdatedFormSubmissionApproval ||\n lastUpdatedFormSubmissionApproval.updatedAt <\n formSubmissionApproval.updatedAt)\n ) {\n return formSubmissionApproval\n }\n return lastUpdatedFormSubmissionApproval\n }, undefined)\n}\n\nfunction getFormApprovalFlowInstanceNodes(\n steps: ApprovalTypes.FormApprovalFlowInstanceStep[],\n) {\n return steps.reduce<\n Array<\n ApprovalTypes.FormApprovalFlowInstanceNode &\n Pick<\n ApprovalTypes.FlowInstanceNodeMeta,\n | 'parentStepLabelsId'\n | 'isConcurrentWithPrevious'\n | 'isConcurrentWithNext'\n >\n >\n >((memo, step) => {\n switch (step.type) {\n case 'CONCURRENT': {\n const parentStepLabelsId = step.nodes\n .map(({ label }) => label)\n .join('_')\n for (const node of step.nodes) {\n const index = step.nodes.indexOf(node)\n memo.push({\n ...node,\n parentStepLabelsId,\n isConcurrentWithPrevious: index !== 0,\n isConcurrentWithNext: index < step.nodes.length - 1,\n })\n }\n break\n }\n case 'STANDARD':\n default: {\n memo.push({\n ...step,\n isConcurrentWithPrevious: false,\n isConcurrentWithNext: false,\n parentStepLabelsId: step.label,\n })\n break\n }\n }\n return memo\n }, [])\n}\n\n/**\n * Inputs a form approval flow instance and set of form submission approvals and\n * returns a flattened array of nodes/steps with inlcuded metadata.\n *\n * #### Example\n *\n * ```js\n * const formApprovalFlowInstance = {\n * steps: [\n * {\n * type: 'STANDARD',\n * group: 'oneblink:administrator',\n * isSkipped: false,\n * label: 'Manager Approval',\n * approvalFormId: '1234',\n * },\n * {\n * type: 'CONCURRENT',\n * nodes: [\n * {\n * label: 'HR Review',\n * group: 'oneblink:administrator',\n * isSkipped: false,\n * approvalFormId: '1234',\n * },\n * {\n * label: 'Finance Review',\n * group: 'oneblink:administrator',\n * isSkipped: false,\n * approvalFormId: '1234',\n * },\n * ],\n * },\n * ],\n * }\n *\n * const formSubmissionApprovals = [\n * {\n * id: 'approval1',\n * stepLabel: 'Manager Approval',\n * status: 'APPROVED',\n * createdAt: '2024-03-20T10:00:00Z',\n * updatedAt: '2024-03-20T10:00:00Z',\n * updatedBy: 'fake@fake.com',\n * group: 'oneblink:administrator',\n * approvalFormId: '1234',\n * },\n * ]\n *\n * const nodesWithMeta = getFlowInstanceNodesWithMeta(\n * formApprovalFlowInstance,\n * formSubmissionApprovals,\n * )\n * ```\n *\n * @param formApprovalFlowInstance\n * @param formSubmissionApprovals\n * @returns ApprovalTypes.FlowInstanceNodeWithMeta[]\n */\nexport function getFlowInstanceNodesWithMeta(\n formApprovalFlowInstance: ApprovalTypes.FormApprovalFlowInstance,\n formSubmissionApprovals: ApprovalTypes.FormSubmissionApproval[],\n): ApprovalTypes.FlowInstanceNodeWithMeta[] {\n const formApprovalFlowInstanceNodes = getFormApprovalFlowInstanceNodes(\n formApprovalFlowInstance.steps,\n )\n let isDenied = false\n let isClarificationRequired = false\n return formApprovalFlowInstanceNodes.map((step) => {\n const associatedApproval = findLatestFormSubmissionApproval(\n step,\n formSubmissionApprovals,\n )\n const status = possibleStatuses.find(\n ({ value }) => value === associatedApproval?.status,\n )\n\n let isDeniedInConcurrentStep = false\n let isClarificationRequiredInConcurrentStep = false\n if (status?.value === 'PENDING') {\n const siblingNodes = formApprovalFlowInstanceNodes.filter(\n ({ parentStepLabelsId, label }) =>\n parentStepLabelsId === step.parentStepLabelsId &&\n label !== step.label,\n )\n for (const siblingNode of siblingNodes) {\n const formSubmissionApproval = findLatestFormSubmissionApproval(\n siblingNode,\n formSubmissionApprovals,\n )\n if (formSubmissionApproval?.status === 'CLOSED') {\n isDeniedInConcurrentStep = true\n }\n if (formSubmissionApproval?.status === 'CLARIFICATION_REQUIRED') {\n isClarificationRequiredInConcurrentStep = true\n }\n }\n }\n\n const isAfterDeniedStep = isDenied\n if (status?.value === 'CLOSED') {\n isDenied = true\n }\n\n const isAfterClarificationRequiredStep = isClarificationRequired\n if (status?.value === 'CLARIFICATION_REQUIRED') {\n isClarificationRequired = true\n }\n\n let description = 'Awaiting previous approvals'\n if (step.isSkipped) {\n description = 'Skipped based on form submission'\n } else if (status) {\n const updatedByText = associatedApproval?.updatedBy\n ? ` by ${associatedApproval.updatedBy}`\n : ''\n description = `${status.label}${updatedByText}`\n } else if (isAfterDeniedStep) {\n description = 'Denied in a previous step'\n } else if (isAfterClarificationRequiredStep) {\n description = 'Sent for clarification in a previous step'\n }\n\n return {\n ...step,\n status,\n isDeniedInConcurrentStep,\n isAfterDeniedStep,\n isClarificationRequiredInConcurrentStep,\n isAfterClarificationRequiredStep,\n description,\n }\n })\n}\n"]}
@@ -23,12 +23,13 @@ export declare function uploadFormSubmissionEdit({ submission, definition, submi
23
23
  }): Promise<import("@oneblink/storage/dist/http-handlers/types").OneBlinkResponse<{
24
24
  formSubmissionEditId: string;
25
25
  }>>;
26
- export declare function downloadFormSubmission({ formId, submissionId, abortSignal, versionId, }: {
26
+ export declare function downloadFormSubmission({ formId, submissionId, abortSignal, versionId, asSubmitted, }: {
27
27
  formId: number;
28
28
  submissionId: string;
29
29
  abortSignal?: AbortSignal;
30
30
  versionId?: string;
31
+ asSubmitted?: boolean;
31
32
  }): Promise<{
32
33
  data: SubmissionTypes.S3SubmissionData;
33
- versionId: string;
34
+ versionId: string | undefined;
34
35
  }>;
@@ -127,12 +127,13 @@ export async function uploadFormSubmissionEdit({ submission, definition, submiss
127
127
  throw handleError(error);
128
128
  }
129
129
  }
130
- export async function downloadFormSubmission({ formId, submissionId, abortSignal, versionId, }) {
130
+ export async function downloadFormSubmission({ formId, submissionId, abortSignal, versionId, asSubmitted, }) {
131
131
  try {
132
132
  console.log('Attempting to download form submission data:', {
133
133
  formId,
134
134
  submissionId,
135
135
  versionId,
136
+ asSubmitted,
136
137
  });
137
138
  const oneblinkDownloader = generateOneBlinkDownloader();
138
139
  const result = await oneblinkDownloader.downloadSubmission({
@@ -140,17 +141,13 @@ export async function downloadFormSubmission({ formId, submissionId, abortSignal
140
141
  submissionId,
141
142
  abortSignal,
142
143
  versionId,
144
+ asSubmitted,
143
145
  });
144
146
  if (!result) {
145
147
  throw new OneBlinkAppsError("This submission has been removed based on your administrator's retention policy.", {
146
148
  title: 'Submission Data Unavailable',
147
149
  });
148
150
  }
149
- if (!result.versionId) {
150
- throw new OneBlinkAppsError('The submission version could not be determined. Please reload and try again.', {
151
- title: 'Submission Version Unavailable',
152
- });
153
- }
154
151
  return {
155
152
  data: result.data,
156
153
  versionId: result.versionId,
@@ -1 +1 @@
1
- {"version":3,"file":"submissions.js","sourceRoot":"","sources":["../../../../src/apps/services/api/submissions.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,MAAM,6BAA6B,CAAA;AAC3D,OAAO,MAAM,MAAM,cAAc,CAAA;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAE9D,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,wBAAwB,MAAM,6BAA6B,CAAA;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;AACxD,OAAO,0BAA0B,MAAM,+BAA+B,CAAA;AAGtE,MAAM,kBAAkB,GAAG,CAAC,KAA2B,EAAE,EAAE;IACzD,OAAO,IAAI,iBAAiB,CAAC,KAAK,CAAC,OAAO,EAAE;QAC1C,KAAK,EAAE,oBAAoB;QAC3B,cAAc,EAAE,KAAK,CAAC,cAAc;KACrC,CAAC,CAAA;AACJ,CAAC,CAAA;AACD,MAAM,uBAAuB,GAAG,CAAC,KAA2B,EAAE,EAAE;IAC9D,OAAO,IAAI,iBAAiB,CAC1B,8FAA8F,EAC9F;QACE,aAAa,EAAE,IAAI;QACnB,aAAa,EAAE,KAAK;QACpB,cAAc,EAAE,KAAK,CAAC,cAAc;KACrC,CACF,CAAA;AACH,CAAC,CAAA;AACD,MAAM,oBAAoB,GAAG,CAAC,KAA2B,EAAE,EAAE;IAC3D,OAAO,IAAI,iBAAiB,CAC1B,sHAAsH,EACtH;QACE,qBAAqB,EAAE,IAAI;QAC3B,aAAa,EAAE,KAAK;QACpB,cAAc,EAAE,KAAK,CAAC,cAAc;KACrC,CACF,CAAA;AACH,CAAC,CAAA;AACD,MAAM,gBAAgB,GAAG,CAAC,KAA2B,EAAE,EAAE;I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AAK,CAAC,OAAO,EAAE;wBACzC,KAAK,EAAE,iBAAiB;wBACxB,cAAc,EAAE,KAAK,CAAC,cAAc;qBACrC,CAAC,CAAA;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;QAED,MAAM,IAAI,iBAAiB,CACzB,gFAAgF,EAChF;YACE,aAAa,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;YACzD,cAAc,EACZ,KAAK,YAAY,oBAAoB;gBACnC,CAAC,CAAC,KAAK,CAAC,cAAc;gBACtB,CAAC,CAAC,SAAS;SAChB,CACF,CAAA;IACH,CAAC;AACH,CAAC","sourcesContent":["import OneBlinkAppsError from '../errors/oneBlinkAppsError'\nimport Sentry from '../../Sentry'\nimport { isOffline } from '../../offline-service'\nimport { getDeviceInformation } from '../getDeviceInformation'\nimport { FormSubmission, ProgressListener } from '../../types/submissions'\nimport { getUserToken } from '../user-token'\nimport generateOneBlinkUploader from '../generateOneBlinkUploader'\nimport { OneBlinkStorageError } from '@oneblink/storage'\nimport generateOneBlinkDownloader from '../generateOneBlinkDownloader'\nimport { FormTypes, SubmissionTypes } from '@oneblink/types'\n\nconst getBadRequestError = (error: OneBlinkStorageError) => {\n return new OneBlinkAppsError(error.message, {\n title: 'Invalid Submission',\n httpStatusCode: error.httpStatusCode,\n })\n}\nconst getUnauthenticatedError = (error: OneBlinkStorageError) => {\n return new OneBlinkAppsError(\n 'The form you are attempting to complete requires authentication. Please login and try again.',\n {\n requiresLogin: true,\n originalError: error,\n httpStatusCode: error.httpStatusCode,\n },\n )\n}\nconst getUnauthorisedError = (error: OneBlinkStorageError) => {\n return new OneBlinkAppsError(\n 'You do not have access to complete this form. Please contact your administrator to gain the correct level of access.',\n {\n requiresAccessRequest: true,\n originalError: error,\n httpStatusCode: error.httpStatusCode,\n },\n )\n}\nconst getNotFoundError = (error: OneBlinkStorageError) => {\n return new OneBlinkAppsError(\n 'We could not find the form you are looking for. Please contact your administrator to ensure your form configuration has been completed successfully.',\n {\n title: 'Unknown Form',\n originalError: error,\n httpStatusCode: error.httpStatusCode,\n },\n )\n}\nconst getDefaultError = (error: OneBlinkStorageError) => {\n return new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.httpStatusCode,\n },\n )\n}\n\nconst handleError = (error: OneBlinkStorageError) => {\n if (/Failed to fetch/.test((error as Error).message)) {\n throw new OneBlinkAppsError(\n 'We encountered a network related issue. Please ensure you are connected to the internet before trying again. If the problem persists, contact your administrator.',\n {\n title: 'Connectivity Issues',\n originalError: error as Error,\n isOffline: true,\n },\n )\n }\n switch (error.httpStatusCode) {\n case 400: {\n return getBadRequestError(error)\n }\n case 401: {\n return getUnauthenticatedError(error)\n }\n case 403: {\n return getUnauthorisedError(error)\n }\n case 404: {\n return getNotFoundError(error)\n }\n case 409: {\n return new OneBlinkAppsError(error.message, {\n originalError: error,\n httpStatusCode: error.httpStatusCode,\n conflict: error.conflict,\n })\n }\n default: {\n return getDefaultError(error)\n }\n }\n}\n\nexport async function uploadFormSubmission(\n formSubmission: FormSubmission,\n /**\n * The date and time (in ISO format) the form was completed I.e. when the user\n * clicked the submit button\n */\n completionTimestamp: string,\n onProgress?: ProgressListener,\n abortSignal?: AbortSignal,\n) {\n try {\n const oneblinkUploader = generateOneBlinkUploader()\n\n const userToken = getUserToken()\n\n console.log('Uploading submission')\n return await oneblinkUploader.uploadSubmission({\n completionTimestamp,\n submission: formSubmission.submission,\n definition: formSubmission.definition,\n device: getDeviceInformation(),\n userToken: userToken || undefined,\n previousFormSubmissionApprovalId:\n formSubmission.previousFormSubmissionApprovalId,\n jobId: formSubmission.jobId || undefined,\n formsAppId: formSubmission.formsAppId,\n externalId: formSubmission.externalId || undefined,\n taskId: formSubmission.taskCompletion?.task.taskId || undefined,\n taskActionId: formSubmission.taskCompletion?.taskAction.taskActionId,\n taskGroupInstanceId:\n formSubmission.taskCompletion?.taskGroupInstance?.taskGroupInstanceId,\n taskCompletionTimestamp: formSubmission.taskCompletion?.completedAt,\n taskIsAdhoc: formSubmission.taskCompletion?.isAdhoc,\n recaptchas: formSubmission.recaptchas,\n onProgress,\n abortSignal,\n formSubmissionDraftId: formSubmission.formSubmissionDraftId,\n })\n } catch (error) {\n throw handleError(error as OneBlinkStorageError)\n }\n}\n\nexport async function uploadFormSubmissionEdit({\n submission,\n definition,\n submissionId,\n context,\n editedS3ObjectVersionId,\n onProgress,\n abortSignal,\n}: {\n submission: SubmissionTypes.NewS3SubmissionData['submission']\n definition: FormTypes.Form\n submissionId: string\n context: SubmissionTypes.FormSubmissionMetaEditContext\n editedS3ObjectVersionId: string\n onProgress?: ProgressListener\n abortSignal?: AbortSignal\n}) {\n try {\n const oneblinkUploader = generateOneBlinkUploader()\n return await oneblinkUploader.uploadFormSubmissionEdit({\n submission,\n definition,\n device: getDeviceInformation(),\n completionTimestamp: new Date().toISOString(),\n submissionId,\n context,\n editedS3ObjectVersionId,\n onProgress,\n abortSignal,\n })\n } catch (error) {\n throw handleError(error as OneBlinkStorageError)\n }\n}\n\nexport async function downloadFormSubmission({\n formId,\n submissionId,\n abortSignal,\n versionId,\n}: {\n formId: number\n submissionId: string\n abortSignal?: AbortSignal\n versionId?: string\n}) {\n try {\n console.log('Attempting to download form submission data:', {\n formId,\n submissionId,\n versionId,\n })\n const oneblinkDownloader = generateOneBlinkDownloader()\n const result = await oneblinkDownloader.downloadSubmission({\n formId,\n submissionId,\n abortSignal,\n versionId,\n })\n if (!result) {\n throw new OneBlinkAppsError(\n \"This submission has been removed based on your administrator's retention policy.\",\n {\n title: 'Submission Data Unavailable',\n },\n )\n }\n if (!result.versionId) {\n throw new OneBlinkAppsError(\n 'The submission version could not be determined. Please reload and try again.',\n {\n title: 'Submission Version Unavailable',\n },\n )\n }\n return {\n data: result.data,\n versionId: result.versionId,\n }\n } catch (error) {\n console.error('Error retrieving form submission data', error)\n\n if (error instanceof OneBlinkAppsError) {\n throw error\n }\n\n Sentry.captureException(error)\n\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline, please connect to the internet and try again',\n {\n originalError: error instanceof Error ? error : undefined,\n isOffline: true,\n },\n )\n }\n\n if (error instanceof OneBlinkStorageError) {\n switch (error.httpStatusCode) {\n case 401: {\n throw new OneBlinkAppsError(\n 'The submission you are attempting to view requires authentication. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.httpStatusCode,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to submission data. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.httpStatusCode,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.httpStatusCode,\n })\n }\n }\n }\n\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error instanceof Error ? error : undefined,\n httpStatusCode:\n error instanceof OneBlinkStorageError\n ? error.httpStatusCode\n : undefined,\n },\n )\n }\n}\n"]}
1
+ {"version":3,"file":"submissions.js","sourceRoot":"","sources":["../../../../src/apps/services/api/submissions.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,MAAM,6BAA6B,CAAA;AAC3D,OAAO,MAAM,MAAM,cAAc,CAAA;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAE9D,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,wBAAwB,MAAM,6BAA6B,CAAA;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;AACxD,OAAO,0BAA0B,MAAM,+BAA+B,CAAA;AAGtE,MAAM,kBAAkB,GAAG,CAAC,KAA2B,EAAE,EAAE;IACzD,OAAO,IAAI,iBAAiB,CAAC,KAAK,CAAC,OAAO,EAA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,CAAC,CAAC,CAAC;oBACT,MAAM,IAAI,iBAAiB,CACzB,gGAAgG,EAChG;wBACE,aAAa,EAAE,KAAK;wBACpB,aAAa,EAAE,IAAI;wBACnB,cAAc,EAAE,KAAK,CAAC,cAAc;qBACrC,CACF,CAAA;gBACH,CAAC;gBACD,KAAK,GAAG,CAAC,CAAC,CAAC;oBACT,MAAM,IAAI,iBAAiB,CACzB,mHAAmH,EACnH;wBACE,aAAa,EAAE,KAAK;wBACpB,qBAAqB,EAAE,IAAI;wBAC3B,cAAc,EAAE,KAAK,CAAC,cAAc;qBACrC,CACF,CAAA;gBACH,CAAC;gBACD,KAAK,GAAG,CAAC;gBACT,KAAK,GAAG,CAAC,CAAC,CAAC;oBACT,MAAM,IAAI,iBAAiB,CAAC,KAAK,CAAC,OAAO,EAAE;wBACzC,KAAK,EAAE,iBAAiB;wBACxB,cAAc,EAAE,KAAK,CAAC,cAAc;qBACrC,CAAC,CAAA;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;QAED,MAAM,IAAI,iBAAiB,CACzB,gFAAgF,EAChF;YACE,aAAa,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;YACzD,cAAc,EACZ,KAAK,YAAY,oBAAoB;gBACnC,CAAC,CAAC,KAAK,CAAC,cAAc;gBACtB,CAAC,CAAC,SAAS;SAChB,CACF,CAAA;IACH,CAAC;AACH,CAAC","sourcesContent":["import OneBlinkAppsError from '../errors/oneBlinkAppsError'\nimport Sentry from '../../Sentry'\nimport { isOffline } from '../../offline-service'\nimport { getDeviceInformation } from '../getDeviceInformation'\nimport { FormSubmission, ProgressListener } from '../../types/submissions'\nimport { getUserToken } from '../user-token'\nimport generateOneBlinkUploader from '../generateOneBlinkUploader'\nimport { OneBlinkStorageError } from '@oneblink/storage'\nimport generateOneBlinkDownloader from '../generateOneBlinkDownloader'\nimport { FormTypes, SubmissionTypes } from '@oneblink/types'\n\nconst getBadRequestError = (error: OneBlinkStorageError) => {\n return new OneBlinkAppsError(error.message, {\n title: 'Invalid Submission',\n httpStatusCode: error.httpStatusCode,\n })\n}\nconst getUnauthenticatedError = (error: OneBlinkStorageError) => {\n return new OneBlinkAppsError(\n 'The form you are attempting to complete requires authentication. Please login and try again.',\n {\n requiresLogin: true,\n originalError: error,\n httpStatusCode: error.httpStatusCode,\n },\n )\n}\nconst getUnauthorisedError = (error: OneBlinkStorageError) => {\n return new OneBlinkAppsError(\n 'You do not have access to complete this form. Please contact your administrator to gain the correct level of access.',\n {\n requiresAccessRequest: true,\n originalError: error,\n httpStatusCode: error.httpStatusCode,\n },\n )\n}\nconst getNotFoundError = (error: OneBlinkStorageError) => {\n return new OneBlinkAppsError(\n 'We could not find the form you are looking for. Please contact your administrator to ensure your form configuration has been completed successfully.',\n {\n title: 'Unknown Form',\n originalError: error,\n httpStatusCode: error.httpStatusCode,\n },\n )\n}\nconst getDefaultError = (error: OneBlinkStorageError) => {\n return new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.httpStatusCode,\n },\n )\n}\n\nconst handleError = (error: OneBlinkStorageError) => {\n if (/Failed to fetch/.test((error as Error).message)) {\n throw new OneBlinkAppsError(\n 'We encountered a network related issue. Please ensure you are connected to the internet before trying again. If the problem persists, contact your administrator.',\n {\n title: 'Connectivity Issues',\n originalError: error as Error,\n isOffline: true,\n },\n )\n }\n switch (error.httpStatusCode) {\n case 400: {\n return getBadRequestError(error)\n }\n case 401: {\n return getUnauthenticatedError(error)\n }\n case 403: {\n return getUnauthorisedError(error)\n }\n case 404: {\n return getNotFoundError(error)\n }\n case 409: {\n return new OneBlinkAppsError(error.message, {\n originalError: error,\n httpStatusCode: error.httpStatusCode,\n conflict: error.conflict,\n })\n }\n default: {\n return getDefaultError(error)\n }\n }\n}\n\nexport async function uploadFormSubmission(\n formSubmission: FormSubmission,\n /**\n * The date and time (in ISO format) the form was completed I.e. when the user\n * clicked the submit button\n */\n completionTimestamp: string,\n onProgress?: ProgressListener,\n abortSignal?: AbortSignal,\n) {\n try {\n const oneblinkUploader = generateOneBlinkUploader()\n\n const userToken = getUserToken()\n\n console.log('Uploading submission')\n return await oneblinkUploader.uploadSubmission({\n completionTimestamp,\n submission: formSubmission.submission,\n definition: formSubmission.definition,\n device: getDeviceInformation(),\n userToken: userToken || undefined,\n previousFormSubmissionApprovalId:\n formSubmission.previousFormSubmissionApprovalId,\n jobId: formSubmission.jobId || undefined,\n formsAppId: formSubmission.formsAppId,\n externalId: formSubmission.externalId || undefined,\n taskId: formSubmission.taskCompletion?.task.taskId || undefined,\n taskActionId: formSubmission.taskCompletion?.taskAction.taskActionId,\n taskGroupInstanceId:\n formSubmission.taskCompletion?.taskGroupInstance?.taskGroupInstanceId,\n taskCompletionTimestamp: formSubmission.taskCompletion?.completedAt,\n taskIsAdhoc: formSubmission.taskCompletion?.isAdhoc,\n recaptchas: formSubmission.recaptchas,\n onProgress,\n abortSignal,\n formSubmissionDraftId: formSubmission.formSubmissionDraftId,\n })\n } catch (error) {\n throw handleError(error as OneBlinkStorageError)\n }\n}\n\nexport async function uploadFormSubmissionEdit({\n submission,\n definition,\n submissionId,\n context,\n editedS3ObjectVersionId,\n onProgress,\n abortSignal,\n}: {\n submission: SubmissionTypes.NewS3SubmissionData['submission']\n definition: FormTypes.Form\n submissionId: string\n context: SubmissionTypes.FormSubmissionMetaEditContext\n editedS3ObjectVersionId: string\n onProgress?: ProgressListener\n abortSignal?: AbortSignal\n}) {\n try {\n const oneblinkUploader = generateOneBlinkUploader()\n return await oneblinkUploader.uploadFormSubmissionEdit({\n submission,\n definition,\n device: getDeviceInformation(),\n completionTimestamp: new Date().toISOString(),\n submissionId,\n context,\n editedS3ObjectVersionId,\n onProgress,\n abortSignal,\n })\n } catch (error) {\n throw handleError(error as OneBlinkStorageError)\n }\n}\n\nexport async function downloadFormSubmission({\n formId,\n submissionId,\n abortSignal,\n versionId,\n asSubmitted,\n}: {\n formId: number\n submissionId: string\n abortSignal?: AbortSignal\n versionId?: string\n asSubmitted?: boolean\n}) {\n try {\n console.log('Attempting to download form submission data:', {\n formId,\n submissionId,\n versionId,\n asSubmitted,\n })\n const oneblinkDownloader = generateOneBlinkDownloader()\n const result = await oneblinkDownloader.downloadSubmission({\n formId,\n submissionId,\n abortSignal,\n versionId,\n asSubmitted,\n })\n if (!result) {\n throw new OneBlinkAppsError(\n \"This submission has been removed based on your administrator's retention policy.\",\n {\n title: 'Submission Data Unavailable',\n },\n )\n }\n return {\n data: result.data,\n versionId: result.versionId,\n }\n } catch (error) {\n console.error('Error retrieving form submission data', error)\n\n if (error instanceof OneBlinkAppsError) {\n throw error\n }\n\n Sentry.captureException(error)\n\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline, please connect to the internet and try again',\n {\n originalError: error instanceof Error ? error : undefined,\n isOffline: true,\n },\n )\n }\n\n if (error instanceof OneBlinkStorageError) {\n switch (error.httpStatusCode) {\n case 401: {\n throw new OneBlinkAppsError(\n 'The submission you are attempting to view requires authentication. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.httpStatusCode,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to submission data. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.httpStatusCode,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.httpStatusCode,\n })\n }\n }\n }\n\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error instanceof Error ? error : undefined,\n httpStatusCode:\n error instanceof OneBlinkStorageError\n ? error.httpStatusCode\n : undefined,\n },\n )\n }\n}\n"]}
@@ -214,17 +214,23 @@ declare function executePostSubmissionAction(submissionResult: FormSubmissionRes
214
214
  * })
215
215
  * ```
216
216
  *
217
- * @param formId
218
- * @param submissionId
219
- * @param abortSignal
217
+ * @param options
218
+ * @param options.formId
219
+ * @param options.submissionId
220
+ * @param options.abortSignal
221
+ * @param options.versionId
222
+ * @param options.asSubmitted
220
223
  * @returns
221
224
  */
222
- declare function getSubmissionData({ formId, submissionId, abortSignal, }: {
225
+ declare function getSubmissionData({ formId, submissionId, abortSignal, versionId, asSubmitted, }: {
223
226
  formId: number;
224
227
  submissionId: string;
225
228
  abortSignal?: AbortSignal;
229
+ versionId?: string;
230
+ /** Download the submission data as it was originally submitted. */
231
+ asSubmitted?: boolean;
226
232
  }): Promise<{
227
233
  data: SubmissionTypes.S3SubmissionData;
228
- versionId: string;
234
+ versionId: string | undefined;
229
235
  }>;
230
236
  export { submit, executePostSubmissionAction, executeCancelAction, goBackOrCloseWindow, getPendingQueueSubmissions, deletePendingQueueSubmission, editPendingQueueSubmission, cancelEditingPendingQueueSubmission, registerPendingQueueListener, processPendingQueue, BaseFormSubmission, NewDraftSubmission, NewFormSubmission, DraftSubmissionInput, DraftSubmission, FormSubmission, FormSubmissionResult, PendingFormSubmission, SubmissionParams, registerPendingQueueAttachmentProgressListener, registerPendingQueueProgressListener, ProgressListener, ProgressListenerEvent, PendingQueueListener, PendingQueueAction, getSubmissionData, uploadFormSubmissionEdit, getPostSubmissionAttachments, };
@@ -409,16 +409,21 @@ async function executeAction(submissionResult, { action, redirectUrl, onRedirect
409
409
  * })
410
410
  * ```
411
411
  *
412
- * @param formId
413
- * @param submissionId
414
- * @param abortSignal
412
+ * @param options
413
+ * @param options.formId
414
+ * @param options.submissionId
415
+ * @param options.abortSignal
416
+ * @param options.versionId
417
+ * @param options.asSubmitted
415
418
  * @returns
416
419
  */
417
- async function getSubmissionData({ formId, submissionId, abortSignal, }) {
420
+ async function getSubmissionData({ formId, submissionId, abortSignal, versionId, asSubmitted, }) {
418
421
  return await downloadFormSubmission({
419
422
  formId,
420
423
  submissionId,
421
424
  abortSignal,
425
+ versionId,
426
+ asSubmitted,
422
427
  });
423
428
  }
424
429
  export { submit, executePostSubmissionAction, executeCancelAction, goBackOrCloseWindow, getPendingQueueSubmissions, deletePendingQueueSubmission, editPendingQueueSubmission, cancelEditingPendingQueueSubmission, registerPendingQueueListener, processPendingQueue, registerPendingQueueAttachmentProgressListener, registerPendingQueueProgressListener, getSubmissionData, uploadFormSubmissionEdit, getPostSubmissionAttachments, };