@livestore/cli 0.0.0-snapshot-b2da08eec7583e23c0679970016a84b93438039e → 0.0.0-snapshot-bc54ad4b4319f020f2f8d040e4fe96a766c4e49d

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 (50) hide show
  1. package/dist/__tests__/fixtures/mock-config.d.ts +56 -0
  2. package/dist/__tests__/fixtures/mock-config.d.ts.map +1 -0
  3. package/dist/__tests__/fixtures/mock-config.js +88 -0
  4. package/dist/__tests__/fixtures/mock-config.js.map +1 -0
  5. package/dist/__tests__/sync-operations.test.d.ts +2 -0
  6. package/dist/__tests__/sync-operations.test.d.ts.map +1 -0
  7. package/dist/__tests__/sync-operations.test.js +167 -0
  8. package/dist/__tests__/sync-operations.test.js.map +1 -0
  9. package/dist/cli.d.ts +15 -1
  10. package/dist/cli.d.ts.map +1 -1
  11. package/dist/cli.js +2 -1
  12. package/dist/cli.js.map +1 -1
  13. package/dist/commands/import-export.d.ts +34 -0
  14. package/dist/commands/import-export.d.ts.map +1 -0
  15. package/dist/commands/import-export.js +133 -0
  16. package/dist/commands/import-export.js.map +1 -0
  17. package/dist/commands/mcp-coach.d.ts +2 -2
  18. package/dist/commands/mcp-coach.d.ts.map +1 -1
  19. package/dist/commands/mcp-tool-handlers.d.ts +5 -1
  20. package/dist/commands/mcp-tool-handlers.d.ts.map +1 -1
  21. package/dist/commands/mcp-tool-handlers.js +42 -4
  22. package/dist/commands/mcp-tool-handlers.js.map +1 -1
  23. package/dist/commands/mcp-tools-defs.d.ts +31 -1
  24. package/dist/commands/mcp-tools-defs.d.ts.map +1 -1
  25. package/dist/commands/mcp-tools-defs.js +87 -5
  26. package/dist/commands/mcp-tools-defs.js.map +1 -1
  27. package/dist/commands/new-project.d.ts +1 -1
  28. package/dist/mcp-runtime/runtime.d.ts +4 -3
  29. package/dist/mcp-runtime/runtime.d.ts.map +1 -1
  30. package/dist/mcp-runtime/runtime.js +20 -53
  31. package/dist/mcp-runtime/runtime.js.map +1 -1
  32. package/dist/module-loader.d.ts +22 -0
  33. package/dist/module-loader.d.ts.map +1 -0
  34. package/dist/module-loader.js +75 -0
  35. package/dist/module-loader.js.map +1 -0
  36. package/dist/sync-operations.d.ts +121 -0
  37. package/dist/sync-operations.d.ts.map +1 -0
  38. package/dist/sync-operations.js +180 -0
  39. package/dist/sync-operations.js.map +1 -0
  40. package/dist/tsconfig.tsbuildinfo +1 -1
  41. package/package.json +15 -8
  42. package/src/__tests__/fixtures/mock-config.ts +104 -0
  43. package/src/__tests__/sync-operations.test.ts +230 -0
  44. package/src/cli.ts +2 -1
  45. package/src/commands/import-export.ts +278 -0
  46. package/src/commands/mcp-tool-handlers.ts +50 -5
  47. package/src/commands/mcp-tools-defs.ts +92 -4
  48. package/src/mcp-runtime/runtime.ts +32 -65
  49. package/src/module-loader.ts +93 -0
  50. package/src/sync-operations.ts +360 -0
