@uwrl/qc-utils 0.0.20 → 0.0.22
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/dist/index.js +1228 -1020
- package/dist/index.umd.cjs +14 -14
- package/dist/types/index.d.ts +35 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/plotting/__tests__/script.spec.d.ts +1 -0
- package/dist/utils/plotting/observation-record.d.ts +87 -6
- package/dist/utils/plotting/script.d.ts +67 -0
- package/package.json +3 -2
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QC History Script — save / load.
|
|
3
|
+
*
|
|
4
|
+
* See `docs/HISTORY_SCRIPT.md` for the full design rationale. The
|
|
5
|
+
* short version:
|
|
6
|
+
*
|
|
7
|
+
* - **Save:** walk `record.history`, strip runtime-only fields
|
|
8
|
+
* (`isLoading`, `duration`, `executionMode`, `selected`), keep
|
|
9
|
+
* `method`, `args`, and the optional `status` flag. Wrap with
|
|
10
|
+
* a `version`, `createdAt`, and the wall-clock `window` the
|
|
11
|
+
* consumer was working in.
|
|
12
|
+
*
|
|
13
|
+
* - **Load:** reset `history` + `redoStack`, `record.reload()`,
|
|
14
|
+
* then `record.dispatch(operations.map(o => [o.method, ...o.args]))`.
|
|
15
|
+
* Per-op failures are caught (the dispatch's own `catch` already
|
|
16
|
+
* marks the entry `status: "failed"`); we tally them in the
|
|
17
|
+
* returned `ApplyScriptReport` for the consumer to surface.
|
|
18
|
+
*
|
|
19
|
+
* - **No per-method serialization rules.** Args round-trip
|
|
20
|
+
* verbatim. Selection-coupled ops (DELETE_POINTS, INTERPOLATE,
|
|
21
|
+
* SHIFT_DATETIMES, DRIFT_CORRECTION, CHANGE_VALUES,
|
|
22
|
+
* ASSIGN_*_BULK) read their target indices off
|
|
23
|
+
* `history[length - 2].selected` at runtime — replay walks the
|
|
24
|
+
* ops in order so the SELECTION is in the right slot when the
|
|
25
|
+
* consumer fires.
|
|
26
|
+
*/
|
|
27
|
+
import { ApplyScriptReport, QcScript, QcScriptWindow } from "../../types";
|
|
28
|
+
import { ObservationRecord } from "./observation-record";
|
|
29
|
+
/** The schema version this loader / serializer understands. */
|
|
30
|
+
export declare const QC_SCRIPT_VERSION: "1";
|
|
31
|
+
/**
|
|
32
|
+
* Serialize an `ObservationRecord`'s history into a `QcScript`.
|
|
33
|
+
*
|
|
34
|
+
* @param record The record whose `.history` to serialize.
|
|
35
|
+
* @param window Wall-clock bounds the consumer was working in. The
|
|
36
|
+
* loader on the other end will fetch this range into the target
|
|
37
|
+
* record before replaying.
|
|
38
|
+
*/
|
|
39
|
+
export declare function serializeHistory(record: ObservationRecord, window: QcScriptWindow): QcScript;
|
|
40
|
+
/**
|
|
41
|
+
* Parse and validate a JSON-decoded payload as a `QcScript`. Throws
|
|
42
|
+
* on schema violations — callers should wrap in try/catch and
|
|
43
|
+
* surface the message to the user. Validation is deliberately
|
|
44
|
+
* minimal: structural shape, version, and per-op method recognition.
|
|
45
|
+
* Arg shape per method is the dispatcher's job.
|
|
46
|
+
*/
|
|
47
|
+
export declare function parseScript(json: unknown): QcScript;
|
|
48
|
+
/**
|
|
49
|
+
* Apply a parsed `QcScript` to a freshly-prepared `ObservationRecord`.
|
|
50
|
+
*
|
|
51
|
+
* Caller's responsibility BEFORE this runs:
|
|
52
|
+
* 1. Pick the target datastream (no id matching is enforced — see
|
|
53
|
+
* the design doc's "Stay reusable" goal).
|
|
54
|
+
* 2. Fetch the script's `window` into the record's raw data.
|
|
55
|
+
*
|
|
56
|
+
* What `applyScript` does:
|
|
57
|
+
* 1. Resets `history` + `redoStack` in-place (preserves the array
|
|
58
|
+
* reference so the consumer's reactive ref stays bound).
|
|
59
|
+
* 2. `await record.reload()` to restore from raw.
|
|
60
|
+
* 3. Dispatches operations one at a time so per-op failures can be
|
|
61
|
+
* caught and reported. Failures don't abort the remainder.
|
|
62
|
+
*
|
|
63
|
+
* Returns an `ApplyScriptReport` summarising the outcome. Per-op
|
|
64
|
+
* `HistoryItem.status` is also written by the dispatch path itself,
|
|
65
|
+
* so the UI can read failures directly off the history entries.
|
|
66
|
+
*/
|
|
67
|
+
export declare function applyScript(record: ObservationRecord, script: QcScript): Promise<ApplyScriptReport>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uwrl/qc-utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.22",
|
|
4
4
|
"description": "Quality Control Utilities",
|
|
5
5
|
"homepage": "https://github.com/hydroserver2/qc-utils#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
],
|
|
27
27
|
"type": "module",
|
|
28
28
|
"scripts": {
|
|
29
|
-
"build": "
|
|
29
|
+
"build": "vite build --mode prod && vue-tsc --declaration --emitDeclarationOnly",
|
|
30
|
+
"build:clean": "npm run clean:dist && npm run build",
|
|
30
31
|
"pub": "npm publish --access public",
|
|
31
32
|
"clean:dist": "rimraf dist",
|
|
32
33
|
"clean:coverage": "rimraf coverage",
|