@recordtimelabel/core 0.1.10 → 0.2.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.
Files changed (3) hide show
  1. package/README.md +58 -51
  2. package/package.json +20 -20
  3. package/src/index.js +1433 -795
package/README.md CHANGED
@@ -1,34 +1,34 @@
1
- # @recordtimelabel/core
2
-
3
- Shared RecordTimeLabel data model, normalization, merge logic, operation reducer, and sync engine.
4
-
5
- ## Scope
6
-
7
- This package is intentionally platform-neutral. It must not import React, Firebase, Chrome extension APIs, Electron APIs, or app-specific UI code.
8
-
9
- Current consumers:
10
-
11
- - `D:\Programming\RecordTimeLabel`
12
- - `D:\Programming\YouTwitchDownloader`
13
-
1
+ # @recordtimelabel/core
2
+
3
+ Shared RecordTimeLabel data model, normalization, merge logic, operation reducer, and sync engine.
4
+
5
+ ## Scope
6
+
7
+ This package is intentionally platform-neutral. It must not import React, Firebase, Chrome extension APIs, Electron APIs, or app-specific UI code.
8
+
9
+ Current consumers:
10
+
11
+ - `D:\Programming\RecordTimeLabel`
12
+ - `D:\Programming\YouTwitchDownloader`
13
+
14
14
  During local development an app can consume a sibling checkout with:
15
-
16
- ```json
17
- "@recordtimelabel/core": "file:../recordtimelabel-core"
18
- ```
19
-
20
- For release builds, consume a fixed npm package, git tag, or private registry version so builds do not depend on a sibling folder path. The current published release is:
21
15
 
22
16
  ```json
23
- "@recordtimelabel/core": "0.1.10"
17
+ "@recordtimelabel/core": "file:../recordtimelabel-core"
18
+ ```
19
+
20
+ For release builds, consume a fixed npm package, git tag, or private registry version so builds do not depend on a sibling folder path. The v2 gateway contract release is:
21
+
22
+ ```json
23
+ "@recordtimelabel/core": "0.2.0"
24
24
  ```
25
25
 
26
26
  If this checkout's `package.json` is ahead of the published version, publish the new package before updating consumers to that version.
27
-
28
- ## Public API
29
-
30
- - `normalizeState(input)`
31
- - `normalizeRecords(records, options)`
27
+
28
+ ## Public API
29
+
30
+ - `normalizeState(input)`
31
+ - `normalizeRecords(records, options)`
32
32
  - `mergeLocalRemote({ localState, remoteState, pendingOps, clientId, now })`
33
33
  - `applyOperation(state, operation)`
34
34
  - `applyRecordTimeLabelOperation(state, operation)`
@@ -45,6 +45,13 @@ If this checkout's `package.json` is ahead of the published version, publish the
45
45
  - `buildFirestoreV2DocumentsFromState(state, options)`
46
46
  - `buildFirestoreV2DocumentChangeSet(previousDocuments, nextDocuments, options)`
47
47
  - `buildStateFromFirestoreV2Documents(documents, options)`
48
+ - `validateRecordTimeLabelOperationBatch(body)`
49
+ - `buildFirestoreV2OperationReadPlan(operations)`
50
+ - `extendFirestoreV2OperationReadPlanWithRecords(readPlan, records)`
51
+ - `planFirestoreV2OperationChanges({ documents, operations, localState, now })`
52
+ - `estimateFirestoreV2WriteUnits(changes, overhead)`
53
+ - `buildOperationsFromSnapshotDiff({ previousState, nextState, now, operationIdPrefix, batchSize })`
54
+ - `RTL_SYNC_PROTOCOL_VERSION`
48
55
  - `hasMeaningfulRecordTimeLabelCloudState(data, options)`
49
56
  - `buildRecordTimeLabelContentFingerprint(data)`
50
57
  - `buildMigratedRecordTimeLabelV2State(legacyState, options)`
