@slorenzot/memento-core 0.7.0 → 2.0.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.
@@ -1,353 +0,0 @@
1
- export declare const sessions: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
2
- name: "sessions";
3
- schema: undefined;
4
- columns: {
5
- id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
6
- name: "id";
7
- tableName: "sessions";
8
- dataType: "number";
9
- columnType: "SQLiteInteger";
10
- data: number;
11
- driverParam: number;
12
- notNull: true;
13
- hasDefault: true;
14
- enumValues: undefined;
15
- baseColumn: never;
16
- }, object>;
17
- uuid: import("drizzle-orm/sqlite-core").SQLiteColumn<{
18
- name: "uuid";
19
- tableName: "sessions";
20
- dataType: "string";
21
- columnType: "SQLiteText";
22
- data: string;
23
- driverParam: string;
24
- notNull: true;
25
- hasDefault: false;
26
- enumValues: [string, ...string[]];
27
- baseColumn: never;
28
- }, object>;
29
- projectId: import("drizzle-orm/sqlite-core").SQLiteColumn<{
30
- name: "project_id";
31
- tableName: "sessions";
32
- dataType: "string";
33
- columnType: "SQLiteText";
34
- data: string;
35
- driverParam: string;
36
- notNull: true;
37
- hasDefault: false;
38
- enumValues: [string, ...string[]];
39
- baseColumn: never;
40
- }, object>;
41
- startedAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
42
- name: "started_at";
43
- tableName: "sessions";
44
- dataType: "number";
45
- columnType: "SQLiteInteger";
46
- data: number;
47
- driverParam: number;
48
- notNull: true;
49
- hasDefault: false;
50
- enumValues: undefined;
51
- baseColumn: never;
52
- }, object>;
53
- endedAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
54
- name: "ended_at";
55
- tableName: "sessions";
56
- dataType: "number";
57
- columnType: "SQLiteInteger";
58
- data: number;
59
- driverParam: number;
60
- notNull: false;
61
- hasDefault: false;
62
- enumValues: undefined;
63
- baseColumn: never;
64
- }, object>;
65
- metadata: import("drizzle-orm/sqlite-core").SQLiteColumn<{
66
- name: "metadata";
67
- tableName: "sessions";
68
- dataType: "string";
69
- columnType: "SQLiteText";
70
- data: string;
71
- driverParam: string;
72
- notNull: false;
73
- hasDefault: false;
74
- enumValues: [string, ...string[]];
75
- baseColumn: never;
76
- }, object>;
77
- };
78
- dialect: "sqlite";
79
- }>;
80
- export declare const observations: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
81
- name: "observations";
82
- schema: undefined;
83
- columns: {
84
- id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
85
- name: "id";
86
- tableName: "observations";
87
- dataType: "number";
88
- columnType: "SQLiteInteger";
89
- data: number;
90
- driverParam: number;
91
- notNull: true;
92
- hasDefault: true;
93
- enumValues: undefined;
94
- baseColumn: never;
95
- }, object>;
96
- uuid: import("drizzle-orm/sqlite-core").SQLiteColumn<{
97
- name: "uuid";
98
- tableName: "observations";
99
- dataType: "string";
100
- columnType: "SQLiteText";
101
- data: string;
102
- driverParam: string;
103
- notNull: true;
104
- hasDefault: false;
105
- enumValues: [string, ...string[]];
106
- baseColumn: never;
107
- }, object>;
108
- sessionId: import("drizzle-orm/sqlite-core").SQLiteColumn<{
109
- name: "session_id";
110
- tableName: "observations";
111
- dataType: "number";
112
- columnType: "SQLiteInteger";
113
- data: number;
114
- driverParam: number;
115
- notNull: true;
116
- hasDefault: false;
117
- enumValues: undefined;
118
- baseColumn: never;
119
- }, object>;
120
- title: import("drizzle-orm/sqlite-core").SQLiteColumn<{
121
- name: "title";
122
- tableName: "observations";
123
- dataType: "string";
124
- columnType: "SQLiteText";
125
- data: string;
126
- driverParam: string;
127
- notNull: true;
128
- hasDefault: false;
129
- enumValues: [string, ...string[]];
130
- baseColumn: never;
131
- }, object>;
132
- content: import("drizzle-orm/sqlite-core").SQLiteColumn<{
133
- name: "content";
134
- tableName: "observations";
135
- dataType: "string";
136
- columnType: "SQLiteText";
137
- data: string;
138
- driverParam: string;
139
- notNull: true;
140
- hasDefault: false;
141
- enumValues: [string, ...string[]];
142
- baseColumn: never;
143
- }, object>;
144
- type: import("drizzle-orm/sqlite-core").SQLiteColumn<{
145
- name: "type";
146
- tableName: "observations";
147
- dataType: "string";
148
- columnType: "SQLiteText";
149
- data: string;
150
- driverParam: string;
151
- notNull: true;
152
- hasDefault: false;
153
- enumValues: [string, ...string[]];
154
- baseColumn: never;
155
- }, object>;
156
- topicKey: import("drizzle-orm/sqlite-core").SQLiteColumn<{
157
- name: "topic_key";
158
- tableName: "observations";
159
- dataType: "string";
160
- columnType: "SQLiteText";
161
- data: string;
162
- driverParam: string;
163
- notNull: false;
164
- hasDefault: false;
165
- enumValues: [string, ...string[]];
166
- baseColumn: never;
167
- }, object>;
168
- projectId: import("drizzle-orm/sqlite-core").SQLiteColumn<{
169
- name: "project_id";
170
- tableName: "observations";
171
- dataType: "string";
172
- columnType: "SQLiteText";
173
- data: string;
174
- driverParam: string;
175
- notNull: true;
176
- hasDefault: false;
177
- enumValues: [string, ...string[]];
178
- baseColumn: never;
179
- }, object>;
180
- createdAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
181
- name: "created_at";
182
- tableName: "observations";
183
- dataType: "number";
184
- columnType: "SQLiteInteger";
185
- data: number;
186
- driverParam: number;
187
- notNull: true;
188
- hasDefault: false;
189
- enumValues: undefined;
190
- baseColumn: never;
191
- }, object>;
192
- metadata: import("drizzle-orm/sqlite-core").SQLiteColumn<{
193
- name: "metadata";
194
- tableName: "observations";
195
- dataType: "string";
196
- columnType: "SQLiteText";
197
- data: string;
198
- driverParam: string;
199
- notNull: false;
200
- hasDefault: false;
201
- enumValues: [string, ...string[]];
202
- baseColumn: never;
203
- }, object>;
204
- };
205
- dialect: "sqlite";
206
- }>;
207
- export declare const prompts: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
208
- name: "prompts";
209
- schema: undefined;
210
- columns: {
211
- id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
212
- name: "id";
213
- tableName: "prompts";
214
- dataType: "number";
215
- columnType: "SQLiteInteger";
216
- data: number;
217
- driverParam: number;
218
- notNull: true;
219
- hasDefault: true;
220
- enumValues: undefined;
221
- baseColumn: never;
222
- }, object>;
223
- uuid: import("drizzle-orm/sqlite-core").SQLiteColumn<{
224
- name: "uuid";
225
- tableName: "prompts";
226
- dataType: "string";
227
- columnType: "SQLiteText";
228
- data: string;
229
- driverParam: string;
230
- notNull: true;
231
- hasDefault: false;
232
- enumValues: [string, ...string[]];
233
- baseColumn: never;
234
- }, object>;
235
- sessionId: import("drizzle-orm/sqlite-core").SQLiteColumn<{
236
- name: "session_id";
237
- tableName: "prompts";
238
- dataType: "number";
239
- columnType: "SQLiteInteger";
240
- data: number;
241
- driverParam: number;
242
- notNull: true;
243
- hasDefault: false;
244
- enumValues: undefined;
245
- baseColumn: never;
246
- }, object>;
247
- content: import("drizzle-orm/sqlite-core").SQLiteColumn<{
248
- name: "content";
249
- tableName: "prompts";
250
- dataType: "string";
251
- columnType: "SQLiteText";
252
- data: string;
253
- driverParam: string;
254
- notNull: true;
255
- hasDefault: false;
256
- enumValues: [string, ...string[]];
257
- baseColumn: never;
258
- }, object>;
259
- projectId: import("drizzle-orm/sqlite-core").SQLiteColumn<{
260
- name: "project_id";
261
- tableName: "prompts";
262
- dataType: "string";
263
- columnType: "SQLiteText";
264
- data: string;
265
- driverParam: string;
266
- notNull: true;
267
- hasDefault: false;
268
- enumValues: [string, ...string[]];
269
- baseColumn: never;
270
- }, object>;
271
- createdAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
272
- name: "created_at";
273
- tableName: "prompts";
274
- dataType: "number";
275
- columnType: "SQLiteInteger";
276
- data: number;
277
- driverParam: number;
278
- notNull: true;
279
- hasDefault: false;
280
- enumValues: undefined;
281
- baseColumn: never;
282
- }, object>;
283
- metadata: import("drizzle-orm/sqlite-core").SQLiteColumn<{
284
- name: "metadata";
285
- tableName: "prompts";
286
- dataType: "string";
287
- columnType: "SQLiteText";
288
- data: string;
289
- driverParam: string;
290
- notNull: false;
291
- hasDefault: false;
292
- enumValues: [string, ...string[]];
293
- baseColumn: never;
294
- }, object>;
295
- };
296
- dialect: "sqlite";
297
- }>;
298
- export declare const projects: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
299
- name: "projects";
300
- schema: undefined;
301
- columns: {
302
- id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
303
- name: "id";
304
- tableName: "projects";
305
- dataType: "number";
306
- columnType: "SQLiteInteger";
307
- data: number;
308
- driverParam: number;
309
- notNull: true;
310
- hasDefault: true;
311
- enumValues: undefined;
312
- baseColumn: never;
313
- }, object>;
314
- name: import("drizzle-orm/sqlite-core").SQLiteColumn<{
315
- name: "name";
316
- tableName: "projects";
317
- dataType: "string";
318
- columnType: "SQLiteText";
319
- data: string;
320
- driverParam: string;
321
- notNull: true;
322
- hasDefault: false;
323
- enumValues: [string, ...string[]];
324
- baseColumn: never;
325
- }, object>;
326
- createdAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
327
- name: "created_at";
328
- tableName: "projects";
329
- dataType: "number";
330
- columnType: "SQLiteInteger";
331
- data: number;
332
- driverParam: number;
333
- notNull: true;
334
- hasDefault: false;
335
- enumValues: undefined;
336
- baseColumn: never;
337
- }, object>;
338
- metadata: import("drizzle-orm/sqlite-core").SQLiteColumn<{
339
- name: "metadata";
340
- tableName: "projects";
341
- dataType: "string";
342
- columnType: "SQLiteText";
343
- data: string;
344
- driverParam: string;
345
- notNull: false;
346
- hasDefault: false;
347
- enumValues: [string, ...string[]];
348
- baseColumn: never;
349
- }, object>;
350
- };
351
- dialect: "sqlite";
352
- }>;
353
- //# sourceMappingURL=schema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/db/schema.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOnB,CAAC;AAEH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWvB,CAAC;AAEH,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQlB,CAAC;AAEH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKnB,CAAC"}
package/dist/db/schema.js DELETED
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.projects = exports.prompts = exports.observations = exports.sessions = void 0;
4
- const sqlite_core_1 = require("drizzle-orm/sqlite-core");
5
- exports.sessions = (0, sqlite_core_1.sqliteTable)('sessions', {
6
- id: (0, sqlite_core_1.integer)('id').primaryKey({ autoIncrement: true }),
7
- uuid: (0, sqlite_core_1.text)('uuid').unique().notNull(),
8
- projectId: (0, sqlite_core_1.text)('project_id').notNull(),
9
- startedAt: (0, sqlite_core_1.integer)('started_at').notNull(),
10
- endedAt: (0, sqlite_core_1.integer)('ended_at'),
11
- metadata: (0, sqlite_core_1.text)('metadata'),
12
- });
13
- exports.observations = (0, sqlite_core_1.sqliteTable)('observations', {
14
- id: (0, sqlite_core_1.integer)('id').primaryKey({ autoIncrement: true }),
15
- uuid: (0, sqlite_core_1.text)('uuid').unique().notNull(),
16
- sessionId: (0, sqlite_core_1.integer)('session_id').notNull(),
17
- title: (0, sqlite_core_1.text)('title').notNull(),
18
- content: (0, sqlite_core_1.text)('content').notNull(),
19
- type: (0, sqlite_core_1.text)('type').notNull(),
20
- topicKey: (0, sqlite_core_1.text)('topic_key'),
21
- projectId: (0, sqlite_core_1.text)('project_id').notNull(),
22
- createdAt: (0, sqlite_core_1.integer)('created_at').notNull(),
23
- metadata: (0, sqlite_core_1.text)('metadata'),
24
- });
25
- exports.prompts = (0, sqlite_core_1.sqliteTable)('prompts', {
26
- id: (0, sqlite_core_1.integer)('id').primaryKey({ autoIncrement: true }),
27
- uuid: (0, sqlite_core_1.text)('uuid').unique().notNull(),
28
- sessionId: (0, sqlite_core_1.integer)('session_id').notNull(),
29
- content: (0, sqlite_core_1.text)('content').notNull(),
30
- projectId: (0, sqlite_core_1.text)('project_id').notNull(),
31
- createdAt: (0, sqlite_core_1.integer)('created_at').notNull(),
32
- metadata: (0, sqlite_core_1.text)('metadata'),
33
- });
34
- exports.projects = (0, sqlite_core_1.sqliteTable)('projects', {
35
- id: (0, sqlite_core_1.integer)('id').primaryKey({ autoIncrement: true }),
36
- name: (0, sqlite_core_1.text)('name').unique().notNull(),
37
- createdAt: (0, sqlite_core_1.integer)('created_at').notNull(),
38
- metadata: (0, sqlite_core_1.text)('metadata'),
39
- });
40
- //# sourceMappingURL=schema.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/db/schema.ts"],"names":[],"mappings":";;;AAAA,yDAAqE;AAExD,QAAA,QAAQ,GAAG,IAAA,yBAAW,EAAC,UAAU,EAAE;IAC9C,EAAE,EAAE,IAAA,qBAAO,EAAC,IAAI,CAAC,CAAC,UAAU,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;IACrD,IAAI,EAAE,IAAA,kBAAI,EAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE;IACrC,SAAS,EAAE,IAAA,kBAAI,EAAC,YAAY,CAAC,CAAC,OAAO,EAAE;IACvC,SAAS,EAAE,IAAA,qBAAO,EAAC,YAAY,CAAC,CAAC,OAAO,EAAE;IAC1C,OAAO,EAAE,IAAA,qBAAO,EAAC,UAAU,CAAC;IAC5B,QAAQ,EAAE,IAAA,kBAAI,EAAC,UAAU,CAAC;CAC3B,CAAC,CAAC;AAEU,QAAA,YAAY,GAAG,IAAA,yBAAW,EAAC,cAAc,EAAE;IACtD,EAAE,EAAE,IAAA,qBAAO,EAAC,IAAI,CAAC,CAAC,UAAU,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;IACrD,IAAI,EAAE,IAAA,kBAAI,EAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE;IACrC,SAAS,EAAE,IAAA,qBAAO,EAAC,YAAY,CAAC,CAAC,OAAO,EAAE;IAC1C,KAAK,EAAE,IAAA,kBAAI,EAAC,OAAO,CAAC,CAAC,OAAO,EAAE;IAC9B,OAAO,EAAE,IAAA,kBAAI,EAAC,SAAS,CAAC,CAAC,OAAO,EAAE;IAClC,IAAI,EAAE,IAAA,kBAAI,EAAC,MAAM,CAAC,CAAC,OAAO,EAAE;IAC5B,QAAQ,EAAE,IAAA,kBAAI,EAAC,WAAW,CAAC;IAC3B,SAAS,EAAE,IAAA,kBAAI,EAAC,YAAY,CAAC,CAAC,OAAO,EAAE;IACvC,SAAS,EAAE,IAAA,qBAAO,EAAC,YAAY,CAAC,CAAC,OAAO,EAAE;IAC1C,QAAQ,EAAE,IAAA,kBAAI,EAAC,UAAU,CAAC;CAC3B,CAAC,CAAC;AAEU,QAAA,OAAO,GAAG,IAAA,yBAAW,EAAC,SAAS,EAAE;IAC5C,EAAE,EAAE,IAAA,qBAAO,EAAC,IAAI,CAAC,CAAC,UAAU,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;IACrD,IAAI,EAAE,IAAA,kBAAI,EAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE;IACrC,SAAS,EAAE,IAAA,qBAAO,EAAC,YAAY,CAAC,CAAC,OAAO,EAAE;IAC1C,OAAO,EAAE,IAAA,kBAAI,EAAC,SAAS,CAAC,CAAC,OAAO,EAAE;IAClC,SAAS,EAAE,IAAA,kBAAI,EAAC,YAAY,CAAC,CAAC,OAAO,EAAE;IACvC,SAAS,EAAE,IAAA,qBAAO,EAAC,YAAY,CAAC,CAAC,OAAO,EAAE;IAC1C,QAAQ,EAAE,IAAA,kBAAI,EAAC,UAAU,CAAC;CAC3B,CAAC,CAAC;AAEU,QAAA,QAAQ,GAAG,IAAA,yBAAW,EAAC,UAAU,EAAE;IAC9C,EAAE,EAAE,IAAA,qBAAO,EAAC,IAAI,CAAC,CAAC,UAAU,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;IACrD,IAAI,EAAE,IAAA,kBAAI,EAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE;IACrC,SAAS,EAAE,IAAA,qBAAO,EAAC,YAAY,CAAC,CAAC,OAAO,EAAE;IAC1C,QAAQ,EAAE,IAAA,kBAAI,EAAC,UAAU,CAAC;CAC3B,CAAC,CAAC"}
package/drizzle.config.ts DELETED
@@ -1,10 +0,0 @@
1
- import { defineConfig } from 'drizzle-kit';
2
-
3
- export default defineConfig({
4
- schema: './src/db/schema.ts',
5
- out: './src/db/migrations',
6
- driver: 'better-sqlite',
7
- dbCredentials: {
8
- url: './data/memento.db',
9
- },
10
- });
@@ -1,248 +0,0 @@
1
- import { describe, it, expect, beforeEach, afterEach, beforeAll, afterAll } from 'bun:test';
2
- import { rmSync, mkdirSync, existsSync, writeFileSync } from 'fs';
3
- import { join } from 'path';
4
-
5
- const testDir = join(process.cwd(), 'test-data');
6
- const configDir = join(testDir, 'config');
7
- const storageDir = join(testDir, 'storage');
8
-
9
- beforeAll(() => {
10
- if (existsSync(testDir)) {
11
- rmSync(testDir, { recursive: true, force: true });
12
- }
13
- mkdirSync(testDir, { recursive: true });
14
- mkdirSync(configDir, { recursive: true });
15
- mkdirSync(storageDir, { recursive: true });
16
-
17
- writeFileSync(
18
- join(configDir, '.mementorc'),
19
- JSON.stringify(
20
- {
21
- storageMethod: 'database',
22
- dbPath: '.memento/db/memento.db',
23
- storagePath: 'database/storage',
24
- projectId: 'test-project',
25
- },
26
- null,
27
- 2
28
- )
29
- );
30
- });
31
-
32
- afterAll(() => {
33
- if (existsSync(testDir)) {
34
- rmSync(testDir, { recursive: true, force: true });
35
- }
36
- });
37
-
38
- describe('ConfigManager', () => {
39
- describe('loadConfig()', () => {
40
- it('should load .mementorc from current directory', () => {
41
- const { loadConfig } = require('../src/ConfigManager');
42
-
43
- const originalCwd = process.cwd;
44
- process.cwd = () => configDir;
45
-
46
- try {
47
- const config = loadConfig();
48
- expect(config.storagePath).toBe('database/storage');
49
- expect(config.projectId).toBe('test-project');
50
- } finally {
51
- process.cwd = originalCwd;
52
- }
53
- });
54
-
55
- it('should use default config when no .mementorc found', () => {
56
- const { loadConfig } = require('../src/ConfigManager');
57
- const { join } = require('path');
58
- const { mkdirSync } = require('fs');
59
-
60
- const noConfigDir = join(testDir, 'no-config-isolated');
61
- mkdirSync(noConfigDir, { recursive: true });
62
-
63
- const originalCwd = process.cwd;
64
- // Use /tmp which should not have .mementorc
65
- process.cwd = () => '/tmp';
66
-
67
- try {
68
- const config = loadConfig();
69
- expect(config.storageMethod).toBe('database');
70
- expect(config.dbPath).toBe('.memento/db/memento.db');
71
- expect(config.storagePath).toBe('database/storage');
72
- // projectId will be undefined when no .mementorc and no package.json
73
- expect(config.projectId).toBeUndefined();
74
- } finally {
75
- process.cwd = originalCwd;
76
- }
77
- });
78
-
79
- it('should use environment variables when set', () => {
80
- const { loadConfig } = require('../src/ConfigManager');
81
-
82
- const originalEnv = { ...process.env };
83
- process.env.MEMENTO_STORAGE_METHOD = 'storage';
84
- process.env.MEMENTO_DB_PATH = '/custom/db/memento.db';
85
- process.env.MEMENTO_STORAGE_PATH = '/custom/storage';
86
- process.env.MEMENTO_PROJECT_ID = 'env-project';
87
-
88
- try {
89
- const config = loadConfig();
90
- expect(config.storageMethod).toBe('storage');
91
- expect(config.dbPath).toBe('/custom/db/memento.db');
92
- expect(config.storagePath).toBe('/custom/storage');
93
- expect(config.projectId).toBe('env-project');
94
- } finally {
95
- process.env = originalEnv;
96
- }
97
- });
98
- });
99
-
100
- describe('resolveStoragePath()', () => {
101
- it('should resolve absolute paths', () => {
102
- const { resolveStoragePath } = require('../src/ConfigManager');
103
- const config = { storagePath: '/absolute/path', projectId: 'test' };
104
- const resolved = resolveStoragePath(config);
105
- expect(resolved).toBe('/absolute/path');
106
- });
107
-
108
- it('should resolve ~ to home directory', () => {
109
- const { resolveStoragePath } = require('../src/ConfigManager');
110
- const { homedir } = require('os');
111
- const config = { storagePath: '~/memento-data', projectId: 'test' };
112
-
113
- const originalCwd = process.cwd;
114
- process.cwd = () => '/some/working/dir';
115
-
116
- try {
117
- const resolved = resolveStoragePath(config);
118
- expect(resolved).toBe(join(homedir(), 'memento-data'));
119
- } finally {
120
- process.cwd = originalCwd;
121
- }
122
- });
123
-
124
- it('should resolve relative paths from working directory', () => {
125
- const { resolveStoragePath } = require('../src/ConfigManager');
126
- const config = { storagePath: 'database/storage', projectId: 'test' };
127
-
128
- const originalCwd = process.cwd;
129
- process.cwd = () => '/project/root';
130
-
131
- try {
132
- const resolved = resolveStoragePath(config);
133
- expect(resolved).toBe('/project/root/database/storage');
134
- } finally {
135
- process.cwd = originalCwd;
136
- }
137
- });
138
- });
139
-
140
- describe('resolveDbPath()', () => {
141
- it('should resolve absolute paths', () => {
142
- const { resolveDbPath } = require('../src/ConfigManager');
143
- const config = { dbPath: '/absolute/path/memento.db', projectId: 'test' };
144
- const resolved = resolveDbPath(config);
145
- expect(resolved).toBe('/absolute/path/memento.db');
146
- });
147
-
148
- it('should resolve ~ to home directory', () => {
149
- const { resolveDbPath } = require('../src/ConfigManager');
150
- const { homedir } = require('os');
151
- const config = { dbPath: '~/.memento/db/memento.db', projectId: 'test' };
152
-
153
- const originalCwd = process.cwd;
154
- process.cwd = () => '/some/working/dir';
155
-
156
- try {
157
- const resolved = resolveDbPath(config);
158
- expect(resolved).toBe(join(homedir(), '.memento/db/memento.db'));
159
- } finally {
160
- process.cwd = originalCwd;
161
- }
162
- });
163
-
164
- it('should resolve relative paths from working directory', () => {
165
- const { resolveDbPath } = require('../src/ConfigManager');
166
- const config = { dbPath: '.memento/db/memento.db', projectId: 'test' };
167
-
168
- const originalCwd = process.cwd;
169
- process.cwd = () => '/project/root';
170
-
171
- try {
172
- const resolved = resolveDbPath(config);
173
- expect(resolved).toBe('/project/root/.memento/db/memento.db');
174
- } finally {
175
- process.cwd = originalCwd;
176
- }
177
- });
178
-
179
- it('should use default dbPath when not specified', () => {
180
- const { resolveDbPath } = require('../src/ConfigManager');
181
- const config = { projectId: 'test' };
182
-
183
- const originalCwd = process.cwd;
184
- process.cwd = () => '/project/root';
185
-
186
- try {
187
- const resolved = resolveDbPath(config);
188
- expect(resolved).toBe('/project/root/.memento/db/memento.db');
189
- } finally {
190
- process.cwd = originalCwd;
191
- }
192
- });
193
- });
194
-
195
- describe('getProjectId()', () => {
196
- it('should use projectId from config if available', () => {
197
- const { getProjectId } = require('../src/ConfigManager');
198
- const config = { storagePath: 'test', projectId: 'config-project' };
199
-
200
- const originalCwd = process.cwd;
201
- process.cwd = () => '/some/dir';
202
-
203
- try {
204
- const projectId = getProjectId(config);
205
- expect(projectId).toBe('config-project');
206
- } finally {
207
- process.cwd = originalCwd;
208
- }
209
- });
210
-
211
- it('should read package.json if no projectId in config', () => {
212
- const { getProjectId } = require('../src/ConfigManager');
213
- const packageDir = join(testDir, 'with-package');
214
- mkdirSync(packageDir, { recursive: true });
215
-
216
- writeFileSync(
217
- join(packageDir, 'package.json'),
218
- JSON.stringify({ name: 'my-project-from-package' }, null, 2)
219
- );
220
-
221
- const config = { storagePath: 'test', projectId: undefined };
222
- const originalCwd = process.cwd;
223
- process.cwd = () => packageDir;
224
-
225
- try {
226
- const projectId = getProjectId(config);
227
- expect(projectId).toBe('my-project-from-package');
228
- } finally {
229
- process.cwd = originalCwd;
230
- }
231
- });
232
-
233
- it('should default to "default" when no projectId found', () => {
234
- const { getProjectId } = require('../src/ConfigManager');
235
- const config = { storagePath: 'test', projectId: undefined };
236
-
237
- const originalCwd = process.cwd;
238
- process.cwd = () => '/no/package/here';
239
-
240
- try {
241
- const projectId = getProjectId(config);
242
- expect(projectId).toBe('default');
243
- } finally {
244
- process.cwd = originalCwd;
245
- }
246
- });
247
- });
248
- });