@tryterra/react-native 0.0.0-stage → 2.2.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.
Files changed (112) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +142 -2
  3. package/TerraReactNative.podspec +48 -0
  4. package/android/build.gradle +87 -0
  5. package/android/src/bridgeCore/kotlin/README.md +1 -0
  6. package/android/src/bridgeCore/kotlin/co/tryterra/sdk/bridge/BridgeBootstrap.kt +133 -0
  7. package/android/src/bridgeCore/kotlin/co/tryterra/sdk/bridge/BridgeHost.kt +32 -0
  8. package/android/src/bridgeCore/kotlin/co/tryterra/sdk/bridge/Conversions.kt +557 -0
  9. package/android/src/bridgeCore/kotlin/co/tryterra/sdk/bridge/LauncherSlots.kt +41 -0
  10. package/android/src/bridgeCore/kotlin/co/tryterra/sdk/bridge/ReadConversions.kt +250 -0
  11. package/android/src/bridgeCore/kotlin/co/tryterra/sdk/bridge/Rejections.kt +150 -0
  12. package/android/src/bridgeCore/kotlin/co/tryterra/sdk/bridge/StreamRegistry.kt +77 -0
  13. package/android/src/bridgeCore/kotlin/co/tryterra/sdk/bridge/TerraBridge.kt +86 -0
  14. package/android/src/bridgeCore/kotlin/co/tryterra/sdk/bridge/TerraBridgeOpsImpl.kt +300 -0
  15. package/android/src/bridgeCore/kotlin/co/tryterra/sdk/bridge/TerraBridgeStreamsImpl.kt +50 -0
  16. package/android/src/bridgeCore/kotlin/co/tryterra/sdk/bridge/TokenBroker.kt +198 -0
  17. package/android/src/bridgeCore/kotlin/co/tryterra/sdk/bridge/generated/BridgeErrors.kt +217 -0
  18. package/android/src/bridgeCore/kotlin/co/tryterra/sdk/bridge/generated/BridgeOps.kt +582 -0
  19. package/android/src/bridgeCore/kotlin/co/tryterra/sdk/bridge/generated/BridgeTypes.kt +1569 -0
  20. package/android/src/healthConnectOnly/kotlin/co/tryterra/sdk/reactnative/TerraStores.kt +11 -0
  21. package/android/src/main/AndroidManifest.xml +24 -0
  22. package/android/src/main/java/co/tryterra/sdk/reactnative/TerraBridgeModule.kt +96 -0
  23. package/android/src/main/java/co/tryterra/sdk/reactnative/TerraReactNativePackage.kt +26 -0
  24. package/android/src/main/java/co/tryterra/sdk/reactnative/TerraStartup.kt +46 -0
  25. package/android/src/samsung/kotlin/co/tryterra/sdk/reactnative/TerraStores.kt +13 -0
  26. package/docs/availability.md +396 -0
  27. package/frameworks/TerraSDK.xcframework/Info.plist +48 -0
  28. package/frameworks/TerraSDK.xcframework/ios-arm64/TerraSDK.framework/Info.plist +0 -0
  29. package/frameworks/TerraSDK.xcframework/ios-arm64/TerraSDK.framework/Modules/TerraSDK.swiftmodule/arm64-apple-ios.abi.json +82672 -0
  30. package/frameworks/TerraSDK.xcframework/ios-arm64/TerraSDK.framework/Modules/TerraSDK.swiftmodule/arm64-apple-ios.package.swiftinterface +2186 -0
  31. package/frameworks/TerraSDK.xcframework/ios-arm64/TerraSDK.framework/Modules/TerraSDK.swiftmodule/arm64-apple-ios.private.swiftinterface +2186 -0
  32. package/frameworks/TerraSDK.xcframework/ios-arm64/TerraSDK.framework/Modules/TerraSDK.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  33. package/frameworks/TerraSDK.xcframework/ios-arm64/TerraSDK.framework/Modules/TerraSDK.swiftmodule/arm64-apple-ios.swiftinterface +2163 -0
  34. package/frameworks/TerraSDK.xcframework/ios-arm64/TerraSDK.framework/PrivacyInfo.xcprivacy +96 -0
  35. package/frameworks/TerraSDK.xcframework/ios-arm64/TerraSDK.framework/TerraSDK +0 -0
  36. package/frameworks/TerraSDK.xcframework/ios-arm64/dSYMs/TerraSDK.framework.dSYM/Contents/Info.plist +20 -0
  37. package/frameworks/TerraSDK.xcframework/ios-arm64/dSYMs/TerraSDK.framework.dSYM/Contents/Resources/DWARF/TerraSDK +0 -0
  38. package/frameworks/TerraSDK.xcframework/ios-arm64/dSYMs/TerraSDK.framework.dSYM/Contents/Resources/Relocations/aarch64/TerraSDK.yml +6594 -0
  39. package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/Info.plist +0 -0
  40. package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/Modules/TerraSDK.swiftmodule/arm64-apple-ios-simulator.abi.json +82672 -0
  41. package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/Modules/TerraSDK.swiftmodule/arm64-apple-ios-simulator.package.swiftinterface +2186 -0
  42. package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/Modules/TerraSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +2186 -0
  43. package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/Modules/TerraSDK.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  44. package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/Modules/TerraSDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface +2163 -0
  45. package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/Modules/TerraSDK.swiftmodule/x86_64-apple-ios-simulator.abi.json +82672 -0
  46. package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/Modules/TerraSDK.swiftmodule/x86_64-apple-ios-simulator.package.swiftinterface +2186 -0
  47. package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/Modules/TerraSDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +2186 -0
  48. package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/Modules/TerraSDK.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  49. package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/Modules/TerraSDK.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +2163 -0
  50. package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/PrivacyInfo.xcprivacy +96 -0
  51. package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/TerraSDK +0 -0
  52. package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/_CodeSignature/CodeResources +223 -0
  53. package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/TerraSDK.framework.dSYM/Contents/Info.plist +20 -0
  54. package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/TerraSDK.framework.dSYM/Contents/Resources/DWARF/TerraSDK +0 -0
  55. package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/TerraSDK.framework.dSYM/Contents/Resources/Relocations/aarch64/TerraSDK.yml +6595 -0
  56. package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/TerraSDK.framework.dSYM/Contents/Resources/Relocations/x86_64/TerraSDK.yml +6513 -0
  57. package/ios/TerraBridgeCore/BridgeBootstrap.swift +89 -0
  58. package/ios/TerraBridgeCore/BridgeHost.swift +13 -0
  59. package/ios/TerraBridgeCore/Conversions+Reads.swift +259 -0
  60. package/ios/TerraBridgeCore/Conversions.swift +594 -0
  61. package/ios/TerraBridgeCore/Generated/BridgeErrors.swift +179 -0
  62. package/ios/TerraBridgeCore/Generated/BridgeOps.swift +967 -0
  63. package/ios/TerraBridgeCore/Generated/BridgeTypes.swift +2050 -0
  64. package/ios/TerraBridgeCore/Locked.swift +15 -0
  65. package/ios/TerraBridgeCore/README.md +1 -0
  66. package/ios/TerraBridgeCore/Rejections.swift +130 -0
  67. package/ios/TerraBridgeCore/RuntimeAttachment.swift +60 -0
  68. package/ios/TerraBridgeCore/StreamRegistry.swift +59 -0
  69. package/ios/TerraBridgeCore/TerraBridge.swift +122 -0
  70. package/ios/TerraBridgeCore/TerraBridgeOpsImpl.swift +318 -0
  71. package/ios/TerraBridgeCore/TerraBridgeStreamsImpl.swift +60 -0
  72. package/ios/TerraBridgeCore/TokenBroker.swift +147 -0
  73. package/ios/TerraBridgeModule.mm +79 -0
  74. package/ios/TerraBridgeModuleImpl.swift +49 -0
  75. package/ios/TerraReactNative.swift +19 -0
  76. package/lib/EndUser.d.ts +12 -0
  77. package/lib/EndUser.js +13 -0
  78. package/lib/NativeTerraBridge.d.ts +23 -0
  79. package/lib/NativeTerraBridge.js +13 -0
  80. package/lib/Terra.d.ts +223 -0
  81. package/lib/Terra.js +336 -0
  82. package/lib/TerraError.d.ts +42 -0
  83. package/lib/TerraError.js +95 -0
  84. package/lib/createTerra.d.ts +8 -0
  85. package/lib/createTerra.js +19 -0
  86. package/lib/generated/client.d.ts +128 -0
  87. package/lib/generated/client.js +256 -0
  88. package/lib/generated/codecs.d.ts +219 -0
  89. package/lib/generated/codecs.js +2066 -0
  90. package/lib/generated/errors.d.ts +13 -0
  91. package/lib/generated/errors.js +68 -0
  92. package/lib/generated/ops.d.ts +13 -0
  93. package/lib/generated/ops.js +161 -0
  94. package/lib/generated/streams.d.ts +23 -0
  95. package/lib/generated/streams.js +58 -0
  96. package/lib/generated/types.d.ts +794 -0
  97. package/lib/generated/types.js +224 -0
  98. package/lib/index.d.ts +29 -0
  99. package/lib/index.js +55 -0
  100. package/package.json +71 -4
  101. package/src/EndUser.ts +15 -0
  102. package/src/NativeTerraBridge.ts +27 -0
  103. package/src/Terra.ts +592 -0
  104. package/src/TerraError.ts +116 -0
  105. package/src/createTerra.ts +18 -0
  106. package/src/generated/client.ts +315 -0
  107. package/src/generated/codecs.ts +1989 -0
  108. package/src/generated/errors.ts +113 -0
  109. package/src/generated/ops.ts +233 -0
  110. package/src/generated/streams.ts +74 -0
  111. package/src/generated/types.ts +1222 -0
  112. package/src/index.ts +54 -0
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ /**
3
+ * The error every rejected op carries, hydrated from the bridge's JSON.
4
+ *
5
+ * Hand-written, and one of only two files here that are: the shape is fixed, while the *vocabulary*
6
+ * it carries is generated. `code` is a `TerraErrorCode`, so a code renamed natively stops a
7
+ * `switch` over it compiling rather than silently never matching.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.TerraError = void 0;
11
+ const codecs_1 = require("./generated/codecs");
12
+ const errors_1 = require("./generated/errors");
13
+ class TerraError extends Error {
14
+ constructor(json, options) {
15
+ super(json.message, options);
16
+ this.name = "TerraError";
17
+ const known = isKnownCode(json.code);
18
+ this.code = known ? json.code : "platform";
19
+ this.retryable = known ? (json.retryable ?? fallbackRetryable(json.code)) : false;
20
+ this.source = json.source;
21
+ this.details = known ? json.details : { ...json.details, unrecognisedCode: json.code };
22
+ }
23
+ /**
24
+ * Rebuilds a `TerraError` from whatever the native module rejected with.
25
+ *
26
+ * Anything unrecognisable becomes `platform` rather than being rethrown as-is: a caller that has
27
+ * to handle both `TerraError` and an arbitrary `Error` ends up handling neither properly, and the
28
+ * original is kept as `cause` and its text in `message`.
29
+ */
30
+ static from(thrown) {
31
+ if (thrown instanceof TerraError)
32
+ return thrown;
33
+ const json = readJSON(thrown);
34
+ if (json !== undefined)
35
+ return new TerraError(json, { cause: thrown });
36
+ return new TerraError({ code: "platform", retryable: false, message: messageOf(thrown) }, { cause: thrown });
37
+ }
38
+ /** A response the bridge resolved that this build cannot read: the native side and JS disagree. */
39
+ static invalidPayload(op, thrown) {
40
+ return new TerraError({ code: "bridge.invalid_payload", message: `${op}: ${messageOf(thrown)}`, details: { op } }, { cause: thrown });
41
+ }
42
+ }
43
+ exports.TerraError = TerraError;
44
+ function isKnownCode(code) {
45
+ return Object.prototype.hasOwnProperty.call(errors_1.retryableByCode, code);
46
+ }
47
+ function messageOf(thrown) {
48
+ if (thrown instanceof Error)
49
+ return thrown.message;
50
+ if (isObject(thrown) && typeof thrown.message === "string")
51
+ return thrown.message;
52
+ return String(thrown);
53
+ }
54
+ function fallbackRetryable(code) {
55
+ return errors_1.retryableByCode[code] === true;
56
+ }
57
+ /** A JSON string preserves payload types across `NSError` and `WritableMap`, unlike a nested map. */
58
+ function readJSON(thrown) {
59
+ if (typeof thrown !== "object" || thrown === null)
60
+ return undefined;
61
+ const candidate = thrown;
62
+ const userInfo = candidate.userInfo;
63
+ const encoded = isObject(userInfo) ? userInfo.payload : undefined;
64
+ return (typeof encoded === "string" ? decode(parse(encoded)) : undefined) ?? decode(userInfo) ?? decode(candidate);
65
+ }
66
+ function parse(encoded) {
67
+ try {
68
+ return JSON.parse(encoded);
69
+ }
70
+ catch {
71
+ return undefined;
72
+ }
73
+ }
74
+ /** The generated decoder does the checking: a string code, a boolean flag, a known source. */
75
+ function decode(raw) {
76
+ if (!isObject(raw) || typeof raw.code !== "string")
77
+ return undefined;
78
+ try {
79
+ // Read field by field: an Error's `message` is not enumerable, so spreading one drops it.
80
+ const { retryable, ...rest } = (0, codecs_1.decodeTerraErrorPayload)({
81
+ code: raw.code,
82
+ retryable: raw.retryable ?? false,
83
+ message: raw.message,
84
+ source: raw.source,
85
+ details: raw.details,
86
+ });
87
+ return raw.retryable === undefined ? rest : { ...rest, retryable };
88
+ }
89
+ catch {
90
+ return undefined;
91
+ }
92
+ }
93
+ function isObject(value) {
94
+ return typeof value === "object" && value !== null;
95
+ }
@@ -0,0 +1,8 @@
1
+ import { Terra, type TerraOptions } from "./Terra";
2
+ /**
3
+ * Attaches this JavaScript runtime to the native client the app built at launch.
4
+ *
5
+ * Call it once, at module scope. The native client outlives a reload, so a reload attaches again
6
+ * rather than building a second client.
7
+ */
8
+ export declare function createTerra(options?: TerraOptions): Terra;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createTerra = createTerra;
4
+ const react_native_1 = require("react-native");
5
+ const NativeTerraBridge_1 = require("./NativeTerraBridge");
6
+ const Terra_1 = require("./Terra");
7
+ /**
8
+ * Attaches this JavaScript runtime to the native client the app built at launch.
9
+ *
10
+ * Call it once, at module scope. The native client outlives a reload, so a reload attaches again
11
+ * rather than building a second client.
12
+ */
13
+ function createTerra(options = {}) {
14
+ const platform = react_native_1.Platform.OS;
15
+ if (platform !== "ios" && platform !== "android") {
16
+ throw new Error(`@tryterra/react-native runs on iOS and Android, not ${platform}`);
17
+ }
18
+ return new Terra_1.Terra(NativeTerraBridge_1.default, platform, options);
19
+ }
@@ -0,0 +1,128 @@
1
+ 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";
2
+ import type { OpId } from "./ops";
3
+ /** What the facade needs from the native module. The TurboModule spec satisfies it; so does a test double. */
4
+ export interface Invoker {
5
+ invoke(op: OpId, payload: string): Promise<string>;
6
+ }
7
+ /**
8
+ * One generated method per op, and nothing else.
9
+ *
10
+ * The `op` string exists only between this file and the generated native dispatch, and a vector
11
+ * in `vectors/bridge` pins the two to each other. A caller never sees it.
12
+ */
13
+ export declare class GeneratedClient {
14
+ protected readonly invoker: Invoker;
15
+ constructor(invoker: Invoker);
16
+ private call;
17
+ /**
18
+ * Reports the native client the JS side is attaching to. Idempotent, and safe to call after a
19
+ * JS reload.
20
+ */
21
+ clientAttach(request: Empty): Promise<BootstrapState>;
22
+ clientConnect(request: ConnectRequest): Promise<Connection>;
23
+ clientConnections(request: Empty): Promise<ConnectionList>;
24
+ /** Whether the device can serve the source at all. Needs no connection and prompts for nothing. */
25
+ clientAvailability(request: SourceRequest): Promise<AvailabilityResult>;
26
+ clientDisconnect(request: SourceRequest): Promise<Empty>;
27
+ /**
28
+ * Tells the broker whether JS can answer at all. Without it a link asks a provider that is not
29
+ * there and waits out the timeout.
30
+ */
31
+ tokenSetProviderPresent(request: TokenProviderRequest): Promise<Empty>;
32
+ /**
33
+ * An unknown or already-settled requestId is ignored rather than rejected, so a reload cannot
34
+ * fail a link that has already moved on.
35
+ */
36
+ tokenResolve(request: TokenResolveRequest): Promise<Empty>;
37
+ tokenReject(request: TokenRejectRequest): Promise<Empty>;
38
+ permissionsRequest(request: PermissionRequest): Promise<PermissionGrant>;
39
+ permissionsStatus(request: CategoryRequest): Promise<StatusResult>;
40
+ permissionsWriteStatus(request: CategoryRequest): Promise<StatusResult>;
41
+ permissionsRequested(request: SourceRequest): Promise<HealthAccess>;
42
+ /** Available on android only. */
43
+ permissionsStatuses(request: SourceRequest): Promise<StatusesResult>;
44
+ /** Available on android only. */
45
+ permissionsBackgroundReadStatus(request: SourceRequest): Promise<StatusResult>;
46
+ /** Available on android only. */
47
+ permissionsHistoryReadStatus(request: SourceRequest): Promise<StatusResult>;
48
+ diagnosticsState(request: SourceRequest): Promise<DiagnosticsState>;
49
+ diagnosticsLastDelivery(request: SourceRequest): Promise<LastDeliveryResult>;
50
+ diagnosticsReport(request: SourceRequest): Promise<SupportReport>;
51
+ diagnosticsSend(request: SourceRequest): Promise<Empty>;
52
+ /**
53
+ * False means bootstrap did not run. The SDK reports the same thing independently as
54
+ * backgroundRefreshUnscheduled.
55
+ */
56
+ backgroundIsRegistered(request: Empty): Promise<BoolResult>;
57
+ /** Available on android only. */
58
+ backgroundCancel(request: Empty): Promise<BoolResult>;
59
+ bodyHeartRate(request: RangeRequest): Promise<HeartRateList>;
60
+ /**
61
+ * The store's own daily figures. Health Connect grants them under daily, so Android answers
62
+ * authorization_not_determined where only body was asked for.
63
+ */
64
+ bodyRestingHeartRate(request: RangeRequest): Promise<RestingHeartRateList>;
65
+ bodyReadings(request: RangeRequest): Promise<BodyReadingList>;
66
+ /** Its own op rather than an overload: Swift overloads log by element type and JS cannot. */
67
+ bodyLogHeartRate(request: HeartRateEntryList): Promise<RecordIdList>;
68
+ bodyLog(request: BodyEntryList): Promise<RecordIdList>;
69
+ bodyDelete(request: RecordIdRequest): Promise<Empty>;
70
+ dailySteps(request: RangeRequest): Promise<StepCountList>;
71
+ /**
72
+ * One total per metric per whole local day the range touches. A day with nothing recorded has
73
+ * no total, not a zero.
74
+ */
75
+ dailyTotals(request: RangeRequest): Promise<DayTotalList>;
76
+ /** The active energy, basal energy, distance and floors records the totals are made of. */
77
+ dailyIntraday(request: RangeRequest): Promise<IntradaySampleList>;
78
+ dailyLog(request: StepEntryList): Promise<RecordIdList>;
79
+ dailyDelete(request: RecordIdRequest): Promise<Empty>;
80
+ sleepSegments(request: RangeRequest): Promise<SleepSegmentList>;
81
+ sleepLog(request: SleepEntryList): Promise<RecordIdList>;
82
+ sleepDelete(request: RecordIdRequest): Promise<Empty>;
83
+ activityWorkouts(request: RangeRequest): Promise<WorkoutList>;
84
+ /** The GPS tracks of the workouts in the range, each naming its workout. */
85
+ activityRoutes(request: RangeRequest): Promise<WorkoutRouteList>;
86
+ /** Speed, power and cycling cadence readings in the range. */
87
+ activityIntensity(request: RangeRequest): Promise<WorkoutIntensityList>;
88
+ activityLog(request: WorkoutEntryList): Promise<RecordIdList>;
89
+ activityDelete(request: RecordIdRequest): Promise<Empty>;
90
+ /** One quantity per nutrient a meal recorded, not grouped into meals. Water is not among them. */
91
+ nutritionQuantities(request: RangeRequest): Promise<DietaryQuantityList>;
92
+ nutritionLog(request: NutritionEntryList): Promise<RecordIdList>;
93
+ nutritionDelete(request: RecordIdRequest): Promise<Empty>;
94
+ /** Water drunk in the range, one sample per drink. */
95
+ nutritionHydration(request: RangeRequest): Promise<HydrationList>;
96
+ /**
97
+ * Logged flow days overlapping the range, one per day. A day logged with no flow is noFlow,
98
+ * not left out.
99
+ */
100
+ menstruationFlow(request: RangeRequest): Promise<MenstruationFlowDayList>;
101
+ /** Ovulation tests, cervical mucus and intermenstrual bleeding logged in the range. */
102
+ menstruationEvents(request: RangeRequest): Promise<MenstrualEventList>;
103
+ /**
104
+ * Characteristics have no history.
105
+ *
106
+ * Available on ios only.
107
+ */
108
+ athleteProfile(request: Empty): Promise<AthleteProfileResult>;
109
+ /** Available on ios only. */
110
+ plannedWorkoutsPlanned(request: Empty): Promise<PlannedWorkoutList>;
111
+ /** Available on ios only. */
112
+ plannedWorkoutsMarkComplete(request: MarkCompleteRequest): Promise<Empty>;
113
+ /** Available on ios only. */
114
+ plannedWorkoutsDelete(request: RecordIdRequest): Promise<Empty>;
115
+ /**
116
+ * Never prompts.
117
+ *
118
+ * Available on ios only.
119
+ */
120
+ plannedWorkoutsSchedulingStatus(request: Empty): Promise<WorkoutScheduling>;
121
+ /**
122
+ * Shows WorkoutKit's sheet if the person has not been asked, and reconciles straight away once
123
+ * authorized.
124
+ *
125
+ * Available on ios only.
126
+ */
127
+ plannedWorkoutsRequestScheduling(request: Empty): Promise<WorkoutScheduling>;
128
+ }
@@ -0,0 +1,256 @@
1
+ "use strict";
2
+ // Generated from surface/terra-surface.json by surface/gen. Do not edit by hand.
3
+ // Regenerate with: node surface/gen/src/cli.ts generate
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.GeneratedClient = void 0;
6
+ const codecs_1 = require("./codecs");
7
+ const TerraError_1 = require("../TerraError");
8
+ /**
9
+ * One generated method per op, and nothing else.
10
+ *
11
+ * The `op` string exists only between this file and the generated native dispatch, and a vector
12
+ * in `vectors/bridge` pins the two to each other. A caller never sees it.
13
+ */
14
+ class GeneratedClient {
15
+ constructor(invoker) {
16
+ this.invoker = invoker;
17
+ }
18
+ async call(op, encode, decode) {
19
+ let payload;
20
+ try {
21
+ payload = JSON.stringify(encode());
22
+ }
23
+ catch (thrown) {
24
+ throw TerraError_1.TerraError.invalidPayload(op, thrown);
25
+ }
26
+ let text;
27
+ try {
28
+ text = await this.invoker.invoke(op, payload);
29
+ }
30
+ catch (thrown) {
31
+ throw TerraError_1.TerraError.from(thrown);
32
+ }
33
+ try {
34
+ return decode(JSON.parse(text));
35
+ }
36
+ catch (thrown) {
37
+ throw TerraError_1.TerraError.invalidPayload(op, thrown);
38
+ }
39
+ }
40
+ /**
41
+ * Reports the native client the JS side is attaching to. Idempotent, and safe to call after a
42
+ * JS reload.
43
+ */
44
+ async clientAttach(request) {
45
+ return this.call("client.attach", () => (0, codecs_1.encodeEmpty)(request), (raw) => (0, codecs_1.decodeBootstrapState)(raw, "BootstrapState"));
46
+ }
47
+ async clientConnect(request) {
48
+ return this.call("client.connect", () => (0, codecs_1.encodeConnectRequest)(request), (raw) => (0, codecs_1.decodeConnection)(raw, "Connection"));
49
+ }
50
+ async clientConnections(request) {
51
+ return this.call("client.connections", () => (0, codecs_1.encodeEmpty)(request), (raw) => (0, codecs_1.decodeConnectionList)(raw, "ConnectionList"));
52
+ }
53
+ /** Whether the device can serve the source at all. Needs no connection and prompts for nothing. */
54
+ async clientAvailability(request) {
55
+ return this.call("client.availability", () => (0, codecs_1.encodeSourceRequest)(request), (raw) => (0, codecs_1.decodeAvailabilityResult)(raw, "AvailabilityResult"));
56
+ }
57
+ async clientDisconnect(request) {
58
+ return this.call("client.disconnect", () => (0, codecs_1.encodeSourceRequest)(request), (raw) => (0, codecs_1.decodeEmpty)(raw, "Empty"));
59
+ }
60
+ /**
61
+ * Tells the broker whether JS can answer at all. Without it a link asks a provider that is not
62
+ * there and waits out the timeout.
63
+ */
64
+ async tokenSetProviderPresent(request) {
65
+ return this.call("token.setProviderPresent", () => (0, codecs_1.encodeTokenProviderRequest)(request), (raw) => (0, codecs_1.decodeEmpty)(raw, "Empty"));
66
+ }
67
+ /**
68
+ * An unknown or already-settled requestId is ignored rather than rejected, so a reload cannot
69
+ * fail a link that has already moved on.
70
+ */
71
+ async tokenResolve(request) {
72
+ return this.call("token.resolve", () => (0, codecs_1.encodeTokenResolveRequest)(request), (raw) => (0, codecs_1.decodeEmpty)(raw, "Empty"));
73
+ }
74
+ async tokenReject(request) {
75
+ return this.call("token.reject", () => (0, codecs_1.encodeTokenRejectRequest)(request), (raw) => (0, codecs_1.decodeEmpty)(raw, "Empty"));
76
+ }
77
+ async permissionsRequest(request) {
78
+ return this.call("permissions.request", () => (0, codecs_1.encodePermissionRequest)(request), (raw) => (0, codecs_1.decodePermissionGrant)(raw, "PermissionGrant"));
79
+ }
80
+ async permissionsStatus(request) {
81
+ return this.call("permissions.status", () => (0, codecs_1.encodeCategoryRequest)(request), (raw) => (0, codecs_1.decodeStatusResult)(raw, "StatusResult"));
82
+ }
83
+ async permissionsWriteStatus(request) {
84
+ return this.call("permissions.writeStatus", () => (0, codecs_1.encodeCategoryRequest)(request), (raw) => (0, codecs_1.decodeStatusResult)(raw, "StatusResult"));
85
+ }
86
+ async permissionsRequested(request) {
87
+ return this.call("permissions.requested", () => (0, codecs_1.encodeSourceRequest)(request), (raw) => (0, codecs_1.decodeHealthAccess)(raw, "HealthAccess"));
88
+ }
89
+ /** Available on android only. */
90
+ async permissionsStatuses(request) {
91
+ return this.call("permissions.statuses", () => (0, codecs_1.encodeSourceRequest)(request), (raw) => (0, codecs_1.decodeStatusesResult)(raw, "StatusesResult"));
92
+ }
93
+ /** Available on android only. */
94
+ async permissionsBackgroundReadStatus(request) {
95
+ return this.call("permissions.backgroundReadStatus", () => (0, codecs_1.encodeSourceRequest)(request), (raw) => (0, codecs_1.decodeStatusResult)(raw, "StatusResult"));
96
+ }
97
+ /** Available on android only. */
98
+ async permissionsHistoryReadStatus(request) {
99
+ return this.call("permissions.historyReadStatus", () => (0, codecs_1.encodeSourceRequest)(request), (raw) => (0, codecs_1.decodeStatusResult)(raw, "StatusResult"));
100
+ }
101
+ async diagnosticsState(request) {
102
+ return this.call("diagnostics.state", () => (0, codecs_1.encodeSourceRequest)(request), (raw) => (0, codecs_1.decodeDiagnosticsState)(raw, "DiagnosticsState"));
103
+ }
104
+ async diagnosticsLastDelivery(request) {
105
+ return this.call("diagnostics.lastDelivery", () => (0, codecs_1.encodeSourceRequest)(request), (raw) => (0, codecs_1.decodeLastDeliveryResult)(raw, "LastDeliveryResult"));
106
+ }
107
+ async diagnosticsReport(request) {
108
+ return this.call("diagnostics.report", () => (0, codecs_1.encodeSourceRequest)(request), (raw) => (0, codecs_1.decodeSupportReport)(raw, "SupportReport"));
109
+ }
110
+ async diagnosticsSend(request) {
111
+ return this.call("diagnostics.send", () => (0, codecs_1.encodeSourceRequest)(request), (raw) => (0, codecs_1.decodeEmpty)(raw, "Empty"));
112
+ }
113
+ /**
114
+ * False means bootstrap did not run. The SDK reports the same thing independently as
115
+ * backgroundRefreshUnscheduled.
116
+ */
117
+ async backgroundIsRegistered(request) {
118
+ return this.call("background.isRegistered", () => (0, codecs_1.encodeEmpty)(request), (raw) => (0, codecs_1.decodeBoolResult)(raw, "BoolResult"));
119
+ }
120
+ /** Available on android only. */
121
+ async backgroundCancel(request) {
122
+ return this.call("background.cancel", () => (0, codecs_1.encodeEmpty)(request), (raw) => (0, codecs_1.decodeBoolResult)(raw, "BoolResult"));
123
+ }
124
+ async bodyHeartRate(request) {
125
+ return this.call("body.heartRate", () => (0, codecs_1.encodeRangeRequest)(request), (raw) => (0, codecs_1.decodeHeartRateList)(raw, "HeartRateList"));
126
+ }
127
+ /**
128
+ * The store's own daily figures. Health Connect grants them under daily, so Android answers
129
+ * authorization_not_determined where only body was asked for.
130
+ */
131
+ async bodyRestingHeartRate(request) {
132
+ return this.call("body.restingHeartRate", () => (0, codecs_1.encodeRangeRequest)(request), (raw) => (0, codecs_1.decodeRestingHeartRateList)(raw, "RestingHeartRateList"));
133
+ }
134
+ async bodyReadings(request) {
135
+ return this.call("body.readings", () => (0, codecs_1.encodeRangeRequest)(request), (raw) => (0, codecs_1.decodeBodyReadingList)(raw, "BodyReadingList"));
136
+ }
137
+ /** Its own op rather than an overload: Swift overloads log by element type and JS cannot. */
138
+ async bodyLogHeartRate(request) {
139
+ return this.call("body.logHeartRate", () => (0, codecs_1.encodeHeartRateEntryList)(request), (raw) => (0, codecs_1.decodeRecordIdList)(raw, "RecordIdList"));
140
+ }
141
+ async bodyLog(request) {
142
+ return this.call("body.log", () => (0, codecs_1.encodeBodyEntryList)(request), (raw) => (0, codecs_1.decodeRecordIdList)(raw, "RecordIdList"));
143
+ }
144
+ async bodyDelete(request) {
145
+ return this.call("body.delete", () => (0, codecs_1.encodeRecordIdRequest)(request), (raw) => (0, codecs_1.decodeEmpty)(raw, "Empty"));
146
+ }
147
+ async dailySteps(request) {
148
+ return this.call("daily.steps", () => (0, codecs_1.encodeRangeRequest)(request), (raw) => (0, codecs_1.decodeStepCountList)(raw, "StepCountList"));
149
+ }
150
+ /**
151
+ * One total per metric per whole local day the range touches. A day with nothing recorded has
152
+ * no total, not a zero.
153
+ */
154
+ async dailyTotals(request) {
155
+ return this.call("daily.totals", () => (0, codecs_1.encodeRangeRequest)(request), (raw) => (0, codecs_1.decodeDayTotalList)(raw, "DayTotalList"));
156
+ }
157
+ /** The active energy, basal energy, distance and floors records the totals are made of. */
158
+ async dailyIntraday(request) {
159
+ return this.call("daily.intraday", () => (0, codecs_1.encodeRangeRequest)(request), (raw) => (0, codecs_1.decodeIntradaySampleList)(raw, "IntradaySampleList"));
160
+ }
161
+ async dailyLog(request) {
162
+ return this.call("daily.log", () => (0, codecs_1.encodeStepEntryList)(request), (raw) => (0, codecs_1.decodeRecordIdList)(raw, "RecordIdList"));
163
+ }
164
+ async dailyDelete(request) {
165
+ return this.call("daily.delete", () => (0, codecs_1.encodeRecordIdRequest)(request), (raw) => (0, codecs_1.decodeEmpty)(raw, "Empty"));
166
+ }
167
+ async sleepSegments(request) {
168
+ return this.call("sleep.segments", () => (0, codecs_1.encodeRangeRequest)(request), (raw) => (0, codecs_1.decodeSleepSegmentList)(raw, "SleepSegmentList"));
169
+ }
170
+ async sleepLog(request) {
171
+ return this.call("sleep.log", () => (0, codecs_1.encodeSleepEntryList)(request), (raw) => (0, codecs_1.decodeRecordIdList)(raw, "RecordIdList"));
172
+ }
173
+ async sleepDelete(request) {
174
+ return this.call("sleep.delete", () => (0, codecs_1.encodeRecordIdRequest)(request), (raw) => (0, codecs_1.decodeEmpty)(raw, "Empty"));
175
+ }
176
+ async activityWorkouts(request) {
177
+ return this.call("activity.workouts", () => (0, codecs_1.encodeRangeRequest)(request), (raw) => (0, codecs_1.decodeWorkoutList)(raw, "WorkoutList"));
178
+ }
179
+ /** The GPS tracks of the workouts in the range, each naming its workout. */
180
+ async activityRoutes(request) {
181
+ return this.call("activity.routes", () => (0, codecs_1.encodeRangeRequest)(request), (raw) => (0, codecs_1.decodeWorkoutRouteList)(raw, "WorkoutRouteList"));
182
+ }
183
+ /** Speed, power and cycling cadence readings in the range. */
184
+ async activityIntensity(request) {
185
+ return this.call("activity.intensity", () => (0, codecs_1.encodeRangeRequest)(request), (raw) => (0, codecs_1.decodeWorkoutIntensityList)(raw, "WorkoutIntensityList"));
186
+ }
187
+ async activityLog(request) {
188
+ return this.call("activity.log", () => (0, codecs_1.encodeWorkoutEntryList)(request), (raw) => (0, codecs_1.decodeRecordIdList)(raw, "RecordIdList"));
189
+ }
190
+ async activityDelete(request) {
191
+ return this.call("activity.delete", () => (0, codecs_1.encodeRecordIdRequest)(request), (raw) => (0, codecs_1.decodeEmpty)(raw, "Empty"));
192
+ }
193
+ /** One quantity per nutrient a meal recorded, not grouped into meals. Water is not among them. */
194
+ async nutritionQuantities(request) {
195
+ return this.call("nutrition.quantities", () => (0, codecs_1.encodeRangeRequest)(request), (raw) => (0, codecs_1.decodeDietaryQuantityList)(raw, "DietaryQuantityList"));
196
+ }
197
+ async nutritionLog(request) {
198
+ return this.call("nutrition.log", () => (0, codecs_1.encodeNutritionEntryList)(request), (raw) => (0, codecs_1.decodeRecordIdList)(raw, "RecordIdList"));
199
+ }
200
+ async nutritionDelete(request) {
201
+ return this.call("nutrition.delete", () => (0, codecs_1.encodeRecordIdRequest)(request), (raw) => (0, codecs_1.decodeEmpty)(raw, "Empty"));
202
+ }
203
+ /** Water drunk in the range, one sample per drink. */
204
+ async nutritionHydration(request) {
205
+ return this.call("nutrition.hydration", () => (0, codecs_1.encodeRangeRequest)(request), (raw) => (0, codecs_1.decodeHydrationList)(raw, "HydrationList"));
206
+ }
207
+ /**
208
+ * Logged flow days overlapping the range, one per day. A day logged with no flow is noFlow,
209
+ * not left out.
210
+ */
211
+ async menstruationFlow(request) {
212
+ return this.call("menstruation.flow", () => (0, codecs_1.encodeRangeRequest)(request), (raw) => (0, codecs_1.decodeMenstruationFlowDayList)(raw, "MenstruationFlowDayList"));
213
+ }
214
+ /** Ovulation tests, cervical mucus and intermenstrual bleeding logged in the range. */
215
+ async menstruationEvents(request) {
216
+ return this.call("menstruation.events", () => (0, codecs_1.encodeRangeRequest)(request), (raw) => (0, codecs_1.decodeMenstrualEventList)(raw, "MenstrualEventList"));
217
+ }
218
+ /**
219
+ * Characteristics have no history.
220
+ *
221
+ * Available on ios only.
222
+ */
223
+ async athleteProfile(request) {
224
+ return this.call("athlete.profile", () => (0, codecs_1.encodeEmpty)(request), (raw) => (0, codecs_1.decodeAthleteProfileResult)(raw, "AthleteProfileResult"));
225
+ }
226
+ /** Available on ios only. */
227
+ async plannedWorkoutsPlanned(request) {
228
+ return this.call("plannedWorkouts.planned", () => (0, codecs_1.encodeEmpty)(request), (raw) => (0, codecs_1.decodePlannedWorkoutList)(raw, "PlannedWorkoutList"));
229
+ }
230
+ /** Available on ios only. */
231
+ async plannedWorkoutsMarkComplete(request) {
232
+ return this.call("plannedWorkouts.markComplete", () => (0, codecs_1.encodeMarkCompleteRequest)(request), (raw) => (0, codecs_1.decodeEmpty)(raw, "Empty"));
233
+ }
234
+ /** Available on ios only. */
235
+ async plannedWorkoutsDelete(request) {
236
+ return this.call("plannedWorkouts.delete", () => (0, codecs_1.encodeRecordIdRequest)(request), (raw) => (0, codecs_1.decodeEmpty)(raw, "Empty"));
237
+ }
238
+ /**
239
+ * Never prompts.
240
+ *
241
+ * Available on ios only.
242
+ */
243
+ async plannedWorkoutsSchedulingStatus(request) {
244
+ return this.call("plannedWorkouts.schedulingStatus", () => (0, codecs_1.encodeEmpty)(request), (raw) => (0, codecs_1.decodeWorkoutScheduling)(raw, "WorkoutScheduling"));
245
+ }
246
+ /**
247
+ * Shows WorkoutKit's sheet if the person has not been asked, and reconciles straight away once
248
+ * authorized.
249
+ *
250
+ * Available on ios only.
251
+ */
252
+ async plannedWorkoutsRequestScheduling(request) {
253
+ return this.call("plannedWorkouts.requestScheduling", () => (0, codecs_1.encodeEmpty)(request), (raw) => (0, codecs_1.decodeWorkoutScheduling)(raw, "WorkoutScheduling"));
254
+ }
255
+ }
256
+ exports.GeneratedClient = GeneratedClient;