oro-sdk-apis 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +35 -0
  3. package/dist/index.d.ts +27 -0
  4. package/dist/index.js +8 -0
  5. package/dist/models/consult.d.ts +102 -0
  6. package/dist/models/diagnosis.d.ts +122 -0
  7. package/dist/models/error.d.ts +12 -0
  8. package/dist/models/guard.d.ts +119 -0
  9. package/dist/models/index.d.ts +8 -0
  10. package/dist/models/practice.d.ts +353 -0
  11. package/dist/models/shared.d.ts +8 -0
  12. package/dist/models/vault.d.ts +124 -0
  13. package/dist/models/workflow.d.ts +106 -0
  14. package/dist/oro-sdk-apis.cjs.development.js +3019 -0
  15. package/dist/oro-sdk-apis.cjs.development.js.map +1 -0
  16. package/dist/oro-sdk-apis.cjs.production.min.js +2 -0
  17. package/dist/oro-sdk-apis.cjs.production.min.js.map +1 -0
  18. package/dist/oro-sdk-apis.esm.js +3051 -0
  19. package/dist/oro-sdk-apis.esm.js.map +1 -0
  20. package/dist/services/api.d.ts +11 -0
  21. package/dist/services/axios.d.ts +14 -0
  22. package/dist/services/consult.d.ts +54 -0
  23. package/dist/services/diagnosis.d.ts +44 -0
  24. package/dist/services/guard.d.ts +92 -0
  25. package/dist/services/index.d.ts +9 -0
  26. package/dist/services/practice.d.ts +98 -0
  27. package/dist/services/teller.d.ts +9 -0
  28. package/dist/services/vault.d.ts +54 -0
  29. package/dist/services/workflow.d.ts +21 -0
  30. package/package.json +62 -0
  31. package/src/index.ts +56 -0
  32. package/src/models/consult.ts +110 -0
  33. package/src/models/diagnosis.ts +141 -0
  34. package/src/models/error.ts +6 -0
  35. package/src/models/guard.ts +136 -0
  36. package/src/models/index.ts +8 -0
  37. package/src/models/practice.ts +411 -0
  38. package/src/models/shared.ts +6 -0
  39. package/src/models/vault.ts +158 -0
  40. package/src/models/workflow.ts +142 -0
  41. package/src/services/api.ts +77 -0
  42. package/src/services/axios.ts +91 -0
  43. package/src/services/consult.ts +264 -0
  44. package/src/services/diagnosis.ts +144 -0
  45. package/src/services/guard.ts +228 -0
  46. package/src/services/index.ts +9 -0
  47. package/src/services/practice.ts +430 -0
  48. package/src/services/teller.ts +39 -0
  49. package/src/services/vault.ts +178 -0
  50. package/src/services/workflow.ts +36 -0
