mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-24 09:28:31 +00:00
- Updated `AbilityGuard` to utilize `TransactionLogger` for logging execution time and errors. - Enhanced `ResponseInterceptor` to include transaction metadata in logs. - Modified `QueryAuthGuard`, `ValidateQueryAppGuard`, and `ValidateQuerySourceGuard` to log completion times and transaction IDs. - Introduced `TransactionLogger` service for structured logging with transaction context. - Added transaction ID and route information to request context in `RequestContextMiddleware`. - Updated `JwtStrategy` to log validation completion times. - Refactored logging configuration in `AppModuleLoader` to support pretty printing in non-production environments. - Removed console logs in favor of structured logging for better traceability.
81 lines
2.3 KiB
TypeScript
81 lines
2.3 KiB
TypeScript
import { QueryOptions } from './types';
|
|
import { QdrantClient } from '@qdrant/js-client-rest';
|
|
|
|
export async function getCollectionInfo(qdrant: QdrantClient, options: QueryOptions): Promise<any> {
|
|
const { collectionName } = options;
|
|
|
|
if (!collectionName) {
|
|
throw new Error('Collection name is required');
|
|
}
|
|
|
|
return await qdrant.getCollection(collectionName);
|
|
}
|
|
|
|
export async function listCollections(qdrant: QdrantClient, options: QueryOptions): Promise<any> {
|
|
const collections = (await qdrant.getCollections()).collections;
|
|
return collections.map((c) => c.name);
|
|
}
|
|
|
|
export async function getPoints(qdrant: QdrantClient, options: QueryOptions): Promise<any> {
|
|
const { collectionName, ids } = options;
|
|
|
|
if (!collectionName) {
|
|
throw new Error('Collection name is required');
|
|
}
|
|
|
|
const points = await qdrant.retrieve(collectionName, {
|
|
ids: JSON.parse(ids),
|
|
with_payload: true,
|
|
with_vector: true,
|
|
});
|
|
|
|
return points;
|
|
}
|
|
|
|
export async function upsertPoints(qdrant: QdrantClient, options: QueryOptions): Promise<any> {
|
|
const { collectionName, points } = options;
|
|
|
|
if (!collectionName) {
|
|
throw new Error('Collection name is required');
|
|
}
|
|
|
|
const response = await qdrant.upsert(collectionName, {
|
|
points: JSON.parse(points),
|
|
wait: true,
|
|
});
|
|
return response.status;
|
|
}
|
|
|
|
export async function deletePoints(qdrant: QdrantClient, options: QueryOptions): Promise<any> {
|
|
const { collectionName, ids, filter } = options;
|
|
|
|
if (!collectionName) {
|
|
throw new Error('Collection name is required');
|
|
}
|
|
|
|
const response = await qdrant.delete(collectionName, {
|
|
filter: filter ? JSON.parse(filter) : undefined,
|
|
points: ids ? JSON.parse(ids) : undefined,
|
|
wait: true,
|
|
});
|
|
|
|
return response.status;
|
|
}
|
|
|
|
export async function queryPoints(qdrant: QdrantClient, options: QueryOptions): Promise<any> {
|
|
const { collectionName, query, filter, limit, withPayload, withVectors } = options;
|
|
|
|
if (!collectionName) {
|
|
throw new Error('Collection name is required');
|
|
}
|
|
|
|
const response = await qdrant.query(collectionName, {
|
|
query: query ? JSON.parse(query) : null,
|
|
filter: filter ? JSON.parse(filter) : {},
|
|
limit: limit ? JSON.parse(limit) : 10,
|
|
with_payload: withPayload.toLowerCase() === 'true',
|
|
with_vector: withVectors.toLowerCase() == 'true',
|
|
});
|
|
|
|
return response.points;
|
|
}
|