@livestore/cli 0.0.0-snapshot-75de2b24a1fb1df981b56b5d9ec7381ea351e95b → 0.0.0-snapshot-8ed820c4fc69291ddbf497c7639246e903f3a299

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@livestore/cli",
3
- "version": "0.0.0-snapshot-75de2b24a1fb1df981b56b5d9ec7381ea351e95b",
3
+ "version": "0.0.0-snapshot-8ed820c4fc69291ddbf497c7639246e903f3a299",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "exports": {
@@ -11,17 +11,17 @@
11
11
  },
12
12
  "dependencies": {
13
13
  "@effect/ai-openai": "0.32.0",
14
- "@livestore/adapter-node": "0.0.0-snapshot-75de2b24a1fb1df981b56b5d9ec7381ea351e95b",
15
- "@livestore/common": "0.0.0-snapshot-75de2b24a1fb1df981b56b5d9ec7381ea351e95b",
16
- "@livestore/peer-deps": "0.0.0-snapshot-75de2b24a1fb1df981b56b5d9ec7381ea351e95b",
17
- "@livestore/livestore": "0.0.0-snapshot-75de2b24a1fb1df981b56b5d9ec7381ea351e95b",
18
- "@livestore/sync-cf": "0.0.0-snapshot-75de2b24a1fb1df981b56b5d9ec7381ea351e95b",
19
- "@livestore/utils": "0.0.0-snapshot-75de2b24a1fb1df981b56b5d9ec7381ea351e95b"
14
+ "@livestore/common": "0.0.0-snapshot-8ed820c4fc69291ddbf497c7639246e903f3a299",
15
+ "@livestore/livestore": "0.0.0-snapshot-8ed820c4fc69291ddbf497c7639246e903f3a299",
16
+ "@livestore/adapter-node": "0.0.0-snapshot-8ed820c4fc69291ddbf497c7639246e903f3a299",
17
+ "@livestore/peer-deps": "0.0.0-snapshot-8ed820c4fc69291ddbf497c7639246e903f3a299",
18
+ "@livestore/sync-cf": "0.0.0-snapshot-8ed820c4fc69291ddbf497c7639246e903f3a299",
19
+ "@livestore/utils": "0.0.0-snapshot-8ed820c4fc69291ddbf497c7639246e903f3a299"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@types/node": "24.10.1",
23
23
  "typescript": "5.9.2",
24
- "@livestore/utils-dev": "0.0.0-snapshot-75de2b24a1fb1df981b56b5d9ec7381ea351e95b"
24
+ "@livestore/utils-dev": "0.0.0-snapshot-8ed820c4fc69291ddbf497c7639246e903f3a299"
25
25
  },
26
26
  "files": [
27
27
  "package.json",
package/src/cli.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  import { Cli } from '@livestore/utils/node'
2
- import { syncCommand } from './commands/import-export.ts'
3
2
  import { mcpCommand } from './commands/mcp.ts'
4
3
  import { createCommand } from './commands/new-project.ts'
5
4
 
6
5
  export const command = Cli.Command.make('livestore', {
7
6
  verbose: Cli.Options.boolean('verbose').pipe(Cli.Options.withDefault(false)),
8
- }).pipe(Cli.Command.withSubcommands([mcpCommand, createCommand, syncCommand]))
7
+ }).pipe(Cli.Command.withSubcommands([mcpCommand, createCommand]))
@@ -1,17 +1,12 @@
1
- import { Effect, FetchHttpClient, Layer } from '@livestore/utils/effect'
2
- import { PlatformNode } from '@livestore/utils/node'
1
+ import { Effect } from '@livestore/utils/effect'
3
2
  import { blogSchemaContent } from '../mcp-content/schemas/blog.ts'
4
3
  import { ecommerceSchemaContent } from '../mcp-content/schemas/ecommerce.ts'
5
4
  import { socialSchemaContent } from '../mcp-content/schemas/social.ts'
6
5
  import { todoSchemaContent } from '../mcp-content/schemas/todo.ts'
