@prmichaelsen/remember-mcp 3.12.0 → 3.14.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.
- package/CHANGELOG.md +20 -0
- package/agent/milestones/milestone-17-remember-core-migration.md +140 -0
- package/agent/progress.yaml +123 -6
- package/agent/tasks/milestone-17-remember-core-migration/task-193-foundation-setup.md +58 -0
- package/agent/tasks/milestone-17-remember-core-migration/task-194-migrate-relationship-tools.md +47 -0
- package/agent/tasks/milestone-17-remember-core-migration/task-195-migrate-preference-tools.md +34 -0
- package/agent/tasks/milestone-17-remember-core-migration/task-196-migrate-memory-tools.md +46 -0
- package/agent/tasks/milestone-17-remember-core-migration/task-197-migrate-space-confirmation-tools.md +49 -0
- package/agent/tasks/milestone-17-remember-core-migration/task-198-migrate-space-search-moderate.md +46 -0
- package/agent/tasks/milestone-17-remember-core-migration/task-199-migrate-delete-memory.md +43 -0
- package/agent/tasks/milestone-17-remember-core-migration/task-200-code-cleanup-verification.md +52 -0
- package/dist/core-services.d.ts +25 -0
- package/dist/server-factory.js +3578 -4485
- package/dist/server.js +3070 -3973
- package/dist/tools/confirm-publish-moderation.spec.d.ts +3 -2
- package/dist/tools/create-memory.d.ts +1 -1
- package/dist/tools/query-space.d.ts +1 -1
- package/dist/tools/search-space.d.ts +10 -14
- package/jest.config.js +11 -0
- package/package.json +2 -1
- package/src/core-services.ts +50 -0
- package/src/tools/confirm-publish-moderation.spec.ts +120 -176
- package/src/tools/confirm.ts +70 -1035
- package/src/tools/create-memory.ts +16 -67
- package/src/tools/create-relationship.ts +13 -181
- package/src/tools/delete-memory.ts +7 -72
- package/src/tools/delete-relationship.ts +7 -91
- package/src/tools/deny.ts +4 -14
- package/src/tools/find-similar.ts +16 -110
- package/src/tools/get-preferences.ts +3 -8
- package/src/tools/moderate.spec.ts +65 -81
- package/src/tools/moderate.ts +18 -121
- package/src/tools/publish.ts +7 -204
- package/src/tools/query-space.ts +28 -140
- package/src/tools/retract.ts +7 -185
- package/src/tools/revise.ts +4 -136
- package/src/tools/search-relationship.ts +17 -116
- package/src/tools/search-space.ts +58 -304
- package/src/tools/set-preference.ts +3 -8
- package/src/tools/update-memory.ts +22 -190
- package/src/tools/update-relationship.ts +16 -90
- package/src/v2-smoke.e2e.ts +3 -2
- package/dist/collections/composite-ids.d.ts +0 -106
- package/dist/collections/core-infrastructure.spec.d.ts +0 -11
- package/dist/collections/dot-notation.d.ts +0 -106
- package/dist/collections/tracking-arrays.d.ts +0 -176
- package/dist/constants/content-types.d.ts +0 -61
- package/dist/services/confirmation-token.service.d.ts +0 -99
- package/dist/services/confirmation-token.service.spec.d.ts +0 -5
- package/dist/services/preferences-database.service.d.ts +0 -22
- package/dist/services/space-config.service.d.ts +0 -23
- package/dist/services/space-config.service.spec.d.ts +0 -2
- package/src/collections/composite-ids.ts +0 -193
- package/src/collections/core-infrastructure.spec.ts +0 -353
- package/src/collections/dot-notation.ts +0 -212
- package/src/collections/tracking-arrays.ts +0 -298
- package/src/constants/content-types.ts +0 -490
- package/src/services/confirmation-token.service.spec.ts +0 -254
- package/src/services/confirmation-token.service.ts +0 -328
- package/src/services/preferences-database.service.ts +0 -120
- package/src/services/space-config.service.spec.ts +0 -102
- package/src/services/space-config.service.ts +0 -79
|
@@ -4,13 +4,10 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import type { Memory, MemoryUpdate } from '../types/memory.js';
|
|
7
|
-
import {
|
|
8
|
-
import { fetchMemoryWithAllProperties } from '../weaviate/client.js';
|
|
9
|
-
import { logger } from '../utils/logger.js';
|
|
10
|
-
import { handleToolError, withErrorHandling } from '../utils/error-handler.js';
|
|
11
|
-
import { isValidContentType } from '../constants/content-types.js';
|
|
7
|
+
import { handleToolError } from '../utils/error-handler.js';
|
|
12
8
|
import { createDebugLogger } from '../utils/debug.js';
|
|
13
9
|
import type { AuthContext } from '../types/auth.js';
|
|
10
|
+
import { createCoreServices } from '../core-services.js';
|
|
14
11
|
|
|
15
12
|
/**
|
|
16
13
|
* Tool definition for remember_update_memory
|
|
@@ -133,196 +130,31 @@ export async function handleUpdateMemory(
|
|
|
133
130
|
try {
|
|
134
131
|
debug.info('Tool invoked');
|
|
135
132
|
debug.trace('Arguments', { args });
|
|
136
|
-
logger.info('Updating memory', { userId, memoryId: args.memory_id });
|
|
137
133
|
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
userId,
|
|
152
|
-
memoryId: args.memory_id,
|
|
153
|
-
collectionName: `Memory_${userId}`,
|
|
154
|
-
});
|
|
155
|
-
throw new Error(`Failed to fetch memory ${args.memory_id}: ${fetchErrorMsg}`);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
if (!existingMemory || !existingMemory.properties) {
|
|
159
|
-
throw new Error(`Memory not found: ${args.memory_id}. It may have been deleted or never existed.`);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// Verify ownership
|
|
163
|
-
if (existingMemory.properties.user_id !== userId) {
|
|
164
|
-
throw new Error('Unauthorized: Cannot update another user\'s memory');
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
// Verify it's a memory (not a relationship)
|
|
168
|
-
if (existingMemory.properties.doc_type !== 'memory') {
|
|
169
|
-
throw new Error('Cannot update relationships using this tool. Use remember_update_relationship instead.');
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// Check if memory is deleted
|
|
173
|
-
if (existingMemory.properties.deleted_at) {
|
|
174
|
-
const deletedAt = typeof existingMemory.properties.deleted_at === 'string'
|
|
175
|
-
? existingMemory.properties.deleted_at
|
|
176
|
-
: new Date(existingMemory.properties.deleted_at as any).toISOString();
|
|
177
|
-
throw new Error(`Cannot update deleted memory: ${args.memory_id}. Memory was deleted on ${deletedAt}.`);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
// Build update object with only provided fields
|
|
181
|
-
const updates: Record<string, any> = {};
|
|
182
|
-
const updatedFields: string[] = [];
|
|
183
|
-
|
|
184
|
-
// Update content fields
|
|
185
|
-
if (args.content !== undefined) {
|
|
186
|
-
updates.content = args.content;
|
|
187
|
-
updatedFields.push('content');
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
if (args.title !== undefined) {
|
|
191
|
-
updates.title = args.title;
|
|
192
|
-
updates.summary = args.title; // Keep summary in sync with title
|
|
193
|
-
updatedFields.push('title');
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
if (args.type !== undefined) {
|
|
197
|
-
if (!isValidContentType(args.type)) {
|
|
198
|
-
throw new Error(`Invalid content type: ${args.type}`);
|
|
199
|
-
}
|
|
200
|
-
updates.content_type = args.type;
|
|
201
|
-
updatedFields.push('content_type');
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
// Update scoring fields
|
|
205
|
-
if (args.weight !== undefined) {
|
|
206
|
-
if (args.weight < 0 || args.weight > 1) {
|
|
207
|
-
throw new Error('Weight must be between 0 and 1');
|
|
208
|
-
}
|
|
209
|
-
updates.weight = args.weight;
|
|
210
|
-
updates.base_weight = args.weight;
|
|
211
|
-
updates.computed_weight = args.weight; // Recalculate if needed
|
|
212
|
-
updatedFields.push('weight');
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
if (args.trust !== undefined) {
|
|
216
|
-
if (args.trust < 0 || args.trust > 1) {
|
|
217
|
-
throw new Error('Trust must be between 0 and 1');
|
|
218
|
-
}
|
|
219
|
-
updates.trust_score = args.trust;
|
|
220
|
-
updatedFields.push('trust_score');
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
// Update organization fields
|
|
224
|
-
if (args.tags !== undefined) {
|
|
225
|
-
updates.tags = args.tags;
|
|
226
|
-
updatedFields.push('tags');
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
if (args.references !== undefined) {
|
|
230
|
-
updates.references = args.references;
|
|
231
|
-
updatedFields.push('references');
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
// Update structured content
|
|
235
|
-
if (args.structured_content !== undefined) {
|
|
236
|
-
updates.structured_content = args.structured_content;
|
|
237
|
-
updatedFields.push('structured_content');
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
// NOTE: space_ids and group_ids (publication tracking arrays) are intentionally
|
|
241
|
-
// NOT exposed in UpdateMemoryArgs — they are managed exclusively by
|
|
242
|
-
// remember_publish and remember_retract. The spread below preserves them.
|
|
243
|
-
|
|
244
|
-
// Update comment/threading fields
|
|
245
|
-
if (args.parent_id !== undefined) {
|
|
246
|
-
updates.parent_id = args.parent_id;
|
|
247
|
-
updatedFields.push('parent_id');
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
if (args.thread_root_id !== undefined) {
|
|
251
|
-
updates.thread_root_id = args.thread_root_id;
|
|
252
|
-
updatedFields.push('thread_root_id');
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
if (args.moderation_flags !== undefined) {
|
|
256
|
-
updates.moderation_flags = args.moderation_flags;
|
|
257
|
-
updatedFields.push('moderation_flags');
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
// Check if any fields were provided
|
|
261
|
-
if (updatedFields.length === 0) {
|
|
262
|
-
throw new Error('No fields provided for update. At least one field must be specified.');
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
// Update metadata
|
|
266
|
-
const now = new Date().toISOString();
|
|
267
|
-
updates.updated_at = now;
|
|
268
|
-
updates.version = (existingMemory.properties.version as number) + 1;
|
|
269
|
-
|
|
270
|
-
// Merge updates with existing properties
|
|
271
|
-
// Use replace() instead of update() due to Weaviate bug where update() only
|
|
272
|
-
// persists if vectorized fields (content/observation) are changed
|
|
273
|
-
const mergedProperties = {
|
|
274
|
-
...existingMemory.properties,
|
|
275
|
-
...updates,
|
|
276
|
-
};
|
|
277
|
-
|
|
278
|
-
logger.info('Calling Weaviate replace', {
|
|
279
|
-
userId,
|
|
280
|
-
memoryId: args.memory_id,
|
|
281
|
-
updateFields: Object.keys(updates),
|
|
282
|
-
updateValues: updates,
|
|
283
|
-
collectionName: `Memory_${userId}`,
|
|
284
|
-
totalProperties: Object.keys(mergedProperties).length,
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
try {
|
|
288
|
-
await collection.data.replace({
|
|
289
|
-
id: args.memory_id,
|
|
290
|
-
properties: mergedProperties,
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
logger.info('Weaviate replace completed (no error thrown)', {
|
|
294
|
-
userId,
|
|
295
|
-
memoryId: args.memory_id,
|
|
296
|
-
updatedFields: Object.keys(updates),
|
|
297
|
-
});
|
|
298
|
-
} catch (updateError) {
|
|
299
|
-
const updateErrorMsg = updateError instanceof Error ? updateError.message : String(updateError);
|
|
300
|
-
logger.error('Failed to perform Weaviate replace:', {
|
|
301
|
-
error: updateErrorMsg,
|
|
302
|
-
userId,
|
|
303
|
-
memoryId: args.memory_id,
|
|
304
|
-
updateFields: Object.keys(updates),
|
|
305
|
-
collectionName: `Memory_${userId}`,
|
|
306
|
-
});
|
|
307
|
-
throw new Error(`Failed to update memory in Weaviate: ${updateErrorMsg}`);
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
logger.info('Memory updated successfully', {
|
|
311
|
-
userId,
|
|
312
|
-
memoryId: args.memory_id,
|
|
313
|
-
version: updates.version,
|
|
314
|
-
updatedFields,
|
|
134
|
+
const { memory } = createCoreServices(userId);
|
|
135
|
+
const result = await memory.update({
|
|
136
|
+
memory_id: args.memory_id,
|
|
137
|
+
content: args.content,
|
|
138
|
+
title: args.title,
|
|
139
|
+
type: args.type,
|
|
140
|
+
weight: args.weight,
|
|
141
|
+
trust: args.trust,
|
|
142
|
+
tags: args.tags,
|
|
143
|
+
references: args.references,
|
|
144
|
+
parent_id: args.parent_id,
|
|
145
|
+
thread_root_id: args.thread_root_id,
|
|
146
|
+
moderation_flags: args.moderation_flags,
|
|
315
147
|
});
|
|
316
148
|
|
|
317
|
-
const
|
|
318
|
-
memory_id:
|
|
319
|
-
updated_at:
|
|
320
|
-
version:
|
|
321
|
-
updated_fields:
|
|
322
|
-
message: `Memory updated successfully. Updated fields: ${
|
|
149
|
+
const response: UpdateMemoryResult = {
|
|
150
|
+
memory_id: result.memory_id,
|
|
151
|
+
updated_at: result.updated_at,
|
|
152
|
+
version: result.version,
|
|
153
|
+
updated_fields: result.updated_fields,
|
|
154
|
+
message: `Memory updated successfully. Updated fields: ${result.updated_fields.join(', ')}`,
|
|
323
155
|
};
|
|
324
156
|
|
|
325
|
-
return JSON.stringify(
|
|
157
|
+
return JSON.stringify(response, null, 2);
|
|
326
158
|
} catch (error) {
|
|
327
159
|
debug.error('Tool failed', { error: error instanceof Error ? error.message : String(error) });
|
|
328
160
|
handleToolError(error, {
|
|
@@ -3,12 +3,10 @@
|
|
|
3
3
|
* Update an existing relationship with partial updates
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type { RelationshipUpdate } from '../types/memory.js';
|
|
7
|
-
import { getMemoryCollection } from '../weaviate/schema.js';
|
|
8
|
-
import { logger } from '../utils/logger.js';
|
|
9
6
|
import { handleToolError } from '../utils/error-handler.js';
|
|
10
7
|
import { createDebugLogger } from '../utils/debug.js';
|
|
11
8
|
import type { AuthContext } from '../types/auth.js';
|
|
9
|
+
import { createCoreServices } from '../core-services.js';
|
|
12
10
|
|
|
13
11
|
/**
|
|
14
12
|
* Tool definition for remember_update_relationship
|
|
@@ -100,97 +98,25 @@ export async function handleUpdateRelationship(
|
|
|
100
98
|
debug.info('Tool invoked');
|
|
101
99
|
debug.trace('Arguments', { args });
|
|
102
100
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
if (!existingRelationship) {
|
|
113
|
-
throw new Error(`Relationship not found: ${args.relationship_id}`);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// Verify ownership
|
|
117
|
-
if (existingRelationship.properties.user_id !== userId) {
|
|
118
|
-
throw new Error('Unauthorized: Cannot update another user\'s relationship');
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// Verify it's a relationship (not a memory)
|
|
122
|
-
if (existingRelationship.properties.doc_type !== 'relationship') {
|
|
123
|
-
throw new Error('Cannot update memories using this tool. Use remember_update_memory instead.');
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// Build update object with only provided fields
|
|
127
|
-
const updates: Record<string, any> = {};
|
|
128
|
-
const updatedFields: string[] = [];
|
|
129
|
-
|
|
130
|
-
// Update relationship fields
|
|
131
|
-
if (args.relationship_type !== undefined) {
|
|
132
|
-
updates.relationship_type = args.relationship_type;
|
|
133
|
-
updatedFields.push('relationship_type');
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
if (args.observation !== undefined) {
|
|
137
|
-
updates.observation = args.observation;
|
|
138
|
-
updatedFields.push('observation');
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
if (args.strength !== undefined) {
|
|
142
|
-
if (args.strength < 0 || args.strength > 1) {
|
|
143
|
-
throw new Error('Strength must be between 0 and 1');
|
|
144
|
-
}
|
|
145
|
-
updates.strength = args.strength;
|
|
146
|
-
updatedFields.push('strength');
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
if (args.confidence !== undefined) {
|
|
150
|
-
if (args.confidence < 0 || args.confidence > 1) {
|
|
151
|
-
throw new Error('Confidence must be between 0 and 1');
|
|
152
|
-
}
|
|
153
|
-
updates.confidence = args.confidence;
|
|
154
|
-
updatedFields.push('confidence');
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
if (args.tags !== undefined) {
|
|
158
|
-
updates.tags = args.tags;
|
|
159
|
-
updatedFields.push('tags');
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// Check if any fields were provided
|
|
163
|
-
if (updatedFields.length === 0) {
|
|
164
|
-
throw new Error('No fields provided for update. At least one field must be specified.');
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
// Update metadata
|
|
168
|
-
const now = new Date().toISOString();
|
|
169
|
-
updates.updated_at = now;
|
|
170
|
-
updates.version = (existingRelationship.properties.version as number) + 1;
|
|
171
|
-
|
|
172
|
-
// Perform update in Weaviate
|
|
173
|
-
await collection.data.update({
|
|
174
|
-
id: args.relationship_id,
|
|
175
|
-
properties: updates,
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
logger.info('Relationship updated successfully', {
|
|
179
|
-
userId,
|
|
180
|
-
relationshipId: args.relationship_id,
|
|
181
|
-
version: updates.version,
|
|
182
|
-
updatedFields,
|
|
101
|
+
const { relationship } = createCoreServices(userId);
|
|
102
|
+
const result = await relationship.update({
|
|
103
|
+
relationship_id: args.relationship_id,
|
|
104
|
+
relationship_type: args.relationship_type,
|
|
105
|
+
observation: args.observation,
|
|
106
|
+
strength: args.strength,
|
|
107
|
+
confidence: args.confidence,
|
|
108
|
+
tags: args.tags,
|
|
183
109
|
});
|
|
184
110
|
|
|
185
|
-
const
|
|
186
|
-
relationship_id:
|
|
187
|
-
updated_at:
|
|
188
|
-
version:
|
|
189
|
-
updated_fields:
|
|
190
|
-
message: `Relationship updated successfully. Updated fields: ${
|
|
111
|
+
const response: UpdateRelationshipResult = {
|
|
112
|
+
relationship_id: result.relationship_id,
|
|
113
|
+
updated_at: result.updated_at,
|
|
114
|
+
version: result.version,
|
|
115
|
+
updated_fields: result.updated_fields,
|
|
116
|
+
message: `Relationship updated successfully. Updated fields: ${result.updated_fields.join(', ')}`,
|
|
191
117
|
};
|
|
192
118
|
|
|
193
|
-
return JSON.stringify(
|
|
119
|
+
return JSON.stringify(response, null, 2);
|
|
194
120
|
} catch (error) {
|
|
195
121
|
debug.error('Tool failed', { error: error instanceof Error ? error.message : String(error) });
|
|
196
122
|
handleToolError(error, {
|
package/src/v2-smoke.e2e.ts
CHANGED
|
@@ -17,13 +17,14 @@ dotenv.config({ path: process.env.DOTENV_CONFIG_PATH || '.env.e1.local', overrid
|
|
|
17
17
|
|
|
18
18
|
import weaviate, { WeaviateClient, configure } from 'weaviate-client';
|
|
19
19
|
import { config } from './config.js';
|
|
20
|
-
import { generateCompositeId, parseCompositeId } from './collections/composite-ids.js';
|
|
21
20
|
import {
|
|
21
|
+
generateCompositeId,
|
|
22
|
+
parseCompositeId,
|
|
22
23
|
addToSpaceIds,
|
|
23
24
|
addToGroupIds,
|
|
24
25
|
isPublishedToSpace,
|
|
25
26
|
getPublishedLocations,
|
|
26
|
-
} from '
|
|
27
|
+
} from '@prmichaelsen/remember-core';
|
|
27
28
|
|
|
28
29
|
// ---------------------------------------------------------------------------
|
|
29
30
|
// Test constants
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Composite ID Utilities
|
|
3
|
-
*
|
|
4
|
-
* Provides utilities for working with composite IDs in Memory Collection Pattern v2.
|
|
5
|
-
* Composite IDs preserve the source reference when memories are published to spaces or groups.
|
|
6
|
-
*
|
|
7
|
-
* Format: {userId}.{memoryId}
|
|
8
|
-
* Example: "user123.my-recipe"
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* Components of a composite ID
|
|
12
|
-
*/
|
|
13
|
-
export interface CompositeIdComponents {
|
|
14
|
-
userId: string;
|
|
15
|
-
memoryId: string;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Error thrown when composite ID is invalid
|
|
19
|
-
*/
|
|
20
|
-
export declare class InvalidCompositeIdError extends Error {
|
|
21
|
-
constructor(message: string);
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Generate a composite ID from user ID and memory ID
|
|
25
|
-
*
|
|
26
|
-
* @param userId - User ID (must not contain dots)
|
|
27
|
-
* @param memoryId - Memory ID (must not contain dots)
|
|
28
|
-
* @returns Composite ID in format {userId}.{memoryId}
|
|
29
|
-
* @throws {InvalidCompositeIdError} If userId or memoryId contains dots
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* generateCompositeId('user123', 'my-recipe')
|
|
33
|
-
* // Returns: 'user123.my-recipe'
|
|
34
|
-
*/
|
|
35
|
-
export declare function generateCompositeId(userId: string, memoryId: string): string;
|
|
36
|
-
/**
|
|
37
|
-
* Parse a composite ID into its components
|
|
38
|
-
*
|
|
39
|
-
* @param compositeId - Composite ID to parse
|
|
40
|
-
* @returns Object with userId and memoryId
|
|
41
|
-
* @throws {InvalidCompositeIdError} If composite ID format is invalid
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* parseCompositeId('user123.my-recipe')
|
|
45
|
-
* // Returns: { userId: 'user123', memoryId: 'my-recipe' }
|
|
46
|
-
*/
|
|
47
|
-
export declare function parseCompositeId(compositeId: string): CompositeIdComponents;
|
|
48
|
-
/**
|
|
49
|
-
* Check if a string is a composite ID
|
|
50
|
-
*
|
|
51
|
-
* @param id - String to check
|
|
52
|
-
* @returns true if valid composite ID, false otherwise
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* isCompositeId('user123.my-recipe') // true
|
|
56
|
-
* isCompositeId('simple-id') // false
|
|
57
|
-
* isCompositeId('too.many.dots') // false
|
|
58
|
-
*/
|
|
59
|
-
export declare function isCompositeId(id: string): boolean;
|
|
60
|
-
/**
|
|
61
|
-
* Validate a composite ID (returns true on valid, throws on invalid)
|
|
62
|
-
*
|
|
63
|
-
* @param id - Composite ID to validate
|
|
64
|
-
* @returns true if valid
|
|
65
|
-
* @throws {InvalidCompositeIdError} If composite ID is invalid
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* validateCompositeId('user123.my-recipe') // Returns true
|
|
69
|
-
* validateCompositeId('invalid') // Throws InvalidCompositeIdError
|
|
70
|
-
*/
|
|
71
|
-
export declare function validateCompositeId(id: string): true;
|
|
72
|
-
/**
|
|
73
|
-
* Extract user ID from a composite ID
|
|
74
|
-
*
|
|
75
|
-
* @param compositeId - Composite ID
|
|
76
|
-
* @returns User ID component
|
|
77
|
-
*
|
|
78
|
-
* @example
|
|
79
|
-
* getUserIdFromComposite('user123.my-recipe')
|
|
80
|
-
* // Returns: 'user123'
|
|
81
|
-
*/
|
|
82
|
-
export declare function getUserIdFromComposite(compositeId: string): string;
|
|
83
|
-
/**
|
|
84
|
-
* Extract memory ID from a composite ID
|
|
85
|
-
*
|
|
86
|
-
* @param compositeId - Composite ID
|
|
87
|
-
* @returns Memory ID component
|
|
88
|
-
*
|
|
89
|
-
* @example
|
|
90
|
-
* getMemoryIdFromComposite('user123.my-recipe')
|
|
91
|
-
* // Returns: 'my-recipe'
|
|
92
|
-
*/
|
|
93
|
-
export declare function getMemoryIdFromComposite(compositeId: string): string;
|
|
94
|
-
/**
|
|
95
|
-
* Check if an ID belongs to a specific user
|
|
96
|
-
*
|
|
97
|
-
* @param compositeId - Composite ID to check
|
|
98
|
-
* @param userId - User ID to match
|
|
99
|
-
* @returns true if composite ID belongs to user, false otherwise
|
|
100
|
-
*
|
|
101
|
-
* @example
|
|
102
|
-
* belongsToUser('user123.my-recipe', 'user123') // true
|
|
103
|
-
* belongsToUser('user123.my-recipe', 'user456') // false
|
|
104
|
-
*/
|
|
105
|
-
export declare function belongsToUser(compositeId: string, userId: string): boolean;
|
|
106
|
-
//# sourceMappingURL=composite-ids.d.ts.map
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Unit tests for Memory Collection Pattern v2 Core Infrastructure
|
|
3
|
-
*
|
|
4
|
-
* Tests core functionality of:
|
|
5
|
-
* - Dot notation collection utilities
|
|
6
|
-
* - Composite ID utilities
|
|
7
|
-
* - Tracking array management
|
|
8
|
-
* - Schema definitions
|
|
9
|
-
*/
|
|
10
|
-
export {};
|
|
11
|
-
//# sourceMappingURL=core-infrastructure.spec.d.ts.map
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Dot Notation Collection Utilities
|
|
3
|
-
*
|
|
4
|
-
* Provides utilities for working with Memory Collection Pattern v2's
|
|
5
|
-
* dot notation collection naming scheme.
|
|
6
|
-
*
|
|
7
|
-
* Collection Types:
|
|
8
|
-
* - USERS: Memory_users_{userId} - Private user memories
|
|
9
|
-
* - SPACES: Memory_spaces_public - All public space memories
|
|
10
|
-
* - GROUPS: Memory_groups_{groupId} - Group memories
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
|
-
* Collection type enum for Memory Collection Pattern v2
|
|
14
|
-
*/
|
|
15
|
-
export declare enum CollectionType {
|
|
16
|
-
USERS = "USERS",
|
|
17
|
-
SPACES = "SPACES",
|
|
18
|
-
GROUPS = "GROUPS"
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Metadata about a parsed collection
|
|
22
|
-
*/
|
|
23
|
-
export interface CollectionMetadata {
|
|
24
|
-
type: CollectionType;
|
|
25
|
-
id?: string;
|
|
26
|
-
name: string;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Error thrown when collection name is invalid
|
|
30
|
-
*/
|
|
31
|
-
export declare class InvalidCollectionNameError extends Error {
|
|
32
|
-
constructor(message: string);
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Get the Weaviate collection name for a given type and optional ID
|
|
36
|
-
*
|
|
37
|
-
* @param type - Collection type (USERS, SPACES, or GROUPS)
|
|
38
|
-
* @param id - Optional ID (required for USERS and GROUPS, not used for SPACES)
|
|
39
|
-
* @returns Weaviate collection name
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* getCollectionName(CollectionType.USERS, 'user123')
|
|
43
|
-
* // Returns: 'Memory_users_user123'
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
* getCollectionName(CollectionType.SPACES)
|
|
47
|
-
* // Returns: 'Memory_spaces_public'
|
|
48
|
-
*
|
|
49
|
-
* @example
|
|
50
|
-
* getCollectionName(CollectionType.GROUPS, 'group456')
|
|
51
|
-
* // Returns: 'Memory_groups_group456'
|
|
52
|
-
*/
|
|
53
|
-
export declare function getCollectionName(type: CollectionType, id?: string): string;
|
|
54
|
-
/**
|
|
55
|
-
* Parse a collection name into its components
|
|
56
|
-
*
|
|
57
|
-
* @param name - Weaviate collection name
|
|
58
|
-
* @returns Collection metadata with type, optional ID, and name
|
|
59
|
-
*
|
|
60
|
-
* @example
|
|
61
|
-
* parseCollectionName('Memory_users_user123')
|
|
62
|
-
* // Returns: { type: CollectionType.USERS, id: 'user123', name: 'Memory_users_user123' }
|
|
63
|
-
*
|
|
64
|
-
* @example
|
|
65
|
-
* parseCollectionName('Memory_spaces_public')
|
|
66
|
-
* // Returns: { type: CollectionType.SPACES, id: undefined, name: 'Memory_spaces_public' }
|
|
67
|
-
*
|
|
68
|
-
* @example
|
|
69
|
-
* parseCollectionName('Memory_groups_group456')
|
|
70
|
-
* // Returns: { type: CollectionType.GROUPS, id: 'group456', name: 'Memory_groups_group456' }
|
|
71
|
-
*/
|
|
72
|
-
export declare function parseCollectionName(name: string): CollectionMetadata;
|
|
73
|
-
/**
|
|
74
|
-
* Validate a collection name
|
|
75
|
-
*
|
|
76
|
-
* @param name - Collection name to validate
|
|
77
|
-
* @returns true if valid, false otherwise
|
|
78
|
-
*
|
|
79
|
-
* @example
|
|
80
|
-
* validateCollectionName('Memory_users_user123') // true
|
|
81
|
-
* validateCollectionName('Memory_spaces_public') // true
|
|
82
|
-
* validateCollectionName('Invalid_name') // false
|
|
83
|
-
*/
|
|
84
|
-
export declare function validateCollectionName(name: string): boolean;
|
|
85
|
-
/**
|
|
86
|
-
* Check if a collection name is a user collection
|
|
87
|
-
*
|
|
88
|
-
* @param name - Collection name to check
|
|
89
|
-
* @returns true if user collection, false otherwise
|
|
90
|
-
*/
|
|
91
|
-
export declare function isUserCollection(name: string): boolean;
|
|
92
|
-
/**
|
|
93
|
-
* Check if a collection name is the spaces collection
|
|
94
|
-
*
|
|
95
|
-
* @param name - Collection name to check
|
|
96
|
-
* @returns true if spaces collection, false otherwise
|
|
97
|
-
*/
|
|
98
|
-
export declare function isSpacesCollection(name: string): boolean;
|
|
99
|
-
/**
|
|
100
|
-
* Check if a collection name is a group collection
|
|
101
|
-
*
|
|
102
|
-
* @param name - Collection name to check
|
|
103
|
-
* @returns true if group collection, false otherwise
|
|
104
|
-
*/
|
|
105
|
-
export declare function isGroupCollection(name: string): boolean;
|
|
106
|
-
//# sourceMappingURL=dot-notation.d.ts.map
|