@korajs/store 0.3.2 → 0.5.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.
Files changed (73) hide show
  1. package/dist/adapters/better-sqlite3.cjs +1 -1
  2. package/dist/adapters/better-sqlite3.cjs.map +1 -1
  3. package/dist/adapters/better-sqlite3.d.cts +1 -1
  4. package/dist/adapters/better-sqlite3.d.ts +1 -1
  5. package/dist/adapters/better-sqlite3.js +1 -1
  6. package/dist/adapters/better-sqlite3.js.map +1 -1
  7. package/dist/adapters/indexeddb.cjs +413 -18
  8. package/dist/adapters/indexeddb.cjs.map +1 -1
  9. package/dist/adapters/indexeddb.d.cts +23 -5
  10. package/dist/adapters/indexeddb.d.ts +23 -5
  11. package/dist/adapters/indexeddb.js +166 -19
  12. package/dist/adapters/indexeddb.js.map +1 -1
  13. package/dist/adapters/sqlite-wasm-shared-host.cjs +68 -0
  14. package/dist/adapters/sqlite-wasm-shared-host.cjs.map +1 -0
  15. package/dist/adapters/sqlite-wasm-shared-host.d.cts +2 -0
  16. package/dist/adapters/sqlite-wasm-shared-host.d.ts +2 -0
  17. package/dist/adapters/sqlite-wasm-shared-host.js +66 -0
  18. package/dist/adapters/sqlite-wasm-shared-host.js.map +1 -0
  19. package/dist/adapters/sqlite-wasm-worker.cjs +34 -5
  20. package/dist/adapters/sqlite-wasm-worker.cjs.map +1 -1
  21. package/dist/adapters/sqlite-wasm-worker.js +34 -5
  22. package/dist/adapters/sqlite-wasm-worker.js.map +1 -1
  23. package/dist/adapters/sqlite-wasm.cjs +249 -2
  24. package/dist/adapters/sqlite-wasm.cjs.map +1 -1
  25. package/dist/adapters/sqlite-wasm.d.cts +15 -3
  26. package/dist/adapters/sqlite-wasm.d.ts +15 -3
  27. package/dist/adapters/sqlite-wasm.js +2 -2
  28. package/dist/audit-trace-store-AM4EWQNZ.js +15 -0
  29. package/dist/backup-JN3LB4YT.js +14 -0
  30. package/dist/backup-JN3LB4YT.js.map +1 -0
  31. package/dist/chunk-56LL4XP6.js +205 -0
  32. package/dist/chunk-56LL4XP6.js.map +1 -0
  33. package/dist/chunk-6AHYGQQT.js +425 -0
  34. package/dist/chunk-6AHYGQQT.js.map +1 -0
  35. package/dist/chunk-7BPETY5Y.js +570 -0
  36. package/dist/chunk-7BPETY5Y.js.map +1 -0
  37. package/dist/chunk-AGN3CIPB.js +188 -0
  38. package/dist/chunk-AGN3CIPB.js.map +1 -0
  39. package/dist/chunk-EZSTD2XC.js +380 -0
  40. package/dist/chunk-EZSTD2XC.js.map +1 -0
  41. package/dist/chunk-MYSJN3DF.js +117 -0
  42. package/dist/chunk-MYSJN3DF.js.map +1 -0
  43. package/dist/{chunk-DXKLAQ6P.js → chunk-XO4LMPAH.js} +1 -1
  44. package/dist/chunk-XO4LMPAH.js.map +1 -0
  45. package/dist/export-audit-5GV6VRDZ.js +15 -0
  46. package/dist/export-audit-5GV6VRDZ.js.map +1 -0
  47. package/dist/index.cjs +3351 -510
  48. package/dist/index.cjs.map +1 -1
  49. package/dist/index.d.cts +822 -50
  50. package/dist/index.d.ts +822 -50
  51. package/dist/index.js +1976 -558
  52. package/dist/index.js.map +1 -1
  53. package/dist/internal.cjs +789 -0
  54. package/dist/internal.cjs.map +1 -0
  55. package/dist/internal.d.cts +154 -0
  56. package/dist/internal.d.ts +154 -0
  57. package/dist/internal.js +48 -0
  58. package/dist/internal.js.map +1 -0
  59. package/dist/{sqlite-wasm-channel-46AOWNPM.js → sqlite-wasm-channel-HDDW6UBH.js} +2 -2
  60. package/dist/sqlite-wasm-channel-HDDW6UBH.js.map +1 -0
  61. package/dist/{sqlite-wasm-channel-Lakjuk2E.d.cts → sqlite-wasm-channel-I9y_jObg.d.cts} +1 -0
  62. package/dist/{sqlite-wasm-channel-Lakjuk2E.d.ts → sqlite-wasm-channel-I9y_jObg.d.ts} +1 -0
  63. package/dist/types-BMyHmwvn.d.ts +163 -0
  64. package/dist/types-CTr00g_d.d.cts +163 -0
  65. package/dist/types-DepnRDk_.d.cts +212 -0
  66. package/dist/types-DepnRDk_.d.ts +212 -0
  67. package/package.json +23 -2
  68. package/dist/chunk-DXKLAQ6P.js.map +0 -1
  69. package/dist/chunk-ZP5AXQ3Z.js +0 -179
  70. package/dist/chunk-ZP5AXQ3Z.js.map +0 -1
  71. package/dist/types-DF-KDSK1.d.cts +0 -106
  72. package/dist/types-DF-KDSK1.d.ts +0 -106
  73. /package/dist/{sqlite-wasm-channel-46AOWNPM.js.map → audit-trace-store-AM4EWQNZ.js.map} +0 -0
