@mongrov/analytics 0.6.0 → 0.8.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.md +23 -10
- package/UPGRADING.md +456 -0
- package/dist/core/device-events.d.ts +14 -0
- package/dist/core/device-events.d.ts.map +1 -0
- package/dist/core/device-events.js +13 -0
- package/dist/core/device-events.js.map +1 -0
- package/dist/core/errors.d.ts +1 -1
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js.map +1 -1
- package/dist/core/extensions.d.ts +21 -4
- package/dist/core/extensions.d.ts.map +1 -1
- package/dist/core/extensions.js +21 -4
- package/dist/core/extensions.js.map +1 -1
- package/dist/core/factory.d.ts.map +1 -1
- package/dist/core/factory.js +125 -23
- package/dist/core/factory.js.map +1 -1
- package/dist/core/hooks.js +1 -1
- package/dist/core/hooks.js.map +1 -1
- package/dist/core/index.d.ts +13 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +18 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/insight.d.ts +44 -0
- package/dist/core/insight.d.ts.map +1 -0
- package/dist/core/insight.js +62 -0
- package/dist/core/insight.js.map +1 -0
- package/dist/core/metric_metadata.d.ts +55 -0
- package/dist/core/metric_metadata.d.ts.map +1 -1
- package/dist/core/metric_metadata.js +35 -7
- package/dist/core/metric_metadata.js.map +1 -1
- package/dist/core/migrations.d.ts.map +1 -1
- package/dist/core/migrations.js +103 -2
- package/dist/core/migrations.js.map +1 -1
- package/dist/core/retention.d.ts +44 -13
- package/dist/core/retention.d.ts.map +1 -1
- package/dist/core/retention.js +49 -22
- package/dist/core/retention.js.map +1 -1
- package/dist/core/sampling.d.ts +70 -0
- package/dist/core/sampling.d.ts.map +1 -0
- package/dist/core/sampling.js +107 -0
- package/dist/core/sampling.js.map +1 -0
- package/dist/core/schemas.d.ts +73 -2
- package/dist/core/schemas.d.ts.map +1 -1
- package/dist/core/schemas.js +160 -5
- package/dist/core/schemas.js.map +1 -1
- package/dist/core/table_metadata.d.ts.map +1 -1
- package/dist/core/table_metadata.js +3 -0
- package/dist/core/table_metadata.js.map +1 -1
- package/dist/core/types.d.ts +45 -10
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/warehouse.d.ts +28 -0
- package/dist/core/warehouse.d.ts.map +1 -1
- package/dist/core/warehouse.js +44 -0
- package/dist/core/warehouse.js.map +1 -1
- package/dist/core/watermark-cache.d.ts +75 -0
- package/dist/core/watermark-cache.d.ts.map +1 -0
- package/dist/core/watermark-cache.js +0 -0
- package/dist/core/watermark-cache.js.map +1 -0
- package/dist/rules/__fakes__/fakeEngine.d.ts +2 -0
- package/dist/rules/__fakes__/fakeEngine.d.ts.map +1 -1
- package/dist/rules/__fakes__/fakeEngine.js +4 -0
- package/dist/rules/__fakes__/fakeEngine.js.map +1 -1
- package/dist/rules/baseline-reader.d.ts +55 -0
- package/dist/rules/baseline-reader.d.ts.map +1 -0
- package/dist/rules/baseline-reader.js +111 -0
- package/dist/rules/baseline-reader.js.map +1 -0
- package/dist/rules/compiler.d.ts +36 -1
- package/dist/rules/compiler.d.ts.map +1 -1
- package/dist/rules/compiler.js +185 -39
- package/dist/rules/compiler.js.map +1 -1
- package/dist/rules/defaults/luminx.d.ts.map +1 -1
- package/dist/rules/defaults/luminx.js +8 -0
- package/dist/rules/defaults/luminx.js.map +1 -1
- package/dist/rules/defaults/viva.d.ts.map +1 -1
- package/dist/rules/defaults/viva.js +7 -0
- package/dist/rules/defaults/viva.js.map +1 -1
- package/dist/rules/defaults/yogaring.d.ts.map +1 -1
- package/dist/rules/defaults/yogaring.js +7 -0
- package/dist/rules/defaults/yogaring.js.map +1 -1
- package/dist/rules/defaults/ziva.d.ts.map +1 -1
- package/dist/rules/defaults/ziva.js +100 -24
- package/dist/rules/defaults/ziva.js.map +1 -1
- package/dist/rules/evaluator.d.ts +14 -3
- package/dist/rules/evaluator.d.ts.map +1 -1
- package/dist/rules/evaluator.js +157 -5
- package/dist/rules/evaluator.js.map +1 -1
- package/dist/rules/factory.d.ts.map +1 -1
- package/dist/rules/factory.js +5 -1
- package/dist/rules/factory.js.map +1 -1
- package/dist/rules/index.d.ts +2 -1
- package/dist/rules/index.d.ts.map +1 -1
- package/dist/rules/index.js +2 -1
- package/dist/rules/index.js.map +1 -1
- package/dist/rules/schema.d.ts +75 -4
- package/dist/rules/schema.d.ts.map +1 -1
- package/dist/rules/schema.js +44 -0
- package/dist/rules/schema.js.map +1 -1
- package/dist/rules/types.d.ts +16 -1
- package/dist/rules/types.d.ts.map +1 -1
- package/dist/rules/validator.d.ts.map +1 -1
- package/dist/rules/validator.js +89 -0
- package/dist/rules/validator.js.map +1 -1
- package/dist/sync/baseline-compute.d.ts +63 -0
- package/dist/sync/baseline-compute.d.ts.map +1 -0
- package/dist/sync/baseline-compute.js +211 -0
- package/dist/sync/baseline-compute.js.map +1 -0
- package/dist/sync/events.d.ts +19 -5
- package/dist/sync/events.d.ts.map +1 -1
- package/dist/sync/events.js +17 -0
- package/dist/sync/events.js.map +1 -1
- package/dist/sync/factory.d.ts +54 -8
- package/dist/sync/factory.d.ts.map +1 -1
- package/dist/sync/factory.js +145 -46
- package/dist/sync/factory.js.map +1 -1
- package/dist/sync/fetcher.d.ts +15 -2
- package/dist/sync/fetcher.d.ts.map +1 -1
- package/dist/sync/fetcher.js +43 -7
- package/dist/sync/fetcher.js.map +1 -1
- package/dist/sync/flusher.d.ts +52 -2
- package/dist/sync/flusher.d.ts.map +1 -1
- package/dist/sync/flusher.js +78 -9
- package/dist/sync/flusher.js.map +1 -1
- package/dist/sync/index.d.ts +3 -1
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +1 -0
- package/dist/sync/index.js.map +1 -1
- package/dist/sync/mapper/activity.d.ts.map +1 -1
- package/dist/sync/mapper/activity.js +2 -1
- package/dist/sync/mapper/activity.js.map +1 -1
- package/dist/sync/mapper/firmware.d.ts +3 -12
- package/dist/sync/mapper/firmware.d.ts.map +1 -1
- package/dist/sync/mapper/firmware.js +2 -8
- package/dist/sync/mapper/firmware.js.map +1 -1
- package/dist/sync/mapper/ring-config.d.ts +76 -28
- package/dist/sync/mapper/ring-config.d.ts.map +1 -1
- package/dist/sync/mapper/ring-config.js +118 -35
- package/dist/sync/mapper/ring-config.js.map +1 -1
- package/dist/sync/mapper/schema.d.ts +669 -0
- package/dist/sync/mapper/schema.d.ts.map +1 -0
- package/dist/sync/mapper/schema.js +160 -0
- package/dist/sync/mapper/schema.js.map +1 -0
- package/dist/sync/mapper/sleep.d.ts +58 -13
- package/dist/sync/mapper/sleep.d.ts.map +1 -1
- package/dist/sync/mapper/sleep.js +141 -44
- package/dist/sync/mapper/sleep.js.map +1 -1
- package/dist/sync/mapper/types.d.ts +118 -29
- package/dist/sync/mapper/types.d.ts.map +1 -1
- package/dist/sync/pending_closes.js +2 -2
- package/dist/sync/pending_closes.js.map +1 -1
- package/dist/sync/pusher.js +2 -2
- package/dist/sync/pusher.js.map +1 -1
- package/dist/sync/scheduler.d.ts +7 -0
- package/dist/sync/scheduler.d.ts.map +1 -1
- package/dist/sync/scheduler.js +14 -0
- package/dist/sync/scheduler.js.map +1 -1
- package/dist/tools/__fakes__/engine.d.ts +2 -0
- package/dist/tools/__fakes__/engine.d.ts.map +1 -1
- package/dist/tools/__fakes__/engine.js +10 -0
- package/dist/tools/__fakes__/engine.js.map +1 -1
- package/dist/tools/authorize.d.ts +19 -12
- package/dist/tools/authorize.d.ts.map +1 -1
- package/dist/tools/authorize.js +31 -40
- package/dist/tools/authorize.js.map +1 -1
- package/dist/tools/factory.d.ts +2 -0
- package/dist/tools/factory.d.ts.map +1 -1
- package/dist/tools/factory.js +12 -1
- package/dist/tools/factory.js.map +1 -1
- package/dist/tools/formatters/copy-guidelines.d.ts +57 -0
- package/dist/tools/formatters/copy-guidelines.d.ts.map +1 -0
- package/dist/tools/formatters/copy-guidelines.js +110 -0
- package/dist/tools/formatters/copy-guidelines.js.map +1 -0
- package/dist/tools/formatters/index.d.ts +14 -0
- package/dist/tools/formatters/index.d.ts.map +1 -0
- package/dist/tools/formatters/index.js +14 -0
- package/dist/tools/formatters/index.js.map +1 -0
- package/dist/tools/formatters/spo2.d.ts +21 -0
- package/dist/tools/formatters/spo2.d.ts.map +1 -0
- package/dist/tools/formatters/spo2.js +79 -0
- package/dist/tools/formatters/spo2.js.map +1 -0
- package/dist/tools/{formatters.d.ts → formatters/text.d.ts} +1 -1
- package/dist/tools/formatters/text.d.ts.map +1 -0
- package/dist/tools/{formatters.js → formatters/text.js} +1 -1
- package/dist/tools/formatters/text.js.map +1 -0
- package/dist/tools/impls/activity.d.ts +2 -2
- package/dist/tools/impls/activity.js +7 -3
- package/dist/tools/impls/activity.js.map +1 -1
- package/dist/tools/impls/anomaly.d.ts +2 -2
- package/dist/tools/impls/anomaly.js +8 -4
- package/dist/tools/impls/anomaly.js.map +1 -1
- package/dist/tools/impls/compare.d.ts +2 -2
- package/dist/tools/impls/compare.js +8 -4
- package/dist/tools/impls/compare.js.map +1 -1
- package/dist/tools/impls/hrv.d.ts +2 -2
- package/dist/tools/impls/hrv.js +6 -2
- package/dist/tools/impls/hrv.js.map +1 -1
- package/dist/tools/impls/insights.d.ts +4 -4
- package/dist/tools/impls/insights.d.ts.map +1 -1
- package/dist/tools/impls/insights.js +10 -3
- package/dist/tools/impls/insights.js.map +1 -1
- package/dist/tools/impls/sleep.d.ts +2 -2
- package/dist/tools/impls/sleep.js +6 -2
- package/dist/tools/impls/sleep.js.map +1 -1
- package/dist/tools/impls/spo2.d.ts +52 -0
- package/dist/tools/impls/spo2.d.ts.map +1 -0
- package/dist/tools/impls/spo2.js +65 -0
- package/dist/tools/impls/spo2.js.map +1 -0
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +4 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/mcp/guard.d.ts +28 -11
- package/dist/tools/mcp/guard.d.ts.map +1 -1
- package/dist/tools/mcp/guard.js +45 -15
- package/dist/tools/mcp/guard.js.map +1 -1
- package/dist/tools/mcp/index.d.ts +1 -1
- package/dist/tools/mcp/index.d.ts.map +1 -1
- package/dist/tools/mcp/index.js +1 -1
- package/dist/tools/mcp/index.js.map +1 -1
- package/dist/tools/mcp/server.d.ts.map +1 -1
- package/dist/tools/mcp/server.js +4 -0
- package/dist/tools/mcp/server.js.map +1 -1
- package/dist/tools/mcp/transports/http.d.ts.map +1 -1
- package/dist/tools/mcp/transports/http.js +4 -0
- package/dist/tools/mcp/transports/http.js.map +1 -1
- package/package.json +8 -5
- package/dist/tools/formatters.d.ts.map +0 -1
- package/dist/tools/formatters.js.map +0 -1
package/dist/sync/flusher.js
CHANGED
|
@@ -33,7 +33,8 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
33
33
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
34
34
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
35
35
|
};
|
|
36
|
-
var _BatchFlusher_instances, _BatchFlusher_engine, _BatchFlusher_buffer, _BatchFlusher_columnOrder, _BatchFlusher_queue, _BatchFlusher_sleep, _BatchFlusher_now, _BatchFlusher_emit, _BatchFlusher_tables, _BatchFlusher_runWithRetry, _BatchFlusher_flushWithTimeout, _BatchFlusher_writeToAppender, _BatchFlusher_restore, _BatchFlusher_ensureState;
|
|
36
|
+
var _BatchFlusher_instances, _BatchFlusher_engine, _BatchFlusher_buffer, _BatchFlusher_columnOrder, _BatchFlusher_queue, _BatchFlusher_sleep, _BatchFlusher_now, _BatchFlusher_emit, _BatchFlusher_tables, _BatchFlusher_batches, _BatchFlusher_recordInBatch, _BatchFlusher_runWithRetry, _BatchFlusher_flushWithTimeout, _BatchFlusher_writeToAppender, _BatchFlusher_restore, _BatchFlusher_ensureState;
|
|
37
|
+
import { nanoid } from 'nanoid';
|
|
37
38
|
import PQueue from 'p-queue';
|
|
38
39
|
import { SyncError } from './errors';
|
|
39
40
|
// p-queue: HIGHER priority values run first. Foreground / manual sit at the
|
|
@@ -69,6 +70,7 @@ export class BatchFlusher {
|
|
|
69
70
|
_BatchFlusher_now.set(this, void 0);
|
|
70
71
|
_BatchFlusher_emit.set(this, void 0);
|
|
71
72
|
_BatchFlusher_tables.set(this, new Map());
|
|
73
|
+
_BatchFlusher_batches.set(this, new Map());
|
|
72
74
|
__classPrivateFieldSet(this, _BatchFlusher_engine, config.engine, "f");
|
|
73
75
|
__classPrivateFieldSet(this, _BatchFlusher_buffer, config.buffer, "f");
|
|
74
76
|
__classPrivateFieldSet(this, _BatchFlusher_columnOrder, config.columnOrder, "f");
|
|
@@ -77,6 +79,56 @@ export class BatchFlusher {
|
|
|
77
79
|
__classPrivateFieldSet(this, _BatchFlusher_emit, config.emit, "f");
|
|
78
80
|
__classPrivateFieldSet(this, _BatchFlusher_queue, new PQueue({ concurrency: config.concurrency ?? 2 }), "f");
|
|
79
81
|
}
|
|
82
|
+
// -------------------- batch lifecycle (Sprint 5 T-11) --------------------
|
|
83
|
+
/**
|
|
84
|
+
* Open a batch. Every `flush(table, reason, batchId)` passing this id
|
|
85
|
+
* accumulates into it; `endBatch(batchId)` closes it and emits
|
|
86
|
+
* `batch-complete`.
|
|
87
|
+
*
|
|
88
|
+
* Batches are bookkeeping, not a lock: flushes still run concurrently
|
|
89
|
+
* through the p-queue, and a flush with no batchId is unaffected. The
|
|
90
|
+
* batch only decides *when* downstream consumers are told the write is
|
|
91
|
+
* settled.
|
|
92
|
+
*/
|
|
93
|
+
beginBatch(reason = 'manual', batchId) {
|
|
94
|
+
const id = batchId ?? nanoid(12);
|
|
95
|
+
__classPrivateFieldGet(this, _BatchFlusher_batches, "f").set(id, {
|
|
96
|
+
reason,
|
|
97
|
+
tables: new Set(),
|
|
98
|
+
userIds: new Set(),
|
|
99
|
+
rowCounts: {},
|
|
100
|
+
});
|
|
101
|
+
return id;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Close a batch and emit `batch-complete`.
|
|
105
|
+
*
|
|
106
|
+
* Returns the event payload, or `null` when the batch wrote nothing —
|
|
107
|
+
* an empty cycle has no consumers to wake, and emitting would make rules
|
|
108
|
+
* re-evaluate on no new data. Unknown ids also return `null` rather than
|
|
109
|
+
* throwing, so a double-`endBatch` in a retry path is harmless.
|
|
110
|
+
*/
|
|
111
|
+
endBatch(batchId) {
|
|
112
|
+
const record = __classPrivateFieldGet(this, _BatchFlusher_batches, "f").get(batchId);
|
|
113
|
+
__classPrivateFieldGet(this, _BatchFlusher_batches, "f").delete(batchId);
|
|
114
|
+
if (!record || record.tables.size === 0)
|
|
115
|
+
return null;
|
|
116
|
+
const payload = {
|
|
117
|
+
batchId,
|
|
118
|
+
affectedTables: [...record.tables],
|
|
119
|
+
affectedUserIds: [...record.userIds],
|
|
120
|
+
brand: record.brand,
|
|
121
|
+
familyId: record.familyId,
|
|
122
|
+
rowCounts: record.rowCounts,
|
|
123
|
+
reason: record.reason,
|
|
124
|
+
};
|
|
125
|
+
__classPrivateFieldGet(this, _BatchFlusher_emit, "f")?.call(this, { type: 'batch-complete', payload });
|
|
126
|
+
return payload;
|
|
127
|
+
}
|
|
128
|
+
/** Open batch ids — diagnostics + leak detection in tests. */
|
|
129
|
+
openBatchIds() {
|
|
130
|
+
return [...__classPrivateFieldGet(this, _BatchFlusher_batches, "f").keys()];
|
|
131
|
+
}
|
|
80
132
|
/** Runtime state for a table. `idle` if we've never touched it. */
|
|
81
133
|
stateOf(table) {
|
|
82
134
|
return __classPrivateFieldGet(this, _BatchFlusher_tables, "f").get(table)?.state ?? 'idle';
|
|
@@ -92,7 +144,7 @@ export class BatchFlusher {
|
|
|
92
144
|
* Single flush attempt (no retry). Used directly by explicit user code and
|
|
93
145
|
* indirectly by `scheduleFlush` for the retry loop.
|
|
94
146
|
*/
|
|
95
|
-
async flush(table, reason = 'manual') {
|
|
147
|
+
async flush(table, reason = 'manual', batchId) {
|
|
96
148
|
const state = __classPrivateFieldGet(this, _BatchFlusher_instances, "m", _BatchFlusher_ensureState).call(this, table);
|
|
97
149
|
state.state = 'flushing';
|
|
98
150
|
const drained = await __classPrivateFieldGet(this, _BatchFlusher_buffer, "f").drain(table);
|
|
@@ -106,9 +158,12 @@ export class BatchFlusher {
|
|
|
106
158
|
state.lastError = undefined;
|
|
107
159
|
state.state = 'idle';
|
|
108
160
|
const affectedUserIds = distinctUserIds(drained);
|
|
161
|
+
const brand = drained[0]?.brand;
|
|
162
|
+
const familyId = drained[0]?.familyId;
|
|
163
|
+
__classPrivateFieldGet(this, _BatchFlusher_instances, "m", _BatchFlusher_recordInBatch).call(this, batchId, table, rowsFlushed, affectedUserIds, brand, familyId);
|
|
109
164
|
__classPrivateFieldGet(this, _BatchFlusher_emit, "f")?.call(this, {
|
|
110
165
|
type: 'flushed',
|
|
111
|
-
payload: { table, rowsFlushed, reason, affectedUserIds },
|
|
166
|
+
payload: { table, rowsFlushed, reason, affectedUserIds, brand, familyId },
|
|
112
167
|
});
|
|
113
168
|
return { table, rowsFlushed, ok: true };
|
|
114
169
|
}
|
|
@@ -129,9 +184,9 @@ export class BatchFlusher {
|
|
|
129
184
|
* Enqueue a flush with retry orchestration. Non-blocking — returns the
|
|
130
185
|
* promise for callers that want to await final resolution.
|
|
131
186
|
*/
|
|
132
|
-
scheduleFlush(table, reason) {
|
|
187
|
+
scheduleFlush(table, reason, batchId) {
|
|
133
188
|
const priority = PRIORITY_BY_REASON[reason];
|
|
134
|
-
return __classPrivateFieldGet(this, _BatchFlusher_queue, "f").add(() => __classPrivateFieldGet(this, _BatchFlusher_instances, "m", _BatchFlusher_runWithRetry).call(this, table, reason), { priority })
|
|
189
|
+
return __classPrivateFieldGet(this, _BatchFlusher_queue, "f").add(() => __classPrivateFieldGet(this, _BatchFlusher_instances, "m", _BatchFlusher_runWithRetry).call(this, table, reason, batchId), { priority })
|
|
135
190
|
// p-queue's typings make add() return `Promise<T | void>`; we always
|
|
136
191
|
// resolve with a FlushResult so this cast is safe.
|
|
137
192
|
.then(r => r);
|
|
@@ -149,10 +204,24 @@ export class BatchFlusher {
|
|
|
149
204
|
__classPrivateFieldGet(this, _BatchFlusher_queue, "f").start();
|
|
150
205
|
}
|
|
151
206
|
}
|
|
152
|
-
_BatchFlusher_engine = new WeakMap(), _BatchFlusher_buffer = new WeakMap(), _BatchFlusher_columnOrder = new WeakMap(), _BatchFlusher_queue = new WeakMap(), _BatchFlusher_sleep = new WeakMap(), _BatchFlusher_now = new WeakMap(), _BatchFlusher_emit = new WeakMap(), _BatchFlusher_tables = new WeakMap(), _BatchFlusher_instances = new WeakSet(),
|
|
207
|
+
_BatchFlusher_engine = new WeakMap(), _BatchFlusher_buffer = new WeakMap(), _BatchFlusher_columnOrder = new WeakMap(), _BatchFlusher_queue = new WeakMap(), _BatchFlusher_sleep = new WeakMap(), _BatchFlusher_now = new WeakMap(), _BatchFlusher_emit = new WeakMap(), _BatchFlusher_tables = new WeakMap(), _BatchFlusher_batches = new WeakMap(), _BatchFlusher_instances = new WeakSet(), _BatchFlusher_recordInBatch = function _BatchFlusher_recordInBatch(batchId, table, rowsFlushed, userIds, brand, familyId) {
|
|
208
|
+
if (batchId === undefined)
|
|
209
|
+
return;
|
|
210
|
+
const record = __classPrivateFieldGet(this, _BatchFlusher_batches, "f").get(batchId);
|
|
211
|
+
// A flush can outlive its batch if endBatch already ran (timeout, retry
|
|
212
|
+
// landing late). Dropping it is correct: the batch was already reported.
|
|
213
|
+
if (!record)
|
|
214
|
+
return;
|
|
215
|
+
record.tables.add(table);
|
|
216
|
+
record.rowCounts[table] = (record.rowCounts[table] ?? 0) + rowsFlushed;
|
|
217
|
+
for (const id of userIds)
|
|
218
|
+
record.userIds.add(id);
|
|
219
|
+
record.brand ?? (record.brand = brand);
|
|
220
|
+
record.familyId ?? (record.familyId = familyId);
|
|
221
|
+
}, _BatchFlusher_runWithRetry = async function _BatchFlusher_runWithRetry(table, reason, batchId) {
|
|
153
222
|
let lastResult = { table, rowsFlushed: 0, ok: false };
|
|
154
223
|
for (let attempt = 0; attempt < BACKOFF_SEQUENCE_MS.length; attempt++) {
|
|
155
|
-
const result = await __classPrivateFieldGet(this, _BatchFlusher_instances, "m", _BatchFlusher_flushWithTimeout).call(this, table, reason);
|
|
224
|
+
const result = await __classPrivateFieldGet(this, _BatchFlusher_instances, "m", _BatchFlusher_flushWithTimeout).call(this, table, reason, batchId);
|
|
156
225
|
lastResult = result;
|
|
157
226
|
if (result.ok)
|
|
158
227
|
return result;
|
|
@@ -165,8 +234,8 @@ _BatchFlusher_engine = new WeakMap(), _BatchFlusher_buffer = new WeakMap(), _Bat
|
|
|
165
234
|
await __classPrivateFieldGet(this, _BatchFlusher_sleep, "f").call(this, BACKOFF_SEQUENCE_MS[attempt]);
|
|
166
235
|
}
|
|
167
236
|
return lastResult;
|
|
168
|
-
}, _BatchFlusher_flushWithTimeout = async function _BatchFlusher_flushWithTimeout(table, reason) {
|
|
169
|
-
const attempt = this.flush(table, reason);
|
|
237
|
+
}, _BatchFlusher_flushWithTimeout = async function _BatchFlusher_flushWithTimeout(table, reason, batchId) {
|
|
238
|
+
const attempt = this.flush(table, reason, batchId);
|
|
170
239
|
let timeoutId;
|
|
171
240
|
const timeout = new Promise((resolve) => {
|
|
172
241
|
timeoutId = setTimeout(() => {
|
package/dist/sync/flusher.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flusher.js","sourceRoot":"","sources":["../../src/sync/flusher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;;;;;;;;;;;AAEH,OAAO,MAAM,MAAM,SAAS,CAAA;AAI5B,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAWpC,4EAA4E;AAC5E,qCAAqC;AACrC,MAAM,kBAAkB,GAAgC;IACtD,UAAU,EAAE,GAAG;IACf,MAAM,EAAE,EAAE;IACV,WAAW,EAAE,EAAE;IACf,G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AAE,KAAK,CAAC,KAAK;YAClB,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,IAAI,EAAE,KAAK,CAAC,IAAI;SACjB,CAAC,CAAA;IACJ,CAAC;AACH,CAAC,iEAEY,KAAa;IACxB,IAAI,KAAK,GAAG,uBAAA,IAAI,4BAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;IACnC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,KAAK,GAAG,EAAE,YAAY,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAA;QAC1C,uBAAA,IAAI,4BAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;IAChC,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAGH,SAAS,YAAY,CAAC,EAAU;IAC9B,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAA;AACxD,CAAC;AAED,SAAS,eAAe,CAAC,OAAsB;IAC7C,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAA;IAC9B,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,IAAI,KAAK,CAAC,MAAM;YAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IAC1C,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC"}
|
package/dist/sync/index.d.ts
CHANGED
|
@@ -4,13 +4,15 @@
|
|
|
4
4
|
* Phases A–C: mapper + buffer + flusher surfaces. Pusher/fetcher/scheduler
|
|
5
5
|
* ship in subsequent phases (see `.specifica/features/analytics-sync/tasks.md`).
|
|
6
6
|
*/
|
|
7
|
+
export { buildBaselineSql, createBaselineComputer, type BaselineComputeConfig, type BaselineComputeContext, type BaselineComputeResult, type BaselineComputer, } from './baseline-compute';
|
|
7
8
|
export { SensorBuffer, type SensorBufferConfig } from './buffer';
|
|
8
9
|
export { OverflowStore } from './overflow';
|
|
9
10
|
export type { BufferEntry, BufferSize, FlushResult, OverflowPolicy, SensorBatch, } from './types';
|
|
10
11
|
export { type WatermarkKind, WatermarkStore, type WatermarkStoreConfig, } from './watermark';
|
|
11
12
|
export { type PushResult, R2Pusher, type R2PusherConfig, } from './pusher';
|
|
12
13
|
export { type FetchParams, type FetchResult, type PrefetchPolicy, R2Fetcher, type R2FetcherConfig, } from './fetcher';
|
|
13
|
-
export { BACKOFF_SEQUENCE_MS, BatchFlusher, type BatchFlusherConfig, FLUSH_TIMEOUT_MS, type FlushReason, type FlushedEvent, MAX_CONSECUTIVE_FAILURES, type FlusherState, type SyncEmitter, } from './flusher';
|
|
14
|
+
export { BACKOFF_SEQUENCE_MS, type BatchCompleteEvent, BatchFlusher, type BatchFlusherConfig, FLUSH_TIMEOUT_MS, type FlushReason, type FlushedEvent, MAX_CONSECUTIVE_FAILURES, type FlusherState, type SyncEmitter, } from './flusher';
|
|
15
|
+
export type { BatchCompletePayload } from './events';
|
|
14
16
|
export { SyncError, type SyncErrorCode } from './errors';
|
|
15
17
|
export { DEFAULT_MAX_AGE_MS, DEFAULT_MAX_ROWS, FlushTriggers, type FlushTriggersConfig, } from './triggers';
|
|
16
18
|
export { createSyncManager, type CreateSyncManagerConfig } from './factory';
|
package/dist/sync/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sync/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,YAAY,EAAE,KAAK,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC1C,YAAY,EACV,WAAW,EACX,UAAU,EACV,WAAW,EACX,cAAc,EACd,WAAW,GACZ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AAwB,EACxB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,YAAY,EACZ,MAAM,EACN,WAAW,EACX,aAAa,EACb,oBAAoB,EACpB,WAAW,EACX,eAAe,EACf,aAAa,EACb,OAAO,EACP,cAAc,GACf,MAAM,gBAAgB,CAAA;AAGvB,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA"}
|
package/dist/sync/index.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* ship in subsequent phases (see `.specifica/features/analytics-sync/tasks.md`).
|
|
6
6
|
*/
|
|
7
7
|
// Buffer + overflow (Phase B).
|
|
8
|
+
export { buildBaselineSql, createBaselineComputer, } from './baseline-compute';
|
|
8
9
|
export { SensorBuffer } from './buffer';
|
|
9
10
|
export { OverflowStore } from './overflow';
|
|
10
11
|
// Watermark + pusher + fetcher (Phase D+E+F).
|
package/dist/sync/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sync/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,+BAA+B;AAC/B,OAAO,EAAE,YAAY,EAA2B,MAAM,UAAU,CAAA;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAS1C,8CAA8C;AAC9C,OAAO,EAEL,cAAc,GAEf,MAAM,aAAa,CAAA;AACpB,OAAO,EAEL,QAAQ,GAET,MAAM,UAAU,CAAA;AACjB,OAAO,EAIL,SAAS,GAEV,MAAM,WAAW,CAAA;AAElB,gCAAgC;AAChC,OAAO,EACL,mBAAmB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sync/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,+BAA+B;AAC/B,OAAO,EACL,gBAAgB,EAChB,sBAAsB,GAKvB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,YAAY,EAA2B,MAAM,UAAU,CAAA;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EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AA8B9D,mCAAmC;AACnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"activity.d.ts","sourceRoot":"","sources":["../../../src/sync/mapper/activity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAGH,OAAO,KAAK,EACV,iBAAiB,EACjB,WAAW,EACX,mBAAmB,EACnB,aAAa,EACd,MAAM,SAAS,CAAA;AAEhB,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,WAAW,EAAE,CAAA;IACvB,eAAe,EAAE,iBAAiB,EAAE,CAAA;CACrC;AAID,wBAAgB,WAAW,CACzB,IAAI,EAAE,SAAS,mBAAmB,EAAE,EACpC,GAAG,EAAE,aAAa,GACjB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"activity.d.ts","sourceRoot":"","sources":["../../../src/sync/mapper/activity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAGH,OAAO,KAAK,EACV,iBAAiB,EACjB,WAAW,EACX,mBAAmB,EACnB,aAAa,EACd,MAAM,SAAS,CAAA;AAEhB,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,WAAW,EAAE,CAAA;IACvB,eAAe,EAAE,iBAAiB,EAAE,CAAA;CACrC;AAID,wBAAgB,WAAW,CACzB,IAAI,EAAE,SAAS,mBAAmB,EAAE,EACpC,GAAG,EAAE,aAAa,GACjB,iBAAiB,CA+BnB"}
|
|
@@ -46,7 +46,8 @@ export function mapActivity(rows, ctx) {
|
|
|
46
46
|
family_id: ctx.familyId,
|
|
47
47
|
user_id: ctx.userId,
|
|
48
48
|
device_id: ctx.deviceId,
|
|
49
|
-
steps
|
|
49
|
+
// No `steps` — the bucket carries calories/distance only. Steps are
|
|
50
|
+
// unnested to 1-min `activity` rows above (spec §Table schema).
|
|
50
51
|
calories: row.calories,
|
|
51
52
|
distance_km: row.distance,
|
|
52
53
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"activity.js","sourceRoot":"","sources":["../../../src/sync/mapper/activity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAA;AAavC,MAAM,SAAS,GAAG,KAAM,CAAA;AAExB,MAAM,UAAU,WAAW,CACzB,IAAoC,EACpC,GAAkB;IAElB,MAAM,QAAQ,GAAkB,EAAE,CAAA;IAClC,MAAM,eAAe,GAAwB,EAAE,CAAA;IAE/C,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,MAAM,GAAG,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;QAC5C,MAAM,KAAK,GAAG,GAAG,CAAC,UAAU,IAAI,EAAE,CAAA;QAClC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACtC,QAAQ,CAAC,IAAI,CAAC;gBACZ,EAAE,EAAE,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,GAAG,SAAS,CAAC;gBAC9C,KAAK,EAAE,GAAG,CAAC,KAAK;gBAChB,SAAS,EAAE,GAAG,CAAC,QAAQ;gBACvB,OAAO,EAAE,GAAG,CAAC,MAAM;gBACnB,SAAS,EAAE,GAAG,CAAC,QAAQ;gBACvB,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;aAChB,CAAC,CAAA;QACJ,CAAC;QACD,eAAe,CAAC,IAAI,CAAC;YACnB,EAAE,EAAE,MAAM;YACV,KAAK,EAAE,GAAG,CAAC,KAAK;YAChB,SAAS,EAAE,GAAG,CAAC,QAAQ;YACvB,OAAO,E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,oEAAoE;YACpE,gEAAgE;YAChE,QAAQ,EAAE,GAAG,CAAC,QAAQ;YACtB,WAAW,EAAE,GAAG,CAAC,QAAQ;SAC1B,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAA;AACtC,CAAC"}
|
|
@@ -14,23 +14,14 @@
|
|
|
14
14
|
* shape contract.
|
|
15
15
|
*/
|
|
16
16
|
import { type RingConfigClose } from './ring-config';
|
|
17
|
-
import type { DeviceConfigRow, FirmwareExport, MappedBatch, MapperContext
|
|
17
|
+
import type { DeviceConfigRow, FirmwareExport, MappedBatch, MapperContext } from './types';
|
|
18
18
|
export interface MapFirmwareOptions {
|
|
19
19
|
/** Override for deterministic tests. Defaults to `new Date()`. */
|
|
20
20
|
now?: Date;
|
|
21
21
|
/**
|
|
22
|
-
* SCD-2 prior-config map keyed by
|
|
23
|
-
* `mapRingConfig`. Required whenever `fw.ring` is non-empty; the mapper
|
|
24
|
-
* skips ring-config translation entirely when this is absent and `fw.ring`
|
|
25
|
-
* has no windows.
|
|
22
|
+
* SCD-2 prior-config map keyed by metric id — see `mapRingConfig`.
|
|
26
23
|
*/
|
|
27
|
-
activePriorConfigs?: ReadonlyMap<
|
|
28
|
-
/**
|
|
29
|
-
* Consumer-provided translation from firmware ring metrics to schema
|
|
30
|
-
* fields. Required if `fw.ring.automaticMonitoringData` has entries;
|
|
31
|
-
* skipped (empty inserts + closes) if absent.
|
|
32
|
-
*/
|
|
33
|
-
translator?: RingConfigTranslator;
|
|
24
|
+
activePriorConfigs?: ReadonlyMap<string, DeviceConfigRow>;
|
|
34
25
|
}
|
|
35
26
|
export interface FirmwareMappedBatch extends MappedBatch {
|
|
36
27
|
device_config_closes: RingConfigClose[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"firmware.d.ts","sourceRoot":"","sources":["../../../src/sync/mapper/firmware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH,OAAO,EAAiB,KAAK,eAAe,EAAE,MAAM,eAAe,CAAA;AAInE,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,WAAW,EACX,aAAa,
|
|
1
|
+
{"version":3,"file":"firmware.d.ts","sourceRoot":"","sources":["../../../src/sync/mapper/firmware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH,OAAO,EAAiB,KAAK,eAAe,EAAE,MAAM,eAAe,CAAA;AAInE,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,WAAW,EACX,aAAa,EACd,MAAM,SAAS,CAAA;AAEhB,MAAM,WAAW,kBAAkB;IACjC,kEAAkE;IAClE,GAAG,CAAC,EAAE,IAAI,CAAA;IACV;;OAEG;IACH,kBAAkB,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;CAC1D;AAED,MAAM,WAAW,mBAAoB,SAAQ,WAAW;IACtD,oBAAoB,EAAE,eAAe,EAAE,CAAA;CACxC;AAED,wBAAgB,iBAAiB,CAC/B,EAAE,EAAE,cAAc,EAClB,GAAG,EAAE,aAAa,EAClB,IAAI,GAAE,kBAAuB,GAC5B,mBAAmB,CAsBrB"}
|
|
@@ -51,17 +51,11 @@ export function mapFirmwareExport(fw, ctx, opts = {}) {
|
|
|
51
51
|
* sub-mappers).
|
|
52
52
|
*/
|
|
53
53
|
function mapRingConfigIfPossible(fw, ctx, opts) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return { inserts: [], closes: [] };
|
|
57
|
-
}
|
|
58
|
-
if (!opts.translator) {
|
|
59
|
-
throw new Error('mapFirmwareExport: firmware ring.automaticMonitoringData has entries but no `translator` was provided in options');
|
|
60
|
-
}
|
|
54
|
+
// No consumer translator any more: the mapper reads the vendor struct
|
|
55
|
+
// directly and owns the dataType -> metric translation itself.
|
|
61
56
|
return mapRingConfig(fw.ring ?? { automaticMonitoringData: [] }, ctx, {
|
|
62
57
|
now: opts.now,
|
|
63
58
|
activePriorConfigs: opts.activePriorConfigs,
|
|
64
|
-
translator: opts.translator,
|
|
65
59
|
});
|
|
66
60
|
}
|
|
67
61
|
//# sourceMappingURL=firmware.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"firmware.js","sourceRoot":"","sources":["../../../src/sync/mapper/firmware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,aAAa,EAAwB,MAAM,eAAe,CAAA;AACnE,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"firmware.js","sourceRoot":"","sources":["../../../src/sync/mapper/firmware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,aAAa,EAAwB,MAAM,eAAe,CAAA;AACnE,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAqB9C,MAAM,UAAU,iBAAiB,CAC/B,EAAkB,EAClB,GAAkB,EAClB,OAA2B,EAAE;IAE7B,MAAM,QAAQ,G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;QACb,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;KAC5C,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -1,35 +1,85 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Ring config mapper (T-08).
|
|
2
|
+
* Ring config mapper (T-08, Sprint 5 T-09/T-10).
|
|
3
3
|
*
|
|
4
4
|
* Firmware `ring.automaticMonitoringData[]` describes which metrics the ring
|
|
5
|
-
* currently samples
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* currently samples and on what schedule. We store these as SCD-2-style rows
|
|
6
|
+
* in `device_config`, with `valid_from = now()` and `valid_to = null` on the
|
|
7
|
+
* new insert.
|
|
8
|
+
*
|
|
9
|
+
* ## The firmware boundary (principles 20 + 21)
|
|
10
|
+
*
|
|
11
|
+
* The vendor struct is `AutomaticMonitoring_J2301A` (JStyle J2301A SDK):
|
|
12
|
+
*
|
|
13
|
+
* ```c
|
|
14
|
+
* int mode;
|
|
15
|
+
* int startTime_Hour; int startTime_Minutes;
|
|
16
|
+
* int endTime_Hour; int endTime_Minutes;
|
|
17
|
+
* MyWeeks_J2301A weeks; // 7 booleans
|
|
18
|
+
* int intervalTime;
|
|
19
|
+
* int dataType; // 1 = heartRate, 2 = spo2, 3 = temperature, 4 = HRV
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* Everything firmware-shaped is translated here and nothing crosses into
|
|
23
|
+
* the warehouse: `dataType` becomes our metric id, split hour/minute fields
|
|
24
|
+
* become `HH:MM` strings, and the seven-boolean `weeks` struct becomes a
|
|
25
|
+
* bitmask. Principle 21 is explicit that firmware enums must not reach the
|
|
26
|
+
* schema, so `device_config` stores `metric`, never `data_type`.
|
|
27
|
+
*
|
|
28
|
+
* Prior versions inverted this: the mapper's input type had already
|
|
29
|
+
* discarded `dataType`, so a consumer-supplied `RingConfigTranslator` had
|
|
30
|
+
* to invent the enum back from our own metric names — the schema ended up
|
|
31
|
+
* holding a firmware integer that the app, not the firmware, produced.
|
|
8
32
|
*
|
|
9
33
|
* Closing prior config (SCD-2 semantics):
|
|
10
34
|
* The mapper accepts an optional `activePriorConfigs` map keyed by
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
35
|
+
* metric. For every metric present in the new snapshot, if a prior config
|
|
36
|
+
* was open, it emits a `close` entry so the sink can `UPDATE ... SET
|
|
37
|
+
* valid_to = now()` before the INSERT lands. Metrics present in the prior
|
|
38
|
+
* map but absent from the new snapshot are left open — the ring is silent
|
|
39
|
+
* on them, not disabling them.
|
|
40
|
+
*/
|
|
41
|
+
import type { DeviceConfigRow, FirmwareRingConfig, FirmwareWeekdays, MapperContext } from './types';
|
|
42
|
+
/**
|
|
43
|
+
* Firmware `dataType` → our metric id (Sprint 5 T-09).
|
|
44
|
+
*
|
|
45
|
+
* Verbatim from the vendor header's own comment. Note this is a **1:1**
|
|
46
|
+
* map: `dataType = 2` is SpO₂ alone, and temperature is its own code 3.
|
|
47
|
+
* The Sprint 5 spec described 2 as "spo2 + temperature (shared schedule)"
|
|
48
|
+
* requiring a fan-out to two rows; the SDK does not agree, so there is
|
|
49
|
+
* nothing to fan out.
|
|
50
|
+
*
|
|
51
|
+
* (Whether firmware *slaves* the two schedules together in practice is a
|
|
52
|
+
* separate, still-open question — but it would not change this mapping,
|
|
53
|
+
* only mean the ring reports two windows with identical timings.)
|
|
54
|
+
*/
|
|
55
|
+
export declare const FIRMWARE_DATA_TYPE_TO_METRIC: Readonly<Record<number, string>>;
|
|
56
|
+
/** Reverse map, for diagnostics and for keying prior-config reads. */
|
|
57
|
+
export declare const METRIC_TO_FIRMWARE_DATA_TYPE: Readonly<Record<string, number>>;
|
|
58
|
+
/**
|
|
59
|
+
* Translate a firmware `dataType` to the metric(s) it schedules.
|
|
60
|
+
*
|
|
61
|
+
* Returns an array for forward-compatibility — if a future firmware
|
|
62
|
+
* revision genuinely does share one code across metrics, this signature
|
|
63
|
+
* absorbs it without a breaking change.
|
|
64
|
+
*
|
|
65
|
+
* @throws on an unknown code, with the raw value in the message. Silently
|
|
66
|
+
* dropping an unrecognised code would mean a metric the ring is actively
|
|
67
|
+
* sampling never appears in `device_config`, and every cadence-dependent
|
|
68
|
+
* consumer would fall back to the `metric_metadata` default without
|
|
69
|
+
* anyone noticing.
|
|
70
|
+
*/
|
|
71
|
+
export declare function firmwareDataTypeToMetrics(dataType: number): string[];
|
|
72
|
+
/**
|
|
73
|
+
* Seven booleans → a 7-bit mask for `device_config.weeks`.
|
|
74
|
+
* Bit 0 = Sunday … bit 6 = Saturday. All-days is `0x7F`.
|
|
28
75
|
*/
|
|
29
|
-
|
|
76
|
+
export declare function weekdaysToBitmask(weeks: FirmwareWeekdays | undefined): number | null;
|
|
77
|
+
/** `HH:MM`, zero-padded. Null when the firmware supplied out-of-range values. */
|
|
78
|
+
export declare function formatClockTime(hour: number, minutes: number): string | null;
|
|
30
79
|
export interface RingConfigClose {
|
|
31
80
|
device_id: string;
|
|
32
|
-
|
|
81
|
+
/** Our metric id — matches `device_config.metric`. */
|
|
82
|
+
metric: string;
|
|
33
83
|
valid_to: Date;
|
|
34
84
|
}
|
|
35
85
|
export interface MapRingConfigResult {
|
|
@@ -38,10 +88,8 @@ export interface MapRingConfigResult {
|
|
|
38
88
|
}
|
|
39
89
|
export interface MapRingConfigOptions {
|
|
40
90
|
now?: Date;
|
|
41
|
-
/** Prior open configs for this device, keyed by
|
|
42
|
-
activePriorConfigs?: ReadonlyMap<
|
|
43
|
-
/** Required — consumer-provided translation from firmware to schema. */
|
|
44
|
-
translator: RingConfigTranslator;
|
|
91
|
+
/** Prior open configs for this device, keyed by metric id. */
|
|
92
|
+
activePriorConfigs?: ReadonlyMap<string, DeviceConfigRow>;
|
|
45
93
|
}
|
|
46
|
-
export declare function mapRingConfig(fw: FirmwareRingConfig, ctx: MapperContext, opts
|
|
94
|
+
export declare function mapRingConfig(fw: FirmwareRingConfig, ctx: MapperContext, opts?: MapRingConfigOptions): MapRingConfigResult;
|
|
47
95
|
//# sourceMappingURL=ring-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ring-config.d.ts","sourceRoot":"","sources":["../../../src/sync/mapper/ring-config.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"ring-config.d.ts","sourceRoot":"","sources":["../../../src/sync/mapper/ring-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,OAAO,KAAK,EACV,eAAe,EAEf,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACd,MAAM,SAAS,CAAA;AAEhB;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,4BAA4B,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAKxE,CAAA;AAEF,sEAAsE;AACtE,eAAO,MAAM,4BAA4B,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAIzE,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAcpE;AAOD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAOpF;AAED,iFAAiF;AACjF,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAI5E;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAA;IACjB,sDAAsD;IACtD,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EA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