@spooky-sync/client-solid 0.0.0-canary.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.
@@ -0,0 +1,84 @@
1
+ import type { Surreal } from 'surrealdb';
2
+ import type { SyncedDb } from '../index';
3
+ import { GenericSchema } from '../lib/models';
4
+ import type { SpookyConfig } from '@spooky-sync/core';
5
+ import type { SchemaStructure, TableNames, GetTable, TableModel } from '@spooky-sync/query-builder';
6
+
7
+ /**
8
+ * Options for database provisioning
9
+ */
10
+ export interface ProvisionOptions {
11
+ /** Force re-provision even if schema already exists */
12
+ force?: boolean;
13
+ }
14
+
15
+ declare global {
16
+ interface Window {
17
+ db?: SyncedDb<any>;
18
+ }
19
+ }
20
+
21
+ export type CacheStrategy = 'memory' | 'indexeddb';
22
+
23
+ /**
24
+ * Infer Schema type (Record<TableName, Model>) from schema const
25
+ */
26
+ export type InferSchemaFromConst<S extends SchemaStructure> = {
27
+ [K in TableNames<S>]: TableModel<GetTable<S, K>>;
28
+ };
29
+
30
+ /**
31
+ * Infer Relationships type from schema const's relationships array
32
+ * Converts from array format to nested object format
33
+ */
34
+ export type InferRelationshipsFromConst<S extends SchemaStructure, Schema extends GenericSchema> = {
35
+ [TableName in TableNames<S>]: {
36
+ [Rel in Extract<S['relationships'][number], { from: TableName }> as Rel['field']]: {
37
+ model: Rel['to'] extends keyof Schema ? Schema[Rel['to']] : any;
38
+ table: Rel['to'];
39
+ cardinality: Rel['cardinality'];
40
+ };
41
+ };
42
+ };
43
+
44
+ // Prettify helper expands types for better intellisense
45
+ type Prettify<T> = { [K in keyof T]: T[K] } & {};
46
+
47
+ export type SyncedDbConfig<S extends SchemaStructure> = Prettify<SpookyConfig<S>>;
48
+
49
+ // export interface LocalDbConfig {
50
+ // name: string;
51
+ // storageStrategy: CacheStrategy;
52
+ // namespace?: string;
53
+ // database?: string;
54
+ // }
55
+
56
+ // export interface RemoteDbConfig {
57
+ // url: string;
58
+ // token?: string;
59
+ // namespace?: string;
60
+ // database?: string;
61
+ // }
62
+
63
+ // export interface DbConnection {
64
+ // internal: Surreal;
65
+ // local: Surreal;
66
+ // remote?: Surreal;
67
+ // }
68
+
69
+ // export interface SyncStatus {
70
+ // isConnected: boolean;
71
+ // lastSync?: Date;
72
+ // pendingChanges: number;
73
+ // localRecords: number;
74
+ // remoteRecords?: number;
75
+ // }
76
+
77
+ // export interface SyncOptions {
78
+ // /** Force full sync regardless of last sync time */
79
+ // force?: boolean;
80
+ // /** Sync only specific tables */
81
+ // tables?: string[];
82
+ // /** Batch size for sync operations */
83
+ // batchSize?: number;
84
+ // }
package/tsconfig.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
5
+ "module": "ESNext",
6
+ "skipLibCheck": true,
7
+ "esModuleInterop": true,
8
+ "allowSyntheticDefaultImports": true,
9
+ "strict": true,
10
+ "forceConsistentCasingInFileNames": true,
11
+ "moduleResolution": "bundler",
12
+ "allowImportingTsExtensions": true,
13
+ "resolveJsonModule": true,
14
+ "isolatedModules": true,
15
+ "noEmit": true,
16
+ "declaration": true,
17
+ "declarationMap": true,
18
+ "emitDeclarationOnly": false,
19
+ "outDir": "./dist",
20
+ "paths": {
21
+ "@spooky-sync/query-builder": ["../query-builder/src/index.ts"],
22
+ "@spooky-sync/core": ["../core/src/index.ts"]
23
+ }
24
+ },
25
+ "include": ["src/**/*"],
26
+ "exclude": ["node_modules", "dist"]
27
+ }
@@ -0,0 +1,19 @@
1
+ import { defineConfig } from 'tsdown';
2
+
3
+ export default defineConfig({
4
+ entry: ['src/index.ts'],
5
+ format: ['esm', 'cjs'],
6
+ dts: true,
7
+ external: [
8
+ 'surrealdb',
9
+ '@surrealdb/wasm',
10
+ 'solid-js',
11
+ '@spooky-sync/core',
12
+ '@spooky-sync/query-builder',
13
+ 'valtio',
14
+ ],
15
+ clean: true,
16
+ hash: false,
17
+ sourcemap: true,
18
+ target: 'es2020',
19
+ });
package/tsup.config.ts ADDED
@@ -0,0 +1,29 @@
1
+ import { defineConfig } from 'vite';
2
+
3
+ export default defineConfig({
4
+ build: {
5
+ lib: {
6
+ entry: 'src/index.ts',
7
+ name: 'DbSolid',
8
+ fileName: (format) => `index.${format === 'es' ? 'mjs' : 'js'}`,
9
+ formats: ['es', 'cjs'],
10
+ },
11
+ rollupOptions: {
12
+ external: ['solid-js'],
13
+ output: {
14
+ preserveModules: false,
15
+ },
16
+ },
17
+ outDir: 'dist',
18
+ emptyOutDir: true,
19
+ sourcemap: true,
20
+ minify: false,
21
+ target: 'es2020',
22
+ },
23
+ esbuild: {
24
+ loader: 'ts',
25
+ },
26
+ resolve: {
27
+ extensions: ['.ts', '.js'],
28
+ },
29
+ });