@oneblink/apps-react 9.0.0-beta.2 → 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.
- package/dist/OneBlinkForm.d.ts +6 -6
- package/dist/OneBlinkFormBase.js +1 -0
- package/dist/OneBlinkFormBase.js.map +1 -1
- package/dist/apps/Sentry.d.ts +7 -0
- package/dist/apps/Sentry.js +16 -0
- package/dist/apps/Sentry.js.map +1 -0
- package/dist/apps/approvals-service.d.ts +390 -0
- package/dist/apps/approvals-service.js +987 -0
- package/dist/apps/approvals-service.js.map +1 -0
- package/dist/apps/attachments-service.d.ts +49 -0
- package/dist/apps/attachments-service.js +134 -0
- package/dist/apps/attachments-service.js.map +1 -0
- package/dist/apps/auth-service.d.ts +114 -0
- package/dist/apps/auth-service.js +194 -0
- package/dist/apps/auth-service.js.map +1 -0
- package/dist/apps/auto-save-service.d.ts +82 -0
- package/dist/apps/auto-save-service.js +105 -0
- package/dist/apps/auto-save-service.js.map +1 -0
- package/dist/apps/draft-service.d.ts +148 -0
- package/dist/apps/draft-service.js +583 -0
- package/dist/apps/draft-service.js.map +1 -0
- package/dist/apps/form-service.d.ts +204 -0
- package/dist/apps/form-service.js +718 -0
- package/dist/apps/form-service.js.map +1 -0
- package/dist/apps/form-store-service.d.ts +141 -0
- package/dist/apps/form-store-service.js +114 -0
- package/dist/apps/form-store-service.js.map +1 -0
- package/dist/apps/forms-app-environment-service.d.ts +19 -0
- package/dist/apps/forms-app-environment-service.js +55 -0
- package/dist/apps/forms-app-environment-service.js.map +1 -0
- package/dist/apps/forms-app-service.d.ts +18 -0
- package/dist/apps/forms-app-service.js +53 -0
- package/dist/apps/forms-app-service.js.map +1 -0
- package/dist/apps/index.d.ts +252 -0
- package/dist/apps/index.js +254 -0
- package/dist/apps/index.js.map +1 -0
- package/dist/apps/job-service.d.ts +20 -0
- package/dist/apps/job-service.js +95 -0
- package/dist/apps/job-service.js.map +1 -0
- package/dist/apps/localisation-service.d.ts +207 -0
- package/dist/apps/localisation-service.js +321 -0
- package/dist/apps/localisation-service.js.map +1 -0
- package/dist/apps/notification-service.d.ts +83 -0
- package/dist/apps/notification-service.js +315 -0
- package/dist/apps/notification-service.js.map +1 -0
- package/dist/apps/offline-service.d.ts +18 -0
- package/dist/apps/offline-service.js +25 -0
- package/dist/apps/offline-service.js.map +1 -0
- package/dist/apps/payment-service.d.ts +110 -0
- package/dist/apps/payment-service.js +182 -0
- package/dist/apps/payment-service.js.map +1 -0
- package/dist/apps/prefill-service.d.ts +14 -0
- package/dist/apps/prefill-service.js +19 -0
- package/dist/apps/prefill-service.js.map +1 -0
- package/dist/apps/scheduled-tasks-service.d.ts +127 -0
- package/dist/apps/scheduled-tasks-service.js +240 -0
- package/dist/apps/scheduled-tasks-service.js.map +1 -0
- package/dist/apps/scheduling-service.d.ts +101 -0
- package/dist/apps/scheduling-service.js +171 -0
- package/dist/apps/scheduling-service.js.map +1 -0
- package/dist/apps/services/AWSCognitoClient.d.ts +55 -0
- package/dist/apps/services/AWSCognitoClient.js +436 -0
- package/dist/apps/services/AWSCognitoClient.js.map +1 -0
- package/dist/apps/services/api/drafts.d.ts +7 -0
- package/dist/apps/services/api/drafts.js +236 -0
- package/dist/apps/services/api/drafts.js.map +1 -0
- package/dist/apps/services/api/notifications.d.ts +3 -0
- package/dist/apps/services/api/notifications.js +60 -0
- package/dist/apps/services/api/notifications.js.map +1 -0
- package/dist/apps/services/api/payment.d.ts +23 -0
- package/dist/apps/services/api/payment.js +235 -0
- package/dist/apps/services/api/payment.js.map +1 -0
- package/dist/apps/services/api/post-submission-attachment-urls.d.ts +7 -0
- package/dist/apps/services/api/post-submission-attachment-urls.js +19 -0
- package/dist/apps/services/api/post-submission-attachment-urls.js.map +1 -0
- package/dist/apps/services/api/prefill.d.ts +1 -0
- package/dist/apps/services/api/prefill.js +70 -0
- package/dist/apps/services/api/prefill.js.map +1 -0
- package/dist/apps/services/api/receipt-id.d.ts +2 -0
- package/dist/apps/services/api/receipt-id.js +54 -0
- package/dist/apps/services/api/receipt-id.js.map +1 -0
- package/dist/apps/services/api/scheduling.d.ts +38 -0
- package/dist/apps/services/api/scheduling.js +142 -0
- package/dist/apps/services/api/scheduling.js.map +1 -0
- package/dist/apps/services/api/submissions.d.ts +18 -0
- package/dist/apps/services/api/submissions.js +166 -0
- package/dist/apps/services/api/submissions.js.map +1 -0
- package/dist/apps/services/cognito.d.ts +302 -0
- package/dist/apps/services/cognito.js +441 -0
- package/dist/apps/services/cognito.js.map +1 -0
- package/dist/apps/services/draft-data-store.d.ts +16 -0
- package/dist/apps/services/draft-data-store.js +115 -0
- package/dist/apps/services/draft-data-store.js.map +1 -0
- package/dist/apps/services/errors/oneBlinkAppsError.d.ts +35 -0
- package/dist/apps/services/errors/oneBlinkAppsError.js +32 -0
- package/dist/apps/services/errors/oneBlinkAppsError.js.map +1 -0
- package/dist/apps/services/external-id-generation.d.ts +4 -0
- package/dist/apps/services/external-id-generation.js +59 -0
- package/dist/apps/services/external-id-generation.js.map +1 -0
- package/dist/apps/services/fetch.d.ts +12 -0
- package/dist/apps/services/fetch.js +95 -0
- package/dist/apps/services/fetch.js.map +1 -0
- package/dist/apps/services/forms-key.d.ts +51 -0
- package/dist/apps/services/forms-key.js +83 -0
- package/dist/apps/services/forms-key.js.map +1 -0
- package/dist/apps/services/generate-generic-error.d.ts +3 -0
- package/dist/apps/services/generate-generic-error.js +52 -0
- package/dist/apps/services/generate-generic-error.js.map +1 -0
- package/dist/apps/services/generateOneBlinkDownloader.d.ts +2 -0
- package/dist/apps/services/generateOneBlinkDownloader.js +11 -0
- package/dist/apps/services/generateOneBlinkDownloader.js.map +1 -0
- package/dist/apps/services/generateOneBlinkUploader.d.ts +2 -0
- package/dist/apps/services/generateOneBlinkUploader.js +11 -0
- package/dist/apps/services/generateOneBlinkUploader.js.map +1 -0
- package/dist/apps/services/getDeviceInformation.d.ts +17 -0
- package/dist/apps/services/getDeviceInformation.js +38 -0
- package/dist/apps/services/getDeviceInformation.js.map +1 -0
- package/dist/apps/services/integration-elements.d.ts +383 -0
- package/dist/apps/services/integration-elements.js +761 -0
- package/dist/apps/services/integration-elements.js.map +1 -0
- package/dist/apps/services/job-prefill.d.ts +40 -0
- package/dist/apps/services/job-prefill.js +78 -0
- package/dist/apps/services/job-prefill.js.map +1 -0
- package/dist/apps/services/payment-providers/BPOINTPaymentProvider.d.ts +29 -0
- package/dist/apps/services/payment-providers/BPOINTPaymentProvider.js +59 -0
- package/dist/apps/services/payment-providers/BPOINTPaymentProvider.js.map +1 -0
- package/dist/apps/services/payment-providers/CPPayPaymentProvider.d.ts +27 -0
- package/dist/apps/services/payment-providers/CPPayPaymentProvider.js +63 -0
- package/dist/apps/services/payment-providers/CPPayPaymentProvider.js.map +1 -0
- package/dist/apps/services/payment-providers/NSWGovPayPaymentProvider.d.ts +30 -0
- package/dist/apps/services/payment-providers/NSWGovPayPaymentProvider.js +116 -0
- package/dist/apps/services/payment-providers/NSWGovPayPaymentProvider.js.map +1 -0
- package/dist/apps/services/payment-providers/WestpacQuickStreamPaymentProvider.d.ts +49 -0
- package/dist/apps/services/payment-providers/WestpacQuickStreamPaymentProvider.js +116 -0
- package/dist/apps/services/payment-providers/WestpacQuickStreamPaymentProvider.js.map +1 -0
- package/dist/apps/services/payment-providers/receipt-items.d.ts +8 -0
- package/dist/apps/services/payment-providers/receipt-items.js +58 -0
- package/dist/apps/services/payment-providers/receipt-items.js.map +1 -0
- package/dist/apps/services/pending-queue.d.ts +150 -0
- package/dist/apps/services/pending-queue.js +316 -0
- package/dist/apps/services/pending-queue.js.map +1 -0
- package/dist/apps/services/prepareSubmissionData.d.ts +2 -0
- package/dist/apps/services/prepareSubmissionData.js +113 -0
- package/dist/apps/services/prepareSubmissionData.js.map +1 -0
- package/dist/apps/services/query-string.d.ts +1 -0
- package/dist/apps/services/query-string.js +16 -0
- package/dist/apps/services/query-string.js.map +1 -0
- package/dist/apps/services/replaceInjectablesWithSubmissionValues.d.ts +3 -0
- package/dist/apps/services/replaceInjectablesWithSubmissionValues.js +18 -0
- package/dist/apps/services/replaceInjectablesWithSubmissionValues.js.map +1 -0
- package/dist/apps/services/schedulingHandlers.d.ts +36 -0
- package/dist/apps/services/schedulingHandlers.js +76 -0
- package/dist/apps/services/schedulingHandlers.js.map +1 -0
- package/dist/apps/services/server-validation.d.ts +2 -0
- package/dist/apps/services/server-validation.js +36 -0
- package/dist/apps/services/server-validation.js.map +1 -0
- package/dist/apps/services/serverRequest.d.ts +5 -0
- package/dist/apps/services/serverRequest.js +24 -0
- package/dist/apps/services/serverRequest.js.map +1 -0
- package/dist/apps/services/submit.d.ts +19 -0
- package/dist/apps/services/submit.js +219 -0
- package/dist/apps/services/submit.js.map +1 -0
- package/dist/apps/services/uploadAttachment.d.ts +52 -0
- package/dist/apps/services/uploadAttachment.js +73 -0
- package/dist/apps/services/uploadAttachment.js.map +1 -0
- package/dist/apps/services/user-token.d.ts +27 -0
- package/dist/apps/services/user-token.js +33 -0
- package/dist/apps/services/user-token.js.map +1 -0
- package/dist/apps/services/utils.d.ts +12 -0
- package/dist/apps/services/utils.js +100 -0
- package/dist/apps/services/utils.js.map +1 -0
- package/dist/apps/submission-service.d.ts +226 -0
- package/dist/apps/submission-service.js +425 -0
- package/dist/apps/submission-service.js.map +1 -0
- package/dist/apps/tenants.d.ts +29 -0
- package/dist/apps/tenants.js +127 -0
- package/dist/apps/tenants.js.map +1 -0
- package/dist/apps/types/form.d.ts +4 -0
- package/dist/apps/types/form.js +2 -0
- package/dist/apps/types/form.js.map +1 -0
- package/dist/apps/types/payments.d.ts +45 -0
- package/dist/apps/types/payments.js +2 -0
- package/dist/apps/types/payments.js.map +1 -0
- package/dist/apps/types/scheduling.d.ts +5 -0
- package/dist/apps/types/scheduling.js +2 -0
- package/dist/apps/types/scheduling.js.map +1 -0
- package/dist/apps/types/submissions.d.ts +175 -0
- package/dist/apps/types/submissions.js +2 -0
- package/dist/apps/types/submissions.js.map +1 -0
- package/dist/components/CustomAccordion.d.ts +3 -3
- package/dist/components/Lists.d.ts +4 -1
- package/dist/components/formStore/display/ElementDisplay.js +2 -2
- package/dist/components/formStore/display/ElementDisplay.js.map +1 -1
- package/dist/components/formStore/useFormStoreTableContext.d.ts +2 -2
- package/dist/components/mfa/MultiFactorAuthentication.d.ts +1 -1
- package/dist/components/renderer/LookupNotification.js +1 -1
- package/dist/components/renderer/LookupNotification.js.map +1 -1
- package/dist/form-elements/FormElementAutocomplete.js +1 -1
- package/dist/form-elements/FormElementAutocomplete.js.map +1 -1
- package/dist/hooks/attachments/useAttachment.js +1 -1
- package/dist/hooks/attachments/useAttachment.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/services/download-file.js +1 -1
- package/dist/services/download-file.js.map +1 -1
- package/dist/styles.css +208 -204
- package/package.json +42 -34
|
@@ -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":"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","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"]}
|