@openmrs/esm-utils 3.1.15-pre.693 → 3.1.15-pre.709

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/README.md CHANGED
@@ -1,5 +1,3 @@
1
1
  # openmrs-esm-utils
2
2
 
3
3
  openmrs-esm-utils provides helper functions.
4
-
5
- [API Docs](docs/API.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-utils",
3
- "version": "3.1.15-pre.693",
3
+ "version": "3.1.15-pre.709",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Helper utilities for OpenMRS",
6
6
  "browser": "dist/openmrs-esm-utils.js",
@@ -8,7 +8,6 @@
8
8
  "source": true,
9
9
  "sideEffects": false,
10
10
  "scripts": {
11
- "document": "../../../document.sh esm-utils",
12
11
  "test": "jest --config jest.config.js --passWithNoTests",
13
12
  "build": "webpack --mode=production",
14
13
  "analyze": "webpack --mode=production --env analyze=true",
@@ -49,5 +48,5 @@
49
48
  "dependencies": {
50
49
  "semver": "^7.3.2"
51
50
  },
52
- "gitHead": "4348b79bf1c23aea131af938164ef9dbfd4e68d7"
51
+ "gitHead": "20e905827ceb11c90871b5e28a7bd56ab4fbab18"
53
52
  }
package/docs/API.md DELETED
@@ -1,394 +0,0 @@
1
- [Back to README.md](../README.md)
2
-
3
- # @openmrs/esm-utils
4
-
5
- ## Table of contents
6
-
7
- ### Interfaces
8
-
9
- - [RetryOptions](interfaces/RetryOptions.md)
10
-
11
- ### Type aliases
12
-
13
- - [DateInput](API.md#dateinput)
14
-
15
- ### Functions
16
-
17
- - [age](API.md#age)
18
- - [daysIntoYear](API.md#daysintoyear)
19
- - [isOmrsDateStrict](API.md#isomrsdatestrict)
20
- - [isOmrsDateToday](API.md#isomrsdatetoday)
21
- - [isSameDay](API.md#issameday)
22
- - [isVersionSatisfied](API.md#isversionsatisfied)
23
- - [retry](API.md#retry)
24
- - [toDateObjectStrict](API.md#todateobjectstrict)
25
- - [toOmrsDateFormat](API.md#toomrsdateformat)
26
- - [toOmrsDayDateFormat](API.md#toomrsdaydateformat)
27
- - [toOmrsIsoString](API.md#toomrsisostring)
28
- - [toOmrsTimeString](API.md#toomrstimestring)
29
- - [toOmrsTimeString24](API.md#toomrstimestring24)
30
- - [toOmrsYearlessDateFormat](API.md#toomrsyearlessdateformat)
31
- - [translateFrom](API.md#translatefrom)
32
-
33
- ## Type aliases
34
-
35
- ### DateInput
36
-
37
- Ƭ **DateInput**: `string` \| `number` \| `Date`
38
-
39
- #### Defined in
40
-
41
- [omrs-dates.ts:8](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-utils/src/omrs-dates.ts#L8)
42
-
43
- ## Functions
44
-
45
- ### age
46
-
47
- ▸ **age**(`dateString`): `string`
48
-
49
- Gets a human readable age represention of the provided date string.
50
-
51
- #### Parameters
52
-
53
- | Name | Type | Description |
54
- | :------ | :------ | :------ |
55
- | `dateString` | `string` | The stringified date. |
56
-
57
- #### Returns
58
-
59
- `string`
60
-
61
- A human-readable string version of the age.
62
-
63
- #### Defined in
64
-
65
- [age-helpers.tsx:37](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-utils/src/age-helpers.tsx#L37)
66
-
67
- ___
68
-
69
- ### daysIntoYear
70
-
71
- ▸ **daysIntoYear**(`date`): `number`
72
-
73
- Gets the number of days in the year of the given date.
74
-
75
- #### Parameters
76
-
77
- | Name | Type | Description |
78
- | :------ | :------ | :------ |
79
- | `date` | `Date` | The date to compute the days within the year. |
80
-
81
- #### Returns
82
-
83
- `number`
84
-
85
- The number of days.
86
-
87
- #### Defined in
88
-
89
- [age-helpers.tsx:6](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-utils/src/age-helpers.tsx#L6)
90
-
91
- ___
92
-
93
- ### isOmrsDateStrict
94
-
95
- ▸ **isOmrsDateStrict**(`omrsPayloadString`): `boolean`
96
-
97
- This function is STRICT on checking whether a date string is the openmrs format.
98
- The format should be YYYY-MM-DDTHH:mm:ss.SSSZZ
99
-
100
- #### Parameters
101
-
102
- | Name | Type |
103
- | :------ | :------ |
104
- | `omrsPayloadString` | `string` |
105
-
106
- #### Returns
107
-
108
- `boolean`
109
-
110
- #### Defined in
111
-
112
- [omrs-dates.ts:16](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-utils/src/omrs-dates.ts#L16)
113
-
114
- ___
115
-
116
- ### isOmrsDateToday
117
-
118
- ▸ **isOmrsDateToday**(`date`): `boolean`
119
-
120
- #### Parameters
121
-
122
- | Name | Type | Description |
123
- | :------ | :------ | :------ |
124
- | `date` | [`DateInput`](API.md#dateinput) | Checks if the provided date is today. |
125
-
126
- #### Returns
127
-
128
- `boolean`
129
-
130
- #### Defined in
131
-
132
- [omrs-dates.ts:53](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-utils/src/omrs-dates.ts#L53)
133
-
134
- ___
135
-
136
- ### isSameDay
137
-
138
- ▸ **isSameDay**(`firstDate`, `secondDate`): `boolean`
139
-
140
- Checks if two dates are representing the same day.
141
-
142
- #### Parameters
143
-
144
- | Name | Type | Description |
145
- | :------ | :------ | :------ |
146
- | `firstDate` | `Date` | The first date. |
147
- | `secondDate` | `Date` | The second date. |
148
-
149
- #### Returns
150
-
151
- `boolean`
152
-
153
- True if both are located on the same day.
154
-
155
- #### Defined in
156
-
157
- [age-helpers.tsx:23](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-utils/src/age-helpers.tsx#L23)
158
-
159
- ___
160
-
161
- ### isVersionSatisfied
162
-
163
- ▸ **isVersionSatisfied**(`requiredVersion`, `installedVersion`): `boolean`
164
-
165
- #### Parameters
166
-
167
- | Name | Type |
168
- | :------ | :------ |
169
- | `requiredVersion` | `string` |
170
- | `installedVersion` | `string` |
171
-
172
- #### Returns
173
-
174
- `boolean`
175
-
176
- #### Defined in
177
-
178
- [version.ts:21](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-utils/src/version.ts#L21)
179
-
180
- ___
181
-
182
- ### retry
183
-
184
- ▸ **retry**<`T`\>(`fn`, `options?`): `Promise`<`T`\>
185
-
186
- Executes the specified function and retries executing on failure with a custom backoff strategy
187
- defined by the options.
188
-
189
- If not configured otherwise, this function uses the following default options:
190
- * Retries 5 times beyond the initial attempt.
191
- * Uses an exponential backoff starting with an initial delay of 1000ms.
192
-
193
- **`throws`** Rethrows the final error of running `fn` when the function stops retrying.
194
-
195
- #### Type parameters
196
-
197
- | Name |
198
- | :------ |
199
- | `T` |
200
-
201
- #### Parameters
202
-
203
- | Name | Type | Description |
204
- | :------ | :------ | :------ |
205
- | `fn` | () => `Promise`<`T`\> | The function to be executed and retried on failure. |
206
- | `options` | [`RetryOptions`](interfaces/RetryOptions.md) | Additional options which configure the retry behavior. |
207
-
208
- #### Returns
209
-
210
- `Promise`<`T`\>
211
-
212
- The result of successfully executing `fn`.
213
-
214
- #### Defined in
215
-
216
- [retry.ts:38](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-utils/src/retry.ts#L38)
217
-
218
- ___
219
-
220
- ### toDateObjectStrict
221
-
222
- ▸ **toDateObjectStrict**(`omrsDateString`): `Date` \| ``null``
223
-
224
- Converts the object to a date object if it is a valid ISO date time string.
225
-
226
- #### Parameters
227
-
228
- | Name | Type |
229
- | :------ | :------ |
230
- | `omrsDateString` | `string` |
231
-
232
- #### Returns
233
-
234
- `Date` \| ``null``
235
-
236
- #### Defined in
237
-
238
- [omrs-dates.ts:60](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-utils/src/omrs-dates.ts#L60)
239
-
240
- ___
241
-
242
- ### toOmrsDateFormat
243
-
244
- ▸ **toOmrsDateFormat**(`date`, `format?`): `string`
245
-
246
- Formats the input as a date string. By default the format "YYYY-MMM-DD" is used.
247
-
248
- #### Parameters
249
-
250
- | Name | Type | Default value |
251
- | :------ | :------ | :------ |
252
- | `date` | [`DateInput`](API.md#dateinput) | `undefined` |
253
- | `format` | `string` | `"YYYY-MMM-DD"` |
254
-
255
- #### Returns
256
-
257
- `string`
258
-
259
- #### Defined in
260
-
261
- [omrs-dates.ts:112](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-utils/src/omrs-dates.ts#L112)
262
-
263
- ___
264
-
265
- ### toOmrsDayDateFormat
266
-
267
- ▸ **toOmrsDayDateFormat**(`date`): `string`
268
-
269
- Formats the input as a date string using the format "DD - MMM - YYYY".
270
-
271
- #### Parameters
272
-
273
- | Name | Type |
274
- | :------ | :------ |
275
- | `date` | [`DateInput`](API.md#dateinput) |
276
-
277
- #### Returns
278
-
279
- `string`
280
-
281
- #### Defined in
282
-
283
- [omrs-dates.ts:98](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-utils/src/omrs-dates.ts#L98)
284
-
285
- ___
286
-
287
- ### toOmrsIsoString
288
-
289
- ▸ **toOmrsIsoString**(`date`, `toUTC?`): `string`
290
-
291
- Formats the input as a date time string using the format "YYYY-MM-DDTHH:mm:ss.SSSZZ".
292
-
293
- #### Parameters
294
-
295
- | Name | Type | Default value |
296
- | :------ | :------ | :------ |
297
- | `date` | [`DateInput`](API.md#dateinput) | `undefined` |
298
- | `toUTC` | `boolean` | `false` |
299
-
300
- #### Returns
301
-
302
- `string`
303
-
304
- #### Defined in
305
-
306
- [omrs-dates.ts:71](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-utils/src/omrs-dates.ts#L71)
307
-
308
- ___
309
-
310
- ### toOmrsTimeString
311
-
312
- ▸ **toOmrsTimeString**(`date`): `string`
313
-
314
- Formats the input as a time string using the format "HH:mm A".
315
-
316
- #### Parameters
317
-
318
- | Name | Type |
319
- | :------ | :------ |
320
- | `date` | [`DateInput`](API.md#dateinput) |
321
-
322
- #### Returns
323
-
324
- `string`
325
-
326
- #### Defined in
327
-
328
- [omrs-dates.ts:91](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-utils/src/omrs-dates.ts#L91)
329
-
330
- ___
331
-
332
- ### toOmrsTimeString24
333
-
334
- ▸ **toOmrsTimeString24**(`date`): `string`
335
-
336
- Formats the input as a time string using the format "HH:mm".
337
-
338
- #### Parameters
339
-
340
- | Name | Type |
341
- | :------ | :------ |
342
- | `date` | [`DateInput`](API.md#dateinput) |
343
-
344
- #### Returns
345
-
346
- `string`
347
-
348
- #### Defined in
349
-
350
- [omrs-dates.ts:84](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-utils/src/omrs-dates.ts#L84)
351
-
352
- ___
353
-
354
- ### toOmrsYearlessDateFormat
355
-
356
- ▸ **toOmrsYearlessDateFormat**(`date`): `string`
357
-
358
- Formats the input as a date string using the format "DD-MMM".
359
-
360
- #### Parameters
361
-
362
- | Name | Type |
363
- | :------ | :------ |
364
- | `date` | [`DateInput`](API.md#dateinput) |
365
-
366
- #### Returns
367
-
368
- `string`
369
-
370
- #### Defined in
371
-
372
- [omrs-dates.ts:105](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-utils/src/omrs-dates.ts#L105)
373
-
374
- ___
375
-
376
- ### translateFrom
377
-
378
- ▸ **translateFrom**(`moduleName`, `key`, `fallback?`): `string`
379
-
380
- #### Parameters
381
-
382
- | Name | Type |
383
- | :------ | :------ |
384
- | `moduleName` | `string` |
385
- | `key` | `string` |
386
- | `fallback?` | `string` |
387
-
388
- #### Returns
389
-
390
- `string`
391
-
392
- #### Defined in
393
-
394
- [translate.ts:3](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-utils/src/translate.ts#L3)
@@ -1,83 +0,0 @@
1
- [@openmrs/esm-utils](../API.md) / RetryOptions
2
-
3
- # Interface: RetryOptions
4
-
5
- Options for configuring the behavior of the [retry](../API.md#retry) function.
6
-
7
- ## Table of contents
8
-
9
- ### Methods
10
-
11
- - [getDelay](RetryOptions.md#getdelay)
12
- - [onError](RetryOptions.md#onerror)
13
- - [shouldRetry](RetryOptions.md#shouldretry)
14
-
15
- ## Methods
16
-
17
- ### getDelay
18
-
19
- ▸ `Optional` **getDelay**(`attempt`): `number`
20
-
21
- Calculates the next delay (in milliseconds) before a retry attempt.
22
- Returning a value for the inital attempt (`0`) delays the initial function invocation.
23
-
24
- #### Parameters
25
-
26
- | Name | Type | Description |
27
- | :------ | :------ | :------ |
28
- | `attempt` | `number` | The current (zero-based) retry attempt. `0` indicates the initial attempt. |
29
-
30
- #### Returns
31
-
32
- `number`
33
-
34
- #### Defined in
35
-
36
- [retry.ts:16](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-utils/src/retry.ts#L16)
37
-
38
- ___
39
-
40
- ### onError
41
-
42
- ▸ `Optional` **onError**(`e`, `attempt`): `void`
43
-
44
- Called when invoking the function resulted in an error.
45
- Allows running side-effects on errors, e.g. logging.
46
-
47
- #### Parameters
48
-
49
- | Name | Type | Description |
50
- | :------ | :------ | :------ |
51
- | `e` | `any` | The error thrown by the function. |
52
- | `attempt` | `number` | The current (zero-based) retry attempt. `0` indicates the initial attempt. |
53
-
54
- #### Returns
55
-
56
- `void`
57
-
58
- #### Defined in
59
-
60
- [retry.ts:23](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-utils/src/retry.ts#L23)
61
-
62
- ___
63
-
64
- ### shouldRetry
65
-
66
- ▸ `Optional` **shouldRetry**(`attempt`): `any`
67
-
68
- Determines whether the retry function should retry executing the function after it failed
69
- with an error on the current attempt.
70
-
71
- #### Parameters
72
-
73
- | Name | Type | Description |
74
- | :------ | :------ | :------ |
75
- | `attempt` | `number` | The current (zero-based) retry attempt. `0` indicates the initial attempt. |
76
-
77
- #### Returns
78
-
79
- `any`
80
-
81
- #### Defined in
82
-
83
- [retry.ts:10](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-utils/src/retry.ts#L10)
package/typedoc.json DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "out": "docs",
3
- "readme": "none",
4
- "excludeInternal": true,
5
- "gitRevision": "master",
6
- "entryDocument": "API.md"
7
- }