@dabble/patches 0.4.4 → 0.4.5
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/dist/json-patch/pathProxy.d.ts +1 -1
- package/dist/types.d.ts +12 -1
- package/package.json +1 -1
|
@@ -18,5 +18,5 @@ import type { PathProxy } from '../types.js';
|
|
|
18
18
|
* @template T The type of the object to create paths for.
|
|
19
19
|
* @returns A path proxy object.
|
|
20
20
|
*/
|
|
21
|
-
export declare const createPathProxy: <T>() => PathProxy<T>;
|
|
21
|
+
export declare const createPathProxy: <T = any>() => PathProxy<T>;
|
|
22
22
|
export declare function pathProxy<T>(path?: string): PathProxy<T>;
|
package/dist/types.d.ts
CHANGED
|
@@ -125,12 +125,23 @@ export interface ListVersionsOptions {
|
|
|
125
125
|
/** Filter by the group ID (branch ID or offline batch ID). */
|
|
126
126
|
groupId?: string;
|
|
127
127
|
}
|
|
128
|
+
/** Detects if T is exactly `any` */
|
|
129
|
+
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
130
|
+
/** Untyped path proxy that allows arbitrary deep property access */
|
|
131
|
+
type DeepPathProxy = {
|
|
132
|
+
[key: string]: DeepPathProxy;
|
|
133
|
+
} & {
|
|
134
|
+
toString: () => string;
|
|
135
|
+
};
|
|
128
136
|
/**
|
|
129
137
|
* A proxy type for creating JSON Pointer paths in a type-safe way.
|
|
130
138
|
* This type makes all optional properties required to allow path navigation
|
|
131
139
|
* without null checks, but should only be used for path generation, not value access.
|
|
140
|
+
*
|
|
141
|
+
* Defaults to `any`, which returns a `DeepPathProxy` allowing arbitrary deep property access.
|
|
142
|
+
* When a specific type is provided, returns a strictly typed proxy.
|
|
132
143
|
*/
|
|
133
|
-
export type PathProxy<T> = {
|
|
144
|
+
export type PathProxy<T = any> = IsAny<T> extends true ? DeepPathProxy : {
|
|
134
145
|
[P in keyof T]-?: NonNullable<T[P]> extends object ? PathProxy<NonNullable<T[P]>> : {
|
|
135
146
|
toString: () => string;
|
|
136
147
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dabble/patches",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.5",
|
|
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": {
|