@webority-technologies/mobile-core 0.0.1 → 0.0.2
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 +22 -1
- package/lib/commonjs/api/baseUrl.js +34 -0
- package/lib/commonjs/api/curl.js +109 -0
- package/lib/commonjs/api/publicClient.js +11 -20
- package/lib/commonjs/api/retry.js +75 -0
- package/lib/commonjs/api/userClient.js +46 -22
- package/lib/commonjs/auth/authStore.js +101 -33
- package/lib/commonjs/auth/jwt.js +32 -8
- package/lib/commonjs/config/index.js +2 -1
- package/lib/commonjs/deepLink/index.js +286 -0
- package/lib/commonjs/download/adapters/expoFs.js +100 -0
- package/lib/commonjs/download/adapters/shared.js +13 -0
- package/lib/commonjs/download/index.js +272 -0
- package/lib/commonjs/formatters/date.js +1 -1
- package/lib/commonjs/formatters/index.js +6 -0
- package/lib/commonjs/formatters/phone.js +103 -15
- package/lib/commonjs/geolocation/adapters/expoLocation.js +126 -0
- package/lib/commonjs/geolocation/index.js +339 -0
- package/lib/commonjs/index.js +133 -48
- package/lib/commonjs/initSDK.js +23 -2
- package/lib/commonjs/initUserAuth.js +2 -1
- package/lib/commonjs/logger/index.js +159 -5
- package/lib/commonjs/network/index.js +6 -0
- package/lib/commonjs/network/networkStatus.js +50 -15
- package/lib/commonjs/permissions/index.js +24 -1
- package/lib/commonjs/sqlite/adapters/expo.js +53 -0
- package/lib/commonjs/sqlite/adapters/op.js +43 -0
- package/lib/commonjs/sqlite/adapters/rows.js +33 -0
- package/lib/commonjs/sqlite/adapters/storage.js +50 -0
- package/lib/commonjs/sqlite/adapters/sync.js +45 -0
- package/lib/commonjs/sqlite/index.js +610 -0
- package/lib/commonjs/sqlite/nitro.js +17 -0
- package/lib/commonjs/sqlite/op.js +18 -0
- package/lib/commonjs/sqlite/quick.js +14 -0
- package/lib/commonjs/sqlite/storage.js +14 -0
- package/lib/commonjs/storage/index.js +40 -19
- package/lib/commonjs/types/globals.d.js +6 -0
- package/lib/commonjs/utils/imageCompression.js +51 -14
- package/lib/commonjs/utils/index.js +6 -0
- package/lib/commonjs/versionCheck/index.js +28 -4
- package/lib/module/api/baseUrl.js +30 -0
- package/lib/module/api/curl.js +104 -0
- package/lib/module/api/publicClient.js +11 -20
- package/lib/module/api/retry.js +69 -0
- package/lib/module/api/userClient.js +45 -21
- package/lib/module/auth/authStore.js +99 -32
- package/lib/module/auth/jwt.js +32 -8
- package/lib/module/config/index.js +2 -1
- package/lib/module/deepLink/index.js +280 -0
- package/lib/module/download/adapters/expoFs.js +95 -0
- package/lib/module/download/adapters/shared.js +8 -0
- package/lib/module/download/index.js +264 -0
- package/lib/module/formatters/date.js +1 -1
- package/lib/module/formatters/index.js +1 -1
- package/lib/module/formatters/phone.js +99 -13
- package/lib/module/geolocation/adapters/expoLocation.js +121 -0
- package/lib/module/geolocation/index.js +332 -0
- package/lib/module/index.js +28 -11
- package/lib/module/initSDK.js +23 -2
- package/lib/module/initUserAuth.js +2 -1
- package/lib/module/logger/index.js +156 -4
- package/lib/module/network/index.js +1 -1
- package/lib/module/network/networkStatus.js +47 -14
- package/lib/module/permissions/index.js +22 -0
- package/lib/module/sqlite/adapters/expo.js +48 -0
- package/lib/module/sqlite/adapters/op.js +38 -0
- package/lib/module/sqlite/adapters/rows.js +28 -0
- package/lib/module/sqlite/adapters/storage.js +46 -0
- package/lib/module/sqlite/adapters/sync.js +41 -0
- package/lib/module/sqlite/index.js +600 -0
- package/lib/module/sqlite/nitro.js +12 -0
- package/lib/module/sqlite/op.js +13 -0
- package/lib/module/sqlite/quick.js +9 -0
- package/lib/module/sqlite/storage.js +9 -0
- package/lib/module/storage/index.js +37 -18
- package/lib/module/types/globals.d.js +10 -0
- package/lib/module/utils/imageCompression.js +49 -13
- package/lib/module/utils/index.js +1 -1
- package/lib/module/versionCheck/index.js +27 -4
- package/lib/typescript/commonjs/api/baseUrl.d.ts +20 -0
- package/lib/typescript/commonjs/api/curl.d.ts +18 -0
- package/lib/typescript/commonjs/api/retry.d.ts +27 -0
- package/lib/typescript/commonjs/api/userClient.d.ts +11 -0
- package/lib/typescript/commonjs/auth/authStore.d.ts +29 -6
- package/lib/typescript/commonjs/config/index.d.ts +6 -0
- package/lib/typescript/commonjs/deepLink/index.d.ts +54 -0
- package/lib/typescript/commonjs/download/adapters/expoFs.d.ts +45 -0
- package/lib/typescript/commonjs/download/adapters/shared.d.ts +3 -0
- package/lib/typescript/commonjs/download/index.d.ts +76 -0
- package/lib/typescript/commonjs/formatters/index.d.ts +2 -1
- package/lib/typescript/commonjs/formatters/phone.d.ts +16 -1
- package/lib/typescript/commonjs/geolocation/adapters/expoLocation.d.ts +42 -0
- package/lib/typescript/commonjs/geolocation/index.d.ts +89 -0
- package/lib/typescript/commonjs/index.d.ts +30 -13
- package/lib/typescript/commonjs/initSDK.d.ts +32 -0
- package/lib/typescript/commonjs/logger/index.d.ts +39 -0
- package/lib/typescript/commonjs/network/index.d.ts +2 -2
- package/lib/typescript/commonjs/network/networkStatus.d.ts +16 -0
- package/lib/typescript/commonjs/permissions/index.d.ts +35 -0
- package/lib/typescript/commonjs/sqlite/adapters/expo.d.ts +30 -0
- package/lib/typescript/commonjs/sqlite/adapters/op.d.ts +27 -0
- package/lib/typescript/commonjs/sqlite/adapters/rows.d.ts +7 -0
- package/lib/typescript/commonjs/sqlite/adapters/storage.d.ts +30 -0
- package/lib/typescript/commonjs/sqlite/adapters/sync.d.ts +31 -0
- package/lib/typescript/commonjs/sqlite/index.d.ts +121 -0
- package/lib/typescript/commonjs/sqlite/nitro.d.ts +7 -0
- package/lib/typescript/commonjs/sqlite/op.d.ts +8 -0
- package/lib/typescript/commonjs/sqlite/quick.d.ts +4 -0
- package/lib/typescript/commonjs/sqlite/storage.d.ts +4 -0
- package/lib/typescript/commonjs/storage/index.d.ts +24 -2
- package/lib/typescript/commonjs/utils/imageCompression.d.ts +17 -0
- package/lib/typescript/commonjs/utils/index.d.ts +2 -2
- package/lib/typescript/module/api/baseUrl.d.ts +20 -0
- package/lib/typescript/module/api/curl.d.ts +18 -0
- package/lib/typescript/module/api/retry.d.ts +27 -0
- package/lib/typescript/module/api/userClient.d.ts +11 -0
- package/lib/typescript/module/auth/authStore.d.ts +29 -6
- package/lib/typescript/module/config/index.d.ts +6 -0
- package/lib/typescript/module/deepLink/index.d.ts +54 -0
- package/lib/typescript/module/download/adapters/expoFs.d.ts +45 -0
- package/lib/typescript/module/download/adapters/shared.d.ts +3 -0
- package/lib/typescript/module/download/index.d.ts +76 -0
- package/lib/typescript/module/formatters/index.d.ts +2 -1
- package/lib/typescript/module/formatters/phone.d.ts +16 -1
- package/lib/typescript/module/geolocation/adapters/expoLocation.d.ts +42 -0
- package/lib/typescript/module/geolocation/index.d.ts +89 -0
- package/lib/typescript/module/index.d.ts +30 -13
- package/lib/typescript/module/initSDK.d.ts +32 -0
- package/lib/typescript/module/logger/index.d.ts +39 -0
- package/lib/typescript/module/network/index.d.ts +2 -2
- package/lib/typescript/module/network/networkStatus.d.ts +16 -0
- package/lib/typescript/module/permissions/index.d.ts +35 -0
- package/lib/typescript/module/sqlite/adapters/expo.d.ts +30 -0
- package/lib/typescript/module/sqlite/adapters/op.d.ts +27 -0
- package/lib/typescript/module/sqlite/adapters/rows.d.ts +7 -0
- package/lib/typescript/module/sqlite/adapters/storage.d.ts +30 -0
- package/lib/typescript/module/sqlite/adapters/sync.d.ts +31 -0
- package/lib/typescript/module/sqlite/index.d.ts +121 -0
- package/lib/typescript/module/sqlite/nitro.d.ts +7 -0
- package/lib/typescript/module/sqlite/op.d.ts +8 -0
- package/lib/typescript/module/sqlite/quick.d.ts +4 -0
- package/lib/typescript/module/sqlite/storage.d.ts +4 -0
- package/lib/typescript/module/storage/index.d.ts +24 -2
- package/lib/typescript/module/utils/imageCompression.d.ts +17 -0
- package/lib/typescript/module/utils/index.d.ts +2 -2
- package/package.json +102 -14
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
* Simple initialization API for Webority packages
|
|
3
3
|
* One function to configure everything needed
|
|
4
4
|
*/
|
|
5
|
+
import { type KeychainLike } from './auth/authStore.js';
|
|
5
6
|
import { type Environment, type LogLevel } from './config/index.js';
|
|
7
|
+
import { type NetInfoLike } from './network/networkStatus.js';
|
|
8
|
+
import { setStorageImplementation } from './storage/index.js';
|
|
6
9
|
export interface InitConfig {
|
|
7
10
|
/** Your API base URL (required) */
|
|
8
11
|
baseUrl: string;
|
|
@@ -17,6 +20,35 @@ export interface InitConfig {
|
|
|
17
20
|
* version checks. Defaults to `'in'`.
|
|
18
21
|
*/
|
|
19
22
|
country?: string;
|
|
23
|
+
/**
|
|
24
|
+
* The app's store identifier (Android package name / iOS bundle id) and its
|
|
25
|
+
* user-visible version, both needed by the version-check module. Every
|
|
26
|
+
* Webority app already has them in `appsettings.Compiled.json`, which is why
|
|
27
|
+
* they come from config rather than across the native bridge.
|
|
28
|
+
*/
|
|
29
|
+
appId?: string;
|
|
30
|
+
appVersion?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Log a redacted curl line per request. Off by default; it is a debugging
|
|
33
|
+
* aid, not something to leave on.
|
|
34
|
+
*/
|
|
35
|
+
logCurl?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* The native modules that fill the seams the library does not import.
|
|
38
|
+
*
|
|
39
|
+
* Passing them here is strongly preferred over calling each setter, because
|
|
40
|
+
* forgetting one is silent: storage returns falsy and network status reports
|
|
41
|
+
* optimistic online, so an app looks like it works and simply never persists
|
|
42
|
+
* anything. The pilot migration wired NONE of them and nothing said so.
|
|
43
|
+
*
|
|
44
|
+
* Every value is whatever that surface's package exports, or an Expo adapter
|
|
45
|
+
* from its own import path. See docs/expo.md.
|
|
46
|
+
*/
|
|
47
|
+
backends?: {
|
|
48
|
+
storage?: Parameters<typeof setStorageImplementation>[0];
|
|
49
|
+
keychain?: KeychainLike | null;
|
|
50
|
+
network?: NetInfoLike | null;
|
|
51
|
+
};
|
|
20
52
|
}
|
|
21
53
|
/**
|
|
22
54
|
* Initialize Webority packages with your project configuration.
|
|
@@ -24,6 +24,39 @@ export interface RemoteLogger {
|
|
|
24
24
|
* Pass `null` to detach. Safe to call before or after `initWebority`.
|
|
25
25
|
*/
|
|
26
26
|
export declare const setRemoteLogger: (impl: RemoteLogger | null) => void;
|
|
27
|
+
/**
|
|
28
|
+
* Device / app context attached once at boot (platform, OS version, app version,
|
|
29
|
+
* build number, device model, etc). Merged into every `recordError` context so
|
|
30
|
+
* every crash carries it without every call site repeating it.
|
|
31
|
+
*/
|
|
32
|
+
export interface DeviceContext {
|
|
33
|
+
platform: string;
|
|
34
|
+
osVersion?: string;
|
|
35
|
+
appVersion?: string;
|
|
36
|
+
buildNumber?: string;
|
|
37
|
+
deviceModel?: string;
|
|
38
|
+
isEmulator?: boolean;
|
|
39
|
+
locale?: string;
|
|
40
|
+
[key: string]: unknown;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Set (or clear, with `null`) the device/app context merged into every
|
|
44
|
+
* `recordError` call. Each key is also forwarded to `remote.setAttribute`
|
|
45
|
+
* once, at the moment it is set.
|
|
46
|
+
*/
|
|
47
|
+
export declare const setDeviceContext: (context: DeviceContext | null) => void;
|
|
48
|
+
export declare const getDeviceContext: () => DeviceContext | null;
|
|
49
|
+
/** Tuning knobs for screen history and duplicate-error suppression. */
|
|
50
|
+
export interface LoggerOptions {
|
|
51
|
+
/** Identical errors within this window are collapsed. Default 5000ms. 0 disables dedupe. */
|
|
52
|
+
dedupeWindowMs?: number;
|
|
53
|
+
/** Max identical errors forwarded per window before suppression. Default 1. */
|
|
54
|
+
dedupeMaxPerWindow?: number;
|
|
55
|
+
/** Cap on tracked screen history. Default 20. */
|
|
56
|
+
screenHistoryLimit?: number;
|
|
57
|
+
}
|
|
58
|
+
/** Configure dedupe window/threshold and screen history size. Merges with current options. */
|
|
59
|
+
export declare const configureLogger: (options: LoggerOptions) => void;
|
|
27
60
|
export interface LoggerType {
|
|
28
61
|
info: LogFn;
|
|
29
62
|
warn: LogFn;
|
|
@@ -36,6 +69,12 @@ export interface LoggerType {
|
|
|
36
69
|
setUser: (id: string | null, attrs?: Record<string, unknown>) => void;
|
|
37
70
|
/** Attach a custom attribute (release, build, env, role, etc.). */
|
|
38
71
|
setAttribute: (key: string, value: string | number | boolean | null) => void;
|
|
72
|
+
/** Record the active screen; attaches `screen` to subsequent `recordError` context. */
|
|
73
|
+
trackScreen: (name: string, params?: Record<string, unknown>) => void;
|
|
74
|
+
/** The most recently tracked screen name, or `null` if none was tracked yet. */
|
|
75
|
+
getCurrentScreen: () => string | null;
|
|
76
|
+
/** Bounded history of tracked screen names, oldest first. */
|
|
77
|
+
getScreenHistory: () => string[];
|
|
39
78
|
}
|
|
40
79
|
export declare const Logger: LoggerType;
|
|
41
80
|
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export type { NetworkConnectionType, NetworkStatus, NetworkStatusListener } from './networkStatus.js';
|
|
2
|
-
export { addNetworkStatusListener, getNetworkStatus, useNetworkStatus } from './networkStatus.js';
|
|
1
|
+
export type { NetworkConnectionType, NetworkStatus, NetworkStatusLike, NetworkStatusListener } from './networkStatus.js';
|
|
2
|
+
export { addNetworkStatusListener, getNetworkStatus, setNetworkStatusImplementation, useNetworkStatus } from './networkStatus.js';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -10,6 +10,21 @@ export interface NetworkStatus {
|
|
|
10
10
|
type: NetworkConnectionType;
|
|
11
11
|
}
|
|
12
12
|
export type NetworkStatusListener = (status: NetworkStatus) => void;
|
|
13
|
+
interface NetInfoStateLike {
|
|
14
|
+
isConnected: boolean | null;
|
|
15
|
+
isInternetReachable: boolean | null;
|
|
16
|
+
type?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface NetInfoLike {
|
|
19
|
+
fetch: () => Promise<NetInfoStateLike>;
|
|
20
|
+
addEventListener: (cb: (state: NetInfoStateLike) => void) => () => void;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Replace the backend. Intended for TESTS and for the showcase, which uses it
|
|
24
|
+
* to reach error paths that a healthy device never takes; it is not the way an
|
|
25
|
+
* app is meant to configure the library. Pass `null` to restore expo-network.
|
|
26
|
+
*/
|
|
27
|
+
export declare const setNetworkStatusImplementation: (impl: NetInfoLike | null) => void;
|
|
13
28
|
/**
|
|
14
29
|
* Imperative one-shot fetch of current network status. Resolves to the default
|
|
15
30
|
* online status when NetInfo is unavailable so callers never crash.
|
|
@@ -24,4 +39,5 @@ export declare const addNetworkStatusListener: (listener: NetworkStatusListener)
|
|
|
24
39
|
* Reports an optimistic online default when NetInfo is not installed.
|
|
25
40
|
*/
|
|
26
41
|
export declare const useNetworkStatus: () => NetworkStatus;
|
|
42
|
+
export type { NetInfoLike as NetworkStatusLike };
|
|
27
43
|
//# sourceMappingURL=networkStatus.d.ts.map
|
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
export type PermissionKind = 'camera' | 'microphone' | 'photos' | 'photosAdd' | 'mediaLibrary' | 'location' | 'locationAlways' | 'contacts' | 'calendar' | 'reminders' | 'notifications' | 'bluetooth' | 'storage';
|
|
2
2
|
export type PermissionStatus = 'unavailable' | 'denied' | 'limited' | 'granted' | 'blocked';
|
|
3
|
+
export interface RNPermissionsModule {
|
|
4
|
+
PERMISSIONS: {
|
|
5
|
+
IOS: Record<string, string>;
|
|
6
|
+
ANDROID: Record<string, string>;
|
|
7
|
+
};
|
|
8
|
+
RESULTS: {
|
|
9
|
+
UNAVAILABLE: string;
|
|
10
|
+
DENIED: string;
|
|
11
|
+
LIMITED: string;
|
|
12
|
+
GRANTED: string;
|
|
13
|
+
BLOCKED: string;
|
|
14
|
+
};
|
|
15
|
+
check: (permission: string) => Promise<string>;
|
|
16
|
+
request: (permission: string) => Promise<string>;
|
|
17
|
+
openSettings: () => Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Inject a custom permissions implementation at runtime.
|
|
21
|
+
* Pass `null` to reset to the default lazily-resolved native module.
|
|
22
|
+
*
|
|
23
|
+
* `resolved` goes FALSE on null, never true. Marking it resolved with a null
|
|
24
|
+
* backend would permanently disable permissions: the resolver short-circuits and the
|
|
25
|
+
* real module is never loaded again, which contradicts this function's own
|
|
26
|
+
* documented contract. That exact bug shipped once, in the storage seam.
|
|
27
|
+
*
|
|
28
|
+
* THIS MODULE IS THE EXPO-FIRST EXCEPTION, and deliberately keeps the old
|
|
29
|
+
* shape. Expo ships no permissions package: each module carries its own
|
|
30
|
+
* (expo-location's requestForegroundPermissionsAsync, expo-image-picker's, and
|
|
31
|
+
* so on), so there is no single object to adapt and the library must not guess
|
|
32
|
+
* which Expo modules an app installed. react-native-permissions stays, behind
|
|
33
|
+
* this module's own import path so an app that never asks for permissions
|
|
34
|
+
* never names the package to Metro.
|
|
35
|
+
*/
|
|
36
|
+
export declare const setPermissionsImplementation: (impl: RNPermissionsModule | null) => void;
|
|
3
37
|
/**
|
|
4
38
|
* Cross-platform permissions wrapper. Maps an abstract `PermissionKind`
|
|
5
39
|
* (camera, photos, location, notifications, …) to the right
|
|
@@ -17,4 +51,5 @@ export declare const Permissions: {
|
|
|
17
51
|
ensure: (kind: PermissionKind) => Promise<PermissionStatus>;
|
|
18
52
|
openSettings: () => Promise<boolean>;
|
|
19
53
|
};
|
|
54
|
+
export type { RNPermissionsModule as PermissionsLike };
|
|
20
55
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { SqliteDriver } from '../index.js';
|
|
2
|
+
/**
|
|
3
|
+
* expo-sqlite. Shape verified against 57.0.2 rather than assumed, and it is the
|
|
4
|
+
* one driver that cannot share an adapter with the others: expo splits reads
|
|
5
|
+
* from writes. `getAllAsync` yields rows but no change count, `runAsync` yields
|
|
6
|
+
* `{ changes, lastInsertRowId }` but no rows, and SqliteResultSet needs all
|
|
7
|
+
* three from one call. `prepareAsync` + `executeAsync` is the only call that
|
|
8
|
+
* returns both, so every statement goes through it rather than being routed by
|
|
9
|
+
* sniffing the SQL for a leading SELECT.
|
|
10
|
+
*
|
|
11
|
+
* The REQUIRE lives in the driver entry point beside this file, never here.
|
|
12
|
+
*/
|
|
13
|
+
export interface ExpoSqliteExecuteResult {
|
|
14
|
+
lastInsertRowId: number;
|
|
15
|
+
changes: number;
|
|
16
|
+
getAllAsync: () => Promise<Record<string, unknown>[]>;
|
|
17
|
+
}
|
|
18
|
+
export interface ExpoSqliteStatementLike {
|
|
19
|
+
executeAsync: (params: unknown[]) => Promise<ExpoSqliteExecuteResult>;
|
|
20
|
+
finalizeAsync: () => Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
export interface ExpoSqliteDatabaseLike {
|
|
23
|
+
prepareAsync: (source: string) => Promise<ExpoSqliteStatementLike>;
|
|
24
|
+
closeAsync: () => Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
export interface ExpoSqliteModuleLike {
|
|
27
|
+
openDatabaseAsync: (name: string, options?: Record<string, unknown>, directory?: string) => Promise<ExpoSqliteDatabaseLike>;
|
|
28
|
+
}
|
|
29
|
+
export declare const adaptExpoSqlite: (mod: ExpoSqliteModuleLike) => SqliteDriver;
|
|
30
|
+
//# sourceMappingURL=expo.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { SqliteDriver } from '../index.js';
|
|
2
|
+
/**
|
|
3
|
+
* @op-engineering/op-sqlite. Shape verified against 18.1.4 rather than assumed:
|
|
4
|
+
* `open({ name, location })` is synchronous and returns a DB whose `execute` is
|
|
5
|
+
* ASYNC, and whose `rows` is already a plain array of objects rather than the
|
|
6
|
+
* `{ _array, item() }` shape the older drivers use. Both differences are why it
|
|
7
|
+
* cannot share the sync adapter.
|
|
8
|
+
*
|
|
9
|
+
* The REQUIRE lives in the driver entry point beside this file, never here.
|
|
10
|
+
*/
|
|
11
|
+
export interface OpSqliteQueryResult {
|
|
12
|
+
rows?: Record<string, unknown>[];
|
|
13
|
+
rowsAffected?: number;
|
|
14
|
+
insertId?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface OpSqliteModuleLike {
|
|
17
|
+
open: (options: {
|
|
18
|
+
name: string;
|
|
19
|
+
location?: string;
|
|
20
|
+
}) => {
|
|
21
|
+
execute: (sql: string, params?: unknown[]) => Promise<OpSqliteQueryResult>;
|
|
22
|
+
close: () => void;
|
|
23
|
+
closeAsync?: () => Promise<void>;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export declare const adaptOpSqlite: (mod: OpSqliteModuleLike) => SqliteDriver;
|
|
27
|
+
//# sourceMappingURL=op.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Row shapes differ per driver: a plain array, `{ _array, length, item() }`, or
|
|
3
|
+
* `{ length, item() }` alone. Every adapter normalises to a plain array here so
|
|
4
|
+
* nothing driver-specific escapes into the Db layer.
|
|
5
|
+
*/
|
|
6
|
+
export declare const rowsToArray: (rows: unknown) => Record<string, unknown>[];
|
|
7
|
+
//# sourceMappingURL=rows.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { SqliteDriver } from '../index.js';
|
|
2
|
+
interface SqliteStorageResultSet {
|
|
3
|
+
rows: {
|
|
4
|
+
length: number;
|
|
5
|
+
item: (i: number) => Record<string, unknown>;
|
|
6
|
+
};
|
|
7
|
+
rowsAffected: number;
|
|
8
|
+
insertId?: number;
|
|
9
|
+
}
|
|
10
|
+
/** react-native-sqlite-storage: callback-based by default, promise-based once
|
|
11
|
+
* `enablePromise(true)` is called; `executeSql` resolves an array whose first
|
|
12
|
+
* element is the result set. */
|
|
13
|
+
interface SqliteStorageModuleLike {
|
|
14
|
+
enablePromise: (enabled: boolean) => void;
|
|
15
|
+
openDatabase: (options: {
|
|
16
|
+
name: string;
|
|
17
|
+
location?: string;
|
|
18
|
+
}) => Promise<{
|
|
19
|
+
executeSql: (sql: string, params?: unknown[]) => Promise<[SqliteStorageResultSet]>;
|
|
20
|
+
close: () => Promise<void>;
|
|
21
|
+
}>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Adapt an already-required `react-native-sqlite-storage` module. Exported for
|
|
25
|
+
* the same reason as the filesystem adapters: the library cannot name a package
|
|
26
|
+
* the app did not install without breaking the app's bundle.
|
|
27
|
+
*/
|
|
28
|
+
export declare const adaptSqliteStorage: (mod: SqliteStorageModuleLike) => SqliteDriver;
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { SqliteDriver } from '../index.js';
|
|
2
|
+
/**
|
|
3
|
+
* nitro-sqlite and quick-sqlite share one synchronous shape, so one adapter
|
|
4
|
+
* serves both. The REQUIRE lives in the driver entry points beside this file,
|
|
5
|
+
* never here and never in the core: Metro resolves requires statically, so a
|
|
6
|
+
* package named anywhere reachable becomes mandatory for every consumer.
|
|
7
|
+
*/
|
|
8
|
+
interface SyncQueryResult {
|
|
9
|
+
rows?: unknown;
|
|
10
|
+
rowsAffected?: number;
|
|
11
|
+
insertId?: number;
|
|
12
|
+
}
|
|
13
|
+
/** Shape shared by react-native-nitro-sqlite and react-native-quick-sqlite: a
|
|
14
|
+
* synchronous `open({ name, location })` whose `db.execute()` and `db.close()`
|
|
15
|
+
* are also synchronous. Both are wrapped in Promise.resolve to fit SqliteDriver. */
|
|
16
|
+
interface SyncSqliteModuleLike {
|
|
17
|
+
open: (options: {
|
|
18
|
+
name: string;
|
|
19
|
+
location?: string;
|
|
20
|
+
}) => {
|
|
21
|
+
execute: (sql: string, params?: unknown[]) => SyncQueryResult;
|
|
22
|
+
close: () => void;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Adapt an already-required nitro-sqlite or quick-sqlite module. Both expose the
|
|
27
|
+
* same synchronous shape. Exported so an app on quick-sqlite can inject it.
|
|
28
|
+
*/
|
|
29
|
+
export declare const adaptSyncSqlite: (mod: SyncSqliteModuleLike) => SqliteDriver;
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=sync.d.ts.map
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This module names NO native package. Metro resolves requires statically, so a
|
|
3
|
+
* driver named here would be bundled by every consumer and would have to be
|
|
4
|
+
* installed by every app, whichever driver it actually chose. Each driver lives
|
|
5
|
+
* behind its own import path, and the app wires one at startup:
|
|
6
|
+
*
|
|
7
|
+
* import { setSqliteImplementation } from '@webority-technologies/mobile-core/sqlite';
|
|
8
|
+
* import { opSqliteDriver } from '@webority-technologies/mobile-core/sqlite/op';
|
|
9
|
+
* setSqliteImplementation(opSqliteDriver());
|
|
10
|
+
*
|
|
11
|
+
* Supported entry points: /sqlite/op, /sqlite/nitro, /sqlite/quick,
|
|
12
|
+
* /sqlite/storage. Any object matching SqliteDriver also works.
|
|
13
|
+
*/
|
|
14
|
+
export interface SqliteResultSet {
|
|
15
|
+
rows: Record<string, unknown>[];
|
|
16
|
+
rowsAffected: number;
|
|
17
|
+
insertId?: number;
|
|
18
|
+
}
|
|
19
|
+
export interface SqliteDatabase {
|
|
20
|
+
execute: (sql: string, params?: readonly unknown[]) => Promise<SqliteResultSet>;
|
|
21
|
+
close: () => Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
export interface SqliteDriver {
|
|
24
|
+
open: (name: string, options?: {
|
|
25
|
+
location?: string;
|
|
26
|
+
}) => Promise<SqliteDatabase>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Inject the SQLite driver. Pass `null` to clear it.
|
|
30
|
+
*
|
|
31
|
+
* `@webority-technologies/mobile-core` ships no database: it is pure JavaScript
|
|
32
|
+
* and defines only this interface. Wire a driver once at startup:
|
|
33
|
+
*
|
|
34
|
+
* import { opSqliteDriver } from '@webority-technologies/mobile-core/sqlite/op';
|
|
35
|
+
* setSqliteImplementation(opSqliteDriver());
|
|
36
|
+
*/
|
|
37
|
+
export declare const setSqliteImplementation: (impl: SqliteDriver | null) => void;
|
|
38
|
+
export declare const isSqliteAvailable: () => boolean;
|
|
39
|
+
/** The ledger of applied migrations. Never emptied by `wipe`. */
|
|
40
|
+
export declare const MIGRATIONS_TABLE = "_webority_migrations";
|
|
41
|
+
/**
|
|
42
|
+
* SQLite cannot bind an identifier to `?`, so every table/column name reaching
|
|
43
|
+
* a statement is concatenated. This is the ONE place that is allowed to happen,
|
|
44
|
+
* and it throws rather than quoting a hostile name into something executable.
|
|
45
|
+
*/
|
|
46
|
+
export declare const assertSqlIdentifier: (value: unknown, kind?: string) => string;
|
|
47
|
+
/** Normalise a JS value into something every SQLite driver can bind. */
|
|
48
|
+
export declare const toSqliteValue: (value: unknown) => unknown;
|
|
49
|
+
/** SQLite has no boolean type, so a stored flag comes back as 0/1 or '0'/'1'. */
|
|
50
|
+
export declare const fromSqliteBoolean: (value: unknown) => boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Build an `IN (...)` clause with one placeholder per value. An empty list
|
|
53
|
+
* yields a clause that matches nothing, because `IN ()` is a syntax error.
|
|
54
|
+
*/
|
|
55
|
+
export declare const whereIn: (column: string, values: readonly unknown[]) => {
|
|
56
|
+
sql: string;
|
|
57
|
+
params: unknown[];
|
|
58
|
+
};
|
|
59
|
+
export interface RawWhere {
|
|
60
|
+
sql: string;
|
|
61
|
+
params?: readonly unknown[];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Either a map of column to value (ANDed, `null` meaning IS NULL) or a raw
|
|
65
|
+
* fragment for anything the object form cannot express.
|
|
66
|
+
*/
|
|
67
|
+
export type Where = Record<string, unknown> | RawWhere;
|
|
68
|
+
export interface FindOptions {
|
|
69
|
+
orderBy?: string;
|
|
70
|
+
limit?: number;
|
|
71
|
+
offset?: number;
|
|
72
|
+
}
|
|
73
|
+
export interface Migration {
|
|
74
|
+
version: number;
|
|
75
|
+
name?: string;
|
|
76
|
+
up: string | string[] | ((tx: Pick<Db, 'execute'>) => Promise<void>);
|
|
77
|
+
}
|
|
78
|
+
export interface MigrateOptions {
|
|
79
|
+
/**
|
|
80
|
+
* Skip the downgrade guard. Only set this when the app knows the older code
|
|
81
|
+
* can read the newer schema.
|
|
82
|
+
*/
|
|
83
|
+
allowDowngrade?: boolean;
|
|
84
|
+
}
|
|
85
|
+
export declare const DEFAULT_PRAGMAS: Readonly<Record<string, string | number>>;
|
|
86
|
+
export interface OpenDatabaseOptions {
|
|
87
|
+
location?: string;
|
|
88
|
+
/**
|
|
89
|
+
* Merged over DEFAULT_PRAGMAS and applied on open. Pass `false` to apply none.
|
|
90
|
+
*/
|
|
91
|
+
pragmas?: Record<string, string | number> | false;
|
|
92
|
+
}
|
|
93
|
+
export interface Db {
|
|
94
|
+
readonly name: string;
|
|
95
|
+
execute: (sql: string, params?: readonly unknown[]) => Promise<SqliteResultSet>;
|
|
96
|
+
select: <T = Record<string, unknown>>(sql: string, params?: readonly unknown[]) => Promise<T[]>;
|
|
97
|
+
selectOne: <T = Record<string, unknown>>(sql: string, params?: readonly unknown[]) => Promise<T | null>;
|
|
98
|
+
transaction: <T>(work: (tx: Pick<Db, 'execute' | 'select' | 'selectOne'>) => Promise<T>) => Promise<T>;
|
|
99
|
+
insert: (table: string, row: Record<string, unknown>) => Promise<number | undefined>;
|
|
100
|
+
insertMany: (table: string, rows: Record<string, unknown>[]) => Promise<number>;
|
|
101
|
+
update: (table: string, values: Record<string, unknown>, where: Where) => Promise<number>;
|
|
102
|
+
remove: (table: string, where: Where) => Promise<number>;
|
|
103
|
+
upsert: (table: string, row: Record<string, unknown>, conflictColumns: string[]) => Promise<void>;
|
|
104
|
+
findAll: <T = Record<string, unknown>>(table: string, where?: Where, options?: FindOptions) => Promise<T[]>;
|
|
105
|
+
findOne: <T = Record<string, unknown>>(table: string, where?: Where) => Promise<T | null>;
|
|
106
|
+
count: (table: string, where?: Where) => Promise<number>;
|
|
107
|
+
tableExists: (table: string) => Promise<boolean>;
|
|
108
|
+
createTable: (table: string, columns: Record<string, string>, options?: {
|
|
109
|
+
ifNotExists?: boolean;
|
|
110
|
+
}) => Promise<void>;
|
|
111
|
+
dropTable: (table: string, options?: {
|
|
112
|
+
ifExists?: boolean;
|
|
113
|
+
}) => Promise<void>;
|
|
114
|
+
wipe: () => Promise<void>;
|
|
115
|
+
reset: (migrations: Migration[]) => Promise<number>;
|
|
116
|
+
migrate: (migrations: Migration[], options?: MigrateOptions) => Promise<number>;
|
|
117
|
+
baseline: (version: number, migrations?: Migration[]) => Promise<void>;
|
|
118
|
+
close: () => Promise<void>;
|
|
119
|
+
}
|
|
120
|
+
export declare const openDatabase: (name: string, options?: OpenDatabaseOptions) => Promise<Db>;
|
|
121
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SqliteDriver } from './index.js';
|
|
2
|
+
/**
|
|
3
|
+
* The one place `react-native-nitro-sqlite` is named. Import this module only if
|
|
4
|
+
* you installed it; nothing else in the library reaches it.
|
|
5
|
+
*/
|
|
6
|
+
export declare const nitroSqliteDriver: () => SqliteDriver;
|
|
7
|
+
//# sourceMappingURL=nitro.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SqliteDriver } from './index.js';
|
|
2
|
+
/**
|
|
3
|
+
* The one place `@op-engineering/op-sqlite` is named. It is the driver we
|
|
4
|
+
* recommend: the most actively maintained of the four, and the only one already
|
|
5
|
+
* proven in one of our apps. Import this module only if you installed it.
|
|
6
|
+
*/
|
|
7
|
+
export declare const opSqliteDriver: () => SqliteDriver;
|
|
8
|
+
//# sourceMappingURL=op.d.ts.map
|
|
@@ -6,6 +6,22 @@ interface AsyncStorageLike {
|
|
|
6
6
|
getItem: (key: string) => Promise<string | null>;
|
|
7
7
|
setItem: (key: string, value: string) => Promise<void>;
|
|
8
8
|
removeItem: (key: string) => Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* The batch API exists under TWO names, and both are live in this fleet.
|
|
11
|
+
*
|
|
12
|
+
* `@react-native-async-storage/async-storage` 3 renamed the v1 trio and
|
|
13
|
+
* changed their shapes: `getMany` returns a Record where `multiGet` returned
|
|
14
|
+
* pairs, and `setMany` takes a Record where `multiSet` took pairs. The v1
|
|
15
|
+
* names are still what `expo-sqlite/kv-store` and AsyncStorage 2 expose.
|
|
16
|
+
*
|
|
17
|
+
* Declaring only one set is not a compile error and not a runtime error — it
|
|
18
|
+
* silently falls through to the per-key loop below. The fleet pins
|
|
19
|
+
* AsyncStorage 3, so recognising only the v1 names put every consumer on N
|
|
20
|
+
* round-trips per batch with nothing to notice.
|
|
21
|
+
*/
|
|
22
|
+
getMany?: (keys: string[]) => Promise<Record<string, string | null>>;
|
|
23
|
+
setMany?: (entries: Record<string, string>) => Promise<void>;
|
|
24
|
+
removeMany?: (keys: string[]) => Promise<void>;
|
|
9
25
|
multiGet?: (keys: readonly string[]) => Promise<readonly [string, string | null][]>;
|
|
10
26
|
multiSet?: (kvs: readonly [string, string][]) => Promise<void>;
|
|
11
27
|
multiRemove?: (keys: readonly string[]) => Promise<void>;
|
|
@@ -13,8 +29,14 @@ interface AsyncStorageLike {
|
|
|
13
29
|
getAllKeys?: () => Promise<readonly string[]>;
|
|
14
30
|
}
|
|
15
31
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
32
|
+
* Always true now that the backend ships with the library. Kept because callers
|
|
33
|
+
* whose use of storage is an OPTIMISATION branch on it, and removing it would
|
|
34
|
+
* be a breaking change for no gain.
|
|
35
|
+
*/
|
|
36
|
+
export declare const isStorageAvailable: () => boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Replace the storage backend. Intended for TESTS and for the showcase; an app
|
|
39
|
+
* gets expo-sqlite/kv-store without wiring anything. Pass `null` to restore it.
|
|
18
40
|
*/
|
|
19
41
|
export declare const setStorageImplementation: (impl: AsyncStorageLike | null) => void;
|
|
20
42
|
export interface StorageApi {
|
|
@@ -16,6 +16,22 @@ export interface CompressImageOptions {
|
|
|
16
16
|
*/
|
|
17
17
|
fileSize?: number;
|
|
18
18
|
}
|
|
19
|
+
export interface CompressorModule {
|
|
20
|
+
Image: {
|
|
21
|
+
compress: (uri: string, options: {
|
|
22
|
+
maxWidth?: number;
|
|
23
|
+
maxHeight?: number;
|
|
24
|
+
quality?: number;
|
|
25
|
+
compressionMethod?: 'auto' | 'manual';
|
|
26
|
+
output?: 'jpg' | 'png' | 'webp';
|
|
27
|
+
}) => Promise<string>;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Replace the compressor. Intended for TESTS and for the showcase; an app gets
|
|
32
|
+
* expo-image-manipulator without wiring anything. Pass `null` to restore it.
|
|
33
|
+
*/
|
|
34
|
+
export declare const setImageCompressorImplementation: (impl: CompressorModule | null) => void;
|
|
19
35
|
/**
|
|
20
36
|
* Bigger source files get compressed harder — a fixed quality either over-compresses
|
|
21
37
|
* small photos or leaves large ones too heavy to upload quickly. Unknown size falls
|
|
@@ -28,4 +44,5 @@ export declare const qualityForFileSize: (fileSize?: number) => number;
|
|
|
28
44
|
* dependency is missing — so callers can rely on always getting a usable URI.
|
|
29
45
|
*/
|
|
30
46
|
export declare const compressImage: (uri: string, options?: CompressImageOptions) => Promise<string>;
|
|
47
|
+
export type { CompressorModule as ImageCompressorLike };
|
|
31
48
|
//# sourceMappingURL=imageCompression.d.ts.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export type { CompressImageOptions } from './imageCompression.js';
|
|
2
|
-
export { compressImage } from './imageCompression.js';
|
|
1
|
+
export type { CompressImageOptions, ImageCompressorLike } from './imageCompression.js';
|
|
2
|
+
export { compressImage, setImageCompressorImplementation } from './imageCompression.js';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|