@wayq/beekon-rn 0.0.3 → 0.0.6

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.
Files changed (84) hide show
  1. package/BeekonRn.podspec +5 -3
  2. package/CHANGELOG.md +103 -0
  3. package/README.md +326 -52
  4. package/android/build.gradle +9 -4
  5. package/android/src/main/java/in/wayq/beekonrn/BeekonRnModule.kt +411 -59
  6. package/ios/BeekonRn.mm +103 -24
  7. package/ios/BeekonRn.swift +465 -61
  8. package/ios/Frameworks/BeekonKit.xcframework/Info.plist +5 -5
  9. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64/BeekonKit.framework/BeekonKit +0 -0
  10. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64/BeekonKit.framework/Info.plist +0 -0
  11. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64/BeekonKit.framework/Modules/BeekonKit.swiftmodule/arm64-apple-ios.abi.json +11424 -1279
  12. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64/BeekonKit.framework/Modules/BeekonKit.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  13. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64/BeekonKit.framework/Modules/BeekonKit.swiftmodule/arm64-apple-ios.swiftinterface +262 -36
  14. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/BeekonKit +0 -0
  15. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/Info.plist +0 -0
  16. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/Modules/BeekonKit.swiftmodule/arm64-apple-ios-simulator.abi.json +11424 -1279
  17. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/Modules/BeekonKit.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  18. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/Modules/BeekonKit.swiftmodule/arm64-apple-ios-simulator.swiftinterface +262 -36
  19. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/Modules/BeekonKit.swiftmodule/x86_64-apple-ios-simulator.abi.json +11424 -1279
  20. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/Modules/BeekonKit.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  21. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/Modules/BeekonKit.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +262 -36
  22. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/_CodeSignature/CodeResources +2 -80
  23. package/lib/module/NativeBeekonRn.js +35 -7
  24. package/lib/module/NativeBeekonRn.js.map +1 -1
  25. package/lib/module/beekon.js +246 -45
  26. package/lib/module/beekon.js.map +1 -1
  27. package/lib/module/index.js.map +1 -1
  28. package/lib/module/internal/mappers.js +166 -25
  29. package/lib/module/internal/mappers.js.map +1 -1
  30. package/lib/module/types/auth.js +4 -0
  31. package/lib/module/types/auth.js.map +1 -0
  32. package/lib/module/types/config.js +2 -0
  33. package/lib/module/types/enums.js +2 -0
  34. package/lib/module/types/enums.js.map +1 -0
  35. package/lib/module/types/error.js +20 -4
  36. package/lib/module/types/error.js.map +1 -1
  37. package/lib/module/types/geofence.js +2 -0
  38. package/lib/module/types/geofence.js.map +1 -0
  39. package/lib/module/types/location.js +2 -0
  40. package/lib/module/types/sync.js +2 -0
  41. package/lib/module/types/sync.js.map +1 -0
  42. package/lib/typescript/src/NativeBeekonRn.d.ts +150 -20
  43. package/lib/typescript/src/NativeBeekonRn.d.ts.map +1 -1
  44. package/lib/typescript/src/beekon.d.ts +110 -33
  45. package/lib/typescript/src/beekon.d.ts.map +1 -1
  46. package/lib/typescript/src/index.d.ts +6 -2
  47. package/lib/typescript/src/index.d.ts.map +1 -1
  48. package/lib/typescript/src/internal/mappers.d.ts +16 -6
  49. package/lib/typescript/src/internal/mappers.d.ts.map +1 -1
  50. package/lib/typescript/src/types/auth.d.ts +99 -0
  51. package/lib/typescript/src/types/auth.d.ts.map +1 -0
  52. package/lib/typescript/src/types/config.d.ts +66 -20
  53. package/lib/typescript/src/types/config.d.ts.map +1 -1
  54. package/lib/typescript/src/types/enums.d.ts +62 -0
  55. package/lib/typescript/src/types/enums.d.ts.map +1 -0
  56. package/lib/typescript/src/types/error.d.ts +21 -5
  57. package/lib/typescript/src/types/error.d.ts.map +1 -1
  58. package/lib/typescript/src/types/geofence.d.ts +36 -0
  59. package/lib/typescript/src/types/geofence.d.ts.map +1 -0
  60. package/lib/typescript/src/types/location.d.ts +22 -8
  61. package/lib/typescript/src/types/location.d.ts.map +1 -1
  62. package/lib/typescript/src/types/state.d.ts +13 -4
  63. package/lib/typescript/src/types/state.d.ts.map +1 -1
  64. package/lib/typescript/src/types/sync.d.ts +27 -0
  65. package/lib/typescript/src/types/sync.d.ts.map +1 -0
  66. package/package.json +8 -5
  67. package/scripts/fetch-beekonkit.sh +5 -5
  68. package/src/NativeBeekonRn.ts +165 -20
  69. package/src/beekon.ts +278 -48
  70. package/src/index.tsx +24 -2
  71. package/src/internal/mappers.ts +242 -27
  72. package/src/types/auth.ts +101 -0
  73. package/src/types/config.ts +68 -20
  74. package/src/types/enums.ts +80 -0
  75. package/src/types/error.ts +23 -5
  76. package/src/types/geofence.ts +37 -0
  77. package/src/types/location.ts +28 -8
  78. package/src/types/state.ts +13 -3
  79. package/src/types/sync.ts +23 -0
  80. package/ios/Frameworks/BeekonKit.xcframework/_CodeSignature/CodeDirectory +0 -0
  81. package/ios/Frameworks/BeekonKit.xcframework/_CodeSignature/CodeRequirements +0 -0
  82. package/ios/Frameworks/BeekonKit.xcframework/_CodeSignature/CodeResources +0 -296
  83. package/ios/Frameworks/BeekonKit.xcframework/_CodeSignature/CodeSignature +0 -0
  84. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64/BeekonKit.framework/_CodeSignature/CodeResources +0 -146
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/enums.ts"],"mappings":"","ignoreList":[]}
@@ -1,13 +1,29 @@
1
1
  "use strict";
