misc sdk changes (#2934)

* misc sdk changes

* delete the store ☠️

* port comments

* fix build

* fix removing

* fix tests

* beta.20

---------

Co-authored-by: Matt Hill <mattnine@protonmail.com>
This commit is contained in:
Aiden McClelland
2025-05-09 15:10:51 -06:00
committed by GitHub
parent d2c4741f0b
commit 7750e33f82
62 changed files with 1255 additions and 2130 deletions

View File

@@ -1,38 +0,0 @@
import { Affine } from "../util"
const pathValue = Symbol("pathValue")
export type PathValue = typeof pathValue
export type PathBuilderStored<AllStore, Store> = {
[K in PathValue]: [AllStore, Store]
}
export type PathBuilder<AllStore, Store = AllStore> = (Store extends Record<
string,
unknown
>
? {
[K in keyof Store]: PathBuilder<AllStore, Store[K]>
}
: {}) &
PathBuilderStored<AllStore, Store>
export type StorePath = string & Affine<"StorePath">
const privateSymbol = Symbol("jsonPath")
export const extractJsonPath = (builder: PathBuilder<unknown>) => {
return (builder as any)[privateSymbol] as StorePath
}
export const pathBuilder = <Store, StorePath = Store>(
paths: string[] = [],
): PathBuilder<Store, StorePath> => {
return new Proxy({} as PathBuilder<Store, StorePath>, {
get(target, prop) {
if (prop === privateSymbol) {
if (paths.length === 0) return ""
return `/${paths.join("/")}`
}
return pathBuilder<any>([...paths, prop as string])
},
}) as PathBuilder<Store, StorePath>
}

View File

@@ -17,6 +17,5 @@ export { nullIfEmpty } from "./nullIfEmpty"
export { deepMerge, partialDiff } from "./deepMerge"
export { deepEqual } from "./deepEqual"
export { hostnameInfoToAddress } from "./Hostname"
export { PathBuilder, extractJsonPath, StorePath } from "./PathBuilder"
export * as regexes from "./regexes"
export { stringFromStdErrOut } from "./stringFromStdErrOut"