@openmrs/esm-utils 4.0.0-pre.1 → 4.0.1-pre.208

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/jest.config.js CHANGED
@@ -3,4 +3,7 @@ module.exports = {
3
3
  "^.+\\.tsx?$": ["@swc/jest"],
4
4
  },
5
5
  testEnvironment: "jsdom",
6
+ testEnvironmentOptions: {
7
+ url: "http://localhost/",
8
+ },
6
9
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-utils",
3
- "version": "4.0.0-pre.1",
3
+ "version": "4.0.1-pre.208",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Helper utilities for OpenMRS",
6
6
  "browser": "dist/openmrs-esm-utils.js",
@@ -49,5 +49,5 @@
49
49
  "dependencies": {
50
50
  "semver": "^7.3.2"
51
51
  },
52
- "gitHead": "9f58b801f07526083a9edc1cc5a1e58660d71eb0"
52
+ "gitHead": "7d28c0d3bdd2d73f38ceb04f4ca2c5b913158140"
53
53
  }
package/src/version.ts CHANGED
@@ -27,5 +27,5 @@ export function isVersionSatisfied(
27
27
 
28
28
  return semver.satisfies(version, requiredVersion, {
29
29
  includePrerelease: true,
30
- });
30
+ } as semver.Options);
31
31
  }
