@recordtimelabel/core 0.1.0 → 0.1.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 +57 -55
- package/package.json +20 -20
- package/src/index.js +946 -809
package/README.md
CHANGED
|
@@ -1,55 +1,57 @@
|
|
|
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
|
-
During local development both apps consume it with:
|
|
15
|
-
|
|
16
|
-
```json
|
|
17
|
-
"@recordtimelabel/core": "file:../recordtimelabel-core"
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
For release builds, move this dependency to a git tag, npm package, or private registry version so builds do not depend on a sibling folder path.
|
|
21
|
-
|
|
22
|
-
## Public API
|
|
23
|
-
|
|
24
|
-
- `normalizeState(input)`
|
|
25
|
-
- `normalizeRecords(records, options)`
|
|
26
|
-
- `mergeLocalRemote({ localState, remoteState, pendingOps, clientId, now })`
|
|
27
|
-
- `applyOperation(state, operation)`
|
|
28
|
-
- `createSyncEngine({ storageAdapter, cloudAdapter, clientId, clock, logger })`
|
|
29
|
-
- `
|
|
30
|
-
- `
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
- `
|
|
39
|
-
- `
|
|
40
|
-
- `
|
|
41
|
-
- `
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
- `
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
```
|
|
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
|
+
During local development both apps consume it with:
|
|
15
|
+
|
|
16
|
+
```json
|
|
17
|
+
"@recordtimelabel/core": "file:../recordtimelabel-core"
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
For release builds, move this dependency to a git tag, npm package, or private registry version so builds do not depend on a sibling folder path.
|
|
21
|
+
|
|
22
|
+
## Public API
|
|
23
|
+
|
|
24
|
+
- `normalizeState(input)`
|
|
25
|
+
- `normalizeRecords(records, options)`
|
|
26
|
+
- `mergeLocalRemote({ localState, remoteState, pendingOps, clientId, now })`
|
|
27
|
+
- `applyOperation(state, operation)`
|
|
28
|
+
- `createSyncEngine({ storageAdapter, cloudAdapter, clientId, clock, logger })`
|
|
29
|
+
- `buildRecordTimeLabelSyncPayload({ data, previousCloudData, pendingOps, syncMode, clientId, now })`
|
|
30
|
+
- `RECORD_TIMELABEL_SYNC_MODES`
|
|
31
|
+
- `createOperation(type, payload, options)`
|
|
32
|
+
- `OPERATION_TYPES`
|
|
33
|
+
|
|
34
|
+
## Firestore v1 Compatibility
|
|
35
|
+
|
|
36
|
+
Phase 1 keeps the existing `users/{uid}` document shape:
|
|
37
|
+
|
|
38
|
+
- `folders`
|
|
39
|
+
- `records`
|
|
40
|
+
- `groupOrder`
|
|
41
|
+
- `folderOrder`
|
|
42
|
+
- `expandedGroups`
|
|
43
|
+
- `settings`
|
|
44
|
+
|
|
45
|
+
The core also normalizes and preserves these compatibility metadata fields:
|
|
46
|
+
|
|
47
|
+
- `rtlSyncMeta`
|
|
48
|
+
- `deletedRecordTombstones`
|
|
49
|
+
- `deletedFolderTombstones`
|
|
50
|
+
|
|
51
|
+
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.
|
|
52
|
+
|
|
53
|
+
## Test
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
npm test
|
|
57
|
+
```
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@recordtimelabel/core",
|
|
3
|
-
"version": "0.1.
|
|
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.1.1",
|
|
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
|
+
}
|