@@ -52,27 +59,27 @@ If this checkout's `package.json` is ahead of the published version, publish the
52
59
  - `RECORD_TIMELABEL_SYNC_MODES`
53
60
  - `createOperation(type, payload, options)`
54
61
  - `OPERATION_TYPES`
55
-
56
- ## Firestore v1 Compatibility
57
-
58
- Phase 1 keeps the existing `users/{uid}` document shape:
59
-
60
- - `folders`
61
- - `records`
62
- - `groupOrder`
63
- - `folderOrder`
64
- - `expandedGroups`
65
- - `settings`
66
-
67
- The core also normalizes and preserves these compatibility metadata fields:
68
-
69
- - `rtlSyncMeta`
70
- - `deletedRecordTombstones`
71
- - `deletedFolderTombstones`
72
-
62
+
63
+ ## Firestore v1 Compatibility
64
+
65
+ Phase 1 keeps the existing `users/{uid}` document shape:
66
+
67
+ - `folders`
68
+ - `records`
69
+ - `groupOrder`
70
+ - `folderOrder`
71
+ - `expandedGroups`
72
+ - `settings`
73
+
74
+ The core also normalizes and preserves these compatibility metadata fields:
75
+
76
+ - `rtlSyncMeta`
77
+ - `deletedRecordTombstones`
78
+ - `deletedFolderTombstones`
79
+
73
80
  Deletion must be represented by tombstones or operations. Do not reintroduce the old heuristic that treats "local exists but cloud missing for more than five minutes" as deletion.
74
81
 
75
- ## Firestore v2 Preparation
82
+ ## Firestore v2 Gateway Contract
76
83
 
77
84
  The package exposes platform-neutral v2 document helpers so app adapters can share the same record/folder/settings/ops shape before wiring Firebase SDK or REST calls:
78
85
 
@@ -81,10 +88,10 @@ The package exposes platform-neutral v2 document helpers so app adapters can sha
81
88
  - `users/{uid}/recordTimeLabel/main/folders/{folderId}`: per-folder documents
82
89
  - `users/{uid}/recordTimeLabel/main/ops/{opId}`: pending operation documents
83
90
 
84
- These helpers do not import Firebase and do not perform network writes.
85
-
86
- ## Test
87
-
88
- ```bash
89
- npm test
90
- ```
91
+ The v2 validator, bounded read planner, pure mutation planner, cost estimator, and snapshot-diff batch builder are also platform-neutral. They do not import Firebase and do not perform network writes. Functions and clients must use this package instead of maintaining app-specific planner copies.
92
+
93
+ ## Test
94
+
95
+ ```bash
96
+ npm test
97
+ ```
package/package.json CHANGED
@@ -1,20 +1,20 @@
1
- {
2
- "name": "@recordtimelabel/core",
3
- "version": "0.1.10",
4
- "type": "module",
5
- "description": "Shared RecordTimeLabel data model, merge logic, operations, and sync engine.",
6
- "main": "./src/index.js",
7
- "exports": {
8
- ".": "./src/index.js"
9
- },
10
- "scripts": {
11
- "test": "node --test tests/*.test.mjs"
12
- },
13
- "engines": {
14
- "node": ">=18.0.0"
15
- },
16
- "files": [
17
- "src",
18
- "README.md"
19
- ]
20
- }
1
+ {
2
+ "name": "@recordtimelabel/core",
3
+ "version": "0.2.0",
4
+ "type": "module",
5
+ "description": "Shared RecordTimeLabel data model, merge logic, operations, and sync engine.",
6
+ "main": "./src/index.js",
7
+ "exports": {
8
+ ".": "./src/index.js"
9
+ },
10
+ "scripts": {
11
+ "test": "node --test tests/*.test.mjs"
12
+ },
13
+ "engines": {
14
+ "node": ">=18.0.0"
15
+ },
16
+ "files": [
17
+ "src",
18
+ "README.md"
19
+ ]
20
+ }