@shapeshift-labs/frontier-mutation 0.1.0 → 0.1.2

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 Shapeshift Labs
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 CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  Explicit mutation and selector plans for Frontier.
4
4
 
5
+ Repository: [siliconjungle/-shapeshift-labs-frontier-mutation](https://github.com/siliconjungle/-shapeshift-labs-frontier-mutation)
6
+
7
+ Built on the core JSON diff/apply package: [`@shapeshift-labs/frontier`](https://github.com/siliconjungle/-shapeshift-labs-frontier).
8
+
5
9
  ```sh
6
10
  npm install @shapeshift-labs/frontier @shapeshift-labs/frontier-mutation
7
11
  ```
@@ -13,7 +17,9 @@ import { createMutationPlan, select } from '@shapeshift-labs/frontier-mutation';
13
17
 
14
18
  const enemies = select('/entities/*')
15
19
  .where('type', '==', 'enemy')
16
- .and('hp', '>', 0);
20
+ .and('hp', '>', 0)
21
+ .keyBy('id')
22
+ .indexBy('id');
17
23
 
18
24
  const plan = createMutationPlan()
19
25
  .forEach(enemies)
@@ -24,6 +30,175 @@ const result = plan.compilePatch(state);
24
30
 
25
31
  The compiled patch contains concrete paths, indexes, and values. Queries are compile-time selectors, not replay-time patch semantics.
26
32
 
33
+ The public surface is intentionally small: build selectors, build a mutation plan, then compile or commit it. Planner choices, compiler passes, and CRDT lowering stay behind options and result metadata.
34
+
35
+ ## Performance
36
+
37
+ Frontier Mutation was measured from this package on Node v26.1.0, darwin arm64. Timings are median microseconds per operation across warmed samples; p95 is shown to make noise visible. Patch bytes are `JSON.stringify(patch)` bytes because this package emits Frontier patches and does not own binary transport encoding.
38
+
39
+ | Fixture | Matches | Strategy | Patch | Bytes | Compile median | Compile p95 | Apply median |
40
+ | --- | ---: | --- | ---: | ---: | ---: | ---: | ---: |
41
+ | Selector increment, 1% sparse 10k-row table | 100 | row-field | 1 op | 1.0 KiB | 3.55 ms | 4.04 ms | 10.35 us |
42
+ | Selector increment, indexed id IN | 100 | row-field | 1 op | 1.0 KiB | 2.84 ms | 3.12 ms | 8.77 us |
43
+ | Selector increment, 10% 10k-row table | 1,000 | row-field | 1 op | 8.5 KiB | 4.10 ms | 4.90 ms | 20.33 us |
44
+ | Repeated arithmetic fold, 1000x | 0 | direct | 1 op | 20 B | 0.45 us | 0.78 us | 0.05 us |
45
+ | Repeated text append fold, 1000x | 0 | direct | 1 op | 1.0 KiB | 0.55 us | 0.72 us | 0.10 us |
46
+
47
+ These are Frontier-only package measurements, not a competitor comparison. Hardware, Node version, selector shape, and table size will affect absolute timings.
48
+
49
+ ## API Overview
50
+
51
+ ```ts
52
+ import {
53
+ compileMutationPlan,
54
+ commitCrdtMutation,
55
+ commitMutation,
56
+ createMutationPlan,
57
+ createSelectorRegistry,
58
+ select,
59
+ type MutationCompileResult,
60
+ type MutationPlannerDecision,
61
+ type MutationPlanLike,
62
+ type MutationStateEngine
63
+ } from '@shapeshift-labs/frontier-mutation';
64
+ ```
65
+
66
+ Core exports:
67
+
68
+ - `select(path)` creates a selector builder for array/object-map rows.
69
+ - `createSelectorRegistry(initial?)` stores reusable named selectors.
70
+ - `createMutationPlan()` creates a fluent mutation plan.
71
+ - `compileMutationPlan(plan, state, options?)` compiles intent into a normal Frontier patch.
72
+ - `commitMutation(stateEngine, plan, options?)` compiles and commits to any state engine with `get()` and `commitPatch()`.
73
+ - `commitCrdtMutation(doc, plan, options?)` lowers safe intent to native CRDT operations when the document supports them.
74
+
75
+ The package has a peer dependency on the core package only. State and CRDT integration use small structural interfaces, so the mutation package does not force the full state or CRDT packages into the core import path.
76
+
77
+ ## Selectors
78
+
79
+ Selectors support arrays, object maps, and multiple wildcard segments:
80
+
81
+ ```js
82
+ const inNestedRooms = select('/rooms/*/entities/*')
83
+ .where('type', '==', 'enemy')
84
+ .keyBy('id');
85
+
86
+ const byMapKey = select('/entitiesById/*')
87
+ .where('$key', 'in', ['e1', 'e2'])
88
+ .keyBy('$key');
89
+ ```
90
+
91
+ `$key` targets the current object-map key and `$index` targets the current array index. `keyBy(path)` controls the stable match key reported in `result.matches`; `indexBy(path)` is a compile-time hint for equality/in selectors on hot entity tables and object maps.
92
+
93
+ Selectors can also make the mutation target deterministic with ordering, limits, and projections:
94
+
95
+ ```js
96
+ const strongestEnemy = select('/entities/*')
97
+ .where('type', '==', 'enemy')
98
+ .orderBy('hp', 'desc')
99
+ .first()
100
+ .project('id', 'hp')
101
+ .keyBy('id');
102
+ ```
103
+
104
+ `limit(n)` caps matched rows after ordering, `first()` is `limit(1)`, and `project(...)` adds a compact field projection to `result.matches` for diagnostics and agent-readable explanations.
105
+
106
+ Reusable selectors can be named and stored in a registry:
107
+
108
+ ```js
109
+ import { createSelectorRegistry } from '@shapeshift-labs/frontier-mutation';
110
+
111
+ const selectors = createSelectorRegistry()
112
+ .define('activeEnemies', enemies.named('activeEnemies'));
113
+
114
+ const plan = createMutationPlan()
115
+ .forEach(selectors.get('activeEnemies'))
116
+ .increment('hp', -5);
117
+ ```
118
+
119
+ Selectors can also be scoped with a callback so later operations return to the previous selector:
120
+
121
+ ```js
122
+ const plan = createMutationPlan()
123
+ .forEach(enemies, (rows) => {
124
+ rows.increment('hp', -5)
125
+ .append('tags', 'damaged');
126
+ })
127
+ .increment('/turn', 1);
128
+ ```
129
+
130
+ `compilePatch()` runs a small planner before it emits the patch. In `auto` mode it chooses between direct patch emission, row-field assignment, dirty-row/dirty-path diffing, and materialize-and-diff fallback based on the mutation shape and selector selectivity.
131
+
132
+ ```js
133
+ const result = plan.compilePatch(state, {
134
+ planner: {
135
+ strategy: 'auto',
136
+ schema: {
137
+ tables: [{
138
+ path: '/entities',
139
+ key: 'id',
140
+ stableRowShape: true,
141
+ numericFields: ['hp', 'stats.score'],
142
+ textFields: ['name', 'zoneId'],
143
+ listFields: ['tags'],
144
+ selectorFields: ['id', 'type', 'hp', 'zoneId']
145
+ }]
146
+ },
147
+ dirtyDiffMinSelectivity: 0.75
148
+ }
149
+ });
150
+
151
+ result.decisions;
152
+ // [{ strategy: 'row-field' | 'dirty-diff' | 'direct' | ... }]
153
+ ```
154
+
155
+ Strategies can be forced for diagnostics or benchmarking with `direct`, `row-field`, `dirty-diff`, or `materialize-diff`.
156
+
157
+ Schema hints are trusted table/entity contracts. The key field becomes the default selector `keyBy`/`indexBy`, stable row shape lets the planner reuse selector matches across adjacent mutations that do not touch declared selector fields, and known numeric/text/list fields are reported in planner decisions for debugging and downstream specialization.
158
+
159
+ If you already use `createDiffEngine()` with schema, profile, or adaptive settings, pass it as `planner.diffEngine`. The planner will use that engine when it chooses a dirty diff or materialize-and-diff path.
160
+
161
+ ## Mutation Operations
162
+
163
+ Plan methods include:
164
+
165
+ - object/value: `set`, `unset`, `remove`, `ensure`, `upsert`, `assign`, `rename`, `copy`, `move`
166
+ - numbers: `increment`, `decrement`, `multiply`, `min`, `max`, `clamp`
167
+ - booleans: `toggle`
168
+ - arrays/lists: `append`, `prepend`, `splice`, `insert`, `removeAt`, `moveItem`, `addToSet`, `pull`, `removeWhere`
169
+ - text: `appendText`, `insertText`, `deleteText`, `replaceText`, `spliceText`, `formatText`
170
+ - guards: `test`, `compareAndSet`
171
+ - control: `forEach`, `where`, `clearSelector`, `transaction`, `repeat`, `explain`
172
+
173
+ Examples:
174
+
175
+ ```js
176
+ const plan = createMutationPlan()
177
+ .ensure('/session', { started: true })
178
+ .upsert('/profile', { level: 3 })
179
+ .compareAndSet('/version', 1, 2)
180
+ .insert('/items', 0, { id: 'first' })
181
+ .addToSet('/tags', ['new', 'seen'])
182
+ .replaceText('/title', 0, 5, 'Draft')
183
+ .transaction((tx) => {
184
+ tx.rename('/profile/name', 'label');
185
+ tx.remove('/profile/stale');
186
+ }, { origin: 'agent-edit' });
187
+
188
+ const explanation = plan.explain(state);
189
+ ```
190
+
191
+ `test(path, expected)` and `compareAndSet(path, expected, next)` are compile-time guards. If the current state does not match `expected`, compilation throws before a patch or CRDT update is emitted.
192
+
193
+ Compiled results include:
194
+
195
+ - `patch`: the Frontier patch to apply or send
196
+ - `matched`: weighted selector matches
197
+ - `lowered`: lowering notes for diagnostics
198
+ - `dirtyPaths` / `dirtyRows`: locality passed to diff planning
199
+ - `matches`: selector matches with resolved paths
200
+ - `decisions`: planner choices and reasons
201
+
27
202
  Adjacent arithmetic and repeated calls are folded where Frontier can represent the result compactly:
28
203
 
29
204
  ```js
@@ -35,11 +210,41 @@ plan.compilePatch({ count: 0 }).patch;
35
210
  // [[OP_SET, ['count'], 50]]
36
211
  ```
37
212
 
213
+ The compiler also folds adjacent compatible operations before lowering:
214
+
215
+ - arithmetic runs such as `+1, +2, -1` become one `+2`
216
+ - repeated list appends and text appends become one append operation
217
+ - statically empty repeats and even toggle repeats are removed
218
+ - selector operations can merge only when the mutation cannot affect selector membership
219
+
220
+ Selector row-field batching still checks the resolved row set at compile time. If a selector-targeted mutation changes which rows match the next operation, the compiler leaves a barrier and emits separate row-field frontiers.
221
+
38
222
  State engines and CRDT documents can be committed directly:
39
223
 
40
224
  ```js
41
225
  import { commitCrdtMutation, commitMutation } from '@shapeshift-labs/frontier-mutation';
42
226
 
43
227
  commitMutation(stateEngine, plan);
44
- commitCrdtMutation(doc, plan);
228
+ plan.commit(stateEngine);
229
+
230
+ commitCrdtMutation(doc, plan, {
231
+ planner: {
232
+ crdt: 'auto',
233
+ crdtAssignmentPolicy: 'preserve-conflicts',
234
+ crdtMetadata: { source: 'combat-system' }
235
+ }
236
+ });
237
+ plan.commitCrdt(doc);
45
238
  ```
239
+
240
+ CRDT commits lower intent to native operations when that is semantically safe:
241
+
242
+ - arithmetic becomes native counters
243
+ - list appends, inserts, removes, moves, and splices become native list operations
244
+ - text appends, inserts, deletes, replaces, and safe text splices become native text operations
245
+ - object field updates can become map field assignments instead of whole-object replacement
246
+ - deletes can become native CRDT tombstones
247
+
248
+ `crdtAssignmentPolicy` controls assignment lowering. `preserve-conflicts` keeps object updates at field granularity so concurrent same-field register conflicts remain inspectable and resolvable. `last-write-wins` and `materialize` keep the older whole-value materialization behavior for assignment-shaped operations.
249
+
250
+ `crdtMetadata` is passed through Frontier's durable CRDT update metadata. The returned `crdtDecisions` list also includes per-operation debug metadata with the chosen strategy, reason, path, repeat count, and operation size summary.
package/dist/index.d.ts CHANGED
@@ -1,8 +1,47 @@
1
- import { type JsonObject, type JsonPath, type JsonValue, type ObjectKey, type Patch } from '@shapeshift-labs/frontier';
2
- import type { StateEngine } from '@shapeshift-labs/frontier/state';
3
- import type { CrdtCommitResult, CrdtDocument } from '@shapeshift-labs/frontier/crdt';
1
+ import { type DiffOptions, type JsonObject, type JsonPath, type JsonValue, type ObjectKey, type Patch } from '@shapeshift-labs/frontier';
4
2
  export type MutationPath = string | JsonPath;
3
+ export interface MutationStateEngine {
4
+ get(): JsonValue;
5
+ commitPatch(patch: Patch): unknown;
6
+ }
7
+ export type MutationCrdtCommit = unknown;
8
+ export interface MutationCrdtDocument {
9
+ toJSON(): JsonValue;
10
+ change(callback: (tx: MutationCrdtTransaction) => void, options?: {
11
+ metadata?: JsonObject;
12
+ }): MutationCrdtCommit;
13
+ changesSince(frontier: null | JsonValue): Array<{
14
+ type: string;
15
+ path: JsonPath;
16
+ keys?: string[];
17
+ }>;
18
+ }
19
+ export interface MutationCrdtCounterHandle {
20
+ increment(delta: number): void;
21
+ decrement(delta: number): void;
22
+ }
23
+ export interface MutationCrdtTextHandle {
24
+ insert(index: number, text: string): void;
25
+ splice(index: number, deleteCount: number, text?: string): void;
26
+ }
27
+ export interface MutationCrdtListHandle {
28
+ insert(index: number, values: JsonValue[]): void;
29
+ delete(index: number, count?: number): void;
30
+ move(fromIndex: number, toIndex: number, count?: number): void;
31
+ }
32
+ export interface MutationCrdtMapHandle {
33
+ set(key: ObjectKey, value: JsonValue): void;
34
+ }
35
+ export interface MutationCrdtTransaction {
36
+ set(path: JsonPath, value: JsonValue): void;
37
+ delete(path: JsonPath): void;
38
+ counter(path: JsonPath): MutationCrdtCounterHandle;
39
+ text(path: JsonPath): MutationCrdtTextHandle;
40
+ list(path: JsonPath): MutationCrdtListHandle;
41
+ map(path: JsonPath): MutationCrdtMapHandle;
42
+ }
5
43
  export type SelectorOperator = '==' | 'eq' | '!=' | 'neq' | '>' | 'gt' | '>=' | 'gte' | '<' | 'lt' | '<=' | 'lte' | 'in' | 'exists';
44
+ export type SelectorOrderDirection = 'asc' | 'desc';
6
45
  export type SelectorCondition = {
7
46
  field: MutationPath;
8
47
  op?: SelectorOperator;
@@ -22,30 +61,141 @@ export type SelectorCondition = {
22
61
  } | {
23
62
  not: SelectorCondition;
24
63
  };
25
- export type MutationOperationKind = 'set' | 'assign' | 'increment' | 'decrement' | 'toggle' | 'append' | 'splice' | 'appendText' | 'spliceText';
64
+ export type MutationOperationKind = 'set' | 'unset' | 'remove' | 'ensure' | 'upsert' | 'assign' | 'increment' | 'decrement' | 'multiply' | 'min' | 'max' | 'clamp' | 'toggle' | 'append' | 'prepend' | 'splice' | 'insert' | 'removeAt' | 'moveItem' | 'addToSet' | 'pull' | 'removeWhere' | 'appendText' | 'spliceText' | 'insertText' | 'deleteText' | 'replaceText' | 'formatText' | 'move' | 'copy' | 'rename' | 'test' | 'compareAndSet';
65
+ export type MutationValueFactory = (current: JsonValue | undefined, path: JsonPath) => JsonValue;
66
+ export type MutationArrayPredicate = (value: JsonValue, index: number, array: readonly JsonValue[]) => boolean;
67
+ export interface MutationTransactionOptions {
68
+ origin?: string;
69
+ metadata?: JsonObject;
70
+ timestamp?: number;
71
+ }
72
+ export interface MutationTransactionInfo {
73
+ origin?: string;
74
+ metadata?: JsonObject;
75
+ timestamp?: number;
76
+ }
26
77
  export interface SelectorPlan {
27
78
  path: JsonPath;
28
79
  conditions: SelectorCondition[];
29
- keyBy?: ObjectKey;
80
+ keyBy?: JsonPath;
81
+ indexBy?: JsonPath;
82
+ orderBy?: {
83
+ path: JsonPath;
84
+ direction: SelectorOrderDirection;
85
+ };
86
+ limit?: number;
87
+ project?: JsonPath[];
88
+ name?: string;
89
+ }
90
+ export interface MutationTableSchema {
91
+ /** Path to an array table or object-map table, without the wildcard segment. */
92
+ path: MutationPath;
93
+ /** Stable row identity field. Used as default keyBy/indexBy for selectors over this table. */
94
+ key?: MutationPath;
95
+ /** Trusted claim that row objects have a stable field layout. */
96
+ stableRowShape?: boolean;
97
+ /** Fields known to contain numbers. */
98
+ numericFields?: MutationPath[];
99
+ /** Fields known to contain strings. */
100
+ textFields?: MutationPath[];
101
+ /** Fields known to contain arrays/lists. */
102
+ listFields?: MutationPath[];
103
+ /** Fields expected to participate in selector predicates for this table. */
104
+ selectorFields?: MutationPath[];
105
+ }
106
+ export interface MutationShapeSchema {
107
+ tables?: MutationTableSchema[];
108
+ /** Alias for table-like entity collections. */
109
+ entities?: MutationTableSchema[];
30
110
  }
111
+ export type MutationSchemaInput = MutationShapeSchema | MutationTableSchema[];
31
112
  export interface MutationOperation {
32
113
  kind: MutationOperationKind;
33
114
  path: JsonPath;
115
+ to?: JsonPath;
116
+ key?: ObjectKey;
34
117
  value?: JsonValue;
118
+ expected?: JsonValue;
35
119
  values?: JsonValue[];
120
+ factory?: MutationValueFactory;
121
+ predicate?: MutationArrayPredicate;
36
122
  start?: number;
123
+ toIndex?: number;
37
124
  deleteCount?: number;
125
+ length?: number;
38
126
  text?: string;
127
+ attributes?: JsonObject;
39
128
  delta?: number;
129
+ min?: number;
130
+ max?: number;
40
131
  repeat: number;
41
132
  selector?: SelectorPlan;
133
+ transaction?: MutationTransactionInfo;
42
134
  }
43
135
  export interface MutationCompileOptions {
44
136
  compact?: boolean;
137
+ strategy?: MutationPatchStrategy;
138
+ diff?: DiffOptions;
139
+ planner?: MutationPlannerOptions;
140
+ }
141
+ export type MutationPatchStrategy = 'auto' | 'direct' | 'row-field' | 'dirty-diff' | 'materialize-diff';
142
+ export type MutationPlannerDecisionStrategy = 'direct' | 'row-field' | 'dirty-diff' | 'materialize-diff' | 'noop';
143
+ export type MutationCrdtStrategy = 'auto' | 'native' | 'materialize';
144
+ export type MutationCrdtDecisionStrategy = 'native-counter' | 'native-text' | 'native-text-splice' | 'native-list' | 'native-map-field' | 'native-delete' | 'materialized-set' | 'noop';
145
+ export type MutationCrdtAssignmentPolicy = 'preserve-conflicts' | 'last-write-wins' | 'materialize';
146
+ export interface MutationDiffEngine {
147
+ diff(source: JsonValue, target: JsonValue, options?: DiffOptions): Patch;
148
+ }
149
+ export interface MutationPlannerOptions {
150
+ strategy?: MutationPatchStrategy;
151
+ crdt?: MutationCrdtStrategy;
152
+ crdtAssignmentPolicy?: MutationCrdtAssignmentPolicy;
153
+ crdtMetadata?: JsonObject;
154
+ schema?: MutationSchemaInput;
155
+ diff?: DiffOptions;
156
+ diffEngine?: MutationDiffEngine;
157
+ dirtyDiffMinSelectivity?: number;
158
+ }
159
+ export interface MutationDirtyRowsFrontier {
160
+ path: JsonPath;
161
+ rows: number[];
162
+ fields?: JsonPath[];
163
+ }
164
+ export interface MutationPlannerDecision {
165
+ strategy: MutationPlannerDecisionStrategy;
166
+ reason: string;
167
+ kind: MutationOperationKind;
168
+ path: JsonPath;
169
+ selectorPath?: JsonPath;
170
+ matched?: number;
171
+ collectionSize?: number;
172
+ selectivity?: number | null;
173
+ dirtyPaths?: JsonPath[];
174
+ dirtyRows?: MutationDirtyRowsFrontier[];
175
+ schema?: MutationPlannerSchemaDecision;
176
+ }
177
+ export interface MutationPlannerSchemaDecision {
178
+ tablePath: JsonPath;
179
+ key?: JsonPath;
180
+ stableRowShape: boolean;
181
+ fieldKind?: 'numeric' | 'text' | 'list';
182
+ selectorCached?: boolean;
183
+ selectorIndexed?: boolean;
184
+ }
185
+ export interface MutationCrdtPlannerDecision {
186
+ strategy: MutationCrdtDecisionStrategy;
187
+ reason: string;
188
+ kind: MutationOperationKind;
189
+ path: JsonPath;
190
+ selectorPath?: JsonPath;
191
+ native: boolean;
192
+ assignmentPolicy?: MutationCrdtAssignmentPolicy;
193
+ metadata?: JsonObject;
45
194
  }
46
195
  export interface MutationSelectorMatch {
47
196
  path: JsonPath;
48
197
  row: ObjectKey;
198
+ projection?: JsonObject;
49
199
  }
50
200
  export interface MutationCompileResult {
51
201
  patch: Patch;
@@ -59,14 +209,23 @@ export interface MutationCompileResult {
59
209
  }>;
60
210
  warnings: string[];
61
211
  matches: MutationSelectorMatch[];
212
+ decisions: MutationPlannerDecision[];
213
+ }
214
+ export interface MutationPlanExplanation extends MutationCompileResult {
215
+ operations: MutationOperation[];
216
+ operationCount: number;
217
+ patchOperationCount: number;
62
218
  }
63
219
  export interface MutationCrdtCommitResult extends MutationCompileResult {
64
- commit: CrdtCommitResult;
220
+ commit: MutationCrdtCommit;
221
+ crdtDecisions: MutationCrdtPlannerDecision[];
65
222
  }
66
223
  export interface MutationPlanLike {
67
224
  readonly operations: readonly MutationOperation[];
68
225
  compilePatch(state: JsonValue | undefined, options?: MutationCompileOptions): MutationCompileResult;
69
226
  }
227
+ export type MutationPlanScope = (plan: MutationPlan) => void;
228
+ type SelectorRegistryInit = Record<string, SelectorBuilder | SelectorPlan> | Iterable<readonly [string, SelectorBuilder | SelectorPlan]>;
70
229
  export declare class SelectorBuilder {
71
230
  private readonly plan;
72
231
  constructor(path: MutationPath);
@@ -74,32 +233,77 @@ export declare class SelectorBuilder {
74
233
  and(fieldOrCondition: MutationPath | SelectorCondition, op?: SelectorOperator, value?: JsonValue | JsonValue[]): this;
75
234
  or(...conditions: SelectorCondition[]): this;
76
235
  not(condition: SelectorCondition): this;
77
- keyBy(key: ObjectKey): this;
236
+ keyBy(key: MutationPath): this;
237
+ indexBy(key?: MutationPath): this;
238
+ orderBy(path: MutationPath, direction?: SelectorOrderDirection): this;
239
+ limit(count: number): this;
240
+ first(): this;
241
+ project(...fields: MutationPath[]): this;
242
+ named(name: string): this;
78
243
  toPlan(): SelectorPlan;
79
244
  }
245
+ export declare class SelectorRegistry {
246
+ private readonly selectors;
247
+ constructor(initial?: SelectorRegistryInit);
248
+ define(name: string, selector: SelectorBuilder | SelectorPlan): this;
249
+ get(name: string): SelectorPlan;
250
+ has(name: string): boolean;
251
+ entries(): Array<[string, SelectorPlan]>;
252
+ }
80
253
  export declare class MutationPlan implements MutationPlanLike {
81
254
  private readonly ops;
82
255
  private currentSelector;
256
+ private readonly transactionStack;
83
257
  get operations(): readonly MutationOperation[];
84
- forEach(selector: SelectorBuilder | SelectorPlan): this;
258
+ forEach(selector: SelectorBuilder | SelectorPlan, scope?: MutationPlanScope): this;
85
259
  where(path: MutationPath, condition?: SelectorCondition): this;
86
260
  clearSelector(): this;
87
261
  set(path: MutationPath, value: JsonValue): this;
262
+ unset(path: MutationPath): this;
263
+ remove(path: MutationPath): this;
264
+ ensure(path: MutationPath, defaultValue: JsonValue | MutationValueFactory): this;
265
+ upsert(path: MutationPath, value: JsonValue | MutationValueFactory): this;
88
266
  assign(path: MutationPath, value: JsonObject): this;
89
267
  increment(path: MutationPath, delta?: number): this;
90
268
  decrement(path: MutationPath, delta?: number): this;
269
+ multiply(path: MutationPath, factor: number): this;
270
+ min(path: MutationPath, value: number): this;
271
+ max(path: MutationPath, value: number): this;
272
+ clamp(path: MutationPath, min: number, max: number): this;
91
273
  toggle(path: MutationPath): this;
92
274
  append(path: MutationPath, values: JsonValue | JsonValue[]): this;
275
+ prepend(path: MutationPath, values: JsonValue | JsonValue[]): this;
93
276
  splice(path: MutationPath, start: number, deleteCount: number, values?: JsonValue[]): this;
277
+ insert(path: MutationPath, index: number, values: JsonValue | JsonValue[]): this;
278
+ removeAt(path: MutationPath, index: number, count?: number): this;
279
+ moveItem(path: MutationPath, fromIndex: number, toIndex: number, count?: number): this;
280
+ addToSet(path: MutationPath, values: JsonValue | JsonValue[]): this;
281
+ pull(path: MutationPath, values: JsonValue | JsonValue[]): this;
282
+ removeWhere(path: MutationPath, predicate: MutationArrayPredicate): this;
94
283
  appendText(path: MutationPath, text: string): this;
95
284
  spliceText(path: MutationPath, start: number, deleteCount: number, text?: string): this;
285
+ insertText(path: MutationPath, index: number, text: string): this;
286
+ deleteText(path: MutationPath, index: number, count: number): this;
287
+ replaceText(path: MutationPath, index: number, count: number, text: string): this;
288
+ formatText(path: MutationPath, index: number, length: number, attributes: JsonObject): this;
289
+ move(from: MutationPath, to: MutationPath): this;
290
+ copy(from: MutationPath, to: MutationPath): this;
291
+ rename(path: MutationPath, newKey: ObjectKey): this;
292
+ test(path: MutationPath, expected: JsonValue): this;
293
+ compareAndSet(path: MutationPath, expected: JsonValue, next: JsonValue | MutationValueFactory): this;
294
+ transaction(scope: MutationPlanScope, options?: MutationTransactionOptions): this;
96
295
  repeat(count: number): this;
97
296
  compilePatch(state: JsonValue | undefined, options?: MutationCompileOptions): MutationCompileResult;
297
+ commit(state: MutationStateEngine, options?: MutationCompileOptions): MutationCompileResult;
298
+ commitCrdt(doc: MutationCrdtDocument, options?: MutationCompileOptions): MutationCrdtCommitResult;
299
+ explain(state: JsonValue | undefined, options?: MutationCompileOptions): MutationPlanExplanation;
98
300
  private push;
99
301
  }
100
302
  export declare function select(path: MutationPath): SelectorBuilder;
101
303
  export declare function createMutationPlan(): MutationPlan;
304
+ export declare function createSelectorRegistry(initial?: SelectorRegistryInit): SelectorRegistry;
102
305
  export declare function compileMutationPlan(plan: MutationPlanLike, state: JsonValue | undefined, options?: MutationCompileOptions): MutationCompileResult;
103
- export declare function commitMutation(state: StateEngine, plan: MutationPlanLike, options?: MutationCompileOptions): MutationCompileResult;
104
- export declare function commitCrdtMutation(doc: CrdtDocument, plan: MutationPlanLike, options?: MutationCompileOptions): MutationCrdtCommitResult;
306
+ export declare function commitMutation(state: MutationStateEngine, plan: MutationPlanLike, options?: MutationCompileOptions): MutationCompileResult;
307
+ export declare function commitCrdtMutation(doc: MutationCrdtDocument, plan: MutationPlanLike, options?: MutationCompileOptions): MutationCrdtCommitResult;
308
+ export {};
105
309
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAUL,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,KAAK,EAGX,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAmB,MAAM,gCAAgC,CAAC;AAEtG,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,QAAQ,CAAC;AAE7C,MAAM,MAAM,gBAAgB,GACxB,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,KAAK,GACL,GAAG,GACH,IAAI,GACJ,IAAI,GACJ,KAAK,GACL,GAAG,GACH,IAAI,GACJ,IAAI,GACJ,KAAK,GACL,IAAI,GACJ,QAAQ,CAAC;AAEb,MAAM,MAAM,iBAAiB,GACzB;IAAE,KAAK,EAAE,YAAY,CAAC;IAAC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