@webority/mobile-core 0.0.29 → 0.2.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.
- package/README.md +32 -0
- package/lib/commonjs/api/baseUrl.js +1 -34
- package/lib/commonjs/api/clientHeaders.js +1 -0
- package/lib/commonjs/api/curl.js +1 -109
- package/lib/commonjs/api/minAppVersion.js +1 -0
- package/lib/commonjs/api/multipart.js +1 -21
- package/lib/commonjs/api/publicClient.js +1 -79
- package/lib/commonjs/api/requestDefaults.js +1 -0
- package/lib/commonjs/api/responseBodyText.js +1 -0
- package/lib/commonjs/api/retry.js +1 -91
- package/lib/commonjs/api/tokenRefresh.js +1 -205
- package/lib/commonjs/api/userClient.js +1 -265
- package/lib/commonjs/auth/authStore.js +1 -265
- package/lib/commonjs/auth/index.js +1 -44
- package/lib/commonjs/auth/jwt.js +1 -112
- package/lib/commonjs/config/index.js +1 -72
- package/lib/commonjs/deepLink/index.js +1 -286
- package/lib/commonjs/download/adapters/expoFs.js +1 -69
- package/lib/commonjs/download/adapters/shared.js +1 -13
- package/lib/commonjs/download/index.js +1 -250
- package/lib/commonjs/errors/extractApiError.js +1 -0
- package/lib/commonjs/errors/index.js +1 -0
- package/lib/commonjs/formatters/currency.js +1 -70
- package/lib/commonjs/formatters/date.js +1 -167
- package/lib/commonjs/formatters/dateMath.js +1 -311
- package/lib/commonjs/formatters/formatConfig.js +1 -0
- package/lib/commonjs/formatters/house.js +1 -0
- package/lib/commonjs/formatters/index.js +1 -246
- package/lib/commonjs/formatters/initials.js +1 -32
- package/lib/commonjs/formatters/intlCache.js +1 -37
- package/lib/commonjs/formatters/number.js +1 -89
- package/lib/commonjs/formatters/phone.js +1 -369
- package/lib/commonjs/formatters/windowsToIanaTable.js +1 -164
- package/lib/commonjs/geolocation/adapters/expoLocation.js +1 -126
- package/lib/commonjs/geolocation/index.js +1 -355
- package/lib/commonjs/index.js +1 -644
- package/lib/commonjs/initSDK.js +1 -66
- package/lib/commonjs/initUserAuth.js +1 -37
- package/lib/commonjs/logger/crashlytics.js +1 -0
- package/lib/commonjs/logger/index.js +1 -301
- package/lib/commonjs/logger/redact.js +1 -50
- package/lib/commonjs/network/index.js +1 -31
- package/lib/commonjs/network/networkStatus.js +1 -171
- package/lib/commonjs/permissions/calendar.js +1 -14
- package/lib/commonjs/permissions/camera.js +1 -14
- package/lib/commonjs/permissions/contacts.js +1 -10
- package/lib/commonjs/permissions/index.js +1 -133
- package/lib/commonjs/permissions/location.js +1 -14
- package/lib/commonjs/permissions/mediaLibrary.js +1 -10
- package/lib/commonjs/permissions/notifications.js +1 -10
- package/lib/commonjs/permissions/photos.js +1 -14
- package/lib/commonjs/phone/countries.js +1 -265
- package/lib/commonjs/push/index.js +1 -61
- package/lib/commonjs/push/push.js +1 -468
- package/lib/commonjs/push/status.js +1 -0
- package/lib/commonjs/push/task.js +1 -43
- package/lib/commonjs/query/apiBaseQuery.js +1 -0
- package/lib/commonjs/query/createAppApi.js +1 -0
- package/lib/commonjs/query/index.js +1 -0
- package/lib/commonjs/query/listeners.js +1 -0
- package/lib/commonjs/query/paging.js +1 -0
- package/lib/commonjs/query/tags.js +1 -0
- package/lib/commonjs/redux/errorToastMiddleware.js +1 -0
- package/lib/commonjs/redux/index.js +1 -0
- package/lib/commonjs/redux/rootReducer.js +1 -0
- package/lib/commonjs/redux/serializableCheck.js +1 -0
- package/lib/commonjs/secureScreen/index.js +1 -0
- package/lib/commonjs/share/index.js +1 -70
- package/lib/commonjs/smsRetriever/index.js +1 -91
- package/lib/commonjs/specs/NativeSmsRetriever.js +1 -15
- package/lib/commonjs/sqlite/adapters/expo.js +1 -53
- package/lib/commonjs/sqlite/index.js +1 -604
- package/lib/commonjs/storage/index.js +1 -214
- package/lib/commonjs/types/axios.js +1 -4
- package/lib/commonjs/types/globals.d.js +1 -6
- package/lib/commonjs/utils/base64.js +1 -24
- package/lib/commonjs/utils/imageCompression.js +1 -389
- package/lib/commonjs/utils/index.js +1 -19
- package/lib/commonjs/validators/index.js +1 -227
- package/lib/commonjs/versionCheck/buildNumber.js +1 -0
- package/lib/commonjs/versionCheck/index.js +1 -419
- package/lib/module/api/baseUrl.js +1 -30
- package/lib/module/api/clientHeaders.js +1 -0
- package/lib/module/api/curl.js +1 -104
- package/lib/module/api/minAppVersion.js +1 -0
- package/lib/module/api/multipart.js +1 -16
- package/lib/module/api/publicClient.js +1 -75
- package/lib/module/api/requestDefaults.js +1 -0
- package/lib/module/api/responseBodyText.js +1 -0
- package/lib/module/api/retry.js +1 -85
- package/lib/module/api/tokenRefresh.js +1 -192
- package/lib/module/api/userClient.js +1 -243
- package/lib/module/auth/authStore.js +1 -257
- package/lib/module/auth/index.js +1 -5
- package/lib/module/auth/jwt.js +1 -106
- package/lib/module/config/index.js +1 -64
- package/lib/module/deepLink/index.js +1 -280
- package/lib/module/download/adapters/expoFs.js +1 -64
- package/lib/module/download/adapters/shared.js +1 -8
- package/lib/module/download/index.js +1 -242
- package/lib/module/errors/extractApiError.js +1 -0
- package/lib/module/errors/index.js +1 -0
- package/lib/module/formatters/currency.js +1 -65
- package/lib/module/formatters/date.js +1 -159
- package/lib/module/formatters/dateMath.js +1 -295
- package/lib/module/formatters/formatConfig.js +1 -0
- package/lib/module/formatters/house.js +1 -0
- package/lib/module/formatters/index.js +1 -9
- package/lib/module/formatters/initials.js +1 -27
- package/lib/module/formatters/intlCache.js +1 -30
- package/lib/module/formatters/number.js +1 -82
- package/lib/module/formatters/phone.js +1 -302
- package/lib/module/formatters/windowsToIanaTable.js +1 -160
- package/lib/module/geolocation/adapters/expoLocation.js +1 -121
- package/lib/module/geolocation/index.js +1 -347
- package/lib/module/index.js +1 -57
- package/lib/module/initSDK.js +1 -61
- package/lib/module/initUserAuth.js +1 -33
- package/lib/module/logger/crashlytics.js +1 -0
- package/lib/module/logger/index.js +1 -295
- package/lib/module/logger/redact.js +1 -44
- package/lib/module/network/index.js +1 -4
- package/lib/module/network/networkStatus.js +1 -161
- package/lib/module/permissions/calendar.js +1 -15
- package/lib/module/permissions/camera.js +1 -15
- package/lib/module/permissions/contacts.js +1 -11
- package/lib/module/permissions/index.js +1 -128
- package/lib/module/permissions/location.js +1 -15
- package/lib/module/permissions/mediaLibrary.js +1 -11
- package/lib/module/permissions/notifications.js +1 -11
- package/lib/module/permissions/photos.js +1 -15
- package/lib/module/phone/countries.js +1 -261
- package/lib/module/push/index.js +1 -4
- package/lib/module/push/push.js +1 -452
- package/lib/module/push/status.js +1 -0
- package/lib/module/push/task.js +1 -38
- package/lib/module/query/apiBaseQuery.js +1 -0
- package/lib/module/query/createAppApi.js +1 -0
- package/lib/module/query/index.js +1 -0
- package/lib/module/query/listeners.js +1 -0
- package/lib/module/query/paging.js +1 -0
- package/lib/module/query/tags.js +1 -0
- package/lib/module/redux/errorToastMiddleware.js +1 -0
- package/lib/module/redux/index.js +1 -0
- package/lib/module/redux/rootReducer.js +1 -0
- package/lib/module/redux/serializableCheck.js +1 -0
- package/lib/module/secureScreen/index.js +1 -0
- package/lib/module/share/index.js +1 -64
- package/lib/module/smsRetriever/index.js +1 -86
- package/lib/module/specs/NativeSmsRetriever.js +1 -13
- package/lib/module/sqlite/adapters/expo.js +1 -48
- package/lib/module/sqlite/index.js +1 -594
- package/lib/module/storage/index.js +1 -208
- package/lib/module/types/axios.js +1 -4
- package/lib/module/types/globals.d.js +1 -10
- package/lib/module/utils/base64.js +1 -19
- package/lib/module/utils/imageCompression.js +1 -383
- package/lib/module/utils/index.js +1 -4
- package/lib/module/validators/index.js +1 -205
- package/lib/module/versionCheck/buildNumber.js +1 -0
- package/lib/module/versionCheck/index.js +1 -413
- package/lib/typescript/commonjs/api/clientHeaders.d.ts +25 -0
- package/lib/typescript/commonjs/api/minAppVersion.d.ts +24 -0
- package/lib/typescript/commonjs/api/requestDefaults.d.ts +21 -0
- package/lib/typescript/commonjs/api/responseBodyText.d.ts +6 -0
- package/lib/typescript/commonjs/api/retry.d.ts +23 -9
- package/lib/typescript/commonjs/api/tokenRefresh.d.ts +14 -2
- package/lib/typescript/commonjs/api/userClient.d.ts +1 -1
- package/lib/typescript/commonjs/auth/authStore.d.ts +76 -0
- package/lib/typescript/commonjs/auth/index.d.ts +2 -2
- package/lib/typescript/commonjs/config/index.d.ts +31 -2
- package/lib/typescript/commonjs/errors/extractApiError.d.ts +69 -0
- package/lib/typescript/commonjs/errors/index.d.ts +3 -0
- package/lib/typescript/commonjs/formatters/currency.d.ts +22 -7
- package/lib/typescript/commonjs/formatters/date.d.ts +13 -13
- package/lib/typescript/commonjs/formatters/dateMath.d.ts +4 -2
- package/lib/typescript/commonjs/formatters/formatConfig.d.ts +48 -0
- package/lib/typescript/commonjs/formatters/house.d.ts +143 -0
- package/lib/typescript/commonjs/formatters/index.d.ts +4 -0
- package/lib/typescript/commonjs/formatters/number.d.ts +15 -5
- package/lib/typescript/commonjs/index.d.ts +26 -8
- package/lib/typescript/commonjs/initSDK.d.ts +18 -6
- package/lib/typescript/commonjs/initUserAuth.d.ts +29 -0
- package/lib/typescript/commonjs/logger/crashlytics.d.ts +31 -0
- package/lib/typescript/commonjs/logger/index.d.ts +17 -0
- package/lib/typescript/commonjs/push/index.d.ts +3 -1
- package/lib/typescript/commonjs/push/push.d.ts +1 -1
- package/lib/typescript/commonjs/push/status.d.ts +9 -0
- package/lib/typescript/commonjs/query/apiBaseQuery.d.ts +55 -0
- package/lib/typescript/commonjs/query/createAppApi.d.ts +21 -0
- package/lib/typescript/commonjs/query/index.d.ts +9 -0
- package/lib/typescript/commonjs/query/listeners.d.ts +11 -0
- package/lib/typescript/commonjs/query/paging.d.ts +42 -0
- package/lib/typescript/commonjs/query/tags.d.ts +31 -0
- package/lib/typescript/commonjs/redux/errorToastMiddleware.d.ts +51 -0
- package/lib/typescript/commonjs/redux/index.d.ts +6 -0
- package/lib/typescript/commonjs/redux/rootReducer.d.ts +19 -0
- package/lib/typescript/commonjs/redux/serializableCheck.d.ts +14 -0
- package/lib/typescript/commonjs/secureScreen/index.d.ts +25 -0
- package/lib/typescript/commonjs/versionCheck/buildNumber.d.ts +14 -0
- package/lib/typescript/commonjs/versionCheck/index.d.ts +28 -17
- package/lib/typescript/module/api/clientHeaders.d.ts +25 -0
- package/lib/typescript/module/api/minAppVersion.d.ts +24 -0
- package/lib/typescript/module/api/requestDefaults.d.ts +21 -0
- package/lib/typescript/module/api/responseBodyText.d.ts +6 -0
- package/lib/typescript/module/api/retry.d.ts +23 -9
- package/lib/typescript/module/api/tokenRefresh.d.ts +14 -2
- package/lib/typescript/module/api/userClient.d.ts +1 -1
- package/lib/typescript/module/auth/authStore.d.ts +76 -0
- package/lib/typescript/module/auth/index.d.ts +2 -2
- package/lib/typescript/module/config/index.d.ts +31 -2
- package/lib/typescript/module/errors/extractApiError.d.ts +69 -0
- package/lib/typescript/module/errors/index.d.ts +3 -0
- package/lib/typescript/module/formatters/currency.d.ts +22 -7
- package/lib/typescript/module/formatters/date.d.ts +13 -13
- package/lib/typescript/module/formatters/dateMath.d.ts +4 -2
- package/lib/typescript/module/formatters/formatConfig.d.ts +48 -0
- package/lib/typescript/module/formatters/house.d.ts +143 -0
- package/lib/typescript/module/formatters/index.d.ts +4 -0
- package/lib/typescript/module/formatters/number.d.ts +15 -5
- package/lib/typescript/module/index.d.ts +26 -8
- package/lib/typescript/module/initSDK.d.ts +18 -6
- package/lib/typescript/module/initUserAuth.d.ts +29 -0
- package/lib/typescript/module/logger/crashlytics.d.ts +31 -0
- package/lib/typescript/module/logger/index.d.ts +17 -0
- package/lib/typescript/module/push/index.d.ts +3 -1
- package/lib/typescript/module/push/push.d.ts +1 -1
- package/lib/typescript/module/push/status.d.ts +9 -0
- package/lib/typescript/module/query/apiBaseQuery.d.ts +55 -0
- package/lib/typescript/module/query/createAppApi.d.ts +21 -0
- package/lib/typescript/module/query/index.d.ts +9 -0
- package/lib/typescript/module/query/listeners.d.ts +11 -0
- package/lib/typescript/module/query/paging.d.ts +42 -0
- package/lib/typescript/module/query/tags.d.ts +31 -0
- package/lib/typescript/module/redux/errorToastMiddleware.d.ts +51 -0
- package/lib/typescript/module/redux/index.d.ts +6 -0
- package/lib/typescript/module/redux/rootReducer.d.ts +19 -0
- package/lib/typescript/module/redux/serializableCheck.d.ts +14 -0
- package/lib/typescript/module/secureScreen/index.d.ts +25 -0
- package/lib/typescript/module/versionCheck/buildNumber.d.ts +14 -0
- package/lib/typescript/module/versionCheck/index.d.ts +28 -17
- package/package.json +52 -5
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalizes any failure a thunk, a service or the RTK Query base query can see into one
|
|
3
|
+
* `ApiError`. Identical source in @webority/web-core and @webority/mobile-core.
|
|
4
|
+
*
|
|
5
|
+
* Bodies read, newest first: the fleet body `{ code, message, traceId, errors }` (D-077),
|
|
6
|
+
* where `errors` is a ModelState dictionary (`{ Field: ["msg"] }`) or a list of
|
|
7
|
+
* `{ field, message, reference }` (a refusal that names its fields),
|
|
8
|
+
* ProblemDetails `{ title, detail, errors }` from APIs not yet moved, legacy `{ error }` and
|
|
9
|
+
* `{ message }`, and a plain-text body.
|
|
10
|
+
*
|
|
11
|
+
* Message precedence is fixed (react.md): first field error, then `message`, `detail`, a
|
|
12
|
+
* legacy `error`, `title`, then `Request failed (<status>)`. `title` is last because it is
|
|
13
|
+
* the ProblemDetails category ("Bad Request"), not the curated sentence.
|
|
14
|
+
*
|
|
15
|
+
* Two things never become `message`: a 5xx body (our failure, nothing the user can act on)
|
|
16
|
+
* and anything that reads like an exception dump. The server's text goes on `detail` for
|
|
17
|
+
* the logger instead.
|
|
18
|
+
*/
|
|
19
|
+
export interface ApiError {
|
|
20
|
+
/** Stable snake_case branch key from the server (`not_found`, `validation_failed`). Branch on it, never render it. */
|
|
21
|
+
code: string | null;
|
|
22
|
+
/** The only user-facing string. */
|
|
23
|
+
message: string;
|
|
24
|
+
/** camelCase field path to its first message, ready for react-hook-form `setError`. */
|
|
25
|
+
fieldErrors: Record<string, string>;
|
|
26
|
+
/** HTTP status, or 0 when no response arrived. */
|
|
27
|
+
status: number;
|
|
28
|
+
/** True when no answer arrived (offline, network drop, timeout): a retry is worth offering. */
|
|
29
|
+
offline: boolean;
|
|
30
|
+
/** The server's trace id, for a support reference. */
|
|
31
|
+
traceId: string | null;
|
|
32
|
+
/** What the server or runtime actually said. For the logger, never for the screen. */
|
|
33
|
+
detail: string | null;
|
|
34
|
+
}
|
|
35
|
+
export declare const SERVER_FAILURE_MESSAGE = "Something went wrong on our side. Please try again in a moment.";
|
|
36
|
+
export declare const OFFLINE_MESSAGE = "You appear to be offline. Check your connection and try again.";
|
|
37
|
+
export declare const TIMEOUT_MESSAGE = "That took too long to respond. Check your connection and try again.";
|
|
38
|
+
export declare const UNEXPECTED_MESSAGE = "Something went wrong. Please try again.";
|
|
39
|
+
/** `code` for a request the caller cancelled (axios `CanceledError`). Never toasted. */
|
|
40
|
+
export declare const REQUEST_CANCELED_CODE = "request_canceled";
|
|
41
|
+
/** `code` for a response that failed schema validation at the service boundary. */
|
|
42
|
+
export declare const CONTRACT_ERROR_CODE = "contract_error";
|
|
43
|
+
/** `code` for a request that got no answer in time (axios `ECONNABORTED` / `ETIMEDOUT`). `offline` is true. */
|
|
44
|
+
export declare const TIMEOUT_CODE = "timeout";
|
|
45
|
+
/** `code` for a request that never reached the server (offline, DNS, CORS, a dropped connection). `offline` is true. */
|
|
46
|
+
export declare const NETWORK_CODE = "network";
|
|
47
|
+
/** `Items[0].UnitPrice` -> `items[0].unitPrice`; `$.email` (System.Text.Json path) -> `email`. */
|
|
48
|
+
export declare const toFieldPath: (key: string) => string;
|
|
49
|
+
export declare const isApiError: (value: unknown) => value is ApiError;
|
|
50
|
+
export declare function extractApiError(error: unknown): ApiError;
|
|
51
|
+
/**
|
|
52
|
+
* True when no answer arrived (offline, a dropped connection, a timeout), so the caller cannot
|
|
53
|
+
* tell what the server did. The same as `extractApiError(error).offline`.
|
|
54
|
+
*/
|
|
55
|
+
export declare const isNoResponse: (error: unknown) => boolean;
|
|
56
|
+
/**
|
|
57
|
+
* The sentence a screen shows for a failure: the server's own curated message when it sent one,
|
|
58
|
+
* otherwise the screen's `fallback` ("We couldn't save the project."), otherwise the library's
|
|
59
|
+
* generic sentence. A lost answer always reads as the connection message, because "check your
|
|
60
|
+
* connection" is more accurate than any screen's fallback. A 5xx, a cancelled request and a body
|
|
61
|
+
* with no usable sentence count as "the server said nothing usable".
|
|
62
|
+
*
|
|
63
|
+
* `fallback: null` is the "say nothing" mode, for a screen that shows only what the server
|
|
64
|
+
* curated (a live panel that keeps its last result): it returns null when the server said
|
|
65
|
+
* nothing usable, and still the connection message for a lost answer.
|
|
66
|
+
*/
|
|
67
|
+
export declare function apiErrorMessage(error: unknown, fallback?: string): string;
|
|
68
|
+
export declare function apiErrorMessage(error: unknown, fallback: string | null): string | null;
|
|
69
|
+
//# sourceMappingURL=extractApiError.d.ts.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export type { ApiError } from './extractApiError.js';
|
|
2
|
+
export { apiErrorMessage, CONTRACT_ERROR_CODE, extractApiError, isApiError, isNoResponse, NETWORK_CODE, OFFLINE_MESSAGE, REQUEST_CANCELED_CODE, SERVER_FAILURE_MESSAGE, TIMEOUT_CODE, TIMEOUT_MESSAGE, toFieldPath, UNEXPECTED_MESSAGE } from './extractApiError.js';
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,24 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* The currency keys plus any other `Intl.NumberFormatOptions` (`currencyDisplay`, `notation`,
|
|
3
|
+
* `signDisplay`, ...), passed through to Intl.NumberFormat.
|
|
4
|
+
*/
|
|
5
|
+
export interface FormatCurrencyOptions extends Omit<Intl.NumberFormatOptions, 'style' | 'currency'> {
|
|
2
6
|
/** ISO 4217 currency code. Defaults to `'INR'`. */
|
|
3
7
|
currency?: string;
|
|
4
|
-
/** BCP-47 locale tag. Defaults to `'en-IN'` (Indian numbering system). */
|
|
8
|
+
/** BCP-47 locale tag. Defaults to the configured locale, else `'en-IN'` (Indian numbering system). */
|
|
5
9
|
locale?: string;
|
|
6
|
-
/** Minimum fraction digits. Defaults to 0 for whole amounts, 2
|
|
10
|
+
/** Minimum fraction digits. Defaults to 0 for whole amounts, else the currency's own (2 for INR, 0 for JPY). */
|
|
7
11
|
minimumFractionDigits?: number;
|
|
8
|
-
/** Maximum fraction digits. Defaults to
|
|
12
|
+
/** Maximum fraction digits. Defaults to the currency's own. */
|
|
9
13
|
maximumFractionDigits?: number;
|
|
10
14
|
/** Strip the currency symbol — useful when the symbol is rendered separately. */
|
|
11
15
|
stripSymbol?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* What a missing amount prints. Defaults to the configured placeholder once the app has
|
|
18
|
+
* configured a locale or an `empty` (`configureFormatters`), else `''`.
|
|
19
|
+
*/
|
|
20
|
+
empty?: string;
|
|
12
21
|
}
|
|
13
22
|
/**
|
|
14
23
|
* Format an amount as currency. Defaults to **INR** with Indian numbering (`en-IN`),
|
|
15
|
-
* which matches the standard convention across Webority projects.
|
|
24
|
+
* which matches the standard convention across Webority projects. Called with no
|
|
25
|
+
* options: "₹1,50,000" for 150000, "₹1,234.50" for 1234.5, and `''` for a missing amount.
|
|
26
|
+
* Once the app configures a locale (`configureFormatters({ locale })`), the amount is
|
|
27
|
+
* written in that locale and a missing amount prints the configured placeholder ("-").
|
|
28
|
+
* A numeric string reads as its number. For money the API carries in minor units (paise),
|
|
29
|
+
* use `formatMinor`.
|
|
16
30
|
*
|
|
17
31
|
* @example
|
|
18
32
|
* formatCurrency(150000) // ₹1,50,000
|
|
19
33
|
* formatCurrency(1234.5) // ₹1,234.50
|
|
20
|
-
* formatCurrency(99, { currency: 'USD', locale: 'en-US' }) // $99
|
|
34
|
+
* formatCurrency(99, { currency: 'USD', locale: 'en-US' }) // $99
|
|
21
35
|
* formatCurrency(150000, { stripSymbol: true }) // 1,50,000
|
|
36
|
+
* formatCurrency(1500000, { notation: 'compact' }) // ₹15L
|
|
22
37
|
*/
|
|
23
|
-
export declare const formatCurrency: (amount: number | null | undefined, options?: FormatCurrencyOptions) => string;
|
|
38
|
+
export declare const formatCurrency: (amount: number | string | null | undefined, options?: FormatCurrencyOptions) => string;
|
|
24
39
|
//# sourceMappingURL=currency.d.ts.map
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
+
import { type DateValue, type FormatDateOptions, type FormatDateTimeOptions, type FormatTimeOptions } from './house.js';
|
|
1
2
|
export type DateInput = Date | string | number;
|
|
2
3
|
export type DateStyle = 'short' | 'medium' | 'long' | 'full';
|
|
3
4
|
export type TimeStyle = 'short' | 'medium' | 'long';
|
|
4
|
-
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export declare const formatDateTime: (value: DateInput, dateStyle?: DateStyle, timeStyle?: TimeStyle, locale?: string) => string;
|
|
5
|
+
/** "08-Apr-2026" in the configured zone; a bare calendar date stays that day. */
|
|
6
|
+
export declare function formatDate(value: DateValue, options?: FormatDateOptions): string;
|
|
7
|
+
/** Intl `dateStyle` output, `'en-IN'` by default. */
|
|
8
|
+
export declare function formatDate(value: DateInput, style: DateStyle, locale?: string): string;
|
|
9
|
+
/** "8:05 PM" in IST, labelled in any other zone. */
|
|
10
|
+
export declare function formatTime(value: DateValue, options?: FormatTimeOptions): string;
|
|
11
|
+
/** Intl `timeStyle` output (24-hour fallback when Intl is unavailable). */
|
|
12
|
+
export declare function formatTime(value: DateInput, style: TimeStyle, locale?: string): string;
|
|
13
|
+
/** "08-Apr-2026, 8:05 PM" in IST, labelled in any other zone. */
|
|
14
|
+
export declare function formatDateTime(value: DateValue, options?: FormatDateTimeOptions): string;
|
|
15
|
+
/** Intl `dateStyle` + `timeStyle` output. */
|
|
16
|
+
export declare function formatDateTime(value: DateInput, dateStyle: DateStyle, timeStyle?: TimeStyle, locale?: string): string;
|
|
17
17
|
/**
|
|
18
18
|
* Returns a humanized relative-time string (e.g. "5 minutes ago", "in 3 days").
|
|
19
19
|
* Uses `Intl.RelativeTimeFormat` when available; otherwise a sensible English fallback.
|
|
@@ -21,9 +21,11 @@ export declare const diffMs: (a: DateInput, b: DateInput) => number;
|
|
|
21
21
|
export declare const startOfDay: (value: DateInput) => Date | null;
|
|
22
22
|
/**
|
|
23
23
|
* Adds (or, with a negative count, subtracts) whole calendar days in the
|
|
24
|
-
* device's local timezone. Returns null for unparseable
|
|
24
|
+
* device's local timezone. Returns null for a missing or unparseable date or
|
|
25
|
+
* count, so the result can go straight to `formatDate`. Same name and meaning
|
|
26
|
+
* as `@webority/web-core`'s `addDays`.
|
|
25
27
|
*/
|
|
26
|
-
export declare const addDays: (value: DateInput, count: number) => Date | null;
|
|
28
|
+
export declare const addDays: (value: DateInput | null | undefined, count: number) => Date | null;
|
|
27
29
|
/**
|
|
28
30
|
* Small dayjs/moment-style token formatter — YYYY/YY, MMMM/MMM/MM/M,
|
|
29
31
|
* DD/D, dddd/ddd, HH/H (24h), hh/h (12h), mm/m, ss/s, A/a (upper/lower AM/PM).
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* App-wide settings for the house formatters. This file is byte-identical in
|
|
3
|
+
* @webority/mobile-core and @webority/web-core, so a screen formats the same
|
|
4
|
+
* instant the same way on a phone and in a browser.
|
|
5
|
+
*
|
|
6
|
+
* Zone policy: an India-market product shows every instant in IST, unlabelled
|
|
7
|
+
* (the default). A product whose users span time zones opts into the viewer's
|
|
8
|
+
* own zone; times then carry a zone label so an instant is never ambiguous.
|
|
9
|
+
*
|
|
10
|
+
* Text policy: with no locale configured, every formatter prints the house
|
|
11
|
+
* text, assembled here so it reads the same on every engine ("08-Apr-2026",
|
|
12
|
+
* "8:05 PM", "1,23,456.79"). Configuring a locale hands the words and
|
|
13
|
+
* separators to Intl for that locale: month names, digit separators, the
|
|
14
|
+
* 12- or 24-hour clock and its AM/PM casing, zone names and relative phrases.
|
|
15
|
+
* The date order stays DD-MMM-YYYY either way.
|
|
16
|
+
*/
|
|
17
|
+
/** `'IST'`: every instant in India Standard Time. `'viewer'`: the device or browser zone, labelled. */
|
|
18
|
+
export type ZoneMode = 'IST' | 'viewer';
|
|
19
|
+
/** How the integer part of a number is grouped. */
|
|
20
|
+
export type NumberGrouping = 'indian' | 'international' | 'none';
|
|
21
|
+
export interface FormatterConfig {
|
|
22
|
+
/** Default zone for every date and time formatter. */
|
|
23
|
+
zone: ZoneMode;
|
|
24
|
+
/**
|
|
25
|
+
* BCP-47 locale. Left at its default (en-IN), it only picks the house digit
|
|
26
|
+
* grouping. Configured (`configureFormatters({ locale })`), it switches every
|
|
27
|
+
* formatter to Intl's text for that locale: en-IN gives "08-Sept-2026" and
|
|
28
|
+
* "IST", de-DE gives "1.234,5" and "20:05".
|
|
29
|
+
*/
|
|
30
|
+
locale: string;
|
|
31
|
+
/** What every formatter returns for a missing or unreadable value. */
|
|
32
|
+
empty: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Set the zone mode, locale or empty placeholder for the whole app. Call it
|
|
36
|
+
* once at startup; a key left out (or undefined) keeps its current value.
|
|
37
|
+
* Passing nothing restores the defaults (IST, en-IN, "-", house text).
|
|
38
|
+
*/
|
|
39
|
+
export declare const configureFormatters: (config?: Partial<FormatterConfig>) => void;
|
|
40
|
+
/** The settings in force, as a copy. */
|
|
41
|
+
export declare const getFormatterConfig: () => FormatterConfig;
|
|
42
|
+
/** Whether the app set `key` through `configureFormatters`, rather than leaving the default. */
|
|
43
|
+
export declare const isFormatterConfigured: (key: keyof FormatterConfig) => boolean;
|
|
44
|
+
/** The configured locale when the app set one (Intl text), else null (house text). */
|
|
45
|
+
export declare const configuredLocale: () => string | null;
|
|
46
|
+
/** The grouping a locale implies: Indian for a locale whose region is IN. */
|
|
47
|
+
export declare const groupingForLocale: (locale: string) => NumberGrouping;
|
|
48
|
+
//# sourceMappingURL=formatConfig.d.ts.map
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The house formatters: DD-MMM-YYYY dates, IST by default or the viewer's own
|
|
3
|
+
* zone with a label, Indian digit grouping by default, money in minor units,
|
|
4
|
+
* and one empty placeholder. Byte-identical in @webority/mobile-core and
|
|
5
|
+
* @webority/web-core.
|
|
6
|
+
*
|
|
7
|
+
* Same output on Hermes and in every browser is the design constraint, so the
|
|
8
|
+
* text is assembled here rather than by Intl. Engines disagree on month
|
|
9
|
+
* abbreviations ("Sep" or "Sept"), on the space before AM/PM (a plain or a
|
|
10
|
+
* narrow no-break space), on zone names ("IST" or "GMT+5:30") and on which
|
|
11
|
+
* Intl options exist at all (Hermes has no RelativeTimeFormat and no
|
|
12
|
+
* trailingZeroDisplay). IST and the viewer's zone are therefore computed with
|
|
13
|
+
* plain Date arithmetic; Intl is used only to read the wall clock of an
|
|
14
|
+
* explicitly named IANA zone, through formatToParts with numeric fields, to
|
|
15
|
+
* read the locale's 12- or 24-hour clock, and where a caller asks for Intl
|
|
16
|
+
* output itself (Intl number options, `formatRelative({ intl: true })`).
|
|
17
|
+
*
|
|
18
|
+
* Called with no options (house defaults: zone IST, locale en-IN, empty "-"):
|
|
19
|
+
* - formatDate(v) "08-Apr-2026"; formatTime(v) "8:05 PM"; formatDateTime(v) "08-Apr-2026, 8:05 PM";
|
|
20
|
+
* - formatRelative(v) "5 minutes ago", "in 3 days", "just now";
|
|
21
|
+
* - formatNumber(v) "1,23,456.789" (Indian grouping, up to 3 decimals);
|
|
22
|
+
* - formatPercent(0.42) "42%"; formatMinor(15000000) "₹1,50,000.00";
|
|
23
|
+
* - a missing or unreadable value "-".
|
|
24
|
+
*
|
|
25
|
+
* With a configured locale (`configureFormatters({ locale })`), the words and separators come
|
|
26
|
+
* from Intl for that locale and the date order stays DD-MMM-YYYY. For en-IN in the viewer zone:
|
|
27
|
+
* "08-Sept-2026", "08:05 pm", "08-Sept-2026, 08:05 pm IST", "yesterday", "12,34,567.891",
|
|
28
|
+
* "₹1,50,000". For de-DE: "08-Sept-2026", "20:05", "1.234.567,891".
|
|
29
|
+
*/
|
|
30
|
+
import { type NumberGrouping, type ZoneMode } from './formatConfig.js';
|
|
31
|
+
/** A date the house formatters accept; null, undefined and "" read as missing. */
|
|
32
|
+
export type DateValue = Date | string | number | null | undefined;
|
|
33
|
+
/** A zone mode, `'UTC'`, or any IANA zone name such as `'America/New_York'`. */
|
|
34
|
+
export type ZoneOption = ZoneMode | 'UTC' | (string & {});
|
|
35
|
+
export interface FormatDateOptions {
|
|
36
|
+
/** Overrides the configured zone mode for this call. */
|
|
37
|
+
zone?: ZoneOption;
|
|
38
|
+
/** Overrides the configured empty placeholder for this call. */
|
|
39
|
+
empty?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface FormatTimeOptions extends FormatDateOptions {
|
|
42
|
+
/**
|
|
43
|
+
* 12 gives "8:05 PM", 24 gives "20:05". Defaults to 12 for the house text, and to the
|
|
44
|
+
* configured locale's own clock once a locale is configured (12 for en-IN and en-US,
|
|
45
|
+
* 24 for en-GB, de-DE and most of Europe).
|
|
46
|
+
*/
|
|
47
|
+
hourCycle?: 12 | 24;
|
|
48
|
+
/**
|
|
49
|
+
* Append the zone label ("IST", "UTC", "GMT-4"; Intl's short zone name for a
|
|
50
|
+
* configured locale). Defaults to on for every zone except IST, so the viewer
|
|
51
|
+
* mode always says which clock it shows.
|
|
52
|
+
*/
|
|
53
|
+
zoneLabel?: boolean;
|
|
54
|
+
}
|
|
55
|
+
export type FormatDateTimeOptions = FormatTimeOptions;
|
|
56
|
+
export interface FormatRelativeOptions {
|
|
57
|
+
/** The instant to measure from. Defaults to now. */
|
|
58
|
+
now?: Date | string | number;
|
|
59
|
+
empty?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Intl's own phrasing ("yesterday", "in 2 days", "now") instead of the house phrase
|
|
62
|
+
* ("1 day ago"). Always on once a locale is configured. Intl phrases count in rounded
|
|
63
|
+
* years, months, days, hours, minutes and seconds, with no week unit, so 36 hours ahead reads
|
|
64
|
+
* "in 2 days". An engine without Intl.RelativeTimeFormat (older Hermes) prints the house phrase.
|
|
65
|
+
*/
|
|
66
|
+
intl?: boolean;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The house keys, plus any `Intl.NumberFormatOptions`. With house keys only, the text is
|
|
70
|
+
* assembled here (same on every engine). With any other Intl key (`style`, `unit`,
|
|
71
|
+
* `notation`, `signDisplay`, `useGrouping`, ...), the number goes to `Intl.NumberFormat` in
|
|
72
|
+
* `locale` with every option passed through, so it reads as that engine's Intl reads it.
|
|
73
|
+
*/
|
|
74
|
+
export interface FormatNumberOptions extends Intl.NumberFormatOptions {
|
|
75
|
+
/**
|
|
76
|
+
* Defaults to the locale's grouping (Indian for en-IN). An explicit `'indian'` or
|
|
77
|
+
* `'international'` prints the house text even with a configured locale; `'none'` drops
|
|
78
|
+
* the separators either way.
|
|
79
|
+
*/
|
|
80
|
+
grouping?: NumberGrouping;
|
|
81
|
+
/** Defaults to 0. */
|
|
82
|
+
minimumFractionDigits?: number;
|
|
83
|
+
/** Defaults to 3 for formatNumber and 0 for formatPercent. */
|
|
84
|
+
maximumFractionDigits?: number;
|
|
85
|
+
/** Overrides the configured locale for this call. */
|
|
86
|
+
locale?: string;
|
|
87
|
+
empty?: string;
|
|
88
|
+
}
|
|
89
|
+
export interface FormatPercentOptions extends FormatNumberOptions {
|
|
90
|
+
/** `'ratio'` (the default) reads 0.42 as 42%; `'percent'` reads 42 as 42%. */
|
|
91
|
+
scale?: 'ratio' | 'percent';
|
|
92
|
+
}
|
|
93
|
+
export interface FormatMinorOptions {
|
|
94
|
+
/** ISO 4217 code. Defaults to `'INR'`. */
|
|
95
|
+
currency?: string;
|
|
96
|
+
/** Defaults to Indian grouping for INR and international grouping for every other currency. */
|
|
97
|
+
grouping?: NumberGrouping;
|
|
98
|
+
/** Print a whole amount without its zero decimals: "₹1,500" instead of "₹1,500.00". */
|
|
99
|
+
dropZeroDecimals?: boolean;
|
|
100
|
+
/** `false` prints the digits alone, for a field that draws the symbol itself. */
|
|
101
|
+
symbol?: boolean;
|
|
102
|
+
empty?: string;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* "08-Apr-2026". A bare calendar date ("2026-04-08") always shows as that day;
|
|
106
|
+
* an instant shows its day in the configured zone.
|
|
107
|
+
*/
|
|
108
|
+
export declare const formatDate: (value: DateValue, options?: FormatDateOptions) => string;
|
|
109
|
+
/** "8:05 PM" in IST, "8:05 PM GMT-4" in the viewer's zone; "20:05" for a configured locale with a 24-hour clock. */
|
|
110
|
+
export declare const formatTime: (value: DateValue, options?: FormatTimeOptions) => string;
|
|
111
|
+
/** "08-Apr-2026, 8:05 PM" in IST, "08-Apr-2026, 10:35 AM GMT-4" in the viewer's zone. */
|
|
112
|
+
export declare const formatDateTime: (value: DateValue, options?: FormatDateTimeOptions) => string;
|
|
113
|
+
/**
|
|
114
|
+
* "just now", "5 minutes ago", "in 3 days". English on every engine: Hermes
|
|
115
|
+
* has no Intl.RelativeTimeFormat. Counts are whole units, rounded down, so
|
|
116
|
+
* 59 minutes never reads as "60 minutes". With a configured locale, or
|
|
117
|
+
* `{ intl: true }`, the phrase is Intl's in that locale instead, with numeric
|
|
118
|
+
* "auto" and rounded counts: "yesterday", "in 2 days" at 36 hours ahead, "10 days ago",
|
|
119
|
+
* "30 seconds ago", "now".
|
|
120
|
+
*/
|
|
121
|
+
export declare const formatRelative: (value: DateValue, options?: FormatRelativeOptions) => string;
|
|
122
|
+
/**
|
|
123
|
+
* "1,23,456.79" by default; a string holding a number is read as that number. Any Intl option
|
|
124
|
+
* beyond the house keys (`{ style: 'unit', unit: 'meter' }`, `{ notation: 'compact' }`) hands
|
|
125
|
+
* the number to Intl.NumberFormat with every option passed through. With a configured locale,
|
|
126
|
+
* the separators are that locale's ("1.234,5" for de-DE).
|
|
127
|
+
*/
|
|
128
|
+
export declare const formatNumber: (value: number | string | null | undefined, options?: FormatNumberOptions) => string;
|
|
129
|
+
/**
|
|
130
|
+
* "42%" from 0.42, or from 42 with `scale: 'percent'`. Whole percent unless fraction digits are asked for.
|
|
131
|
+
* Any Intl option beyond the house keys goes to Intl.NumberFormat with `style: 'percent'`.
|
|
132
|
+
*/
|
|
133
|
+
export declare const formatPercent: (value: number | string | null | undefined, options?: FormatPercentOptions) => string;
|
|
134
|
+
/**
|
|
135
|
+
* Money held in minor units (paise, cents), which is how every API carries
|
|
136
|
+
* it: formatMinor(15000000) gives "₹1,50,000.00". The split into whole and
|
|
137
|
+
* fractional units is done on the integer's digits, so no floating-point
|
|
138
|
+
* division can shift a paisa. A fractional input is rounded to the nearest
|
|
139
|
+
* minor unit. A currency without a known symbol prints its code: "AED 1,000.00".
|
|
140
|
+
* With a configured locale, Intl writes it in that locale ("150.000,00 €" for de-DE).
|
|
141
|
+
*/
|
|
142
|
+
export declare const formatMinor: (amountMinor: number | string | null | undefined, options?: FormatMinorOptions) => string;
|
|
143
|
+
//# sourceMappingURL=house.d.ts.map
|
|
@@ -3,6 +3,10 @@ export { formatCurrency } from './currency.js';
|
|
|
3
3
|
export type { DateInput, DateStyle, TimeStyle } from './date.js';
|
|
4
4
|
export { formatDate, formatDateTime, formatRelativeTime, formatTime } from './date.js';
|
|
5
5
|
export { addDays, diffMs, formatDateDDMMMYYYY, formatDateISO, formatDatePattern, formatTime12h, formatTimeInWindowsZone, formatTimeInZone, isDateAfter, isDateBefore, isSameDay, startOfDay } from './dateMath.js';
|
|
6
|
+
export type { FormatterConfig, NumberGrouping, ZoneMode } from './formatConfig.js';
|
|
7
|
+
export { configureFormatters, getFormatterConfig } from './formatConfig.js';
|
|
8
|
+
export type { DateValue, FormatDateOptions, FormatDateTimeOptions, FormatMinorOptions, FormatNumberOptions, FormatPercentOptions, FormatRelativeOptions, FormatTimeOptions, ZoneOption } from './house.js';
|
|
9
|
+
export { formatMinor, formatRelative } from './house.js';
|
|
6
10
|
export { getInitials } from './initials.js';
|
|
7
11
|
export { formatCompactNumber, formatNumber, formatPercent } from './number.js';
|
|
8
12
|
export type { FormatPhoneOptions, PhoneCountry, PhoneCountryEntry, PhoneNumber, PhoneNumberType, PhoneParts, PhoneValidationKind } from './phone.js';
|
|
@@ -1,12 +1,22 @@
|
|
|
1
|
+
import { type FormatNumberOptions, type FormatPercentOptions } from './house.js';
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
+
* Two forms share each name. With an options object, or nothing, the house
|
|
4
|
+
* formatter runs (`./house`: no Intl, the configured grouping and empty
|
|
5
|
+
* placeholder, a numeric string read as its number). With positional
|
|
6
|
+
* arguments the original Intl formatter runs, unchanged, returning '' for
|
|
7
|
+
* missing input.
|
|
3
8
|
*/
|
|
4
|
-
|
|
9
|
+
/** "1,23,456.79": the configured grouping, up to three decimals by default. */
|
|
10
|
+
export declare function formatNumber(value: number | string | null | undefined, options?: FormatNumberOptions): string;
|
|
11
|
+
/** Intl output for `locale` (default `'en-IN'`), with exactly `fractionDigits` decimals when given. */
|
|
12
|
+
export declare function formatNumber(value: number | null | undefined, fractionDigits: number | undefined, locale?: string): string;
|
|
13
|
+
/** "42%" from 0.42 (or from 42 with `scale: 'percent'`), whole percent by default. */
|
|
14
|
+
export declare function formatPercent(value: number | string | null | undefined, options?: FormatPercentOptions): string;
|
|
5
15
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
16
|
+
* Intl percent output. Pass `asRatio: false` if the input is already on the
|
|
17
|
+
* 0–100 scale.
|
|
8
18
|
*/
|
|
9
|
-
export declare
|
|
19
|
+
export declare function formatPercent(value: number | null | undefined, fractionDigits: number | undefined, asRatio?: boolean, locale?: string): string;
|
|
10
20
|
/**
|
|
11
21
|
* Format a number compactly (1.2K, 3.4M, 1.5L, 2.3Cr).
|
|
12
22
|
* Defaults to Indian compact notation via `'en-IN'` locale (lakh / crore).
|
|
@@ -11,7 +11,14 @@
|
|
|
11
11
|
* @webority/mobile-core/sqlite expo-sqlite
|
|
12
12
|
* @webority/mobile-core/download a filesystem module
|
|
13
13
|
* @webority/mobile-core/share expo-sharing
|
|
14
|
+
* @webority/mobile-core/secureScreen expo-screen-capture
|
|
14
15
|
* @webority/mobile-core/smsRetriever Android only, own TurboModule
|
|
16
|
+
* @webority/mobile-core/query RTK Query base query and createApi preset
|
|
17
|
+
* (@reduxjs/toolkit and react-redux)
|
|
18
|
+
*
|
|
19
|
+
* `@webority/mobile-core/redux` (errorToastMiddleware, createRootReducer, resetState,
|
|
20
|
+
* SERIALIZABLE_IGNORED_ACTION_PATHS) is separate too: it needs @reduxjs/toolkit, an optional
|
|
21
|
+
* peer.
|
|
15
22
|
*
|
|
16
23
|
* One more path is separate for size, not for a native package:
|
|
17
24
|
*
|
|
@@ -21,36 +28,47 @@
|
|
|
21
28
|
* client reads the bearer token. It needs no optional peer: the backend is
|
|
22
29
|
* expo-secure-store, and `expo` is required anyway.
|
|
23
30
|
*/
|
|
31
|
+
export type { AccountIdProvider, ClientKind } from './api/clientHeaders.js';
|
|
32
|
+
export { ACCOUNT_ID_HEADER, CLIENT_BUILD_HEADER, CLIENT_KIND, CLIENT_KIND_HEADER, getClientBuild } from './api/clientHeaders.js';
|
|
24
33
|
export { buildCurl, logCurl } from './api/curl.js';
|
|
34
|
+
export type { MinAppVersionListener } from './api/minAppVersion.js';
|
|
35
|
+
export { addMinAppVersionListener, getMinAppVersion, MIN_APP_VERSION_HEADER } from './api/minAppVersion.js';
|
|
25
36
|
export { default as publicClient } from './api/publicClient.js';
|
|
37
|
+
export { applyRequestDefaults, newCorrelationId } from './api/requestDefaults.js';
|
|
26
38
|
export type { RetryPolicy } from './api/retry.js';
|
|
27
|
-
export { attachRetry, isRetryableStatus } from './api/retry.js';
|
|
39
|
+
export { attachRetry, IDEMPOTENCY_KEY_HEADER, isNeverSentError, isRetryableFailure, isRetryableStatus, retryAfterMs } from './api/retry.js';
|
|
28
40
|
export { refreshAccessToken } from './api/tokenRefresh.js';
|
|
29
41
|
export type { RefreshableStore, SessionTerminationCode } from './api/userClient.js';
|
|
30
|
-
export { default as userClient, injectStore, injectUserAuth, RequestOfflineError, resetRefreshState, SESSION_TERMINATION_CODES } from './api/userClient.js';
|
|
31
|
-
export type { KeychainLike, SecureCredentials, StoredToken } from './auth/authStore.js';
|
|
32
|
-
export { ACCESS_TOKEN_KEY, getToken, REFRESH_TOKEN_KEY, removeToken, setKeychainImplementation, storeToken } from './auth/authStore.js';
|
|
42
|
+
export { default as userClient, injectStore, injectUserAuth, RequestOfflineError, resetRefreshState, SESSION_TERMINATION_CODES, SIGN_OUT_REASON_HEADER } from './api/userClient.js';
|
|
43
|
+
export type { KeychainLike, LegacyTokenKeys, SecureCredentials, SessionEndDetail, SessionEndedListener, SessionEndReason, StoredToken } from './auth/authStore.js';
|
|
44
|
+
export { ACCESS_TOKEN_KEY, addSessionEndedListener, clearSession, getSessionUser, getToken, LEGACY_REFRESH_TOKEN_LIFETIME_MS, REFRESH_TOKEN_KEY, removeSessionUser, removeToken, SESSION_USER_KEY, setKeychainImplementation, setLegacyTokenKeys, storeSessionUser, storeToken } from './auth/authStore.js';
|
|
33
45
|
export type { JwtClaims } from './auth/jwt.js';
|
|
34
46
|
export { decodeJWT, getJWTExpiry, isJWTExpired } from './auth/jwt.js';
|
|
35
47
|
export type { Config, Environment, LogLevel } from './config/index.js';
|
|
36
48
|
export { getConfig, getConfigValue, resetConfig, setConfig } from './config/index.js';
|
|
37
49
|
export type { DeepLinkConfig, DeepLinkRoute, ParsedLink } from './deepLink/index.js';
|
|
38
50
|
export { DeepLink, parseDeepLink, useDeepLink } from './deepLink/index.js';
|
|
39
|
-
export type {
|
|
40
|
-
export {
|
|
51
|
+
export type { ApiError } from './errors/index.js';
|
|
52
|
+
export { apiErrorMessage, CONTRACT_ERROR_CODE, extractApiError, isApiError, isNoResponse, NETWORK_CODE, OFFLINE_MESSAGE, REQUEST_CANCELED_CODE, SERVER_FAILURE_MESSAGE, TIMEOUT_CODE, TIMEOUT_MESSAGE, toFieldPath, UNEXPECTED_MESSAGE } from './errors/index.js';
|
|
53
|
+
export type { DateInput, DateStyle, DateValue, FormatCurrencyOptions, FormatDateOptions, FormatDateTimeOptions, FormatMinorOptions, FormatNumberOptions, FormatPercentOptions, FormatPhoneOptions, FormatRelativeOptions, FormatTimeOptions, FormatterConfig, NumberGrouping, PhoneCountry, PhoneCountryEntry, PhoneNumber, PhoneNumberType, PhoneParts, PhoneValidationKind, TimeStyle, ZoneMode, ZoneOption } from './formatters/index.js';
|
|
54
|
+
export { AsYouType, addDays, clampNationalNumber, configureFormatters, countryFlagEmoji, detectPhoneCountry, diffMs, formatCompactNumber, formatCurrency, formatDate, formatDateDDMMMYYYY, formatDateISO, formatDatePattern, formatDateTime, formatMinor, formatNumber, formatPercent, formatPhone, formatPhoneAsTyped, formatRelative, formatRelativeTime, formatTime, formatTime12h, formatTimeInWindowsZone, formatTimeInZone, getCountries, getCountryCallingCode, getFormatterConfig, getInitials, getPhoneCountries, isDateAfter, isDateBefore, isSameDay, isSupportedCountry, isValidNationalNumber, isValidPhoneNumber, maxNationalNumberLength, normalizePhone, parsePhoneNumber, parsePhoneNumberFromString, splitPhoneNumber, startOfDay, validatePhoneNumberLength } from './formatters/index.js';
|
|
41
55
|
export type { InitConfig } from './initSDK.js';
|
|
42
56
|
export { initWebority } from './initSDK.js';
|
|
43
57
|
export type { TokenRefreshConfig, TokenRefreshResult, UserAuthOptions } from './initUserAuth.js';
|
|
44
58
|
export { initUserAuth } from './initUserAuth.js';
|
|
45
|
-
export type { DeviceContext, LoggerOptions, LoggerType, RemoteLogger } from './logger/index.js';
|
|
59
|
+
export type { DeviceContext, LoggerOptions, LoggerType, RemoteLogger, RequestFailedContext } from './logger/index.js';
|
|
46
60
|
export { configureLogger, getDeviceContext, Logger, setDeviceContext, setRemoteLogger } from './logger/index.js';
|
|
61
|
+
export type { CrashlyticsModule } from './logger/crashlytics.js';
|
|
62
|
+
export { crashlyticsRemoteLogger } from './logger/crashlytics.js';
|
|
47
63
|
export type { NetworkConnectionType, NetworkStatus, NetworkStatusLike, NetworkStatusListener } from './network/index.js';
|
|
48
64
|
export { addNetworkStatusListener, getNetworkStatus, setNetworkStatusImplementation, useNetworkStatus } from './network/index.js';
|
|
65
|
+
export type { PushStatus } from './push/status.js';
|
|
66
|
+
export { PUSH_STATUS } from './push/status.js';
|
|
49
67
|
export type { AsyncStorageLike, StorageApi } from './storage/index.js';
|
|
50
68
|
export { isStorageAvailable, Storage, setStorageImplementation } from './storage/index.js';
|
|
51
69
|
export { encodeBase64 } from './utils/base64.js';
|
|
52
70
|
export type { PasswordRules } from './validators/index.js';
|
|
53
71
|
export { isAadhaar, isAlphanumeric, isBetween, isEmail, isGstin, isHexColor, isIfsc, isIndianMobile, isIndianPincode, isInteger, isNonEmpty, isNumeric, isPan, isPhone, isStrongPassword, isUrl, maxLength, minLength } from './validators/index.js';
|
|
54
72
|
export type { DeviceInfoLike, ParsedVersion, Platform, UpdateInfo, UpdateType, VersionCheckResult, VersionCheckType, VersionComparison, VersionData } from './versionCheck/index.js';
|
|
55
|
-
export { setDeviceInfoImplementation, useVersionCheck, VersionCheck } from './versionCheck/index.js';
|
|
73
|
+
export { isBuildBelowMinimum, parseBuildNumber, setDeviceInfoImplementation, useVersionCheck, VersionCheck } from './versionCheck/index.js';
|
|
56
74
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -16,23 +16,35 @@ export interface InitConfig {
|
|
|
16
16
|
/** Environment. Defaults to `'Development'`. */
|
|
17
17
|
environment?: Environment;
|
|
18
18
|
/**
|
|
19
|
-
* ISO 3166-1 alpha-2 country code (lowercase) used
|
|
20
|
-
*
|
|
19
|
+
* ISO 3166-1 alpha-2 country code (lowercase) used in the App Store / Play
|
|
20
|
+
* Store link of the update prompt. Defaults to `'in'`.
|
|
21
21
|
*/
|
|
22
22
|
country?: string;
|
|
23
23
|
/**
|
|
24
|
-
* The app's store identifier (Android package name / iOS bundle id)
|
|
25
|
-
* user-visible version
|
|
26
|
-
* Webority app already has them in `appsettings.Compiled.json`, which
|
|
27
|
-
* they come from config rather than across the native bridge.
|
|
24
|
+
* The app's store identifier (Android package name / iOS bundle id), its
|
|
25
|
+
* user-visible version and its internal build number (`VERSION_INTERNAL`).
|
|
26
|
+
* Every Webority app already has them in `appsettings.Compiled.json`, which
|
|
27
|
+
* is why they come from config rather than across the native bridge. The
|
|
28
|
+
* version check compares `appBuild` with the API's `X-Min-App-Version`.
|
|
28
29
|
*/
|
|
29
30
|
appId?: string;
|
|
30
31
|
appVersion?: string;
|
|
32
|
+
appBuild?: number;
|
|
33
|
+
/** The numeric Apple App Store id; the iOS update button needs it. */
|
|
34
|
+
appStoreId?: string;
|
|
35
|
+
/** The build's short git sha (`COMMIT` in appsettings); sent as `X-Client-Build: <appVersion>+<commit>`. */
|
|
36
|
+
commit?: string;
|
|
31
37
|
/**
|
|
32
38
|
* Log a redacted curl line per request. Off by default; it is a debugging
|
|
33
39
|
* aid, not something to leave on.
|
|
34
40
|
*/
|
|
35
41
|
logCurl?: boolean;
|
|
42
|
+
/** Request timeout in milliseconds. Defaults to 30000; a request's own `timeout` wins. */
|
|
43
|
+
timeoutMs?: number;
|
|
44
|
+
/** Retries under the retry rule. Defaults to 3; 0 turns retrying off. */
|
|
45
|
+
retries?: number;
|
|
46
|
+
/** Header for the per-request correlation id. Defaults to `'X-Correlation-Id'`; `null` sends none. */
|
|
47
|
+
correlationIdHeader?: string | null;
|
|
36
48
|
/**
|
|
37
49
|
* The native modules that fill the seams the library does not import.
|
|
38
50
|
*
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { AccountIdProvider } from './api/clientHeaders.js';
|
|
2
|
+
import { type LegacyTokenKeys } from './auth/authStore.js';
|
|
1
3
|
/** The tokens a refresh response carries, with their expiry timestamps. */
|
|
2
4
|
export interface TokenRefreshResult {
|
|
3
5
|
accessToken: string;
|
|
@@ -17,6 +19,12 @@ export interface TokenRefreshConfig {
|
|
|
17
19
|
accessToken: string | null;
|
|
18
20
|
refreshToken: string;
|
|
19
21
|
}) => unknown;
|
|
22
|
+
/**
|
|
23
|
+
* Extra headers for the refresh call, read on every refresh; may return a promise. For a
|
|
24
|
+
* value the API must see as a header, such as `X-Installation-Id` for a rate limiter that
|
|
25
|
+
* cannot read the body.
|
|
26
|
+
*/
|
|
27
|
+
headers?: () => Record<string, string> | Promise<Record<string, string>>;
|
|
20
28
|
/**
|
|
21
29
|
* Reads the new tokens from the response body. Defaults to the Webority API's
|
|
22
30
|
* `{ accessToken, accessTokenExpiration, refreshToken, refreshTokenExpiration }`.
|
|
@@ -27,12 +35,33 @@ export interface UserAuthOptions {
|
|
|
27
35
|
/** Action creator dispatched when the session is over. */
|
|
28
36
|
logout: () => unknown;
|
|
29
37
|
refresh: TokenRefreshConfig;
|
|
38
|
+
/**
|
|
39
|
+
* The account the signed-in user is working in, sent as `X-Account-Id` on
|
|
40
|
+
* every userClient request. Read on every send, so a switch applies at once.
|
|
41
|
+
* Omit it in a product whose API takes the account from the token alone.
|
|
42
|
+
*/
|
|
43
|
+
accountId?: AccountIdProvider;
|
|
44
|
+
/**
|
|
45
|
+
* The response header in which the API names why it ended a session. A 401 carrying it is a
|
|
46
|
+
* revoked session: no refresh is tried, the session is cleared as `terminated`, and the
|
|
47
|
+
* value reaches every `addSessionEndedListener` listener as `detail.signOutReason`. It is
|
|
48
|
+
* read from a refused refresh too. Default `'X-Sign-Out-Reason'`; `null` turns it off.
|
|
49
|
+
*/
|
|
50
|
+
signOutReasonHeader?: string | null;
|
|
51
|
+
/**
|
|
52
|
+
* The secure-store keys the app kept its session under before this library. The first token
|
|
53
|
+
* read that finds the library's keys empty moves a session found there and deletes the old
|
|
54
|
+
* keys, so the release that adopts the library signs nobody out.
|
|
55
|
+
*/
|
|
56
|
+
legacyKeys?: LegacyTokenKeys;
|
|
30
57
|
}
|
|
31
58
|
/**
|
|
32
59
|
* Wire the user client to the app: the Redux store it dispatches `logout` to,
|
|
33
60
|
* and the refresh endpoint it calls when an access token expires or a request
|
|
34
61
|
* answers 401. Only a 400 or 401 from that endpoint, or a missing or expired
|
|
35
62
|
* refresh token, logs out; a network error, timeout or 5xx keeps the session.
|
|
63
|
+
* Logging out clears the session first (`clearSession('rejected' | 'terminated')`),
|
|
64
|
+
* so the tokens are gone and the session-ended listeners hear it, then dispatches `logout`.
|
|
36
65
|
*
|
|
37
66
|
* @example
|
|
38
67
|
* initUserAuth(store, { logout, refresh: { path: '/Account/RefreshToken' } });
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { RemoteLogger } from './index.js';
|
|
2
|
+
/**
|
|
3
|
+
* The part of `@react-native-firebase/crashlytics`'s modular API the adapter
|
|
4
|
+
* calls. Typed here, never imported, so the library carries no Firebase
|
|
5
|
+
* dependency: the app passes the module it already installs.
|
|
6
|
+
*/
|
|
7
|
+
export interface CrashlyticsModule<Instance = unknown> {
|
|
8
|
+
getCrashlytics: () => Instance;
|
|
9
|
+
log: (crashlytics: Instance, message: string) => void;
|
|
10
|
+
recordError: (crashlytics: Instance, error: Error, jsErrorName?: string) => void;
|
|
11
|
+
setUserId: (crashlytics: Instance, userId: string) => Promise<unknown>;
|
|
12
|
+
setAttribute: (crashlytics: Instance, name: string, value: string) => Promise<unknown>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Builds the `setRemoteLogger` adapter for Firebase Crashlytics:
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* import * as crashlytics from '@react-native-firebase/crashlytics';
|
|
19
|
+
* import { crashlyticsRemoteLogger, setRemoteLogger } from '@webority/mobile-core';
|
|
20
|
+
*
|
|
21
|
+
* setRemoteLogger(crashlyticsRemoteLogger(crashlytics));
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* Breadcrumbs and log lines become Crashlytics log lines, errors become
|
|
25
|
+
* non-fatals with their context logged just before, and the user id and
|
|
26
|
+
* attributes are set as given. Every call swallows its own failure, sync or
|
|
27
|
+
* async: the adapter runs inside `Logger.error`, so a throw would recurse, and
|
|
28
|
+
* a build without its Firebase config files has no Firebase app to report to.
|
|
29
|
+
*/
|
|
30
|
+
export declare const crashlyticsRemoteLogger: <Instance>(crashlytics: CrashlyticsModule<Instance>) => RemoteLogger;
|
|
31
|
+
//# sourceMappingURL=crashlytics.d.ts.map
|