@transistorsoft/background-geolocation-types 5.0.0-beta.1 → 5.0.0-beta.3

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.
@@ -0,0 +1,124 @@
1
+ import type { Config } from '../config/Config';
2
+ /**
3
+ * Represents an authorization token issued by a Transistorsoft Tracking Server.
4
+ *
5
+ * Returned from {@link TransistorAuthorizationService.findOrCreate} and consumed by
6
+ * `Config.authorization` / `transistorAuthorizationToken` flows.
7
+ *
8
+ * @category Demo / Debug Server
9
+ */
10
+ export interface TransistorAuthorizationToken {
11
+ /** JWT access token used for `Authorization: Bearer <token>`. */
12
+ accessToken: string;
13
+ /** JWT refresh token used at the `refreshUrl` endpoint. */
14
+ refreshToken: string;
15
+ /**
16
+ * Expiry time of the access token (epoch milliseconds).
17
+ * Typically used to drive {@link AuthorizationConfig.expires}.
18
+ */
19
+ expires: number;
20
+ /** Base tracker server URL that issued this token. */
21
+ url: string;
22
+ }
23
+ /**
24
+ * Transistor Software hosts a demo server at [tracker.transistorsoft.com](http://tracker.transistorsoft.com) which is
25
+ * designed to consume location data from devices running the Background Geolocation SDK.
26
+ *
27
+ * You may also run your own instance of Demo Server locally. See [background-geolocation-console](https://github.com/transistorsoft/background-geolocation-console)
28
+ *
29
+ * The test server is a great way to debug location problems or evalute the SDK's behaviour, since the results can easily
30
+ * be shared with *Transistor Software* when requesting support.
31
+ *
32
+ * ![](https://dl.dropboxusercontent.com/s/3abuyyhioyypk8c/screenshot-tracker-transistorsoft.png?dl=1)
33
+ *
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * // Url to demo server.
38
+ * const url = "http://tracker.transistorsoft.com";
39
+ * const orgname = "my-company-name";
40
+ * const username = "my-username";
41
+ *
42
+ * // Fetch an authoriztion token from server. The SDK will cache the received token.
43
+ * const token = await
44
+ * BackgroundGeolocation.findOrCreateTransistorAuthorizationToken(orgname, username, url);
45
+ *
46
+ * BackgroundGeolocation.ready({
47
+ * transistorAuthorizationToken: token
48
+ * })
49
+ * ```
50
+ *
51
+ * __Viewing Your Tracking Results__
52
+ *
53
+ * To *view* your tracking results in the browser, use your configured "Organization Name" and visit:
54
+ *
55
+ * http://tracker.transistorsoft.com/my-organization-name
56
+ *
57
+ * @category Demo / Debug Server
58
+ */
59
+ export interface TransistorAuthorizationService {
60
+ /**
61
+ * Find or create a token for the given organization and username.
62
+ *
63
+ * @param orgName - Organization / company identifier.
64
+ * @param username - Username or device label.
65
+ * @param url - Optional tracker base URL. Defaults to the SDK's built‑in value.
66
+ *
67
+ * @returns A Promise resolving with a {@link TransistorAuthorizationToken} instance.
68
+ *
69
+ * @example
70
+ * ```typescript
71
+ * // Url to demo server.
72
+ * const url = "http://tracker.transistorsoft.com";
73
+ * const orgname = "my-company-name";
74
+ * const username = "my-username";
75
+ *
76
+ * // Fetch an authoriztion token from server. The SDK will cache the received token.
77
+ * const token = await
78
+ * BackgroundGeolocation.findOrCreateTransistorAuthorizationToken(orgname, username, url);
79
+ *
80
+ * BackgroundGeolocation.ready({
81
+ * transistorAuthorizationToken: token
82
+ * })
83
+ * ```
84
+ */
85
+ findOrCreate(orgName: string, username: string, url?: string): Promise<TransistorAuthorizationToken>;
86
+ /**
87
+ * Destroy the token associated with the given tracker base URL.
88
+ *
89
+ * @param url - Tracker base URL. Defaults to the SDK's built‑in value.
90
+ */
91
+ destroy(url?: string): Promise<void>;
92
+ /**
93
+ * Mutates a {@link Config} to apply the given Transistor token if present.
94
+ *
95
+ * The JS implementation typically:
96
+ * - Reads `config.transistorAuthorizationToken`
97
+ * - Deletes that property
98
+ * - Sets `config.http.url` or `config.url` to `"<token.url>/api/locations"`
99
+ * - Sets `config.authorization = { strategy: "jwt", ... }`
100
+ *
101
+ * If no `transistorAuthorizationToken` is found, the `config` is returned unchanged.
102
+ *
103
+ * @param config - A config that may contain a `transistorAuthorizationToken` field.
104
+ * @returns A {@link Config} with HTTP + authorization wired to the token, if present.
105
+ *
106
+ * @example
107
+ * ```ts
108
+ * async function applyDemoToken(
109
+ * service: TransistorAuthorizationService,
110
+ * config: Config
111
+ * ): Promise<Config> {
112
+ * const token = await service.findOrCreate('my-org', 'user@example.com');
113
+ *
114
+ * return service.applyIf({
115
+ * ...config,
116
+ * transistorAuthorizationToken: token
117
+ * });
118
+ * }
119
+ * ```
120
+ */
121
+ applyIf<T extends Config & {
122
+ transistorAuthorizationToken?: TransistorAuthorizationToken;
123
+ }>(config: T): Config;
124
+ }
@@ -5,6 +5,7 @@ import { AppConfig } from './AppConfig';
5
5
  import { PersistenceConfig } from './PersistenceConfig';
