@oneblink/apps-react 9.0.0-beta.1 → 9.0.0-beta.3

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 (208) hide show
  1. package/dist/OneBlinkForm.d.ts +6 -6
  2. package/dist/OneBlinkFormBase.js +1 -0
  3. package/dist/OneBlinkFormBase.js.map +1 -1
  4. package/dist/apps/Sentry.d.ts +7 -0
  5. package/dist/apps/Sentry.js +16 -0
  6. package/dist/apps/Sentry.js.map +1 -0
  7. package/dist/apps/approvals-service.d.ts +390 -0
  8. package/dist/apps/approvals-service.js +987 -0
  9. package/dist/apps/approvals-service.js.map +1 -0
  10. package/dist/apps/attachments-service.d.ts +49 -0
  11. package/dist/apps/attachments-service.js +134 -0
  12. package/dist/apps/attachments-service.js.map +1 -0
  13. package/dist/apps/auth-service.d.ts +114 -0
  14. package/dist/apps/auth-service.js +194 -0
  15. package/dist/apps/auth-service.js.map +1 -0
  16. package/dist/apps/auto-save-service.d.ts +82 -0
  17. package/dist/apps/auto-save-service.js +105 -0
  18. package/dist/apps/auto-save-service.js.map +1 -0
  19. package/dist/apps/draft-service.d.ts +148 -0
  20. package/dist/apps/draft-service.js +583 -0
  21. package/dist/apps/draft-service.js.map +1 -0
  22. package/dist/apps/form-service.d.ts +204 -0
  23. package/dist/apps/form-service.js +718 -0
  24. package/dist/apps/form-service.js.map +1 -0
  25. package/dist/apps/form-store-service.d.ts +141 -0
  26. package/dist/apps/form-store-service.js +114 -0
  27. package/dist/apps/form-store-service.js.map +1 -0
  28. package/dist/apps/forms-app-environment-service.d.ts +19 -0
  29. package/dist/apps/forms-app-environment-service.js +55 -0
  30. package/dist/apps/forms-app-environment-service.js.map +1 -0
  31. package/dist/apps/forms-app-service.d.ts +18 -0
  32. package/dist/apps/forms-app-service.js +53 -0
  33. package/dist/apps/forms-app-service.js.map +1 -0
  34. package/dist/apps/index.d.ts +252 -0
  35. package/dist/apps/index.js +254 -0
  36. package/dist/apps/index.js.map +1 -0
  37. package/dist/apps/job-service.d.ts +20 -0
  38. package/dist/apps/job-service.js +95 -0
  39. package/dist/apps/job-service.js.map +1 -0
  40. package/dist/apps/localisation-service.d.ts +207 -0
  41. package/dist/apps/localisation-service.js +321 -0
  42. package/dist/apps/localisation-service.js.map +1 -0
  43. package/dist/apps/notification-service.d.ts +83 -0
  44. package/dist/apps/notification-service.js +315 -0
  45. package/dist/apps/notification-service.js.map +1 -0
  46. package/dist/apps/offline-service.d.ts +18 -0
  47. package/dist/apps/offline-service.js +25 -0
  48. package/dist/apps/offline-service.js.map +1 -0
  49. package/dist/apps/payment-service.d.ts +110 -0
  50. package/dist/apps/payment-service.js +182 -0
  51. package/dist/apps/payment-service.js.map +1 -0
  52. package/dist/apps/prefill-service.d.ts +14 -0
  53. package/dist/apps/prefill-service.js +19 -0
  54. package/dist/apps/prefill-service.js.map +1 -0
  55. package/dist/apps/scheduled-tasks-service.d.ts +127 -0
  56. package/dist/apps/scheduled-tasks-service.js +240 -0
  57. package/dist/apps/scheduled-tasks-service.js.map +1 -0
  58. package/dist/apps/scheduling-service.d.ts +101 -0
  59. package/dist/apps/scheduling-service.js +171 -0
  60. package/dist/apps/scheduling-service.js.map +1 -0
  61. package/dist/apps/services/AWSCognitoClient.d.ts +55 -0
  62. package/dist/apps/services/AWSCognitoClient.js +436 -0
  63. package/dist/apps/services/AWSCognitoClient.js.map +1 -0
  64. package/dist/apps/services/api/drafts.d.ts +7 -0
  65. package/dist/apps/services/api/drafts.js +236 -0
  66. package/dist/apps/services/api/drafts.js.map +1 -0
  67. package/dist/apps/services/api/notifications.d.ts +3 -0
  68. package/dist/apps/services/api/notifications.js +60 -0
  69. package/dist/apps/services/api/notifications.js.map +1 -0
  70. package/dist/apps/services/api/payment.d.ts +23 -0
  71. package/dist/apps/services/api/payment.js +235 -0
  72. package/dist/apps/services/api/payment.js.map +1 -0
  73. package/dist/apps/services/api/post-submission-attachment-urls.d.ts +7 -0
  74. package/dist/apps/services/api/post-submission-attachment-urls.js +19 -0
  75. package/dist/apps/services/api/post-submission-attachment-urls.js.map +1 -0
  76. package/dist/apps/services/api/prefill.d.ts +1 -0
  77. package/dist/apps/services/api/prefill.js +70 -0
  78. package/dist/apps/services/api/prefill.js.map +1 -0
  79. package/dist/apps/services/api/receipt-id.d.ts +2 -0
  80. package/dist/apps/services/api/receipt-id.js +54 -0
  81. package/dist/apps/services/api/receipt-id.js.map +1 -0
  82. package/dist/apps/services/api/scheduling.d.ts +38 -0
  83. package/dist/apps/services/api/scheduling.js +142 -0
  84. package/dist/apps/services/api/scheduling.js.map +1 -0
  85. package/dist/apps/services/api/submissions.d.ts +18 -0
  86. package/dist/apps/services/api/submissions.js +166 -0
  87. package/dist/apps/services/api/submissions.js.map +1 -0
  88. package/dist/apps/services/cognito.d.ts +302 -0
  89. package/dist/apps/services/cognito.js +441 -0
  90. package/dist/apps/services/cognito.js.map +1 -0
  91. package/dist/apps/services/draft-data-store.d.ts +16 -0
  92. package/dist/apps/services/draft-data-store.js +115 -0
  93. package/dist/apps/services/draft-data-store.js.map +1 -0
  94. package/dist/apps/services/errors/oneBlinkAppsError.d.ts +35 -0
  95. package/dist/apps/services/errors/oneBlinkAppsError.js +32 -0
  96. package/dist/apps/services/errors/oneBlinkAppsError.js.map +1 -0
  97. package/dist/apps/services/external-id-generation.d.ts +4 -0
  98. package/dist/apps/services/external-id-generation.js +59 -0
  99. package/dist/apps/services/external-id-generation.js.map +1 -0
  100. package/dist/apps/services/fetch.d.ts +12 -0
  101. package/dist/apps/services/fetch.js +95 -0
  102. package/dist/apps/services/fetch.js.map +1 -0
  103. package/dist/apps/services/forms-key.d.ts +51 -0
  104. package/dist/apps/services/forms-key.js +83 -0
  105. package/dist/apps/services/forms-key.js.map +1 -0
  106. package/dist/apps/services/generate-generic-error.d.ts +3 -0
  107. package/dist/apps/services/generate-generic-error.js +52 -0
  108. package/dist/apps/services/generate-generic-error.js.map +1 -0
  109. package/dist/apps/services/generateOneBlinkDownloader.d.ts +2 -0
  110. package/dist/apps/services/generateOneBlinkDownloader.js +11 -0
  111. package/dist/apps/services/generateOneBlinkDownloader.js.map +1 -0
  112. package/dist/apps/services/generateOneBlinkUploader.d.ts +2 -0
  113. package/dist/apps/services/generateOneBlinkUploader.js +11 -0
  114. package/dist/apps/services/generateOneBlinkUploader.js.map +1 -0
  115. package/dist/apps/services/getDeviceInformation.d.ts +17 -0
  116. package/dist/apps/services/getDeviceInformation.js +38 -0
  117. package/dist/apps/services/getDeviceInformation.js.map +1 -0
  118. package/dist/apps/services/integration-elements.d.ts +383 -0
  119. package/dist/apps/services/integration-elements.js +761 -0
  120. package/dist/apps/services/integration-elements.js.map +1 -0
  121. package/dist/apps/services/job-prefill.d.ts +40 -0
  122. package/dist/apps/services/job-prefill.js +78 -0
  123. package/dist/apps/services/job-prefill.js.map +1 -0
  124. package/dist/apps/services/payment-providers/BPOINTPaymentProvider.d.ts +29 -0
  125. package/dist/apps/services/payment-providers/BPOINTPaymentProvider.js +59 -0
  126. package/dist/apps/services/payment-providers/BPOINTPaymentProvider.js.map +1 -0
  127. package/dist/apps/services/payment-providers/CPPayPaymentProvider.d.ts +27 -0
  128. package/dist/apps/services/payment-providers/CPPayPaymentProvider.js +63 -0
  129. package/dist/apps/services/payment-providers/CPPayPaymentProvider.js.map +1 -0
  130. package/dist/apps/services/payment-providers/NSWGovPayPaymentProvider.d.ts +30 -0
  131. package/dist/apps/services/payment-providers/NSWGovPayPaymentProvider.js +116 -0
  132. package/dist/apps/services/payment-providers/NSWGovPayPaymentProvider.js.map +1 -0
  133. package/dist/apps/services/payment-providers/WestpacQuickStreamPaymentProvider.d.ts +49 -0
  134. package/dist/apps/services/payment-providers/WestpacQuickStreamPaymentProvider.js +116 -0
  135. package/dist/apps/services/payment-providers/WestpacQuickStreamPaymentProvider.js.map +1 -0
  136. package/dist/apps/services/payment-providers/receipt-items.d.ts +8 -0
  137. package/dist/apps/services/payment-providers/receipt-items.js +58 -0
  138. package/dist/apps/services/payment-providers/receipt-items.js.map +1 -0
  139. package/dist/apps/services/pending-queue.d.ts +150 -0
  140. package/dist/apps/services/pending-queue.js +316 -0
  141. package/dist/apps/services/pending-queue.js.map +1 -0
  142. package/dist/apps/services/prepareSubmissionData.d.ts +2 -0
  143. package/dist/apps/services/prepareSubmissionData.js +113 -0
  144. package/dist/apps/services/prepareSubmissionData.js.map +1 -0
  145. package/dist/apps/services/query-string.d.ts +1 -0
  146. package/dist/apps/services/query-string.js +16 -0
  147. package/dist/apps/services/query-string.js.map +1 -0
  148. package/dist/apps/services/replaceInjectablesWithSubmissionValues.d.ts +3 -0
  149. package/dist/apps/services/replaceInjectablesWithSubmissionValues.js +18 -0
  150. package/dist/apps/services/replaceInjectablesWithSubmissionValues.js.map +1 -0
  151. package/dist/apps/services/schedulingHandlers.d.ts +36 -0
  152. package/dist/apps/services/schedulingHandlers.js +76 -0
  153. package/dist/apps/services/schedulingHandlers.js.map +1 -0
  154. package/dist/apps/services/server-validation.d.ts +2 -0
  155. package/dist/apps/services/server-validation.js +36 -0
  156. package/dist/apps/services/server-validation.js.map +1 -0
  157. package/dist/apps/services/serverRequest.d.ts +5 -0
  158. package/dist/apps/services/serverRequest.js +24 -0
  159. package/dist/apps/services/serverRequest.js.map +1 -0
  160. package/dist/apps/services/submit.d.ts +19 -0
  161. package/dist/apps/services/submit.js +219 -0
  162. package/dist/apps/services/submit.js.map +1 -0
  163. package/dist/apps/services/uploadAttachment.d.ts +52 -0
  164. package/dist/apps/services/uploadAttachment.js +73 -0
  165. package/dist/apps/services/uploadAttachment.js.map +1 -0
  166. package/dist/apps/services/user-token.d.ts +27 -0
  167. package/dist/apps/services/user-token.js +33 -0
  168. package/dist/apps/services/user-token.js.map +1 -0
  169. package/dist/apps/services/utils.d.ts +12 -0
  170. package/dist/apps/services/utils.js +100 -0
  171. package/dist/apps/services/utils.js.map +1 -0
  172. package/dist/apps/submission-service.d.ts +226 -0
  173. package/dist/apps/submission-service.js +425 -0
  174. package/dist/apps/submission-service.js.map +1 -0
  175. package/dist/apps/tenants.d.ts +29 -0
  176. package/dist/apps/tenants.js +127 -0
  177. package/dist/apps/tenants.js.map +1 -0
  178. package/dist/apps/types/form.d.ts +4 -0
  179. package/dist/apps/types/form.js +2 -0
  180. package/dist/apps/types/form.js.map +1 -0
  181. package/dist/apps/types/payments.d.ts +45 -0
  182. package/dist/apps/types/payments.js +2 -0
  183. package/dist/apps/types/payments.js.map +1 -0
  184. package/dist/apps/types/scheduling.d.ts +5 -0
  185. package/dist/apps/types/scheduling.js +2 -0
  186. package/dist/apps/types/scheduling.js.map +1 -0
  187. package/dist/apps/types/submissions.d.ts +175 -0
  188. package/dist/apps/types/submissions.js +2 -0
  189. package/dist/apps/types/submissions.js.map +1 -0
  190. package/dist/components/CustomAccordion.d.ts +3 -3
  191. package/dist/components/Lists.d.ts +4 -1
  192. package/dist/components/formStore/display/ElementDisplay.js +2 -2
  193. package/dist/components/formStore/display/ElementDisplay.js.map +1 -1
  194. package/dist/components/formStore/useFormStoreTableContext.d.ts +2 -2
  195. package/dist/components/mfa/MultiFactorAuthentication.d.ts +1 -1
  196. package/dist/components/renderer/LookupNotification.js +1 -1
  197. package/dist/components/renderer/LookupNotification.js.map +1 -1
  198. package/dist/form-elements/FormElementAutocomplete.js +1 -1
  199. package/dist/form-elements/FormElementAutocomplete.js.map +1 -1
  200. package/dist/hooks/attachments/useAttachment.js +1 -1
  201. package/dist/hooks/attachments/useAttachment.js.map +1 -1
  202. package/dist/index.d.ts +1 -0
  203. package/dist/index.js +2 -0
  204. package/dist/index.js.map +1 -1
  205. package/dist/services/download-file.js +1 -1
  206. package/dist/services/download-file.js.map +1 -1
  207. package/dist/styles.css +208 -204
  208. package/package.json +43 -35