2
2
 
3
3
  /**
4
- * Error kinds thrown from `Beekon.start()` / `Beekon.history()`. Match the
5
- * native `BeekonError` cases byte-for-byte.
4
+ * Error kinds thrown across the bridge.
5
+ *
6
+ * Lifecycle problems on the tracking path never throw — they surface on the
7
+ * `onState` stream as `stopped(reason)`. The exceptions are the storage/geofence
8
+ * kinds below and the precondition kinds thrown by the explicit one-shot
9
+ * `getCurrentLocation()` (which has no `onState` arc of its own to report on; a
10
+ * plain timeout returns `null` instead of throwing).
11
+ *
12
+ * - `'storage'` — a local-store (SQLite) read/write failed. Thrown by
13
+ * `getLocations()`, `deleteLocations()`, and `pendingUploadCount()`.
14
+ * - `'invalidGeofence'` — a geofence passed to `addGeofences()` failed
15
+ * validation (empty/oversized id, or non-positive radius).
16
+ * - `'permissionDenied'` — location permission is missing. Thrown by
17
+ * `getCurrentLocation()`.
18
+ * - `'locationServicesDisabled'` — system location services are off. Thrown by
19
+ * `getCurrentLocation()`.
20
+ * - `'locationUnavailable'` — location is otherwise unavailable (e.g. Play
21
+ * Services absent/old). Thrown by `getCurrentLocation()`.
6
22
  */
7
23
 
8
24
  /**
9
- * Typed error surfaced from the bridge. The native module rejects promises
10
- * with the kind encoded as the error code; the facade re-wraps into this.
25
+ * Typed error surfaced from the bridge. The native module rejects promises with
26
+ * the kind encoded as the error code; the facade re-wraps into this.
11
27
  */