6
6
  import { ActivityConfig } from './ActivityConfig';
7
7
  import { AuthorizationConfig } from './AuthorizationConfig';
8
+ import { TransistorAuthorizationToken } from '../api/TransistorAuthorizationService';
8
9
  /**
9
10
  * Configuration API.
10
11
  *
@@ -146,4 +147,49 @@ export interface Config {
146
147
  * Authorization configuration.
147
148
  */
148
149
  authorization?: AuthorizationConfig;
150
+ /**
151
+ * *Convenience* option to automatically configures the SDK to upload locations to the Transistor Software demo server
152
+ * at http://tracker.transistorsoft.com (or your own local instance of [background-geolocation-console](https://github.com/transistorsoft/background-geolocation-console))
153
+ *
154
+ * See {@link TransistorAuthorizationService}. This option will **automatically configure** the {@link HttpConfig.url}
155
+ * to point at the Demo server as well as well as the required {@link AuthorizationConfig} configuration.
156
+ *
157
+ * @example
158
+ * ```typescript
159
+ * const token = await
160
+ * BackgroundGeolocation.findOrCreateTransistorAuthorizationToken("my-company-name", "my-username");
161
+ *
162
+ * BackgroundGeolocation.ready({
163
+ * transistorAuthorizationToken: token
164
+ * });
165
+ * ```
166
+ *
167
+ * This *convenience* option merely performs the following [[Authorization]] configuration *automatically* for you:
168
+ *
169
+ * @example
170
+ * ```typescript
171
+ * // Base url to Transistor Demo Server.
172
+ * const url = "http://tracker.transistorsoft.com";
173
+ *
174
+ * // Register for an authorization token from server.
175
+ * const token = await
176
+ * BackgroundGeolocation.findOrCreateTransistorAuthorizationToken("my-company-name", "my-username");
177
+ *
178
+ * BackgroundGeolocation.ready({
179
+ * url: url + "/api/locations",
180
+ * authorization: {
181
+ * strategy: "JWT",
182
+ * accessToken: token.accessToken,
183
+ * refreshToken: token.refreshToken,
184
+ * refreshUrl: url + "/v2/refresh_token",
185
+ * refreshPayload: {
186
+ * refresh_token: "{refreshToken}"
187
+ * },
188
+ * expires: token.expires
189
+ * }
190
+ * });
191
+ * ```
192
+ *
193
+ */
194
+ transistorAuthorization?: TransistorAuthorizationToken;
149
195
  }
