@livestore/common 0.0.54-dev.3 → 0.0.54-dev.31

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 (90) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/__tests__/fixture.d.ts +0 -2
  3. package/dist/__tests__/fixture.d.ts.map +1 -1
  4. package/dist/adapter-types.d.ts +75 -16
  5. package/dist/adapter-types.d.ts.map +1 -1
  6. package/dist/adapter-types.js +18 -0
  7. package/dist/adapter-types.js.map +1 -1
  8. package/dist/bounded-collections.d.ts +1 -1
  9. package/dist/bounded-collections.d.ts.map +1 -1
  10. package/dist/bounded-collections.js.map +1 -1
  11. package/dist/debug-info.d.ts +4 -0
  12. package/dist/debug-info.d.ts.map +1 -1
  13. package/dist/debug-info.js +6 -9
  14. package/dist/debug-info.js.map +1 -1
  15. package/dist/derived-mutations.d.ts +12 -13
  16. package/dist/derived-mutations.d.ts.map +1 -1
  17. package/dist/devtools/devtools-messages.d.ts +248 -46
  18. package/dist/devtools/devtools-messages.d.ts.map +1 -1
  19. package/dist/devtools/devtools-messages.js +110 -48
  20. package/dist/devtools/devtools-messages.js.map +1 -1
  21. package/dist/devtools/devtools-window-message.d.ts +29 -0
  22. package/dist/devtools/devtools-window-message.d.ts.map +1 -0
  23. package/dist/devtools/devtools-window-message.js +33 -0
  24. package/dist/devtools/devtools-window-message.js.map +1 -0
  25. package/dist/devtools/index.d.ts +1 -0
  26. package/dist/devtools/index.d.ts.map +1 -1
  27. package/dist/devtools/index.js +1 -0
  28. package/dist/devtools/index.js.map +1 -1
  29. package/dist/index.d.ts +1 -0
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +1 -0
  32. package/dist/index.js.map +1 -1
  33. package/dist/mutation.d.ts.map +1 -1
  34. package/dist/rehydrate-from-mutationlog.d.ts +8 -3
  35. package/dist/rehydrate-from-mutationlog.d.ts.map +1 -1
  36. package/dist/rehydrate-from-mutationlog.js +71 -56
  37. package/dist/rehydrate-from-mutationlog.js.map +1 -1
  38. package/dist/schema/index.d.ts.map +1 -1
  39. package/dist/schema/mutations.d.ts +2 -1
  40. package/dist/schema/mutations.d.ts.map +1 -1
  41. package/dist/schema/mutations.js +4 -2
  42. package/dist/schema/mutations.js.map +1 -1
  43. package/dist/schema/parse-utils.d.ts +3 -14
  44. package/dist/schema/parse-utils.d.ts.map +1 -1
  45. package/dist/schema/schema-helpers.d.ts +3 -13
  46. package/dist/schema/schema-helpers.d.ts.map +1 -1
  47. package/dist/schema/system-tables.d.ts +0 -5
  48. package/dist/schema/system-tables.d.ts.map +1 -1
  49. package/dist/schema/table-def.d.ts +3 -21
  50. package/dist/schema/table-def.d.ts.map +1 -1
  51. package/dist/schema/table-def.js +0 -1
  52. package/dist/schema/table-def.js.map +1 -1
  53. package/dist/schema-management/common.d.ts.map +1 -1
  54. package/dist/schema-management/migrations.d.ts +10 -5
  55. package/dist/schema-management/migrations.d.ts.map +1 -1
  56. package/dist/schema-management/migrations.js +24 -13
  57. package/dist/schema-management/migrations.js.map +1 -1
  58. package/dist/schema-management/validate-mutation-defs.d.ts.map +1 -1
  59. package/dist/sql-queries/misc.d.ts.map +1 -1
  60. package/dist/sql-queries/sql-queries.d.ts.map +1 -1
  61. package/dist/sql-queries/sql-query-builder.d.ts +33 -33
  62. package/dist/sql-queries/sql-query-builder.d.ts.map +1 -1
  63. package/dist/sql-queries/types.d.ts.map +1 -1
  64. package/dist/sync/sync.d.ts +3 -3
  65. package/dist/util.d.ts +0 -1
  66. package/dist/util.d.ts.map +1 -1
  67. package/dist/util.js +1 -1
  68. package/dist/util.js.map +1 -1
  69. package/dist/version.d.ts +2 -0
  70. package/dist/version.d.ts.map +1 -0
  71. package/dist/version.js +3 -0
  72. package/dist/version.js.map +1 -0
  73. package/package.json +4 -8
  74. package/src/adapter-types.ts +53 -15
  75. package/src/bounded-collections.ts +1 -1
  76. package/src/debug-info.ts +6 -18
  77. package/src/devtools/devtools-messages.ts +146 -65
  78. package/src/devtools/devtools-window-message.ts +27 -0
  79. package/src/devtools/index.ts +1 -0
  80. package/src/index.ts +1 -0
  81. package/src/rehydrate-from-mutationlog.ts +99 -64
  82. package/src/schema/mutations.ts +8 -5
  83. package/src/schema/table-def.ts +0 -4
  84. package/src/schema-management/migrations.ts +104 -84
  85. package/src/util.ts +1 -1
  86. package/src/version.ts +3 -0
  87. package/dist/devtools/index copy.d.ts +0 -214
  88. package/dist/devtools/index copy.d.ts.map +0 -1
  89. package/dist/devtools/index copy.js +0 -137
  90. package/dist/devtools/index copy.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { memoizeByStringifyArgs } from '@livestore/utils'
