@nexo-labs/payload-typesense 1.9.9 → 1.11.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/dist/index.d.mts +86 -80
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +18 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -181,7 +181,7 @@ async function createNewSession(payload, userId, conversationId, newUserMessage,
|
|
|
181
181
|
await payload.create({
|
|
182
182
|
collection: collectionName,
|
|
183
183
|
data: {
|
|
184
|
-
user: userId,
|
|
184
|
+
user: typeof userId === "string" ? Number(userId) : userId,
|
|
185
185
|
conversation_id: conversationId,
|
|
186
186
|
status: "active",
|
|
187
187
|
agentSlug,
|
|
@@ -883,6 +883,15 @@ async function renameSession(payload, userId, conversationId, newTitle, config =
|
|
|
883
883
|
});
|
|
884
884
|
}
|
|
885
885
|
|
|
886
|
+
//#endregion
|
|
887
|
+
//#region src/adapter/types.ts
|
|
888
|
+
/**
|
|
889
|
+
* Type-safe check for Typesense 404 (Not Found) errors
|
|
890
|
+
*/
|
|
891
|
+
function isTypesense404(error) {
|
|
892
|
+
return error?.httpStatus === 404;
|
|
893
|
+
}
|
|
894
|
+
|
|
886
895
|
//#endregion
|
|
887
896
|
//#region src/features/rag/setup.ts
|
|
888
897
|
/**
|
|
@@ -898,7 +907,7 @@ async function ensureConversationCollection(client, collectionName = "conversati
|
|
|
898
907
|
logger$1.info("Conversation collection already exists", { collection: collectionName });
|
|
899
908
|
return true;
|
|
900
909
|
} catch (error) {
|
|
901
|
-
if (error
|
|
910
|
+
if (isTypesense404(error)) {
|
|
902
911
|
logger$1.info("Creating conversation collection", { collection: collectionName });
|
|
903
912
|
try {
|
|
904
913
|
await client.collections().create({
|
|
@@ -3029,7 +3038,7 @@ var SchemaManager = class {
|
|
|
3029
3038
|
const collection = await this.client.collections(tableName).retrieve();
|
|
3030
3039
|
await this.updateCollectionSchema(tableName, collection, targetSchema);
|
|
3031
3040
|
} catch (error) {
|
|
3032
|
-
if (error
|
|
3041
|
+
if (isTypesense404(error)) {
|
|
3033
3042
|
logger$1.info(`Creating collection: ${tableName}`);
|
|
3034
3043
|
await this.client.collections().create(targetSchema);
|
|
3035
3044
|
} else {
|
|
@@ -3225,7 +3234,7 @@ var TypesenseAdapter = class {
|
|
|
3225
3234
|
const existing = await this.client.collections(schema.name).retrieve();
|
|
3226
3235
|
await this.updateCollectionIfNeeded(schema.name, existing, typesenseSchema);
|
|
3227
3236
|
} catch (error) {
|
|
3228
|
-
if (error
|
|
3237
|
+
if (isTypesense404(error)) {
|
|
3229
3238
|
logger$1.info(`Creating collection: ${schema.name}`);
|
|
3230
3239
|
await this.client.collections().create(typesenseSchema);
|
|
3231
3240
|
} else throw error;
|
|
@@ -3239,7 +3248,7 @@ var TypesenseAdapter = class {
|
|
|
3239
3248
|
await this.client.collections(collectionName).retrieve();
|
|
3240
3249
|
return true;
|
|
3241
3250
|
} catch (error) {
|
|
3242
|
-
if (error
|
|
3251
|
+
if (isTypesense404(error)) return false;
|
|
3243
3252
|
throw error;
|
|
3244
3253
|
}
|
|
3245
3254
|
}
|
|
@@ -3251,7 +3260,7 @@ var TypesenseAdapter = class {
|
|
|
3251
3260
|
await this.client.collections(collectionName).delete();
|
|
3252
3261
|
logger$1.info(`Deleted collection: ${collectionName}`);
|
|
3253
3262
|
} catch (error) {
|
|
3254
|
-
if (error
|
|
3263
|
+
if (!isTypesense404(error)) throw error;
|
|
3255
3264
|
}
|
|
3256
3265
|
}
|
|
3257
3266
|
/**
|
|
@@ -3285,7 +3294,7 @@ var TypesenseAdapter = class {
|
|
|
3285
3294
|
try {
|
|
3286
3295
|
await this.client.collections(collectionName).documents(documentId).delete();
|
|
3287
3296
|
} catch (error) {
|
|
3288
|
-
if (error
|
|
3297
|
+
if (!isTypesense404(error)) {
|
|
3289
3298
|
logger$1.error(`Failed to delete document ${documentId} from ${collectionName}`, error);
|
|
3290
3299
|
throw error;
|
|
3291
3300
|
}
|
|
@@ -3447,7 +3456,7 @@ const deleteDocumentFromTypesense = async (typesenseClient, collectionSlug, docI
|
|
|
3447
3456
|
tableName
|
|
3448
3457
|
});
|
|
3449
3458
|
} catch (docDeleteError) {
|
|
3450
|
-
if (docDeleteError
|
|
3459
|
+
if (isTypesense404(docDeleteError)) {
|
|
3451
3460
|
logger$1.debug("Document not found, attempting to delete chunks", {
|
|
3452
3461
|
documentId: docId,
|
|
3453
3462
|
tableName
|
|
@@ -3459,7 +3468,7 @@ const deleteDocumentFromTypesense = async (typesenseClient, collectionSlug, docI
|
|
|
3459
3468
|
tableName
|
|
3460
3469
|
});
|
|
3461
3470
|
} catch (chunkDeleteError) {
|
|
3462
|
-
if (chunkDeleteError
|
|
3471
|
+
if (!isTypesense404(chunkDeleteError)) logger$1.error("Failed to delete chunks for document", chunkDeleteError, {
|
|
3463
3472
|
documentId: docId,
|
|
3464
3473
|
tableName
|
|
3465
3474
|
});
|