@dabble/patches 0.4.0 → 0.4.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.
@@ -1,5 +1,5 @@
1
1
  import { JSONPatch } from './JSONPatch.js';
2
- import { createPathProxy } from './patchProxy.js';
2
+ import { createPathProxy } from './pathProxy.js';
3
3
  /**
4
4
  * Creates a `JSONPatch` instance using a path-only proxy for type-safe operation generation.
5
5
  *
@@ -61,7 +61,7 @@ export declare class PatchesServer {
61
61
  * @param mutator
62
62
  * @returns
63
63
  */
64
- change<T = Record<string, any>>(docId: string, mutator: (patch: JSONPatch, path: PathProxy<T>) => void, metadata?: Record<string, any>): Promise<Change | null>;
64
+ change<T = Record<string, any>>(docId: string, mutator: (patch: JSONPatch, root: PathProxy<T>) => void, metadata?: Record<string, any>): Promise<Change | null>;
65
65
  /**
66
66
  * Deletes a document.
67
67
  * @param docId The document ID.
package/dist/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
+ import { JSONPatch } from './json-patch/JSONPatch.js';
1
2
  import type { JSONPatchOp } from './json-patch/types.js';
2
- import type { JSONPatch } from './json-patch/JSONPatch.js';
3
3
  export interface Change {
4
4
  /** Unique identifier for the change, generated client-side. */
5
5
  id: string;
@@ -131,12 +131,16 @@ export interface ListVersionsOptions {
131
131
  * without null checks, but should only be used for path generation, not value access.
132
132
  */
133
133
  export type PathProxy<T> = {
134
- [P in keyof T]-?: T[P] extends object ? PathProxy<T[P]> : T[P];
134
+ [P in keyof T]-?: NonNullable<T[P]> extends object ? PathProxy<NonNullable<T[P]>> : {
135
+ toString: () => string;
136
+ };
137
+ } & {
138
+ toString: () => string;
135
139
  };
136
140
  /**
137
141
  * Type signature for change mutator functions that use path-only proxies.
138
142
  * The mutator receives a JSONPatch instance and a PathProxy for type-safe path creation.
139
143
  * All modifications must be done through explicit patch operations.
140
144
  */
141
- export type ChangeMutator<T> = (patch: JSONPatch, path: PathProxy<T>) => void;
145
+ export type ChangeMutator<T> = (patch: JSONPatch, root: PathProxy<T>) => void;
142
146
  export {};
package/dist/types.js CHANGED
@@ -1 +1 @@
1
- export {};
1
+ import { JSONPatch } from './json-patch/JSONPatch.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dabble/patches",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Immutable JSON Patch implementation based on RFC 6902 supporting operational transformation and last-writer-wins",
5
5
  "author": "Jacob Wright <jacwright@gmail.com>",
6
6
  "bugs": {
File without changes