@korajs/merge 0.0.0-canary-20261008174129

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Dr. Obed Ehoneah
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # @korajs/merge
2
+
3
+ Cross-record rules for Kora.js: constraint checks (unique, capacity, referential), referential
4
+ integrity on delete, and rich-text helpers.
5
+
6
+ > Most apps do not install this directly. Records are merged by the per-field fold in
7
+ > `@korajs/core` on every device and server; `createApp` and the sync server wire this package.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ pnpm add @korajs/merge@beta
13
+ ```
14
+
15
+ ## How Kora merges
16
+
17
+ Since 1.0.0-beta.13 every replica computes a record from its operations with one deterministic
18
+ per-field CRDT (the fold in `@korajs/core`), so the result depends only on the set of operations,
19
+ not their order or duplicates:
20
+
21
+ - strings, numbers, booleans, enums, timestamps: the later write wins (hybrid logical clock)
22
+ - arrays: an element set (concurrent additions and removals both apply)
23
+ - objects: per top-level key
24
+ - rich text: Yjs, character by character
25
+ - `.merge('counter' | 'max' | 'min' | 'append-only' | 'server-authoritative')` and custom
26
+ `resolve` functions where declared
27
+
28
+ Constraints span records, so the **sync server** enforces them: a violating operation is refused,
29
+ and races are corrected with deterministic server operations.
30
+
31
+ <!-- docs-check: standalone -->
32
+ ```typescript
33
+ import { defineSchema, t } from 'korajs'
34
+
35
+ export const schema = defineSchema({
36
+ version: 1,
37
+ collections: {
38
+ inventory: {
39
+ fields: {
40
+ sku: t.string(),
41
+ quantity: t.number().merge('counter'), // concurrent changes add up
42
+ },
43
+ constraints: [{ type: 'unique', fields: ['sku'], onConflict: 'first-write-wins' }],
44
+ },
45
+ },
46
+ })
47
+ ```
48
+
49
+ `MergeEngine` and the pairwise strategy functions implement the 1.0.0-beta.12 merge. They remain
50
+ only for `experimental.legacyMerge` in this release and will be removed.
51
+
52
+ ## Documentation
53
+
54
+ [Conflict Resolution](https://korajs.dev/guide/conflict-resolution) and the
55
+ [Merge API reference](https://korajs.dev/api/merge).
56
+
57
+ ## License
58
+
59
+ MIT