12
28
  export class BeekonError extends Error {
13
29
  constructor(kind, message) {
@@ -1 +1 @@
1
- {"version":3,"names":["BeekonError","Error","constructor","kind","message","name"],"sourceRoot":"../../../src","sources":["types/error.ts"],"mappings":";;AAAA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA,OAAO,MAAMA,WAAW,SAASC,KAAK,CAAC;EAGrCC,WAAWA,CAACC,IAAqB,EAAEC,OAAe,EAAE;IAClD,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,aAAa;IACzB,IAAI,CAACF,IAAI,GAAGA,IAAI;EAClB;AACF","ignoreList":[]}
1
+ {"version":3,"names":["BeekonError","Error","constructor","kind","message","name"],"sourceRoot":"../../../src","sources":["types/error.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA,OAAO,MAAMA,WAAW,SAASC,KAAK,CAAC;EAGrCC,WAAWA,CAACC,IAAqB,EAAEC,OAAe,EAAE;IAClD,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,aAAa;IACzB,IAAI,CAACF,IAAI,GAAGA,IAAI;EAClB;AACF","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=geofence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/geofence.ts"],"mappings":"","ignoreList":[]}
@@ -1,2 +1,4 @@
1
1
  "use strict";
2
+
3
+ export {};
2
4
  //# sourceMappingURL=location.js.map
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=sync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/sync.ts"],"mappings":"","ignoreList":[]}
@@ -1,53 +1,183 @@
1
1
  /**
2
- * Codegen TurboModule spec — DO NOT export Wire* types from `src/index.tsx`.
3
- * The public TS API in `src/beekon.ts` and `src/types/` is what consumers use;
4
- * mappers in `src/internal/mappers.ts` convert between the two.
2
+ * Codegen TurboModule spec — the single source React Native's Codegen reads to
3
+ * generate the native interface. **DO NOT export Wire* types from
4
+ * `src/index.tsx`.** The public TS API in `src/beekon.ts` and `src/types/` is
5
+ * what consumers use; mappers in `src/internal/mappers.ts` convert between the
6
+ * two.
5
7
  *
6
- * Wire types are flat (primitives + nested flat objects) because Codegen's
7
- * TS-to-Kotlin/ObjC type derivation has limited support for unions and
8
- * recursive structures. The state variants are encoded as a `type`
9
- * discriminator string with sibling fields nullable per variant.
8
+ * Wire types are deliberately **flat** (primitives + flat nested objects +
9
+ * arrays) because Codegen's TSKotlin/ObjC derivation has no support for unions
10
+ * or recursive structures:
11
+ *
12
+ * - **Enums travel as plain `string`** (e.g. `accuracyMode`, `quality`); the
13
+ * mappers translate to/from the public string-literal unions with a defensive
14
+ * fallback, so an unknown value never crashes a subscriber.
15
+ * - **Sum types** (`WireState`, `WireSyncStatus`) are a `type` discriminator
16
+ * string plus sibling fields nullable per variant.
17
+ * - **String maps** (`headers`, `extras`) travel as `WireKeyValue[]` pairs —
18
+ * Codegen has no portable dictionary type.
19
+ * - **Timestamps** are epoch-milliseconds; intervals are seconds.
10
20
  */
11
21
  import type { CodegenTypes, TurboModule } from 'react-native';
12
- export type WireAndroidNotification = {
22
+ /** A single string map entry — see `headers` / `setExtras`. */
23
+ export type WireKeyValue = {
24
+ key: string;
25
+ value: string;
26
+ };
27
+ /** Flat wire form of `AuthResponseMapping`. Omitted keys use common-name detection. */
28
+ export type WireAuthResponseMapping = {
29
+ accessToken?: string;
30
+ refreshToken?: string;
31
+ expiresIn?: string;
32
+ expiresAt?: string;
33
+ };
34
+ /**
35
+ * Flat wire form of `AuthConfig` on {@link WireSyncConfig.auth}. Enums travel as
36
+ * strings (`strategy`: 'bearer'|'raw'; `refreshBodyFormat`: 'form'|'json'),
37
+ * string maps as `WireKeyValue[]`, and `expiresAtMs` is epoch milliseconds.
38
+ */
39
+ export type WireAuthConfig = {
40
+ accessToken?: string;
41
+ refreshToken?: string;
42
+ expiresAtMs?: number;
43
+ strategy: string;
44
+ refreshUrl?: string;
45
+ refreshPayload: WireKeyValue[];
46
+ refreshHeaders: WireKeyValue[];
47
+ refreshBodyFormat: string;
48
+ responseMapping: WireAuthResponseMapping;
49
+ skewMarginSeconds: number;
50
+ seedEpoch?: number;
51
+ };
52
+ export type WireSyncConfig = {
53
+ url: string;
54
+ headers: WireKeyValue[];
55
+ intervalSeconds: number;
56
+ batchSize: number;
57
+ /** Token-refresh recipe; omitted keeps static-header auth. */
58
+ auth?: WireAuthConfig;
59
+ };
60
+ /** Android-only foreground-service notification overrides. iOS ignores it. */
61
+ export type WireNotificationConfig = {
13
62
  title?: string;
14
63
  text?: string;
15
- smallIconResName?: string;
64
+ smallIcon?: string;
16
65
  };
17
66
  export type WireConfig = {
18
- /** Required at the wire level — the TS facade applies defaults (30 / 100). */
19
- intervalSeconds: number;
20
- /** Required at the wire level — the TS facade applies defaults (30 / 100). */
21
- distanceMeters: number;
22
- /** Android-only. iOS native module ignores. */
23
- androidNotification?: WireAndroidNotification;
67
+ /** All fields required at the wire level — the TS facade applies defaults. */
68
+ minTimeBetweenLocationsSeconds: number;
69
+ minDistanceBetweenLocationsMeters: number;
70
+ /** One of: 'high' | 'balanced' | 'low'. */
71
+ accuracyMode: string;
72
+ /** One of: 'keepTracking' | 'pause' | 'pauseWithCheckIns'. */
73
+ whenStationary: string;
74
+ stationaryRadiusMeters: number;
75
+ detectActivity: boolean;
76
+ /** Omitted keeps tracking local-only. */
77
+ sync?: WireSyncConfig;
78
+ /** Android-only; the iOS native module ignores it. */
79
+ notification?: WireNotificationConfig;
24
80
  };
25
81
  export type WireLocation = {
82
+ id: string;
26
83
  lat: number;
27
84
  lng: number;
28
85
  timestampMs: number;
29
- /** `null` when the OS did not report a value (e.g. low-confidence fix). */
86
+ /** `null` when the OS did not report a value. */
30
87
  accuracy: number | null;
31
88
  speed: number | null;
32
89
  bearing: number | null;
33
90
  altitude: number | null;
91
+ /** One of: 'ok' | 'lowAccuracy' | 'implausibleSpeed'. */
92
+ quality: string;
93
+ /** One of: 'interval' | 'motion' | 'checkIn' | 'geofence' | 'manual'. */
94
+ trigger: string;
95
+ /** One of: 'moving' | 'stationary' | 'unknown'. */
96
+ motion: string;
97
+ /** Activity enum string, or `null` unless activity detection is enabled. */
98
+ activity: string | null;
99
+ isMock: boolean;
100
+ };
101
+ export type WireGeofence = {
102
+ id: string;
103
+ lat: number;
104
+ lng: number;
105
+ radiusMeters: number;
106
+ notifyOnEntry: boolean;
107
+ notifyOnExit: boolean;
108
+ };
109
+ export type WireGeofenceEvent = {
110
+ id: string;
111
+ geofenceId: string;
112
+ /** One of: 'enter' | 'exit'. */
113
+ type: string;
114
+ timestampMs: number;
34
115
  };
35
116
  export type WireState = {
36
117
  /** One of: 'idle' | 'tracking' | 'stopped'. */
37
118
  type: string;
38
119
  /**
39
- * Only populated when `type === 'stopped'`. One of:
40
- * 'user' | 'permissionDenied' | 'locationServicesDisabled' | 'system'.
120
+ * Only populated when `type === 'stopped'`. One of: 'user' |
121
+ * 'permissionDenied' | 'locationServicesDisabled' | 'locationUnavailable' |
122
+ * 'system'.
41
123
  */
42
124
  stopReason?: string;
43
125
  };
126
+ export type WireSyncStatus = {
127
+ /** One of: 'idle' | 'pending' | 'failed'. */
128
+ type: string;
129
+ /** Only populated when `type === 'failed'`. One of: 'auth' | 'rejected'. */
130
+ failure?: string;
131
+ };
132
+ /**
133
+ * A token set the SDK rotated, delivered on `onAuthTokens`. `expiresAtMs` is
134
+ * epoch milliseconds; both it and `refreshToken` are `null` when absent.
135
+ */
136
+ export type WireAuthTokens = {
137
+ accessToken: string;
138
+ refreshToken: string | null;
139
+ expiresAtMs: number | null;
140
+ epoch: number;
141
+ };
44
142
  export interface Spec extends TurboModule {
45
- configure(config: WireConfig): Promise<void>;
143
+ /**
144
+ * The config crosses as an untyped object (`ReadableMap` on Android,
145
+ * `NSDictionary` on iOS) and is parsed natively. Typing it as the nested
146
+ * {@link WireConfig} struct would force the iOS ObjC++ layer to walk Codegen's
147
+ * generated C++ structs; the facade still builds a `WireConfig`-shaped value
148
+ * via `configToWire`, so the shape is enforced upstream.
149
+ */
150
+ configure(config: CodegenTypes.UnsafeObject): Promise<void>;
46
151
  start(): Promise<void>;
47
152
  stop(): Promise<void>;
48
- history(fromMs: number, toMs: number): Promise<WireLocation[]>;
153
+ resumeIfNeeded(): Promise<void>;
154
+ /**
155
+ * One immediate fix. `accuracy` `''` uses the configured mode (a plain
156
+ * `string` rather than `string | null` for portable Codegen, matching
157
+ * `deleteLocations`). Resolves a 0- or 1-element array — empty means timeout /
158
+ * no fix — rather than a nullable struct, which Codegen does not portably
159
+ * support. Rejects with `PERMISSION_DENIED` / `LOCATION_SERVICES_DISABLED` /
160
+ * `LOCATION_UNAVAILABLE` on a precondition failure.
161
+ */
162
+ getCurrentLocation(timeoutMs: number, accuracy: string): Promise<WireLocation[]>;
163
+ getLocations(fromMs: number, toMs: number): Promise<WireLocation[]>;
164
+ /**
165
+ * A negative `beforeMs` deletes all stored locations (the wire encoding of
166
+ * the public `deleteLocations()` no-argument case). A plain `number` is used
167
+ * rather than `number | null` for portable Codegen support across platforms.
168
+ */
169
+ deleteLocations(beforeMs: number): Promise<number>;
170
+ pendingUploadCount(): Promise<number>;
171
+ sync(): Promise<void>;
172
+ setExtras(entries: WireKeyValue[]): Promise<void>;
173
+ addGeofences(geofences: WireGeofence[]): Promise<void>;
174
+ removeGeofences(ids: string[]): Promise<void>;
175
+ listGeofences(): Promise<WireGeofence[]>;
49
176
  readonly onState: CodegenTypes.EventEmitter<WireState>;
50
177
  readonly onLocation: CodegenTypes.EventEmitter<WireLocation>;
178
+ readonly onGeofenceEvent: CodegenTypes.EventEmitter<WireGeofenceEvent>;
179
+ readonly onSyncStatus: CodegenTypes.EventEmitter<WireSyncStatus>;
180
+ readonly onAuthTokens: CodegenTypes.EventEmitter<WireAuthTokens>;
51
181
  }
52
182
  declare const _default: Spec;
53
183
  export default _default;
@@ -1 +1 @@
1
- {"version":3,"file":"NativeBeekonRn.d.ts","sourceRoot":"","sources":["../../../src/NativeBeekonRn.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;A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,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC;IACpE;;;;OAIG;IACH,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACnD,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAEtC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,SAAS,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAElD,YAAY,CAAC,SAAS,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,aAAa,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC;IAEzC,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IACvD,QAAQ,CAAC,UAAU,EAAE,YAAY,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;IAC7D,QAAQ,CAAC,eAAe,EAAE,YAAY,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC;IACvE,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;IACjE,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;CAClE;;AAED,wBAAkE"}
@@ -1,66 +1,143 @@
1
+ import type { AuthTokens } from './types/auth';
1
2
  import type { BeekonConfig } from './types/config';
2
- import type { BeekonState } from './types/state';
3
+ import type { AccuracyMode } from './types/enums';
4
+ import type { BeekonGeofence, GeofenceEvent } from './types/geofence';
3
5
  import type { Location } from './types/location';
6
+ import type { BeekonState } from './types/state';
7
+ import type { SyncStatus } from './types/sync';
4
8
  /**
5
- * Public facade for the Beekon SDK. Mirrors the native APIs:
9
+ * Public facade for the Beekon SDK a 1:1 mirror of the native APIs:
6
10
  *
7
11
  * - Android: `in.wayq.beekon.Beekon` (object)
8
12
  * - iOS: `BeekonKit.Beekon.shared` (actor)
9
13
  *
10
- * Lifecycle: `configure(config)` `start()` ... `stop()` (idempotent).
11
- * Subscribe to `onState` / `onLocation` for live updates; query
12
- * `history(from, to)` for persisted fixes.
14
+ * There is **no `initialize()`** the native SDKs auto-initialize. Lifecycle:
15
+ * `configure(config)` (optional; defaults 30s / 100m) → `start()`
16
+ * `stop()`. `start()` / `stop()` **never throw** — `onState` is the single
17
+ * source of truth for whether tracking is active and why it stopped.
13
18
  *
14
- * **Threading:** Methods are safe to call from any JS context. Subscribers'
19
+ * **Threading:** methods are safe to call from any JS context; subscriber
15
20
  * callbacks fire on the JS thread.
16
21
  *
17
- * **Persistence invariant:** the SDK persists every gated fix natively; JS is
18
- * a passive observer. In background, the JS engine is not guaranteed to be
19
- * alive — for past fixes, use `history()`.
22
+ * **Persistence invariant:** the SDK persists every gated fix natively; JS is a
23
+ * passive observer that is not guaranteed to be alive in the background. For
24
+ * past fixes use `getLocations()`.
20
25
  */
21
26
  declare class BeekonImpl {
27
+ private readonly hub;
22
28
  /**
23
29
  * Set tracking parameters. Optional — `start()` falls back to the previously
24
- * persisted config or the SDK default (30s / 100m) if never configured.
25
- *
26
- * While tracking, the new gate values take effect on the next admitted fix
27
- * without restarting the underlying location subscription.
30
+ * persisted config, or the SDK defaults if never configured. While tracking,
31
+ * gate thresholds take effect on the next admitted fix without restarting the
32
+ * location subscription; `accuracyMode` applies on the next `start()`.
28
33
  */
29
34
  configure(config: BeekonConfig): Promise<void>;
30
35
  /**
31
- * Begin tracking. State transitions to `tracking`.
32
- *
33
- * Throws a `BeekonError` with kind:
34
- * - `'permissionDenied'` — location permission not granted.
35
- * - `'locationServicesDisabled'` — system location services off (or GMS
36
- * unavailable on Android).
36
+ * Begin tracking. Never throws observe `onState` for the outcome
37
+ * (`stopped(reason)` on a permission / services / system problem). Beekon
38
+ * ships no permission API: request permissions in the host app, then observe
39
+ * `onState`.
37
40
  */
38
41
  start(): Promise<void>;
39
- /** Stop tracking. Idempotent. State transitions to `stopped(user)`. */
42
+ /** Stop tracking. Idempotent. Registered geofences keep firing. */
40
43
  stop(): Promise<void>;
41
44
  /**
42
- * Read persisted fixes in the time range [from, to]. Returns fixes in
43
- * chronological order. Reads come from the SDK's local storage (Room on
44
- * Android, GRDB on iOS) — the source of truth even when JS was asleep.
45
+ * Resume tracking if a session was active before the app was terminated. A
46
+ * no-op if the user explicitly stopped. Call early in app startup.
47
+ *
48
+ * Note: on a background relaunch the JS engine may not be running, so true
49
+ * cold-launch resume also requires native host wiring (Android: call
50
+ * `Beekon.start()` from `Application.onCreate`; iOS: `registerBackgroundTasks`
51
+ * in the AppDelegate). See the README.
52
+ */
53
+ resumeIfNeeded(): Promise<void>;
54
+ /**
55
+ * Return a single fresh fix on demand — for the moment a host needs an
56
+ * immediate position (e.g. the instant a trip starts).
45
57
  *
46
- * Retention: fixes older than 7 days OR beyond the most recent 100K are
47
- * pruned automatically.
58
+ * Independent of tracking: works whether or not a session is running and never
59
+ * starts, stops, or disturbs one. The fix is not persisted and does not appear
60
+ * on `onLocation` — it is returned here only, tagged `'manual'`.
48
61
  *
49
- * Throws `BeekonError` with kind `'storageFailure'` on database read failure.
62
+ * Resolves `null` if no usable fix arrives within `timeoutMs` (default
63
+ * 15000). `accuracy` overrides the configured mode for this call only;
64
+ * omitted uses the configured mode.
65
+ *
66
+ * Throws `BeekonError` with kind `'permissionDenied'`,
67
+ * `'locationServicesDisabled'`, or `'locationUnavailable'` on a precondition
68
+ * failure.
69
+ */
70
+ getCurrentLocation(options?: {
71
+ timeoutMs?: number;
72
+ accuracy?: AccuracyMode;
73
+ }): Promise<Location | null>;
74
+ /**
75
+ * Read persisted fixes in the inclusive range `[from, to]`, oldest first.
76
+ * Reads come from the SDK's local storage (Room on Android, GRDB on iOS) — the
77
+ * source of truth even when JS was asleep. With sync enabled, rows are deleted
78
+ * locally once the server accepts them, so this returns only un-uploaded fixes.
79
+ *
80
+ * Throws `BeekonError` with kind `'storage'` on a database read failure.
81
+ */
82
+ getLocations(from: Date, to: Date): Promise<Location[]>;
83
+ /**
84
+ * Delete stored locations captured before `before` (all of them when
85
+ * `before` is omitted). Returns the number of rows removed. Throws
86
+ * `BeekonError` with kind `'storage'` on a failure.
50
87
  */
51
- history(from: Date, to: Date): Promise<Location[]>;
88
+ deleteLocations(before?: Date): Promise<number>;
52
89
  /**
53
- * Subscribe to state transitions. Returns an unsubscribe function. The
54
- * current state is delivered to new subscribers immediately (replay-1
55
- * semantics, matching the native `state` flow / AsyncStream).
90
+ * The number of stored locations not yet uploaded. Throws `BeekonError` with
91
+ * kind `'storage'` on a failure.
92
+ */
93
+ pendingUploadCount(): Promise<number>;
94
+ /**
95
+ * Request an immediate upload. Best-effort and self-retrying; a no-op when
96
+ * sync is not configured.
97
+ */
98
+ sync(): Promise<void>;
99
+ /** Set custom key/value fields (e.g. `user_id`) included with every upload. */
100
+ setExtras(extras: Record<string, string>): Promise<void>;
101
+ /**
102
+ * Register geofences. Re-adding an `id` replaces the existing one. Throws
103
+ * `BeekonError` with kind `'invalidGeofence'` if any entry fails validation —
104
+ * none are added when one is invalid.
105
+ */
106
+ addGeofences(geofences: BeekonGeofence[]): Promise<void>;
107
+ /** Unregister geofences by id. Unknown ids are ignored. */
108
+ removeGeofences(ids: string[]): Promise<void>;
109
+ /** The currently registered geofences. */
110
+ listGeofences(): Promise<BeekonGeofence[]>;
111
+ /**
112
+ * Subscribe to tracking-state transitions (`idle` / `tracking` /
113
+ * `stopped(reason)`). The current state is delivered to new subscribers
114
+ * immediately (replay-1). Returns an unsubscribe function.
56
115
  */
57
116
  onState(cb: (s: BeekonState) => void): () => void;
58
117
  /**
59
- * Subscribe to gated locations as they arrive. Returns an unsubscribe
60
- * function. Broadcast (no replay) only delivers while the JS engine is
61
- * alive. For fixes emitted while JS was asleep, use `history()`.
118
+ * Subscribe to gated locations as they arrive. Broadcast (no replay) — only
119
+ * delivers while the JS engine is alive. For fixes emitted while JS was
120
+ * asleep, use `getLocations()`. Returns an unsubscribe function.
62
121
  */
63
122
  onLocation(cb: (l: Location) => void): () => void;
123
+ /**
124
+ * Subscribe to geofence enter / exit crossings. Broadcast (no replay).
125
+ * Returns an unsubscribe function.
126
+ */
127
+ onGeofenceEvent(cb: (e: GeofenceEvent) => void): () => void;
128
+ /**
129
+ * Subscribe to upload health (`idle` / `pending` / `failed(reason)`). The
130
+ * current status is delivered to new subscribers immediately (replay-1).
131
+ * Returns an unsubscribe function.
132
+ */
133
+ onSyncStatus(cb: (s: SyncStatus) => void): () => void;
134
+ /**
135
+ * Subscribe to token rotations the SDK performed during a native refresh (see
136
+ * `SyncConfig.auth`). Mirror them into your own session store. The latest
137
+ * rotation is delivered to new subscribers immediately (replay-1). Sensitive —
138
+ * delivered in-process only, never logged. Returns an unsubscribe function.
139
+ */
140
+ onAuthTokens(cb: (t: AuthTokens) => void): () => void;
64
141
  }
65
142
  export declare const Beekon: BeekonImpl;
66
143
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"beekon.d.ts","sourceRoot":"","sources":["../../../src/beekon.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAQjD;;;;;;;;;;;;;;;;GAgBG;AACH,cAAM,UAAU;IACd;;;;;;OAMG;IACG,SAAS,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAQpD;;;;;;;OAOG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ5B,uEAAuE;IACjE,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ3B;;;;;;;;;OASG;IACG,OA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E,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,GAAG,MAAM,IAAI;CAGtD;AAED,eAAO,MAAM,MAAM,YAAmB,CAAC"}
@@ -1,6 +1,10 @@
1
1
  export { Beekon } from './beekon';
2
- export type { BeekonConfig, AndroidNotificationConfig } from './types/config';
3
- export type { BeekonState, StopReason } from './types/state';
2
+ export type { BeekonConfig, SyncConfig, NotificationConfig, } from './types/config';
3
+ export type { AccuracyMode, StationaryMode, LocationTrigger, LocationQuality, MotionState, ActivityType, AuthStrategy, AuthBodyFormat, } from './types/enums';
4
+ export type { AuthConfig, AuthResponseMapping, AuthTokens } from './types/auth';
4
5
  export type { Location } from './types/location';
6
+ export type { BeekonGeofence, GeofenceEvent, Transition, } from './types/geofence';
7
+ export type { BeekonState, StopReason } from './types/state';
8
+ export type { SyncStatus, SyncFailure } from './types/sync';
5
9
  export { BeekonError, type BeekonErrorKind } from './types/error';
6
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,YAAY,EAAE,YAAY,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAC9E,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC7D,YAAY,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,YAAY,EACV,YAAY,EACZ,UAAU,EACV,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,YAAY,EACZ,cAAc,EACd,eAAe,EACf,eAAe,EACf,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,cAAc,GACf,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,UAAU,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAChF,YAAY,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,YAAY,EACV,cAAc,EACd,aAAa,EACb,UAAU,GACX,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC7D,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC"}
@@ -1,15 +1,25 @@
1
+ import type { AuthConfig, AuthTokens } from '../types/auth';
1
2
  import type { BeekonConfig } from '../types/config';
2
- import type { BeekonState } from '../types/state';
3
+ import type { BeekonGeofence, GeofenceEvent } from '../types/geofence';
3
4
  import type { Location } from '../types/location';
4
- import type { WireConfig, WireLocation, WireState } from '../NativeBeekonRn';
5
+ import type { BeekonState } from '../types/state';
6
+ import type { SyncStatus } from '../types/sync';
7
+ import type { WireAuthConfig, WireAuthTokens, WireConfig, WireGeofence, WireGeofenceEvent, WireKeyValue, WireLocation, WireState, WireSyncStatus } from '../NativeBeekonRn';
8
+ export declare function recordToEntries(record: Record<string, string> | undefined): WireKeyValue[];
5
9
  export declare function configToWire(config: BeekonConfig): WireConfig;
10
+ export declare function geofenceToWire(g: BeekonGeofence): WireGeofence;
11
+ export declare function authToWire(a: AuthConfig): WireAuthConfig;
6
12
  export declare function wireToLocation(w: WireLocation): Location;
13
+ export declare function wireToGeofence(w: WireGeofence): BeekonGeofence;
14
+ export declare function wireToGeofenceEvent(w: WireGeofenceEvent): GeofenceEvent;
7
15
  export declare function wireToState(w: WireState): BeekonState;
16
+ export declare function wireToSyncStatus(w: WireSyncStatus): SyncStatus;
17
+ /** `expiresAtMs` (epoch millis) becomes a `Date`; `null` propagates faithfully. */
18
+ export declare function wireToAuthTokens(w: WireAuthTokens): AuthTokens;
8
19
  /**
9
- * Re-throw a native promise rejection as a typed `BeekonError`. Native modules
10
- * encode the kind in the error code string (`PERMISSION_DENIED`,
11
- * `LOCATION_SERVICES_DISABLED`, `STORAGE_FAILURE`); anything else falls
12
- * through as the original error.
20
+ * Re-throw a native promise rejection as a typed {@link BeekonError}. The native
21
+ * modules encode the kind in the error-code string (`STORAGE_FAILURE`,
22
+ * `INVALID_GEOFENCE`); anything else falls through as the original error.
13
23
  */
14
24
  export declare function rethrowAsBeekonError(e: unknown): never;
15
25
  //# sourceMappingURL=mappers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mappers.d.ts","sourceRoot":"","sources":["../../../../src/internal/mappers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAc,MAAM,gBAAgB,CAAC;AAC9D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAK7E,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,UAAU,CAM7D;AAED,wBAAgB,cAAc,CAAC,CAAC,EAAE,YAAY,GAAG,QAAQ,CAUxD;AAeD,wBAAgB,WAAW,CAAC,CAAC,EAAE,SAAS,GAAG,WAAW,CAYrD;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,OAAO,GAAG,KAAK,CAQtD"}
1
+ {"version":3,"file":"mappers.d.ts","sourceRoot":"","sources":["../../../../src/internal/mappers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAA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'./enums';
2
+ /**
3
+ * Where the SDK reads rotated tokens from the JSON response to a refresh
4
+ * request. Mirrors the native `AuthResponseMapping` (iOS) / `ResponseMapping`
5
+ * (Android).
6
+ *
7
+ * Each value is a response key. An omitted field falls back to common-name
8
+ * detection: `access_token`/`accessToken`/`token` for the access token,
9
+ * `refresh_token`/`refreshToken` for a rotated refresh token, and `expires_in`
10
+ * (relative seconds) or `expires_at`/`expires` (absolute epoch seconds) for the
11
+ * expiry. The default (all-omitted) is pure common-name detection.
12
+ */
13
+ export type AuthResponseMapping = {
14
+ /** Response key holding the new access token. Omitted uses common-name detection. */
15
+ accessToken?: string;
16
+ /** Response key holding a rotated refresh token. Omitted uses common-name detection. */
17
+ refreshToken?: string;
18
+ /** Response key holding a relative lifetime in seconds. Omitted uses detection. */
19
+ expiresIn?: string;
20
+ /** Response key holding an absolute expiry in epoch seconds. Omitted uses detection. */
21
+ expiresAt?: string;
22
+ };
23
+ /**
24
+ * Declarative recipe for native token refresh, set on `SyncConfig.auth`.
25
+ * Mirrors the native `AuthConfig`.
26
+ *
27
+ * When present, the SDK attaches the access token to every upload (per
28
+ * {@link AuthConfig.strategy}), refreshes it **proactively** before
29
+ * {@link AuthConfig.expiresAt} and **reactively** on a `401`/`403`, then retries
30
+ * the upload — all natively, so it works in the background and on a cold launch
31
+ * with no host involvement. Omit {@link AuthConfig.refreshUrl} to disable
32
+ * refresh and keep the legacy behaviour (a `401`/`403` pauses sync and surfaces
33
+ * `SyncFailure 'auth'`).
34
+ *
35
+ * **Tokens are a seed, not config.** {@link AuthConfig.accessToken},
36
+ * {@link AuthConfig.refreshToken} and {@link AuthConfig.expiresAt} are supplied
37
+ * once; the SDK then owns and rotates the live token set in secure storage
38
+ * (Keychain / encrypted prefs). Observe rotations via `Beekon.onAuthTokens()` to
39
+ * mirror the tokens into your own session store.
40
+ *
41
+ * Requires the native SDK ≥ 0.0.6; with an older native binary the recipe is
42
+ * ignored and only static `SyncConfig.headers` apply.
43
+ */
44
+ export type AuthConfig = {
45
+ /** Initial access token. A seed: the SDK owns and rotates it after first persist. */
46
+ accessToken?: string;
47
+ /** Initial refresh token POSTed to {@link AuthConfig.refreshUrl}. A seed. */
48
+ refreshToken?: string;
49
+ /** Absolute expiry of {@link AuthConfig.accessToken}. Omitted disables proactive refresh. */
50
+ expiresAt?: Date;
51
+ /** How the access token is attached. Default: `'bearer'`. */
52
+ strategy?: AuthStrategy;
53
+ /** Authorization server's refresh endpoint. Omitted disables refresh. */
54
+ refreshUrl?: string;
55
+ /**
56
+ * Form fields POSTed to {@link AuthConfig.refreshUrl}. A value containing
57
+ * `{refreshToken}` is substituted with the current refresh token. Default: empty.
58
+ */
59
+ refreshPayload?: Record<string, string>;
60
+ /**
61
+ * Headers sent on the refresh request. A value containing `{accessToken}` is
62
+ * substituted with the current access token. Default:
63
+ * `{ Authorization: 'Bearer {accessToken}' }`.
64
+ */
65
+ refreshHeaders?: Record<string, string>;
66
+ /** Encoding of the refresh request body. Default: `'form'`. */
67
+ refreshBodyFormat?: AuthBodyFormat;
68
+ /** Where to read rotated tokens from the refresh response. Default: detection. */
69
+ responseMapping?: AuthResponseMapping;
70
+ /** Seconds before {@link AuthConfig.expiresAt} at which a proactive refresh fires. Default: `60`. */
71
+ skewMarginSeconds?: number;
72
+ /**
73
+ * Optional monotonic re-seed signal. When greater than the SDK's stored epoch,
74
+ * a re-supplied seed replaces the rotated token set (e.g. after the user
75
+ * re-authenticates). Omitted adopts a re-supplied seed only when no token has
76
+ * been stored yet.
77
+ */
78
+ seedEpoch?: number;
79
+ };
80
+ /**
81
+ * A token set the SDK rotated, delivered via `Beekon.onAuthTokens()`. Mirrors
82
+ * the native `AuthTokens` (iOS) / `TokenRefresh` (Android).
83
+ *
84
+ * Treat these as sensitive: they are delivered in-process only and are never
85
+ * logged or persisted to plaintext. Use them to mirror the SDK's current
86
+ * credentials into your own session store. The latest rotation is replayed to
87
+ * new subscribers (replay-1).
88
+ */
89
+ export type AuthTokens = {
90
+ /** The rotated access token now in use. */
91
+ accessToken: string;
92
+ /** The current refresh token (rotated if the server returned a new one), or `null`. */
93
+ refreshToken: string | null;
94
+ /** Absolute expiry of {@link AuthTokens.accessToken}, or `null` if the response carried none. */
95
+ expiresAt: Date | null;
96
+ /** The SDK's monotonic token generation, incremented on each successful refresh. */
97
+ epoch: number;
98
+ };
99
+ //# sourceMappingURL=auth.d.ts.map