@@ -1,106 +0,0 @@
1
- import { SchemaDefinition, KoraEventEmitter } from '@korajs/core';
2
-
3
- /**
4
- * Transaction interface for executing multiple operations atomically.
5
- */
6
- interface Transaction {
7
- execute(sql: string, params?: unknown[]): Promise<void>;
8
- query<T>(sql: string, params?: unknown[]): Promise<T[]>;
9
- }
10
- /**
11
- * Migration plan containing SQL statements and optional data transforms.
12
- */
13
- interface MigrationPlan {
14
- statements: string[];
15
- transforms?: Array<(row: Record<string, unknown>) => Record<string, unknown>>;
16
- }
17
- /**
18
- * Storage adapter interface. All storage backends must implement this.
19
- * Operations are async to support both sync (better-sqlite3) and async (IndexedDB, WASM) backends.
20
- */
21
- interface StorageAdapter {
22
- /** Open or create the database */
23
- open(schema: SchemaDefinition): Promise<void>;
24
- /** Close the database and release resources */
25
- close(): Promise<void>;
26
- /** Execute a write query (INSERT, UPDATE, DELETE) within a transaction */
27
- execute(sql: string, params?: unknown[]): Promise<void>;
28
- /** Execute a read query (SELECT) */
29
- query<T>(sql: string, params?: unknown[]): Promise<T[]>;
30
- /** Execute multiple operations atomically */
31
- transaction(fn: (tx: Transaction) => Promise<void>): Promise<void>;
32
- /** Apply a schema migration */
33
- migrate(from: number, to: number, migration: MigrationPlan): Promise<void>;
34
- }
35
- /**
36
- * Configuration for creating a Store instance.
37
- */
38
- interface StoreConfig {
39
- schema: SchemaDefinition;
40
- adapter: StorageAdapter;
41
- /** Optional node ID. If omitted, one is generated or loaded from the database. */
42
- nodeId?: string;
43
- /** Optional event emitter. When provided, local mutations emit 'operation:created' events. */
44
- emitter?: KoraEventEmitter;
45
- }
46
- /**
47
- * Operators for where clause conditions.
48
- */
49
- interface WhereOperators {
50
- $eq?: unknown;
51
- $ne?: unknown;
52
- $gt?: number | string;
53
- $gte?: number | string;
54
- $lt?: number | string;
55
- $lte?: number | string;
56
- $in?: unknown[];
57
- }
58
- /**
59
- * Where clause: field name to value (shorthand for $eq) or WhereOperators.
60
- */
61
- type WhereClause = Record<string, unknown | WhereOperators>;
62
- /**
63
- * Order direction for sorting query results.
64
- */
65
- type OrderByDirection = 'asc' | 'desc';
66
- /**
67
- * Order-by clause: field name and optional direction.
68
- */
69
- interface OrderByClause {
70
- field: string;
71
- direction: OrderByDirection;
72
- }
73
- /**
74
- * Internal representation of a query to be compiled to SQL.
75
- */
76
- interface QueryDescriptor {
77
- collection: string;
78
- where: WhereClause;
79
- orderBy: OrderByClause[];
80
- limit?: number;
81
- offset?: number;
82
- /** Relation names to include in results (for relational queries). */
83
- include?: string[];
84
- /** Resolved collection names for included relations (for subscription tracking). */
85
- includeCollections?: string[];
86
- }
87
- /**
88
- * Callback for reactive subscriptions. Receives the current result set.
89
- */
90
- type SubscriptionCallback<T> = (results: T[]) => void;
91
- /**
92
- * Record type returned from collection queries.
93
- * Includes the id and mapped metadata fields.
94
- */
95
- interface CollectionRecord {
96
- id: string;
97
- createdAt: number;
98
- updatedAt: number;
99
- [key: string]: unknown;
100
- }
101
- /**
102
- * Result of a remote operation application.
103
- */
104
- type ApplyResult = 'applied' | 'duplicate' | 'skipped';
105
-
106
- export type { ApplyResult as A, CollectionRecord as C, MigrationPlan as M, OrderByDirection as O, QueryDescriptor as Q, StorageAdapter as S, Transaction as T, WhereClause as W, SubscriptionCallback as a, StoreConfig as b, OrderByClause as c, WhereOperators as d };