@openfn/language-dhis2 3.2.1 → 3.2.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/types/index.d.ts CHANGED
@@ -1,828 +1,3 @@
1
- /**
2
- * Execute a sequence of operations.
3
- * Wraps `language-common/execute`, and prepends initial state for DHIS2.
4
- * @example
5
- * execute(
6
- * create('foo'),
7
- * delete('bar')
8
- * )(state)
9
- * @constructor
10
- * @param {Operations} operations - Operations to be performed.
11
- * @returns {Operation}
12
- */
13
- declare function execute(...operations: Operations): Operation;
14
- declare class execute {
15
- /**
16
- * Execute a sequence of operations.
17
- * Wraps `language-common/execute`, and prepends initial state for DHIS2.
18
- * @example
19
- * execute(
20
- * create('foo'),
21
- * delete('bar')
22
- * )(state)
23
- * @constructor
24
- * @param {Operations} operations - Operations to be performed.
25
- * @returns {Operation}
26
- */
27
- constructor(...operations: Operations);
28
- }
29
- /**
30
- * Create a record
31
- * @public
32
- * @constructor
33
- * @param {string} resourceType - Type of resource to create. E.g. `trackedEntityInstances`, `programs`, `events`, ...
34
- * @param {Object} data - Data that will be used to create a given instance of resource. To create a single instance of a resource, `data` must be a javascript object, and to create multiple instances of a resources, `data` must be an array of javascript objects.
35
- * @param {Object} [options] - Optional `options` to define URL parameters via params (E.g. `filter`, `dimension` and other import parameters), request config (E.g. `auth`) and the DHIS2 apiVersion.
36
- * @param {function} [callback] - Optional callback to handle the response
37
- * @returns {Operation}
38
- * @example <caption>a program</caption>
39
- * create('programs', {
40
- * name: 'name 20',
41
- * shortName: 'n20',
42
- * programType: 'WITHOUT_REGISTRATION',
43
- * });
44
- * @example <caption>an event</caption>
45
- * create('events', {
46
- * program: 'eBAyeGv0exc',
47
- * orgUnit: 'DiszpKrYNg8',
48
- * status: 'COMPLETED',
49
- * });
50
- * @example <caption>a trackedEntityInstance</caption>
51
- * create('trackedEntityInstances', {
52
- * orgUnit: 'TSyzvBiovKh',
53
- * trackedEntityType: 'nEenWmSyUEp',
54
- * attributes: [
55
- * {
56
- * attribute: 'w75KJ2mc4zz',
57
- * value: 'Gigiwe',
58
- * },
59
- * ]
60
- * });
61
- * @example <caption>a dataSet</caption>
62
- * create('dataSets', { name: 'OpenFn Data Set', periodType: 'Monthly' });
63
- * @example <caption>a dataSetNotification</caption>
64
- * create('dataSetNotificationTemplates', {
65
- * dataSetNotificationTrigger: 'DATA_SET_COMPLETION',
66
- * notificationRecipient: 'ORGANISATION_UNIT_CONTACT',
67
- * name: 'Notification',
68
- * messageTemplate: 'Hello',
69
- * deliveryChannels: ['SMS'],
70
- * dataSets: [],
71
- * });
72
- * @example <caption>a dataElement</caption>
73
- * create('dataElements', {
74
- * aggregationType: 'SUM',
75
- * domainType: 'AGGREGATE',
76
- * valueType: 'NUMBER',
77
- * name: 'Paracetamol',
78
- * shortName: 'Para',
79
- * });
80
- * @example <caption>a dataElementGroup</caption>
81
- * create('dataElementGroups', {
82
- * name: 'Data Element Group 1',
83
- * dataElements: [],
84
- * });
85
- * @example <caption>a dataElementGroupSet</caption>
86
- * create('dataElementGroupSets', {
87
- * name: 'Data Element Group Set 4',
88
- * dataDimension: true,
89
- * shortName: 'DEGS4',
90
- * dataElementGroups: [],
91
- * });
92
- * @example <caption>a dataValueSet</caption>
93
- * create('dataValueSets', {
94
- * dataElement: 'f7n9E0hX8qk',
95
- * period: '201401',
96
- * orgUnit: 'DiszpKrYNg8',
97
- * value: '12',
98
- * });
99
- * @example <caption>a dataValueSet with related dataValues</caption>
100
- * create('dataValueSets', {
101
- * dataSet: 'pBOMPrpg1QX',
102
- * completeDate: '2014-02-03',
103
- * period: '201401',
104
- * orgUnit: 'DiszpKrYNg8',
105
- * dataValues: [
106
- * {
107
- * dataElement: 'f7n9E0hX8qk',
108
- * value: '1',
109
- * },
110
- * {
111
- * dataElement: 'Ix2HsbDMLea',
112
- * value: '2',
113
- * },
114
- * {
115
- * dataElement: 'eY5ehpbEsB7',
116
- * value: '3',
117
- * },
118
- * ],
119
- * });
120
- * @example <caption>an enrollment</caption>
121
- * create('enrollments', {
122
- * trackedEntityInstance: 'bmshzEacgxa',
123
- * orgUnit: 'TSyzvBiovKh',
124
- * program: 'gZBxv9Ujxg0',
125
- * enrollmentDate: '2013-09-17',
126
- * incidentDate: '2013-09-17',
127
- * });
128
- */
129
- declare function create(resourceType: string, data: any, options?: any, callback?: Function): Operation;
130
- declare class create {
131
- /**
132
- * Create a record
133
- * @public
134
- * @constructor
135
- * @param {string} resourceType - Type of resource to create. E.g. `trackedEntityInstances`, `programs`, `events`, ...
136
- * @param {Object} data - Data that will be used to create a given instance of resource. To create a single instance of a resource, `data` must be a javascript object, and to create multiple instances of a resources, `data` must be an array of javascript objects.
137
- * @param {Object} [options] - Optional `options` to define URL parameters via params (E.g. `filter`, `dimension` and other import parameters), request config (E.g. `auth`) and the DHIS2 apiVersion.
138
- * @param {function} [callback] - Optional callback to handle the response
139
- * @returns {Operation}
140
- * @example <caption>a program</caption>
141
- * create('programs', {
142
- * name: 'name 20',
143
- * shortName: 'n20',
144
- * programType: 'WITHOUT_REGISTRATION',
145
- * });
146
- * @example <caption>an event</caption>
147
- * create('events', {
148
- * program: 'eBAyeGv0exc',
149
- * orgUnit: 'DiszpKrYNg8',
150
- * status: 'COMPLETED',
151
- * });
152
- * @example <caption>a trackedEntityInstance</caption>
153
- * create('trackedEntityInstances', {
154
- * orgUnit: 'TSyzvBiovKh',
155
- * trackedEntityType: 'nEenWmSyUEp',
156
- * attributes: [
157
- * {
158
- * attribute: 'w75KJ2mc4zz',
159
- * value: 'Gigiwe',
160
- * },
161
- * ]
162
- * });
163
- * @example <caption>a dataSet</caption>
164
- * create('dataSets', { name: 'OpenFn Data Set', periodType: 'Monthly' });
165
- * @example <caption>a dataSetNotification</caption>
166
- * create('dataSetNotificationTemplates', {
167
- * dataSetNotificationTrigger: 'DATA_SET_COMPLETION',
168
- * notificationRecipient: 'ORGANISATION_UNIT_CONTACT',
169
- * name: 'Notification',
170
- * messageTemplate: 'Hello',
171
- * deliveryChannels: ['SMS'],
172
- * dataSets: [],
173
- * });
174
- * @example <caption>a dataElement</caption>
175
- * create('dataElements', {
176
- * aggregationType: 'SUM',
177
- * domainType: 'AGGREGATE',
178
- * valueType: 'NUMBER',
179
- * name: 'Paracetamol',
180
- * shortName: 'Para',
181
- * });
182
- * @example <caption>a dataElementGroup</caption>
183
- * create('dataElementGroups', {
184
- * name: 'Data Element Group 1',
185
- * dataElements: [],
186
- * });
187
- * @example <caption>a dataElementGroupSet</caption>
188
- * create('dataElementGroupSets', {
189
- * name: 'Data Element Group Set 4',
190
- * dataDimension: true,
191
- * shortName: 'DEGS4',
192
- * dataElementGroups: [],
193
- * });
194
- * @example <caption>a dataValueSet</caption>
195
- * create('dataValueSets', {
196
- * dataElement: 'f7n9E0hX8qk',
197
- * period: '201401',
198
- * orgUnit: 'DiszpKrYNg8',
199
- * value: '12',
200
- * });
201
- * @example <caption>a dataValueSet with related dataValues</caption>
202
- * create('dataValueSets', {
203
- * dataSet: 'pBOMPrpg1QX',
204
- * completeDate: '2014-02-03',
205
- * period: '201401',
206
- * orgUnit: 'DiszpKrYNg8',
207
- * dataValues: [
208
- * {
209
- * dataElement: 'f7n9E0hX8qk',
210
- * value: '1',
211
- * },
212
- * {
213
- * dataElement: 'Ix2HsbDMLea',
214
- * value: '2',
215
- * },
216
- * {
217
- * dataElement: 'eY5ehpbEsB7',
218
- * value: '3',
219
- * },
220
- * ],
221
- * });
222
- * @example <caption>an enrollment</caption>
223
- * create('enrollments', {
224
- * trackedEntityInstance: 'bmshzEacgxa',
225
- * orgUnit: 'TSyzvBiovKh',
226
- * program: 'gZBxv9Ujxg0',
227
- * enrollmentDate: '2013-09-17',
228
- * incidentDate: '2013-09-17',
229
- * });
230
- */
231
- constructor(resourceType: string, data: any, options?: any, callback?: Function);
232
- }
233
- /**
234
- * Update data. A generic helper function to update a resource object of any type.
235
- * Updating an object requires to send `all required fields` or the `full body`
236
- * @public
237
- * @constructor
238
- * @param {string} resourceType - The type of resource to be updated. E.g. `dataElements`, `organisationUnits`, etc.
239
- * @param {string} path - The `id` or `path` to the `object` to be updated. E.g. `FTRrcoaog83` or `FTRrcoaog83/{collection-name}/{object-id}`
240
- * @param {Object} data - Data to update. It requires to send `all required fields` or the `full body`. If you want `partial updates`, use `patch` operation.
241
- * @param {Object} [options] - Optional `options` to define URL parameters via params (E.g. `filter`, `dimension` and other import parameters), request config (E.g. `auth`) and the DHIS2 apiVersion.
242
- * @param {function} [callback] - Optional callback to handle the response
243
- * @returns {Operation}
244
- * @example <caption>a program</caption>
245
- * update('programs', 'qAZJCrNJK8H', {
246
- * name: '14e1aa02c3f0a31618e096f2c6d03bed',
247
- * shortName: '14e1aa02',
248
- * programType: 'WITHOUT_REGISTRATION',
249
- * });
250
- * @example <caption>an event</caption>
251
- * update('events', 'PVqUD2hvU4E', {
252
- * program: 'eBAyeGv0exc',
253
- * orgUnit: 'Ngelehun CHC',
254
- * status: 'COMPLETED',
255
- * storedBy: 'admin',
256
- * dataValues: [],
257
- * });
258
- * @example <caption>a trackedEntityInstance</caption>
259
- * update('trackedEntityInstances', 'IeQfgUtGPq2', {
260
- * created: '2015-08-06T21:12:37.256',
261
- * orgUnit: 'TSyzvBiovKh',
262
- * createdAtClient: '2015-08-06T21:12:37.256',
263
- * trackedEntityInstance: 'IeQfgUtGPq2',
264
- * lastUpdated: '2015-08-06T21:12:37.257',
265
- * trackedEntityType: 'nEenWmSyUEp',
266
- * inactive: false,
267
- * deleted: false,
268
- * featureType: 'NONE',
269
- * programOwners: [
270
- * {
271
- * ownerOrgUnit: 'TSyzvBiovKh',
272
- * program: 'IpHINAT79UW',
273
- * trackedEntityInstance: 'IeQfgUtGPq2',
274
- * },
275
- * ],
276
- * enrollments: [],
277
- * relationships: [],
278
- * attributes: [
279
- * {
280
- * lastUpdated: '2016-01-12T00:00:00.000',
281
- * displayName: 'Last name',
282
- * created: '2016-01-12T00:00:00.000',
283
- * valueType: 'TEXT',
284
- * attribute: 'zDhUuAYrxNC',
285
- * value: 'Russell',
286
- * },
287
- * {
288
- * lastUpdated: '2016-01-12T00:00:00.000',
289
- * code: 'MMD_PER_NAM',
290
- * displayName: 'First name',
291
- * created: '2016-01-12T00:00:00.000',
292
- * valueType: 'TEXT',
293
- * attribute: 'w75KJ2mc4zz',
294
- * value: 'Catherine',
295
- * },
296
- * ],
297
- * });
298
- * @example <caption>a dataSet</caption>
299
- * update('dataSets', 'lyLU2wR22tC', { name: 'OpenFN Data Set', periodType: 'Weekly' });
300
- * @example <caption>a dataSetNotification</caption>
301
- * update('dataSetNotificationTemplates', 'VbQBwdm1wVP', {
302
- * dataSetNotificationTrigger: 'DATA_SET_COMPLETION',
303
- * notificationRecipient: 'ORGANISATION_UNIT_CONTACT',
304
- * name: 'Notification',
305
- * messageTemplate: 'Hello Updated,
306
- * deliveryChannels: ['SMS'],
307
- * dataSets: [],
308
- * });
309
- * @example <caption>a dataElement</caption>
310
- * update('dataElements', 'FTRrcoaog83', {
311
- * aggregationType: 'SUM',
312
- * domainType: 'AGGREGATE',
313
- * valueType: 'NUMBER',
314
- * name: 'Paracetamol',
315
- * shortName: 'Para',
316
- * });
317
- * @example <caption>a dataElementGroup</caption>
318
- * update('dataElementGroups', 'QrprHT61XFk', {
319
- * name: 'Data Element Group 1',
320
- * dataElements: [],
321
- * });
322
- * @example <caption>a dataElementGroupSet</caption>
323
- * update('dataElementGroupSets', 'VxWloRvAze8', {
324
- * name: 'Data Element Group Set 4',
325
- * dataDimension: true,
326
- * shortName: 'DEGS4',
327
- * dataElementGroups: [],
328
- * });
329
- * @example <caption>a dataValueSet</caption>
330
- * update('dataValueSets', 'AsQj6cDsUq4', {
331
- * dataElement: 'f7n9E0hX8qk',
332
- * period: '201401',
333
- * orgUnit: 'DiszpKrYNg8',
334
- * value: '12',
335
- * });
336
- * @example <caption>a dataValueSet with related dataValues</caption>
337
- * update('dataValueSets', 'Ix2HsbDMLea', {
338
- * dataSet: 'pBOMPrpg1QX',
339
- * completeDate: '2014-02-03',
340
- * period: '201401',
341
- * orgUnit: 'DiszpKrYNg8',
342
- * dataValues: [
343
- * {
344
- * dataElement: 'f7n9E0hX8qk',
345
- * value: '1',
346
- * },
347
- * {
348
- * dataElement: 'Ix2HsbDMLea',
349
- * value: '2',
350
- * },
351
- * {
352
- * dataElement: 'eY5ehpbEsB7',
353
- * value: '3',
354
- * },
355
- * ],
356
- * });
357
- * @example <caption>a single enrollment</caption>
358
- * update('enrollments', 'CmsHzercTBa' {
359
- * trackedEntityInstance: 'bmshzEacgxa',
360
- * orgUnit: 'TSyzvBiovKh',
361
- * program: 'gZBxv9Ujxg0',
362
- * enrollmentDate: '2013-10-17',
363
- * incidentDate: '2013-10-17',
364
- * });
365
- */
366
- declare function update(resourceType: string, path: string, data: any, options?: any, callback?: Function): Operation;
367
- declare class update {
368
- /**
369
- * Update data. A generic helper function to update a resource object of any type.
370
- * Updating an object requires to send `all required fields` or the `full body`
371
- * @public
372
- * @constructor
373
- * @param {string} resourceType - The type of resource to be updated. E.g. `dataElements`, `organisationUnits`, etc.
374
- * @param {string} path - The `id` or `path` to the `object` to be updated. E.g. `FTRrcoaog83` or `FTRrcoaog83/{collection-name}/{object-id}`
375
- * @param {Object} data - Data to update. It requires to send `all required fields` or the `full body`. If you want `partial updates`, use `patch` operation.
376
- * @param {Object} [options] - Optional `options` to define URL parameters via params (E.g. `filter`, `dimension` and other import parameters), request config (E.g. `auth`) and the DHIS2 apiVersion.
377
- * @param {function} [callback] - Optional callback to handle the response
378
- * @returns {Operation}
379
- * @example <caption>a program</caption>
380
- * update('programs', 'qAZJCrNJK8H', {
381
- * name: '14e1aa02c3f0a31618e096f2c6d03bed',
382
- * shortName: '14e1aa02',
383
- * programType: 'WITHOUT_REGISTRATION',
384
- * });
385
- * @example <caption>an event</caption>
386
- * update('events', 'PVqUD2hvU4E', {
387
- * program: 'eBAyeGv0exc',
388
- * orgUnit: 'Ngelehun CHC',
389
- * status: 'COMPLETED',
390
- * storedBy: 'admin',
391
- * dataValues: [],
392
- * });
393
- * @example <caption>a trackedEntityInstance</caption>
394
- * update('trackedEntityInstances', 'IeQfgUtGPq2', {
395
- * created: '2015-08-06T21:12:37.256',
396
- * orgUnit: 'TSyzvBiovKh',
397
- * createdAtClient: '2015-08-06T21:12:37.256',
398
- * trackedEntityInstance: 'IeQfgUtGPq2',
399
- * lastUpdated: '2015-08-06T21:12:37.257',
400
- * trackedEntityType: 'nEenWmSyUEp',
401
- * inactive: false,
402
- * deleted: false,
403
- * featureType: 'NONE',
404
- * programOwners: [
405
- * {
406
- * ownerOrgUnit: 'TSyzvBiovKh',
407
- * program: 'IpHINAT79UW',
408
- * trackedEntityInstance: 'IeQfgUtGPq2',
409
- * },
410
- * ],
411
- * enrollments: [],
412
- * relationships: [],
413
- * attributes: [
414
- * {
415
- * lastUpdated: '2016-01-12T00:00:00.000',
416
- * displayName: 'Last name',
417
- * created: '2016-01-12T00:00:00.000',
418
- * valueType: 'TEXT',
419
- * attribute: 'zDhUuAYrxNC',
420
- * value: 'Russell',
421
- * },
422
- * {
423
- * lastUpdated: '2016-01-12T00:00:00.000',
424
- * code: 'MMD_PER_NAM',
425
- * displayName: 'First name',
426
- * created: '2016-01-12T00:00:00.000',
427
- * valueType: 'TEXT',
428
- * attribute: 'w75KJ2mc4zz',
429
- * value: 'Catherine',
430
- * },
431
- * ],
432
- * });
433
- * @example <caption>a dataSet</caption>
434
- * update('dataSets', 'lyLU2wR22tC', { name: 'OpenFN Data Set', periodType: 'Weekly' });
435
- * @example <caption>a dataSetNotification</caption>
436
- * update('dataSetNotificationTemplates', 'VbQBwdm1wVP', {
437
- * dataSetNotificationTrigger: 'DATA_SET_COMPLETION',
438
- * notificationRecipient: 'ORGANISATION_UNIT_CONTACT',
439
- * name: 'Notification',
440
- * messageTemplate: 'Hello Updated,
441
- * deliveryChannels: ['SMS'],
442
- * dataSets: [],
443
- * });
444
- * @example <caption>a dataElement</caption>
445
- * update('dataElements', 'FTRrcoaog83', {
446
- * aggregationType: 'SUM',
447
- * domainType: 'AGGREGATE',
448
- * valueType: 'NUMBER',
449
- * name: 'Paracetamol',
450
- * shortName: 'Para',
451
- * });
452
- * @example <caption>a dataElementGroup</caption>
453
- * update('dataElementGroups', 'QrprHT61XFk', {
454
- * name: 'Data Element Group 1',
455
- * dataElements: [],
456
- * });
457
- * @example <caption>a dataElementGroupSet</caption>
458
- * update('dataElementGroupSets', 'VxWloRvAze8', {
459
- * name: 'Data Element Group Set 4',
460
- * dataDimension: true,
461
- * shortName: 'DEGS4',
462
- * dataElementGroups: [],
463
- * });
464
- * @example <caption>a dataValueSet</caption>
465
- * update('dataValueSets', 'AsQj6cDsUq4', {
466
- * dataElement: 'f7n9E0hX8qk',
467
- * period: '201401',
468
- * orgUnit: 'DiszpKrYNg8',
469
- * value: '12',
470
- * });
471
- * @example <caption>a dataValueSet with related dataValues</caption>
472
- * update('dataValueSets', 'Ix2HsbDMLea', {
473
- * dataSet: 'pBOMPrpg1QX',
474
- * completeDate: '2014-02-03',
475
- * period: '201401',
476
- * orgUnit: 'DiszpKrYNg8',
477
- * dataValues: [
478
- * {
479
- * dataElement: 'f7n9E0hX8qk',
480
- * value: '1',
481
- * },
482
- * {
483
- * dataElement: 'Ix2HsbDMLea',
484
- * value: '2',
485
- * },
486
- * {
487
- * dataElement: 'eY5ehpbEsB7',
488
- * value: '3',
489
- * },
490
- * ],
491
- * });
492
- * @example <caption>a single enrollment</caption>
493
- * update('enrollments', 'CmsHzercTBa' {
494
- * trackedEntityInstance: 'bmshzEacgxa',
495
- * orgUnit: 'TSyzvBiovKh',
496
- * program: 'gZBxv9Ujxg0',
497
- * enrollmentDate: '2013-10-17',
498
- * incidentDate: '2013-10-17',
499
- * });
500
- */
501
- constructor(resourceType: string, path: string, data: any, options?: any, callback?: Function);
502
- }
503
- /**
504
- * Get data. Generic helper method for getting data of any kind from DHIS2.
505
- * - This can be used to get `DataValueSets`,`events`,`trackedEntityInstances`,`etc.`
506
- * @public
507
- * @constructor
508
- * @param {string} resourceType - The type of resource to get(use its `plural` name). E.g. `dataElements`, `trackedEntityInstances`,`organisationUnits`, etc.
509
- * @param {Object} query - A query object that will limit what resources are retrieved when converted into request params.
510
- * @param {Object} [options] - Optional `options` to define URL parameters via params beyond filters, request configuration (e.g. `auth`) and DHIS2 api version to use.
511
- * @param {function} [callback] - Optional callback to handle the response
512
- * @returns {Operation} state
513
- * @example <caption>all data values for the 'pBOMPrpg1QX' dataset</caption>
514
- * get('dataValueSets', {
515
- * dataSet: 'pBOMPrpg1QX',
516
- * orgUnit: 'DiszpKrYNg8',
517
- * period: '201401',
518
- * fields: '*',
519
- * });
520
- * @example <caption>all programs for an organization unit</caption>
521
- * get('programs', { orgUnit: 'TSyzvBiovKh', fields: '*' });
522
- * @example <caption>a single tracked entity instance by a unique external ID</caption>
523
- * get('trackedEntityInstances', {
524
- * ou: 'DiszpKrYNg8',
525
- * filter: ['flGbXLXCrEo:Eq:124', 'w75KJ2mc4zz:Eq:John'],
526
- * });
527
- */
528
- declare function get(resourceType: string, query: any, options?: any, callback?: Function): Operation;
529
- declare class get {
530
- /**
531
- * Get data. Generic helper method for getting data of any kind from DHIS2.
532
- * - This can be used to get `DataValueSets`,`events`,`trackedEntityInstances`,`etc.`
533
- * @public
534
- * @constructor
535
- * @param {string} resourceType - The type of resource to get(use its `plural` name). E.g. `dataElements`, `trackedEntityInstances`,`organisationUnits`, etc.
536
- * @param {Object} query - A query object that will limit what resources are retrieved when converted into request params.
537
- * @param {Object} [options] - Optional `options` to define URL parameters via params beyond filters, request configuration (e.g. `auth`) and DHIS2 api version to use.
538
- * @param {function} [callback] - Optional callback to handle the response
539
- * @returns {Operation} state
540
- * @example <caption>all data values for the 'pBOMPrpg1QX' dataset</caption>
541
- * get('dataValueSets', {
542
- * dataSet: 'pBOMPrpg1QX',
543
- * orgUnit: 'DiszpKrYNg8',
544
- * period: '201401',
545
- * fields: '*',
546
- * });
547
- * @example <caption>all programs for an organization unit</caption>
548
- * get('programs', { orgUnit: 'TSyzvBiovKh', fields: '*' });
549
- * @example <caption>a single tracked entity instance by a unique external ID</caption>
550
- * get('trackedEntityInstances', {
551
- * ou: 'DiszpKrYNg8',
552
- * filter: ['flGbXLXCrEo:Eq:124', 'w75KJ2mc4zz:Eq:John'],
553
- * });
554
- */
555
- constructor(resourceType: string, query: any, options?: any, callback?: Function);
556
- }
557
- /**
558
- * Upsert a record. A generic helper function used to atomically either insert a row, or on the basis of the row already existing, UPDATE that existing row instead.
559
- * @public
560
- * @constructor
561
- * @param {string} resourceType - The type of a resource to `upsert`. E.g. `trackedEntityInstances`
562
- * @param {Object} query - A query object that allows to uniquely identify the resource to update. If no matches found, then the resource will be created.
563
- * @param {Object} data - The data to use for update or create depending on the result of the query.
564
- * @param {{ apiVersion: object, requestConfig: object, params: object }} [options] - Optional configuration that will be applied to both the `get` and the `create` or `update` operations.
565
- * @param {function} [callback] - Optional callback to handle the response
566
- * @throws {RangeError} - Throws range error
567
- * @returns {Operation}
568
- * @example <caption>Example `expression.js` of upsert</caption>
569
- * upsert('trackedEntityInstances', {
570
- * ou: 'TSyzvBiovKh',
571
- * filter: ['w75KJ2mc4zz:Eq:Qassim'],
572
- * }, {
573
- * orgUnit: 'TSyzvBiovKh',
574
- * trackedEntityType: 'nEenWmSyUEp',
575
- * attributes: [
576
- * {
577
- * attribute: 'w75KJ2mc4zz',
578
- * value: 'Qassim',
579
- * },
580
- * ],
581
- * });
582
- */
583
- declare function upsert(resourceType: string, query: any, data: any, options?: {
584
- apiVersion: object;
585
- requestConfig: object;
586
- params: object;
587
- }, callback?: Function): Operation;
588
- declare class upsert {
589
- /**
590
- * Upsert a record. A generic helper function used to atomically either insert a row, or on the basis of the row already existing, UPDATE that existing row instead.
591
- * @public
592
- * @constructor
593
- * @param {string} resourceType - The type of a resource to `upsert`. E.g. `trackedEntityInstances`
594
- * @param {Object} query - A query object that allows to uniquely identify the resource to update. If no matches found, then the resource will be created.
595
- * @param {Object} data - The data to use for update or create depending on the result of the query.
596
- * @param {{ apiVersion: object, requestConfig: object, params: object }} [options] - Optional configuration that will be applied to both the `get` and the `create` or `update` operations.
597
- * @param {function} [callback] - Optional callback to handle the response
598
- * @throws {RangeError} - Throws range error
599
- * @returns {Operation}
600
- * @example <caption>Example `expression.js` of upsert</caption>
601
- * upsert('trackedEntityInstances', {
602
- * ou: 'TSyzvBiovKh',
603
- * filter: ['w75KJ2mc4zz:Eq:Qassim'],
604
- * }, {
605
- * orgUnit: 'TSyzvBiovKh',
606
- * trackedEntityType: 'nEenWmSyUEp',
607
- * attributes: [
608
- * {
609
- * attribute: 'w75KJ2mc4zz',
610
- * value: 'Qassim',
611
- * },
612
- * ],
613
- * });
614
- */
615
- constructor(resourceType: string, query: any, data: any, options?: {
616
- apiVersion: object;
617
- requestConfig: object;
618
- params: object;
619
- }, callback?: Function);
620
- }
621
- /**
622
- * Discover `DHIS2` `api` `endpoint` `query parameters` and allowed `operators` for a given resource's endpoint.
623
- * @public
624
- * @constructor
625
- * @param {string} httpMethod - The HTTP to inspect parameter usage for a given endpoint, e.g., `get`, `post`,`put`,`patch`,`delete`
626
- * @param {string} endpoint - The path for a given endpoint. E.g. `/trackedEntityInstances` or `/dataValueSets`
627
- * @returns {Operation}
628
- * @example <caption>a list of parameters allowed on a given endpoint for specific http method</caption>
629
- * discover('post', '/trackedEntityInstances')
630
- */
631
- declare function discover(httpMethod: string, endpoint: string): Operation;
632
- declare class discover {
633
- /**
634
- * Discover `DHIS2` `api` `endpoint` `query parameters` and allowed `operators` for a given resource's endpoint.
635
- * @public
636
- * @constructor
637
- * @param {string} httpMethod - The HTTP to inspect parameter usage for a given endpoint, e.g., `get`, `post`,`put`,`patch`,`delete`
638
- * @param {string} endpoint - The path for a given endpoint. E.g. `/trackedEntityInstances` or `/dataValueSets`
639
- * @returns {Operation}
640
- * @example <caption>a list of parameters allowed on a given endpoint for specific http method</caption>
641
- * discover('post', '/trackedEntityInstances')
642
- */
643
- constructor(httpMethod: string, endpoint: string);
644
- }
645
- /**
646
- * Patch a record. A generic helper function to send partial updates on one or more object properties.
647
- * - You are not required to send the full body of object properties.
648
- * - This is useful for cases where you don't want or need to update all properties on a object.
649
- * @public
650
- * @constructor
651
- * @param {string} resourceType - The type of resource to be updated. E.g. `dataElements`, `organisationUnits`, etc.
652
- * @param {string} path - The `id` or `path` to the `object` to be updated. E.g. `FTRrcoaog83` or `FTRrcoaog83/{collection-name}/{object-id}`
653
- * @param {Object} data - Data to update. Include only the fields you want to update. E.g. `{name: "New Name"}`
654
- * @param {Object} [options] - Optional configuration, including params for the update ({preheatCache: true, strategy: 'UPDATE', mergeMode: 'REPLACE'}). Defaults to `{operationName: 'patch', apiVersion: state.configuration.apiVersion, responseType: 'json'}`
655
- * @param {function} [callback] - Optional callback to handle the response
656
- * @returns {Operation}
657
- * @example <caption>a dataElement</caption>
658
- * patch('dataElements', 'FTRrcoaog83', { name: 'New Name' });
659
- */
660
- declare function patch(resourceType: string, path: string, data: any, options?: any, callback?: Function): Operation;
661
- declare class patch {
662
- /**
663
- * Patch a record. A generic helper function to send partial updates on one or more object properties.
664
- * - You are not required to send the full body of object properties.
665
- * - This is useful for cases where you don't want or need to update all properties on a object.
666
- * @public
667
- * @constructor
668
- * @param {string} resourceType - The type of resource to be updated. E.g. `dataElements`, `organisationUnits`, etc.
669
- * @param {string} path - The `id` or `path` to the `object` to be updated. E.g. `FTRrcoaog83` or `FTRrcoaog83/{collection-name}/{object-id}`
670
- * @param {Object} data - Data to update. Include only the fields you want to update. E.g. `{name: "New Name"}`
671
- * @param {Object} [options] - Optional configuration, including params for the update ({preheatCache: true, strategy: 'UPDATE', mergeMode: 'REPLACE'}). Defaults to `{operationName: 'patch', apiVersion: state.configuration.apiVersion, responseType: 'json'}`
672
- * @param {function} [callback] - Optional callback to handle the response
673
- * @returns {Operation}
674
- * @example <caption>a dataElement</caption>
675
- * patch('dataElements', 'FTRrcoaog83', { name: 'New Name' });
676
- */
677
- constructor(resourceType: string, path: string, data: any, options?: any, callback?: Function);
678
- }
679
- /**
680
- * Delete a record. A generic helper function to delete an object
681
- * @public
682
- * @constructor
683
- * @param {string} resourceType - The type of resource to be deleted. E.g. `trackedEntityInstances`, `organisationUnits`, etc.
684
- * @param {string} path - Can be an `id` of an `object` or `path` to the `nested object` to `delete`.
685
- * @param {Object} [data] - Optional. This is useful when you want to remove multiple objects from a collection in one request. You can send `data` as, for example, `{"identifiableObjects": [{"id": "IDA"}, {"id": "IDB"}, {"id": "IDC"}]}`. See more {@link https://docs.dhis2.org/2.34/en/dhis2_developer_manual/web-api.html#deleting-objects on DHIS2 API docs}
686
- * @param {{apiVersion: number,operationName: string,resourceType: string}} [options] - Optional `options` for `del` operation including params e.g. `{preheatCache: true, strategy: 'UPDATE', mergeMode: 'REPLACE'}`. Run `discover` or see {@link https://docs.dhis2.org/2.34/en/dhis2_developer_manual/web-api.html#create-update-parameters DHIS2 documentation}. Defaults to `{operationName: 'delete', apiVersion: state.configuration.apiVersion, responseType: 'json'}`
687
- * @param {function} [callback] - Optional callback to handle the response
688
- * @returns {Operation}
689
- * @example <caption>a tracked entity instance</caption>
690
- * destroy('trackedEntityInstances', 'LcRd6Nyaq7T');
691
- */
692
- declare function destroy(resourceType: string, path: string, data?: any, options?: {
693
- apiVersion: number;
694
- operationName: string;
695
- resourceType: string;
696
- }, callback?: Function): Operation;
697
- declare class destroy {
698
- /**
699
- * Delete a record. A generic helper function to delete an object
700
- * @public
701
- * @constructor
702
- * @param {string} resourceType - The type of resource to be deleted. E.g. `trackedEntityInstances`, `organisationUnits`, etc.
703
- * @param {string} path - Can be an `id` of an `object` or `path` to the `nested object` to `delete`.
704
- * @param {Object} [data] - Optional. This is useful when you want to remove multiple objects from a collection in one request. You can send `data` as, for example, `{"identifiableObjects": [{"id": "IDA"}, {"id": "IDB"}, {"id": "IDC"}]}`. See more {@link https://docs.dhis2.org/2.34/en/dhis2_developer_manual/web-api.html#deleting-objects on DHIS2 API docs}
705
- * @param {{apiVersion: number,operationName: string,resourceType: string}} [options] - Optional `options` for `del` operation including params e.g. `{preheatCache: true, strategy: 'UPDATE', mergeMode: 'REPLACE'}`. Run `discover` or see {@link https://docs.dhis2.org/2.34/en/dhis2_developer_manual/web-api.html#create-update-parameters DHIS2 documentation}. Defaults to `{operationName: 'delete', apiVersion: state.configuration.apiVersion, responseType: 'json'}`
706
- * @param {function} [callback] - Optional callback to handle the response
707
- * @returns {Operation}
708
- * @example <caption>a tracked entity instance</caption>
709
- * destroy('trackedEntityInstances', 'LcRd6Nyaq7T');
710
- */
711
- constructor(resourceType: string, path: string, data?: any, options?: {
712
- apiVersion: number;
713
- operationName: string;
714
- resourceType: string;
715
- }, callback?: Function);
716
- }
717
- /**
718
- * Gets an attribute value by its case-insensitive display name
719
- * @public
720
- * @example
721
- * findAttributeValue(state.data.trackedEntityInstances[0], 'first name')
722
- * @constructor
723
- * @param {Object} trackedEntityInstance - A tracked entity instance (TEI) object
724
- * @param {string} attributeDisplayName - The 'displayName' to search for in the TEI's attributes
725
- * @returns {string}
726
- */
727
- declare function findAttributeValue(trackedEntityInstance: any, attributeDisplayName: string): string;
728
- declare class findAttributeValue {
729
- /**
730
- * Gets an attribute value by its case-insensitive display name
731
- * @public
732
- * @example
733
- * findAttributeValue(state.data.trackedEntityInstances[0], 'first name')
734
- * @constructor
735
- * @param {Object} trackedEntityInstance - A tracked entity instance (TEI) object
736
- * @param {string} attributeDisplayName - The 'displayName' to search for in the TEI's attributes
737
- * @returns {string}
738
- */
739
- constructor(trackedEntityInstance: any, attributeDisplayName: string);
740
- }
741
- /**
742
- * Converts an attribute ID and value into a DSHI2 attribute object
743
- * @public
744
- * @example
745
- * attr('w75KJ2mc4zz', 'Elias')
746
- * @constructor
747
- * @param {string} attribute - A tracked entity instance (TEI) attribute ID.
748
- * @param {string} value - The value for that attribute.
749
- * @returns {object}
750
- */
751
- declare function attr(attribute: string, value: string): object;
752
- declare class attr {
753
- /**
754
- * Converts an attribute ID and value into a DSHI2 attribute object
755
- * @public
756
- * @example
757
- * attr('w75KJ2mc4zz', 'Elias')
758
- * @constructor
759
- * @param {string} attribute - A tracked entity instance (TEI) attribute ID.
760
- * @param {string} value - The value for that attribute.
761
- * @returns {object}
762
- */
763
- constructor(attribute: string, value: string);
764
- }
765
- /**
766
- * Converts a dataElement and value into a DSHI2 dataValue object
767
- * @public
768
- * @example
769
- * dv('f7n9E0hX8qk', 12)
770
- * @constructor
771
- * @param {string} dataElement - A data element ID.
772
- * @param {string} value - The value for that data element.
773
- * @returns {object}
774
- */
775
- declare function dv(dataElement: string, value: string): object;
776
- declare class dv {
777
- /**
778
- * Converts a dataElement and value into a DSHI2 dataValue object
779
- * @public
780
- * @example
781
- * dv('f7n9E0hX8qk', 12)
782
- * @constructor
783
- * @param {string} dataElement - A data element ID.
784
- * @param {string} value - The value for that data element.
785
- * @returns {object}
786
- */
787
- constructor(dataElement: string, value: string);
788
- }
789
-
790
- type Adaptor_execute = execute;
791
- declare const Adaptor_execute: typeof execute;
792
- type Adaptor_create = create;
793
- declare const Adaptor_create: typeof create;
794
- type Adaptor_update = update;
795
- declare const Adaptor_update: typeof update;
796
- type Adaptor_get = get;
797
- declare const Adaptor_get: typeof get;
798
- type Adaptor_upsert = upsert;
799
- declare const Adaptor_upsert: typeof upsert;
800
- type Adaptor_discover = discover;
801
- declare const Adaptor_discover: typeof discover;
802
- type Adaptor_patch = patch;
803
- declare const Adaptor_patch: typeof patch;
804
- type Adaptor_destroy = destroy;
805
- declare const Adaptor_destroy: typeof destroy;
806
- type Adaptor_findAttributeValue = findAttributeValue;
807
- declare const Adaptor_findAttributeValue: typeof findAttributeValue;
808
- type Adaptor_attr = attr;
809
- declare const Adaptor_attr: typeof attr;
810
- type Adaptor_dv = dv;
811
- declare const Adaptor_dv: typeof dv;
812
- declare namespace Adaptor {
813
- export {
814
- Adaptor_execute as execute,
815
- Adaptor_create as create,
816
- Adaptor_update as update,
817
- Adaptor_get as get,
818
- Adaptor_upsert as upsert,
819
- Adaptor_discover as discover,
820
- Adaptor_patch as patch,
821
- Adaptor_destroy as destroy,
822
- Adaptor_findAttributeValue as findAttributeValue,
823
- Adaptor_attr as attr,
824
- Adaptor_dv as dv,
825
- };
826
- }
827
-
828
- export { Adaptor, Adaptor as default };
1
+ export default Adaptor;
2
+ export * from "./Adaptor";
3
+ import * as Adaptor from "./Adaptor";