@framers/sql-storage-adapter 0.7.2 → 0.7.4

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 (194) hide show
  1. package/README.md +41 -0
  2. package/dist/adapters/electron/preload.cjs +289 -0
  3. package/dist/adapters/electron/renderer.d.ts +9 -0
  4. package/dist/adapters/electron/renderer.d.ts.map +1 -0
  5. package/dist/adapters/electron/renderer.js +8 -0
  6. package/dist/adapters/electron/renderer.js.map +1 -0
  7. package/dist/cjs/adapters/__tests__/indexedDbAdapter.spec.d.ts +2 -0
  8. package/dist/cjs/adapters/__tests__/indexedDbAdapter.spec.js +133 -0
  9. package/dist/cjs/adapters/baseStorageAdapter.d.ts +368 -0
  10. package/dist/cjs/adapters/baseStorageAdapter.js +744 -0
  11. package/dist/cjs/adapters/betterSqliteAdapter.d.ts +124 -0
  12. package/dist/cjs/adapters/betterSqliteAdapter.js +334 -0
  13. package/dist/cjs/adapters/capacitorSqliteAdapter.d.ts +83 -0
  14. package/dist/cjs/adapters/capacitorSqliteAdapter.js +250 -0
  15. package/dist/cjs/adapters/electron/electronMainAdapter.d.ts +251 -0
  16. package/dist/cjs/adapters/electron/electronMainAdapter.js +392 -0
  17. package/dist/cjs/adapters/electron/electronRendererAdapter.d.ts +177 -0
  18. package/dist/cjs/adapters/electron/electronRendererAdapter.js +283 -0
  19. package/dist/cjs/adapters/electron/index.d.ts +74 -0
  20. package/dist/cjs/adapters/electron/index.js +86 -0
  21. package/dist/cjs/adapters/electron/ipc/channels.d.ts +196 -0
  22. package/dist/cjs/adapters/electron/ipc/channels.js +127 -0
  23. package/dist/cjs/adapters/electron/ipc/index.d.ts +11 -0
  24. package/dist/cjs/adapters/electron/ipc/index.js +38 -0
  25. package/dist/cjs/adapters/electron/ipc/protocol.d.ts +78 -0
  26. package/dist/cjs/adapters/electron/ipc/protocol.js +341 -0
  27. package/dist/cjs/adapters/electron/ipc/types.d.ts +248 -0
  28. package/dist/cjs/adapters/electron/ipc/types.js +15 -0
  29. package/dist/cjs/adapters/electron/migration/autoMigrator.d.ts +184 -0
  30. package/dist/cjs/adapters/electron/migration/autoMigrator.js +441 -0
  31. package/dist/cjs/adapters/electron/migration/index.d.ts +9 -0
  32. package/dist/cjs/adapters/electron/migration/index.js +29 -0
  33. package/dist/cjs/adapters/electron/preload.d.ts +126 -0
  34. package/dist/cjs/adapters/electron/preload.js +233 -0
  35. package/dist/cjs/adapters/electron/recovery/corruptionDetector.d.ts +214 -0
  36. package/dist/cjs/adapters/electron/recovery/corruptionDetector.js +359 -0
  37. package/dist/cjs/adapters/electron/recovery/index.d.ts +11 -0
  38. package/dist/cjs/adapters/electron/recovery/index.js +34 -0
  39. package/dist/cjs/adapters/electron/recovery/walCheckpoint.d.ts +186 -0
  40. package/dist/cjs/adapters/electron/recovery/walCheckpoint.js +263 -0
  41. package/dist/cjs/adapters/electron/renderer.d.ts +9 -0
  42. package/dist/cjs/adapters/electron/renderer.js +33 -0
  43. package/dist/cjs/adapters/electron/window/index.d.ts +9 -0
  44. package/dist/cjs/adapters/electron/window/index.js +29 -0
  45. package/dist/cjs/adapters/electron/window/windowManager.d.ts +190 -0
  46. package/dist/cjs/adapters/electron/window/windowManager.js +321 -0
  47. package/dist/cjs/adapters/indexedDbAdapter.d.ts +490 -0
  48. package/dist/cjs/adapters/indexedDbAdapter.js +993 -0
  49. package/dist/cjs/adapters/postgresAdapter.d.ts +424 -0
  50. package/dist/cjs/adapters/postgresAdapter.js +889 -0
  51. package/dist/cjs/adapters/sqlJsAdapter.d.ts +64 -0
  52. package/dist/cjs/adapters/sqlJsAdapter.js +268 -0
  53. package/dist/cjs/adapters/supabase.d.ts +58 -0
  54. package/dist/cjs/adapters/supabase.js +401 -0
  55. package/dist/cjs/codecs/BrowserBlobCodec.d.ts +14 -0
  56. package/dist/cjs/codecs/BrowserBlobCodec.js +57 -0
  57. package/dist/cjs/codecs/NodeBlobCodec.d.ts +14 -0
  58. package/dist/cjs/codecs/NodeBlobCodec.js +59 -0
  59. package/dist/cjs/core/contracts/blobCodec.d.ts +15 -0
  60. package/dist/cjs/core/contracts/blobCodec.js +15 -0
  61. package/dist/cjs/core/contracts/context.d.ts +221 -0
  62. package/dist/cjs/core/contracts/context.js +15 -0
  63. package/dist/cjs/core/contracts/dialect.d.ts +154 -0
  64. package/dist/cjs/core/contracts/dialect.js +15 -0
  65. package/dist/cjs/core/contracts/events.d.ts +225 -0
  66. package/dist/cjs/core/contracts/events.js +15 -0
  67. package/dist/cjs/core/contracts/exporter.d.ts +13 -0
  68. package/dist/cjs/core/contracts/exporter.js +15 -0
  69. package/dist/cjs/core/contracts/extensions.d.ts +73 -0
  70. package/dist/cjs/core/contracts/extensions.js +15 -0
  71. package/dist/cjs/core/contracts/features.d.ts +25 -0
  72. package/dist/cjs/core/contracts/features.js +61 -0
  73. package/dist/cjs/core/contracts/fts.d.ts +66 -0
  74. package/dist/cjs/core/contracts/fts.js +15 -0
  75. package/dist/cjs/core/contracts/hooks.d.ts +481 -0
  76. package/dist/cjs/core/contracts/hooks.js +140 -0
  77. package/dist/cjs/core/contracts/index.d.ts +260 -0
  78. package/dist/cjs/core/contracts/index.js +41 -0
  79. package/dist/cjs/core/contracts/limitations.d.ts +46 -0
  80. package/dist/cjs/core/contracts/limitations.js +218 -0
  81. package/dist/cjs/core/contracts/performance.d.ts +308 -0
  82. package/dist/cjs/core/contracts/performance.js +144 -0
  83. package/dist/cjs/core/database.d.ts +220 -0
  84. package/dist/cjs/core/database.js +136 -0
  85. package/dist/cjs/core/portable.d.ts +24 -0
  86. package/dist/cjs/core/portable.js +68 -0
  87. package/dist/cjs/core/resolver.d.ts +77 -0
  88. package/dist/cjs/core/resolver.js +235 -0
  89. package/dist/cjs/dialects/PostgresDialect.d.ts +35 -0
  90. package/dist/cjs/dialects/PostgresDialect.js +143 -0
  91. package/dist/cjs/dialects/SqliteDialect.d.ts +35 -0
  92. package/dist/cjs/dialects/SqliteDialect.js +142 -0
  93. package/dist/cjs/dialects/shared.d.ts +17 -0
  94. package/dist/cjs/dialects/shared.js +90 -0
  95. package/dist/cjs/exporters/PostgresExporter.d.ts +14 -0
  96. package/dist/cjs/exporters/PostgresExporter.js +61 -0
  97. package/dist/cjs/exporters/SqliteFileExporter.d.ts +16 -0
  98. package/dist/cjs/exporters/SqliteFileExporter.js +43 -0
  99. package/dist/cjs/features/auth/authJsAdapter.d.ts +110 -0
  100. package/dist/cjs/features/auth/authJsAdapter.js +251 -0
  101. package/dist/cjs/features/backup/cloudBackup.d.ts +219 -0
  102. package/dist/cjs/features/backup/cloudBackup.js +209 -0
  103. package/dist/cjs/features/kv/idb.d.ts +79 -0
  104. package/dist/cjs/features/kv/idb.js +32 -0
  105. package/dist/cjs/features/kv/index.d.ts +14 -0
  106. package/dist/cjs/features/kv/index.js +40 -0
  107. package/dist/cjs/features/kv/indexedDbKeyValueStore.d.ts +77 -0
  108. package/dist/cjs/features/kv/indexedDbKeyValueStore.js +116 -0
  109. package/dist/cjs/features/kv/keyValueStore.d.ts +48 -0
  110. package/dist/cjs/features/kv/keyValueStore.js +67 -0
  111. package/dist/cjs/features/kv/sqlKeyValueStore.d.ts +34 -0
  112. package/dist/cjs/features/kv/sqlKeyValueStore.js +81 -0
  113. package/dist/cjs/features/kv/valueCodec.d.ts +35 -0
  114. package/dist/cjs/features/kv/valueCodec.js +426 -0
  115. package/dist/cjs/features/migrations/dataExport.d.ts +77 -0
  116. package/dist/cjs/features/migrations/dataExport.js +194 -0
  117. package/dist/cjs/features/migrations/dataImport.d.ts +54 -0
  118. package/dist/cjs/features/migrations/dataImport.js +300 -0
  119. package/dist/cjs/features/migrations/migration.d.ts +89 -0
  120. package/dist/cjs/features/migrations/migration.js +187 -0
  121. package/dist/cjs/features/migrations/schemaMigrations.d.ts +93 -0
  122. package/dist/cjs/features/migrations/schemaMigrations.js +220 -0
  123. package/dist/cjs/features/sync/conflicts/conflictResolver.d.ts +222 -0
  124. package/dist/cjs/features/sync/conflicts/conflictResolver.js +366 -0
  125. package/dist/cjs/features/sync/conflicts/index.d.ts +9 -0
  126. package/dist/cjs/features/sync/conflicts/index.js +21 -0
  127. package/dist/cjs/features/sync/crossPlatformSync.d.ts +281 -0
  128. package/dist/cjs/features/sync/crossPlatformSync.js +551 -0
  129. package/dist/cjs/features/sync/devices/deviceManager.d.ts +243 -0
  130. package/dist/cjs/features/sync/devices/deviceManager.js +450 -0
  131. package/dist/cjs/features/sync/devices/index.d.ts +10 -0
  132. package/dist/cjs/features/sync/devices/index.js +21 -0
  133. package/dist/cjs/features/sync/index.d.ts +37 -0
  134. package/dist/cjs/features/sync/index.js +111 -0
  135. package/dist/cjs/features/sync/protocol/index.d.ts +11 -0
  136. package/dist/cjs/features/sync/protocol/index.js +23 -0
  137. package/dist/cjs/features/sync/protocol/messages.d.ts +348 -0
  138. package/dist/cjs/features/sync/protocol/messages.js +215 -0
  139. package/dist/cjs/features/sync/protocol/vectorClock.d.ts +164 -0
  140. package/dist/cjs/features/sync/protocol/vectorClock.js +256 -0
  141. package/dist/cjs/features/sync/syncManager.d.ts +348 -0
  142. package/dist/cjs/features/sync/syncManager.js +455 -0
  143. package/dist/cjs/features/sync/tables/index.d.ts +10 -0
  144. package/dist/cjs/features/sync/tables/index.js +21 -0
  145. package/dist/cjs/features/sync/tables/syncLogManager.d.ts +216 -0
  146. package/dist/cjs/features/sync/tables/syncLogManager.js +423 -0
  147. package/dist/cjs/features/sync/transport/httpTransport.d.ts +123 -0
  148. package/dist/cjs/features/sync/transport/httpTransport.js +346 -0
  149. package/dist/cjs/features/sync/transport/index.d.ts +12 -0
  150. package/dist/cjs/features/sync/transport/index.js +25 -0
  151. package/dist/cjs/features/sync/transport/transport.d.ts +259 -0
  152. package/dist/cjs/features/sync/transport/transport.js +163 -0
  153. package/dist/cjs/features/sync/transport/websocketTransport.d.ts +126 -0
  154. package/dist/cjs/features/sync/transport/websocketTransport.js +342 -0
  155. package/dist/cjs/fts/PostgresFts.d.ts +29 -0
  156. package/dist/cjs/fts/PostgresFts.js +77 -0
  157. package/dist/cjs/fts/SqliteFts5.d.ts +22 -0
  158. package/dist/cjs/fts/SqliteFts5.js +58 -0
  159. package/dist/cjs/index.d.ts +31 -0
  160. package/dist/cjs/index.js +103 -0
  161. package/dist/cjs/package.json +3 -0
  162. package/dist/cjs/shared/connectionGate.d.ts +94 -0
  163. package/dist/cjs/shared/connectionGate.js +77 -0
  164. package/dist/cjs/shared/errors.d.ts +23 -0
  165. package/dist/cjs/shared/errors.js +45 -0
  166. package/dist/cjs/shared/logger.d.ts +26 -0
  167. package/dist/cjs/shared/logger.js +40 -0
  168. package/dist/cjs/shared/parameterUtils.d.ts +16 -0
  169. package/dist/cjs/shared/parameterUtils.js +59 -0
  170. package/dist/cjs/shared/postgresTarget.d.ts +11 -0
  171. package/dist/cjs/shared/postgresTarget.js +30 -0
  172. package/dist/cjs/shared/segment.d.ts +43 -0
  173. package/dist/cjs/shared/segment.js +63 -0
  174. package/dist/cjs/shared/serializedTransaction.d.ts +14 -0
  175. package/dist/cjs/shared/serializedTransaction.js +74 -0
  176. package/dist/cjs/shared/splitSqlStatements.d.ts +27 -0
  177. package/dist/cjs/shared/splitSqlStatements.js +163 -0
  178. package/dist/cjs/shared/sqlPlaceholders.d.ts +48 -0
  179. package/dist/cjs/shared/sqlPlaceholders.js +263 -0
  180. package/dist/cjs/types/index.d.ts +29 -0
  181. package/dist/cjs/types/index.js +33 -0
  182. package/dist/core/portable.d.ts +24 -0
  183. package/dist/core/portable.d.ts.map +1 -0
  184. package/dist/core/portable.js +24 -0
  185. package/dist/core/portable.js.map +1 -0
  186. package/dist/features/auth/authJsAdapter.d.ts +110 -0
  187. package/dist/features/auth/authJsAdapter.d.ts.map +1 -0
  188. package/dist/features/auth/authJsAdapter.js +248 -0
  189. package/dist/features/auth/authJsAdapter.js.map +1 -0
  190. package/dist/index.d.ts +1 -0
  191. package/dist/index.d.ts.map +1 -1
  192. package/dist/index.js +1 -0
  193. package/dist/index.js.map +1 -1
  194. package/package.json +149 -24
