@wayq/beekon-rn 0.0.7 → 0.0.9

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 (63) hide show
  1. package/BeekonRn.podspec +1 -1
  2. package/CHANGELOG.md +43 -0
  3. package/README.md +67 -5
  4. package/android/build.gradle +3 -2
  5. package/android/src/main/java/in/wayq/beekonrn/BeekonRnModule.kt +106 -8
  6. package/ios/BeekonRn.mm +35 -0
  7. package/ios/BeekonRn.swift +140 -8
  8. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64/BeekonKit.framework/BeekonKit +0 -0
  9. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64/BeekonKit.framework/Info.plist +0 -0
  10. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64/BeekonKit.framework/Modules/BeekonKit.swiftmodule/arm64-apple-ios.abi.json +6048 -3656
  11. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64/BeekonKit.framework/Modules/BeekonKit.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  12. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64/BeekonKit.framework/Modules/BeekonKit.swiftmodule/arm64-apple-ios.swiftinterface +95 -18
  13. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/BeekonKit +0 -0
  14. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/Info.plist +0 -0
  15. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/Modules/BeekonKit.swiftmodule/arm64-apple-ios-simulator.abi.json +6048 -3656
  16. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/Modules/BeekonKit.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  17. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/Modules/BeekonKit.swiftmodule/arm64-apple-ios-simulator.swiftinterface +95 -18
  18. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/Modules/BeekonKit.swiftmodule/x86_64-apple-ios-simulator.abi.json +6048 -3656
  19. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/Modules/BeekonKit.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  20. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/Modules/BeekonKit.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +95 -18
  21. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/_CodeSignature/CodeResources +1 -1
  22. package/lib/module/NativeBeekonRn.js.map +1 -1
  23. package/lib/module/beekon.js +97 -1
  24. package/lib/module/beekon.js.map +1 -1
  25. package/lib/module/index.js +4 -0
  26. package/lib/module/index.js.map +1 -1
  27. package/lib/module/internal/licenseNudge.js +64 -0
  28. package/lib/module/internal/licenseNudge.js.map +1 -0
  29. package/lib/module/internal/mappers.js +56 -8
  30. package/lib/module/internal/mappers.js.map +1 -1
  31. package/lib/module/types/config.js +73 -1
  32. package/lib/module/types/config.js.map +1 -1
  33. package/lib/module/types/log.js +4 -0
  34. package/lib/module/types/log.js.map +1 -0
  35. package/lib/typescript/src/NativeBeekonRn.d.ts +47 -2
  36. package/lib/typescript/src/NativeBeekonRn.d.ts.map +1 -1
  37. package/lib/typescript/src/beekon.d.ts +46 -1
  38. package/lib/typescript/src/beekon.d.ts.map +1 -1
  39. package/lib/typescript/src/index.d.ts +4 -2
  40. package/lib/typescript/src/index.d.ts.map +1 -1
  41. package/lib/typescript/src/internal/licenseNudge.d.ts +38 -0
  42. package/lib/typescript/src/internal/licenseNudge.d.ts.map +1 -0
  43. package/lib/typescript/src/internal/mappers.d.ts +3 -1
  44. package/lib/typescript/src/internal/mappers.d.ts.map +1 -1
  45. package/lib/typescript/src/types/config.d.ts +90 -7
  46. package/lib/typescript/src/types/config.d.ts.map +1 -1
  47. package/lib/typescript/src/types/enums.d.ts +8 -0
  48. package/lib/typescript/src/types/enums.d.ts.map +1 -1
  49. package/lib/typescript/src/types/log.d.ts +22 -0
  50. package/lib/typescript/src/types/log.d.ts.map +1 -0
  51. package/lib/typescript/src/types/state.d.ts +4 -1
  52. package/lib/typescript/src/types/state.d.ts.map +1 -1
  53. package/package.json +1 -1
  54. package/scripts/fetch-beekonkit.sh +4 -4
  55. package/src/NativeBeekonRn.ts +49 -2
  56. package/src/beekon.ts +100 -1
  57. package/src/index.tsx +7 -1
  58. package/src/internal/licenseNudge.ts +80 -0
  59. package/src/internal/mappers.ts +67 -7
  60. package/src/types/config.ts +99 -7
  61. package/src/types/enums.ts +9 -0
  62. package/src/types/log.ts +22 -0
  63. package/src/types/state.ts +4 -0
@@ -1,5 +1,5 @@
1
1
  import type { AuthConfig } from './auth';
2
- import type { AccuracyMode, StationaryMode } from './enums';
2
+ import type { AccuracyMode, LogLevel, StationaryMode } from './enums';
3
3
 
4
4
  /**
5
5
  * Foreground-service notification overrides. **Android-only** — the platform
@@ -23,8 +23,8 @@ export type NotificationConfig = {
23
23
  };
24
24
 
25
25
  /**
26
- * Server-upload configuration. Presence of {@link BeekonConfig.sync} turns on
27
- * batched uploads of stored locations and geofence events; omitting it keeps
26
+ * Server-upload configuration. Presence of {@link SelfManagedConfig.sync} turns
27
+ * on batched uploads of stored locations and geofence events; omitting it keeps
28
28
  * tracking local-only.
29
29
  */