@@ -0,0 +1,56 @@
1
+ import { State } from '@livestore/common/schema';
2
+ import type { MockSyncBackend } from '@livestore/common/sync';
3
+ import { EventFactory } from '@livestore/common/testing';
4
+ import { Effect, FileSystem, type Mailbox } from '@livestore/utils/effect';
5
+ export declare const events: {
6
+ itemAdded: State.SQLite.EventDef<"itemAdded", {
7
+ readonly id: string;
8
+ readonly title: string;
9
+ }, {
10
+ readonly id: string;
11
+ readonly title: string;
12
+ }>;
13
+ };
14
+ export declare const schema: import("@livestore/common/schema").FromInputSchema.DeriveSchema<{
15
+ state: import("@livestore/common/schema").InternalState;
16
+ events: {
17
+ itemAdded: State.SQLite.EventDef<"itemAdded", {
18
+ readonly id: string;
19
+ readonly title: string;
20
+ }, {
21
+ readonly id: string;
22
+ readonly title: string;
23
+ }>;
24
+ };
25
+ }>;
26
+ /**
27
+ * Creates a temporary config module (schema + mock backend) and cleans it up afterwards.
28
+ * Returns the module path plus handles to the backend and connection event mailbox, keeping lifecycle assertions local to each test.
29
+ */
30
+ export declare const useMockConfig: Effect.Effect<{
31
+ configPath: string;
32
+ mockBackend: MockSyncBackend;
33
+ connectionEvents: Mailbox.Mailbox<"connect" | "disconnect", never>;
34
+ }, Error | import("@effect/platform/Error").PlatformError, FileSystem.FileSystem | import("effect/Scope").Scope>;
35
+ export declare const makeEventFactory: () => {
36
+ itemAdded: {
37
+ next: (args: {
38
+ readonly id: string;
39
+ readonly title: string;
40
+ }) => {
41
+ readonly name: string;
42
+ readonly args: any;
43
+ readonly seqNum: any;
44
+ readonly parentSeqNum: any;
45
+ readonly clientId: string;
46
+ readonly sessionId: string;
47
+ };
48
+ advanceTo: (seq: number, parent?: EventFactory.SequenceValue) => void;
49
+ setParent: (parent: EventFactory.SequenceValue) => void;
50
+ current: () => {
51
+ seq: number;
52
+ parent: EventFactory.SequenceValue;
53
+ };
54
+ };
55
+ };
56
+ //# sourceMappingURL=mock-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mock-config.d.ts","sourceRoot":"","sources":["../../../src/__tests__/fixtures/mock-config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAsB,KAAK,EAAE,MAAM,0BAA0B,CAAA;AACpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,OAAO,EAAU,MAAM,yBAAyB,CAAA;AAYlF,eAAO,MAAM,MAAM;;;;;;;;CAKlB,CAAA;AAWD,eAAO,MAAM,MAAM;;;;;;;;;;;EAAgC,CAAA;AAiCnD;;;GAGG;AACH,eAAO,MAAM,aAAa;;;;gHA0BzB,CAAA;AAED,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;uCApDC,CAAC;;;;;;;CAyD3B,CAAA"}
@@ -0,0 +1,88 @@
1
+ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
2
+ if (typeof path === "string" && /^\.\.?\//.test(path)) {
3
+ return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
4
+ return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
5
+ });
6
+ }
7
+ return path;
8
+ };
9
+ import path from 'node:path';
10
+ import { fileURLToPath, pathToFileURL } from 'node:url';
11
+ import { Events, makeSchema, State } from '@livestore/common/schema';
12
+ import { EventFactory } from '@livestore/common/testing';
13
+ import { Effect, FileSystem, Schema } from '@livestore/utils/effect';
14
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
15
+ const items = State.SQLite.table({
16
+ name: 'items',
17
+ columns: {
18
+ id: State.SQLite.text({ primaryKey: true }),
19
+ title: State.SQLite.text({ default: '', nullable: false }),
20
+ },
21
+ });
22
+ export const events = {
23
+ itemAdded: Events.synced({
24
+ name: 'itemAdded',
25
+ schema: Schema.Struct({ id: Schema.String, title: Schema.String }),
26
+ }),
27
+ };
28
+ const materializers = State.SQLite.materializers(events, {
29
+ itemAdded: ({ id, title }) => items.insert({ id, title }),
30
+ });
31
+ const state = State.SQLite.makeState({
32
+ tables: { items },
33
+ materializers,
34
+ });
35
+ export const schema = makeSchema({ state, events });
36
+ const tmpDir = path.join(process.cwd(), 'tmp', 'cli-sync-tests');
37
+ const schemaModuleUrl = pathToFileURL(path.join(__dirname, 'mock-config.ts')).href;
38
+ /** Generates a per-test config module exporting schema, a mock backend, and connection event taps. */
39
+ const makeTempConfig = () => {
40
+ const moduleSource = `
41
+ import { schema } from ${JSON.stringify(schemaModuleUrl)}
42
+ import { makeMockSyncBackend } from '@livestore/common/sync'
43
+ import { Effect, Mailbox } from '@livestore/utils/effect'
44
+
45
+ export const mockBackend = await Effect.runPromise(Effect.scoped(makeMockSyncBackend({ startConnected: true })))
46
+ export const connectionEvents = await Effect.runPromise(Mailbox.make<'connect' | 'disconnect'>())
47
+
48
+ export { schema }
49
+
50
+ export const syncBackend = (_args) =>
51
+ mockBackend.makeSyncBackend.pipe(
52
+ Effect.tap(() => connectionEvents.offer('connect')),
53
+ Effect.map((backend) => {
54
+ const disconnect = backend.disconnect ?? Effect.void
55
+ return {
56
+ ...backend,
57
+ disconnect: disconnect.pipe(Effect.tap(() => connectionEvents.offer('disconnect'))),
58
+ }
59
+ }),
60
+ )
61
+ `;
62
+ return moduleSource;
63
+ };
64
+ /**
65
+ * Creates a temporary config module (schema + mock backend) and cleans it up afterwards.
66
+ * Returns the module path plus handles to the backend and connection event mailbox, keeping lifecycle assertions local to each test.
67
+ */
68
+ export const useMockConfig = Effect.acquireRelease(Effect.gen(function* () {
69
+ const fs = yield* FileSystem.FileSystem;
70
+ yield* fs.makeDirectory(tmpDir, { recursive: true });
71
+ const tempPath = path.join(tmpDir, `mock-config-${Date.now()}-${Math.random().toString(16).slice(2)}.ts`);
72
+ const moduleSource = makeTempConfig();
73
+ yield* fs.writeFileString(tempPath, moduleSource);
74
+ const mod = (yield* Effect.tryPromise({
75
+ try: () => import(__rewriteRelativeImportExtension(pathToFileURL(tempPath).href)),
76
+ catch: (cause) => (cause instanceof Error ? cause : new Error(String(cause))),
77
+ }));
78
+ return { configPath: tempPath, mockBackend: mod.mockBackend, connectionEvents: mod.connectionEvents };
79
+ }), ({ configPath }) => Effect.gen(function* () {
80
+ const fs = yield* FileSystem.FileSystem;
81
+ yield* fs.remove(configPath, { recursive: false }).pipe(Effect.catchAll(() => Effect.void));
82
+ }));
83
+ export const makeEventFactory = () => EventFactory.makeFactory(events)({
84
+ client: EventFactory.clientIdentity('cli-test-client'),
85
+ startSeq: 1,
86
+ initialParent: 'root',
87
+ });
88
+ //# sourceMappingURL=mock-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mock-config.js","sourceRoot":"","sources":["../../../src/__tests__/fixtures/mock-config.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,M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GAAG,EAAE,CAAC,MAAM,kCAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAC;QAC/C,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;KAC9E,CAAC,CAGD,CAAA;IAED,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,CAAC,WAAW,EAAE,gBAAgB,EAAE,GAAG,CAAC,gBAAgB,EAAE,CAAA;AACvG,CAAC,CAAC,EACF,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CACjB,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,UAAU,CAAC,UAAU,CAAA;IACvC,KAAK,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;AAC7F,CAAC,CAAC,CACL,CAAA;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,EAAE,CACnC,YAAY,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAC/B,MAAM,EAAE,YAAY,CAAC,cAAc,CAAC,iBAAiB,CAAC;IACtD,QAAQ,EAAE,CAAC;IACX,aAAa,EAAE,MAAM;CACtB,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=sync-operations.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync-operations.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/sync-operations.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,167 @@
1
+ import { Chunk, Effect, FetchHttpClient, Layer, Mailbox, Stream } from '@livestore/utils/effect';
2
+ import { PlatformNode } from '@livestore/utils/node';
3
+ import { Vitest } from '@livestore/utils-dev/node-vitest';
4
+ import { expect } from 'vitest';
5
+ import { pullEventsFromSyncBackend, pushEventsToSyncBackend } from "../sync-operations.js";
6
+ import { makeEventFactory, useMockConfig } from "./fixtures/mock-config.js";
7
+ const baseLayer = Layer.mergeAll(PlatformNode.NodeFileSystem.layer, FetchHttpClient.layer);
8
+ const withTestCtx = Vitest.makeWithTestCtx({ makeLayer: () => baseLayer });
9
+ /** Each test acquires its own temporary config module via useMockConfig, avoiding shared state. */
10
+ Vitest.describe('sync-operations', { timeout: 10_000 }, () => {
11
+ const storeId = 'test-store';
12
+ const clientId = 'test-client';
13
+ /** Collects the connect + disconnect lifecycle emitted by the mock sync backend. */
14
+ const expectConnectLifecycle = (mailbox) => Mailbox.toStream(mailbox).pipe(Stream.take(2), Stream.runCollect, Effect.map((chunk) => Chunk.toReadonlyArray(chunk)));
15
+ Vitest.scopedLive('exports events and releases the backend connection', (test) => Effect.gen(function* () {
16
+ const { mockBackend, connectionEvents, configPath } = yield* useMockConfig;
17
+ const factory = makeEventFactory();
18
+ const batch = [
19
+ factory.itemAdded.next({ id: 'e1', title: 'First' }),
20
+ factory.itemAdded.next({ id: 'e2', title: 'Second' }),
21
+ ];
22
+ yield* mockBackend.advance(...batch);
23
+ const result = yield* pullEventsFromSyncBackend({
24
+ configPath,
25
+ storeId,
26
+ clientId,
27
+ });
28
+ expect(result.eventCount).toBe(2);
29
+ expect(result.data.events).toHaveLength(2);
30
+ const lifecycle = yield* expectConnectLifecycle(connectionEvents);
31
+ expect(lifecycle).toEqual(['connect', 'disconnect']);
32
+ }).pipe(withTestCtx(test)));
33
+ Vitest.scopedLive('fails import when backend is not empty', (test) => Effect.gen(function* () {
34
+ const { mockBackend, connectionEvents, configPath } = yield* useMockConfig;
35
+ const factory = makeEventFactory();
36
+ yield* mockBackend.advance(factory.itemAdded.next({ id: 'existing', title: 'Present' }));
37
+ const importBatch = [
38
+ factory.itemAdded.next({ id: 'incoming-1', title: 'Incoming' }),
39
+ factory.itemAdded.next({ id: 'incoming-2', title: 'Incoming 2' }),
40
+ ];
41
+ const result = yield* pushEventsToSyncBackend({
42
+ configPath,
43
+ storeId,
44
+ clientId,
45
+ data: {
46
+ version: 1,
47
+ storeId,
48
+ exportedAt: new Date().toISOString(),
49
+ eventCount: importBatch.length,
50
+ events: importBatch,
51
+ },
52
+ force: false,
53
+ dryRun: false,
54
+ }).pipe(Effect.either);
55
+ expect(result._tag).toBe('Left');
56
+ if (result._tag === 'Left') {
57
+ expect(result.left._tag).toBe('ImportError');
58
+ }
59
+ const lifecycle = yield* expectConnectLifecycle(connectionEvents);
60
+ expect(lifecycle).toEqual(['connect', 'disconnect']);
61
+ }).pipe(withTestCtx(test)));
62
+ Vitest.scopedLive('supports dry-run import and releases backend', (test) => Effect.gen(function* () {
63
+ const { configPath, connectionEvents } = yield* useMockConfig;
64
+ const factory = makeEventFactory();
65
+ const importBatch = [factory.itemAdded.next({ id: 'dry-run', title: 'Simulated' })];
66
+ const result = yield* pushEventsToSyncBackend({
67
+ configPath,
68
+ storeId,
69
+ clientId,
70
+ data: {
71
+ version: 1,
72
+ storeId,
73
+ exportedAt: new Date().toISOString(),
74
+ eventCount: importBatch.length,
75
+ events: importBatch,
76
+ },
77
+ force: false,
78
+ dryRun: true,
79
+ });
80
+ expect(result.dryRun).toBe(true);
81
+ expect(result.eventCount).toBe(importBatch.length);
82
+ const lifecycle = yield* expectConnectLifecycle(connectionEvents);
83
+ expect(lifecycle).toEqual(['connect', 'disconnect']);
84
+ }).pipe(withTestCtx(test)));
85
+ Vitest.scopedLive('imports events into empty backend with progress and batching', (test) => Effect.gen(function* () {
86
+ const { mockBackend, configPath, connectionEvents } = yield* useMockConfig;
87
+ const factory = makeEventFactory();
88
+ const importBatch = Array.from({ length: 120 }, (_, idx) => factory.itemAdded.next({ id: `id-${idx + 1}`, title: `Item ${idx + 1}` }));
89
+ const progress = [];
90
+ const result = yield* pushEventsToSyncBackend({
91
+ configPath,
92
+ storeId,
93
+ clientId,
94
+ data: {
95
+ version: 1,
96
+ storeId,
97
+ exportedAt: new Date().toISOString(),
98
+ eventCount: importBatch.length,
99
+ events: importBatch,
100
+ },
101
+ force: false,
102
+ dryRun: false,
103
+ onProgress: (pushed, total) => Effect.sync(() => progress.push({ pushed, total })),
104
+ });
105
+ expect(result.dryRun).toBe(false);
106
+ expect(result.eventCount).toBe(importBatch.length);
107
+ expect(progress).toEqual([
108
+ { pushed: 100, total: 120 },
109
+ { pushed: 120, total: 120 },
110
+ ]);
111
+ const pushedEvents = yield* mockBackend.pushedEvents.pipe(Stream.take(importBatch.length), Stream.runCollect, Effect.map((chunk) => Chunk.toReadonlyArray(chunk)));
112
+ expect(pushedEvents.map((event) => event.seqNum)).toHaveLength(importBatch.length);
113
+ const lifecycle = yield* expectConnectLifecycle(connectionEvents);
114
+ expect(lifecycle).toEqual(['connect', 'disconnect']);
115
+ }).pipe(withTestCtx(test)));
116
+ Vitest.scopedLive('allows force import on store ID mismatch', (test) => Effect.gen(function* () {
117
+ const { mockBackend, configPath, connectionEvents } = yield* useMockConfig;
118
+ const factory = makeEventFactory();
119
+ const importBatch = [factory.itemAdded.next({ id: 'force-1', title: 'Force' })];
120
+ const result = yield* pushEventsToSyncBackend({
121
+ configPath,
122
+ storeId,
123
+ clientId,
124
+ data: {
125
+ version: 1,
126
+ storeId: 'different-store',
127
+ exportedAt: new Date().toISOString(),
128
+ eventCount: importBatch.length,
129
+ events: importBatch,
130
+ },
131
+ force: true,
132
+ dryRun: false,
133
+ });
134
+ expect(result.dryRun).toBe(false);
135
+ expect(result.eventCount).toBe(importBatch.length);
136
+ const pushedEvents = yield* mockBackend.pushedEvents.pipe(Stream.take(1), Stream.runCollect, Effect.map((chunk) => Chunk.toReadonlyArray(chunk)));
137
+ expect(pushedEvents).toHaveLength(1);
138
+ const lifecycle = yield* expectConnectLifecycle(connectionEvents);
139
+ expect(lifecycle).toEqual(['connect', 'disconnect']);
140
+ }).pipe(withTestCtx(test)));
141
+ Vitest.scopedLive('rejects store ID mismatch without force', (test) => Effect.gen(function* () {
142
+ const { configPath, connectionEvents } = yield* useMockConfig;
143
+ const factory = makeEventFactory();
144
+ const importBatch = [factory.itemAdded.next({ id: 'mismatch', title: 'Mismatch' })];
145
+ const result = yield* pushEventsToSyncBackend({
146
+ configPath,
147
+ storeId,
148
+ clientId,
149
+ data: {
150
+ version: 1,
151
+ storeId: 'other-store',
152
+ exportedAt: new Date().toISOString(),
153
+ eventCount: importBatch.length,
154
+ events: importBatch,
155
+ },
156
+ force: false,
157
+ dryRun: false,
158
+ }).pipe(Effect.either);
159
+ expect(result._tag).toBe('Left');
160
+ if (result._tag === 'Left') {
161
+ expect(result.left._tag).toBe('ImportError');
162
+ }
163
+ const lifecycle = yield* expectConnectLifecycle(connectionEvents);
164
+ expect(lifecycle).toEqual(['connect', 'disconnect']);
165
+ }).pipe(withTestCtx(test)));
166
+ });
167
+ //# sourceMappingURL=sync-operations.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync-operations.test.js","sourceRoot":"","sources":["../../src/__tests__/sync-operations.test.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAChG,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAA;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AAC1F,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAE3E,MAAM,SAAS,GAAG,KAAK,CAAC,QAAQ,CAAC,YAAY,CAAC,cAAc,CAAC,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AK;YACZ,MAAM,EAAE,KAAK;SACd,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;QAEtB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAChC,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YAC3B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;QAC9C,CAAC;QAED,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,sBAAsB,CAAC,gBAAgB,CAAC,CAAA;QACjE,MAAM,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC,CAAA;IACtD,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAC3B,CAAA;AACH,CAAC,CAAC,CAAA"}
package/dist/cli.d.ts CHANGED
@@ -1,7 +1,21 @@
1
1
  import { Cli } from '@livestore/utils/node';
