@livestore/common 0.0.54-dev.5 → 0.0.55-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.
Files changed (94) 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 +81 -20
  5. package/dist/adapter-types.d.ts.map +1 -1
  6. package/dist/adapter-types.js +22 -1
  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 +4 -5
  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 +73 -57
  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 -8
  55. package/dist/schema-management/migrations.d.ts.map +1 -1
  56. package/dist/schema-management/migrations.js +24 -18
  57. package/dist/schema-management/migrations.js.map +1 -1
  58. package/dist/schema-management/validate-mutation-defs.d.ts +3 -1
  59. package/dist/schema-management/validate-mutation-defs.d.ts.map +1 -1
  60. package/dist/schema-management/validate-mutation-defs.js +7 -5
  61. package/dist/schema-management/validate-mutation-defs.js.map +1 -1
  62. package/dist/sql-queries/misc.d.ts.map +1 -1
  63. package/dist/sql-queries/sql-queries.d.ts.map +1 -1
  64. package/dist/sql-queries/sql-query-builder.d.ts +33 -33
  65. package/dist/sql-queries/sql-query-builder.d.ts.map +1 -1
  66. package/dist/sql-queries/types.d.ts.map +1 -1
  67. package/dist/sync/sync.d.ts +3 -3
  68. package/dist/util.d.ts +0 -1
  69. package/dist/util.d.ts.map +1 -1
  70. package/dist/util.js +1 -1
  71. package/dist/util.js.map +1 -1
  72. package/dist/version.d.ts +2 -0
  73. package/dist/version.d.ts.map +1 -0
  74. package/dist/version.js +3 -0
  75. package/dist/version.js.map +1 -0
  76. package/package.json +4 -8
  77. package/src/adapter-types.ts +69 -19
  78. package/src/bounded-collections.ts +1 -1
  79. package/src/debug-info.ts +6 -18
  80. package/src/devtools/devtools-messages.ts +146 -65
  81. package/src/devtools/devtools-window-message.ts +27 -0
  82. package/src/devtools/index.ts +1 -0
  83. package/src/index.ts +1 -0
  84. package/src/rehydrate-from-mutationlog.ts +102 -65
  85. package/src/schema/mutations.ts +8 -5
  86. package/src/schema/table-def.ts +0 -4
  87. package/src/schema-management/migrations.ts +102 -89
  88. package/src/schema-management/validate-mutation-defs.ts +22 -19
  89. package/src/util.ts +1 -1
  90. package/src/version.ts +3 -0
  91. package/dist/devtools/index copy.d.ts +0 -214
  92. package/dist/devtools/index copy.d.ts.map +0 -1
  93. package/dist/devtools/index copy.js +0 -137
  94. package/dist/devtools/index copy.js.map +0 -1
@@ -1,6 +1,5 @@
1
1
  import { memoizeByStringifyArgs } from '@livestore/utils'
2
- import { Schema as EffectSchema } from '@livestore/utils/effect'
3
- import * as otel from '@opentelemetry/api'
2
+ import { Effect, Schema as EffectSchema } from '@livestore/utils/effect'
4
3
  import { SqliteAst, SqliteDsl } from 'effect-db-schema'
5
4
 
6
5
  import type { InMemoryDatabase } from '../adapter-types.js'
@@ -20,130 +19,144 @@ import { validateSchema } from './validate-mutation-defs.js'
20
19
 
21
20
  const getMemoizedTimestamp = memoizeByStringifyArgs(() => new Date().toISOString())
22
21
 
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',
22
+ export const makeSchemaManager = (db: InMemoryDatabase): Effect.Effect<SchemaManager> =>
23
+ Effect.gen(function* () {
24
+ yield* migrateTable({
25
+ db,
26
+ tableAst: schemaMutationsMetaTable.sqliteDef.ast,
27
+ behaviour: 'create-if-not-exists',
28
+ })
29
+
30
+ return {
31
+ getMutationDefInfos: () => {
32
+ const schemaMutationsMetaRows = dbSelect<SchemaMutationsMetaRow>(
33
+ db,
34
+ sql`SELECT * FROM ${SCHEMA_MUTATIONS_META_TABLE}`,
35
+ )
36
+
37
+ return schemaMutationsMetaRows
38
+ },
39
+ setMutationDefInfo: (info) => {
40
+ dbExecute(
41
+ db,
42
+ sql`INSERT OR REPLACE INTO ${SCHEMA_MUTATIONS_META_TABLE} (mutationName, schemaHash, updatedAt) VALUES ($mutationName, $schemaHash, $updatedAt)`,
43
+ {
44
+ mutationName: info.mutationName,
45
+ schemaHash: info.schemaHash,
46
+ updatedAt: new Date().toISOString(),
47
+ },
48
+ )
49
+ },
50
+ }
29
51
  })
