@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.
@@ -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 {};
@@ -0,0 +1,5 @@
1
+ import type { SurrealSession } from 'surrealdb';
2
+ import type { SurrealDBProps } from './types';
3
+ export declare const getAuthedDBSession: (user: {
4
+ id: string;
5
+ }, token: string, surrealDBProps?: SurrealDBProps) => Promise<SurrealSession>;
@@ -0,0 +1,3 @@
1
+ import { Surreal } from 'surrealdb';
2
+ import type { SurrealDBProps } from './types';
3
+ export declare const getDBInstance: (params?: SurrealDBProps | undefined) => Promise<Surreal>;
@@ -0,0 +1,5 @@
1
+ export * from 'surrealdb';
2
+ export * from './deserialize';
3
+ export * from './getAuthedDBSession';
4
+ export * from './getDBInstance';
5
+ export * from './types';
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export * from "surrealdb";
2
+ export * from "./deserialize.js";
3
+ export * from "./getAuthedDBSession.js";
4
+ export * from "./getDBInstance.js";
5
+ export * from "./types.js";
@@ -0,0 +1,10 @@
1
+ import type { CodecOptions } from 'surrealdb';
2
+ export interface SurrealDBProps {
3
+ url?: string;
4
+ namespace?: string;
5
+ database?: string;
6
+ username?: string;
7
+ password?: string;
8
+ codecOptions?: CodecOptions;
9
+ debug?: boolean;
10
+ }
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
+ }