@@ -0,0 +1,143 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var PostgresDialect_exports = {};
19
+ __export(PostgresDialect_exports, {
20
+ PostgresDialect: () => PostgresDialect
21
+ });
22
+ module.exports = __toCommonJS(PostgresDialect_exports);
23
+ var import_shared = require("./shared.js");
24
+ const COLUMN_TYPES = {
25
+ text: "TEXT",
26
+ integer: "INTEGER",
27
+ bigint: "BIGINT",
28
+ real: "DOUBLE PRECISION",
29
+ boolean: "BOOLEAN",
30
+ timestamp: "TIMESTAMPTZ",
31
+ json: "JSONB",
32
+ uuid: "UUID",
33
+ blob: "BYTEA"
34
+ };
35
+ const CAST_TYPES = {
36
+ text: "text",
37
+ integer: "integer",
38
+ real: "double precision",
39
+ timestamp: "timestamptz"
40
+ };
41
+ const ISO_TEXT = `'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"'`;
42
+ class PostgresDialect {
43
+ constructor() {
44
+ this.name = "postgres";
45
+ }
46
+ insertOrIgnore(table, columns, placeholders) {
47
+ return `INSERT INTO ${table} (${columns.join(", ")}) VALUES (${placeholders.join(", ")}) ON CONFLICT DO NOTHING`;
48
+ }
49
+ insertOrReplace(table, columns, placeholders, primaryKey) {
50
+ return this.upsert(table, columns, placeholders, [primaryKey ?? columns[0]]);
51
+ }
52
+ upsert(table, columns, placeholders, conflictColumns, updateColumns) {
53
+ const updates = (0, import_shared.upsertUpdateColumns)(columns, conflictColumns, updateColumns);
54
+ const action = updates.length ? `DO UPDATE SET ${updates.map((column) => `${column} = EXCLUDED.${column}`).join(", ")}` : "DO NOTHING";
55
+ return `INSERT INTO ${table} (${columns.join(", ")}) VALUES (${placeholders.join(", ")}) ON CONFLICT (${conflictColumns.join(", ")}) ${action}`;
56
+ }
57
+ jsonExtract(column, jsonPath) {
58
+ const path = jsonPath.replace(/^\$\./, "");
59
+ const parts = path.split(".");
60
+ if (parts.length === 1) {
61
+ return `(${column}::jsonb)->>'${parts[0]}'`;
62
+ }
63
+ const args = parts.map((p) => `'${p}'`).join(", ");
64
+ return `jsonb_extract_path_text(${column}::jsonb, ${args})`;
65
+ }
66
+ jsonExtractAs(column, jsonPath, type) {
67
+ (0, import_shared.checkChoice)("jsonExtractAs type", type, ["text", "integer", "real", "json"]);
68
+ const path = `'{${(0, import_shared.parseJsonPath)(jsonPath).join(",")}}'`;
69
+ if (type === "json")
70
+ return `((${column})::jsonb #> ${path})`;
71
+ const text = `((${column})::jsonb #>> ${path})`;
72
+ if (type === "text")
73
+ return text;
74
+ return `(${text})::${type === "integer" ? "integer" : "double precision"}`;
75
+ }
76
+ jsonArrayContains(jsonArray, valueExpr) {
77
+ return `EXISTS (SELECT 1 FROM jsonb_array_elements_text((${jsonArray})::jsonb) AS element(value) WHERE element.value = CAST(${valueExpr} AS text))`;
78
+ }
79
+ ifnull(expr, fallback) {
80
+ return `COALESCE(${expr}, ${fallback})`;
81
+ }
82
+ autoIncrementPrimaryKey() {
83
+ return "INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY";
84
+ }
85
+ columnType(kind) {
86
+ (0, import_shared.checkChoice)("columnType kind", kind, Object.keys(COLUMN_TYPES));
87
+ return COLUMN_TYPES[kind];
88
+ }
89
+ pragma(_key, _value) {
90
+ return null;
91
+ }
92
+ placeholder(index) {
93
+ return `$${index + 1}`;
94
+ }
95
+ now() {
96
+ return "now()";
97
+ }
98
+ cast(expr, type) {
99
+ (0, import_shared.checkChoice)("cast type", type, ["text", "integer", "real", "timestamp"]);
100
+ return `CAST(${expr} AS ${CAST_TYPES[type]})`;
101
+ }
102
+ addInterval(expr, amount, unit) {
103
+ return `((${expr})::timestamptz + interval '${(0, import_shared.intervalSeconds)(amount, unit)} seconds')`;
104
+ }
105
+ dateBucket(unit, expr) {
106
+ return `to_char(date_trunc('${(0, import_shared.checkDateBucketUnit)(unit)}', (${expr})::timestamptz AT TIME ZONE 'UTC'), ${ISO_TEXT})`;
107
+ }
108
+ ilike(expr, pattern) {
109
+ return `${expr} ILIKE ${pattern}`;
110
+ }
111
+ inList(expr, items) {
112
+ return items.length ? `${expr} IN (${items.join(", ")})` : "(1 = 0)";
113
+ }
114
+ inArray(expr, arrayParam) {
115
+ return `${expr} = ANY(${arrayParam})`;
116
+ }
117
+ rowLock(mode, wait = "wait") {
118
+ (0, import_shared.checkChoice)("rowLock mode", mode, ["update", "share"]);
119
+ (0, import_shared.checkChoice)("rowLock wait", wait, ["wait", "skipLocked", "noWait"]);
120
+ const lock = mode === "update" ? " FOR UPDATE" : " FOR SHARE";
121
+ return wait === "skipLocked" ? `${lock} SKIP LOCKED` : wait === "noWait" ? `${lock} NOWAIT` : lock;
122
+ }
123
+ advisoryTransactionLock(keyExpr) {
124
+ return `SELECT pg_advisory_xact_lock(${keyExpr})`;
125
+ }
126
+ greatest(...exprs) {
127
+ if (exprs.length === 0)
128
+ throw new Error("greatest needs at least one expression.");
129
+ return `GREATEST(${exprs.join(", ")})`;
130
+ }
131
+ least(...exprs) {
132
+ if (exprs.length === 0)
133
+ throw new Error("least needs at least one expression.");
134
+ return `LEAST(${exprs.join(", ")})`;
135
+ }
136
+ uuid() {
137
+ return "gen_random_uuid()";
138
+ }
139
+ }
140
+ // Annotate the CommonJS export names for ESM import in node:
141
+ 0 && (module.exports = {
142
+ PostgresDialect
143
+ });
@@ -0,0 +1,35 @@
1
+ import type { CastType, ColumnKind, DateBucketUnit, IntervalUnit, JsonValueType, SqlDialect } from '../core/contracts/dialect.js';
2
+ /**
3
+ * SQLite dialect implementation.
4
+ *
5
+ * Generates SQLite SQL: `INSERT OR IGNORE`, `ON CONFLICT ... DO UPDATE`
6
+ * upserts, `json_extract()`, `ifnull()`, `strftime()` times in ISO 8601 UTC
7
+ * text, `PRAGMA`, and positional `?` placeholders.
8
+ */
9
+ export declare class SqliteDialect implements SqlDialect {
10
+ readonly name: "sqlite";
11
+ insertOrIgnore(table: string, columns: string[], placeholders: string[]): string;
12
+ insertOrReplace(table: string, columns: string[], placeholders: string[], primaryKey?: string): string;
13
+ upsert(table: string, columns: string[], placeholders: string[], conflictColumns: string[], updateColumns?: string[]): string;
14
+ jsonExtract(column: string, jsonPath: string): string;
15
+ jsonExtractAs(column: string, jsonPath: string, type: JsonValueType): string;
16
+ jsonArrayContains(jsonArray: string, valueExpr: string): string;
17
+ ifnull(expr: string, fallback: string): string;
18
+ autoIncrementPrimaryKey(): string;
19
+ columnType(kind: ColumnKind): string;
20
+ pragma(key: string, value: string): string | null;
21
+ placeholder(_index: number): string;
22
+ now(): string;
23
+ cast(expr: string, type: CastType): string;
24
+ addInterval(expr: string, amount: number, unit: IntervalUnit): string;
25
+ dateBucket(unit: DateBucketUnit, expr: string): string;
26
+ ilike(expr: string, pattern: string): string;
27
+ inList(expr: string, items: string[]): string;
28
+ inArray(expr: string, arrayParam: string): string;
29
+ rowLock(mode: 'update' | 'share', wait?: 'wait' | 'skipLocked' | 'noWait'): string;
30
+ advisoryTransactionLock(_keyExpr: string): string | null;
31
+ greatest(...exprs: string[]): string;
32
+ least(...exprs: string[]): string;
33
+ uuid(): string;
34
+ }
35
+ //# sourceMappingURL=SqliteDialect.d.ts.map
@@ -0,0 +1,142 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var SqliteDialect_exports = {};
19
+ __export(SqliteDialect_exports, {
20
+ SqliteDialect: () => SqliteDialect
21
+ });
22
+ module.exports = __toCommonJS(SqliteDialect_exports);
23
+ var import_shared = require("./shared.js");
24
+ const ISO_FORMAT = "%Y-%m-%dT%H:%M:%fZ";
25
+ const BUCKET_FORMATS = {
26
+ minute: "%Y-%m-%dT%H:%M:00.000Z",
27
+ hour: "%Y-%m-%dT%H:00:00.000Z",
28
+ day: "%Y-%m-%dT00:00:00.000Z",
29
+ month: "%Y-%m-01T00:00:00.000Z",
30
+ year: "%Y-01-01T00:00:00.000Z"
31
+ };
32
+ const COLUMN_TYPES = {
33
+ text: "TEXT",
34
+ integer: "INTEGER",
35
+ bigint: "INTEGER",
36
+ real: "REAL",
37
+ boolean: "INTEGER",
38
+ timestamp: "TEXT",
39
+ json: "TEXT",
40
+ uuid: "TEXT",
41
+ blob: "BLOB"
42
+ };
43
+ class SqliteDialect {
44
+ constructor() {
45
+ this.name = "sqlite";
46
+ }
47
+ insertOrIgnore(table, columns, placeholders) {
48
+ return `INSERT OR IGNORE INTO ${table} (${columns.join(", ")}) VALUES (${placeholders.join(", ")})`;
49
+ }
50
+ insertOrReplace(table, columns, placeholders, primaryKey) {
51
+ return this.upsert(table, columns, placeholders, [primaryKey ?? columns[0]]);
52
+ }
53
+ upsert(table, columns, placeholders, conflictColumns, updateColumns) {
54
+ const updates = (0, import_shared.upsertUpdateColumns)(columns, conflictColumns, updateColumns);
55
+ const action = updates.length ? `DO UPDATE SET ${updates.map((column) => `${column} = excluded.${column}`).join(", ")}` : "DO NOTHING";
56
+ return `INSERT INTO ${table} (${columns.join(", ")}) VALUES (${placeholders.join(", ")}) ON CONFLICT (${conflictColumns.join(", ")}) ${action}`;
57
+ }
58
+ jsonExtract(column, jsonPath) {
59
+ return `json_extract(${column}, '${jsonPath}')`;
60
+ }
61
+ jsonExtractAs(column, jsonPath, type) {
62
+ (0, import_shared.checkChoice)("jsonExtractAs type", type, ["text", "integer", "real", "json"]);
63
+ const path = `$${(0, import_shared.parseJsonPath)(jsonPath).map((step) => typeof step === "number" ? `[${step}]` : `.${step}`).join("")}`;
64
+ const value = `json_extract(${column}, '${path}')`;
65
+ if (type === "json")
66
+ return value;
67
+ return `CAST(${value} AS ${type === "text" ? "TEXT" : type === "integer" ? "INTEGER" : "REAL"})`;
68
+ }
69
+ jsonArrayContains(jsonArray, valueExpr) {
70
+ return `EXISTS (SELECT 1 FROM json_each(${jsonArray}) WHERE CAST(json_each.value AS TEXT) = CAST(${valueExpr} AS TEXT))`;
71
+ }
72
+ ifnull(expr, fallback) {
73
+ return `ifnull(${expr}, ${fallback})`;
74
+ }
75
+ autoIncrementPrimaryKey() {
76
+ return "INTEGER PRIMARY KEY AUTOINCREMENT";
77
+ }
78
+ columnType(kind) {
79
+ (0, import_shared.checkChoice)("columnType kind", kind, Object.keys(COLUMN_TYPES));
80
+ return COLUMN_TYPES[kind];
81
+ }
82
+ pragma(key, value) {
83
+ return `PRAGMA ${key} = ${value}`;
84
+ }
85
+ placeholder(_index) {
86
+ return "?";
87
+ }
88
+ now() {
89
+ return `strftime('${ISO_FORMAT}', 'now')`;
90
+ }
91
+ cast(expr, type) {
92
+ (0, import_shared.checkChoice)("cast type", type, ["text", "integer", "real", "timestamp"]);
93
+ if (type === "timestamp")
94
+ return `strftime('${ISO_FORMAT}', ${expr})`;
95
+ return `CAST(${expr} AS ${type === "text" ? "TEXT" : type === "integer" ? "INTEGER" : "REAL"})`;
96
+ }
97
+ addInterval(expr, amount, unit) {
98
+ const seconds = (0, import_shared.intervalSeconds)(amount, unit);
99
+ return `strftime('${ISO_FORMAT}', ${expr}, '${seconds >= 0 ? "+" : ""}${seconds} seconds')`;
100
+ }
101
+ dateBucket(unit, expr) {
102
+ return `strftime('${BUCKET_FORMATS[(0, import_shared.checkDateBucketUnit)(unit)]}', ${expr})`;
103
+ }
104
+ ilike(expr, pattern) {
105
+ return `${expr} LIKE ${pattern}`;
106
+ }
107
+ inList(expr, items) {
108
+ return items.length ? `${expr} IN (${items.join(", ")})` : "(1 = 0)";
109
+ }
110
+ inArray(expr, arrayParam) {
111
+ return `${expr} IN (SELECT value FROM json_each(${arrayParam}))`;
112
+ }
113
+ rowLock(mode, wait = "wait") {
114
+ (0, import_shared.checkChoice)("rowLock mode", mode, ["update", "share"]);
115
+ (0, import_shared.checkChoice)("rowLock wait", wait, ["wait", "skipLocked", "noWait"]);
116
+ return "";
117
+ }
118
+ advisoryTransactionLock(_keyExpr) {
119
+ return null;
120
+ }
121
+ greatest(...exprs) {
122
+ return nullSkippingExtreme("max", exprs);
123
+ }
124
+ least(...exprs) {
125
+ return nullSkippingExtreme("min", exprs);
126
+ }
127
+ uuid() {
128
+ return "lower(hex(randomblob(4)) || '-' || hex(randomblob(2)) || '-4' || substr(hex(randomblob(2)), 2) || '-' || substr('89ab', 1 + (random() & 3), 1) || substr(hex(randomblob(2)), 2) || '-' || hex(randomblob(6)))";
129
+ }
130
+ }
131
+ const nullSkippingExtreme = (fn, exprs) => {
132
+ if (exprs.length === 0)
133
+ throw new Error(`${fn === "max" ? "greatest" : "least"} needs at least one expression.`);
134
+ if (exprs.length === 1)
135
+ return `(${exprs[0]})`;
136
+ const coalesced = exprs.map((expr, index) => `coalesce(${[expr, ...exprs.filter((_, other) => other !== index)].join(", ")})`);
137
+ return `${fn}(${coalesced.join(", ")})`;
138
+ };
139
+ // Annotate the CommonJS export names for ESM import in node:
140
+ 0 && (module.exports = {
141
+ SqliteDialect
142
+ });
@@ -0,0 +1,17 @@
1
+ import type { DateBucketUnit, IntervalUnit } from '../core/contracts/dialect.js';
2
+ /** `amount` units as a number of seconds, after checking both. */
3
+ export declare const intervalSeconds: (amount: number, unit: IntervalUnit) => number;
4
+ /** Checks a dateBucket unit. */
5
+ export declare const checkDateBucketUnit: (unit: DateBucketUnit) => DateBucketUnit;
6
+ /** One step of a JSON path: an object key or an array index. */
7
+ export type JsonPathStep = string | number;
8
+ /**
9
+ * Splits a JSON path of the form `$.key`, `$.key.key` or `$.key[0]` into its
10
+ * steps. Anything else is refused, so a path never carries SQL.
11
+ */
12
+ export declare const parseJsonPath: (jsonPath: string) => JsonPathStep[];
13
+ /** Checks one of a fixed set of option values. */
14
+ export declare const checkChoice: <T extends string>(what: string, value: T, allowed: readonly T[]) => T;
15
+ /** The columns an upsert updates: those given, or every column outside the conflict target. */
16
+ export declare const upsertUpdateColumns: (columns: string[], conflictColumns: string[], updateColumns?: string[]) => string[];
17
+ //# sourceMappingURL=shared.d.ts.map
@@ -0,0 +1,90 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var shared_exports = {};
19
+ __export(shared_exports, {
20
+ checkChoice: () => checkChoice,
21
+ checkDateBucketUnit: () => checkDateBucketUnit,
22
+ intervalSeconds: () => intervalSeconds,
23
+ parseJsonPath: () => parseJsonPath,
24
+ upsertUpdateColumns: () => upsertUpdateColumns
25
+ });
26
+ module.exports = __toCommonJS(shared_exports);
27
+ const SECONDS_PER_UNIT = /* @__PURE__ */ new Map([
28
+ ["seconds", 1],
29
+ ["minutes", 60],
30
+ ["hours", 3600],
31
+ ["days", 86400]
32
+ ]);
33
+ const intervalSeconds = (amount, unit) => {
34
+ if (typeof amount !== "number" || !Number.isFinite(amount)) {
35
+ throw new Error(`addInterval amount must be a finite number; got ${String(amount)}.`);
36
+ }
37
+ const perUnit = SECONDS_PER_UNIT.get(unit);
38
+ if (perUnit === void 0) {
39
+ throw new Error(`addInterval unit must be 'seconds', 'minutes', 'hours' or 'days'; got ${JSON.stringify(unit)}.`);
40
+ }
41
+ return amount * perUnit;
42
+ };
43
+ const DATE_BUCKET_UNITS = /* @__PURE__ */ new Set(["minute", "hour", "day", "month", "year"]);
44
+ const checkDateBucketUnit = (unit) => {
45
+ if (!DATE_BUCKET_UNITS.has(unit)) {
46
+ throw new Error(`dateBucket unit must be 'minute', 'hour', 'day', 'month' or 'year'; got ${JSON.stringify(unit)}.`);
47
+ }
48
+ return unit;
49
+ };
50
+ const PATH_STEP = /\.([A-Za-z_][A-Za-z0-9_]*)|\[(\d+)\]/y;
51
+ const parseJsonPath = (jsonPath) => {
52
+ const refuse = () => {
53
+ throw new Error(`Unsupported JSON path ${JSON.stringify(jsonPath)}: write $.key, $.key.key or $.key[0].`);
54
+ };
55
+ if (typeof jsonPath !== "string" || !jsonPath.startsWith("$"))
56
+ refuse();
57
+ const steps = [];
58
+ let index = 1;
59
+ while (index < jsonPath.length) {
60
+ PATH_STEP.lastIndex = index;
61
+ const match = PATH_STEP.exec(jsonPath);
62
+ if (!match)
63
+ refuse();
64
+ steps.push(match[1] !== void 0 ? match[1] : Number(match[2]));
65
+ index = PATH_STEP.lastIndex;
66
+ }
67
+ if (steps.length === 0)
68
+ refuse();
69
+ return steps;
70
+ };
71
+ const checkChoice = (what, value, allowed) => {
72
+ if (!allowed.includes(value)) {
73
+ throw new Error(`${what} must be ${allowed.map((option) => `'${option}'`).join(", ")}; got ${JSON.stringify(value)}.`);
74
+ }
75
+ return value;
76
+ };
77
+ const upsertUpdateColumns = (columns, conflictColumns, updateColumns) => {
78
+ if (conflictColumns.length === 0) {
79
+ throw new Error("upsert needs at least one conflict column.");
80
+ }
81
+ return updateColumns ?? columns.filter((column) => !conflictColumns.includes(column));
82
+ };
83
+ // Annotate the CommonJS export names for ESM import in node:
84
+ 0 && (module.exports = {
85
+ checkChoice,
86
+ checkDateBucketUnit,
87
+ intervalSeconds,
88
+ parseJsonPath,
89
+ upsertUpdateColumns
90
+ });
@@ -0,0 +1,14 @@
1
+ import type { IDatabaseExporter } from '../core/contracts/exporter.js';
2
+ /**
3
+ * PostgreSQL database exporter using `pg_dump`.
4
+ *
5
+ * Requires a valid connection string and `pg_dump` to be available on
6
+ * the system PATH. Supports both file-based and byte-array exports.
7
+ */
8
+ export declare class PostgresExporter implements IDatabaseExporter {
9
+ private readonly connectionString?;
10
+ constructor(connectionString?: string | undefined);
11
+ exportToFile(outputPath: string): Promise<void>;
12
+ exportToBytes(): Promise<Uint8Array>;
13
+ }
14
+ //# sourceMappingURL=PostgresExporter.d.ts.map
@@ -0,0 +1,61 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var PostgresExporter_exports = {};
29
+ __export(PostgresExporter_exports, {
30
+ PostgresExporter: () => PostgresExporter
31
+ });
32
+ module.exports = __toCommonJS(PostgresExporter_exports);
33
+ class PostgresExporter {
34
+ constructor(connectionString) {
35
+ this.connectionString = connectionString;
36
+ }
37
+ async exportToFile(outputPath) {
38
+ if (!this.connectionString) {
39
+ throw new Error("PostgresExporter requires a connection string for pg_dump.");
40
+ }
41
+ const { execSync } = await Promise.resolve().then(() => __toESM(require("node:child_process")));
42
+ execSync(`pg_dump "${this.connectionString}" --file="${outputPath}" --format=custom`, {
43
+ stdio: "pipe"
44
+ });
45
+ }
46
+ async exportToBytes() {
47
+ if (!this.connectionString) {
48
+ throw new Error("PostgresExporter requires a connection string for pg_dump.");
49
+ }
50
+ const { execSync } = await Promise.resolve().then(() => __toESM(require("node:child_process")));
51
+ const buf = execSync(`pg_dump "${this.connectionString}" --format=custom`, {
52
+ stdio: ["pipe", "pipe", "pipe"],
53
+ maxBuffer: 256 * 1024 * 1024
54
+ });
55
+ return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
56
+ }
57
+ }
58
+ // Annotate the CommonJS export names for ESM import in node:
59
+ 0 && (module.exports = {
60
+ PostgresExporter
61
+ });
@@ -0,0 +1,16 @@
1
+ import type { StorageAdapter } from '../core/contracts/index.js';
2
+ import type { IDatabaseExporter } from '../core/contracts/exporter.js';
3
+ /**
4
+ * SQLite database exporter.
5
+ *
6
+ * Uses `VACUUM INTO` for file-based exports (better-sqlite3) and delegates
7
+ * to the adapter's `exportDatabase()` method for in-memory exports (sql.js,
8
+ * IndexedDB adapters).
9
+ */
10
+ export declare class SqliteFileExporter implements IDatabaseExporter {
11
+ private readonly adapter;
12
+ constructor(adapter: StorageAdapter);
13
+ exportToFile(outputPath: string): Promise<void>;
14
+ exportToBytes(): Promise<Uint8Array>;
15
+ }
16
+ //# sourceMappingURL=SqliteFileExporter.d.ts.map
@@ -0,0 +1,43 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var SqliteFileExporter_exports = {};
19
+ __export(SqliteFileExporter_exports, {
20
+ SqliteFileExporter: () => SqliteFileExporter
21
+ });
22
+ module.exports = __toCommonJS(SqliteFileExporter_exports);
23
+ class SqliteFileExporter {
24
+ constructor(adapter) {
25
+ this.adapter = adapter;
26
+ }
27
+ async exportToFile(outputPath) {
28
+ const escaped = outputPath.replace(/'/g, "''");
29
+ await this.adapter.exec(`VACUUM INTO '${escaped}'`);
30
+ }
31
+ async exportToBytes() {
32
+ const exportable = this.adapter;
33
+ if (typeof exportable.exportDatabase === "function") {
34
+ const result = exportable.exportDatabase();
35
+ return result instanceof Promise ? result : result;
36
+ }
37
+ throw new Error(`SqliteFileExporter.exportToBytes() is not supported for adapter "${this.adapter.kind}". Use exportToFile() instead, or use an adapter that supports exportDatabase() (sql.js, IndexedDB).`);
38
+ }
39
+ }
40
+ // Annotate the CommonJS export names for ESM import in node:
41
+ 0 && (module.exports = {
42
+ SqliteFileExporter
43
+ });
@@ -0,0 +1,110 @@
1
+ /**
2
+ * An Auth.js database adapter over StorageAdapter: users, accounts, sessions
3
+ * and verification tokens kept through this library on PostgreSQL and SQLite
4
+ * alike, so a product's own Auth.js (NextAuth v5, `@auth/core`) stores its
5
+ * auth data where the rest of its data lives.
6
+ *
7
+ * The object `createAuthJsAdapter()` returns has the shape of `Adapter` from
8
+ * `@auth/core/adapters`, without a dependency on it: pass it as `adapter` to
9
+ * `NextAuth()` or `Auth()`. WebAuthn authenticators are not stored.
10
+ *
11
+ * @module
12
+ */
13
+ import type { StorageAdapter } from '../../core/contracts/index.js';
14
+ /** A user as Auth.js reads it (`AdapterUser`). */
15
+ export interface AuthJsUser {
16
+ id: string;
17
+ email: string;
18
+ emailVerified: Date | null;
19
+ name?: string | null;
20
+ image?: string | null;
21
+ }
22
+ /**
23
+ * An account as Auth.js reads it (`AdapterAccount`). A type, not an
24
+ * interface, so it fits Auth.js's account, which allows more token fields.
25
+ * Fields the provider did not give are left out.
26
+ */
27
+ export type AuthJsAccount = {
28
+ userId: string;
29
+ type: 'oauth' | 'oidc' | 'email' | 'webauthn';
30
+ provider: string;
31
+ providerAccountId: string;
32
+ refresh_token?: string;
33
+ access_token?: string;
34
+ expires_at?: number;
35
+ token_type?: Lowercase<string>;
36
+ scope?: string;
37
+ id_token?: string;
38
+ session_state?: string;
39
+ };
40
+ /** A session as Auth.js reads it (`AdapterSession`). */
41
+ export interface AuthJsSession {
42
+ sessionToken: string;
43
+ userId: string;
44
+ expires: Date;
45
+ }
46
+ /** A verification token as Auth.js reads it (`VerificationToken`). */
47
+ export interface AuthJsVerificationToken {
48
+ identifier: string;
49
+ token: string;
50
+ expires: Date;
51
+ }
52
+ /** The methods of Auth.js's `Adapter` this adapter implements. */
53
+ export interface AuthJsAdapter {
54
+ createUser(user: Omit<AuthJsUser, 'id'> & {
55
+ id?: string;
56
+ }): Promise<AuthJsUser>;
57
+ getUser(id: string): Promise<AuthJsUser | null>;
58
+ getUserByEmail(email: string): Promise<AuthJsUser | null>;
59
+ getUserByAccount(account: Pick<AuthJsAccount, 'provider' | 'providerAccountId'>): Promise<AuthJsUser | null>;
60
+ updateUser(user: Partial<AuthJsUser> & Pick<AuthJsUser, 'id'>): Promise<AuthJsUser>;
61
+ deleteUser(userId: string): Promise<AuthJsUser | null>;
62
+ linkAccount(account: AuthJsAccount): Promise<AuthJsAccount>;
63
+ unlinkAccount(account: Pick<AuthJsAccount, 'provider' | 'providerAccountId'>): Promise<void>;
64
+ getAccount(providerAccountId: string, provider: string): Promise<AuthJsAccount | null>;
65
+ createSession(session: AuthJsSession): Promise<AuthJsSession>;
66
+ getSessionAndUser(sessionToken: string): Promise<{
67
+ session: AuthJsSession;
68
+ user: AuthJsUser;
69
+ } | null>;
70
+ updateSession(session: Partial<AuthJsSession> & Pick<AuthJsSession, 'sessionToken'>): Promise<AuthJsSession | null>;
71
+ deleteSession(sessionToken: string): Promise<void>;
72
+ createVerificationToken(token: AuthJsVerificationToken): Promise<AuthJsVerificationToken>;
73
+ useVerificationToken(params: {
74
+ identifier: string;
75
+ token: string;
76
+ }): Promise<AuthJsVerificationToken | null>;
77
+ }
78
+ /** Where the adapter keeps its tables, and how it makes ids. */
79
+ export interface AuthJsAdapterOptions {
80
+ /** Put before each table name: `<prefix>users`, `<prefix>accounts`, `<prefix>sessions`, `<prefix>verification_tokens`. Default `auth_`. */
81
+ tablePrefix?: string;
82
+ /** Makes a user or account id when Auth.js passes none. Default: `crypto.randomUUID()`. */
83
+ generateId?: () => string;
84
+ }
85
+ /**
86
+ * The statements that create the adapter's tables and indexes on `db`'s
87
+ * engine, each `IF NOT EXISTS`, for a migration file or for
88
+ * ensureAuthJsTables.
89
+ */
90
+ export declare function authJsTablesSql(db: StorageAdapter, options?: AuthJsAdapterOptions): string[];
91
+ /** Creates the adapter's tables and indexes on `db` when they are missing. */
92
+ export declare function ensureAuthJsTables(db: StorageAdapter, options?: AuthJsAdapterOptions): Promise<void>;
93
+ /**
94
+ * An Auth.js database adapter that keeps users, accounts, sessions and
95
+ * verification tokens in `db`, on PostgreSQL or SQLite. Create the tables
96
+ * first with ensureAuthJsTables (or authJsTablesSql in a migration).
97
+ *
98
+ * @example
99
+ * ```typescript
100
+ * import NextAuth from 'next-auth';
101
+ * import { createDatabase } from '@framers/sql-storage-adapter';
102
+ * import { createAuthJsAdapter, ensureAuthJsTables } from '@framers/sql-storage-adapter/authjs';
103
+ *
104
+ * const db = await createDatabase({ url: process.env.DATABASE_URL, strict: true });
105
+ * await ensureAuthJsTables(db);
106
+ * export const { handlers, auth } = NextAuth({ adapter: createAuthJsAdapter(db), providers: [] });
107
+ * ```
108
+ */
109
+ export declare function createAuthJsAdapter(db: StorageAdapter, options?: AuthJsAdapterOptions): AuthJsAdapter;
110
+ //# sourceMappingURL=authJsAdapter.d.ts.map