2
- export declare const command: Cli.Command.Command<"livestore", import("@effect/platform/HttpClient").HttpClient | Cli.Prompt.Prompt.Environment | import("@effect/platform/CommandExecutor").CommandExecutor, Error | import("@effect/platform/HttpClientError").ResponseError | import("@effect/platform/Error").PlatformError, {
2
+ export declare const command: Cli.Command.Command<"livestore", import("@effect/platform/HttpClient").HttpClient | Cli.Prompt.Prompt.Environment | import("@effect/platform/CommandExecutor").CommandExecutor, Error | import("@effect/platform/Error").PlatformError | import("@effect/platform/HttpClientError").ResponseError, {
3
3
  readonly verbose: boolean;
4
4
  readonly subcommand: import("effect/Option").Option<{
5
+ readonly subcommand: import("effect/Option").Option<{
6
+ readonly config: string;
7
+ readonly storeId: string;
8
+ readonly clientId: string;
9
+ readonly output: string;
10
+ } | {
11
+ readonly config: string;
12
+ readonly storeId: string;
13
+ readonly clientId: string;
14
+ readonly force: boolean;
15
+ readonly dryRun: boolean;
16
+ readonly input: string;
17
+ }>;
18
+ } | {
5
19
  readonly subcommand: import("effect/Option").Option<{}>;
6
20
  } | {
7
21
  readonly example: import("effect/Option").Option<string>;
package/dist/cli.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAI3C,eAAO,MAAM,OAAO;;;;;;;;;EAE6C,CAAA"}
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAK3C,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;EAE0D,CAAA"}
package/dist/cli.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import { Cli } from '@livestore/utils/node';
2
+ import { syncCommand } from "./commands/import-export.js";
2
3
  import { mcpCommand } from "./commands/mcp.js";
3
4
  import { createCommand } from "./commands/new-project.js";
4
5
  export const command = Cli.Command.make('livestore', {
5
6
  verbose: Cli.Options.boolean('verbose').pipe(Cli.Options.withDefault(false)),
6
- }).pipe(Cli.Command.withSubcommands([mcpCommand, createCommand]));
7
+ }).pipe(Cli.Command.withSubcommands([mcpCommand, createCommand, syncCommand]));
7
8
  //# sourceMappingURL=cli.js.map
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAEzD,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE;IACnD,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;CAC7E,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC,CAAA"}
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAEzD,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE;IACnD,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;CAC7E,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,UAAU,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC,CAAC,CAAA"}
@@ -0,0 +1,34 @@
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, UnknownError | SyncOps.ConnectionError | SyncOps.ExportError, {
6
+ readonly config: 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, UnknownError | SyncOps.ConnectionError | SyncOps.ImportError, {
12
+ readonly config: 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, UnknownError | SyncOps.ConnectionError | SyncOps.ExportError | SyncOps.ImportError, {
20
+ readonly subcommand: import("effect/Option").Option<{
21
+ readonly config: string;
22
+ readonly storeId: string;
23
+ readonly clientId: string;
24
+ readonly output: string;
25
+ } | {
26
+ readonly config: 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
@@ -0,0 +1 @@
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;AAiKhD,eAAO,MAAM,aAAa;;;;;EA6CzB,CAAA;AAED,eAAO,MAAM,aAAa;;;;;;;EA4DzB,CAAA;AAED,eAAO,MAAM,WAAW;;;;;;;;;;;;;;EAGvB,CAAA"}
@@ -0,0 +1,133 @@
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
+ const LARGE_EVENT_WARNING_THRESHOLD = 100_000;
6
+ /**
7
+ * Export events from the sync backend to a JSON file.
8
+ */
9
+ const exportEvents = ({ configPath, storeId, clientId, outputPath, }) => Effect.gen(function* () {
10
+ yield* Console.log(`Connecting to sync backend...`);
11
+ const result = yield* SyncOps.pullEventsFromSyncBackend({ configPath, storeId, clientId });
12
+ yield* Console.log(`✓ Connected to sync backend: ${result.backendName}`);
13
+ yield* Console.log(`Pulled ${result.eventCount} events`);
14
+ if (result.eventCount > LARGE_EVENT_WARNING_THRESHOLD) {
15
+ yield* Console.log(`Warning: exporting ${result.eventCount} events may consume significant memory. Consider exporting on a machine with enough RAM.`);
16
+ }
17
+ const fs = yield* FileSystem.FileSystem;
18
+ const absOutputPath = path.isAbsolute(outputPath) ? outputPath : path.resolve(process.cwd(), outputPath);
19
+ yield* fs.writeFileString(absOutputPath, JSON.stringify(result.data, null, 2)).pipe(Effect.mapError((cause) => new SyncOps.ExportError({
20
+ cause,
21
+ note: `Failed to write export file: ${cause}`,
22
+ })));
23
+ yield* Console.log(`Exported ${result.eventCount} events to ${absOutputPath}`);
24
+ }).pipe(Effect.withSpan('cli:export'));
25
+ /**
26
+ * Import events from a JSON file to the sync backend.
27
+ */
28
+ const importEvents = ({ configPath, storeId, clientId, inputPath, force, dryRun, }) => Effect.gen(function* () {
29
+ const fs = yield* FileSystem.FileSystem;
30
+ const absInputPath = path.isAbsolute(inputPath) ? inputPath : path.resolve(process.cwd(), inputPath);
31
+ const exists = yield* fs.exists(absInputPath).pipe(Effect.mapError((cause) => new SyncOps.ImportError({
32
+ cause,
33
+ note: `Failed to check file existence: ${cause}`,
34
+ })));
35
+ if (!exists) {
36
+ return yield* new SyncOps.ImportError({
37
+ cause: new Error(`File not found: ${absInputPath}`),
38
+ note: `Import file does not exist at ${absInputPath}`,
39
+ });
40
+ }
41
+ yield* Console.log(`Reading import file...`);
42
+ const fileContent = yield* fs.readFileString(absInputPath).pipe(Effect.mapError((cause) => new SyncOps.ImportError({
43
+ cause,
44
+ note: `Failed to read import file: ${cause}`,
45
+ })));
46
+ const parsedContent = yield* Effect.try({
47
+ try: () => JSON.parse(fileContent),
48
+ catch: (error) => new SyncOps.ImportError({
49
+ cause: new Error(`Failed to parse JSON: ${error instanceof Error ? error.message : String(error)}`),
50
+ note: `Invalid JSON in import file: ${error instanceof Error ? error.message : String(error)}`,
51
+ }),
52
+ });
53
+ /** Validate export file format before proceeding */
54
+ const validation = yield* SyncOps.validateExportData({ data: parsedContent, targetStoreId: storeId });
55
+ if (validation.storeIdMismatch) {
56
+ if (!force) {
57
+ return yield* new SyncOps.ImportError({
58
+ cause: new Error(`Store ID mismatch: file has '${validation.sourceStoreId}', expected '${storeId}'`),
59
+ note: `The export file was created for a different store. Use --force to import anyway.`,
60
+ });
61
+ }
62
+ yield* Console.log(`Store ID mismatch: file has '${validation.sourceStoreId}', importing to '${storeId}' (--force)`);
63
+ }
64
+ yield* Console.log(`Found ${validation.eventCount} events in export file`);
65
+ if (validation.eventCount > LARGE_EVENT_WARNING_THRESHOLD) {
66
+ yield* Console.log(`Warning: importing ${validation.eventCount} events may consume significant memory. Ensure the machine has enough RAM.`);
67
+ }
68
+ if (dryRun) {
69
+ yield* Console.log(`Dry run - validating import file...`);
70
+ yield* Console.log(`Dry run complete. ${validation.eventCount} events would be imported.`);
71
+ return;
72
+ }
73
+ yield* Console.log(`Checking for existing events...`);
74
+ yield* Console.log(`Connecting to sync backend...`);
75
+ yield* Console.log(`Pushing events to sync backend...`);
76
+ const result = yield* SyncOps.pushEventsToSyncBackend({
77
+ configPath,
78
+ storeId,
79
+ clientId,
80
+ data: parsedContent,
81
+ force,
82
+ dryRun: false,
83
+ onProgress: (pushed, total) => Console.log(` Pushed ${pushed}/${total} events`),
84
+ });
85
+ yield* Console.log(`✓ Connected to sync backend: ${result.backendName ?? 'unknown'}`);
86
+ yield* Console.log(`Successfully imported ${result.eventCount} events`);
87
+ }).pipe(Effect.withSpan('cli:import'));
88
+ export const exportCommand = Cli.Command.make('export', {
89
+ config: Cli.Options.text('config').pipe(Cli.Options.withAlias('c'), Cli.Options.withDescription('Path to the config module that exports schema and syncBackend')),
90
+ storeId: Cli.Options.text('store-id').pipe(Cli.Options.withAlias('i'), Cli.Options.withDescription('Store identifier')),
91
+ clientId: Cli.Options.text('client-id').pipe(Cli.Options.withDefault('cli-export'), Cli.Options.withDescription('Client identifier for the sync connection')),
92
+ output: Cli.Args.text({ name: 'file' }).pipe(Cli.Args.withDescription('Output JSON file path')),
93
+ }, Effect.fn(function* ({ config, storeId, clientId, output, }) {
94
+ yield* Console.log(`Exporting events from LiveStore...`);
95
+ yield* Console.log(` Config: ${config}`);
96
+ yield* Console.log(` Store ID: ${storeId}`);
97
+ yield* Console.log(` Output: ${output}`);
98
+ yield* Console.log('');
99
+ yield* exportEvents({
100
+ configPath: config,
101
+ storeId,
102
+ clientId,
103
+ outputPath: output,
104
+ }).pipe(Effect.scoped);
105
+ })).pipe(Cli.Command.withDescription('Export all events from the sync backend to a JSON file. Useful for backup and migration.'));
106
+ export const importCommand = Cli.Command.make('import', {
107
+ config: Cli.Options.text('config').pipe(Cli.Options.withAlias('c'), Cli.Options.withDescription('Path to the config module that exports schema and syncBackend')),
108
+ storeId: Cli.Options.text('store-id').pipe(Cli.Options.withAlias('i'), Cli.Options.withDescription('Store identifier')),
109
+ clientId: Cli.Options.text('client-id').pipe(Cli.Options.withDefault('cli-import'), Cli.Options.withDescription('Client identifier for the sync connection')),
110
+ 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')),
111
+ dryRun: Cli.Options.boolean('dry-run').pipe(Cli.Options.withDefault(false), Cli.Options.withDescription('Validate the import file without actually importing')),
112
+ input: Cli.Args.text({ name: 'file' }).pipe(Cli.Args.withDescription('Input JSON file to import')),
113
+ }, Effect.fn(function* ({ config, storeId, clientId, force, dryRun, input, }) {
114
+ yield* Console.log(`Importing events to LiveStore...`);
115
+ yield* Console.log(` Config: ${config}`);
116
+ yield* Console.log(` Store ID: ${storeId}`);
117
+ yield* Console.log(` Input: ${input}`);
118
+ if (force)
119
+ yield* Console.log(` Force: enabled`);
120
+ if (dryRun)
121
+ yield* Console.log(` Dry run: enabled`);
122
+ yield* Console.log('');
123
+ yield* importEvents({
124
+ configPath: config,
125
+ storeId,
126
+ clientId,
127
+ inputPath: input,
128
+ force,
129
+ dryRun,
130
+ }).pipe(Effect.scoped);
131
+ })).pipe(Cli.Command.withDescription('Import events from a JSON file to the sync backend. The sync backend must be empty.'));
132
+ export const syncCommand = Cli.Command.make('sync').pipe(Cli.Command.withSubcommands([exportCommand, importCommand]), Cli.Command.withDescription('Import and export events from the sync backend'));
133
+ //# sourceMappingURL=import-export.js.map
@@ -0,0 +1 @@
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,MAAM,6BAA6B,GAAG,OAAO,CAAA;AAE7C;;GAEG;AACH,MAAM,YAAY,GAAG,CAAC,EACpB,UAAU,EACV,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,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAA;IAE1F,KAAK,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,gCAAgC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAA;IACxE,KAAK,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,MAAM,CAAC,UAAU,SAAS,CAAC,CAAA;IACxD,IAAI,MAAM,CAAC,UA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estore/utils/effect';
2
2
  export declare const coachTool: Tool.Tool<"livestore_coach", {
3
3
  readonly parameters: Schema.Struct<{
4
4
  code: Schema.SchemaClass<string, string, never>;
@@ -15,5 +15,5 @@ export declare const coachToolHandler: (args_0: any) => Effect.Effect<{
15
15
  feedback: string;
16
16
  score: number | undefined;
17
17
  suggestions: string[];
18
- }, AiError.AiError, never>;
18
+ }, AiError.AiError, LanguageModel.LanguageModel>;
19
19
  //# sourceMappingURL=mcp-coach.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-coach.d.ts","sourceRoot":"","sources":["../../src/commands/mcp-coach.ts"],"names":[],"mappings":"AACA,OAAO,EACL,OAAO,EAEP,MAAM,EAKN,MAAM,EACN,IAAI,EACL,MAAM,yBAAyB,CAAA;AAGhC,eAAO,MAAM,SAAS;;;;;;;;;;;SA+BpB,CAAA;AAWF,eAAO,MAAM,gBAAgB;;;;0BAyE5B,CAAA"}
1
+ {"version":3,"file":"mcp-coach.d.ts","sourceRoot":"","sources":["../../src/commands/mcp-coach.ts"],"names":[],"mappings":"AACA,OAAO,EACL,OAAO,EAEP,MAAM,EAEN,aAAa,EAGb,MAAM,EACN,IAAI,EACL,MAAM,yBAAyB,CAAA;AAGhC,eAAO,MAAM,SAAS;;;;;;;;;;;SA+BpB,CAAA;AAWF,eAAO,MAAM,gBAAgB;;;;gDAyE5B,CAAA"}
@@ -1,2 +1,6 @@
1
- export declare const toolHandlers: any;
1
+ import { type Toolkit } from '@livestore/utils/effect';
2
+ import { livestoreToolkit } from './mcp-tools-defs.ts';
3
+ type LivestoreToolHandlers = Toolkit.HandlersFrom<Toolkit.Tools<typeof livestoreToolkit>>;
4
+ export declare const toolHandlers: LivestoreToolHandlers;
5
+ export {};
2
6
  //# sourceMappingURL=mcp-tool-handlers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-tool-handlers.d.ts","sourceRoot":"","sources":["../../src/commands/mcp-tool-handlers.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,YAAY,EAAE,GAoJzB,CAAA"}
1
+ {"version":3,"file":"mcp-tool-handlers.d.ts","sourceRoot":"","sources":["../../src/commands/mcp-tool-handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,KAAK,OAAO,EAAE,MAAM,yBAAyB,CAAA;AAStF,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAKtD,KAAK,qBAAqB,GAAG,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC,CAAA;AAEzF,eAAO,MAAM,YAAY,EAAE,qBA2LzB,CAAA"}