@@ -0,0 +1,430 @@
1
+ import { Buffer } from 'buffer/'
2
+ import { sha256 } from 'hash.js'
3
+ import { PracticeAccount, Uuid } from '../models'
4
+ import {
5
+ Assignment,
6
+ PlanType,
7
+ Practice,
8
+ PracticeConfigKind,
9
+ PracticeConfigs,
10
+ PracticePayment,
11
+ PracticePaymentIntent,
12
+ PracticePlan,
13
+ PracticePlanPrices,
14
+ PracticeWorkflow,
15
+ PracticeWorkflowWithTagSpecialty,
16
+ Practitioner,
17
+ PractitionerLicense,
18
+ PractitionerPreference,
19
+ PractitionerQuota,
20
+ PractitionerRole,
21
+ WorkflowType,
22
+ } from '../models/practice'
23
+ import { APIService } from './api'
24
+
25
+ export class PracticeService {
26
+ constructor(private api: APIService, private baseURL: string) {}
27
+
28
+ /**
29
+ * This function get the practice from the URL of a practice
30
+ * It is the entry point of our web apps
31
+ * @param practiceURL URL of the practice to search
32
+ * @param hydratePracticeConfigs (optional) if set true it the Practice field configs will be set
33
+ * @param accounts (optional) if set true it the Practice field accounts will be set
34
+ * @returns the found practice or undefined
35
+ */
36
+ public practiceGetFromURL(
37
+ practiceURL: string,
38
+ params?: {
39
+ hydratePracticeConfigs?: boolean
40
+ accounts?: boolean
41
+ }
42
+ ): Promise<Practice | undefined> {
43
+ return this.api.get<Practice | undefined>(`${this.baseURL}/v1/practices`, {
44
+ params: {
45
+ url_practice: practiceURL,
46
+ ...params,
47
+ },
48
+ })
49
+ }
50
+
51
+ public practiceGetFromUuid(practiceUuid: Uuid, locale?: string, withAccounts?: boolean): Promise<Practice> {
52
+ return this.api.get<Practice>(`${this.baseURL}/v1/practices/${practiceUuid}`, {
53
+ params: { locale, accounts: withAccounts },
54
+ })
55
+ }
56
+
57
+ /// Practice Configs
58
+
59
+ /**
60
+ * This function retrieves all configs of a specific practice
61
+ * @param practiceUuid uuid of the practice
62
+ * @returns the practice configs
63
+ */
64
+ public practiceConfigGetFromPracticeUuid(practiceUuid: Uuid): Promise<PracticeConfigs[]> {
65
+ return this.api.get<PracticeConfigs[]>(`${this.baseURL}/v1/practices/${practiceUuid}/configs`)
66
+ }
67
+
68
+ /**
69
+ * This function retrieves a specific config of a practice
70
+ * @param practiceUuid uuid of the practice
71
+ * @param kind of the config
72
+ * @returns the practice config
73
+ */
74
+ public practiceConfigGetByKindForPracticeUuid(
75
+ practiceUuid: Uuid,
76
+ kind: PracticeConfigKind
77
+ ): Promise<PracticeConfigs> {
78
+ return this.api.get<PracticeConfigs>(`${this.baseURL}/v1/practices/${practiceUuid}/configs/${kind}`)
79
+ }
80
+
81
+ /**
82
+ * This function creates a config for a specific practice
83
+ * @param practiceUuid uuid of the practice
84
+ * @param config the config to add to the practice
85
+ * @returns the created practice config
86
+ */
87
+ public practiceConfigCreateForPracticeUuid(practiceUuid: Uuid, config: PracticeConfigs): Promise<PracticeConfigs> {
88
+ return this.api.post<PracticeConfigs>(`${this.baseURL}/v1/practices/${practiceUuid}/configs`, config)
89
+ }
90
+
91
+ /**
92
+ * This function updates a specific config of a practice
93
+ * @param practiceUuid uuid of the practice
94
+ * @param config the config to update
95
+ * @returns the practice config
96
+ */
97
+ public practiceConfigUpdate(config: PracticeConfigs): Promise<PracticeConfigs> {
98
+ return this.api.put<PracticeConfigs>(
99
+ `${this.baseURL}/v1/practices/${config.uuidPractice}/configs/${config.kind}`,
100
+ config
101
+ )
102
+ }
103
+
104
+ /// Accounts
105
+ public practiceGetAccounts(practiceUuid: Uuid): Promise<PracticeAccount[]> {
106
+ return this.api.get<PracticeAccount[]>(`${this.baseURL}/v1/practices/${practiceUuid}/accounts`)
107
+ }
108
+
109
+ public practiceGetAccount(practiceUuid: Uuid, accountUuid: Uuid): Promise<PracticeAccount> {
110
+ return this.api.get<PracticeAccount>(`${this.baseURL}/v1/practices/${practiceUuid}/accounts/${accountUuid}`)
111
+ }
112
+
113
+ /// Workflows
114
+ public practiceGetWorkflows(practiceUuid: Uuid): Promise<PracticeWorkflow[]> {
115
+ return this.api.get<PracticeWorkflow[]>(`${this.baseURL}/v1/practices/${practiceUuid}/workflows`)
116
+ }
117
+
118
+ public practiceGetWorkflow(
119
+ practiceUuid: Uuid,
120
+ workflowType: WorkflowType
121
+ ): Promise<PracticeWorkflowWithTagSpecialty> {
122
+ return this.api.get<PracticeWorkflowWithTagSpecialty>(
123
+ `${this.baseURL}/v1/practices/${practiceUuid}/workflows/${workflowType}`
124
+ )
125
+ }
126
+
127
+ /// Plans
128
+ public practiceGetPlans(practiceUuid: Uuid, planType?: PlanType): Promise<PracticePlan[]> {
129
+ return this.api.get<PracticePlan[]>(`${this.baseURL}/v1/practices/${practiceUuid}/plans`, {
130
+ params: { kind: planType },
131
+ })
132
+ }
133
+
134
+ public practiceGetPlan(practiceUuid: Uuid, planId: number): Promise<PracticePlan> {
135
+ return this.api.get<PracticePlan>(`${this.baseURL}/v1/practices/${practiceUuid}/plans/${planId}`)
136
+ }
137
+
138
+ public practiceGetPlanPrices(practiceUuid: Uuid, planId: number): Promise<PracticePlanPrices> {
139
+ return this.api.get<PracticePlanPrices>(`${this.baseURL}/v1/practices/${practiceUuid}/plans/${planId}/prices`)
140
+ }
141
+
142
+ // Payments
143
+ public practiceGetPayments(practiceUuid: Uuid, planType?: PlanType): Promise<PracticePayment[]> {
144
+ return this.api.get<PracticePayment[]>(`${this.baseURL}/v1/practices/${practiceUuid}/payments`, {
145
+ params: { kind: planType },
146
+ })
147
+ }
148
+
149
+ public practiceGetPayment(practiceUuid: Uuid, idStripeInvoiceOrPaymentIntent: string): Promise<PracticePayment> {
150
+ return this.api.get<PracticePayment>(
151
+ `${this.baseURL}/v1/practices/${practiceUuid}/payments/${idStripeInvoiceOrPaymentIntent}`
152
+ )
153
+ }
154
+
155
+ public practiceGetPaymentForStripePaymentIntentWithID(
156
+ practiceUuid: Uuid,
157
+ stripePaymentIntentId: number
158
+ ): Promise<PracticePayment> {
159
+ return this.api.get<PracticePayment>(
160
+ `${this.baseURL}/v1/practices/${practiceUuid}/payments/${stripePaymentIntentId}`
161
+ )
162
+ }
163
+
164
+ // Payments Intent
165
+ public practiceGetPaymentsIntents(practiceUuid: Uuid, planType?: PlanType): Promise<PracticePaymentIntent[]> {
166
+ return this.api.get<PracticePaymentIntent[]>(`${this.baseURL}/v1/practices/${practiceUuid}/payments/intents`, {
167
+ params: { kind: planType },
168
+ })
169
+ }
170
+
171
+ /**
172
+ * This function return the user hased email to be use for creating payment intent
173
+ * @param email the email to hash
174
+ * @returns a hashed email
175
+ */
176
+ public getPaymentIntentHashedEmail(email: string): string {
177
+ return Buffer.from(sha256().update(email.toLowerCase()).digest('hex'), 'hex').toString('base64')
178
+ }
179
+
180
+ public practiceCreatePaymentsIntent(
181
+ practiceUuid: Uuid,
182
+ planId: number,
183
+ userEmail: string,
184
+ isoLocality?: string,
185
+ url_subdomain?: string,
186
+ promotionCode?: string
187
+ ): Promise<PracticePaymentIntent> {
188
+ return this.api.post<PracticePaymentIntent>(
189
+ `${this.baseURL}/v1/practices/${practiceUuid}/payments/intents/`,
190
+ {
191
+ idPlan: planId,
192
+ hashUserEmail: userEmail ? this.getPaymentIntentHashedEmail(userEmail) : undefined,
193
+ isoLocality,
194
+ },
195
+ { params: { url_subdomain, promotionCode } }
196
+ )
197
+ }
198
+
199
+ public practiceGetPaymentsIntent(practiceUuid: Uuid, paymentIntentId: number): Promise<PracticePaymentIntent> {
200
+ return this.api.get<PracticePaymentIntent>(
201
+ `${this.baseURL}/v1/practices/${practiceUuid}/payments/intents/${paymentIntentId}`
202
+ )
203
+ }
204
+
205
+ public practiceUpdatePaymentsIntent(
206
+ practiceUuid: string,
207
+ idPraticePaymentIntent: number,
208
+ practicePaymentIntent: PracticePaymentIntent,
209
+ userEmail: string,
210
+ promotionCode?: string
211
+ ) {
212
+ return this.api.put<PracticePaymentIntent>(
213
+ `${this.baseURL}/v1/practices/${practiceUuid}/payments/intents/${idPraticePaymentIntent}`,
214
+ {
215
+ ...practicePaymentIntent,
216
+ hashUserEmail: userEmail ? this.getPaymentIntentHashedEmail(userEmail) : undefined,
217
+ },
218
+ { params: { promotionCode } }
219
+ )
220
+ }
221
+
222
+ // Practitioner
223
+ public practiceGetPractitioners(practiceUuid: Uuid): Promise<Practitioner[]> {
224
+ return this.api.get<Practitioner[]>(`${this.baseURL}/v1/practices/${practiceUuid}/practitioners`)
225
+ }
226
+
227
+ public practiceUpdatePractitioner(
228
+ practiceUuid: Uuid,
229
+ practitionerUuid: Uuid,
230
+ requestBody: Practitioner
231
+ ): Promise<Practitioner> {
232
+ return this.api.put<Practitioner>(
233
+ `${this.baseURL}/v1/practices/${practiceUuid}/practitioners/${practitionerUuid}`,
234
+ requestBody
235
+ )
236
+ }
237
+
238
+ public practiceGetPractitioner(practiceUuid: Uuid, practitionerUuid: Uuid): Promise<Practitioner> {
239
+ return this.api.get<Practitioner>(
240
+ `${this.baseURL}/v1/practices/${practiceUuid}/practitioners/${practitionerUuid}`
241
+ )
242
+ }
243
+
244
+ // Practitioner Licenses
245
+ public practiceGetPractitionerLicenses(practiceUuid: Uuid, practitionerUuid: Uuid): Promise<PractitionerLicense[]> {
246
+ return this.api.get<PractitionerLicense[]>(
247
+ `${this.baseURL}/v1/practices/${practiceUuid}/practitioners/${practitionerUuid}/licenses`
248
+ )
249
+ }
250
+
251
+ public practiceCreatePractitionerLicense(
252
+ practiceUuid: Uuid,
253
+ practitionerUuid: Uuid,
254
+ requestBody: PractitionerLicense
255
+ ): Promise<PractitionerLicense> {
256
+ return this.api.post<PractitionerLicense>(
257
+ `${this.baseURL}/v1/practices/${practiceUuid}/practitioners/${practitionerUuid}/licenses`,
258
+ requestBody
259
+ )
260
+ }
261
+
262
+ public practiceUpdatePractitionerLicense(
263
+ practiceUuid: Uuid,
264
+ practitionerUuid: Uuid,
265
+ licenseId: number,
266
+ requestBody: PractitionerLicense
267
+ ): Promise<PractitionerLicense> {
268
+ return this.api.put<PractitionerLicense>(
269
+ `${this.baseURL}/v1/practices/${practiceUuid}/practitioners/${practitionerUuid}/licenses/${licenseId}`,
270
+ requestBody
271
+ )
272
+ }
273
+
274
+ public practiceGetPractitionerLicense(
275
+ practiceUuid: Uuid,
276
+ practitionerUuid: Uuid,
277
+ licenseId: number
278
+ ): Promise<PractitionerLicense> {
279
+ return this.api.get<PractitionerLicense>(
280
+ `${this.baseURL}/v1/practices/${practiceUuid}/practitioners/${practitionerUuid}/licenses/${licenseId}`
281
+ )
282
+ }
283
+
284
+ // Practitioner Preferences
285
+ public practiceGetPractitionerPreferences(
286
+ practiceUuid: Uuid,
287
+ practitionerUuid: Uuid
288
+ ): Promise<PractitionerPreference[]> {
289
+ return this.api.get<PractitionerPreference[]>(
290
+ `${this.baseURL}/v1/practices/${practiceUuid}/practitioners/${practitionerUuid}/preferences`
291
+ )
292
+ }
293
+
294
+ public practiceCreatePractitionerPreference(
295
+ practiceUuid: Uuid,
296
+ practitionerUuid: Uuid,
297
+ requestBody: PractitionerPreference
298
+ ): Promise<PractitionerPreference> {
299
+ return this.api.post<PractitionerPreference>(
300
+ `${this.baseURL}/v1/practices/${practiceUuid}/practitioners/${practitionerUuid}/preferences`,
301
+ requestBody
302
+ )
303
+ }
304
+
305
+ public practiceUpdatePractitionerPreference(
306
+ practiceUuid: Uuid,
307
+ practitionerUuid: Uuid,
308
+ preferenceId: number,
309
+ requestBody: PractitionerPreference
310
+ ): Promise<PractitionerPreference> {
311
+ return this.api.put<PractitionerPreference>(
312
+ `${this.baseURL}/v1/practices/${practiceUuid}/practitioners/${practitionerUuid}/preferences/${preferenceId}`,
313
+ requestBody
314
+ )
315
+ }
316
+
317
+ public practiceGetPractitionerPreference(
318
+ practiceUuid: Uuid,
319
+ practitionerUuid: Uuid,
320
+ preferenceId: number
321
+ ): Promise<PractitionerPreference> {
322
+ return this.api.get<PractitionerPreference>(
323
+ `${this.baseURL}/v1/practices/${practiceUuid}/practitioners/${practitionerUuid}/preferences/${preferenceId}`
324
+ )
325
+ }
326
+
327
+ // Practitioner Roles
328
+ public practiceGetPractitionerRoles(practiceUuid: Uuid, practitionerUuid: Uuid): Promise<PractitionerRole[]> {
329
+ return this.api.get<PractitionerRole[]>(
330
+ `${this.baseURL}/v1/practices/${practiceUuid}/practitioners/${practitionerUuid}/roles`
331
+ )
332
+ }
333
+
334
+ public practiceCreatePractitionerRole(
335
+ practiceUuid: Uuid,
336
+ practitionerUuid: Uuid,
337
+ requestBody: PractitionerRole
338
+ ): Promise<PractitionerRole> {
339
+ return this.api.post<PractitionerRole>(
340
+ `${this.baseURL}/v1/practices/${practiceUuid}/practitioners/${practitionerUuid}/roles`,
341
+ requestBody
342
+ )
343
+ }
344
+
345
+ public practiceDeletePractitionerRoles(practiceUuid: Uuid, practitionerUuid: Uuid): Promise<PractitionerRole> {
346
+ return this.api.deleteRequest<PractitionerRole>(
347
+ `${this.baseURL}/v1/practices/${practiceUuid}/practitioners/${practitionerUuid}/roles`
348
+ )
349
+ }
350
+
351
+ public practiceUpdatePractitionerRole(
352
+ practiceUuid: Uuid,
353
+ practitionerUuid: Uuid,
354
+ roleId: number,
355
+ requestBody: PractitionerRole
356
+ ): Promise<PractitionerRole> {
357
+ return this.api.put<PractitionerRole>(
358
+ `${this.baseURL}/v1/practices/${practiceUuid}/practitioners/${practitionerUuid}/roles/${roleId}`,
359
+ requestBody
360
+ )
361
+ }
362
+
363
+ public practiceGetPractitionerRole(
364
+ practiceUuid: Uuid,
365
+ practitionerUuid: Uuid,
366
+ roleId: number
367
+ ): Promise<PractitionerRole> {
368
+ return this.api.get<PractitionerRole>(
369
+ `${this.baseURL}/v1/practices/${practiceUuid}/practitioners/${practitionerUuid}/roles/${roleId}`
370
+ )
371
+ }
372
+
373
+ public practiceDeletePractitionerRole(
374
+ practiceUuid: Uuid,
375
+ practitionerUuid: Uuid,
376
+ roleId: number
377
+ ): Promise<PractitionerRole> {
378
+ return this.api.deleteRequest<PractitionerRole>(
379
+ `${this.baseURL}/v1/practices/${practiceUuid}/practitioners/${practitionerUuid}/roles/${roleId}`
380
+ )
381
+ }
382
+
383
+ // Practitioner signature
384
+
385
+ /**
386
+ * This function returns the practitioner's signature as a Blob
387
+ * @param practiceUuid the practice uuid of the practitioner
388
+ * @param practitionerUuid the practitioner uuid
389
+ * @returns a blob representing the signature
390
+ */
391
+ public practiceGetPractitionerSignature(practiceUuid: Uuid, practitionerUuid: Uuid): Promise<Blob> {
392
+ return this.api.get<Blob>(
393
+ `${this.baseURL}/v1/practices/${practiceUuid}/practitioners/${practitionerUuid}/signature`,
394
+ { responseType: 'blob' }
395
+ )
396
+ }
397
+
398
+ // Assignments
399
+ public practiceGetAssignments(practiceUuid: Uuid): Promise<Assignment[]> {
400
+ return this.api.get<Assignment[]>(`${this.baseURL}/v1/practices/${practiceUuid}/assignments`)
401
+ }
402
+
403
+ public practiceCreateAssignment(practiceUuid: Uuid, requestBody: Assignment): Promise<Assignment> {
404
+ return this.api.post<Assignment>(`${this.baseURL}/v1/practices/${practiceUuid}/assignments`, requestBody)
405
+ }
406
+
407
+ public practiceUpdateAssignment(
408
+ practiceUuid: Uuid,
409
+ assignmentId: number,
410
+ requestBody: Assignment
411
+ ): Promise<Assignment> {
412
+ return this.api.put<Assignment>(
413
+ `${this.baseURL}/v1/practices/${practiceUuid}/assignments/${assignmentId}`,
414
+ requestBody
415
+ )
416
+ }
417
+
418
+ public practiceGetAssignment(practiceUuid: Uuid, assignmentId: number): Promise<Assignment> {
419
+ return this.api.get<Assignment>(`${this.baseURL}/v1/practices/${practiceUuid}/assignments/${assignmentId}`)
420
+ }
421
+
422
+ // Quotas
423
+ public practiceGetQuotas(practiceUuid: Uuid): Promise<PractitionerQuota[]> {
424
+ return this.api.get<PractitionerQuota[]>(`${this.baseURL}/v1/practices/${practiceUuid}/quotas`)
425
+ }
426
+
427
+ public practiceGetQuota(practiceUuid: Uuid, quotaId: number): Promise<PractitionerQuota> {
428
+ return this.api.get<PractitionerQuota>(`${this.baseURL}/v1/practices/${practiceUuid}/quotas/${quotaId}`)
429
+ }
430
+ }
@@ -0,0 +1,39 @@
1
+ import { APIService } from './api'
2
+ import { Consult, DataCreateResponse, LockboxDataRequest, MedicalStatus, Uuid } from '../models'
3
+ export class TellerService {
4
+ constructor(private api: APIService, private baseURL: string) { }
5
+
6
+ public async lockboxDataStore(
7
+ lockboxUuid: Uuid,
8
+ req: LockboxDataRequest,
9
+ lockboxOwnerUuid?: Uuid,
10
+ previousDataUuid?: Uuid
11
+ ): Promise<DataCreateResponse> {
12
+ return this.api.post<DataCreateResponse>(
13
+ `${this.baseURL}/v1/lockboxes/${lockboxUuid}/data`,
14
+ req,
15
+ {
16
+ params: {
17
+ lockbox_owner_uuid: lockboxOwnerUuid,
18
+ data_uuid: previousDataUuid,
19
+ },
20
+ }
21
+ )
22
+ }
23
+
24
+ public updateConsultByUUID(
25
+ patientUuid: Uuid,
26
+ uuidConsult: Uuid,
27
+ statusMedical: MedicalStatus,
28
+ neverExpires?: boolean,
29
+ ): Promise<Consult> {
30
+ return this.api.put<Consult>(
31
+ `${this.baseURL}/v1/consults/${uuidConsult}`,
32
+ {
33
+ patientUuid,
34
+ statusMedical,
35
+ neverExpires,
36
+ },
37
+ )
38
+ }
39
+ }
@@ -0,0 +1,178 @@
1
+ import { APIService } from './api'
2
+ import {
3
+ DataCreateResponse,
4
+ DataResponse,
5
+ GrantedLockboxes,
6
+ LockboxCreateResponse,
7
+ LockboxDataRequest,
8
+ LockboxGrantRequest,
9
+ LockboxManifest,
10
+ SharedSecretResponse,
11
+ Uuid,
12
+ EncryptedVaultIndex,
13
+ IndexKey,
14
+ EncryptedIndexEntry
15
+ } from '../models'
16
+
17
+ export class VaultService {
18
+ constructor(private api: APIService, private baseURL: string) { }
19
+
20
+ public async lockboxCreate(lockboxMetadata?: Object): Promise<LockboxCreateResponse> {
21
+ return this.api.post<LockboxCreateResponse>(
22
+ `${this.baseURL}/v1/lockbox`,
23
+ lockboxMetadata
24
+ )
25
+ }
26
+
27
+ public async lockboxMetadataAdd(
28
+ lockboxUuid: Uuid,
29
+ lockboxMetadata: Object,
30
+ lockboxOwnerUuid?: Uuid
31
+ ): Promise<LockboxCreateResponse> {
32
+ return this.api.put<LockboxCreateResponse>(
33
+ `${this.baseURL}/v1/lockbox/${lockboxUuid}`,
34
+ lockboxMetadata,
35
+ { params: { lockbox_owner_uuid: lockboxOwnerUuid } }
36
+ )
37
+ }
38
+
39
+ public async lockboxSecretGet(
40
+ lockboxUuid: Uuid,
41
+ lockboxOwnerUuid?: Uuid
42
+ ): Promise<SharedSecretResponse> {
43
+ return this.api.get<SharedSecretResponse>(
44
+ `${this.baseURL}/v1/lockboxes/${lockboxUuid}/secret`,
45
+ { params: { lockbox_owner_uuid: lockboxOwnerUuid } }
46
+ )
47
+ }
48
+
49
+ public async lockboxGrant(
50
+ lockboxUuid: Uuid,
51
+ req: LockboxGrantRequest,
52
+ lockboxOwnerUuid?: Uuid
53
+ ): Promise<void> {
54
+ return this.api.post<void>(
55
+ `${this.baseURL}/v1/lockboxes/${lockboxUuid}/grant`,
56
+ req,
57
+ { params: { lockbox_owner_uuid: lockboxOwnerUuid } }
58
+ )
59
+ }
60
+
61
+ /**
62
+ * Get all lockboxes granted to user
63
+ * @param filter filter of lockbox metadata
64
+ * @returns decrypted lockboxes granted to user
65
+ */
66
+ public async grantsGet(): Promise<GrantedLockboxes> {
67
+ return this.api.get<GrantedLockboxes>(`${this.baseURL}/v1/grants`)
68
+ }
69
+
70
+ /**
71
+ * This function create or update a data into the vault.
72
+ * @note At creation it is necessary to have all `req` filled
73
+ * @note When setting `previousDataUuid` you are updating the data. `req` metadata fields are optional.
74
+ * @param lockboxUuid The lockbox uuid the data will be stored in
75
+ * @param req The request (please see notes)
76
+ * @param lockboxOwnerUuid The uuid of the owner of the lockbox (@deprecated)
77
+ * @param previousDataUuid The data uuid of the data you want to update
78
+ * @returns
79
+ */
80
+ public async lockboxDataStore(
81
+ lockboxUuid: Uuid,
82
+ req: LockboxDataRequest,
83
+ lockboxOwnerUuid?: Uuid,
84
+ previousDataUuid?: Uuid
85
+ ): Promise<DataCreateResponse> {
86
+ return this.api.post<DataCreateResponse>(
87
+ `${this.baseURL}/v1/lockboxes/${lockboxUuid}/data`,
88
+ req,
89
+ {
90
+ params: {
91
+ lockbox_owner_uuid: lockboxOwnerUuid,
92
+ data_uuid: previousDataUuid,
93
+ },
94
+ }
95
+ )
96
+ }
97
+
98
+ public async lockboxDataGet(
99
+ lockboxUuid: Uuid,
100
+ dataUuid: Uuid,
101
+ lockboxOwnerUuid?: Uuid,
102
+ stream: boolean = true
103
+ ): Promise<DataResponse> {
104
+ let data = await this.api.get(
105
+ `${this.baseURL}/v1/lockboxes/${lockboxUuid}/data/${dataUuid}`,
106
+ { params: { lockbox_owner_uuid: lockboxOwnerUuid, stream } }
107
+ )
108
+
109
+ // returned as stream, we need to put inside a DataResponse object
110
+ if (stream)
111
+ return { data }
112
+
113
+ return data
114
+ }
115
+
116
+ public async lockboxManifestGet(
117
+ lockboxUuid: Uuid,
118
+ filter?: Object,
119
+ lockboxOwnerUuid?: Uuid
120
+ ): Promise<LockboxManifest> {
121
+ return this.api.get(`${this.baseURL}/v1/lockboxes/${lockboxUuid}`, {
122
+ params: { lockbox_owner_uuid: lockboxOwnerUuid, filter },
123
+ })
124
+ }
125
+
126
+ public async lockboxMetadataGet(
127
+ lockboxUuid: Uuid,
128
+ fields: string[],
129
+ groupby: string[],
130
+ filter?: Object,
131
+ lockboxOwnerUuid?: Uuid
132
+ ): Promise<any[]> {
133
+ return this.api.get(`${this.baseURL}/v1/lockboxes/${lockboxUuid}/metadata`, {
134
+ params: { lockbox_owner_uuid: lockboxOwnerUuid, fields, groupby, filter },
135
+ })
136
+ }
137
+
138
+ /**
139
+ * inserts or updates encrypted index entries
140
+ * @note if the index data is being inserted for a user other than the requester, use `indexOwnerUuid`
141
+ * @note if a uuid for an entry is provided, the service will perform an update
142
+ * @param entries the encrypted index data
143
+ * @param indexOwnerUuid
144
+ */
145
+ public async vaultIndexPut(entries: EncryptedVaultIndex, indexOwnerUuid?: Uuid): Promise<void> {
146
+ return this.api.put(`${this.baseURL}/v1/index`,
147
+ entries,
148
+ {
149
+ params: {
150
+ index_owner_uuid: indexOwnerUuid,
151
+ },
152
+ }
153
+ )
154
+ }
155
+
156
+ /**
157
+ * inserts or updates index snapshot for the provided index owner
158
+ * @note if the index data is being inserted for a user other than the requester, use `indexOwnerUuid`
159
+ * @param entry the encrypted index snapshot
160
+ */
161
+ public async vaultIndexSnapshotPut(entry: EncryptedIndexEntry): Promise<void> {
162
+ return this.api.put(`${this.baseURL}/v1/index-snapshot`, entry)
163
+ }
164
+
165
+ /**
166
+ * Retrieves the encrypted index from the vault for the requesting user
167
+ * @note index keys can be specified to narrow the scope of index being requested
168
+ * @param indexKeys accepted index fields determined by vault
169
+ * @param identifiers: an array of unique_hashes or consultation uuids used to identify an index entry
170
+ * @param timestamp the minimum timestamp that index entries were created
171
+ * @returns the encrypted index
172
+ */
173
+ public async vaultIndexGet(indexKeys: IndexKey[], identifiers?: string[], timestamp?: Date): Promise<EncryptedVaultIndex> {
174
+ return this.api.get<EncryptedVaultIndex>(`${this.baseURL}/v1/index`, {
175
+ params: { index_keys: indexKeys, identifiers, timestamp },
176
+ })
177
+ }
178
+ }
@@ -0,0 +1,36 @@
1
+ import { WorkflowData } from '../models/workflow'
2
+ import { APIService } from './api'
3
+
4
+ export class WorkflowService {
5
+ private v1Url: string
6
+
7
+ constructor(private api: APIService, url: string) {
8
+ this.v1Url = `${url}/v1`
9
+ }
10
+
11
+ /**
12
+ * This function returns all workflows
13
+ * @returns desired workflow
14
+ */
15
+ public getWorkflows(): Promise<WorkflowData[]> {
16
+ return this.api.get<WorkflowData[]>(`${this.v1Url}/workflows`)
17
+ }
18
+
19
+ /**
20
+ * This function retrieves a workflow. If `locale` is not found, it will try to find 'en' version of it.
21
+ * By default, will return most recent workflow of a specific `id`. `createdAt` can be used to select older version.
22
+ * @param id The uuid of the workflow
23
+ * @param locale (optional) The desired locale of the workflow (default: 'en')
24
+ * @param createdAt (optional) The creation date of the workflow (also used for versionning)
25
+ * @returns desired workflow
26
+ */
27
+ public getWorkflow(
28
+ id: string,
29
+ locale?: string,
30
+ createdAt?: string
31
+ ): Promise<WorkflowData> {
32
+ return this.api.get<WorkflowData>(`${this.v1Url}/workflows/${id}`, {
33
+ params: { locale, createdAt },
34
+ })
35
+ }
36
+ }