7
6
  import * as Runtime from '../mcp-runtime/runtime.ts'
8
- import * as SyncOps from '../sync-operations.ts'
9
7
  import { coachToolHandler } from './mcp-coach.ts'
10
8
  import { livestoreToolkit } from './mcp-tools-defs.ts'
11
9
 
12
- /** Layer providing FileSystem and HttpClient for sync operations */
13
- const SyncOpsLayer = Layer.mergeAll(PlatformNode.NodeFileSystem.layer, FetchHttpClient.layer)
14
-
15
10
  // Tool handlers using Tim Smart's pattern
16
11
  export const toolHandlers: any = livestoreToolkit.of({
17
12
  livestore_coach: coachToolHandler,
@@ -161,32 +156,4 @@ export const schema = Schema.create({
161
156
  livestore_instance_disconnect: Effect.fnUntraced(function* () {
162
157
  return yield* Runtime.disconnect
163
158
  }),
164
-
165
- // Sync export - pull all events from sync backend
166
- livestore_sync_export: Effect.fnUntraced(function* ({ storePath, storeId, clientId }) {
167
- const result = yield* SyncOps.pullEventsFromSyncBackend({
168
- storePath,
169
- storeId,
170
- clientId: clientId ?? 'mcp-export',
171
- }).pipe(Effect.scoped, Effect.provide(SyncOpsLayer), Effect.orDie)
172
-
173
- return {
174
- storeId: result.storeId,
175
- eventCount: result.eventCount,
176
- exportedAt: result.exportedAt,
177
- data: result.data,
178
- }
179
- }),
180
-
181
- // Sync import - push events to sync backend
182
- livestore_sync_import: Effect.fnUntraced(function* ({ storePath, storeId, clientId, data, force, dryRun }) {
183
- return yield* SyncOps.pushEventsToSyncBackend({
184
- storePath,
185
- storeId,
186
- clientId: clientId ?? 'mcp-import',
187
- data,
188
- force: force ?? false,
189
- dryRun: dryRun ?? false,
190
- }).pipe(Effect.scoped, Effect.provide(SyncOpsLayer), Effect.orDie)
191
- }),
192
159
  })
@@ -63,13 +63,13 @@ export const syncPayload = { authToken: process.env.LIVESTORE_SYNC_AUTH_TOKEN ??
63
63
 
64
64
  Connect parameters:
65
65
  {
66
- "storePath": "livestore-cli.config.ts",
66
+ "storePath": "<path-to-your-mcp-module>.ts",
67
67
  "storeId": "<store-id>"
68
68
  }
69
69
 
70
70
  Optional identifiers to group client state on the server:
71
71
  {
72
- "storePath": "livestore-cli.config.ts",
72
+ "storePath": "<path-to-your-mcp-module>.ts",
73
73
  "storeId": "<store-id>",
74
74
  "clientId": "<client-id>",
75
75
  "sessionId": "<session-id>"
@@ -226,92 +226,4 @@ Example success:
226
226
  parameters: {},
227
227
  success: Schema.TaggedStruct('disconnected', {}),
228
228
  }),
229
-
230
- Tool.make('livestore_sync_export', {
231
- description: `Export all events from a sync backend to JSON data.
232
-
233
- This tool connects directly to the sync backend (without creating a full LiveStore instance) and pulls all events. Useful for backup, migration, and debugging.
234
-
235
- Module contract (same as livestore_instance_connect):
236
- \`\`\`ts
237
- export { schema } from './src/livestore/schema.ts'
238
- export const syncBackend = makeWsSync({ url: process.env.LIVESTORE_SYNC_URL ?? 'ws://localhost:8787' })
239
- export const syncPayload = { authToken: process.env.LIVESTORE_SYNC_AUTH_TOKEN }
240
- \`\`\`
241
-
242
- Example parameters:
243
- {
244
- "storePath": "livestore-cli.config.ts",
245
- "storeId": "my-store"
246
- }
247
-
248
- Returns on success:
249
- {
250
- "storeId": "my-store",
251
- "eventCount": 127,
252
- "exportedAt": "2024-01-15T10:30:00.000Z",
253
- "data": { "version": 1, "storeId": "my-store", ... }
254
- }`,
255
- parameters: {
256
- storePath: Schema.String.annotations({
257
- description: 'Path to a module that exports schema and syncBackend',
258
- }),
259
- storeId: Schema.String.annotations({ description: 'Store identifier' }),
260
- clientId: Schema.optional(Schema.String.annotations({ description: 'Client identifier (default: mcp-export)' })),
261
- },
262
- success: Schema.Struct({
263
- storeId: Schema.String,
264
- eventCount: Schema.Number,
265
- exportedAt: Schema.String,
266
- data: Schema.JsonValue.annotations({ description: 'The export file data (can be saved or passed to import)' }),
267
- }),
268
- }).annotate(Tool.Readonly, true),
269
-
270
- Tool.make('livestore_sync_import', {
271
- description: `Import events from export data to a sync backend.
272
-
273
- This tool connects directly to the sync backend and pushes events. The sync backend must be empty.
274
-
275
- Example parameters:
276
- {
277
- "storePath": "livestore-cli.config.ts",
278
- "storeId": "my-store",
279
- "data": { "version": 1, "storeId": "my-store", "events": [...] }
280
- }
281
-
282
- With options:
283
- {
284
- "storePath": "livestore-cli.config.ts",
285
- "storeId": "my-store",
286
- "data": { ... },
287
- "force": true, // Import even if store ID doesn't match
288
- "dryRun": true // Validate without importing
289
- }
290
-
291
- Returns on success:
292
- {
293
- "storeId": "my-store",
294
- "eventCount": 127,
295
- "dryRun": false
296
- }`,
297
- parameters: {
298
- storePath: Schema.String.annotations({
299
- description: 'Path to a module that exports schema and syncBackend',
300
- }),
301
- storeId: Schema.String.annotations({ description: 'Store identifier' }),
302
- clientId: Schema.optional(Schema.String.annotations({ description: 'Client identifier (default: mcp-import)' })),
303
- data: Schema.JsonValue.annotations({
304
- description: 'The export data to import (from livestore_sync_export or a file)',
305
- }),
306
- force: Schema.optional(
307
- Schema.Boolean.annotations({ description: 'Force import even if store ID does not match' }),
308
- ),
309
- dryRun: Schema.optional(Schema.Boolean.annotations({ description: 'Validate without actually importing' })),
310
- },
311
- success: Schema.Struct({
312
- storeId: Schema.String,
313
- eventCount: Schema.Number,
314
- dryRun: Schema.Boolean,
315
- }),
316
- }).annotate(Tool.Destructive, true),
317
229
  )
@@ -1,34 +0,0 @@
1
- import type { UnknownError } from '@livestore/common';
2
- import { FileSystem, type HttpClient } from '@livestore/utils/effect';
3
- import { Cli } from '@livestore/utils/node';
4
- import * as SyncOps from '../sync-operations.ts';
5
- export declare const exportCommand: Cli.Command.Command<"export", FileSystem.FileSystem | HttpClient.HttpClient, SyncOps.ConnectionError | SyncOps.ExportError | UnknownError, {
6
- readonly store: string;
7
- readonly storeId: string;
8
- readonly clientId: string;
9
- readonly output: string;
10
- }>;
11
- export declare const importCommand: Cli.Command.Command<"import", FileSystem.FileSystem | HttpClient.HttpClient, SyncOps.ConnectionError | SyncOps.ImportError | UnknownError, {
12
- readonly store: string;
13
- readonly storeId: string;
14
- readonly clientId: string;
15
- readonly force: boolean;
16
- readonly dryRun: boolean;
17
- readonly input: string;
18
- }>;
19
- export declare const syncCommand: Cli.Command.Command<"sync", FileSystem.FileSystem | HttpClient.HttpClient, SyncOps.ConnectionError | SyncOps.ExportError | SyncOps.ImportError | UnknownError, {
20
- readonly subcommand: import("effect/Option").Option<{
21
- readonly store: string;
22
- readonly storeId: string;
23
- readonly clientId: string;
24
- readonly output: string;
25
- } | {
26
- readonly store: string;
27
- readonly storeId: string;
28
- readonly clientId: string;
29
- readonly force: boolean;
30
- readonly dryRun: boolean;
31
- readonly input: string;
32
- }>;
33
- }>;
34
- //# sourceMappingURL=import-export.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"import-export.d.ts","sourceRoot":"","sources":["../../src/commands/import-export.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,EAAmB,UAAU,EAAE,KAAK,UAAU,EAAc,MAAM,yBAAyB,CAAA;AAClG,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAC3C,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAA;AAiJhD,eAAO,MAAM,aAAa;;;;;EA6CzB,CAAA;AAED,eAAO,MAAM,aAAa;;;;;;;EA4DzB,CAAA;AAED,eAAO,MAAM,WAAW;;;;;;;;;;;;;;EAGvB,CAAA"}
@@ -1,123 +0,0 @@
1
- import path from 'node:path';
2
- import { Console, Effect, FileSystem } from '@livestore/utils/effect';
3
- import { Cli } from '@livestore/utils/node';
4
- import * as SyncOps from "../sync-operations.js";
5
- /**
6
- * Export events from the sync backend to a JSON file.
7
- */
8
- const exportEvents = ({ storePath, storeId, clientId, outputPath, }) => Effect.gen(function* () {
9
- yield* Console.log(`Connecting to sync backend...`);
10
- const result = yield* SyncOps.pullEventsFromSyncBackend({ storePath, storeId, clientId });
11
- yield* Console.log(`✓ Connected to sync backend`);
12
- yield* Console.log(`Pulled ${result.eventCount} events`);
13
- const fs = yield* FileSystem.FileSystem;
14
- const absOutputPath = path.isAbsolute(outputPath) ? outputPath : path.resolve(process.cwd(), outputPath);
15
- yield* fs.writeFileString(absOutputPath, JSON.stringify(result.data, null, 2)).pipe(Effect.mapError((cause) => new SyncOps.ExportError({
16
- cause,
17
- note: `Failed to write export file: ${cause}`,
18
- })));
19
- yield* Console.log(`Exported ${result.eventCount} events to ${absOutputPath}`);
20
- }).pipe(Effect.withSpan('cli:export'));
21
- /**
22
- * Import events from a JSON file to the sync backend.
23
- */
24
- const importEvents = ({ storePath, storeId, clientId, inputPath, force, dryRun, }) => Effect.gen(function* () {
25
- const fs = yield* FileSystem.FileSystem;
26
- const absInputPath = path.isAbsolute(inputPath) ? inputPath : path.resolve(process.cwd(), inputPath);
27
- const exists = yield* fs.exists(absInputPath).pipe(Effect.mapError((cause) => new SyncOps.ImportError({
28
- cause,
29
- note: `Failed to check file existence: ${cause}`,
30
- })));
31
- if (!exists) {
32
- return yield* new SyncOps.ImportError({
33
- cause: new Error(`File not found: ${absInputPath}`),
34
- note: `Import file does not exist at ${absInputPath}`,
35
- });
36
- }
37
- yield* Console.log(`Reading import file...`);
38
- const fileContent = yield* fs.readFileString(absInputPath).pipe(Effect.mapError((cause) => new SyncOps.ImportError({
39
- cause,
40
- note: `Failed to read import file: ${cause}`,
41
- })));
42
- const parsedContent = yield* Effect.try({
43
- try: () => JSON.parse(fileContent),
44
- catch: (error) => new SyncOps.ImportError({
45
- cause: new Error(`Failed to parse JSON: ${error instanceof Error ? error.message : String(error)}`),
46
- note: `Invalid JSON in import file: ${error instanceof Error ? error.message : String(error)}`,
47
- }),
48
- });
49
- /** Validate export file format before proceeding */
50
- const validation = yield* SyncOps.validateExportData({ data: parsedContent, targetStoreId: storeId });
51
- if (validation.storeIdMismatch) {
52
- if (!force) {
53
- return yield* new SyncOps.ImportError({
54
- cause: new Error(`Store ID mismatch: file has '${validation.sourceStoreId}', expected '${storeId}'`),
55
- note: `The export file was created for a different store. Use --force to import anyway.`,
56
- });
57
- }
58
- yield* Console.log(`Store ID mismatch: file has '${validation.sourceStoreId}', importing to '${storeId}' (--force)`);
59
- }
60
- yield* Console.log(`Found ${validation.eventCount} events in export file`);
61
- if (dryRun) {
62
- yield* Console.log(`Dry run - validating import file...`);
63
- yield* Console.log(`Dry run complete. ${validation.eventCount} events would be imported.`);
64
- return;
65
- }
66
- yield* Console.log(`Connecting to sync backend...`);
67
- const result = yield* SyncOps.pushEventsToSyncBackend({
68
- storePath,
69
- storeId,
70
- clientId,
71
- data: parsedContent,
72
- force,
73
- dryRun: false,
74
- });
75
- yield* Console.log(`✓ Connected to sync backend`);
76
- yield* Console.log(`Successfully imported ${result.eventCount} events`);
77
- }).pipe(Effect.withSpan('cli:import'));
78
- export const exportCommand = Cli.Command.make('export', {
79
- store: Cli.Options.text('store').pipe(Cli.Options.withAlias('s'), Cli.Options.withDescription('Path to the store module that exports schema and syncBackend')),
80
- storeId: Cli.Options.text('store-id').pipe(Cli.Options.withAlias('i'), Cli.Options.withDescription('Store identifier')),
81
- clientId: Cli.Options.text('client-id').pipe(Cli.Options.withDefault('cli-export'), Cli.Options.withDescription('Client identifier for the sync connection')),
82
- output: Cli.Args.text({ name: 'file' }).pipe(Cli.Args.withDescription('Output JSON file path')),
83
- }, Effect.fn(function* ({ store, storeId, clientId, output, }) {
84
- yield* Console.log(`Exporting events from LiveStore...`);
85
- yield* Console.log(` Store: ${store}`);
86
- yield* Console.log(` Store ID: ${storeId}`);
87
- yield* Console.log(` Output: ${output}`);
88
- yield* Console.log('');
89
- yield* exportEvents({
90
- storePath: store,
91
- storeId,
92
- clientId,
93
- outputPath: output,
94
- }).pipe(Effect.scoped);
95
- })).pipe(Cli.Command.withDescription('Export all events from the sync backend to a JSON file. Useful for backup and migration.'));
96
- export const importCommand = Cli.Command.make('import', {
97
- store: Cli.Options.text('store').pipe(Cli.Options.withAlias('s'), Cli.Options.withDescription('Path to the store module that exports schema and syncBackend')),
98
- storeId: Cli.Options.text('store-id').pipe(Cli.Options.withAlias('i'), Cli.Options.withDescription('Store identifier')),
99
- clientId: Cli.Options.text('client-id').pipe(Cli.Options.withDefault('cli-import'), Cli.Options.withDescription('Client identifier for the sync connection')),
100
- force: Cli.Options.boolean('force').pipe(Cli.Options.withAlias('f'), Cli.Options.withDefault(false), Cli.Options.withDescription('Force import even if store ID does not match')),
101
- dryRun: Cli.Options.boolean('dry-run').pipe(Cli.Options.withDefault(false), Cli.Options.withDescription('Validate the import file without actually importing')),
102
- input: Cli.Args.text({ name: 'file' }).pipe(Cli.Args.withDescription('Input JSON file to import')),
103
- }, Effect.fn(function* ({ store, storeId, clientId, force, dryRun, input, }) {
104
- yield* Console.log(`Importing events to LiveStore...`);
105
- yield* Console.log(` Store: ${store}`);
106
- yield* Console.log(` Store ID: ${storeId}`);
107
- yield* Console.log(` Input: ${input}`);
108
- if (force)
109
- yield* Console.log(` Force: enabled`);
110
- if (dryRun)
111
- yield* Console.log(` Dry run: enabled`);
112
- yield* Console.log('');
113
- yield* importEvents({
114
- storePath: store,
115
- storeId,
116
- clientId,
117
- inputPath: input,
118
- force,
119
- dryRun,
120
- }).pipe(Effect.scoped);
121
- })).pipe(Cli.Command.withDescription('Import events from a JSON file to the sync backend. The sync backend must be empty.'));
122
- export const syncCommand = Cli.Command.make('sync').pipe(Cli.Command.withSubcommands([exportCommand, importCommand]), Cli.Command.withDescription('Import and export events from the sync backend'));
123
- //# sourceMappingURL=import-export.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"import-export.js","sourceRoot":"","sources":["../../src/commands/import-export.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAA+B,MAAM,yBAAyB,CAAA;AAClG,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAC3C,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAA;AAEhD;;GAEG;AACH,MAAM,YAAY,GAAG,CAAC,EACpB,SAAS,EACT,OAAO,EACP,QAAQ,EACR,UAAU,GAMX,EAIC,EAAE,CACF,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,KAAK,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAA;IAEnD,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC,yBAAyB,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAA;IAEzF,KAAK,CAAC,CAAC,OAAO,CAAC,GA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AAC,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAA;IACrD,KAAK,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IAEtB,KAAK,CAAC,CAAC,YAAY,CAAC;QAClB,SAAS,EAAE,KAAK;QAChB,OAAO;QACP,QAAQ;QACR,SAAS,EAAE,KAAK;QAChB,KAAK;QACL,MAAM;KACP,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;AACxB,CAAC,CAAC,CACH,CAAC,IAAI,CACJ,GAAG,CAAC,OAAO,CAAC,eAAe,CAAC,qFAAqF,CAAC,CACnH,CAAA;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CACtD,GAAG,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC,EAC3D,GAAG,CAAC,OAAO,CAAC,eAAe,CAAC,gDAAgD,CAAC,CAC9E,CAAA"}
@@ -1,111 +0,0 @@
1
- import type { SyncBackend } from '@livestore/common';
2
- import { UnknownError } from '@livestore/common';
3
- import { Effect, FileSystem, type HttpClient, Schema, type Scope } from '@livestore/utils/effect';
4
- /**
5
- * Schema for the export file format.
6
- * Contains metadata about the export and an array of events in global encoded format.
7
- */
8
- export declare const ExportFileSchema: Schema.Struct<{
9
- /** Format version for future compatibility */
10
- version: Schema.Literal<[1]>;
11
- /** Store identifier */
12
- storeId: typeof Schema.String;
13
- /** ISO timestamp of when the export was created */
14
- exportedAt: typeof Schema.String;
15
- /** Total number of events in the export */
16
- eventCount: typeof Schema.Number;
17
- /** Array of events in global encoded format */
18
- events: Schema.Array$<Schema.Struct<{
19
- name: typeof Schema.String;
20
- args: typeof Schema.Any;
21
- seqNum: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
22
- parentSeqNum: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
23
- clientId: typeof Schema.String;
24
- sessionId: typeof Schema.String;
25
- }>>;
26
- }>;
27
- export type ExportFile = typeof ExportFileSchema.Type;
28
- declare const ConnectionError_base: Schema.TaggedErrorClass<ConnectionError, "ConnectionError", {
29
- readonly _tag: Schema.tag<"ConnectionError">;
30
- } & {
31
- cause: typeof Schema.Defect;
32
- note: typeof Schema.String;
33
- }>;
34
- export declare class ConnectionError extends ConnectionError_base {
35
- }
36
- declare const ExportError_base: Schema.TaggedErrorClass<ExportError, "ExportError", {
37
- readonly _tag: Schema.tag<"ExportError">;
38
- } & {
39
- cause: typeof Schema.Defect;
40
- note: typeof Schema.String;
41
- }>;
42
- export declare class ExportError extends ExportError_base {
43
- }
44
- declare const ImportError_base: Schema.TaggedErrorClass<ImportError, "ImportError", {
45
- readonly _tag: Schema.tag<"ImportError">;
46
- } & {
47
- cause: typeof Schema.Defect;
48
- note: typeof Schema.String;
49
- }>;
50
- export declare class ImportError extends ImportError_base {
51
- }
52
- /**
53
- * Creates a sync backend connection from a user module and verifies connectivity.
54
- * This is a simplified version of the MCP runtime that only creates the sync backend.
55
- */
56
- export declare const makeSyncBackend: ({ storePath, storeId, clientId, }: {
57
- storePath: string;
58
- storeId: string;
59
- clientId: string;
60
- }) => Effect.Effect<SyncBackend.SyncBackend, UnknownError | ConnectionError, FileSystem.FileSystem | HttpClient.HttpClient | Scope.Scope>;
61
- export interface ExportResult {
62
- storeId: string;
63
- eventCount: number;
64
- exportedAt: string;
65
- /** The export data as JSON string (for MCP) or written to file (for CLI) */
66
- data: ExportFile;
67
- }
68
- /**
69
- * Core export operation - pulls all events from sync backend.
70
- * Returns the export data structure without writing to file.
71
- */
72
- export declare const pullEventsFromSyncBackend: ({ storePath, storeId, clientId, }: {
73
- storePath: string;
74
- storeId: string;
75
- clientId: string;
76
- }) => Effect.Effect<ExportResult, ExportError | UnknownError | ConnectionError, FileSystem.FileSystem | HttpClient.HttpClient | Scope.Scope>;
77
- export interface ImportResult {
78
- storeId: string;
79
- eventCount: number;
80
- /** Whether this was a dry run */
81
- dryRun: boolean;
82
- }
83
- export interface ImportValidationResult {
84
- storeId: string;
85
- eventCount: number;
86
- sourceStoreId: string;
87
- storeIdMismatch: boolean;
88
- }
89
- /**
90
- * Validates an export file for import.
91
- * Returns validation info without actually importing.
92
- */
93
- export declare const validateExportData: ({ data, targetStoreId, }: {
94
- data: unknown;
95
- targetStoreId: string;
96
- }) => Effect.Effect<ImportValidationResult, ImportError>;
97
- /**
98
- * Core import operation - pushes events to sync backend.
99
- * Validates that the backend is empty before importing.
100
- */
101
- export declare const pushEventsToSyncBackend: ({ storePath, storeId, clientId, data, force, dryRun, }: {
102
- storePath: string;
103
- storeId: string;
104
- clientId: string;
105
- /** The export data to import (already parsed) */
106
- data: unknown;
107
- force: boolean;
108
- dryRun: boolean;
109
- }) => Effect.Effect<ImportResult, ImportError | UnknownError | ConnectionError, FileSystem.FileSystem | HttpClient.HttpClient | Scope.Scope>;
110
- export {};
111
- //# sourceMappingURL=sync-operations.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sync-operations.d.ts","sourceRoot":"","sources":["../src/sync-operations.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAGhD,OAAO,EAEL,MAAM,EACN,UAAU,EACV,KAAK,UAAU,EAIf,MAAM,EACN,KAAK,KAAK,EAEX,MAAM,yBAAyB,CAAA;AAKhC;;;GAGG;AACH,eAAO,MAAM,gBAAgB;IAC3B,8CAA8C;;IAE9C,uBAAuB;;IAEvB,mDAAmD;;IAEnD,2CAA2C;;IAE3C,+CAA+C;;;;;;;;;EAE/C,CAAA;AAEF,MAAM,MAAM,UAAU,GAAG,OAAO,gBAAgB,CAAC,IAAI,CAAA;;;;;;;AAErD,qBAAa,eAAgB,SAAQ,oBAGnC;CAAG;;;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