30
52
 
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
53
  // TODO more graceful DB migration (e.g. backup DB before destructive migrations)
55
54
  export const migrateDb = ({
56
55
  db,
57
- otelContext = otel.context.active(),
58
56
  schema,
57
+ onProgress,
59
58
  }: {
60
59
  db: InMemoryDatabase
61
- otelContext?: otel.Context
62
60
  schema: LiveStoreSchema
63
- }) => {
64
- migrateTable({
65
- db,
66
- otelContext,
67
- tableAst: schemaMetaTable.sqliteDef.ast,
68
- behaviour: 'create-if-not-exists',
69
- })
61
+ onProgress?: (opts: { done: number; total: number }) => Effect.Effect<void>
62
+ }) =>
63
+ Effect.gen(function* () {
64
+ yield* migrateTable({
65
+ db,
66
+ tableAst: schemaMetaTable.sqliteDef.ast,
67
+ behaviour: 'create-if-not-exists',
68
+ })
70
69
 
71
- validateSchema(schema, makeSchemaManager(db))
70
+ // TODO enforce that migrating tables isn't allowed once the store is running
72
71
 
73
- const schemaMetaRows = dbSelect<SchemaMetaRow>(db, sql`SELECT * FROM ${SCHEMA_META_TABLE}`)
72
+ const schemaManager = yield* makeSchemaManager(db)
73
+ yield* validateSchema(schema, schemaManager)
74
74
 
75
- const dbSchemaHashByTable = Object.fromEntries(
76
- schemaMetaRows.map(({ tableName, schemaHash }) => [tableName, schemaHash]),
77
- )
75
+ const schemaMetaRows = dbSelect<SchemaMetaRow>(db, sql`SELECT * FROM ${SCHEMA_META_TABLE}`)
78
76
 
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
- ])
77
+ const dbSchemaHashByTable = Object.fromEntries(
78
+ schemaMetaRows.map(({ tableName, schemaHash }) => [tableName, schemaHash]),
79
+ )
84
80
 
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)
81
+ const tableDefs = new Set([
82
+ // NOTE it's important the `SCHEMA_META_TABLE` comes first since we're writing to it below
83
+ ...systemTables,
84
+ ...Array.from(schema.tables.values()).filter((_) => _.sqliteDef.name !== SCHEMA_META_TABLE),
85
+ ])
90
86
 
91
- const skipMigrations = import.meta.env.VITE_LIVESTORE_SKIP_MIGRATIONS !== undefined
87
+ const tablesToMigrate = new Set<{ tableAst: SqliteAst.Table; schemaHash: number }>()
92
88
 
93
- if (schemaHash !== dbSchemaHash && skipMigrations === false) {
94
- console.log(
95
- `Schema hash mismatch for table '${tableName}' (DB: ${dbSchemaHash}, expected: ${schemaHash}), migrating table...`,
96
- )
89
+ for (const tableDef of tableDefs) {
90
+ const tableAst = tableDef.sqliteDef.ast
91
+ const tableName = tableAst.name
92
+ const dbSchemaHash = dbSchemaHashByTable[tableName]
93
+ const schemaHash = SqliteAst.hash(tableAst)
94
+
95
+ if (schemaHash !== dbSchemaHash) {
96
+ tablesToMigrate.add({ tableAst, schemaHash })
97
97
 
98
- migrateTable({ db, tableAst, otelContext, schemaHash, behaviour: 'drop-and-recreate' })
98
+ console.log(
99
+ `Schema hash mismatch for table '${tableName}' (DB: ${dbSchemaHash}, expected: ${schemaHash}), migrating table...`,
100
+ )
101
+ }
99
102
  }
100
- }
101
- }
103
+
104
+ let processedTables = 0
105
+ const tablesCount = tablesToMigrate.size
106
+
107
+ for (const { tableAst, schemaHash } of tablesToMigrate) {
108
+ yield* migrateTable({ db, tableAst, schemaHash, behaviour: 'create-if-not-exists' })
109
+
110
+ if (onProgress !== undefined) {
111
+ processedTables++
112
+ yield* onProgress({ done: processedTables, total: tablesCount })
113
+ }
114
+ }
115
+ })
102
116
 