2
- import { Schema as EffectSchema } from '@livestore/utils/effect'
2
+ import { Effect, Schema as EffectSchema } from '@livestore/utils/effect'
3
3
  import * as otel from '@opentelemetry/api'
4
4
  import { SqliteAst, SqliteDsl } from 'effect-db-schema'
5
5
 
@@ -20,85 +20,104 @@ import { validateSchema } from './validate-mutation-defs.js'
20
20
 
21
21
  const getMemoizedTimestamp = memoizeByStringifyArgs(() => new Date().toISOString())
22
22
 
23
- export const makeSchemaManager = (db: InMemoryDatabase): SchemaManager => {
24
- migrateTable({
25
- db,
26
- otelContext: otel.context.active(),
27
- tableAst: schemaMutationsMetaTable.sqliteDef.ast,
28
- behaviour: 'create-if-not-exists',
23
+ export const makeSchemaManager = (db: InMemoryDatabase): Effect.Effect<SchemaManager> =>
24
+ Effect.gen(function* () {
25
+ yield* migrateTable({
26
+ db,
27
+ otelContext: otel.context.active(),
28
+ tableAst: schemaMutationsMetaTable.sqliteDef.ast,
29
+ behaviour: 'create-if-not-exists',
30
+ })
31
+
32
+ return {
33
+ getMutationDefInfos: () => {
34
+ const schemaMutationsMetaRows = dbSelect<SchemaMutationsMetaRow>(
35
+ db,
36
+ sql`SELECT * FROM ${SCHEMA_MUTATIONS_META_TABLE}`,
37
+ )
38
+
39
+ return schemaMutationsMetaRows
40
+ },
41
+ setMutationDefInfo: (info) => {
42
+ dbExecute(
43
+ db,
44
+ sql`INSERT OR REPLACE INTO ${SCHEMA_MUTATIONS_META_TABLE} (mutationName, schemaHash, updatedAt) VALUES ($mutationName, $schemaHash, $updatedAt)`,
45
+ {
46
+ mutationName: info.mutationName,
47
+ schemaHash: info.schemaHash,
48
+ updatedAt: new Date().toISOString(),
49
+ },
50
+ )
51
+ },
52
+ }
29
53
  })
30
54
 
31
- return {
32
- getMutationDefInfos: () => {
33
- const schemaMutationsMetaRows = dbSelect<SchemaMutationsMetaRow>(
34
- db,
35
- sql`SELECT * FROM ${SCHEMA_MUTATIONS_META_TABLE}`,
36
- )
37
-
38
- return schemaMutationsMetaRows
39
- },
40
- setMutationDefInfo: (info) => {
41
- dbExecute(
42
- db,
43
- sql`INSERT OR REPLACE INTO ${SCHEMA_MUTATIONS_META_TABLE} (mutationName, schemaHash, updatedAt) VALUES ($mutationName, $schemaHash, $updatedAt)`,
44
- {
45
- mutationName: info.mutationName,
46
- schemaHash: info.schemaHash,
47
- updatedAt: new Date().toISOString(),
48
- },
49
- )
50
- },
51
- }
52
- }
53
-
54
55
  // TODO more graceful DB migration (e.g. backup DB before destructive migrations)
55
56
  export const migrateDb = ({
56
57
  db,
57
58
  otelContext = otel.context.active(),
58
59
  schema,
60
+ onProgress,
59
61
  }: {
60
62
  db: InMemoryDatabase
61
63
  otelContext?: otel.Context
62
64
  schema: LiveStoreSchema
63
- }) => {
64
- migrateTable({
65
- db,
66
- otelContext,
67
- tableAst: schemaMetaTable.sqliteDef.ast,
68
- behaviour: 'create-if-not-exists',
69
- })
65
+ onProgress?: (opts: { done: number; total: number }) => Effect.Effect<void>
66
+ }) =>
67
+ Effect.gen(function* () {
68
+ yield* migrateTable({
69
+ db,
70
+ otelContext,
71
+ tableAst: schemaMetaTable.sqliteDef.ast,
72
+ behaviour: 'create-if-not-exists',
73
+ })
70
74
 
71
- validateSchema(schema, makeSchemaManager(db))
75
+ // TODO enforce that migrating tables isn't allowed once the store is running
72
76
 
73
- const schemaMetaRows = dbSelect<SchemaMetaRow>(db, sql`SELECT * FROM ${SCHEMA_META_TABLE}`)
77
+ const schemaManager = yield* makeSchemaManager(db)
78
+ validateSchema(schema, schemaManager)
74
79
 
75
- const dbSchemaHashByTable = Object.fromEntries(
76
- schemaMetaRows.map(({ tableName, schemaHash }) => [tableName, schemaHash]),
77
- )
80
+ const schemaMetaRows = dbSelect<SchemaMetaRow>(db, sql`SELECT * FROM ${SCHEMA_META_TABLE}`)
78
81
 
79
- const tableDefs = new Set([
80
- // NOTE it's important the `SCHEMA_META_TABLE` comes first since we're writing to it below
81
- ...systemTables,
82
- ...Array.from(schema.tables.values()).filter((_) => _.sqliteDef.name !== SCHEMA_META_TABLE),
83
- ])
82
+ const dbSchemaHashByTable = Object.fromEntries(
83
+ schemaMetaRows.map(({ tableName, schemaHash }) => [tableName, schemaHash]),
84
+ )
84
85
 
85
- for (const tableDef of tableDefs) {
86
- const tableAst = tableDef.sqliteDef.ast
87
- const tableName = tableAst.name
88
- const dbSchemaHash = dbSchemaHashByTable[tableName]
89
- const schemaHash = SqliteAst.hash(tableAst)
86
+ const tableDefs = new Set([
87
+ // NOTE it's important the `SCHEMA_META_TABLE` comes first since we're writing to it below
88
+ ...systemTables,
89
+ ...Array.from(schema.tables.values()).filter((_) => _.sqliteDef.name !== SCHEMA_META_TABLE),
90
+ ])
90
91
 
91
- const skipMigrations = import.meta.env.VITE_LIVESTORE_SKIP_MIGRATIONS !== undefined
92
+ const tablesToMigrate = new Set<{ tableAst: SqliteAst.Table; schemaHash: number }>()
92
93
 
93
- if (schemaHash !== dbSchemaHash && skipMigrations === false) {
94
- console.log(
95
- `Schema hash mismatch for table '${tableName}' (DB: ${dbSchemaHash}, expected: ${schemaHash}), migrating table...`,
96
- )
94
+ for (const tableDef of tableDefs) {
95
+ const tableAst = tableDef.sqliteDef.ast
96
+ const tableName = tableAst.name
97
+ const dbSchemaHash = dbSchemaHashByTable[tableName]
98
+ const schemaHash = SqliteAst.hash(tableAst)
99
+
100
+ if (schemaHash !== dbSchemaHash) {
101
+ tablesToMigrate.add({ tableAst, schemaHash })
97
102
 
98
- migrateTable({ db, tableAst, otelContext, schemaHash, behaviour: 'drop-and-recreate' })
103
+ console.log(
104
+ `Schema hash mismatch for table '${tableName}' (DB: ${dbSchemaHash}, expected: ${schemaHash}), migrating table...`,
105
+ )
106
+ }
99
107
  }
100
- }
101
- }
108
+
109
+ let processedTables = 0
110
+ const tablesCount = tablesToMigrate.size
111
+
112
+ for (const { tableAst, schemaHash } of tablesToMigrate) {
113
+ yield* migrateTable({ db, tableAst, otelContext, schemaHash, behaviour: 'create-if-not-exists' })
114
+
115
+ if (onProgress !== undefined) {
116
+ processedTables++
117
+ yield* onProgress({ done: processedTables, total: tablesCount })
118
+ }
119
+ }
120
+ })
102
121
 
103
122
  export const migrateTable = ({
104
123
  db,
@@ -114,36 +133,37 @@ export const migrateTable = ({
114
133
  schemaHash?: number
115
134
  behaviour: 'drop-and-recreate' | 'create-if-not-exists'
116
135
  skipMetaTable?: boolean
117
- }) => {
118
- console.log(`Migrating table '${tableAst.name}'...`)
119
- const tableName = tableAst.name
120
- const columnSpec = makeColumnSpec(tableAst)
121
-
122
- if (behaviour === 'drop-and-recreate') {
123
- // TODO need to possibly handle cascading deletes due to foreign keys
124
- dbExecute(db, sql`drop table if exists ${tableName}`)
125
- dbExecute(db, sql`create table if not exists ${tableName} (${columnSpec}) strict`)
126
- } else if (behaviour === 'create-if-not-exists') {
127
- dbExecute(db, sql`create table if not exists ${tableName} (${columnSpec}) strict`)
128
- }
136
+ }) =>
137
+ Effect.gen(function* () {
138
+ console.log(`Migrating table '${tableAst.name}'...`)
139
+ const tableName = tableAst.name
140
+ const columnSpec = makeColumnSpec(tableAst)
141
+
142
+ if (behaviour === 'drop-and-recreate') {
143
+ // TODO need to possibly handle cascading deletes due to foreign keys
144
+ dbExecute(db, sql`drop table if exists ${tableName}`)
145
+ dbExecute(db, sql`create table if not exists ${tableName} (${columnSpec}) strict`)
146
+ } else if (behaviour === 'create-if-not-exists') {
147
+ dbExecute(db, sql`create table if not exists ${tableName} (${columnSpec}) strict`)
148
+ }
129
149
 
130
- for (const index of tableAst.indexes) {
131
- dbExecute(db, createIndexFromDefinition(tableName, index))
132
- }
150
+ for (const index of tableAst.indexes) {
151
+ dbExecute(db, createIndexFromDefinition(tableName, index))
152
+ }
133
153
 
134
- if (skipMetaTable !== true) {
135
- const updatedAt = getMemoizedTimestamp()
154
+ if (skipMetaTable !== true) {
155
+ const updatedAt = getMemoizedTimestamp()
136
156
 
137
- dbExecute(
138
- db,
139
- sql`
157
+ dbExecute(
158
+ db,
159
+ sql`
140
160
  INSERT INTO ${SCHEMA_META_TABLE} (tableName, schemaHash, updatedAt) VALUES ($tableName, $schemaHash, $updatedAt)
141
161
  ON CONFLICT (tableName) DO UPDATE SET schemaHash = $schemaHash, updatedAt = $updatedAt;
142
162
  `,
143
- { tableName, schemaHash, updatedAt },
144
- )
145
- }
146
- }
163
+ { tableName, schemaHash, updatedAt },
164
+ )
165
+ }
166
+ }).pipe(Effect.withSpan('@livestore/common:migrateTable', { attributes: { tableName: tableAst.name } }))
147
167
 
148
168
  const createIndexFromDefinition = (tableName: string, index: SqliteAst.Index) => {
149
169
  const uniqueStr = index.unique ? 'UNIQUE' : ''
package/src/util.ts CHANGED
@@ -12,7 +12,7 @@ export const SqlValueSchema = Schema.Union(Schema.String, Schema.Number, Schema.
12
12
 
13
13
  export const PreparedBindValues = Schema.Union(
14
14
  Schema.Array(SqlValueSchema),
15
- Schema.Record(Schema.String, SqlValueSchema),
15
+ Schema.Record({ key: Schema.String, value: SqlValueSchema }),
16
16
  ).pipe(Schema.brand('PreparedBindValues'))
17
17
 
18
18
  export type PreparedBindValues = Brand.Branded<Bindable, 'PreparedBindValues'>
package/src/version.ts ADDED
@@ -0,0 +1,3 @@
1
+ import packageJson from '../package.json' with { type: 'json' }
2
+
3
+ export const liveStoreVersion = packageJson.version
@@ -1,214 +0,0 @@
1
- import { Schema } from '@livestore/utils/effect';
2
- declare const SnapshotReq_base: Schema.TaggedStruct<"LSD.SnapshotReq", {
3
- requestId: typeof Schema.String;
4
- channelId: typeof Schema.String;
5
- }>;
6
- export declare class SnapshotReq extends SnapshotReq_base {
7
- }
8
- declare const SnapshotRes_base: Schema.TaggedStruct<"LSD.SnapshotRes", {
9
- requestId: typeof Schema.String;
10
- snapshot: Schema.Schema<Uint8Array, readonly number[], never>;
11
- }>;
12
- export declare class SnapshotRes extends SnapshotRes_base {
13
- }
14
- declare const DebugInfoReq_base: Schema.TaggedStruct<"LSD.DebugInfoReq", {
15
- requestId: typeof Schema.String;
16
- channelId: typeof Schema.String;
17
- }>;
18
- export declare class DebugInfoReq extends DebugInfoReq_base {
19
- }
20
- declare const DebugInfoRes_base: Schema.TaggedStruct<"LSD.DebugInfoRes", {
21
- requestId: typeof Schema.String;
22
- debugInfo: Schema.Struct<{
23
- slowQueries: Schema.transform<Schema.Struct<{
24
- size: typeof Schema.Number;
25
- items: Schema.Array$<Schema.Schema<{
26
- readonly queryStr: string;
27
- readonly bindValues: ((readonly (string | number | Uint8Array | null)[] | {
28
- readonly [x: string]: string | number | Uint8Array | null;
29
- }) & import("effect/Brand").Brand<"PreparedBindValues">) | undefined;
30
- readonly durationMs: number;
31
- readonly rowsCount: number | undefined;
32
- readonly queriedTables: ReadonlySet<string>;
33
- readonly startTimePerfNow: number;
34
- }, {
35
- readonly queryStr: string;
36
- readonly bindValues: readonly (string | number | readonly number[] | null)[] | {
37
- readonly [x: string]: string | number | readonly number[] | null;
38
- } | undefined;
39
- readonly durationMs: number;
40
- readonly rowsCount: number | undefined;
41
- readonly queriedTables: readonly string[];
42
- readonly startTimePerfNow: number;
43
- }, never>>;
44
- }>, Schema.Schema<import("../bounded-collections.js").BoundArray<{
45
- readonly queryStr: string;
46
- readonly bindValues: ((readonly (string | number | Uint8Array | null)[] | {
47
- readonly [x: string]: string | number | Uint8Array | null;
48
- }) & import("effect/Brand").Brand<"PreparedBindValues">) | undefined;
49
- readonly durationMs: number;
50
- readonly rowsCount: number | undefined;
51
- readonly queriedTables: ReadonlySet<string>;
52
- readonly startTimePerfNow: number;
53
- }>, import("../bounded-collections.js").BoundArray<{
54
- readonly queryStr: string;
55
- readonly bindValues: ((readonly (string | number | Uint8Array | null)[] | {
56
- readonly [x: string]: string | number | Uint8Array | null;
57
- }) & import("effect/Brand").Brand<"PreparedBindValues">) | undefined;
58
- readonly durationMs: number;
59
- readonly rowsCount: number | undefined;
60
- readonly queriedTables: ReadonlySet<string>;
61
- readonly startTimePerfNow: number;
62
- }>, never>>;
63
- queryFrameDuration: typeof Schema.Number;
64
- queryFrameCount: typeof Schema.Number;
65
- events: Schema.transform<Schema.Struct<{
66
- size: typeof Schema.Number;
67
- items: Schema.Array$<Schema.Schema<readonly [string, any], readonly [string, any], never>>;
68
- }>, Schema.Schema<import("../bounded-collections.js").BoundArray<readonly [string, any]>, import("../bounded-collections.js").BoundArray<readonly [string, any]>, never>>;
69
- }>;
70
- }>;
71
- export declare class DebugInfoRes extends DebugInfoRes_base {
72
- }
73
- declare const DebugInfoResetReq_base: Schema.TaggedStruct<"LSD.DebugInfoResetReq", {
74
- requestId: typeof Schema.String;
75
- channelId: typeof Schema.String;
76
- }>;
77
- export declare class DebugInfoResetReq extends DebugInfoResetReq_base {
78
- }
79
- declare const DebugInfoResetRes_base: Schema.TaggedStruct<"LSD.DebugInfoResetRes", {
80
- requestId: typeof Schema.String;
81
- }>;
82
- export declare class DebugInfoResetRes extends DebugInfoResetRes_base {
83
- }
84
- declare const DebugInfoRerunQueryReq_base: Schema.TaggedStruct<"LSD.DebugInfoRerunQueryReq", {
85
- requestId: typeof Schema.String;
86
- channelId: typeof Schema.String;
87
- queryStr: typeof Schema.String;
88
- bindValues: Schema.UndefinedOr<Schema.brand<Schema.Union<[Schema.Array$<Schema.Union<[typeof Schema.String, typeof Schema.Number, Schema.Schema<Uint8Array, readonly number[], never>, typeof Schema.Null]>>, Schema.Record$<typeof Schema.String, Schema.Union<[typeof Schema.String, typeof Schema.Number, Schema.Schema<Uint8Array, readonly number[], never>, typeof Schema.Null]>>]>, "PreparedBindValues">>;
89
- queriedTables: Schema.ReadonlySet$<typeof Schema.String>;
90
- }>;
91
- export declare class DebugInfoRerunQueryReq extends DebugInfoRerunQueryReq_base {
92
- }
93
- declare const DebugInfoRerunQueryRes_base: Schema.TaggedStruct<"LSD.DebugInfoRerunQueryRes", {
94
- requestId: typeof Schema.String;
95
- }>;
96
- export declare class DebugInfoRerunQueryRes extends DebugInfoRerunQueryRes_base {
97
- }
98
- declare const MutationBroadcast_base: Schema.TaggedStruct<"LSD.MutationBroadcast", {
99
- requestId: typeof Schema.String;
100
- mutationEventEncoded: Schema.Struct<{
101
- mutation: typeof Schema.String;
102
- args: typeof Schema.Any;
103
- id: typeof Schema.String;
104
- }>;
105
- persisted: typeof Schema.Boolean;
106
- }>;
107
- export declare class MutationBroadcast extends MutationBroadcast_base {
108
- }
109
- declare const MutationLogReq_base: Schema.TaggedStruct<"LSD.MutationLogReq", {
110
- requestId: typeof Schema.String;
111
- channelId: typeof Schema.String;
112
- }>;
113
- export declare class MutationLogReq extends MutationLogReq_base {
114
- }
115
- declare const MutationLogRes_base: Schema.TaggedStruct<"LSD.MutationLogRes", {
116
- requestId: typeof Schema.String;
117
- mutationLog: Schema.Schema<Uint8Array, readonly number[], never>;
118
- }>;
119
- export declare class MutationLogRes extends MutationLogRes_base {
120
- }
121
- declare const SignalsSubscribe_base: Schema.TaggedStruct<"LSD.SignalsSubscribe", {
122
- requestId: typeof Schema.String;
123
- channelId: typeof Schema.String;
124
- includeResults: typeof Schema.Boolean;
125
- }>;
126
- export declare class SignalsSubscribe extends SignalsSubscribe_base {
127
- }
128
- declare const SignalsUnsubscribe_base: Schema.TaggedStruct<"LSD.SignalsUnsubscribe", {
129
- requestId: typeof Schema.String;
130
- channelId: typeof Schema.String;
131
- }>;
132
- export declare class SignalsUnsubscribe extends SignalsUnsubscribe_base {
133
- }
134
- declare const SignalsRes_base: Schema.TaggedStruct<"LSD.SignalsRes", {
135
- requestId: typeof Schema.String;
136
- signals: typeof Schema.Any;
137
- }>;
138
- export declare class SignalsRes extends SignalsRes_base {
139
- }
140
- declare const LiveQueriesSubscribe_base: Schema.TaggedStruct<"LSD.LiveQueriesSubscribe", {
141
- requestId: typeof Schema.String;
142
- channelId: typeof Schema.String;
143
- }>;
144
- export declare class LiveQueriesSubscribe extends LiveQueriesSubscribe_base {
145
- }
146
- declare const LiveQueriesUnsubscribe_base: Schema.TaggedStruct<"LSD.LiveQueriesUnsubscribe", {
147
- requestId: typeof Schema.String;
148
- channelId: typeof Schema.String;
149
- }>;
150
- export declare class LiveQueriesUnsubscribe extends LiveQueriesUnsubscribe_base {
151
- }
152
- declare const SerializedLiveQuery_base: Schema.Struct<{
153
- _tag: Schema.Literal<["js", "sql", "graphql"]>;
154
- id: typeof Schema.Number;
155
- label: typeof Schema.String;
156
- runs: typeof Schema.Number;
157
- executionTimes: Schema.Array$<typeof Schema.Number>;
158
- lastestResult: typeof Schema.Any;
159
- activeSubscriptions: Schema.Array$<Schema.Struct<{
160
- frames: Schema.Array$<Schema.Struct<{
161
- name: typeof Schema.String;
162
- filePath: typeof Schema.String;
163
- }>>;
164
- }>>;
165
- }>;
166
- export declare class SerializedLiveQuery extends SerializedLiveQuery_base {
167
- }
168
- declare const LiveQueriesRes_base: Schema.TaggedStruct<"LSD.LiveQueriesRes", {
169
- requestId: typeof Schema.String;
170
- liveQueries: Schema.Array$<typeof SerializedLiveQuery>;
171
- }>;
172
- export declare class LiveQueriesRes extends LiveQueriesRes_base {
173
- }
174
- declare const ResetAllDataReq_base: Schema.TaggedStruct<"LSD.ResetAllDataReq", {
175
- requestId: typeof Schema.String;
176
- channelId: typeof Schema.String;
177
- mode: Schema.Literal<["all-data", "only-app-db"]>;
178
- }>;
179
- export declare class ResetAllDataReq extends ResetAllDataReq_base {
180
- }
181
- declare const ResetAllDataRes_base: Schema.TaggedStruct<"LSD.ResetAllDataRes", {
182
- requestId: typeof Schema.String;
183
- }>;
184
- export declare class ResetAllDataRes extends ResetAllDataRes_base {
185
- }
186
- declare const DevtoolsReadyBroadcast_base: Schema.TaggedStruct<"LSD.DevtoolsReadyBroadcast", {}>;
187
- export declare class DevtoolsReadyBroadcast extends DevtoolsReadyBroadcast_base {
188
- }
189
- declare const AppHostReadyBroadcast_base: Schema.TaggedStruct<"LSD.AppHostReadyBroadcast", {
190
- channelId: typeof Schema.String;
191
- }>;
192
- export declare class AppHostReadyBroadcast extends AppHostReadyBroadcast_base {
193
- }
194
- declare const Disconnect_base: Schema.TaggedStruct<"LSD.Disconnect", {
195
- requestId: typeof Schema.String;
196
- channelId: typeof Schema.String;
197
- }>;
198
- export declare class Disconnect extends Disconnect_base {
199
- }
200
- declare const SchemaChanged_base: Schema.TaggedStruct<"LSD.SchemaChanged", {
201
- requestId: typeof Schema.String;
202
- }>;
203
- export declare class SchemaChanged extends SchemaChanged_base {
204
- }
205
- export declare const MessageToAppHost: Schema.Union<[typeof SnapshotReq, typeof MutationLogReq, typeof DebugInfoReq, typeof DebugInfoResetReq, typeof DebugInfoRerunQueryReq, typeof SignalsSubscribe, typeof SignalsUnsubscribe, typeof LiveQueriesSubscribe, typeof LiveQueriesUnsubscribe, typeof ResetAllDataReq, typeof DevtoolsReadyBroadcast, typeof Disconnect]>;
206
- export type MessageToAppHost = typeof MessageToAppHost.Type;
207
- export declare const MessageFromAppHost: Schema.Union<[typeof SnapshotRes, typeof MutationLogRes, typeof DebugInfoRes, typeof DebugInfoResetRes, typeof DebugInfoRerunQueryRes, typeof SignalsRes, typeof LiveQueriesRes, typeof ResetAllDataRes, typeof Disconnect, typeof SchemaChanged, typeof MutationBroadcast, typeof AppHostReadyBroadcast]>;
208
- export type MessageFromAppHost = typeof MessageFromAppHost.Type;
209
- export declare const makeBroadcastChannels: () => {
210
- fromAppHost: BroadcastChannel;
211
- toAppHost: BroadcastChannel;
212
- };
213
- export {};
214
- //# sourceMappingURL=index%20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qBAAsB,SAAQ,0BAEzC;CAAG;;;;;AAEL,qBAAa,UAAW,SAAQ,eAG9B;CAAG;;;;AAEL,qBAAa,aAAc,SAAQ,kBAEjC;CAAG;AAEL,eAAO,MAAM,gBAAgB,mUAa5B,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG,OAAO,gBAAgB,CAAC,IAAI,CAAA;AAE3D,eAAO,MAAM,kBAAkB,4SAa9B,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG,OAAO,kBAAkB,CAAC,IAAI,CAAA;AAG/D,eAAO,MAAM,qBAAqB;;;CAGhC,CAAA"}
@@ -1,137 +0,0 @@
1
- import { Schema } from '@livestore/utils/effect';
2
- import { DebugInfo } from '../debug-info.js';
3
- import { mutationEventSchemaEncodedAny } from '../schema/mutations.js';
4
- import { PreparedBindValues } from '../util.js';
5
- const requestId = Schema.String;
6
- const channelId = Schema.String;
7
- export class SnapshotReq extends Schema.TaggedStruct('LSD.SnapshotReq', {
8
- requestId,
9
- channelId,
10
- }) {
11
- }
12
- export class SnapshotRes extends Schema.TaggedStruct('LSD.SnapshotRes', {
13
- requestId,
14
- snapshot: Schema.Uint8Array,
15
- }) {
16
- }
17
- export class DebugInfoReq extends Schema.TaggedStruct('LSD.DebugInfoReq', {
18
- requestId,
19
- channelId,
20
- }) {
21
- }
22
- export class DebugInfoRes extends Schema.TaggedStruct('LSD.DebugInfoRes', {
23
- requestId,
24
- debugInfo: DebugInfo,
25
- }) {
26
- }
27
- export class DebugInfoResetReq extends Schema.TaggedStruct('LSD.DebugInfoResetReq', {
28
- requestId,
29
- channelId,
30
- }) {
31
- }
32
- export class DebugInfoResetRes extends Schema.TaggedStruct('LSD.DebugInfoResetRes', {
33
- requestId,
34
- }) {
35
- }
36
- export class DebugInfoRerunQueryReq extends Schema.TaggedStruct('LSD.DebugInfoRerunQueryReq', {
37
- requestId,
38
- channelId,
39
- queryStr: Schema.String,
40
- bindValues: Schema.UndefinedOr(PreparedBindValues),
41
- queriedTables: Schema.ReadonlySet(Schema.String),
42
- }) {
43
- }
44
- export class DebugInfoRerunQueryRes extends Schema.TaggedStruct('LSD.DebugInfoRerunQueryRes', {
45
- requestId,
46
- }) {
47
- }
48
- export class MutationBroadcast extends Schema.TaggedStruct('LSD.MutationBroadcast', {
49
- requestId,
50
- mutationEventEncoded: mutationEventSchemaEncodedAny,
51
- persisted: Schema.Boolean,
52
- }) {
53
- }
54
- export class MutationLogReq extends Schema.TaggedStruct('LSD.MutationLogReq', {
55
- requestId,
56
- channelId,
57
- }) {
58
- }
59
- export class MutationLogRes extends Schema.TaggedStruct('LSD.MutationLogRes', {
60
- requestId,
61
- mutationLog: Schema.Uint8Array,
62
- }) {
63
- }
64
- export class SignalsSubscribe extends Schema.TaggedStruct('LSD.SignalsSubscribe', {
65
- requestId,
66
- channelId,
67
- includeResults: Schema.Boolean,
68
- }) {
69
- }
70
- export class SignalsUnsubscribe extends Schema.TaggedStruct('LSD.SignalsUnsubscribe', {
71
- requestId,
72
- channelId,
73
- }) {
74
- }
75
- export class SignalsRes extends Schema.TaggedStruct('LSD.SignalsRes', {
76
- requestId,
77
- signals: Schema.Any,
78
- }) {
79
- }
80
- export class LiveQueriesSubscribe extends Schema.TaggedStruct('LSD.LiveQueriesSubscribe', {
81
- requestId,
82
- channelId,
83
- }) {
84
- }
85
- export class LiveQueriesUnsubscribe extends Schema.TaggedStruct('LSD.LiveQueriesUnsubscribe', {
86
- requestId,
87
- channelId,
88
- }) {
89
- }
90
- export class SerializedLiveQuery extends Schema.Struct({
91
- _tag: Schema.Literal('js', 'sql', 'graphql'),
92
- id: Schema.Number,
93
- label: Schema.String,
94
- runs: Schema.Number,
95
- executionTimes: Schema.Array(Schema.Number),
96
- lastestResult: Schema.Any,
97
- activeSubscriptions: Schema.Array(Schema.Struct({ frames: Schema.Array(Schema.Struct({ name: Schema.String, filePath: Schema.String })) })),
98
- }) {
99
- }
100
- export class LiveQueriesRes extends Schema.TaggedStruct('LSD.LiveQueriesRes', {
101
- requestId,
102
- liveQueries: Schema.Array(SerializedLiveQuery),
103
- }) {
104
- }
105
- export class ResetAllDataReq extends Schema.TaggedStruct('LSD.ResetAllDataReq', {
106
- requestId,
107
- channelId,
108
- mode: Schema.Literal('all-data', 'only-app-db'),
109
- }) {
110
- }
111
- export class ResetAllDataRes extends Schema.TaggedStruct('LSD.ResetAllDataRes', {
112
- requestId,
113
- }) {
114
- }
115
- export class DevtoolsReadyBroadcast extends Schema.TaggedStruct('LSD.DevtoolsReadyBroadcast', {}) {
116
- }
117
- export class AppHostReadyBroadcast extends Schema.TaggedStruct('LSD.AppHostReadyBroadcast', {
118
- channelId,
119
- }) {
120
- }
121
- export class Disconnect extends Schema.TaggedStruct('LSD.Disconnect', {
122
- requestId,
123
- channelId,
124
- }) {
125
- }
126
- export class SchemaChanged extends Schema.TaggedStruct('LSD.SchemaChanged', {
127
- requestId,
128
- }) {
129
- }
130
- export const MessageToAppHost = Schema.Union(SnapshotReq, MutationLogReq, DebugInfoReq, DebugInfoResetReq, DebugInfoRerunQueryReq, SignalsSubscribe, SignalsUnsubscribe, LiveQueriesSubscribe, LiveQueriesUnsubscribe, ResetAllDataReq, DevtoolsReadyBroadcast, Disconnect);
131
- export const MessageFromAppHost = Schema.Union(SnapshotRes, MutationLogRes, DebugInfoRes, DebugInfoResetRes, DebugInfoRerunQueryRes, SignalsRes, LiveQueriesRes, ResetAllDataRes, Disconnect, SchemaChanged, MutationBroadcast, AppHostReadyBroadcast);
132
- // TODO make specific over app key
133
- export const makeBroadcastChannels = () => ({
134
- fromAppHost: new BroadcastChannel(`livestore-devtools-from-app-host`),
135
- toAppHost: new BroadcastChannel(`livestore-devtools-to-app-host`),
136
- });
137
- //# sourceMappingURL=index%20copy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index copy.js","sourceRoot":"","sources":["../../src/devtools/index copy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAGhD,OAAO,EAAE,SA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