react-native-asleep 1.1.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ko.md +374 -0
- package/README.md +298 -143
- package/android/build.gradle +1 -1
- package/android/src/main/java/ai/asleep/reactnative/AsleepModule.kt +127 -84
- package/build/Asleep.types.d.ts +38 -20
- package/build/Asleep.types.d.ts.map +1 -1
- package/build/Asleep.types.js +24 -1
- package/build/Asleep.types.js.map +1 -1
- package/build/AsleepStore.d.ts +44 -43
- package/build/AsleepStore.d.ts.map +1 -1
- package/build/AsleepStore.js +539 -672
- package/build/AsleepStore.js.map +1 -1
- package/build/index.d.ts +11 -113
- package/build/index.d.ts.map +1 -1
- package/build/index.js +18 -184
- package/build/index.js.map +1 -1
- package/build/store/createStore.d.ts +14 -0
- package/build/store/createStore.d.ts.map +1 -0
- package/build/store/createStore.js +63 -0
- package/build/store/createStore.js.map +1 -0
- package/docs/INTEGRATION.ko.md +395 -0
- package/docs/INTEGRATION.md +442 -0
- package/ios/Asleep.podspec +1 -1
- package/ios/AsleepModule.swift +39 -14
- package/package.json +7 -7
- package/src/Asleep.types.ts +50 -21
- package/src/AsleepStore.ts +777 -893
- package/src/index.ts +37 -292
- package/src/store/createStore.ts +84 -0
package/src/Asleep.types.ts
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Authentication passed to `setup()` and `initAsleepConfig()`: either an API
|
|
3
|
+
* key or a token-auth `appId` / `appSecret` pair. The two forms are mutually
|
|
4
|
+
* exclusive; supplying neither or both is rejected with `INVALID_ARGUMENT`.
|
|
5
|
+
*/
|
|
6
|
+
export type AsleepCredentials =
|
|
7
|
+
| { apiKey: string; appId?: never; appSecret?: never }
|
|
8
|
+
| { appId: string; appSecret: string; apiKey?: never };
|
|
9
|
+
|
|
10
|
+
export type AsleepConfig = AsleepCredentials & {
|
|
3
11
|
userId?: string;
|
|
4
12
|
baseUrl?: string;
|
|
5
13
|
callbackUrl?: string;
|
|
6
14
|
};
|
|
7
15
|
|
|
8
|
-
export type AsleepSetupConfig = {
|
|
9
|
-
apiKey: string;
|
|
16
|
+
export type AsleepSetupConfig = AsleepCredentials & {
|
|
10
17
|
baseUrl?: string;
|
|
11
18
|
callbackUrl?: string;
|
|
12
19
|
service?: string;
|
|
@@ -167,6 +174,10 @@ export type AsleepAnalysisAck = {
|
|
|
167
174
|
timestamp: number;
|
|
168
175
|
};
|
|
169
176
|
|
|
177
|
+
export type SetupStatus = "idle" | "inProgress" | "complete";
|
|
178
|
+
|
|
179
|
+
export type TrackingStatus = "idle" | "tracking" | "paused" | "recoveryRequired";
|
|
180
|
+
|
|
170
181
|
export type AudioSessionOption = "duckOthers" | "allowAirPlay" | "allowBluetooth" | "allowBluetoothA2DP";
|
|
171
182
|
|
|
172
183
|
export type TrackingConfig = {
|
|
@@ -195,23 +206,39 @@ export type TrackingConfig = {
|
|
|
195
206
|
export type AsleepErrorCategory = "terminal" | "recordingDead" | "recoveryRequired" | "transient" | "unknown";
|
|
196
207
|
|
|
197
208
|
/**
|
|
198
|
-
* Structured
|
|
199
|
-
*
|
|
200
|
-
*
|
|
209
|
+
* Structured error used everywhere the SDK reports a failure.
|
|
210
|
+
*
|
|
211
|
+
* `code` is a stable machine identifier. Classified tracking failures also
|
|
212
|
+
* carry their category and documented native SDK code, while `cause` retains
|
|
213
|
+
* the original rejection or event payload for observability.
|
|
201
214
|
*/
|
|
202
|
-
export
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
+
export class AsleepError extends Error {
|
|
216
|
+
readonly code: string;
|
|
217
|
+
readonly category?: AsleepErrorCategory;
|
|
218
|
+
readonly sdkCode?: number;
|
|
219
|
+
readonly caseName?: string;
|
|
220
|
+
readonly cause?: unknown;
|
|
221
|
+
|
|
222
|
+
constructor(
|
|
223
|
+
code: string,
|
|
224
|
+
message: string,
|
|
225
|
+
options?: {
|
|
226
|
+
cause?: unknown;
|
|
227
|
+
category?: AsleepErrorCategory;
|
|
228
|
+
sdkCode?: number;
|
|
229
|
+
caseName?: string;
|
|
230
|
+
},
|
|
231
|
+
) {
|
|
232
|
+
super(message);
|
|
233
|
+
this.name = "AsleepError";
|
|
234
|
+
this.code = code;
|
|
235
|
+
this.category = options?.category;
|
|
236
|
+
this.sdkCode = options?.sdkCode;
|
|
237
|
+
this.caseName = options?.caseName;
|
|
238
|
+
this.cause = options?.cause;
|
|
239
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
215
242
|
|
|
216
243
|
export type AsleepEventType = {
|
|
217
244
|
onTrackingCreated: { sessionId?: string };
|
|
@@ -223,7 +250,9 @@ export type AsleepEventType = {
|
|
|
223
250
|
message?: string;
|
|
224
251
|
/**
|
|
225
252
|
* @deprecated On iOS this is the Swift enum declaration ordinal from
|
|
226
|
-
* NSError bridging, not the documented Asleep error code
|
|
253
|
+
* NSError bridging, not the documented Asleep error code, and it shifts
|
|
254
|
+
* when the native enum gains cases (iOS SDK 3.3.x moved 38/39 to 59/60).
|
|
255
|
+
* Use `sdkCode`, `caseName`, or `category`.
|
|
227
256
|
*/
|
|
228
257
|
errorCode?: number;
|
|
229
258
|
/** Numeric code documented by the native Asleep SDKs (both platforms). */
|