@@ -527,7 +527,7 @@ export interface PersistenceConfig {
527
527
  * Disable the automatic insertion of a synthetic “provider-change” location
528
528
  * into the SDK’s SQLite database (and its subsequent HTTP upload).
529
529
  *
530
- * By default, when an {@link onProviderChange} event fires, the Android SDK
530
+ * By default, when an {@link BackgroundGeolocation.onProviderChange} event fires, the Android SDK
531
531
  * records a special location documenting *when* and *where* the device’s
532
532
  * location-services state changed (e.g., GPS disabled).
533
533
  * This behavior historically existed to support platforms with limited or
@@ -14,3 +14,8 @@ export declare const AccuracyAuthorization: {
14
14
  readonly Full: 0;
15
15
  readonly Reduced: 1;
16
16
  };
17
+ /**
18
+ * Type union of the AccuracyAuthorization values.
19
+ * @internal @hidden
20
+ */
21
+ export type AccuracyAuthorization = (typeof AccuracyAuthorization)[keyof typeof AccuracyAuthorization];
@@ -26,3 +26,8 @@ export declare const ActivityType: {
26
26
  /** Airborne activity (iOS 15+). */
27
27
  readonly Airborne: 5;
28
28
  };
29
+ /**
30
+ * Type union of the ActivityType values.
31
+ * @internal @hidden
32
+ */
33
+ export type ActivityType = (typeof ActivityType)[keyof typeof ActivityType];
@@ -18,3 +18,7 @@ export declare const AuthorizationStatus: {
18
18
  readonly Always: 3;
19
19
  readonly WhenInUse: 4;
20
20
  };
21
+ /**
22
+ * @hidden @internal
23
+ */
24
+ export type AuthorizationStatus = (typeof AuthorizationStatus)[keyof typeof AuthorizationStatus];
@@ -8,3 +8,7 @@ export declare const AuthorizationStrategy: {
8
8
  readonly Jwt: "jwt";
9
9
  readonly Sas: "sas";
10
10
  };
11
+ /**
12
+ * @internal @hidden
13
+ */
14
+ export type AuthorizationStrategy = (typeof AuthorizationStrategy)[keyof typeof AuthorizationStrategy];
@@ -11,3 +11,5 @@ export declare const DesiredAccuracy: {
11
11
  readonly VeryLow: 1000;
12
12
  readonly Lowest: 3000;
13
13
  };
14
+ /** @internal @hidden */
15
+ export type DesiredAccuracy = typeof DesiredAccuracy[keyof typeof DesiredAccuracy];
@@ -4,6 +4,8 @@
4
4
  * @category Events
5
5
  */
6
6
  export declare const Event: {
7
+ readonly Boot: "boot";
8
+ readonly Terminate: "terminate";
7
9
  readonly Location: "location";
8
10
  readonly MotionChange: "motionchange";
9
11
  readonly ActivityChange: "activitychange";
@@ -19,3 +21,8 @@ export declare const Event: {
19
21
  readonly Schedule: "schedule";
20
22
  readonly Notification: "notification";
21
23
  };
24
+ /**
25
+ * Event names emitted by the SDK.
26
+ * @hidden @internal
27
+ */
28
+ export type Event = (typeof Event)[keyof typeof Event];
@@ -7,6 +7,8 @@ exports.Event = void 0;
7
7
  * @category Events
8
8
  */
9
9
  exports.Event = {
10
+ Boot: 'boot',
11
+ Terminate: 'terminate',
10
12
  Location: 'location',
11
13
  MotionChange: 'motionchange',
12
14
  ActivityChange: 'activitychange',
@@ -16,3 +16,8 @@ export declare const GeofenceAction: {
16
16
  readonly Exit: "EXIT";
17
17
  readonly Dwell: "DWELL";
18
18
  };
19
+ /**
20
+ * Union of geofence transition strings.
21
+ * @internal @hidden
22
+ */
23
+ export type GeofenceAction = (typeof GeofenceAction)[keyof typeof GeofenceAction];
@@ -9,3 +9,5 @@ export declare const HttpMethod: {
9
9
  readonly Put: "PUT";
10
10
  readonly Patch: "PATCH";
11
11
  };
12
+ /** @internal @hidden */
13
+ export type HttpMethod = (typeof HttpMethod)[keyof typeof HttpMethod];
@@ -28,3 +28,5 @@ export declare const KalmanProfile: {
28
28
  /** Conservative — maximum smoothing, slower reaction to change. */
29
29
  readonly Conservative: 2;
30
30
  };
31
+ /** @internal @hidden */
32
+ export type KalmanProfile = (typeof KalmanProfile)[keyof typeof KalmanProfile];
@@ -21,3 +21,8 @@ export declare const LocationError: {
21
21
  readonly Timeout: 408;
22
22
  readonly Cancelled: 499;
23
23
  };
24
+ /**
25
+ * Union type of possible location error codes.
26
+ * @internal @hidden
27
+ */
28
+ export type LocationError = (typeof LocationError)[keyof typeof LocationError];
@@ -106,3 +106,5 @@ export declare const LocationFilterPolicy: {
106
106
  /** Aggressive — filters heavily, preferring stability over responsiveness. */
107
107
  readonly Conservative: 2;
108
108
  };
109
+ /** @internal @hidden */
110
+ export type LocationFilterPolicy = (typeof LocationFilterPolicy)[keyof typeof LocationFilterPolicy];
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Indicates what level of location authorization the SDK should request.
3
+ *
4
+ * | Name | Value | Description |
5
+ * |------------|--------------|----------------------------------------------------------|
6
+ * | Always | `"Always"` | Request full background + foreground authorization. |
7
+ * | WhenInUse | `"WhenInUse"`| Request foreground-only authorization. |
8
+ * | Any | `"Any"` | Accept *either* Always or WhenInUse (no specific request). |
9
+ *
10
+ * Mirrors native iOS authorization request options and existing RN adapter keys.
11
+ *
12
+ * See {@link GeoConfig.locationAuthorizationRequest}
13
+ *
14
+ * @category Config
15
+ */
16
+ export declare const LocationRequest: {
17
+ readonly Always: "Always";
18
+ readonly WhenInUse: "WhenInUse";
19
+ readonly Any: "Any";
20
+ };
21
+ /**
22
+ * Type union of all LocationRequest values.
23
+ * @internal @hidden
24
+ */
25
+ export type LocationRequest = (typeof LocationRequest)[keyof typeof LocationRequest];
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LocationRequest = void 0;
4
+ /**
5
+ * Indicates what level of location authorization the SDK should request.
6
+ *
7
+ * | Name | Value | Description |
8
+ * |------------|--------------|----------------------------------------------------------|
9
+ * | Always | `"Always"` | Request full background + foreground authorization. |
10
+ * | WhenInUse | `"WhenInUse"`| Request foreground-only authorization. |
11
+ * | Any | `"Any"` | Accept *either* Always or WhenInUse (no specific request). |
12
+ *
13
+ * Mirrors native iOS authorization request options and existing RN adapter keys.
14
+ *
15
+ * See {@link GeoConfig.locationAuthorizationRequest}
16
+ *
17
+ * @category Config
18
+ */
19
+ exports.LocationRequest = {
20
+ Always: 'Always',
21
+ WhenInUse: 'WhenInUse',
22
+ Any: 'Any',
23
+ };
@@ -1,6 +1,17 @@
1
1
  /**
2
2
  * Controls the verbosity of plugin logging.
3
3
  *
4
+ * | Level | Value | Description |
5
+ * |---------|:-----:|---------------------------------|
6
+ * | Off | 0 | Disable all logging. |
7
+ * | Error | 1 | Log only critical failures. |
8
+ * | Warning | 2 | Log warnings + errors. |
9
+ * | Info | 3 | Operational information. |
10
+ * | Debug | 4 | Developer-level debug output. |
11
+ * | Verbose | 5 | Maximum detail. |
12
+ *
13
+ * Mirrors native logging constants on iOS & Android.
14
+ *
4
15
  * @category Config
5
16
  */
6
17
  export declare const LogLevel: {
@@ -11,3 +22,8 @@ export declare const LogLevel: {
11
22
  readonly Debug: 4;
12
23
  readonly Verbose: 5;
13
24
  };
25
+ /**
26
+ * Type union of all LogLevel values.
27
+ * @internal @hidden
28
+ */
29
+ export type LogLevel = (typeof LogLevel)[keyof typeof LogLevel];
@@ -4,6 +4,17 @@ exports.LogLevel = void 0;
4
4
  /**
5
5
  * Controls the verbosity of plugin logging.
6
6
  *
7
+ * | Level | Value | Description |
8
+ * |---------|:-----:|---------------------------------|
9
+ * | Off | 0 | Disable all logging. |
10
+ * | Error | 1 | Log only critical failures. |
11
+ * | Warning | 2 | Log warnings + errors. |
12
+ * | Info | 3 | Operational information. |
13
+ * | Debug | 4 | Developer-level debug output. |
14
+ * | Verbose | 5 | Maximum detail. |
15
+ *
16
+ * Mirrors native logging constants on iOS & Android.
17
+ *
7
18
  * @category Config
8
19
  */
9
20
  exports.LogLevel = {
@@ -12,5 +23,5 @@ exports.LogLevel = {
12
23
  Warning: 2,
13
24
  Info: 3,
14
25
  Debug: 4,
15
- Verbose: 5
26
+ Verbose: 5,
16
27
  };
@@ -1 +1,14 @@
1
- export {};
1
+ /**
2
+ * Log severity level used by {@link Logger.debug} {@link Logger.info}, etc.
3
+ * @hidden
4
+ * @internal
5
+ */
6
+ export declare const LogLevelName: {
7
+ readonly Debug: "debug";
8
+ readonly Notice: "notice";
9
+ readonly Info: "info";
10
+ readonly Warn: "warn";
11
+ readonly Error: "error";
12
+ };
13
+ /** @internal @hidden */
14
+ export type LogLevelName = typeof LogLevelName[keyof typeof LogLevelName];
@@ -12,3 +12,5 @@ export declare const MotionActivityType: {
12
12
  readonly InVehicle: "in_vehicle";
13
13
  readonly Unknown: "unknown";
14
14
  };
15
+ /** @internal @hidden */
16
+ export type MotionActivityType = typeof MotionActivityType[keyof typeof MotionActivityType];
@@ -20,3 +20,5 @@ export declare const NotificationPriority: {
20
20
  /** Notification strongly weighted to bottom of list; icon hidden. */
21
21
  readonly Min: -2;
22
22
  };
23
+ /** @internal @hidden */
24
+ export type NotificationPriority = (typeof NotificationPriority)[keyof typeof NotificationPriority];
@@ -10,3 +10,5 @@ export declare const PersistMode: {
10
10
  readonly Geofence: -1;
11
11
  readonly None: 0;
12
12
  };
13
+ /** @internal @hidden */
14
+ export type PersistMode = (typeof PersistMode)[keyof typeof PersistMode];
@@ -12,3 +12,5 @@ export declare const TrackingMode: {
12
12
  readonly Geofences: 0;
13
13
  readonly Location: 1;
14
14
  };
15
+ /** @internal @hidden */
16
+ export type TrackingMode = typeof TrackingMode[keyof typeof TrackingMode];
@@ -11,3 +11,5 @@ export declare const TriggerActivity: {
11
11
  readonly OnBicycle: "on_bicycle";
12
12
  readonly InVehicle: "in_vehicle";
13
13
  };
14
+ /** @internal @hidden */
15
+ export type TriggerActivity = (typeof TriggerActivity)[keyof typeof TriggerActivity];
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export * from './enums/LogLevel';
3
3
  export * from './enums/DesiredAccuracy';
4
4
  export * from './enums/PersistMode';
5
5
  export * from './enums/AuthorizationStrategy';
6
+ export * from './enums/LocationRequest';
6
7
  export * from './enums/LocationFilterPolicy';
7
8
  export * from './enums/KalmanProfile';
8
9
  export * from './enums/HttpMethod';
@@ -47,3 +48,4 @@ export * from './core/api/State';
47
48
  export * from './core/api/Logger';
48
49
  export * from './core/api/DeviceSettings';
49
50
  export * from './core/api/CurrentPositionRequest';
51
+ export * from './core/api/TransistorAuthorizationService';
package/dist/index.js CHANGED
@@ -20,6 +20,7 @@ __exportStar(require("./enums/LogLevel"), exports);
20
20
  __exportStar(require("./enums/DesiredAccuracy"), exports);
21
21
  __exportStar(require("./enums/PersistMode"), exports);
22
22
  __exportStar(require("./enums/AuthorizationStrategy"), exports);
23
+ __exportStar(require("./enums/LocationRequest"), exports);
23
24
  __exportStar(require("./enums/LocationFilterPolicy"), exports);
24
25
  __exportStar(require("./enums/KalmanProfile"), exports);
25
26
  __exportStar(require("./enums/HttpMethod"), exports);
@@ -67,3 +68,4 @@ __exportStar(require("./core/api/State"), exports);
67
68
  __exportStar(require("./core/api/Logger"), exports);
68
69
  __exportStar(require("./core/api/DeviceSettings"), exports);
69
70
  __exportStar(require("./core/api/CurrentPositionRequest"), exports);
71
+ __exportStar(require("./core/api/TransistorAuthorizationService"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transistorsoft/background-geolocation-types",
3
- "version": "5.0.0-beta.1",
3
+ "version": "5.0.0-beta.3",
4
4
  "type": "commonjs",
5
5
  "description": "Shared TypeScript type definitions and documentation for Transistor Software's Background Geolocation SDKs (React Native, Capacitor, Cordova)",
6
6
  "author": "Transistor Software <info@transistorsoft.com>",
@@ -1,19 +0,0 @@
1
- import { LoggerConfig } from './LoggerConfig';
2
- import { HttpConfig } from './HttpConfig';
3
- import { GeoConfig } from './GeoConfig';
4
- import { AppConfig } from './AppConfig';
5
- import { PersistenceConfig } from './PersistenceConfig';
6
- import { ActivityConfig } from './ActivityConfig';
7
- import { AuthorizationConfig } from './AuthorizationConfig';
8
- /**
9
- * Root compound configuration object for the BackgroundGeolocation SDK.
10
- */
11
- export interface CompoundConfig {
12
- logger?: LoggerConfig;
13
- geolocation?: GeoConfig;
14
- http?: HttpConfig;
15
- app?: AppConfig;
16
- persistence?: PersistenceConfig;
17
- activity?: ActivityConfig;
18
- authorization?: AuthorizationConfig;
19
- }