@livestore/livestore 0.0.41 → 0.0.42-dev.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/.tsbuildinfo +1 -1
- package/dist/{inMemoryDatabase.d.ts → MainDatabaseWrapper.d.ts} +11 -18
- package/dist/MainDatabaseWrapper.d.ts.map +1 -0
- package/dist/{inMemoryDatabase.js → MainDatabaseWrapper.js} +26 -72
- package/dist/MainDatabaseWrapper.js.map +1 -0
- package/dist/__tests__/react/fixture.d.ts +41 -40
- package/dist/__tests__/react/fixture.d.ts.map +1 -1
- package/dist/__tests__/react/fixture.js +2 -8
- package/dist/__tests__/react/fixture.js.map +1 -1
- package/dist/cud.d.ts +9 -9
- package/dist/cud.d.ts.map +1 -1
- package/dist/cud.js +7 -8
- package/dist/cud.js.map +1 -1
- package/dist/effect/LiveStore.d.ts +10 -10
- package/dist/effect/LiveStore.d.ts.map +1 -1
- package/dist/effect/LiveStore.js +2 -11
- package/dist/effect/LiveStore.js.map +1 -1
- package/dist/global-state.d.ts +2 -2
- package/dist/global-state.d.ts.map +1 -1
- package/dist/global-state.js.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/migrations.d.ts +5 -5
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +37 -21
- package/dist/migrations.js.map +1 -1
- package/dist/query-info.d.ts +8 -9
- package/dist/query-info.d.ts.map +1 -1
- package/dist/query-info.js +1 -1
- package/dist/query-info.js.map +1 -1
- package/dist/react/LiveStoreProvider.d.ts +7 -7
- package/dist/react/LiveStoreProvider.d.ts.map +1 -1
- package/dist/react/LiveStoreProvider.js +11 -19
- package/dist/react/LiveStoreProvider.js.map +1 -1
- package/dist/react/useRow.d.ts +6 -6
- package/dist/react/useRow.d.ts.map +1 -1
- package/dist/react/useRow.js +2 -2
- package/dist/react/useRow.js.map +1 -1
- package/dist/reactiveQueries/sql.js +2 -2
- package/dist/reactiveQueries/sql.js.map +1 -1
- package/dist/reactiveQueries/sql.test.js +12 -31
- package/dist/reactiveQueries/sql.test.js.map +1 -1
- package/dist/row-query.d.ts +6 -6
- package/dist/row-query.d.ts.map +1 -1
- package/dist/row-query.js +9 -12
- package/dist/row-query.js.map +1 -1
- package/dist/store.d.ts +18 -18
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +80 -86
- package/dist/store.js.map +1 -1
- package/dist/utils/bounded-collections.d.ts +1 -1
- package/dist/utils/bounded-collections.d.ts.map +1 -1
- package/dist/utils/bounded-collections.js +2 -1
- package/dist/utils/bounded-collections.js.map +1 -1
- package/dist/utils/util.d.ts +0 -16
- package/dist/utils/util.d.ts.map +1 -1
- package/dist/utils/util.js +0 -38
- package/dist/utils/util.js.map +1 -1
- package/package.json +8 -44
- package/src/{inMemoryDatabase.ts → MainDatabaseWrapper.ts} +40 -94
- package/src/__tests__/react/fixture.tsx +3 -9
- package/src/cud.ts +17 -16
- package/src/effect/LiveStore.ts +12 -24
- package/src/global-state.ts +3 -2
- package/src/index.ts +7 -23
- package/src/migrations.ts +51 -34
- package/src/query-info.ts +10 -9
- package/src/react/LiveStoreProvider.tsx +19 -27
- package/src/react/useRow.ts +24 -12
- package/src/reactiveQueries/sql.test.ts +12 -31
- package/src/reactiveQueries/sql.ts +2 -2
- package/src/row-query.ts +32 -29
- package/src/store.ts +98 -103
- package/src/utils/bounded-collections.ts +3 -2
- package/src/utils/util.ts +0 -44
- package/tsconfig.json +1 -1
- package/vitest.config.js +4 -0
- package/dist/inMemoryDatabase.d.ts.map +0 -1
- package/dist/inMemoryDatabase.js.map +0 -1
- package/dist/schema/index.d.ts +0 -42
- package/dist/schema/index.d.ts.map +0 -1
- package/dist/schema/index.js +0 -42
- package/dist/schema/index.js.map +0 -1
- package/dist/schema/mutations.d.ts +0 -81
- package/dist/schema/mutations.d.ts.map +0 -1
- package/dist/schema/mutations.js +0 -29
- package/dist/schema/mutations.js.map +0 -1
- package/dist/schema/parse-utils.d.ts +0 -6
- package/dist/schema/parse-utils.d.ts.map +0 -1
- package/dist/schema/parse-utils.js +0 -22
- package/dist/schema/parse-utils.js.map +0 -1
- package/dist/schema/system-tables.d.ts +0 -76
- package/dist/schema/system-tables.d.ts.map +0 -1
- package/dist/schema/system-tables.js +0 -11
- package/dist/schema/system-tables.js.map +0 -1
- package/dist/schema/table-def.d.ts +0 -100
- package/dist/schema/table-def.d.ts.map +0 -1
- package/dist/schema/table-def.js +0 -70
- package/dist/schema/table-def.js.map +0 -1
- package/dist/storage/in-memory/index.d.ts +0 -19
- package/dist/storage/in-memory/index.d.ts.map +0 -1
- package/dist/storage/in-memory/index.js +0 -16
- package/dist/storage/in-memory/index.js.map +0 -1
- package/dist/storage/index.d.ts +0 -18
- package/dist/storage/index.d.ts.map +0 -1
- package/dist/storage/index.js +0 -9
- package/dist/storage/index.js.map +0 -1
- package/dist/storage/tauri/index.d.ts +0 -23
- package/dist/storage/tauri/index.d.ts.map +0 -1
- package/dist/storage/tauri/index.js +0 -46
- package/dist/storage/tauri/index.js.map +0 -1
- package/dist/storage/utils/idb.d.ts +0 -11
- package/dist/storage/utils/idb.d.ts.map +0 -1
- package/dist/storage/utils/idb.js +0 -71
- package/dist/storage/utils/idb.js.map +0 -1
- package/dist/storage/web-worker/common.d.ts +0 -11
- package/dist/storage/web-worker/common.d.ts.map +0 -1
- package/dist/storage/web-worker/common.js +0 -2
- package/dist/storage/web-worker/common.js.map +0 -1
- package/dist/storage/web-worker/index.d.ts +0 -34
- package/dist/storage/web-worker/index.d.ts.map +0 -1
- package/dist/storage/web-worker/index.js +0 -134
- package/dist/storage/web-worker/index.js.map +0 -1
- package/dist/storage/web-worker/make-worker.d.ts +0 -20
- package/dist/storage/web-worker/make-worker.d.ts.map +0 -1
- package/dist/storage/web-worker/make-worker.js +0 -155
- package/dist/storage/web-worker/make-worker.js.map +0 -1
- package/dist/storage/web-worker/vite-dev-polyfill.d.ts +0 -2
- package/dist/storage/web-worker/vite-dev-polyfill.d.ts.map +0 -1
- package/dist/storage/web-worker/vite-dev-polyfill.js +0 -35
- package/dist/storage/web-worker/vite-dev-polyfill.js.map +0 -1
- package/src/schema/index.ts +0 -100
- package/src/schema/mutations.ts +0 -128
- package/src/schema/parse-utils.ts +0 -42
- package/src/schema/system-tables.ts +0 -21
- package/src/schema/table-def.ts +0 -270
- package/src/storage/in-memory/index.ts +0 -28
- package/src/storage/index.ts +0 -36
- package/src/storage/tauri/index.ts +0 -66
- package/src/storage/utils/idb.ts +0 -85
- package/src/storage/web-worker/common.ts +0 -6
- package/src/storage/web-worker/index.ts +0 -185
- package/src/storage/web-worker/make-worker.ts +0 -214
- package/src/storage/web-worker/vite-dev-polyfill.ts +0 -33
|
@@ -1,10 +1,7 @@
|
|
|
1
|
+
import { type MainDatabase } from '@livestore/common';
|
|
1
2
|
import type * as otel from '@opentelemetry/api';
|
|
2
|
-
import type * as Sqlite from 'sqlite-esm';
|
|
3
3
|
import { BoundArray } from './utils/bounded-collections.js';
|
|
4
|
-
import type
|
|
5
|
-
type DatabaseWithCAPI = Sqlite.Database & {
|
|
6
|
-
capi: Sqlite.CAPI;
|
|
7
|
-
};
|
|
4
|
+
import { type Bindable, type PreparedBindValues } from './utils/util.js';
|
|
8
5
|
export interface DebugInfo {
|
|
9
6
|
slowQueries: BoundArray<SlowQueryInfo>;
|
|
10
7
|
queryFrameDuration: number;
|
|
@@ -20,23 +17,20 @@ export type SlowQueryInfo = [
|
|
|
20
17
|
startTimePerfNow: DOMHighResTimeStamp
|
|
21
18
|
];
|
|
22
19
|
export declare const emptyDebugInfo: () => DebugInfo;
|
|
23
|
-
export declare class
|
|
24
|
-
private db;
|
|
25
|
-
private otelTracer;
|
|
26
|
-
private otelRootSpanContext;
|
|
27
|
-
SQL: Sqlite.Sqlite3Static;
|
|
20
|
+
export declare class MainDatabaseWrapper {
|
|
28
21
|
private cachedStmts;
|
|
29
22
|
private tablesUsedCache;
|
|
30
23
|
private resultCache;
|
|
24
|
+
private db;
|
|
25
|
+
private otelTracer;
|
|
26
|
+
private otelRootSpanContext;
|
|
31
27
|
private tablesUsedStmt;
|
|
32
28
|
debugInfo: DebugInfo;
|
|
33
|
-
constructor(db
|
|
34
|
-
|
|
35
|
-
data: Uint8Array | undefined;
|
|
29
|
+
constructor({ db, otelTracer, otelRootSpanContext, }: {
|
|
30
|
+
db: MainDatabase;
|
|
36
31
|
otelTracer: otel.Tracer;
|
|
37
32
|
otelRootSpanContext: otel.Context;
|
|
38
|
-
|
|
39
|
-
}): InMemoryDatabase;
|
|
33
|
+
});
|
|
40
34
|
txn<TRes>(callback: () => TRes): TRes;
|
|
41
35
|
getTablesUsed(query: string): Set<string>;
|
|
42
36
|
execute(query: string, bindValues?: PreparedBindValues, writeTables?: ReadonlySet<string>, options?: {
|
|
@@ -51,7 +45,6 @@ export declare class InMemoryDatabase {
|
|
|
51
45
|
skipCache?: boolean;
|
|
52
46
|
otelContext?: otel.Context;
|
|
53
47
|
}): ReadonlyArray<T>;
|
|
54
|
-
export():
|
|
48
|
+
export(): Uint8Array;
|
|
55
49
|
}
|
|
56
|
-
|
|
57
|
-
//# sourceMappingURL=inMemoryDatabase.d.ts.map
|
|
50
|
+
//# sourceMappingURL=MainDatabaseWrapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MainDatabaseWrapper.d.ts","sourceRoot":"","sources":["../src/MainDatabaseWrapper.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,YAAY,EAA+B,MAAM,mBAAmB,CAAA;AAElF,OAAO,KAAK,KAAK,IAAI,MAAM,oBAAoB,CAAA;AAG/C,OAAiB,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAA;AAErE,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAExE,MAAM,WAAW,SAAS;IACxB,WAAW,EAAE,UAAU,CAAC,aAAa,CAA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CAAC,OAAO,CAAA;KAAE,GAC/D;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE;IAkDzB,MAAM,CAAC,CAAC,GAAG,GAAG,EACZ,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE;QACR,aAAa,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;QAC3B,UAAU,CAAC,EAAE,kBAAkB,CAAA;QAC/B,SAAS,CAAC,EAAE,OAAO,CAAA;QACnB,WAAW,CAAC,EAAE,IAAI,CAAC,OAAO,CAAA;KAC3B,GACA,aAAa,CAAC,CAAC,CAAC;IAkEnB,MAAM;CAQP"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/* eslint-disable prefer-arrow/prefer-arrow-functions */
|
|
2
|
+
import { sql } from '@livestore/common';
|
|
2
3
|
import { shouldNeverHappen } from '@livestore/utils';
|
|
3
|
-
// import { EVENTS_TABLE_NAME } from './events.js'
|
|
4
|
-
import { sql } from './index.js';
|
|
5
4
|
import QueryCache from './QueryCache.js';
|
|
6
5
|
import BoundMap, { BoundArray } from './utils/bounded-collections.js';
|
|
7
6
|
import { getDurationMsFromSpan, getStartTimeHighResFromSpan } from './utils/otel.js';
|
|
@@ -11,38 +10,23 @@ export const emptyDebugInfo = () => ({
|
|
|
11
10
|
queryFrameCount: 0,
|
|
12
11
|
events: new BoundArray(1000),
|
|
13
12
|
});
|
|
14
|
-
export class
|
|
15
|
-
db;
|
|
16
|
-
otelTracer;
|
|
17
|
-
otelRootSpanContext;
|
|
18
|
-
SQL;
|
|
13
|
+
export class MainDatabaseWrapper {
|
|
19
14
|
// TODO: how many unique active statements are expected?
|
|
20
15
|
cachedStmts = new BoundMap(200);
|
|
21
16
|
tablesUsedCache = new BoundMap(200);
|
|
22
17
|
resultCache = new QueryCache();
|
|
18
|
+
db;
|
|
19
|
+
otelTracer;
|
|
20
|
+
otelRootSpanContext;
|
|
23
21
|
tablesUsedStmt;
|
|
24
22
|
debugInfo = emptyDebugInfo();
|
|
25
|
-
constructor(db, otelTracer, otelRootSpanContext,
|
|
23
|
+
constructor({ db, otelTracer, otelRootSpanContext, }) {
|
|
26
24
|
this.db = db;
|
|
27
25
|
this.otelTracer = otelTracer;
|
|
28
26
|
this.otelRootSpanContext = otelRootSpanContext;
|
|
29
|
-
this.
|
|
30
|
-
this.
|
|
31
|
-
|
|
32
|
-
static load({ data, otelTracer, otelRootSpanContext, sqlite3, }) {
|
|
33
|
-
// TODO move WASM init higher up in the init process (to do some other work while it's loading)
|
|
34
|
-
const db = new sqlite3.oo1.DB({ filename: ':memory:', flags: 'c' });
|
|
35
|
-
db.capi = sqlite3.capi;
|
|
36
|
-
if (data !== undefined) {
|
|
37
|
-
// Based on https://sqlite.org/forum/forumpost/2119230da8ac5357a13b731f462dc76e08621a4a29724f7906d5f35bb8508465
|
|
38
|
-
// TODO find cleaner way to do this once possible in sqlite3-wasm
|
|
39
|
-
const bytes = data;
|
|
40
|
-
const p = sqlite3.wasm.allocFromTypedArray(bytes);
|
|
41
|
-
const _rc = sqlite3.capi.sqlite3_deserialize(db.pointer, 'main', p, bytes.length, bytes.length, sqlite3.capi.SQLITE_DESERIALIZE_FREEONCLOSE && sqlite3.capi.SQLITE_DESERIALIZE_RESIZEABLE);
|
|
42
|
-
}
|
|
43
|
-
const inMemoryDatabase = new InMemoryDatabase(db, otelTracer, otelRootSpanContext, sqlite3);
|
|
44
|
-
configureSQLite(inMemoryDatabase);
|
|
45
|
-
return inMemoryDatabase;
|
|
27
|
+
this.tablesUsedStmt = db.prepare(`SELECT tbl_name FROM tables_used(?) AS u JOIN sqlite_master ON sqlite_master.name = u.name WHERE u.schema = 'main';`);
|
|
28
|
+
this.cachedStmts.onEvict = (_queryStr, stmt) => stmt.finalize();
|
|
29
|
+
configureSQLite(this);
|
|
46
30
|
}
|
|
47
31
|
txn(callback) {
|
|
48
32
|
this.execute(sql `begin transaction;`);
|
|
@@ -62,6 +46,12 @@ export class InMemoryDatabase {
|
|
|
62
46
|
return result;
|
|
63
47
|
}
|
|
64
48
|
getTablesUsed(query) {
|
|
49
|
+
// It seems that SQLite doesn't properly handle `DELETE FROM SOME_TABLE` queries without a WHERE clause
|
|
50
|
+
// So we need to handle these queries separately
|
|
51
|
+
const tableNameFromPlainDeleteQuery = tryGetTableNameFromPlainDeleteQuery(query);
|
|
52
|
+
if (tableNameFromPlainDeleteQuery !== undefined) {
|
|
53
|
+
return new Set([tableNameFromPlainDeleteQuery]);
|
|
54
|
+
}
|
|
65
55
|
const cached = this.tablesUsedCache.get(query);
|
|
66
56
|
if (cached) {
|
|
67
57
|
return cached;
|
|
@@ -69,18 +59,15 @@ export class InMemoryDatabase {
|
|
|
69
59
|
const stmt = this.tablesUsedStmt;
|
|
70
60
|
const tablesUsed = new Set();
|
|
71
61
|
try {
|
|
72
|
-
stmt.
|
|
73
|
-
|
|
74
|
-
tablesUsed.add(
|
|
62
|
+
const results = stmt.select([query]);
|
|
63
|
+
for (const row of results) {
|
|
64
|
+
tablesUsed.add(row.tbl_name);
|
|
75
65
|
}
|
|
76
66
|
}
|
|
77
67
|
catch (e) {
|
|
78
68
|
console.error('Error getting tables used', e, 'for query', query);
|
|
79
69
|
return new Set();
|
|
80
70
|
}
|
|
81
|
-
finally {
|
|
82
|
-
stmt.reset();
|
|
83
|
-
}
|
|
84
71
|
this.tablesUsedCache.set(query, tablesUsed);
|
|
85
72
|
return tablesUsed;
|
|
86
73
|
}
|
|
@@ -95,18 +82,7 @@ export class InMemoryDatabase {
|
|
|
95
82
|
stmt = this.db.prepare(query);
|
|
96
83
|
this.cachedStmts.set(query, stmt);
|
|
97
84
|
}
|
|
98
|
-
|
|
99
|
-
stmt.bind(bindValues);
|
|
100
|
-
}
|
|
101
|
-
if (import.meta.env.DEV) {
|
|
102
|
-
this.debugInfo.events.push([query, bindValues]);
|
|
103
|
-
}
|
|
104
|
-
try {
|
|
105
|
-
stmt.step();
|
|
106
|
-
}
|
|
107
|
-
finally {
|
|
108
|
-
stmt.reset(); // Reset is needed for next execution
|
|
109
|
-
}
|
|
85
|
+
stmt.execute(bindValues);
|
|
110
86
|
}
|
|
111
87
|
catch (error) {
|
|
112
88
|
shouldNeverHappen(`Error executing query: ${error} \n ${JSON.stringify({ query, bindValues })}`);
|
|
@@ -152,33 +128,7 @@ export class InMemoryDatabase {
|
|
|
152
128
|
stmt = this.db.prepare(query);
|
|
153
129
|
this.cachedStmts.set(query, stmt);
|
|
154
130
|
}
|
|
155
|
-
|
|
156
|
-
stmt.bind(bindValues);
|
|
157
|
-
}
|
|
158
|
-
const result = [];
|
|
159
|
-
try {
|
|
160
|
-
// NOTE `getColumnNames` only works for `SELECT` statements, ignoring other statements for now
|
|
161
|
-
let columns = undefined;
|
|
162
|
-
try {
|
|
163
|
-
columns = stmt.getColumnNames();
|
|
164
|
-
}
|
|
165
|
-
catch (_e) { }
|
|
166
|
-
while (stmt.step()) {
|
|
167
|
-
if (columns !== undefined) {
|
|
168
|
-
const obj = {};
|
|
169
|
-
for (const [i, c] of columns.entries()) {
|
|
170
|
-
obj[c] = stmt.get(i);
|
|
171
|
-
}
|
|
172
|
-
result.push(obj);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
finally {
|
|
177
|
-
// we're caching statements in this iteration. do not free.
|
|
178
|
-
// stmt.free();
|
|
179
|
-
// reset the cached statement so we can use it again in the future
|
|
180
|
-
stmt.reset();
|
|
181
|
-
}
|
|
131
|
+
const result = stmt.select(bindValues);
|
|
182
132
|
span.setAttribute('sql.rowsCount', result.length);
|
|
183
133
|
span.setAttribute('sql.cached', false);
|
|
184
134
|
const queriedTables_ = queriedTables ?? this.getTablesUsed(query);
|
|
@@ -213,7 +163,7 @@ export class InMemoryDatabase {
|
|
|
213
163
|
for (const key of this.cachedStmts.keys()) {
|
|
214
164
|
this.cachedStmts.delete(key);
|
|
215
165
|
}
|
|
216
|
-
return this.db.
|
|
166
|
+
return this.db.export();
|
|
217
167
|
}
|
|
218
168
|
}
|
|
219
169
|
/** Set up SQLite performance; hasn't been super carefully optimized yet. */
|
|
@@ -229,4 +179,8 @@ const configureSQLite = (db) => {
|
|
|
229
179
|
PRAGMA foreign_keys='ON'; -- we want foreign key constraints to be enforced
|
|
230
180
|
`);
|
|
231
181
|
};
|
|
232
|
-
|
|
182
|
+
const tryGetTableNameFromPlainDeleteQuery = (query) => {
|
|
183
|
+
const [_, tableName] = query.trim().match(/^delete\s+from\s+(\w+)$/i) ?? [];
|
|
184
|
+
return tableName;
|
|
185
|
+
};
|
|
186
|
+
//# sourceMappingURL=MainDatabaseWrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MainDatabaseWrapper.js","sourceRoot":"","sources":["../src/MainDatabaseWrapper.ts"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,OAAO,EAA6C,GAAG,EAAE,MAAM,mBAAmB,CAAA;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAGpD,OAAO,UAAU,MAAM,iBAAiB,CAAA;AACxC,OAAO,QAAQ,EAAE,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAA;AACrE,OAAO,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAA;AAmBpF,MAAM,CAAC,MAAM,cAAc,GAAG,GAAc,EAAE,CAAC,CAAC;IAC9C,WAAW,EAAE,IAAI,UAAU,CAAC,GAAG,CAAC;IAChC,kBAAkB,EAAE,CAAC;IACrB,eAAe,EAAE,CAAC;IAClB,MAAM,EAAE,IAAI,UAAU,CAAC,IAAI,CAAC;CAC7B,CAAC,CAAA;AAEF,MAAM,OAAO,mBAAmB;IAC9B,wDAAwD;IAChD,WAAW,GAAG,IAAI,QAAQ,CAA4B,GAAG,CAAC,CAAA;IAC1D,eAAe,GAAG,IAAI,QAAQ,CAAsB,GAAG,CAAC,CAAA;IACxD,WAAW,GAAG,IAAI,UAAU,EAAE,CAAA;IAC9B,EAAE,CAAc;IAChB,UAAU,CAAa;IACvB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,CAAC,MAAM,EAAE,CAAA;IACzB,CAAC;CACF;AAED,4EAA4E;AAC5E,MAAM,eAAe,GAAG,CAAC,EAAuB,EAAE,EAAE;IAClD,EAAE,CAAC,OAAO;IACR,4DAA4D;IAC5D,GAAG,CAAA;;;;;;;KAOF,CACF,CAAA;AACH,CAAC,CAAA;AAED,MAAM,mCAAmC,GAAG,CAAC,KAAa,EAAE,EAAE;IAC5D,MAAM,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,0BAA0B,CAAC,IAAI,EAAE,CAAA;IAC3E,OAAO,SAAS,CAAA;AAClB,CAAC,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Schema as __Schema } from '@livestore/utils/effect';
|
|
1
2
|
import type * as otel from '@opentelemetry/api';
|
|
2
3
|
import React from 'react';
|
|
3
4
|
import { DbSchema } from '../../index.js';
|
|
@@ -14,21 +15,21 @@ export type AppState = {
|
|
|
14
15
|
export declare const todos: DbSchema.TableDef<DbSchema.SqliteDsl.TableDefinition<"todos", {
|
|
15
16
|
id: {
|
|
16
17
|
columnType: "text";
|
|
17
|
-
schema:
|
|
18
|
+
schema: __Schema.Schema<string, string, never>;
|
|
18
19
|
default: import("effect/Option").None<never>;
|
|
19
20
|
nullable: false;
|
|
20
21
|
primaryKey: true;
|
|
21
22
|
} & DbSchema.SqliteDsl.ColumnDefinition<string, string>;
|
|
22
23
|
text: {
|
|
23
24
|
columnType: "text";
|
|
24
|
-
schema:
|
|
25
|
+
schema: __Schema.Schema<string, string, never>;
|
|
25
26
|
default: import("effect/Option").Some<"">;
|
|
26
27
|
nullable: false;
|
|
27
28
|
primaryKey: false;
|
|
28
29
|
};
|
|
29
30
|
completed: {
|
|
30
31
|
columnType: "integer";
|
|
31
|
-
schema:
|
|
32
|
+
schema: __Schema.Schema<boolean, number, never>;
|
|
32
33
|
default: import("effect/Option").Some<false>;
|
|
33
34
|
nullable: false;
|
|
34
35
|
primaryKey: false;
|
|
@@ -37,7 +38,7 @@ export declare const todos: DbSchema.TableDef<DbSchema.SqliteDsl.TableDefinition
|
|
|
37
38
|
isSingleton: false;
|
|
38
39
|
dynamicRegistration: false;
|
|
39
40
|
disableAutomaticIdColumn: false;
|
|
40
|
-
},
|
|
41
|
+
}, __Schema.Schema<{
|
|
41
42
|
readonly id: string;
|
|
42
43
|
readonly text: string;
|
|
43
44
|
readonly completed: boolean;
|
|
@@ -49,21 +50,21 @@ export declare const todos: DbSchema.TableDef<DbSchema.SqliteDsl.TableDefinition
|
|
|
49
50
|
export declare const app: DbSchema.TableDef<DbSchema.SqliteDsl.TableDefinition<"app", {
|
|
50
51
|
id: {
|
|
51
52
|
columnType: "text";
|
|
52
|
-
schema:
|
|
53
|
+
schema: __Schema.Schema<string, string, never>;
|
|
53
54
|
default: import("effect/Option").None<never>;
|
|
54
55
|
nullable: false;
|
|
55
56
|
primaryKey: true;
|
|
56
57
|
} & DbSchema.SqliteDsl.ColumnDefinition<string, string>;
|
|
57
58
|
newTodoText: {
|
|
58
59
|
columnType: "text";
|
|
59
|
-
schema:
|
|
60
|
+
schema: __Schema.Schema<string | null, string | null, never>;
|
|
60
61
|
default: import("effect/Option").Some<"">;
|
|
61
62
|
nullable: true;
|
|
62
63
|
primaryKey: false;
|
|
63
64
|
};
|
|
64
65
|
filter: {
|
|
65
66
|
columnType: "text";
|
|
66
|
-
schema:
|
|
67
|
+
schema: __Schema.Schema<string, string, never>;
|
|
67
68
|
default: import("effect/Option").Some<"all">;
|
|
68
69
|
nullable: false;
|
|
69
70
|
primaryKey: false;
|
|
@@ -72,7 +73,7 @@ export declare const app: DbSchema.TableDef<DbSchema.SqliteDsl.TableDefinition<"
|
|
|
72
73
|
isSingleton: false;
|
|
73
74
|
dynamicRegistration: false;
|
|
74
75
|
disableAutomaticIdColumn: false;
|
|
75
|
-
},
|
|
76
|
+
}, __Schema.Schema<{
|
|
76
77
|
readonly id: string;
|
|
77
78
|
readonly newTodoText: string | null;
|
|
78
79
|
readonly filter: string;
|
|
@@ -85,21 +86,21 @@ export declare const tables: {
|
|
|
85
86
|
todos: DbSchema.TableDef<DbSchema.SqliteDsl.TableDefinition<"todos", {
|
|
86
87
|
id: {
|
|
87
88
|
columnType: "text";
|
|
88
|
-
schema:
|
|
89
|
+
schema: __Schema.Schema<string, string, never>;
|
|
89
90
|
default: import("effect/Option").None<never>;
|
|
90
91
|
nullable: false;
|
|
91
92
|
primaryKey: true;
|
|
92
93
|
} & DbSchema.SqliteDsl.ColumnDefinition<string, string>;
|
|
93
94
|
text: {
|
|
94
95
|
columnType: "text";
|
|
95
|
-
schema:
|
|
96
|
+
schema: __Schema.Schema<string, string, never>;
|
|
96
97
|
default: import("effect/Option").Some<"">;
|
|
97
98
|
nullable: false;
|
|
98
99
|
primaryKey: false;
|
|
99
100
|
};
|
|
100
101
|
completed: {
|
|
101
102
|
columnType: "integer";
|
|
102
|
-
schema:
|
|
103
|
+
schema: __Schema.Schema<boolean, number, never>;
|
|
103
104
|
default: import("effect/Option").Some<false>;
|
|
104
105
|
nullable: false;
|
|
105
106
|
primaryKey: false;
|
|
@@ -108,7 +109,7 @@ export declare const tables: {
|
|
|
108
109
|
isSingleton: false;
|
|
109
110
|
dynamicRegistration: false;
|
|
110
111
|
disableAutomaticIdColumn: false;
|
|
111
|
-
},
|
|
112
|
+
}, __Schema.Schema<{
|
|
112
113
|
readonly id: string;
|
|
113
114
|
readonly text: string;
|
|
114
115
|
readonly completed: boolean;
|
|
@@ -120,21 +121,21 @@ export declare const tables: {
|
|
|
120
121
|
app: DbSchema.TableDef<DbSchema.SqliteDsl.TableDefinition<"app", {
|
|
121
122
|
id: {
|
|
122
123
|
columnType: "text";
|
|
123
|
-
schema:
|
|
124
|
+
schema: __Schema.Schema<string, string, never>;
|
|
124
125
|
default: import("effect/Option").None<never>;
|
|
125
126
|
nullable: false;
|
|
126
127
|
primaryKey: true;
|
|
127
128
|
} & DbSchema.SqliteDsl.ColumnDefinition<string, string>;
|
|
128
129
|
newTodoText: {
|
|
129
130
|
columnType: "text";
|
|
130
|
-
schema:
|
|
131
|
+
schema: __Schema.Schema<string | null, string | null, never>;
|
|
131
132
|
default: import("effect/Option").Some<"">;
|
|
132
133
|
nullable: true;
|
|
133
134
|
primaryKey: false;
|
|
134
135
|
};
|
|
135
136
|
filter: {
|
|
136
137
|
columnType: "text";
|
|
137
|
-
schema:
|
|
138
|
+
schema: __Schema.Schema<string, string, never>;
|
|
138
139
|
default: import("effect/Option").Some<"all">;
|
|
139
140
|
nullable: false;
|
|
140
141
|
primaryKey: false;
|
|
@@ -143,7 +144,7 @@ export declare const tables: {
|
|
|
143
144
|
isSingleton: false;
|
|
144
145
|
dynamicRegistration: false;
|
|
145
146
|
disableAutomaticIdColumn: false;
|
|
146
|
-
},
|
|
147
|
+
}, __Schema.Schema<{
|
|
147
148
|
readonly id: string;
|
|
148
149
|
readonly newTodoText: string | null;
|
|
149
150
|
readonly filter: string;
|
|
@@ -153,25 +154,25 @@ export declare const tables: {
|
|
|
153
154
|
readonly filter: string;
|
|
154
155
|
}, never>>;
|
|
155
156
|
};
|
|
156
|
-
export declare const schema: import("
|
|
157
|
+
export declare const schema: import("@livestore/common/dist/schema/index.js").LiveStoreSchema<{
|
|
157
158
|
todos: DbSchema.SqliteDsl.TableDefinition<"todos", {
|
|
158
159
|
id: {
|
|
159
160
|
columnType: "text";
|
|
160
|
-
schema:
|
|
161
|
+
schema: __Schema.Schema<string, string, never>;
|
|
161
162
|
default: import("effect/Option").None<never>;
|
|
162
163
|
nullable: false;
|
|
163
164
|
primaryKey: true;
|
|
164
165
|
} & DbSchema.SqliteDsl.ColumnDefinition<string, string>;
|
|
165
166
|
text: {
|
|
166
167
|
columnType: "text";
|
|
167
|
-
schema:
|
|
168
|
+
schema: __Schema.Schema<string, string, never>;
|
|
168
169
|
default: import("effect/Option").Some<"">;
|
|
169
170
|
nullable: false;
|
|
170
171
|
primaryKey: false;
|
|
171
172
|
};
|
|
172
173
|
completed: {
|
|
173
174
|
columnType: "integer";
|
|
174
|
-
schema:
|
|
175
|
+
schema: __Schema.Schema<boolean, number, never>;
|
|
175
176
|
default: import("effect/Option").Some<false>;
|
|
176
177
|
nullable: false;
|
|
177
178
|
primaryKey: false;
|
|
@@ -180,21 +181,21 @@ export declare const schema: import("../../index.js").LiveStoreSchema<{
|
|
|
180
181
|
app: DbSchema.SqliteDsl.TableDefinition<"app", {
|
|
181
182
|
id: {
|
|
182
183
|
columnType: "text";
|
|
183
|
-
schema:
|
|
184
|
+
schema: __Schema.Schema<string, string, never>;
|
|
184
185
|
default: import("effect/Option").None<never>;
|
|
185
186
|
nullable: false;
|
|
186
187
|
primaryKey: true;
|
|
187
188
|
} & DbSchema.SqliteDsl.ColumnDefinition<string, string>;
|
|
188
189
|
newTodoText: {
|
|
189
190
|
columnType: "text";
|
|
190
|
-
schema:
|
|
191
|
+
schema: __Schema.Schema<string | null, string | null, never>;
|
|
191
192
|
default: import("effect/Option").Some<"">;
|
|
192
193
|
nullable: true;
|
|
193
194
|
primaryKey: false;
|
|
194
195
|
};
|
|
195
196
|
filter: {
|
|
196
197
|
columnType: "text";
|
|
197
|
-
schema:
|
|
198
|
+
schema: __Schema.Schema<string, string, never>;
|
|
198
199
|
default: import("effect/Option").Some<"all">;
|
|
199
200
|
nullable: false;
|
|
200
201
|
primaryKey: false;
|
|
@@ -215,7 +216,7 @@ export declare const makeTodoMvc: ({ otelTracer, otelContext, useGlobalDbGraph,
|
|
|
215
216
|
AppComponentSchema: DbSchema.TableDef<DbSchema.SqliteDsl.TableDefinition<"UserInfo", {
|
|
216
217
|
username: {
|
|
217
218
|
columnType: "text";
|
|
218
|
-
schema:
|
|
219
|
+
schema: __Schema.Schema<string, string, never>;
|
|
219
220
|
default: import("effect/Option").Some<"">;
|
|
220
221
|
nullable: false;
|
|
221
222
|
primaryKey: false;
|
|
@@ -225,32 +226,32 @@ export declare const makeTodoMvc: ({ otelTracer, otelContext, useGlobalDbGraph,
|
|
|
225
226
|
isSingleton: false;
|
|
226
227
|
dynamicRegistration: false;
|
|
227
228
|
disableAutomaticIdColumn: false;
|
|
228
|
-
},
|
|
229
|
+
}, __Schema.Schema<{
|
|
229
230
|
readonly username: string;
|
|
230
231
|
readonly id: string;
|
|
231
232
|
}, {
|
|
232
233
|
readonly username: string;
|
|
233
234
|
readonly id: string;
|
|
234
235
|
}, never>>;
|
|
235
|
-
store: import("../../store.js").Store<import("../../store.js").BaseGraphQLContext, import("
|
|
236
|
+
store: import("../../store.js").Store<import("../../store.js").BaseGraphQLContext, import("@livestore/common/dist/schema/index.js").LiveStoreSchema<{
|
|
236
237
|
todos: DbSchema.SqliteDsl.TableDefinition<"todos", {
|
|
237
238
|
id: {
|
|
238
239
|
columnType: "text";
|
|
239
|
-
schema:
|
|
240
|
+
schema: __Schema.Schema<string, string, never>;
|
|
240
241
|
default: import("effect/Option").None<never>;
|
|
241
242
|
nullable: false;
|
|
242
243
|
primaryKey: true;
|
|
243
244
|
} & DbSchema.SqliteDsl.ColumnDefinition<string, string>;
|
|
244
245
|
text: {
|
|
245
246
|
columnType: "text";
|
|
246
|
-
schema:
|
|
247
|
+
schema: __Schema.Schema<string, string, never>;
|
|
247
248
|
default: import("effect/Option").Some<"">;
|
|
248
249
|
nullable: false;
|
|
249
250
|
primaryKey: false;
|
|
250
251
|
};
|
|
251
252
|
completed: {
|
|
252
253
|
columnType: "integer";
|
|
253
|
-
schema:
|
|
254
|
+
schema: __Schema.Schema<boolean, number, never>;
|
|
254
255
|
default: import("effect/Option").Some<false>;
|
|
255
256
|
nullable: false;
|
|
256
257
|
primaryKey: false;
|
|
@@ -259,21 +260,21 @@ export declare const makeTodoMvc: ({ otelTracer, otelContext, useGlobalDbGraph,
|
|
|
259
260
|
app: DbSchema.SqliteDsl.TableDefinition<"app", {
|
|
260
261
|
id: {
|
|
261
262
|
columnType: "text";
|
|
262
|
-
schema:
|
|
263
|
+
schema: __Schema.Schema<string, string, never>;
|
|
263
264
|
default: import("effect/Option").None<never>;
|
|
264
265
|
nullable: false;
|
|
265
266
|
primaryKey: true;
|
|
266
267
|
} & DbSchema.SqliteDsl.ColumnDefinition<string, string>;
|
|
267
268
|
newTodoText: {
|
|
268
269
|
columnType: "text";
|
|
269
|
-
schema:
|
|
270
|
+
schema: __Schema.Schema<string | null, string | null, never>;
|
|
270
271
|
default: import("effect/Option").Some<"">;
|
|
271
272
|
nullable: true;
|
|
272
273
|
primaryKey: false;
|
|
273
274
|
};
|
|
274
275
|
filter: {
|
|
275
276
|
columnType: "text";
|
|
276
|
-
schema:
|
|
277
|
+
schema: __Schema.Schema<string, string, never>;
|
|
277
278
|
default: import("effect/Option").Some<"all">;
|
|
278
279
|
nullable: false;
|
|
279
280
|
primaryKey: false;
|
|
@@ -284,21 +285,21 @@ export declare const makeTodoMvc: ({ otelTracer, otelContext, useGlobalDbGraph,
|
|
|
284
285
|
cud: import("../../cud.js").CudMutations<DbSchema.TableDef<DbSchema.SqliteDsl.TableDefinition<"todos", {
|
|
285
286
|
id: {
|
|
286
287
|
columnType: "text";
|
|
287
|
-
schema:
|
|
288
|
+
schema: __Schema.Schema<string, string, never>;
|
|
288
289
|
default: import("effect/Option").None<never>;
|
|
289
290
|
nullable: false;
|
|
290
291
|
primaryKey: true;
|
|
291
292
|
} & DbSchema.SqliteDsl.ColumnDefinition<string, string>;
|
|
292
293
|
text: {
|
|
293
294
|
columnType: "text";
|
|
294
|
-
schema:
|
|
295
|
+
schema: __Schema.Schema<string, string, never>;
|
|
295
296
|
default: import("effect/Option").Some<"">;
|
|
296
297
|
nullable: false;
|
|
297
298
|
primaryKey: false;
|
|
298
299
|
};
|
|
299
300
|
completed: {
|
|
300
301
|
columnType: "integer";
|
|
301
|
-
schema:
|
|
302
|
+
schema: __Schema.Schema<boolean, number, never>;
|
|
302
303
|
default: import("effect/Option").Some<false>;
|
|
303
304
|
nullable: false;
|
|
304
305
|
primaryKey: false;
|
|
@@ -307,7 +308,7 @@ export declare const makeTodoMvc: ({ otelTracer, otelContext, useGlobalDbGraph,
|
|
|
307
308
|
isSingleton: false;
|
|
308
309
|
dynamicRegistration: false;
|
|
309
310
|
disableAutomaticIdColumn: false;
|
|
310
|
-
},
|
|
311
|
+
}, __Schema.Schema<{
|
|
311
312
|
readonly id: string;
|
|
312
313
|
readonly text: string;
|
|
313
314
|
readonly completed: boolean;
|
|
@@ -318,21 +319,21 @@ export declare const makeTodoMvc: ({ otelTracer, otelContext, useGlobalDbGraph,
|
|
|
318
319
|
}, never>> | DbSchema.TableDef<DbSchema.SqliteDsl.TableDefinition<"app", {
|
|
319
320
|
id: {
|
|
320
321
|
columnType: "text";
|
|
321
|
-
schema:
|
|
322
|
+
schema: __Schema.Schema<string, string, never>;
|
|
322
323
|
default: import("effect/Option").None<never>;
|
|
323
324
|
nullable: false;
|
|
324
325
|
primaryKey: true;
|
|
325
326
|
} & DbSchema.SqliteDsl.ColumnDefinition<string, string>;
|
|
326
327
|
newTodoText: {
|
|
327
328
|
columnType: "text";
|
|
328
|
-
schema:
|
|
329
|
+
schema: __Schema.Schema<string | null, string | null, never>;
|
|
329
330
|
default: import("effect/Option").Some<"">;
|
|
330
331
|
nullable: true;
|
|
331
332
|
primaryKey: false;
|
|
332
333
|
};
|
|
333
334
|
filter: {
|
|
334
335
|
columnType: "text";
|
|
335
|
-
schema:
|
|
336
|
+
schema: __Schema.Schema<string, string, never>;
|
|
336
337
|
default: import("effect/Option").Some<"all">;
|
|
337
338
|
nullable: false;
|
|
338
339
|
primaryKey: false;
|
|
@@ -341,7 +342,7 @@ export declare const makeTodoMvc: ({ otelTracer, otelContext, useGlobalDbGraph,
|
|
|
341
342
|
isSingleton: false;
|
|
342
343
|
dynamicRegistration: false;
|
|
343
344
|
disableAutomaticIdColumn: false;
|
|
344
|
-
},
|
|
345
|
+
}, __Schema.Schema<{
|
|
345
346
|
readonly id: string;
|
|
346
347
|
readonly newTodoText: string | null;
|
|
347
348
|
readonly filter: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixture.d.ts","sourceRoot":"","sources":["../../../src/__tests__/react/fixture.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,IAAI,MAAM,oBAAoB,CAAA;AAC/C,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"fixture.d.ts","sourceRoot":"","sources":["../../../src/__tests__/react/fixture.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAE5D,OAAO,KAAK,KAAK,IAAI,MAAM,oBAAoB,CAAA;AAC/C,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,OAAO,EAAe,QAAQ,EAA8D,MAAM,gBAAgB,CAAA;AAGlH,MAAM,MAAM,IAAI,GAAG;IACjB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,OAAO,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,WAAW,CAAA;AAEnD,MAAM,MAAM,QAAQ,GAAG;IACrB,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAIhB,CAAA;AAEF,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAId,CAAA;AAEF,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAiB,CAAA;AACpC,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAAyB,CAAA;AAE5C,eAAO,MAAM,UAAU;;;;GAAyB,CAAA;AAEhD,eAAO,MAAM,WAAW;;;;;4BA6BS,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKnC,CAAA"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
import { makeDb } from '@livestore/web';
|
|
1
2
|
import React from 'react';
|
|
2
|
-
import initSqlite3Wasm from 'sqlite-esm';
|
|
3
3
|
import { globalDbGraph } from '../../global-state.js';
|
|
4
4
|
import { createStore, DbSchema, makeCudMutations, makeDbGraph, makeSchema, ParseUtils, sql } from '../../index.js';
|
|
5
5
|
import * as LiveStoreReact from '../../react/index.js';
|
|
6
|
-
import { InMemoryStorage } from '../../storage/in-memory/index.js';
|
|
7
6
|
export const todos = DbSchema.table('todos', {
|
|
8
7
|
id: DbSchema.text({ primaryKey: true }),
|
|
9
8
|
text: DbSchema.text({ default: '', nullable: false }),
|
|
@@ -21,16 +20,11 @@ export const makeTodoMvc = async ({ otelTracer, otelContext, useGlobalDbGraph =
|
|
|
21
20
|
const AppComponentSchema = DbSchema.table('UserInfo', {
|
|
22
21
|
username: DbSchema.text({ default: '' }),
|
|
23
22
|
});
|
|
24
|
-
const sqlite3 = await initSqlite3Wasm({
|
|
25
|
-
print: (message) => console.log(`[livestore sqlite] ${message}`),
|
|
26
|
-
printErr: (message) => console.error(`[livestore sqlite] ${message}`),
|
|
27
|
-
});
|
|
28
23
|
const dbGraph = useGlobalDbGraph ? globalDbGraph : makeDbGraph();
|
|
29
24
|
const store = await createStore({
|
|
30
25
|
schema,
|
|
31
|
-
loadStorage: () => InMemoryStorage.load(),
|
|
32
26
|
boot: (db) => db.execute(sql `INSERT OR IGNORE INTO app (id, newTodoText, filter) VALUES ('static', '', 'all');`),
|
|
33
|
-
|
|
27
|
+
makeDb: makeDb(),
|
|
34
28
|
dbGraph,
|
|
35
29
|
otelTracer,
|
|
36
30
|
otelRootSpanContext: otelContext,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixture.js","sourceRoot":"","sources":["../../../src/__tests__/react/fixture.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"fixture.js","sourceRoot":"","sources":["../../../src/__tests__/react/fixture.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAEvC,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAErD,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,gBAAgB,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AAClH,OAAO,KAAK,cAAc,MAAM,sBAAsB,CAAA;AAetD,MAAM,CAAC,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,OAAO,EAAE;IAC3C,EAAE,EAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;IACvC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IACrD,SAAS,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;CACjE,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE;IACvC,EAAE,EAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;IACvC,WAAW,EAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC3D,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE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