@rolder/kit-surreal-db 0.1.0-alpha.0
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/deserialize.d.ts +17 -0
- package/dist/getAuthedDBSession.d.ts +5 -0
- package/dist/getDBInstance.d.ts +3 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/types.d.ts +10 -0
- package/package.json +24 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { RecordId } from 'surrealdb';
|
|
2
|
+
/**
|
|
3
|
+
* Type that converts specified string paths to RecordId, others stay as their original types
|
|
4
|
+
*/
|
|
5
|
+
type DeserializeResult<T, IdPaths extends string = never> = T extends string ? RecordId<string> : T extends (infer U)[] ? U extends object ? {
|
|
6
|
+
[K in keyof U]: K extends IdPaths ? RecordId<string> : U[K];
|
|
7
|
+
}[] : DeserializeResult<U, IdPaths>[] : T extends object ? T extends Date ? T : {
|
|
8
|
+
[K in keyof T]: K extends IdPaths ? RecordId<string> : T[K];
|
|
9
|
+
} : T;
|
|
10
|
+
/**
|
|
11
|
+
* Deserializes DTO back to SurrealDB Record recursively based on specified ID paths
|
|
12
|
+
*/
|
|
13
|
+
export declare function deserialize<T, K extends keyof T & string>(dto: T[], idPaths: K[]): DeserializeResult<T, K>[];
|
|
14
|
+
export declare function deserialize<T, K extends keyof T & string>(dto: T, idPaths: K[]): DeserializeResult<T, K>;
|
|
15
|
+
export declare function deserialize<T>(dto: T[]): DeserializeResult<T>[];
|
|
16
|
+
export declare function deserialize<T>(dto: T): DeserializeResult<T>;
|
|
17
|
+
export {};
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
package/dist/types.d.ts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rolder/kit-surreal-db",
|
|
3
|
+
"version": "0.1.0-alpha.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": {
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"import": "./dist/index.js"
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "rslib build",
|
|
17
|
+
"dev": "rslib build --watch",
|
|
18
|
+
"prepublishOnly": "bun run build",
|
|
19
|
+
"check": "biome check --write && tsc --noEmit"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"surrealdb": "^2.0.0-alpha.18"
|
|
23
|
+
}
|
|
24
|
+
}
|