@@ -0,0 +1,252 @@
1
+ /**
2
+ * ## Offline Service
3
+ *
4
+ * Helper functions for offline handling
5
+ *
6
+ * ```js
7
+ * import { offlineService } from '@oneblink/apps'
8
+ * ```
9
+ */
10
+ export * as offlineService from './offline-service';
11
+ /**
12
+ * ## Authentication/Authorisation Service
13
+ *
14
+ * Helper functions for handling user authentication and authorisation.
15
+ *
16
+ * **NOTE: `init()` must be called before using some of the functions in this
17
+ * service.**
18
+ *
19
+ * ```js
20
+ * import { authService } from '@oneblink/apps'
21
+ * ```
22
+ */
23
+ export * as authService from './auth-service';
24
+ /**
25
+ * ## Draft Service
26
+ *
27
+ * Helper functions for handling drafts.
28
+ *
29
+ * ```js
30
+ * import { draftService } from '@oneblink/apps'
31
+ * ```
32
+ */
33
+ export * as draftService from './draft-service';
34
+ /**
35
+ * ## Prefill Service
36
+ *
37
+ * Helper functions for offline handling
38
+ *
39
+ * ```js
40
+ * import { prefillService } from '@oneblink/apps'
41
+ * ```
42
+ */
43
+ export * as prefillService from './prefill-service';
44
+ /**
45
+ * ## Payment Service
46
+ *
47
+ * Helper functions for payment handling
48
+ *
49
+ * ```js
50
+ * import { paymentService } from '@oneblink/apps'
51
+ * ```
52
+ */
53
+ export * as paymentService from './payment-service';
54
+ /**
55
+ * ## Scheduling Service
56
+ *
57
+ * Helper functions for scheduling booking handling
58
+ *
59
+ * ```js
60
+ * import { schedulingService } from '@oneblink/apps'
61
+ * ```
62
+ */
63
+ export * as schedulingService from './scheduling-service';
64
+ /**
65
+ * ## Job Service
66
+ *
67
+ * Helper functions for job handling
68
+ *
69
+ * ```js
70
+ * import { jobService } from '@oneblink/apps'
71
+ * ```
72
+ */
73
+ export * as jobService from './job-service';
74
+ /**
75
+ * ## Submission Service
76
+ *
77
+ * Helper functions for handling form submissions
78
+ *
79
+ * ```js
80
+ * import { submissionService } from '@oneblink/apps'
81
+ * ```
82
+ */
83
+ export * as submissionService from './submission-service';
84
+ /**
85
+ * ## Auto Save Service
86
+ *
87
+ * Helper functions for handling data while user is completing form.
88
+ *
89
+ * ```js
90
+ * import { autoSaveService } from '@oneblink/apps'
91
+ * ```
92
+ */
93
+ export * as autoSaveService from './auto-save-service';
94
+ /**
95
+ * ## Notification Service
96
+ *
97
+ * Helper functions for notification handling
98
+ *
99
+ * ```js
100
+ * import { notificationService } from '@oneblink/apps'
101
+ * ```
102
+ *
103
+ * ### Service Worker
104
+ *
105
+ * To display push notifications and allow them to be clicked to open the
106
+ * application, add the following JavaScript to your service worker (we
107
+ * recommend using
108
+ * [offline-plugin](https://www.npmjs.com/package/offline-plugin)):
109
+ *
110
+ * #### Example
111
+ *
112
+ * ```js
113
+ * self.addEventListener('push', (event) => {
114
+ * console.log('push event', event)
115
+ *
116
+ * if (!event.data) {
117
+ * console.log('Received push event without any data', event)
118
+ * return
119
+ * }
120
+ * const notification = event.data.json()
121
+ *
122
+ * event.waitUntil(
123
+ * clients.matchAll().then((c) => {
124
+ * if (c.length === 0 || c.every((client) => !client.focused)) {
125
+ * // Show notification
126
+ * return self.registration.showNotification(
127
+ * notification.title,
128
+ * notification.options,
129
+ * )
130
+ * } else {
131
+ * console.log('Application is already open!')
132
+ * }
133
+ * }),
134
+ * )
135
+ * })
136
+ *
137
+ * self.addEventListener('notificationclick', (event) => {
138
+ * console.log('notification click event', event)
139
+ *
140
+ * const pathname =
141
+ * event.notification.data && event.notification.data.pathname
142
+ * ? event.notification.data.pathname
143
+ * : '/'
144
+ *
145
+ * event.waitUntil(
146
+ * clients.matchAll().then((clis) => {
147
+ * const client = clis[0]
148
+ * if (client === undefined) {
149
+ * // there are no visible windows. Open one.
150
+ * clients.openWindow(pathname)
151
+ * } else {
152
+ * client.navigate(pathname)
153
+ * client.focus()
154
+ * }
155
+ *
156
+ * return self.registration
157
+ * .getNotifications()
158
+ * .then((notifications) => {
159
+ * notifications.forEach((notification) => {
160
+ * notification.close()
161
+ * })
162
+ * })
163
+ * }),
164
+ * )
165
+ * })
166
+ * ```
167
+ */
168
+ export * as notificationService from './notification-service';
169
+ /**
170
+ * ## Form Service
171
+ *
172
+ * Helper functions for form handling
173
+ *
174
+ * ```js
175
+ * import { formService } from '@oneblink/apps'
176
+ * ```
177
+ */
178
+ export * as formService from './form-service';
179
+ /**
180
+ * ## Approvals Service
181
+ *
182
+ * Helper functions for handling approvals
183
+ *
184
+ * ```js
185
+ * import { approvalsService } from '@oneblink/apps'
186
+ * ```
187
+ */
188
+ export * as approvalsService from './approvals-service';
189
+ /**
190
+ * ## Forms App Service
191
+ *
192
+ * Helper functions for forms apps
193
+ *
194
+ * ```js
195
+ * import { formsAppService } from '@oneblink/apps'
196
+ * ```
197
+ */
198
+ export * as formsAppService from './forms-app-service';
199
+ /**
200
+ * ## Form Store Service
201
+ *
202
+ * Helper functions for handling Form Store Records
203
+ *
204
+ * ```js
205
+ * import { formStoreService } from '@oneblink/apps'
206
+ * ```
207
+ */
208
+ export * as formStoreService from './form-store-service';
209
+ /**
210
+ * ## Localisation Service
211
+ *
212
+ * Helper functions for handling all things locale.
213
+ *
214
+ * ```js
215
+ * import { localisationService } from '@oneblink/apps'
216
+ * ```
217
+ */
218
+ export * as localisationService from './localisation-service';
219
+ /**
220
+ * ## Attachments Service
221
+ *
222
+ * Helper functions for attachment handling
223
+ *
224
+ * ```js
225
+ * import { attachmentsService } from '@oneblink/apps'
226
+ * ```
227
+ */
228
+ export * as attachmentsService from './attachments-service';
229
+ /**
230
+ * ## Scheduled Tasks Service
231
+ *
232
+ * Helper functions for scheduled tasks
233
+ *
234
+ * ```js
235
+ * import { scheduledTasksService } from '@oneblink/apps'
236
+ * ```
237
+ */
238
+ export * as scheduledTasksService from './scheduled-tasks-service';
239
+ /**
240
+ * ## Forms App Environment Service
241
+ *
242
+ * Helper functions for forms app environments
243
+ *
244
+ * ```js
245
+ * import { formsAppEnvironmentService } from '@oneblink/apps'
246
+ * ```
247
+ */
248
+ export * as formsAppEnvironmentService from './forms-app-environment-service';
249
+ export { default as OneBlinkAppsError } from './services/errors/oneBlinkAppsError';
250
+ export { default as Sentry } from './Sentry';
251
+ export declare const useTenantCivicPlus: () => void;
252
+ export declare const useTenantOneBlink: () => void;
@@ -0,0 +1,254 @@
1
+ /**
2
+ * ## Offline Service
3
+ *
4
+ * Helper functions for offline handling
5
+ *
6
+ * ```js
7
+ * import { offlineService } from '@oneblink/apps'
8
+ * ```
9
+ */
10
+ export * as offlineService from './offline-service';
11
+ /**
12
+ * ## Authentication/Authorisation Service
13
+ *
14
+ * Helper functions for handling user authentication and authorisation.
15
+ *
16
+ * **NOTE: `init()` must be called before using some of the functions in this
17
+ * service.**
18
+ *
19
+ * ```js
20
+ * import { authService } from '@oneblink/apps'
21
+ * ```
22
+ */
23
+ export * as authService from './auth-service';
24
+ /**
25
+ * ## Draft Service
26
+ *
27
+ * Helper functions for handling drafts.
28
+ *
29
+ * ```js
30
+ * import { draftService } from '@oneblink/apps'
31
+ * ```
32
+ */
33
+ export * as draftService from './draft-service';
34
+ /**
35
+ * ## Prefill Service
36
+ *
37
+ * Helper functions for offline handling
38
+ *
39
+ * ```js
40
+ * import { prefillService } from '@oneblink/apps'
41
+ * ```
42
+ */
43
+ export * as prefillService from './prefill-service';
44
+ /**
45
+ * ## Payment Service
46
+ *
47
+ * Helper functions for payment handling
48
+ *
49
+ * ```js
50
+ * import { paymentService } from '@oneblink/apps'
51
+ * ```
52
+ */
53
+ export * as paymentService from './payment-service';
54
+ /**
55
+ * ## Scheduling Service
56
+ *
57
+ * Helper functions for scheduling booking handling
58
+ *
59
+ * ```js
60
+ * import { schedulingService } from '@oneblink/apps'
61
+ * ```
62
+ */
63
+ export * as schedulingService from './scheduling-service';
64
+ /**
65
+ * ## Job Service
66
+ *
67
+ * Helper functions for job handling
68
+ *
69
+ * ```js
70
+ * import { jobService } from '@oneblink/apps'
71
+ * ```
72
+ */
73
+ export * as jobService from './job-service';
74
+ /**
75
+ * ## Submission Service
76
+ *
77
+ * Helper functions for handling form submissions
78
+ *
79
+ * ```js
80
+ * import { submissionService } from '@oneblink/apps'
81
+ * ```
82
+ */
83
+ export * as submissionService from './submission-service';
84
+ /**
85
+ * ## Auto Save Service
86
+ *
87
+ * Helper functions for handling data while user is completing form.
88
+ *
89
+ * ```js
90
+ * import { autoSaveService } from '@oneblink/apps'
91
+ * ```
92
+ */
93
+ export * as autoSaveService from './auto-save-service';
94
+ /**
95
+ * ## Notification Service
96
+ *
97
+ * Helper functions for notification handling
98
+ *
99
+ * ```js
100
+ * import { notificationService } from '@oneblink/apps'
101
+ * ```
102
+ *
103
+ * ### Service Worker
104
+ *
105
+ * To display push notifications and allow them to be clicked to open the
106
+ * application, add the following JavaScript to your service worker (we
107
+ * recommend using
108
+ * [offline-plugin](https://www.npmjs.com/package/offline-plugin)):
109
+ *
110
+ * #### Example
111
+ *
112
+ * ```js
113
+ * self.addEventListener('push', (event) => {
114
+ * console.log('push event', event)
115
+ *
116
+ * if (!event.data) {
117
+ * console.log('Received push event without any data', event)
118
+ * return
119
+ * }
120
+ * const notification = event.data.json()
121
+ *
122
+ * event.waitUntil(
123
+ * clients.matchAll().then((c) => {
124
+ * if (c.length === 0 || c.every((client) => !client.focused)) {
125
+ * // Show notification
126
+ * return self.registration.showNotification(
127
+ * notification.title,
128
+ * notification.options,
129
+ * )
130
+ * } else {
131
+ * console.log('Application is already open!')
132
+ * }
133
+ * }),
134
+ * )
135
+ * })
136
+ *
137
+ * self.addEventListener('notificationclick', (event) => {
138
+ * console.log('notification click event', event)
139
+ *
140
+ * const pathname =
141
+ * event.notification.data && event.notification.data.pathname
142
+ * ? event.notification.data.pathname
143
+ * : '/'
144
+ *
145
+ * event.waitUntil(
146
+ * clients.matchAll().then((clis) => {
147
+ * const client = clis[0]
148
+ * if (client === undefined) {
149
+ * // there are no visible windows. Open one.
150
+ * clients.openWindow(pathname)
151
+ * } else {
152
+ * client.navigate(pathname)
153
+ * client.focus()
154
+ * }
155
+ *
156
+ * return self.registration
157
+ * .getNotifications()
158
+ * .then((notifications) => {
159
+ * notifications.forEach((notification) => {
160
+ * notification.close()
161
+ * })
162
+ * })
163
+ * }),
164
+ * )
165
+ * })
166
+ * ```
167
+ */
168
+ export * as notificationService from './notification-service';
169
+ /**
170
+ * ## Form Service
171
+ *
172
+ * Helper functions for form handling
173
+ *
174
+ * ```js
175
+ * import { formService } from '@oneblink/apps'
176
+ * ```
177
+ */
178
+ export * as formService from './form-service';
179
+ /**
180
+ * ## Approvals Service
181
+ *
182
+ * Helper functions for handling approvals
183
+ *
184
+ * ```js
185
+ * import { approvalsService } from '@oneblink/apps'
186
+ * ```
187
+ */
188
+ export * as approvalsService from './approvals-service';
189
+ /**
190
+ * ## Forms App Service
191
+ *
192
+ * Helper functions for forms apps
193
+ *
194
+ * ```js
195
+ * import { formsAppService } from '@oneblink/apps'
196
+ * ```
197
+ */
198
+ export * as formsAppService from './forms-app-service';
199
+ /**
200
+ * ## Form Store Service
201
+ *
202
+ * Helper functions for handling Form Store Records
203
+ *
204
+ * ```js
205
+ * import { formStoreService } from '@oneblink/apps'
206
+ * ```
207
+ */
208
+ export * as formStoreService from './form-store-service';
209
+ /**
210
+ * ## Localisation Service
211
+ *
212
+ * Helper functions for handling all things locale.
213
+ *
214
+ * ```js
215
+ * import { localisationService } from '@oneblink/apps'
216
+ * ```
217
+ */
218
+ export * as localisationService from './localisation-service';
219
+ /**
220
+ * ## Attachments Service
221
+ *
222
+ * Helper functions for attachment handling
223
+ *
224
+ * ```js
225
+ * import { attachmentsService } from '@oneblink/apps'
226
+ * ```
227
+ */
228
+ export * as attachmentsService from './attachments-service';
229
+ /**
230
+ * ## Scheduled Tasks Service
231
+ *
232
+ * Helper functions for scheduled tasks
233
+ *
234
+ * ```js
235
+ * import { scheduledTasksService } from '@oneblink/apps'
236
+ * ```
237
+ */
238
+ export * as scheduledTasksService from './scheduled-tasks-service';
239
+ /**
240
+ * ## Forms App Environment Service
241
+ *
242
+ * Helper functions for forms app environments
243
+ *
244
+ * ```js
245
+ * import { formsAppEnvironmentService } from '@oneblink/apps'
246
+ * ```
247
+ */
248
+ export * as formsAppEnvironmentService from './forms-app-environment-service';
249
+ export { default as OneBlinkAppsError } from './services/errors/oneBlinkAppsError';
250
+ import tenants from './tenants';
251
+ export { default as Sentry } from './Sentry';
252
+ export const useTenantCivicPlus = () => tenants.useCivicPlus();
253
+ export const useTenantOneBlink = () => tenants.useOneBlink();
254
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/apps/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,cAAc,MAAM,mBAAmB,CAAA;AACnD;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,WAAW,MAAM,gBAAgB,CAAA;AAC7C;;;;;;;;GAQG;AACH,OAAO,KAAK,YAAY,MAAM,iBAAiB,CAAA;AAC/C;;;;;;;;GAQG;AACH,OAAO,KAAK,cAAc,MAAM,mBAAmB,CAAA;AACnD;;;;;;;;GAQG;AACH,OAAO,KAAK,cAAc,MAAM,mBAAmB,CAAA;AACnD;;;;;;;;GAQG;AACH,OAAO,KAAK,iBAAiB,MAAM,sBAAsB,CAAA;AACzD;;;;;;;;GAQG;AACH,OAAO,KAAK,UAAU,MAAM,eAAe,CAAA;AAC3C;;;;;;;;GAQG;AACH,OAAO,KAAK,iBAAiB,MAAM,sBAAsB,CAAA;AACzD;;;;;;;;GAQG;AACH,OAAO,KAAK,eAAe,MAAM,qBAAqB,CAAA;AACtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyEG;AACH,OAAO,KAAK,mBAAmB,MAAM,wBAAwB,CAAA;AAC7D;;;;;;;;GAQG;AACH,OAAO,KAAK,WAAW,MAAM,gBAAgB,CAAA;AAC7C;;;;;;;;GAQG;AACH,OAAO,KAAK,gBAAgB,MAAM,qBAAqB,CAAA;AACvD;;;;;;;;GAQG;AACH,OAAO,KAAK,eAAe,MAAM,qBAAqB,CAAA;AACtD;;;;;;;;GAQG;AACH,OAAO,KAAK,gBAAgB,MAAM,sBAAsB,CAAA;AACxD;;;;;;;;GAQG;AACH,OAAO,KAAK,mBAAmB,MAAM,wBAAwB,CAAA;AAC7D;;;;;;;;GAQG;AACH,OAAO,KAAK,kBAAkB,MAAM,uBAAuB,CAAA;AAC3D;;;;;;;;GAQG;AACH,OAAO,KAAK,qBAAqB,MAAM,2BAA2B,CAAA;AAClE;;;;;;;;GAQG;AACH,OAAO,KAAK,0BAA0B,MAAM,iCAAiC,CAAA;AAE7E,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qCAAqC,CAAA;AAClF,OAAO,OAAO,MAAM,WAAW,CAAA;AAC/B,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAA;AAE5C,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,YAAY,EAAE,CAAA;AAC9D,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE,CAAA","sourcesContent":["/**\n * ## Offline Service\n *\n * Helper functions for offline handling\n *\n * ```js\n * import { offlineService } from '@oneblink/apps'\n * ```\n */\nexport * as offlineService from './offline-service'\n/**\n * ## Authentication/Authorisation Service\n *\n * Helper functions for handling user authentication and authorisation.\n *\n * **NOTE: `init()` must be called before using some of the functions in this\n * service.**\n *\n * ```js\n * import { authService } from '@oneblink/apps'\n * ```\n */\nexport * as authService from './auth-service'\n/**\n * ## Draft Service\n *\n * Helper functions for handling drafts.\n *\n * ```js\n * import { draftService } from '@oneblink/apps'\n * ```\n */\nexport * as draftService from './draft-service'\n/**\n * ## Prefill Service\n *\n * Helper functions for offline handling\n *\n * ```js\n * import { prefillService } from '@oneblink/apps'\n * ```\n */\nexport * as prefillService from './prefill-service'\n/**\n * ## Payment Service\n *\n * Helper functions for payment handling\n *\n * ```js\n * import { paymentService } from '@oneblink/apps'\n * ```\n */\nexport * as paymentService from './payment-service'\n/**\n * ## Scheduling Service\n *\n * Helper functions for scheduling booking handling\n *\n * ```js\n * import { schedulingService } from '@oneblink/apps'\n * ```\n */\nexport * as schedulingService from './scheduling-service'\n/**\n * ## Job Service\n *\n * Helper functions for job handling\n *\n * ```js\n * import { jobService } from '@oneblink/apps'\n * ```\n */\nexport * as jobService from './job-service'\n/**\n * ## Submission Service\n *\n * Helper functions for handling form submissions\n *\n * ```js\n * import { submissionService } from '@oneblink/apps'\n * ```\n */\nexport * as submissionService from './submission-service'\n/**\n * ## Auto Save Service\n *\n * Helper functions for handling data while user is completing form.\n *\n * ```js\n * import { autoSaveService } from '@oneblink/apps'\n * ```\n */\nexport * as autoSaveService from './auto-save-service'\n/**\n * ## Notification Service\n *\n * Helper functions for notification handling\n *\n * ```js\n * import { notificationService } from '@oneblink/apps'\n * ```\n *\n * ### Service Worker\n *\n * To display push notifications and allow them to be clicked to open the\n * application, add the following JavaScript to your service worker (we\n * recommend using\n * [offline-plugin](https://www.npmjs.com/package/offline-plugin)):\n *\n * #### Example\n *\n * ```js\n * self.addEventListener('push', (event) => {\n * console.log('push event', event)\n *\n * if (!event.data) {\n * console.log('Received push event without any data', event)\n * return\n * }\n * const notification = event.data.json()\n *\n * event.waitUntil(\n * clients.matchAll().then((c) => {\n * if (c.length === 0 || c.every((client) => !client.focused)) {\n * // Show notification\n * return self.registration.showNotification(\n * notification.title,\n * notification.options,\n * )\n * } else {\n * console.log('Application is already open!')\n * }\n * }),\n * )\n * })\n *\n * self.addEventListener('notificationclick', (event) => {\n * console.log('notification click event', event)\n *\n * const pathname =\n * event.notification.data && event.notification.data.pathname\n * ? event.notification.data.pathname\n * : '/'\n *\n * event.waitUntil(\n * clients.matchAll().then((clis) => {\n * const client = clis[0]\n * if (client === undefined) {\n * // there are no visible windows. Open one.\n * clients.openWindow(pathname)\n * } else {\n * client.navigate(pathname)\n * client.focus()\n * }\n *\n * return self.registration\n * .getNotifications()\n * .then((notifications) => {\n * notifications.forEach((notification) => {\n * notification.close()\n * })\n * })\n * }),\n * )\n * })\n * ```\n */\nexport * as notificationService from './notification-service'\n/**\n * ## Form Service\n *\n * Helper functions for form handling\n *\n * ```js\n * import { formService } from '@oneblink/apps'\n * ```\n */\nexport * as formService from './form-service'\n/**\n * ## Approvals Service\n *\n * Helper functions for handling approvals\n *\n * ```js\n * import { approvalsService } from '@oneblink/apps'\n * ```\n */\nexport * as approvalsService from './approvals-service'\n/**\n * ## Forms App Service\n *\n * Helper functions for forms apps\n *\n * ```js\n * import { formsAppService } from '@oneblink/apps'\n * ```\n */\nexport * as formsAppService from './forms-app-service'\n/**\n * ## Form Store Service\n *\n * Helper functions for handling Form Store Records\n *\n * ```js\n * import { formStoreService } from '@oneblink/apps'\n * ```\n */\nexport * as formStoreService from './form-store-service'\n/**\n * ## Localisation Service\n *\n * Helper functions for handling all things locale.\n *\n * ```js\n * import { localisationService } from '@oneblink/apps'\n * ```\n */\nexport * as localisationService from './localisation-service'\n/**\n * ## Attachments Service\n *\n * Helper functions for attachment handling\n *\n * ```js\n * import { attachmentsService } from '@oneblink/apps'\n * ```\n */\nexport * as attachmentsService from './attachments-service'\n/**\n * ## Scheduled Tasks Service\n *\n * Helper functions for scheduled tasks\n *\n * ```js\n * import { scheduledTasksService } from '@oneblink/apps'\n * ```\n */\nexport * as scheduledTasksService from './scheduled-tasks-service'\n/**\n * ## Forms App Environment Service\n *\n * Helper functions for forms app environments\n *\n * ```js\n * import { formsAppEnvironmentService } from '@oneblink/apps'\n * ```\n */\nexport * as formsAppEnvironmentService from './forms-app-environment-service'\n\nexport { default as OneBlinkAppsError } from './services/errors/oneBlinkAppsError'\nimport tenants from './tenants'\nexport { default as Sentry } from './Sentry'\n\nexport const useTenantCivicPlus = () => tenants.useCivicPlus()\nexport const useTenantOneBlink = () => tenants.useOneBlink()\n"]}
@@ -0,0 +1,20 @@
1
+ import { ensurePrefillFormDataExists } from './services/job-prefill';
2
+ import { SubmissionTypes } from '@oneblink/types';
3
+ /**
4
+ * Get Jobs for the current user. Jobs that are in the pending queue will be
5
+ * filtered out and Jobs with drafts will include the `draft` property.
6
+ *
7
+ * #### Example
8
+ *
9
+ * ```js
10
+ * const formsAppId = 1
11
+ * const label = 'Applications'
12
+ * const jobs = await jobService.getJobs(formsAppId, label)
13
+ * ```
14
+ *
15
+ * @param formsAppId
16
+ * @param jobsLabel
17
+ * @returns
18
+ */
19
+ export declare function getJobs(formsAppId: number, jobsLabel: string): Promise<SubmissionTypes.FormsAppJob[]>;
20
+ export { ensurePrefillFormDataExists };
@@ -0,0 +1,95 @@
1
+ import _orderBy from 'lodash.orderby';
2
+ import OneBlinkAppsError from './services/errors/oneBlinkAppsError';
3
+ import { searchRequest } from './services/fetch';
4
+ import { getPendingQueueSubmissions } from './services/pending-queue';
5
+ import { ensurePrefillFormDataExists } from './services/job-prefill';
6
+ import { isOffline } from './offline-service';
7
+ import { isLoggedIn } from './auth-service';
8
+ import { getDrafts } from './draft-service';
9
+ import tenants from './tenants';
10
+ import Sentry from './Sentry';
11
+ async function removePendingSubmissions(jobList) {
12
+ // Get list of pending submissions, remove jobs that are in the pending queue
13
+ return getPendingQueueSubmissions().then((submissions) => {
14
+ const unprocessedJobs = jobList.filter((job) => !submissions.some((sub) => sub.jobId === job.id));
15
+ return unprocessedJobs;
16
+ });
17
+ }
18
+ async function tagDrafts(jobList) {
19
+ return getDrafts().then((drafts) => jobList.map((job) => {
20
+ const draft = drafts.find((draft) => draft.jobId === job.id);
21
+ return {
22
+ ...job,
23
+ draft,
24
+ };
25
+ }));
26
+ }
27
+ /**
28
+ * Get Jobs for the current user. Jobs that are in the pending queue will be
29
+ * filtered out and Jobs with drafts will include the `draft` property.
30
+ *
31
+ * #### Example
32
+ *
33
+ * ```js
34
+ * const formsAppId = 1
35
+ * const label = 'Applications'
36
+ * const jobs = await jobService.getJobs(formsAppId, label)
37
+ * ```
38
+ *
39
+ * @param formsAppId
40
+ * @param jobsLabel
41
+ * @returns
42
+ */
43
+ export async function getJobs(formsAppId, jobsLabel) {
44
+ if (!isLoggedIn()) {
45
+ return [];
46
+ }
47
+ return searchRequest(`${tenants.current.apiOrigin}/forms-apps/${formsAppId}/jobs`, {
48
+ isSubmitted: false,
49
+ })
50
+ .then((data) => removePendingSubmissions(data.jobs))
51
+ .then((jobs) => tagDrafts(jobs))
52
+ .then((jobList) => _orderBy(jobList, ['details.priority', (job) => Date.parse(job.createdAt)], ['asc', 'asc']))
53
+ .catch((error) => {
54
+ Sentry.captureException(error);
55
+ console.warn('Error retrieving Jobs for forms app', error);
56
+ if (isOffline()) {
57
+ throw new OneBlinkAppsError('You are currently offline and do not have a local copy of this app available, please connect to the internet and try again', {
58
+ originalError: error,
59
+ isOffline: true,
60
+ });
61
+ }
62
+ switch (error.status) {
63
+ case 401: {
64
+ throw new OneBlinkAppsError(`You need to log in to see your ${jobsLabel}. Please login and try again.`, {
65
+ originalError: error,
66
+ requiresLogin: true,
67
+ httpStatusCode: error.status,
68
+ });
69
+ }
70
+ case 403: {
71
+ throw new OneBlinkAppsError(`You have not been granted access to ${jobsLabel}. Please contact your administrator to gain the correct level of access.`, {
72
+ originalError: error,
73
+ requiresAccessRequest: true,
74
+ httpStatusCode: error.status,
75
+ });
76
+ }
77
+ case 400:
78
+ case 404: {
79
+ throw new OneBlinkAppsError('We could not find the application you are looking for. Please contact your administrator to ensure your application configuration has been completed successfully.', {
80
+ originalError: error,
81
+ title: 'Unknown Application',
82
+ httpStatusCode: error.status,
83
+ });
84
+ }
85
+ default: {
86
+ throw new OneBlinkAppsError('An unknown error has occurred. Please contact support if the problem persists.', {
87
+ originalError: error,
88
+ httpStatusCode: error.status,
89
+ });
90
+ }
91
+ }
92
+ });
93
+ }
94
+ export { ensurePrefillFormDataExists };
95
+ //# sourceMappingURL=job-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"job-service.js","sourceRoot":"","sources":["../../src/apps/job-service.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,gBAAgB,CAAA;AAErC,OAAO,iBAAiB,MAAM,qCAAqC,CAAA;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAA;AACrE,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAA;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,OAAO,MAAM,WAAW,CAAA;AAE/B,OAAO,MAAM,MAAM,UAAU,CAAA;AAE7B,KAAK,UAAU,wBAAwB,CACrC,OAAsC;IAEtC,6EAA6E;IAC7E,OAAO,0BAA0B,EAAE,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE;QACvD,MAAM,eAAe,GAAG,OAAO,CAAC,MAAM,CACpC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,KAAK,GAAG,CAAC,EAAE,CAAC,CAC1D,CAAA;QACD,OAAO,eAAe,CAAA;IACxB,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,KAAK,UAAU,SAAS,CAAC,OAAsC;IAC7D,OAAO,SAAS,EAAE,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CACjC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;QAClB,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,KAAK,GAAG,CAAC,EAAE,CAAC,CAAA;QAC5D,OAAO;YACL,GAAG,GAAG;YACN,KAAK;SACN,CAAA;IACH,CAAC,CAAC,CACH,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,UAAkB,EAClB,SAAiB;IAEjB,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC;QAClB,OAAO,EAAE,CAAA;IACX,CAAC;IAED,OAAO,aAAa,CAClB,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,eAAe,UAAU,OAAO,EAC5D;QACE,WAAW,EAAE,KAAK;KACnB,CACF;SACE,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,wBAAwB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SACnD,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;SAC/B,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAChB,QAAQ,CACN,OAAO,EACP,CAAC,kBAAkB,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EACxD,CAAC,KAAK,EAAE,KAAK,CAAC,CACf,CACF;SACA,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QACf,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAA;QAC9B,OAAO,CAAC,IAAI,CAAC,qCAAqC,EAAE,KAAK,CAAC,CAAA;QAE1D,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;QAED,QAAQ,KAAK,CAAC,MAAM,EAAE,CAAC;YACrB,KAAK,GAAG,CAAC,CAAC,CAAC;gBACT,MAAM,IAAI,iBAAiB,CACzB,kCAAkC,SAAS,+BAA+B,EAC1E;oBACE,aAAa,EAAE,KAAK;oBACpB,aAAa,EAAE,IAAI;oBACnB,cAAc,EAAE,KAAK,CAAC,MAAM;iBAC7B,CACF,CAAA;YACH,CAAC;YACD,KAAK,GAAG,CAAC,CAAC,CAAC;gBACT,MAAM,IAAI,iBAAiB,CACzB,uCAAuC,SAAS,0EAA0E,EAC1H;oBACE,aAAa,EAAE,KAAK;oBACpB,qBAAqB,EAAE,IAAI;oBAC3B,cAAc,EAAE,KAAK,CAAC,MAAM;iBAC7B,CACF,CAAA;YACH,CAAC;YACD,KAAK,GAAG,CAAC;YACT,KAAK,GAAG,CAAC,CAAC,CAAC;gBACT,MAAM,IAAI,iBAAiB,CACzB,oKAAoK,EACpK;oBACE,aAAa,EAAE,KAAK;oBACpB,KAAK,EAAE,qBAAqB;oBAC5B,cAAc,EAAE,KAAK,CAAC,MAAM;iBAC7B,CACF,CAAA;YACH,CAAC;YACD,OAAO,CAAC,CAAC,CAAC;gBACR,MAAM,IAAI,iBAAiB,CACzB,gFAAgF,EAChF;oBACE,aAAa,EAAE,KAAK;oBACpB,cAAc,EAAE,KAAK,CAAC,MAAM;iBAC7B,CACF,CAAA;YACH,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAA;AACN,CAAC;AAED,OAAO,EAAE,2BAA2B,EAAE,CAAA","sourcesContent":["import _orderBy from 'lodash.orderby'\n\nimport OneBlinkAppsError from './services/errors/oneBlinkAppsError'\nimport { searchRequest } from './services/fetch'\nimport { getPendingQueueSubmissions } from './services/pending-queue'\nimport { ensurePrefillFormDataExists } from './services/job-prefill'\nimport { isOffline } from './offline-service'\nimport { isLoggedIn } from './auth-service'\nimport { getDrafts } from './draft-service'\nimport tenants from './tenants'\nimport { SubmissionTypes } from '@oneblink/types'\nimport Sentry from './Sentry'\n\nasync function removePendingSubmissions(\n jobList: SubmissionTypes.FormsAppJob[],\n) {\n // Get list of pending submissions, remove jobs that are in the pending queue\n return getPendingQueueSubmissions().then((submissions) => {\n const unprocessedJobs = jobList.filter(\n (job) => !submissions.some((sub) => sub.jobId === job.id),\n )\n return unprocessedJobs\n })\n}\n\nasync function tagDrafts(jobList: SubmissionTypes.FormsAppJob[]) {\n return getDrafts().then((drafts) =>\n jobList.map((job) => {\n const draft = drafts.find((draft) => draft.jobId === job.id)\n return {\n ...job,\n draft,\n }\n }),\n )\n}\n\n/**\n * Get Jobs for the current user. Jobs that are in the pending queue will be\n * filtered out and Jobs with drafts will include the `draft` property.\n *\n * #### Example\n *\n * ```js\n * const formsAppId = 1\n * const label = 'Applications'\n * const jobs = await jobService.getJobs(formsAppId, label)\n * ```\n *\n * @param formsAppId\n * @param jobsLabel\n * @returns\n */\nexport async function getJobs(\n formsAppId: number,\n jobsLabel: string,\n): Promise<SubmissionTypes.FormsAppJob[]> {\n if (!isLoggedIn()) {\n return []\n }\n\n return searchRequest<{ jobs: Array<SubmissionTypes.FormsAppJob> }>(\n `${tenants.current.apiOrigin}/forms-apps/${formsAppId}/jobs`,\n {\n isSubmitted: false,\n },\n )\n .then((data) => removePendingSubmissions(data.jobs))\n .then((jobs) => tagDrafts(jobs))\n .then((jobList) =>\n _orderBy(\n jobList,\n ['details.priority', (job) => Date.parse(job.createdAt)],\n ['asc', 'asc'],\n ),\n )\n .catch((error) => {\n Sentry.captureException(error)\n console.warn('Error retrieving Jobs for forms app', error)\n\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\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n `You need to log in to see your ${jobsLabel}. 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 have not been granted access to ${jobsLabel}. 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(\n 'We could not find the application you are looking for. Please contact your administrator to ensure your application configuration has been completed successfully.',\n {\n originalError: error,\n title: 'Unknown Application',\n httpStatusCode: error.status,\n },\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 { ensurePrefillFormDataExists }\n"]}