30
30
  export type SyncConfig = {
@@ -39,6 +39,15 @@ export type SyncConfig = {
39
39
  intervalSeconds?: number;
40
40
  /** Maximum locations per upload. Clamped to `[1, 1000]`. Default: `100`. */
41
41
  batchSize?: number;
42
+ /**
43
+ * Pending-fix count that triggers an early upload of regular fixes, ahead of
44
+ * the {@link SyncConfig.intervalSeconds} schedule (not subject to the Android
45
+ * ~15 min floor). `0` (the default) leaves regular fixes to the schedule.
46
+ * Negative values are treated as `0`. Independent of this setting, a geofence
47
+ * event and a session stop with pending fixes always flush immediately while
48
+ * sync is configured. Requires the native SDK ≥ 0.0.9. Default: `0`.
49
+ */
50
+ syncThreshold?: number;
42
51
  /**
43
52
  * Declarative token-refresh recipe. When set, the SDK attaches and natively
44
53
  * refreshes the access token (proactively before expiry, reactively on
@@ -49,15 +58,58 @@ export type SyncConfig = {
49
58
  };
50
59
 
51
60
  /**
52
- * Tracking configuration. Every field is optional — `Beekon.start()` falls back
53
- * to the previously persisted config, or to the documented defaults below if
54
- * never configured.
61
+ * **Cloud-mode** configuration (cloud-mode-v1 §2). Point the SDK at Beekon
62
+ * Cloud (or a self-hosted Beekon backend) with a project key; the **server**
63
+ * owns the tracking parameters, sync cadence, geofences, and the license. This
64
+ * arm therefore exposes **only** the project credential, an optional endpoint
65
+ * override, the platform-universal Android `notification`, and `logLevel` — it
66
+ * deliberately does NOT expose tracking params, `sync`, or `licenseKey` (those
67
+ * are server-owned or derived).
68
+ */
69
+ export type CloudConfig = {
70
+ /** Arm discriminator — selects cloud mode. */
71
+ mode: 'cloud';
72
+ /**
73
+ * Opaque project credential (prefix `bkproj_`). A **bearer secret** on a
74
+ * separate credential plane from the license token — do **not** commit it to
75
+ * source control. Surrounding whitespace is trimmed and an empty key is
76
+ * rejected natively.
77
+ */
78
+ projectKey: string;
79
+ /**
80
+ * Base URL of the Beekon backend. Omit for Beekon Cloud (the SDK uses the
81
+ * baked-in `https://api.getbeekon.com`); set it to a self-hosted Beekon
82
+ * backend's base URL (the `/v1/token`, `/v1/config`, `/v1/ingest` suffixes
83
+ * are derived). Default: unset (`https://api.getbeekon.com`).
84
+ */
85
+ endpoint?: string;
86
+ /** Android-only notification overrides. Ignored on iOS. */
87
+ notification?: NotificationConfig;
88
+ /**
89
+ * Diagnostic log verbosity threshold. See {@link SelfManagedConfig.logLevel}.
90
+ * Default: `'info'`.
91
+ */
92
+ logLevel?: LogLevel;
93
+ };
94
+
95
+ /**
96
+ * **Self-managed** configuration (cloud-mode-v1 §2 / self-managed-mode-v1).
97
+ * The app owns all configuration locally — tracking parameters, an optional
98
+ * `sync` (omit ⇒ local-only; set ⇒ custom-backend ingest), an optional
99
+ * `licenseKey`, plus `notification` and `logLevel`. This is the pre-cloud
100
+ * behaviour.
101
+ *
102
+ * Every field other than `mode` is optional — `Beekon.start()` falls back to
103
+ * the previously persisted config, or to the documented defaults below if never
104
+ * configured.
55
105
  *
56
106
  * The two gate knobs (`minTimeBetweenLocationsSeconds`,
57
107
  * `minDistanceBetweenLocationsMeters`) admit a fix only when **both** are
58
108
  * satisfied; pass `0` to disable a gate.
59
109
  */
60
- export type BeekonConfig = {
110
+ export type SelfManagedConfig = {
111
+ /** Arm discriminator — selects self-managed mode. */
112
+ mode: 'selfManaged';
61
113
  /** Minimum seconds between admitted fixes (10s floor). Default: `30`. */
62
114
  minTimeBetweenLocationsSeconds?: number;
63
115
  /** Minimum metres between admitted fixes. `0` disables it. Default: `100`. */
@@ -91,4 +143,44 @@ export type BeekonConfig = {
91
143
  * useless to anyone else. Default: unset.
92
144
  */
93
145
  licenseKey?: string;
146
+ /**
147
+ * Diagnostic log verbosity threshold. Entries at or below this level are
148
+ * recorded to the persisted ring buffer and {@link Beekon.onLog}. `'info'`
149
+ * (the default) keeps coordinates out of the buffer — they appear only at
150
+ * `'debug'`/`'verbose'`. Change at runtime with {@link Beekon.setLogLevel}.
151
+ * Requires the native SDK ≥ 0.0.9. Default: `'info'`.
152
+ */
153
+ logLevel?: LogLevel;
94
154
  };
155
+
156
+ /**
157
+ * Tracking configuration. A **sealed two-arm** discriminated union (cloud-mode-v1
158
+ * §2): the `mode` tag selects {@link CloudConfig} (server-owned config) or
159
+ * {@link SelfManagedConfig} (app-owned config). Each arm exposes only that arm's
160
+ * fields — the cloud arm cannot carry tracking params / sync / a license key.
161
+ *
162
+ * Build a value with the {@link BeekonConfig.cloud} / {@link BeekonConfig.selfManaged}
163
+ * factories, or with a plain object literal that includes the `mode` tag.
164
+ */
165
+ export type BeekonConfig = CloudConfig | SelfManagedConfig;
166
+
167
+ /**
168
+ * Factory helpers mirroring the native sealed-type constructors
169
+ * (`BeekonConfig.cloud(...)` / `BeekonConfig.selfManaged(...)`). They stamp the
170
+ * `mode` discriminator so each call site can express only its arm's fields.
171
+ *
172
+ * Merged with the {@link BeekonConfig} type so `BeekonConfig` is usable as both
173
+ * a type and a value.
174
+ */
175
+ export const BeekonConfig = {
176
+ /** Build a {@link CloudConfig}. `projectKey` is required. */
177
+ cloud(options: Omit<CloudConfig, 'mode'>): CloudConfig {
178
+ return { mode: 'cloud', ...options };
179
+ },
180
+ /** Build a {@link SelfManagedConfig}. Every field is optional. */
181
+ selfManaged(
182
+ options: Omit<SelfManagedConfig, 'mode'> = {}
183
+ ): SelfManagedConfig {
184
+ return { mode: 'selfManaged', ...options };
185
+ },
186
+ } as const;
@@ -78,3 +78,12 @@ export type AuthStrategy = 'bearer' | 'raw';
78
78
  * - `'json'` — `application/json`.
79
79
  */
80
80
  export type AuthBodyFormat = 'form' | 'json';
81
+
82
+ /**
83
+ * Diagnostic log verbosity threshold. Ordered by increasing verbosity; an entry
84
+ * is recorded only when its level is at or below the active threshold
85
+ * ({@link BeekonConfig.logLevel} or {@link Beekon.setLogLevel}). The default is
86
+ * `'info'`, so coordinates (logged only at `'debug'`/`'verbose'`) stay out of the
87
+ * buffer. Mirrors the native `LogLevel`; see `spec/diagnostics/log-format-v1`.
88
+ */
89
+ export type LogLevel = 'off' | 'error' | 'warn' | 'info' | 'debug' | 'verbose';
@@ -0,0 +1,22 @@
1
+ import type { LogLevel } from './enums';
2
+
3
+ /**
4
+ * A single diagnostic log record from the Beekon SDK.
5
+ *
6
+ * Delivered live on {@link Beekon.onLog} and read back from the persisted ring
7
+ * buffer via {@link Beekon.getLog}. Entries survive process death — the point of
8
+ * the buffer is post-hoc field diagnosis. Mirrors the native `LogEntry`; see
9
+ * `spec/diagnostics/log-format-v1`.
10
+ */
11
+ export type LogEntry = {
12
+ /** UUIDv7 — orders and dedups entries. */
13
+ id: string;
14
+ /** When the entry was recorded. */
15
+ timestamp: Date;
16
+ /** Severity. Always one of `'error'`…`'verbose'`. */
17
+ level: LogLevel;
18
+ /** Originating subsystem (e.g. `'location'`, `'sync'`); host breadcrumbs use `'app'`. */
19
+ category: string;
20
+ /** Human-readable, already-redacted text. */
21
+ message: string;
22
+ };
@@ -8,6 +8,9 @@
8
8
  * (user-fixable in Settings).
9
9
  * - `'locationUnavailable'` — no usable location backend on this device (e.g.
10
10
  * Google Play Services absent/outdated on Android). Not user-fixable.
11
+ * - `'cloudModeUnavailable'` — the SDK was configured for cloud mode but the
12
+ * running build cannot operate it (cloud-mode-v1). Not user-fixable; switch to
13
+ * a self-managed config or a cloud-capable SDK build.
11
14
  * - `'system'` — the OS terminated tracking (e.g. foreground-service kill,
12
15
  * or an unrecoverable internal error).
13
16
  */
@@ -16,6 +19,7 @@ export type StopReason =
16
19
  | 'permissionDenied'
17
20
  | 'locationServicesDisabled'
18
21
  | 'locationUnavailable'
22
+ | 'cloudModeUnavailable'
19
23
  | 'system';
20
24
 
21
25
  /**