@@ -1,2 +0,0 @@
1
- @openmrs/esm-utils:lint: cache hit, replaying output 9f58a5aad569522c
2
- @openmrs/esm-utils:lint: $ eslint src --ext ts,tsx
@@ -1,10 +0,0 @@
1
- @openmrs/esm-utils:test: cache hit, replaying output cf5960bce80c784e
2
- @openmrs/esm-utils:test: $ jest --config jest.config.js --passWithNoTests
3
- @openmrs/esm-utils:test: PASS src/omrs-dates.test.ts
4
- @openmrs/esm-utils:test: PASS src/version.test.ts
5
- @openmrs/esm-utils:test: 
6
- @openmrs/esm-utils:test: Test Suites: 2 passed, 2 total
7
- @openmrs/esm-utils:test: Tests: 22 passed, 22 total
8
- @openmrs/esm-utils:test: Snapshots: 0 total
9
- @openmrs/esm-utils:test: Time: 5.794 s
10
- @openmrs/esm-utils:test: Ran all test suites.
@@ -1,2 +0,0 @@
1
- @openmrs/esm-utils:typescript: cache hit, replaying output 7a618d75536aa1cc
2
- @openmrs/esm-utils:typescript: $ tsc
@@ -1,20 +0,0 @@
1
- /** @module @category Utility */
2
- /**
3
- * Gets the number of days in the year of the given date.
4
- * @param date The date to compute the days within the year.
5
- * @returns The number of days.
6
- */
7
- export declare function daysIntoYear(date: Date): number;
8
- /**
9
- * Checks if two dates are representing the same day.
10
- * @param firstDate The first date.
11
- * @param secondDate The second date.
12
- * @returns True if both are located on the same day.
13
- */
14
- export declare function isSameDay(firstDate: Date, secondDate: Date): boolean;
15
- /**
16
- * Gets a human readable age represention of the provided date string.
17
- * @param dateString The stringified date.
18
- * @returns A human-readable string version of the age.
19
- */
20
- export declare function age(dateString: string): string;
package/dist/index.d.ts DELETED
@@ -1,5 +0,0 @@
1
- export * from "./age-helpers";
2
- export * from "./omrs-dates";
3
- export * from "./translate";
4
- export * from "./version";
5
- export * from "./retry";
@@ -1,110 +0,0 @@
1
- /**
2
- * @module
3
- * @category Date and Time
4
- */
5
- import { i18n } from "i18next";
6
- declare global {
7
- interface Window {
8
- i18next: i18n;
9
- }
10
- }
11
- export declare type DateInput = string | number | Date;
12
- /**
13
- * This function is STRICT on checking whether a date string is the openmrs format.
14
- * The format should be YYYY-MM-DDTHH:mm:ss.SSSZZ
15
- */
16
- export declare function isOmrsDateStrict(omrsPayloadString: string): boolean;
17
- /**
18
- *
19
- * @param date Checks if the provided date is today.
20
- */
21
- export declare function isOmrsDateToday(date: DateInput): boolean;
22
- /**
23
- * Converts the object to a date object if it is a valid ISO date time string.
24
- */
25
- export declare function toDateObjectStrict(omrsDateString: string): Date | null;
26
- /**
27
- * Formats the input as a date time string using the format "YYYY-MM-DDTHH:mm:ss.SSSZZ".
28
- */
29
- export declare function toOmrsIsoString(date: DateInput, toUTC?: boolean): string;
30
- /**
31
- * @deprecated use `formatTime`
32
- * Formats the input as a time string using the format "HH:mm".
33
- */
34
- export declare function toOmrsTimeString24(date: DateInput): string;
35
- /**
36
- * @deprecated use `formatTime`
37
- * Formats the input as a time string using the format "HH:mm A".
38
- */
39
- export declare function toOmrsTimeString(date: DateInput): string;
40
- /**
41
- * @deprecated use `formatDate(date, "wide")`
42
- * Formats the input as a date string using the format "DD - MMM - YYYY".
43
- */
44
- export declare function toOmrsDayDateFormat(date: DateInput): string;
45
- /**
46
- * @deprecated use `formatDate(date, "no year")`
47
- * Formats the input as a date string using the format "DD-MMM".
48
- */
49
- export declare function toOmrsYearlessDateFormat(date: DateInput): string;
50
- /**
51
- * @deprecated use `formatDate(date)`
52
- * Formats the input as a date string. By default the format "YYYY-MMM-DD" is used.
53
- */
54
- export declare function toOmrsDateFormat(date: DateInput, format?: string): string;
55
- /**
56
- * Utility function to parse an arbitrary string into a date.
57
- * Uses `dayjs(dateString)`.
58
- */
59
- export declare function parseDate(dateString: string): Date;
60
- export declare type FormatDateMode = "standard" | "wide";
61
- export declare type FormatDateOptions = {
62
- /**
63
- * - `standard`: "03 Feb 2022"
64
- * - `wide`: "03 — Feb — 2022"
65
- */
66
- mode: FormatDateMode;
67
- /**
68
- * Whether the time should be included in the output always (`true`),
69
- * never (`false`), or only when the input date is today (`for today`).
70
- */
71
- time: true | false | "for today";
72
- /** Whether to include the day number */
73
- day: boolean;
74
- /** Whether to include the year */
75
- year: boolean;
76
- };
77
- /**
78
- * Formats the input date according to the current locale and the
79
- * given options.
80
- *
81
- * Default options:
82
- * - mode: "standard",
83
- * - time: "for today",
84
- * - day: true,
85
- * - year: true
86
- *
87
- * If the date is today then "Today" is produced (in the locale language).
88
- *
89
- * When time is included, it is appended with a comma and a space. This
90
- * agrees with the output of `Date.prototype.toLocaleString` for *most*
91
- * locales.
92
- *
93
- * TODO: Shouldn't throw on null input
94
- */
95
- export declare function formatDate(date: Date, options?: Partial<FormatDateOptions>): string;
96
- /**
97
- * Formats the input as a time, according to the current locale.
98
- * 12-hour or 24-hour clock depends on locale.
99
- */
100
- export declare function formatTime(date: Date): string;
101
- /**
102
- * Formats the input into a string showing the date and time, according
103
- * to the current locale. The `mode` parameter is as described for
104
- * `formatDate`.
105
- *
106
- * This is created by concatenating the results of `formatDate`
107
- * and `formatTime` with a comma and space. This agrees with the
108
- * output of `Date.prototype.toLocaleString` for *most* locales.
109
- */
110
- export declare function formatDatetime(date: Date, options?: Partial<Omit<FormatDateOptions, "time">>): string;
@@ -1 +0,0 @@
1
- export {};
package/dist/retry.d.ts DELETED
@@ -1,38 +0,0 @@
1
- /** @module @category Utility */
2
- /**
3
- * Options for configuring the behavior of the {@link retry} function.
4
- */
5
- export interface RetryOptions {
6
- /**
7
- * Determines whether the retry function should retry executing the function after it failed
8
- * with an error on the current attempt.
9
- * @param attempt The current (zero-based) retry attempt. `0` indicates the initial attempt.
10
- */
11
- shouldRetry?(attempt: number): any;
12
- /**
13
- * Calculates the next delay (in milliseconds) before a retry attempt.
14
- * Returning a value for the inital attempt (`0`) delays the initial function invocation.
15
- * @param attempt The current (zero-based) retry attempt. `0` indicates the initial attempt.
16
- */
17
- getDelay?(attempt: number): number;
18
- /**
19
- * Called when invoking the function resulted in an error.
20
- * Allows running side-effects on errors, e.g. logging.
21
- * @param e The error thrown by the function.
22
- * @param attempt The current (zero-based) retry attempt. `0` indicates the initial attempt.
23
- */
24
- onError?(e: any, attempt: number): void;
25
- }
26
- /**
27
- * Executes the specified function and retries executing on failure with a custom backoff strategy
28
- * defined by the options.
29
- *
30
- * If not configured otherwise, this function uses the following default options:
31
- * * Retries 5 times beyond the initial attempt.
32
- * * Uses an exponential backoff starting with an initial delay of 1000ms.
33
- * @param fn The function to be executed and retried on failure.
34
- * @param options Additional options which configure the retry behavior.
35
- * @returns The result of successfully executing `fn`.
36
- * @throws Rethrows the final error of running `fn` when the function stops retrying.
37
- */
38
- export declare function retry<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>;
@@ -1 +0,0 @@
1
- export declare function translateFrom(moduleName: string, key: string, fallback?: string, options?: object): string;
package/dist/version.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare function isVersionSatisfied(requiredVersion: string, installedVersion: string): boolean;
@@ -1 +0,0 @@
1
- export {};