103
117
  export const migrateTable = ({
104
118
  db,
105
119
  tableAst,
106
- // otelContext,
107
120
  schemaHash = SqliteAst.hash(tableAst),
108
121
  behaviour,
109
122
  skipMetaTable = false,
110
123
  }: {
111
124
  db: InMemoryDatabase
112
125
  tableAst: SqliteAst.Table
113
- otelContext?: otel.Context
114
126
  schemaHash?: number
115
127
  behaviour: 'drop-and-recreate' | 'create-if-not-exists'
116
128
  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
- }
129
+ }) =>
130
+ Effect.gen(function* () {
131
+ console.log(`Migrating table '${tableAst.name}'...`)
132
+ const tableName = tableAst.name
133
+ const columnSpec = makeColumnSpec(tableAst)
134
+
135
+ if (behaviour === 'drop-and-recreate') {
136
+ // TODO need to possibly handle cascading deletes due to foreign keys
137
+ dbExecute(db, sql`drop table if exists ${tableName}`)
138
+ dbExecute(db, sql`create table if not exists ${tableName} (${columnSpec}) strict`)
139
+ } else if (behaviour === 'create-if-not-exists') {
140
+ dbExecute(db, sql`create table if not exists ${tableName} (${columnSpec}) strict`)
141
+ }
129
142
 
130
- for (const index of tableAst.indexes) {
131
- dbExecute(db, createIndexFromDefinition(tableName, index))
132
- }
143
+ for (const index of tableAst.indexes) {
144
+ dbExecute(db, createIndexFromDefinition(tableName, index))
145
+ }
133
146
 
134
- if (skipMetaTable !== true) {
135
- const updatedAt = getMemoizedTimestamp()
147
+ if (skipMetaTable !== true) {
148
+ const updatedAt = getMemoizedTimestamp()
136
149
 
137
- dbExecute(
138
- db,
139
- sql`
150
+ dbExecute(
151
+ db,
152
+ sql`
140
153
  INSERT INTO ${SCHEMA_META_TABLE} (tableName, schemaHash, updatedAt) VALUES ($tableName, $schemaHash, $updatedAt)
141
154
  ON CONFLICT (tableName) DO UPDATE SET schemaHash = $schemaHash, updatedAt = $updatedAt;
142
155
  `,
143
- { tableName, schemaHash, updatedAt },
144
- )
145
- }
146
- }
156
+ { tableName, schemaHash, updatedAt },
157
+ )
158
+ }
159
+ }).pipe(Effect.withSpan('@livestore/common:migrateTable', { attributes: { tableName: tableAst.name } }))
147
160
 
148
161
  const createIndexFromDefinition = (tableName: string, index: SqliteAst.Index) => {
149
162
  const uniqueStr = index.unique ? 'UNIQUE' : ''
@@ -1,32 +1,35 @@
1
- import { shouldNeverHappen } from '@livestore/utils'
2
- import { Schema } from '@livestore/utils/effect'
1
+ import { Effect, Schema } from '@livestore/utils/effect'
3
2
 
3
+ import { UnexpectedError } from '../adapter-types.js'
4
4
  import type { LiveStoreSchema } from '../schema/index.js'
5
5
  import type { MutationDef } from '../schema/mutations.js'
6
6
  import type { MutationDefInfo, SchemaManager } from './common.js'
7
7
 
8
- export const validateSchema = (schema: LiveStoreSchema, schemaManager: SchemaManager) => {
9
- // Validate mutation definitions
10
- const registeredMutationDefInfos = schemaManager.getMutationDefInfos()
8
+ export const validateSchema = (schema: LiveStoreSchema, schemaManager: SchemaManager) =>
9
+ Effect.gen(function* () {
10
+ // Validate mutation definitions
11
+ const registeredMutationDefInfos = schemaManager.getMutationDefInfos()
11
12
 
12
- const missingMutationDefs = registeredMutationDefInfos.filter(
13
- (registeredMutationDefInfo) => !schema.mutations.has(registeredMutationDefInfo.mutationName),
14
- )
15
-
16
- if (missingMutationDefs.length > 0) {
17
- shouldNeverHappen(
18
- `Missing mutation definitions: ${missingMutationDefs.map((info) => info.mutationName).join(', ')}`,
13
+ const missingMutationDefs = registeredMutationDefInfos.filter(
14
+ (registeredMutationDefInfo) => !schema.mutations.has(registeredMutationDefInfo.mutationName),
19
15
  )
20
- }
21
16
 
22
- for (const [, mutationDef] of schema.mutations) {
23
- const registeredMutationDefInfo = registeredMutationDefInfos.find((info) => info.mutationName === mutationDef.name)
17
+ if (missingMutationDefs.length > 0) {
18
+ yield* new UnexpectedError({
19
+ cause: `Missing mutation definitions: ${missingMutationDefs.map((info) => info.mutationName).join(', ')}`,
20
+ })
21
+ }
24
22
 
25
- validateMutationDef(mutationDef, schemaManager, registeredMutationDefInfo)
26
- }
23
+ for (const [, mutationDef] of schema.mutations) {
24
+ const registeredMutationDefInfo = registeredMutationDefInfos.find(
25
+ (info) => info.mutationName === mutationDef.name,
26
+ )
27
27
 
28
- // Validate table schemas
29
- }
28
+ validateMutationDef(mutationDef, schemaManager, registeredMutationDefInfo)
29
+ }
30
+
31
+ // Validate table schemas
32
+ })
30
33
 
31
34
  export const validateMutationDef = (
32
35
  mutationDef: MutationDef.Any,
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%20copy.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index copy.d.ts","sourceRoot":"","sources":["../../src/devtools/index copy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;;;;;AAUhD,qBAAa,WAAY,SAAQ,gBAG/B;CAAG;;;;;AAEL,qBAAa,WAAY,SAAQ,gBAG/B;CAAG;;;;;AAEL,qBAAa,YAAa,SAAQ,iBAGhC;CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEL,qBAAa,YAAa,SAAQ,iBAGhC;CAAG;;;;;AAEL,qBAAa,iBAAkB,SAAQ,sBAGrC;CAAG;;;;AAEL,qBAAa,iBAAkB,SAAQ,sBAErC;CAAG;;;;;;;;AAEL,qBAAa,sBAAuB,SAAQ,2BAM1C;CAAG;;;;AAEL,qBAAa,sBAAuB,SAAQ,2BAE1C;CAAG;;;;;;;;;;AAEL,qBAAa,iBAAkB,SAAQ,sBAIrC;CAAG;;;;;AAEL,qBAAa,cAAe,SAAQ,mBAGlC;CAAG;;;;;AAEL,qBAAa,cAAe,SAAQ,mBAGlC;CAAG;;;;;;AAEL,qBAAa,gBAAiB,SAAQ,qBAIpC;CAAG;;;;;AAEL,qBAAa,kBAAmB,SAAQ,uBAGtC;CAAG;;;;;AAEL,qBAAa,UAAW,SAAQ,eAG9B;CAAG;;;;;AAEL,qBAAa,oBAAqB,SAAQ,yBAGxC;CAAG;;;;;AAEL,qBAAa,sBAAuB,SAAQ,2BAG1C;CAAG;;;;;;;;;;;;;;;AAEL,qBAAa,mBAAoB,SAAQ,wBAUvC;CAAG;;;;;AAEL,qBAAa,cAAe,SAAQ,mBAGlC;CAAG;;;;;;AAEL,qBAAa,eAAgB,SAAQ,oBAInC;CAAG;;;;AAEL,qBAAa,eAAgB,SAAQ,oBAEnC;CAAG;;AAEL,qBAAa,sBAAuB,SAAQ,2BAAqD;CAAG;;;;AAEpG,qBAAa,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