@openmrs/esm-utils 4.0.0-pre.0 → 4.0.0-pre.1

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.
@@ -1,18 +1,18 @@
1
- @openmrs/esm-utils:build: cache hit, replaying output 5e20e7ebae69c0f9
2
- @openmrs/esm-utils:build: $ webpack --mode=production
3
- @openmrs/esm-utils:build: asset openmrs-esm-utils.js 47.2 KiB [emitted] [minimized] (name: main) 1 related asset
4
- @openmrs/esm-utils:build: runtime modules 2.02 KiB 7 modules
5
- @openmrs/esm-utils:build: orphan modules 18.9 KiB [orphan] 5 modules
6
- @openmrs/esm-utils:build: modules by path ../../../node_modules/semver/ 55.8 KiB 44 modules
7
- @openmrs/esm-utils:build: modules by path ../../../node_modules/systemjs-webpack-interop/ 3.27 KiB
8
- @openmrs/esm-utils:build:  ../../../node_modules/systemjs-webpack-interop/auto-public-path/1.js 89 bytes [built] [code generated]
9
- @openmrs/esm-utils:build:  ../../../node_modules/systemjs-webpack-interop/auto-public-path/auto-public-path.js 846 bytes [built] [code generated]
10
- @openmrs/esm-utils:build:  ../../../node_modules/systemjs-webpack-interop/public-path.js 2.36 KiB [built] [code generated]
11
- @openmrs/esm-utils:build: modules by path ../../../node_modules/dayjs/plugin/*.js 2.56 KiB
12
- @openmrs/esm-utils:build:  ../../../node_modules/dayjs/plugin/utc.js 2.2 KiB [built] [code generated]
13
- @openmrs/esm-utils:build:  ../../../node_modules/dayjs/plugin/isToday.js 365 bytes [built] [code generated]
14
- @openmrs/esm-utils:build: modules by path ../../../node_modules/yallist/*.js 8.42 KiB
15
- @openmrs/esm-utils:build:  ../../../node_modules/yallist/yallist.js 8.21 KiB [built] [code generated]
16
- @openmrs/esm-utils:build:  ../../../node_modules/yallist/iterator.js 207 bytes [built] [code generated]
17
- @openmrs/esm-utils:build: + 5 modules
18
- @openmrs/esm-utils:build: webpack 5.70.0 compiled successfully in 6749 ms
1
+ @openmrs/esm-utils:build: cache hit, replaying output 96a8c5c50f754983
2
+ @openmrs/esm-utils:build: $ webpack --mode=production
3
+ @openmrs/esm-utils:build: asset openmrs-esm-utils.js 47.2 KiB [emitted] [minimized] (name: main) 1 related asset
4
+ @openmrs/esm-utils:build: runtime modules 2.02 KiB 7 modules
5
+ @openmrs/esm-utils:build: orphan modules 19 KiB [orphan] 5 modules
6
+ @openmrs/esm-utils:build: modules by path ../../../node_modules/semver/ 55.8 KiB 44 modules
7
+ @openmrs/esm-utils:build: modules by path ../../../node_modules/systemjs-webpack-interop/ 3.27 KiB
8
+ @openmrs/esm-utils:build:  ../../../node_modules/systemjs-webpack-interop/auto-public-path/1.js 89 bytes [built] [code generated]
9
+ @openmrs/esm-utils:build:  ../../../node_modules/systemjs-webpack-interop/auto-public-path/auto-public-path.js 846 bytes [built] [code generated]
10
+ @openmrs/esm-utils:build:  ../../../node_modules/systemjs-webpack-interop/public-path.js 2.36 KiB [built] [code generated]
11
+ @openmrs/esm-utils:build: modules by path ../../../node_modules/dayjs/plugin/*.js 2.56 KiB
12
+ @openmrs/esm-utils:build:  ../../../node_modules/dayjs/plugin/utc.js 2.2 KiB [built] [code generated]
13
+ @openmrs/esm-utils:build:  ../../../node_modules/dayjs/plugin/isToday.js 365 bytes [built] [code generated]
14
+ @openmrs/esm-utils:build: modules by path ../../../node_modules/yallist/*.js 8.42 KiB
15
+ @openmrs/esm-utils:build:  ../../../node_modules/yallist/yallist.js 8.21 KiB [built] [code generated]
16
+ @openmrs/esm-utils:build:  ../../../node_modules/yallist/iterator.js 207 bytes [built] [code generated]
17
+ @openmrs/esm-utils:build: + 5 modules
18
+ @openmrs/esm-utils:build: webpack 5.70.0 compiled successfully in 22478 ms
@@ -1,2 +1,2 @@
1
- @openmrs/esm-utils:lint: cache hit, replaying output 5f2c624ca5cde50d
1
+ @openmrs/esm-utils:lint: cache hit, replaying output 9f58a5aad569522c
2
2
  @openmrs/esm-utils:lint: $ eslint src --ext ts,tsx
@@ -1,10 +1,10 @@
1
- @openmrs/esm-utils:test: cache hit, replaying output c0c99dbb97300d6e
2
- @openmrs/esm-utils:test: $ jest --config jest.config.js --passWithNoTests
3
- @openmrs/esm-utils:test: PASS src/version.test.ts
4
- @openmrs/esm-utils:test: PASS src/omrs-dates.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: 7.97 s
10
- @openmrs/esm-utils:test: Ran all test suites.
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 +1,2 @@
1
- @openmrs/esm-utils:typescript: cache hit, replaying output 5cdb80788a2384dc
2
- @openmrs/esm-utils:typescript: $ tsc
1
+ @openmrs/esm-utils:typescript: cache hit, replaying output 7a618d75536aa1cc
2
+ @openmrs/esm-utils:typescript: $ tsc
@@ -0,0 +1,20 @@
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;
@@ -0,0 +1,5 @@
1
+ export * from "./age-helpers";
2
+ export * from "./omrs-dates";
3
+ export * from "./translate";
4
+ export * from "./version";
5
+ export * from "./retry";
@@ -0,0 +1,110 @@
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;
@@ -0,0 +1 @@
1
+ export {};
File without changes