@tryterra/react-native 2.2.1 → 2.3.1
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 +68 -0
- package/android/src/bridgeCore/kotlin/co/tryterra/sdk/bridge/BridgeBootstrap.kt +14 -1
- package/android/src/bridgeCore/kotlin/co/tryterra/sdk/bridge/Conversions.kt +35 -2
- package/android/src/bridgeCore/kotlin/co/tryterra/sdk/bridge/Rejections.kt +3 -0
- package/android/src/bridgeCore/kotlin/co/tryterra/sdk/bridge/TerraBridgeOpsImpl.kt +33 -0
- package/android/src/bridgeCore/kotlin/co/tryterra/sdk/bridge/generated/BridgeErrors.kt +12 -0
- package/android/src/bridgeCore/kotlin/co/tryterra/sdk/bridge/generated/BridgeOps.kt +47 -0
- package/android/src/bridgeCore/kotlin/co/tryterra/sdk/bridge/generated/BridgeTypes.kt +348 -0
- package/docs/availability.md +111 -1
- package/frameworks/TerraSDK.xcframework/ios-arm64/TerraSDK.framework/Info.plist +0 -0
- package/frameworks/TerraSDK.xcframework/ios-arm64/TerraSDK.framework/Modules/TerraSDK.swiftmodule/arm64-apple-ios.abi.json +21646 -9224
- package/frameworks/TerraSDK.xcframework/ios-arm64/TerraSDK.framework/Modules/TerraSDK.swiftmodule/arm64-apple-ios.package.swiftinterface +351 -14
- package/frameworks/TerraSDK.xcframework/ios-arm64/TerraSDK.framework/Modules/TerraSDK.swiftmodule/arm64-apple-ios.private.swiftinterface +351 -14
- package/frameworks/TerraSDK.xcframework/ios-arm64/TerraSDK.framework/Modules/TerraSDK.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
- package/frameworks/TerraSDK.xcframework/ios-arm64/TerraSDK.framework/Modules/TerraSDK.swiftmodule/arm64-apple-ios.swiftinterface +339 -13
- package/frameworks/TerraSDK.xcframework/ios-arm64/TerraSDK.framework/TerraSDK +0 -0
- package/frameworks/TerraSDK.xcframework/ios-arm64/dSYMs/TerraSDK.framework.dSYM/Contents/Info.plist +2 -2
- package/frameworks/TerraSDK.xcframework/ios-arm64/dSYMs/TerraSDK.framework.dSYM/Contents/Resources/DWARF/TerraSDK +0 -0
- package/frameworks/TerraSDK.xcframework/ios-arm64/dSYMs/TerraSDK.framework.dSYM/Contents/Resources/Relocations/aarch64/TerraSDK.yml +7449 -6589
- package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/Info.plist +0 -0
- package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/Modules/TerraSDK.swiftmodule/arm64-apple-ios-simulator.abi.json +21646 -9224
- package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/Modules/TerraSDK.swiftmodule/arm64-apple-ios-simulator.package.swiftinterface +351 -14
- package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/Modules/TerraSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +351 -14
- package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/Modules/TerraSDK.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
- package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/Modules/TerraSDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface +339 -13
- package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/Modules/TerraSDK.swiftmodule/x86_64-apple-ios-simulator.abi.json +21646 -9224
- package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/Modules/TerraSDK.swiftmodule/x86_64-apple-ios-simulator.package.swiftinterface +351 -14
- package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/Modules/TerraSDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +351 -14
- package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/Modules/TerraSDK.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
- package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/Modules/TerraSDK.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +339 -13
- package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/TerraSDK +0 -0
- package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/_CodeSignature/CodeResources +21 -21
- package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/TerraSDK.framework.dSYM/Contents/Info.plist +2 -2
- package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/TerraSDK.framework.dSYM/Contents/Resources/DWARF/TerraSDK +0 -0
- package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/TerraSDK.framework.dSYM/Contents/Resources/Relocations/aarch64/TerraSDK.yml +7450 -6590
- package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/TerraSDK.framework.dSYM/Contents/Resources/Relocations/x86_64/TerraSDK.yml +7359 -6508
- package/ios/TerraBridgeCore/BridgeBootstrap.swift +13 -3
- package/ios/TerraBridgeCore/Conversions.swift +36 -1
- package/ios/TerraBridgeCore/Generated/BridgeErrors.swift +15 -0
- package/ios/TerraBridgeCore/Generated/BridgeOps.swift +82 -0
- package/ios/TerraBridgeCore/Generated/BridgeTypes.swift +252 -3
- package/ios/TerraBridgeCore/Rejections.swift +5 -1
- package/ios/TerraBridgeCore/TerraBridgeOpsImpl.swift +32 -1
- package/lib/Terra.d.ts +47 -1
- package/lib/Terra.js +16 -0
- package/lib/generated/client.d.ts +33 -1
- package/lib/generated/client.js +42 -0
- package/lib/generated/codecs.d.ts +15 -1
- package/lib/generated/codecs.js +119 -5
- package/lib/generated/errors.d.ts +1 -1
- package/lib/generated/errors.js +6 -1
- package/lib/generated/ops.d.ts +1 -1
- package/lib/generated/ops.js +12 -0
- package/lib/generated/types.d.ts +70 -2
- package/lib/generated/types.js +101 -1
- package/lib/index.d.ts +1 -1
- package/package.json +3 -3
- package/src/Terra.ts +64 -0
- package/src/generated/client.ts +49 -2
- package/src/generated/codecs.ts +112 -6
- package/src/generated/errors.ts +11 -1
- package/src/generated/ops.ts +17 -0
- package/src/generated/types.ts +274 -1
- package/src/index.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryterra/react-native",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"description": "Terra's health SDK for React Native",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://docs.tryterra.co",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"!docs/distribution.md"
|
|
30
30
|
],
|
|
31
31
|
"terraNative": {
|
|
32
|
-
"ios": "2.
|
|
33
|
-
"android": "2.
|
|
32
|
+
"ios": "2.3.1",
|
|
33
|
+
"android": "2.3.1"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"typecheck": "tsc --noEmit",
|
package/src/Terra.ts
CHANGED
|
@@ -20,10 +20,12 @@ import type {
|
|
|
20
20
|
Connection,
|
|
21
21
|
DataCategory,
|
|
22
22
|
DayTotal,
|
|
23
|
+
DevIdBinding,
|
|
23
24
|
DiagnosticsState,
|
|
24
25
|
DietaryQuantity,
|
|
25
26
|
EndUser,
|
|
26
27
|
HealthAccess,
|
|
28
|
+
HealthDataType,
|
|
27
29
|
HealthChange,
|
|
28
30
|
HeartRateEntry,
|
|
29
31
|
HeartRateSample,
|
|
@@ -92,6 +94,13 @@ export interface Permissions {
|
|
|
92
94
|
*/
|
|
93
95
|
request(access: Partial<HealthAccess>, source?: Source): Promise<HealthAccess | undefined>;
|
|
94
96
|
status(category: DataCategory, source?: Source): Promise<PermissionStatus>;
|
|
97
|
+
/**
|
|
98
|
+
* One type's read status. iOS answers `notDisclosed` wherever it has the type, because HealthKit
|
|
99
|
+
* never reports a read decision; Android answers `granted` once any permission behind the type
|
|
100
|
+
* is granted. A type this platform has no store type for rejects with
|
|
101
|
+
* `bridge.unsupported_on_platform`.
|
|
102
|
+
*/
|
|
103
|
+
typeStatus(type: HealthDataType, source?: Source): Promise<PermissionStatus>;
|
|
95
104
|
writeStatus(category: DataCategory, source?: Source): Promise<PermissionStatus>;
|
|
96
105
|
requested(source?: Source): Promise<HealthAccess>;
|
|
97
106
|
/** Android only. */
|
|
@@ -100,6 +109,15 @@ export interface Permissions {
|
|
|
100
109
|
readonly backgroundReadStatus?: (source?: Source) => Promise<PermissionStatus>;
|
|
101
110
|
/** Android only. */
|
|
102
111
|
readonly historyReadStatus?: (source?: Source) => Promise<PermissionStatus>;
|
|
112
|
+
/**
|
|
113
|
+
* iOS only. Apple Health Records (`clinicalRecord`), on HealthKit's own sheet. Opt-in: the host
|
|
114
|
+
* needs the Clinical Health Records entitlement, both `NSHealthShareUsageDescription` and
|
|
115
|
+
* `NSHealthClinicalHealthRecordsShareUsageDescription`, and `CLINICAL_RECORD` enabled for the
|
|
116
|
+
* Terra client in Terra's dashboard. Rejects with `health_records_unavailable` where the device has
|
|
117
|
+
* no Health Records, and with `health_records_usage_description_missing` when either Info.plist
|
|
118
|
+
* string is absent. The only way to ask: `request` ignores `clinicalRecord`.
|
|
119
|
+
*/
|
|
120
|
+
readonly requestClinicalRecords?: () => Promise<void>;
|
|
103
121
|
}
|
|
104
122
|
|
|
105
123
|
export interface Diagnostics {
|
|
@@ -222,6 +240,32 @@ export interface PlannedWorkouts {
|
|
|
222
240
|
requestScheduling(): Promise<WorkoutSchedulingStatus>;
|
|
223
241
|
}
|
|
224
242
|
|
|
243
|
+
/**
|
|
244
|
+
* The customers one installation serves, in multi-dev-id mode: a connector app that several
|
|
245
|
+
* customers link the same person through, with one read and one upload for all of them. Every call
|
|
246
|
+
* is refused with `dev_id_mismatch` unless the native bootstrap chose the mode - `TerraDevIDMode`
|
|
247
|
+
* set to `multiple` in the iOS Info.plist, `co.tryterra.sdk.DEV_ID_MODE` set to `multiple` in the
|
|
248
|
+
* Android manifest's application meta-data.
|
|
249
|
+
*/
|
|
250
|
+
export interface LinkedDevIds {
|
|
251
|
+
/**
|
|
252
|
+
* Links `devId`'s connection with a link token that customer minted. The first customer links
|
|
253
|
+
* the installation; every later one joins it and is sent the history the others already have.
|
|
254
|
+
*/
|
|
255
|
+
link(devId: string, token: string, source?: Source): Promise<DevIdBinding>;
|
|
256
|
+
/**
|
|
257
|
+
* Stops delivering to `devId`'s connection and leaves the others linked. The last customer's
|
|
258
|
+
* unlink disconnects the installation.
|
|
259
|
+
*/
|
|
260
|
+
unlink(devId: string, source?: Source): Promise<void>;
|
|
261
|
+
/**
|
|
262
|
+
* The customers currently linked, in the order they linked, gone ones included (`active` false).
|
|
263
|
+
* `refresh` asks Terra first, so `active` is as of now; the `devIDBindingChanged` event reports
|
|
264
|
+
* each change.
|
|
265
|
+
*/
|
|
266
|
+
all(options?: { readonly source?: Source; readonly refresh?: boolean }): Promise<readonly DevIdBinding[]>;
|
|
267
|
+
}
|
|
268
|
+
|
|
225
269
|
export class Terra {
|
|
226
270
|
readonly platform: Platform;
|
|
227
271
|
readonly permissions: Permissions;
|
|
@@ -237,6 +281,8 @@ export class Terra {
|
|
|
237
281
|
readonly athlete: AthleteMetrics | undefined;
|
|
238
282
|
/** `undefined` on Android, which has no planned workouts. */
|
|
239
283
|
readonly plannedWorkouts: PlannedWorkouts | undefined;
|
|
284
|
+
/** Multi-dev-id mode's customers, on both platforms. */
|
|
285
|
+
readonly linkedDevIds: LinkedDevIds;
|
|
240
286
|
|
|
241
287
|
private readonly ops: GeneratedClient;
|
|
242
288
|
private readonly streams: StreamHub;
|
|
@@ -272,10 +318,14 @@ export class Terra {
|
|
|
272
318
|
write: access.write ?? [],
|
|
273
319
|
workouts: access.workouts ?? ([] as readonly WorkoutScope[]),
|
|
274
320
|
source,
|
|
321
|
+
// Left out rather than sent empty when the host asks only by category, so the request
|
|
322
|
+
// has the shape it had before types existed.
|
|
323
|
+
...(access.readTypes !== undefined && { readTypes: access.readTypes }),
|
|
275
324
|
});
|
|
276
325
|
return grant.granted;
|
|
277
326
|
},
|
|
278
327
|
status: async (category, source) => (await ops.permissionsStatus({ category, source })).status,
|
|
328
|
+
typeStatus: async (type, source) => (await ops.permissionsTypeStatus({ type, source })).status,
|
|
279
329
|
writeStatus: async (category, source) => (await ops.permissionsWriteStatus({ category, source })).status,
|
|
280
330
|
requested: (source) => ops.permissionsRequested({ source }),
|
|
281
331
|
...(on("permissions.statuses") && {
|
|
@@ -287,6 +337,11 @@ export class Terra {
|
|
|
287
337
|
...(on("permissions.historyReadStatus") && {
|
|
288
338
|
historyReadStatus: async (source?: Source) => (await ops.permissionsHistoryReadStatus({ source })).status,
|
|
289
339
|
}),
|
|
340
|
+
...(on("permissions.requestClinicalRecords") && {
|
|
341
|
+
requestClinicalRecords: async () => {
|
|
342
|
+
await ops.permissionsRequestClinicalRecords({});
|
|
343
|
+
},
|
|
344
|
+
}),
|
|
290
345
|
};
|
|
291
346
|
|
|
292
347
|
this.diagnostics = {
|
|
@@ -378,6 +433,15 @@ export class Terra {
|
|
|
378
433
|
requestScheduling: async () => (await ops.plannedWorkoutsRequestScheduling({})).status,
|
|
379
434
|
}
|
|
380
435
|
: undefined;
|
|
436
|
+
|
|
437
|
+
this.linkedDevIds = {
|
|
438
|
+
link: (devId, token, source) => ops.clientLinkDevId({ devId, token, source }),
|
|
439
|
+
unlink: async (devId, source) => {
|
|
440
|
+
await ops.clientUnlinkDevId({ devId, source });
|
|
441
|
+
},
|
|
442
|
+
all: async (options = {}) =>
|
|
443
|
+
(await ops.clientLinkedDevIds({ source: options.source, refresh: options.refresh })).bindings,
|
|
444
|
+
};
|
|
381
445
|
}
|
|
382
446
|
|
|
383
447
|
/**
|
package/src/generated/client.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Generated from surface/terra-surface.json by surface/gen. Do not edit by hand.
|
|
2
2
|
// Regenerate with: node surface/gen/src/cli.ts generate
|
|
3
3
|
|
|
4
|
-
import type { AthleteProfileResult, AvailabilityResult, BodyEntryList, BodyReadingList, BoolResult, BootstrapState, CategoryRequest, ConnectRequest, Connection, ConnectionList, DayTotalList, DiagnosticsState, DietaryQuantityList, Empty, HealthAccess, HeartRateEntryList, HeartRateList, HydrationList, IntradaySampleList, LastDeliveryResult, MarkCompleteRequest, MenstrualEventList, MenstruationFlowDayList, NutritionEntryList, PermissionGrant, PermissionRequest, PlannedWorkoutList, RangeRequest, RecordIdList, RecordIdRequest, RestingHeartRateList, SleepEntryList, SleepSegmentList, SourceRequest, StatusResult, StatusesResult, StepCountList, StepEntryList, SupportReport, TokenProviderRequest, TokenRejectRequest, TokenResolveRequest, WorkoutEntryList, WorkoutIntensityList, WorkoutList, WorkoutRouteList, WorkoutScheduling } from "./types";
|
|
5
|
-
import { encodeBodyEntryList, encodeCategoryRequest, encodeConnectRequest, encodeEmpty, encodeHeartRateEntryList, encodeMarkCompleteRequest, encodeNutritionEntryList, encodePermissionRequest, encodeRangeRequest, encodeRecordIdRequest, encodeSleepEntryList, encodeSourceRequest, encodeStepEntryList, encodeTokenProviderRequest, encodeTokenRejectRequest, encodeTokenResolveRequest, encodeWorkoutEntryList, decodeAthleteProfileResult, decodeAvailabilityResult, decodeBodyReadingList, decodeBoolResult, decodeBootstrapState, decodeConnection, decodeConnectionList, decodeDayTotalList, decodeDiagnosticsState, decodeDietaryQuantityList, decodeEmpty, decodeHealthAccess, decodeHeartRateList, decodeHydrationList, decodeIntradaySampleList, decodeLastDeliveryResult, decodeMenstrualEventList, decodeMenstruationFlowDayList, decodePermissionGrant, decodePlannedWorkoutList, decodeRecordIdList, decodeRestingHeartRateList, decodeSleepSegmentList, decodeStatusResult, decodeStatusesResult, decodeStepCountList, decodeSupportReport, decodeWorkoutIntensityList, decodeWorkoutList, decodeWorkoutRouteList, decodeWorkoutScheduling } from "./codecs";
|
|
4
|
+
import type { AthleteProfileResult, AvailabilityResult, BodyEntryList, BodyReadingList, BoolResult, BootstrapState, CategoryRequest, ConnectRequest, Connection, ConnectionList, DataTypeRequest, DayTotalList, DevIdBinding, DevIdBindingList, DevIdRequest, DiagnosticsState, DietaryQuantityList, Empty, HealthAccess, HeartRateEntryList, HeartRateList, HydrationList, IntradaySampleList, LastDeliveryResult, LinkDevIdRequest, LinkedDevIdsRequest, MarkCompleteRequest, MenstrualEventList, MenstruationFlowDayList, NutritionEntryList, PermissionGrant, PermissionRequest, PlannedWorkoutList, RangeRequest, RecordIdList, RecordIdRequest, RestingHeartRateList, SleepEntryList, SleepSegmentList, SourceRequest, StatusResult, StatusesResult, StepCountList, StepEntryList, SupportReport, TokenProviderRequest, TokenRejectRequest, TokenResolveRequest, WorkoutEntryList, WorkoutIntensityList, WorkoutList, WorkoutRouteList, WorkoutScheduling } from "./types";
|
|
5
|
+
import { encodeBodyEntryList, encodeCategoryRequest, encodeConnectRequest, encodeDataTypeRequest, encodeDevIdRequest, encodeEmpty, encodeHeartRateEntryList, encodeLinkDevIdRequest, encodeLinkedDevIdsRequest, encodeMarkCompleteRequest, encodeNutritionEntryList, encodePermissionRequest, encodeRangeRequest, encodeRecordIdRequest, encodeSleepEntryList, encodeSourceRequest, encodeStepEntryList, encodeTokenProviderRequest, encodeTokenRejectRequest, encodeTokenResolveRequest, encodeWorkoutEntryList, decodeAthleteProfileResult, decodeAvailabilityResult, decodeBodyReadingList, decodeBoolResult, decodeBootstrapState, decodeConnection, decodeConnectionList, decodeDayTotalList, decodeDevIdBinding, decodeDevIdBindingList, decodeDiagnosticsState, decodeDietaryQuantityList, decodeEmpty, decodeHealthAccess, decodeHeartRateList, decodeHydrationList, decodeIntradaySampleList, decodeLastDeliveryResult, decodeMenstrualEventList, decodeMenstruationFlowDayList, decodePermissionGrant, decodePlannedWorkoutList, decodeRecordIdList, decodeRestingHeartRateList, decodeSleepSegmentList, decodeStatusResult, decodeStatusesResult, decodeStepCountList, decodeSupportReport, decodeWorkoutIntensityList, decodeWorkoutList, decodeWorkoutRouteList, decodeWorkoutScheduling } from "./codecs";
|
|
6
6
|
import type { OpId } from "./ops";
|
|
7
7
|
import { TerraError } from "../TerraError";
|
|
8
8
|
|
|
@@ -69,6 +69,31 @@ export class GeneratedClient {
|
|
|
69
69
|
return this.call("client.disconnect", () => encodeSourceRequest(request), (raw) => decodeEmpty(raw, "Empty"));
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Multi-dev-id mode only: links one customer's connection to the installation's shared device
|
|
74
|
+
* link. The first customer links the installation; every later one joins it, keeping one read
|
|
75
|
+
* and one upload.
|
|
76
|
+
*/
|
|
77
|
+
async clientLinkDevId(request: LinkDevIdRequest): Promise<DevIdBinding> {
|
|
78
|
+
return this.call("client.linkDevId", () => encodeLinkDevIdRequest(request), (raw) => decodeDevIdBinding(raw, "DevIdBinding"));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Multi-dev-id mode only: stops delivering to one customer's connection and leaves the others
|
|
83
|
+
* linked. The last customer's unlink disconnects the installation.
|
|
84
|
+
*/
|
|
85
|
+
async clientUnlinkDevId(request: DevIdRequest): Promise<Empty> {
|
|
86
|
+
return this.call("client.unlinkDevId", () => encodeDevIdRequest(request), (raw) => decodeEmpty(raw, "Empty"));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Multi-dev-id mode only: the customers currently linked, in the order they linked, gone ones
|
|
91
|
+
* included (active false). refresh asks Terra first.
|
|
92
|
+
*/
|
|
93
|
+
async clientLinkedDevIds(request: LinkedDevIdsRequest): Promise<DevIdBindingList> {
|
|
94
|
+
return this.call("client.linkedDevIds", () => encodeLinkedDevIdsRequest(request), (raw) => decodeDevIdBindingList(raw, "DevIdBindingList"));
|
|
95
|
+
}
|
|
96
|
+
|
|
72
97
|
/**
|
|
73
98
|
* Tells the broker whether JS can answer at all. Without it a link asks a provider that is not
|
|
74
99
|
* there and waits out the timeout.
|
|
@@ -97,6 +122,16 @@ export class GeneratedClient {
|
|
|
97
122
|
return this.call("permissions.status", () => encodeCategoryRequest(request), (raw) => decodeStatusResult(raw, "StatusResult"));
|
|
98
123
|
}
|
|
99
124
|
|
|
125
|
+
/**
|
|
126
|
+
* One type's read status. iOS answers notDisclosed wherever the OS has the type, because
|
|
127
|
+
* HealthKit never reports a read decision; Android answers granted once any permission behind
|
|
128
|
+
* the type is granted, denied when it was asked for and none is, and notDetermined when it
|
|
129
|
+
* never was.
|
|
130
|
+
*/
|
|
131
|
+
async permissionsTypeStatus(request: DataTypeRequest): Promise<StatusResult> {
|
|
132
|
+
return this.call("permissions.typeStatus", () => encodeDataTypeRequest(request), (raw) => decodeStatusResult(raw, "StatusResult"));
|
|
133
|
+
}
|
|
134
|
+
|
|
100
135
|
async permissionsWriteStatus(request: CategoryRequest): Promise<StatusResult> {
|
|
101
136
|
return this.call("permissions.writeStatus", () => encodeCategoryRequest(request), (raw) => decodeStatusResult(raw, "StatusResult"));
|
|
102
137
|
}
|
|
@@ -105,6 +140,18 @@ export class GeneratedClient {
|
|
|
105
140
|
return this.call("permissions.requested", () => encodeSourceRequest(request), (raw) => decodeHealthAccess(raw, "HealthAccess"));
|
|
106
141
|
}
|
|
107
142
|
|
|
143
|
+
/**
|
|
144
|
+
* Shows HealthKit's Health Records sheet, on its own. The host needs the Clinical Health
|
|
145
|
+
* Records entitlement, both NSHealthShareUsageDescription and
|
|
146
|
+
* NSHealthClinicalHealthRecordsShareUsageDescription, and CLINICAL_RECORD enabled for the
|
|
147
|
+
* Terra client in Terra's dashboard.
|
|
148
|
+
*
|
|
149
|
+
* Available on ios only.
|
|
150
|
+
*/
|
|
151
|
+
async permissionsRequestClinicalRecords(request: Empty): Promise<Empty> {
|
|
152
|
+
return this.call("permissions.requestClinicalRecords", () => encodeEmpty(request), (raw) => decodeEmpty(raw, "Empty"));
|
|
153
|
+
}
|
|
154
|
+
|
|
108
155
|
/** Available on android only. */
|
|
109
156
|
async permissionsStatuses(request: SourceRequest): Promise<StatusesResult> {
|
|
110
157
|
return this.call("permissions.statuses", () => encodeSourceRequest(request), (raw) => decodeStatusesResult(raw, "StatusesResult"));
|
package/src/generated/codecs.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Generated from surface/terra-surface.json by surface/gen. Do not edit by hand.
|
|
2
2
|
// Regenerate with: node surface/gen/src/cli.ts generate
|
|
3
3
|
|
|
4
|
-
import type { Source, DataCategory, PermissionStatus, MotionContext, Nutrient, MealType, MenstruationFlow, BiologicalSex, ActivityMoveMode, BackgroundRestrictionReason, DiagnosticsReason, DeviceKeyRevokeOutcome, FailureCode, WorkoutSchedulingStatus, DayTotalMetric, IntradayMetric, WorkoutIntensityMetric, BodyMetric, BloodGlucoseUnit, GlucoseMealTime, GlucoseSpecimen, BodyTemperatureMetric, HeartRateVariabilityMetric, VO2MaxTestType, MenstrualEventKind, EndUser, TimeRange, SleepStage, WorkoutActivity, DiagnosticsState, StreamMessage, BodyReadingKind, StoreAvailability, SampleSource, Connection, HeartRateSample, StepCount, SleepSegment, Workout, DietaryQuantity, MenstruationFlowDay, AthleteProfile, HealthChange, WorkoutScope, HealthAccess, HeartRateEntry, StepEntry, SleepEntry, WorkoutEntry, BodyEntry, Nutrients, NutritionEntry, TerraErrorPayload, PlannedWorkout, TerraEvent, SupportReport, BootstrapState, TokenRequest, Empty, SourceRequest, RangeRequest, CategoryRequest, RecordIdRequest, ConnectRequest, PermissionRequest, PermissionGrant, TokenResolveRequest, TokenRejectRequest, TokenProviderRequest, MarkCompleteRequest, BoolResult, StatusResult, StatusesResult, RecordIdList, ConnectionList, HeartRateList, StepCountList, SleepSegmentList, WorkoutList, DietaryQuantityList, MenstruationFlowDayList, MenstrualEvent, MenstrualEventList, AthleteProfileResult, PlannedWorkoutList, WorkoutScheduling, LastDeliveryResult, HeartRateEntryList, BodyEntryList, StepEntryList, SleepEntryList, WorkoutEntryList, NutritionEntryList, DayTotal, IntradaySample, RestingHeartRateSample, BodyReading, RoutePoint, WorkoutRoute, WorkoutIntensitySample, HydrationSample, DayTotalList, IntradaySampleList, RestingHeartRateList, BodyReadingList, WorkoutRouteList, WorkoutIntensityList, HydrationList, AvailabilityResult } from "./types";
|
|
4
|
+
import type { Source, DataCategory, HealthDataType, PermissionStatus, MotionContext, Nutrient, MealType, MenstruationFlow, BiologicalSex, ActivityMoveMode, BackgroundRestrictionReason, DiagnosticsReason, DeviceKeyRevokeOutcome, FailureCode, WorkoutSchedulingStatus, DayTotalMetric, IntradayMetric, WorkoutIntensityMetric, BodyMetric, BloodGlucoseUnit, GlucoseMealTime, GlucoseSpecimen, BodyTemperatureMetric, HeartRateVariabilityMetric, VO2MaxTestType, MenstrualEventKind, EndUser, TimeRange, SleepStage, WorkoutActivity, DiagnosticsState, StreamMessage, BodyReadingKind, StoreAvailability, SampleSource, Connection, HeartRateSample, StepCount, SleepSegment, Workout, DietaryQuantity, MenstruationFlowDay, AthleteProfile, HealthChange, WorkoutScope, HealthAccess, HeartRateEntry, StepEntry, SleepEntry, WorkoutEntry, BodyEntry, Nutrients, NutritionEntry, TerraErrorPayload, PlannedWorkout, TerraEvent, SupportReport, BootstrapState, TokenRequest, Empty, SourceRequest, RangeRequest, CategoryRequest, DataTypeRequest, RecordIdRequest, ConnectRequest, PermissionRequest, PermissionGrant, TokenResolveRequest, TokenRejectRequest, TokenProviderRequest, MarkCompleteRequest, LinkDevIdRequest, DevIdRequest, DevIdBinding, LinkedDevIdsRequest, DevIdBindingList, BoolResult, StatusResult, StatusesResult, RecordIdList, ConnectionList, HeartRateList, StepCountList, SleepSegmentList, WorkoutList, DietaryQuantityList, MenstruationFlowDayList, MenstrualEvent, MenstrualEventList, AthleteProfileResult, PlannedWorkoutList, WorkoutScheduling, LastDeliveryResult, HeartRateEntryList, BodyEntryList, StepEntryList, SleepEntryList, WorkoutEntryList, NutritionEntryList, DayTotal, IntradaySample, RestingHeartRateSample, BodyReading, RoutePoint, WorkoutRoute, WorkoutIntensitySample, HydrationSample, DayTotalList, IntradaySampleList, RestingHeartRateList, BodyReadingList, WorkoutRouteList, WorkoutIntensityList, HydrationList, AvailabilityResult } from "./types";
|
|
5
5
|
|
|
6
6
|
function encodeInstant(value: Date): string {
|
|
7
7
|
return value.toISOString();
|
|
@@ -81,7 +81,7 @@ export function asSource(value: unknown, at = "Source"): Source {
|
|
|
81
81
|
return value as Source;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
const DataCategoryCases: ReadonlySet<string> = new Set(["activity", "body", "daily", "sleep", "nutrition", "menstruation", "athlete"]);
|
|
84
|
+
const DataCategoryCases: ReadonlySet<string> = new Set(["activity", "body", "daily", "sleep", "nutrition", "menstruation", "athlete", "clinicalRecord"]);
|
|
85
85
|
|
|
86
86
|
/** Narrows an untyped value to DataCategory, or throws naming the field. */
|
|
87
87
|
export function asDataCategory(value: unknown, at = "DataCategory"): DataCategory {
|
|
@@ -91,6 +91,16 @@ export function asDataCategory(value: unknown, at = "DataCategory"): DataCategor
|
|
|
91
91
|
return value as DataCategory;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
const HealthDataTypeCases: ReadonlySet<string> = new Set(["steps", "activeEnergy", "basalEnergy", "distance", "floorsClimbed", "swimmingStrokes", "exerciseTime", "moveTime", "standTime", "heartRate", "restingHeartRate", "sleepAnalysis", "workouts", "workoutRoute", "speed", "power", "cyclingCadence", "weight", "height", "bmi", "bodyFat", "leanBodyMass", "waistCircumference", "bloodPressure", "bloodGlucose", "oxygenSaturation", "bodyTemperature", "heartRateVariability", "respiratoryRate", "vo2Max", "insulinDelivery", "heartbeatSeries", "electrocardiogram", "dietaryEnergyConsumed", "dietaryProtein", "dietaryCarbohydrates", "dietaryFatTotal", "dietaryFatSaturated", "dietaryFatMonounsaturated", "dietaryFatPolyunsaturated", "dietarySugar", "dietaryFiber", "dietaryCholesterol", "dietarySodium", "dietaryPotassium", "dietaryCalcium", "dietaryIron", "dietaryMagnesium", "dietaryZinc", "dietaryPhosphorus", "dietaryIodine", "dietaryManganese", "dietaryMolybdenum", "dietarySelenium", "dietaryCopper", "dietaryChromium", "dietaryChloride", "dietaryCaffeine", "dietaryVitaminA", "dietaryVitaminC", "dietaryVitaminD", "dietaryVitaminE", "dietaryVitaminK", "dietaryVitaminB6", "dietaryVitaminB12", "dietaryThiamin", "dietaryRiboflavin", "dietaryNiacin", "dietaryFolate", "dietaryBiotin", "dietaryPantothenicAcid", "dietaryWater", "menstrualFlow", "intermenstrualBleeding", "ovulationTest", "cervicalMucus", "sexualActivity", "pregnancyTest", "progesteroneTest", "pregnancy", "lactation", "contraceptive", "persistentIntermenstrualBleeding", "infrequentCycles", "irregularCycles", "prolongedPeriods", "bleedingDuringPregnancy", "bleedingAfterPregnancy", "biologicalSex", "dateOfBirth", "wheelchairUse", "activityMoveMode", "boneMass", "bodyWaterMass"]);
|
|
95
|
+
|
|
96
|
+
/** Narrows an untyped value to HealthDataType, or throws naming the field. */
|
|
97
|
+
export function asHealthDataType(value: unknown, at = "HealthDataType"): HealthDataType {
|
|
98
|
+
if (typeof value !== "string" || !HealthDataTypeCases.has(value)) {
|
|
99
|
+
throw new TypeError(`${at}: ${String(value)} is not a HealthDataType`);
|
|
100
|
+
}
|
|
101
|
+
return value as HealthDataType;
|
|
102
|
+
}
|
|
103
|
+
|
|
94
104
|
const PermissionStatusCases: ReadonlySet<string> = new Set(["granted", "denied", "notDetermined", "notDisclosed", "unsupported", "unavailable"]);
|
|
95
105
|
|
|
96
106
|
/** Narrows an untyped value to PermissionStatus, or throws naming the field. */
|
|
@@ -193,7 +203,7 @@ export function asDeviceKeyRevokeOutcome(value: unknown, at = "DeviceKeyRevokeOu
|
|
|
193
203
|
return value as DeviceKeyRevokeOutcome;
|
|
194
204
|
}
|
|
195
205
|
|
|
196
|
-
const FailureCodeCases: ReadonlySet<string> = new Set(["healthDataUnavailable", "notConnected", "tokenUnavailable", "tokenRejected", "tokenProviderFailed", "offline", "timedOut", "serverError", "transport", "malformedResponse", "userLimitReached", "upgradeRequired", "platform", "deviceKeyUnavailable", "signatureRejected", "linkRevoked", "linkConflict", "clockSkewed", "devIDMismatch", "syncAlreadyRunning", "linkAlreadyRunning", "storeLocked", "storeUnreadable", "deadlineExceeded", "permissionDenied", "authorizationNotDetermined", "sampleNotFound", "rollbackIncomplete", "distanceNotAttributable", "bloodPressureIncomplete", "authorizationUnavailableInExtension", "routeAwaitingConverter", "readQuotaExceeded", "plannedWorkoutUnnamed"]);
|
|
206
|
+
const FailureCodeCases: ReadonlySet<string> = new Set(["healthDataUnavailable", "notConnected", "tokenUnavailable", "tokenRejected", "tokenProviderFailed", "offline", "timedOut", "serverError", "transport", "malformedResponse", "userLimitReached", "upgradeRequired", "platform", "deviceKeyUnavailable", "signatureRejected", "linkRevoked", "linkConflict", "clockSkewed", "devIDMismatch", "syncAlreadyRunning", "linkAlreadyRunning", "storeLocked", "storeUnreadable", "deadlineExceeded", "permissionDenied", "authorizationNotDetermined", "sampleNotFound", "rollbackIncomplete", "distanceNotAttributable", "workoutsRequired", "bloodPressureIncomplete", "authorizationUnavailableInExtension", "routeAwaitingConverter", "dataTypeNotEnabled", "linkRefused", "readQuotaExceeded", "plannedWorkoutUnnamed"]);
|
|
197
207
|
|
|
198
208
|
/** Narrows an untyped value to FailureCode, or throws naming the field. */
|
|
199
209
|
export function asFailureCode(value: unknown, at = "FailureCode"): FailureCode {
|
|
@@ -576,6 +586,7 @@ export function encodeHealthAccess(value: HealthAccess): Record<string, unknown>
|
|
|
576
586
|
out.read = caseSet(value.read);
|
|
577
587
|
out.write = caseSet(value.write);
|
|
578
588
|
out.workouts = value.workouts.map((item) => encodeWorkoutScope(item));
|
|
589
|
+
if (value.readTypes !== undefined) out.readTypes = value.readTypes;
|
|
579
590
|
return out;
|
|
580
591
|
}
|
|
581
592
|
|
|
@@ -584,7 +595,8 @@ export function decodeHealthAccess(raw: unknown, at$ = "HealthAccess"): HealthAc
|
|
|
584
595
|
const read = caseSet(asArray(object.read, `${at$}.read`).map((item, index) => asDataCategory(item, `${`${at$}.read`}[${index}]`)));
|
|
585
596
|
const write = caseSet(asArray(object.write, `${at$}.write`).map((item, index) => asDataCategory(item, `${`${at$}.write`}[${index}]`)));
|
|
586
597
|
const workouts = asArray(object.workouts, `${at$}.workouts`).map((item, index) => decodeWorkoutScope(item, `${`${at$}.workouts`}[${index}]`));
|
|
587
|
-
|
|
598
|
+
const readTypes = optional(object.readTypes, (value) => asArray(value, `${at$}.readTypes`).map((item, index) => asHealthDataType(item, `${`${at$}.readTypes`}[${index}]`)));
|
|
599
|
+
return { read, write, workouts, readTypes };
|
|
588
600
|
}
|
|
589
601
|
|
|
590
602
|
export function encodeHeartRateEntry(value: HeartRateEntry): Record<string, unknown> {
|
|
@@ -893,6 +905,7 @@ export function encodeBootstrapState(value: BootstrapState): Record<string, unkn
|
|
|
893
905
|
out.platform = value.platform;
|
|
894
906
|
out.sdkVersion = value.sdkVersion;
|
|
895
907
|
out.backgroundRegistered = value.backgroundRegistered;
|
|
908
|
+
if (value.devIdMode !== undefined) out.devIdMode = value.devIdMode;
|
|
896
909
|
return out;
|
|
897
910
|
}
|
|
898
911
|
|
|
@@ -903,7 +916,8 @@ export function decodeBootstrapState(raw: unknown, at$ = "BootstrapState"): Boot
|
|
|
903
916
|
const platform = asString(object.platform, `${at$}.platform`);
|
|
904
917
|
const sdkVersion = asString(object.sdkVersion, `${at$}.sdkVersion`);
|
|
905
918
|
const backgroundRegistered = asBoolean(object.backgroundRegistered, `${at$}.backgroundRegistered`);
|
|
906
|
-
|
|
919
|
+
const devIdMode = optional(object.devIdMode, (value) => asString(value, `${at$}.devIdMode`));
|
|
920
|
+
return { bootstrapped, devId, platform, sdkVersion, backgroundRegistered, devIdMode };
|
|
907
921
|
}
|
|
908
922
|
|
|
909
923
|
export function encodeTokenRequest(value: TokenRequest): Record<string, unknown> {
|
|
@@ -965,6 +979,20 @@ export function decodeCategoryRequest(raw: unknown, at$ = "CategoryRequest"): Ca
|
|
|
965
979
|
return { category, source };
|
|
966
980
|
}
|
|
967
981
|
|
|
982
|
+
export function encodeDataTypeRequest(value: DataTypeRequest): Record<string, unknown> {
|
|
983
|
+
const out: Record<string, unknown> = {};
|
|
984
|
+
out.type = value.type;
|
|
985
|
+
if (value.source !== undefined) out.source = value.source;
|
|
986
|
+
return out;
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
export function decodeDataTypeRequest(raw: unknown, at$ = "DataTypeRequest"): DataTypeRequest {
|
|
990
|
+
const object = asObject(raw, at$);
|
|
991
|
+
const type = asHealthDataType(object.type, `${at$}.type`);
|
|
992
|
+
const source = optional(object.source, (value) => asSource(value, `${at$}.source`));
|
|
993
|
+
return { type, source };
|
|
994
|
+
}
|
|
995
|
+
|
|
968
996
|
export function encodeRecordIdRequest(value: RecordIdRequest): Record<string, unknown> {
|
|
969
997
|
const out: Record<string, unknown> = {};
|
|
970
998
|
out.id = value.id;
|
|
@@ -999,6 +1027,7 @@ export function encodePermissionRequest(value: PermissionRequest): Record<string
|
|
|
999
1027
|
out.write = caseSet(value.write);
|
|
1000
1028
|
out.workouts = value.workouts.map((item) => encodeWorkoutScope(item));
|
|
1001
1029
|
if (value.source !== undefined) out.source = value.source;
|
|
1030
|
+
if (value.readTypes !== undefined) out.readTypes = value.readTypes;
|
|
1002
1031
|
return out;
|
|
1003
1032
|
}
|
|
1004
1033
|
|
|
@@ -1008,7 +1037,8 @@ export function decodePermissionRequest(raw: unknown, at$ = "PermissionRequest")
|
|
|
1008
1037
|
const write = caseSet(asArray(object.write, `${at$}.write`).map((item, index) => asDataCategory(item, `${`${at$}.write`}[${index}]`)));
|
|
1009
1038
|
const workouts = asArray(object.workouts, `${at$}.workouts`).map((item, index) => decodeWorkoutScope(item, `${`${at$}.workouts`}[${index}]`));
|
|
1010
1039
|
const source = optional(object.source, (value) => asSource(value, `${at$}.source`));
|
|
1011
|
-
|
|
1040
|
+
const readTypes = optional(object.readTypes, (value) => asArray(value, `${at$}.readTypes`).map((item, index) => asHealthDataType(item, `${`${at$}.readTypes`}[${index}]`)));
|
|
1041
|
+
return { read, write, workouts, source, readTypes };
|
|
1012
1042
|
}
|
|
1013
1043
|
|
|
1014
1044
|
export function encodePermissionGrant(value: PermissionGrant): Record<string, unknown> {
|
|
@@ -1079,6 +1109,82 @@ export function decodeMarkCompleteRequest(raw: unknown, at$ = "MarkCompleteReque
|
|
|
1079
1109
|
return { id, at };
|
|
1080
1110
|
}
|
|
1081
1111
|
|
|
1112
|
+
export function encodeLinkDevIdRequest(value: LinkDevIdRequest): Record<string, unknown> {
|
|
1113
|
+
const out: Record<string, unknown> = {};
|
|
1114
|
+
out.devId = value.devId;
|
|
1115
|
+
out.token = value.token;
|
|
1116
|
+
if (value.source !== undefined) out.source = value.source;
|
|
1117
|
+
return out;
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
export function decodeLinkDevIdRequest(raw: unknown, at$ = "LinkDevIdRequest"): LinkDevIdRequest {
|
|
1121
|
+
const object = asObject(raw, at$);
|
|
1122
|
+
const devId = asString(object.devId, `${at$}.devId`);
|
|
1123
|
+
const token = asString(object.token, `${at$}.token`);
|
|
1124
|
+
const source = optional(object.source, (value) => asSource(value, `${at$}.source`));
|
|
1125
|
+
return { devId, token, source };
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
export function encodeDevIdRequest(value: DevIdRequest): Record<string, unknown> {
|
|
1129
|
+
const out: Record<string, unknown> = {};
|
|
1130
|
+
out.devId = value.devId;
|
|
1131
|
+
if (value.source !== undefined) out.source = value.source;
|
|
1132
|
+
return out;
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
export function decodeDevIdRequest(raw: unknown, at$ = "DevIdRequest"): DevIdRequest {
|
|
1136
|
+
const object = asObject(raw, at$);
|
|
1137
|
+
const devId = asString(object.devId, `${at$}.devId`);
|
|
1138
|
+
const source = optional(object.source, (value) => asSource(value, `${at$}.source`));
|
|
1139
|
+
return { devId, source };
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
export function encodeDevIdBinding(value: DevIdBinding): Record<string, unknown> {
|
|
1143
|
+
const out: Record<string, unknown> = {};
|
|
1144
|
+
out.devId = value.devId;
|
|
1145
|
+
out.userId = value.userId;
|
|
1146
|
+
if (value.dataTypes !== undefined) out.dataTypes = value.dataTypes;
|
|
1147
|
+
out.linkedAt = encodeInstant(value.linkedAt);
|
|
1148
|
+
out.active = value.active;
|
|
1149
|
+
return out;
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
export function decodeDevIdBinding(raw: unknown, at$ = "DevIdBinding"): DevIdBinding {
|
|
1153
|
+
const object = asObject(raw, at$);
|
|
1154
|
+
const devId = asString(object.devId, `${at$}.devId`);
|
|
1155
|
+
const userId = asString(object.userId, `${at$}.userId`);
|
|
1156
|
+
const dataTypes = optional(object.dataTypes, (value) => asArray(value, `${at$}.dataTypes`).map((item, index) => asString(item, `${`${at$}.dataTypes`}[${index}]`)));
|
|
1157
|
+
const linkedAt = decodeInstant(object.linkedAt, `${at$}.linkedAt`);
|
|
1158
|
+
const active = asBoolean(object.active, `${at$}.active`);
|
|
1159
|
+
return { devId, userId, dataTypes, linkedAt, active };
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
export function encodeLinkedDevIdsRequest(value: LinkedDevIdsRequest): Record<string, unknown> {
|
|
1163
|
+
const out: Record<string, unknown> = {};
|
|
1164
|
+
if (value.source !== undefined) out.source = value.source;
|
|
1165
|
+
if (value.refresh !== undefined) out.refresh = value.refresh;
|
|
1166
|
+
return out;
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
export function decodeLinkedDevIdsRequest(raw: unknown, at$ = "LinkedDevIdsRequest"): LinkedDevIdsRequest {
|
|
1170
|
+
const object = asObject(raw, at$);
|
|
1171
|
+
const source = optional(object.source, (value) => asSource(value, `${at$}.source`));
|
|
1172
|
+
const refresh = optional(object.refresh, (value) => asBoolean(value, `${at$}.refresh`));
|
|
1173
|
+
return { source, refresh };
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
export function encodeDevIdBindingList(value: DevIdBindingList): Record<string, unknown> {
|
|
1177
|
+
const out: Record<string, unknown> = {};
|
|
1178
|
+
out.bindings = value.bindings.map((item) => encodeDevIdBinding(item));
|
|
1179
|
+
return out;
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
export function decodeDevIdBindingList(raw: unknown, at$ = "DevIdBindingList"): DevIdBindingList {
|
|
1183
|
+
const object = asObject(raw, at$);
|
|
1184
|
+
const bindings = asArray(object.bindings, `${at$}.bindings`).map((item, index) => decodeDevIdBinding(item, `${`${at$}.bindings`}[${index}]`));
|
|
1185
|
+
return { bindings };
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1082
1188
|
export function encodeBoolResult(value: BoolResult): Record<string, unknown> {
|
|
1083
1189
|
const out: Record<string, unknown> = {};
|
|
1084
1190
|
out.value = value.value;
|
package/src/generated/errors.ts
CHANGED
|
@@ -6,6 +6,7 @@ export type TerraErrorCode =
|
|
|
6
6
|
| "health_data_unavailable" // ios+android
|
|
7
7
|
| "not_connected" // ios+android
|
|
8
8
|
| "route_awaiting_converter" // ios+android
|
|
9
|
+
| "data_type_not_enabled" // ios
|
|
9
10
|
| "token_unavailable" // ios+android
|
|
10
11
|
| "token_rejected" // ios+android
|
|
11
12
|
| "token_provider_failed" // ios+android
|
|
@@ -18,6 +19,7 @@ export type TerraErrorCode =
|
|
|
18
19
|
| "link_revoked" // ios+android
|
|
19
20
|
| "dev_id_mismatch" // ios+android
|
|
20
21
|
| "link_conflict" // ios+android
|
|
22
|
+
| "link_refused" // ios+android
|
|
21
23
|
| "sync_already_running" // ios+android
|
|
22
24
|
| "link_already_running" // ios+android
|
|
23
25
|
| "store_locked" // ios+android
|
|
@@ -29,8 +31,11 @@ export type TerraErrorCode =
|
|
|
29
31
|
| "sample_not_found" // ios+android
|
|
30
32
|
| "rollback_incomplete" // ios+android
|
|
31
33
|
| "distance_not_attributable" // ios+android
|
|
34
|
+
| "workouts_required" // ios+android
|
|
32
35
|
| "blood_pressure_incomplete" // ios+android
|
|
33
36
|
| "authorization_unavailable_in_extension" // ios+android
|
|
37
|
+
| "health_records_unavailable" // ios
|
|
38
|
+
| "health_records_usage_description_missing" // ios
|
|
34
39
|
| "planned_workout_unnamed" // ios
|
|
35
40
|
| "network.transport" // ios+android
|
|
36
41
|
| "network.throttled" // ios+android
|
|
@@ -55,6 +60,7 @@ export const retryableByCode: Readonly<Record<TerraErrorCode, boolean | 'carried
|
|
|
55
60
|
"health_data_unavailable": false,
|
|
56
61
|
"not_connected": false,
|
|
57
62
|
"route_awaiting_converter": false,
|
|
63
|
+
"data_type_not_enabled": false,
|
|
58
64
|
"token_unavailable": false,
|
|
59
65
|
"token_rejected": false,
|
|
60
66
|
"token_provider_failed": false,
|
|
@@ -67,6 +73,7 @@ export const retryableByCode: Readonly<Record<TerraErrorCode, boolean | 'carried
|
|
|
67
73
|
"link_revoked": false,
|
|
68
74
|
"dev_id_mismatch": false,
|
|
69
75
|
"link_conflict": true,
|
|
76
|
+
"link_refused": false,
|
|
70
77
|
"sync_already_running": false,
|
|
71
78
|
"link_already_running": false,
|
|
72
79
|
"store_locked": true,
|
|
@@ -78,8 +85,11 @@ export const retryableByCode: Readonly<Record<TerraErrorCode, boolean | 'carried
|
|
|
78
85
|
"sample_not_found": false,
|
|
79
86
|
"rollback_incomplete": false,
|
|
80
87
|
"distance_not_attributable": false,
|
|
88
|
+
"workouts_required": false,
|
|
81
89
|
"blood_pressure_incomplete": false,
|
|
82
90
|
"authorization_unavailable_in_extension": false,
|
|
91
|
+
"health_records_unavailable": false,
|
|
92
|
+
"health_records_usage_description_missing": false,
|
|
83
93
|
"planned_workout_unnamed": false,
|
|
84
94
|
"network.transport": true,
|
|
85
95
|
"network.throttled": true,
|
|
@@ -107,7 +117,7 @@ export const bridgeOwnedCodes: readonly TerraErrorCode[] = [
|
|
|
107
117
|
|
|
108
118
|
/** Codes only one platform can raise, so that a caller can narrow rather than discover. */
|
|
109
119
|
export const platformOnlyCodes: Readonly<Record<string, readonly TerraErrorCode[]>> = {
|
|
110
|
-
ios: ["planned_workout_unnamed", "network.offline", "network.timed_out"],
|
|
120
|
+
ios: ["data_type_not_enabled", "health_records_unavailable", "health_records_usage_description_missing", "planned_workout_unnamed", "network.offline", "network.timed_out"],
|
|
111
121
|
android: ["read_quota_exceeded", "bridge.no_activity", "bridge.permission_sheet_unavailable"],
|
|
112
122
|
};
|
|
113
123
|
|
package/src/generated/ops.ts
CHANGED
|
@@ -13,13 +13,18 @@ export type OpId =
|
|
|
13
13
|
| "client.connections"
|
|
14
14
|
| "client.availability"
|
|
15
15
|
| "client.disconnect"
|
|
16
|
+
| "client.linkDevId"
|
|
17
|
+
| "client.unlinkDevId"
|
|
18
|
+
| "client.linkedDevIds"
|
|
16
19
|
| "token.setProviderPresent"
|
|
17
20
|
| "token.resolve"
|
|
18
21
|
| "token.reject"
|
|
19
22
|
| "permissions.request"
|
|
20
23
|
| "permissions.status"
|
|
24
|
+
| "permissions.typeStatus"
|
|
21
25
|
| "permissions.writeStatus"
|
|
22
26
|
| "permissions.requested"
|
|
27
|
+
| "permissions.requestClinicalRecords"
|
|
23
28
|
| "permissions.statuses"
|
|
24
29
|
| "permissions.backgroundReadStatus"
|
|
25
30
|
| "permissions.historyReadStatus"
|
|
@@ -68,13 +73,18 @@ export const opIds: readonly OpId[] = [
|
|
|
68
73
|
"client.connections",
|
|
69
74
|
"client.availability",
|
|
70
75
|
"client.disconnect",
|
|
76
|
+
"client.linkDevId",
|
|
77
|
+
"client.unlinkDevId",
|
|
78
|
+
"client.linkedDevIds",
|
|
71
79
|
"token.setProviderPresent",
|
|
72
80
|
"token.resolve",
|
|
73
81
|
"token.reject",
|
|
74
82
|
"permissions.request",
|
|
75
83
|
"permissions.status",
|
|
84
|
+
"permissions.typeStatus",
|
|
76
85
|
"permissions.writeStatus",
|
|
77
86
|
"permissions.requested",
|
|
87
|
+
"permissions.requestClinicalRecords",
|
|
78
88
|
"permissions.statuses",
|
|
79
89
|
"permissions.backgroundReadStatus",
|
|
80
90
|
"permissions.historyReadStatus",
|
|
@@ -123,13 +133,18 @@ export const availableOn: Readonly<Record<OpId, readonly string[]>> = {
|
|
|
123
133
|
"client.connections": ["ios", "android"],
|
|
124
134
|
"client.availability": ["ios", "android"],
|
|
125
135
|
"client.disconnect": ["ios", "android"],
|
|
136
|
+
"client.linkDevId": ["ios", "android"],
|
|
137
|
+
"client.unlinkDevId": ["ios", "android"],
|
|
138
|
+
"client.linkedDevIds": ["ios", "android"],
|
|
126
139
|
"token.setProviderPresent": ["ios", "android"],
|
|
127
140
|
"token.resolve": ["ios", "android"],
|
|
128
141
|
"token.reject": ["ios", "android"],
|
|
129
142
|
"permissions.request": ["ios", "android"],
|
|
130
143
|
"permissions.status": ["ios", "android"],
|
|
144
|
+
"permissions.typeStatus": ["ios", "android"],
|
|
131
145
|
"permissions.writeStatus": ["ios", "android"],
|
|
132
146
|
"permissions.requested": ["ios", "android"],
|
|
147
|
+
"permissions.requestClinicalRecords": ["ios"],
|
|
133
148
|
"permissions.statuses": ["android"],
|
|
134
149
|
"permissions.backgroundReadStatus": ["android"],
|
|
135
150
|
"permissions.historyReadStatus": ["android"],
|
|
@@ -222,6 +237,8 @@ export const eventKinds: Readonly<Record<string, readonly string[]>> = {
|
|
|
222
237
|
"plannedWorkoutsScheduled": ["ios"],
|
|
223
238
|
"plannedWorkoutScheduleFailed": ["ios"],
|
|
224
239
|
"sleepWakeDateTooLarge": ["ios"],
|
|
240
|
+
"clinicalRecordTooLarge": ["ios"],
|
|
241
|
+
"devIDBindingChanged": ["ios", "android"],
|
|
225
242
|
"backgroundWorkGap": ["android"],
|
|
226
243
|
"backgroundWorkReset": ["android"],
|
|
227
244
|
"changeTokenExpired": ["android"],
|