ydb-qdrant 4.5.1 → 4.6.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.
@@ -9,6 +9,7 @@ collectionsRouter.put("/:collection/index", async (req, res) => {
9
9
  tenant: req.header("X-Tenant-Id") ?? undefined,
10
10
  collection: String(req.params.collection),
11
11
  apiKey: req.header("api-key") ?? undefined,
12
+ userAgent: req.header("User-Agent") ?? undefined,
12
13
  });
13
14
  res.json({ status: "ok", result });
14
15
  }
@@ -27,6 +28,7 @@ collectionsRouter.put("/:collection", async (req, res) => {
27
28
  tenant: req.header("X-Tenant-Id") ?? undefined,
28
29
  collection: String(req.params.collection),
29
30
  apiKey: req.header("api-key") ?? undefined,
31
+ userAgent: req.header("User-Agent") ?? undefined,
30
32
  }, req.body);
31
33
  res.json({ status: "ok", result });
32
34
  }
@@ -45,6 +47,7 @@ collectionsRouter.get("/:collection", async (req, res) => {
45
47
  tenant: req.header("X-Tenant-Id") ?? undefined,
46
48
  collection: String(req.params.collection),
47
49
  apiKey: req.header("api-key") ?? undefined,
50
+ userAgent: req.header("User-Agent") ?? undefined,
48
51
  });
49
52
  res.json({ status: "ok", result });
50
53
  }
@@ -63,6 +66,7 @@ collectionsRouter.delete("/:collection", async (req, res) => {
63
66
  tenant: req.header("X-Tenant-Id") ?? undefined,
64
67
  collection: String(req.params.collection),
65
68
  apiKey: req.header("api-key") ?? undefined,
69
+ userAgent: req.header("User-Agent") ?? undefined,
66
70
  });
67
71
  res.json({ status: "ok", result });
68
72
  }
@@ -10,6 +10,7 @@ pointsRouter.put("/:collection/points", async (req, res) => {
10
10
  tenant: req.header("X-Tenant-Id") ?? undefined,
11
11
  collection: String(req.params.collection),
12
12
  apiKey: req.header("api-key") ?? undefined,
13
+ userAgent: req.header("User-Agent") ?? undefined,
13
14
  }, req.body);
14
15
  res.json({ status: "ok", result });
15
16
  }
@@ -28,6 +29,7 @@ pointsRouter.post("/:collection/points/upsert", async (req, res) => {
28
29
  tenant: req.header("X-Tenant-Id") ?? undefined,
29
30
  collection: String(req.params.collection),
30
31
  apiKey: req.header("api-key") ?? undefined,
32
+ userAgent: req.header("User-Agent") ?? undefined,
31
33
  }, req.body);
32
34
  res.json({ status: "ok", result });
33
35
  }
@@ -46,6 +48,7 @@ pointsRouter.post("/:collection/points/search", async (req, res) => {
46
48
  tenant: req.header("X-Tenant-Id") ?? undefined,
47
49
  collection: String(req.params.collection),
48
50
  apiKey: req.header("api-key") ?? undefined,
51
+ userAgent: req.header("User-Agent") ?? undefined,
49
52
  }, req.body);
50
53
  res.json({ status: "ok", result });
51
54
  }
@@ -65,6 +68,7 @@ pointsRouter.post("/:collection/points/query", async (req, res) => {
65
68
  tenant: req.header("X-Tenant-Id") ?? undefined,
66
69
  collection: String(req.params.collection),
67
70
  apiKey: req.header("api-key") ?? undefined,
71
+ userAgent: req.header("User-Agent") ?? undefined,
68
72
  }, req.body);
69
73
  res.json({ status: "ok", result });
70
74
  }
@@ -83,6 +87,7 @@ pointsRouter.post("/:collection/points/delete", async (req, res) => {
83
87
  tenant: req.header("X-Tenant-Id") ?? undefined,
84
88
  collection: String(req.params.collection),
85
89
  apiKey: req.header("api-key") ?? undefined,
90
+ userAgent: req.header("User-Agent") ?? undefined,
86
91
  }, req.body);
87
92
  res.json({ status: "ok", result });
88
93
  }
@@ -3,6 +3,7 @@ export interface CollectionContextInput {
3
3
  tenant: string | undefined;
4
4
  collection: string;
5
5
  apiKey?: string;
6
+ userAgent?: string;
6
7
  }
7
8
  export interface NormalizedCollectionContext {
8
9
  tenant: string;
@@ -5,7 +5,7 @@ import { QdrantServiceError } from "./errors.js";
5
5
  import { normalizeCollectionContextShared, tableNameFor, } from "./CollectionService.shared.js";
6
6
  import { resolvePointsTableAndUidOneTable } from "./CollectionService.one-table.js";
7
7
  export function normalizeCollectionContext(input) {
8
- return normalizeCollectionContextShared(input.tenant, input.collection, input.apiKey);
8
+ return normalizeCollectionContextShared(input.tenant, input.collection, input.apiKey, input.userAgent);
9
9
  }
10
10
  export async function resolvePointsTableAndUid(ctx, meta) {
11
11
  if (meta?.table === GLOBAL_POINTS_TABLE) {
@@ -4,7 +4,7 @@ export interface NormalizedCollectionContextLike {
4
4
  }
5
5
  export declare function tableNameFor(tenantId: string, collection: string): string;
6
6
  export declare function uidFor(tenantId: string, collection: string): string;
7
- export declare function normalizeCollectionContextShared(tenant: string | undefined, collection: string, apiKey?: string): {
7
+ export declare function normalizeCollectionContextShared(tenant: string | undefined, collection: string, apiKey?: string, userAgent?: string): {
8
8
  tenant: string;
9
9
  collection: string;
10
10
  metaKey: string;
@@ -1,14 +1,15 @@
1
- import { sanitizeCollectionName, sanitizeTenantId, metaKeyFor, tableNameFor as tableNameForInternal, uidFor as uidForInternal, hashApiKey, } from "../utils/tenant.js";
1
+ import { sanitizeCollectionName, sanitizeTenantId, metaKeyFor, tableNameFor as tableNameForInternal, uidFor as uidForInternal, hashApiKey, hashUserAgent, } from "../utils/tenant.js";
2
2
  export function tableNameFor(tenantId, collection) {
3
3
  return tableNameForInternal(tenantId, collection);
4
4
  }
5
5
  export function uidFor(tenantId, collection) {
6
6
  return uidForInternal(tenantId, collection);
7
7
  }
8
- export function normalizeCollectionContextShared(tenant, collection, apiKey) {
8
+ export function normalizeCollectionContextShared(tenant, collection, apiKey, userAgent) {
9
9
  const normalizedTenant = sanitizeTenantId(tenant);
10
10
  const apiKeyHash = hashApiKey(apiKey);
11
- const normalizedCollection = sanitizeCollectionName(collection, apiKeyHash);
11
+ const userAgentHash = hashUserAgent(userAgent);
12
+ const normalizedCollection = sanitizeCollectionName(collection, apiKeyHash, userAgentHash);
12
13
  const metaKey = metaKeyFor(normalizedTenant, normalizedCollection);
13
14
  return {
14
15
  tenant: normalizedTenant,
@@ -1,5 +1,6 @@
1
1
  export declare function hashApiKey(apiKey: string | undefined): string | undefined;
2
- export declare function sanitizeCollectionName(name: string, apiKeyHash?: string): string;
2
+ export declare function hashUserAgent(userAgent: string | undefined): string | undefined;
3
+ export declare function sanitizeCollectionName(name: string, apiKeyHash?: string, userAgentHash?: string): string;
3
4
  export declare function sanitizeTenantId(tenantId: string | undefined): string;
4
5
  export declare function tableNameFor(sanitizedTenant: string, sanitizedCollection: string): string;
5
6
  export declare function metaKeyFor(sanitizedTenant: string, sanitizedCollection: string): string;
@@ -5,12 +5,28 @@ export function hashApiKey(apiKey) {
5
5
  const hash = createHash("sha256").update(apiKey).digest("hex");
6
6
  return hash.slice(0, 8);
7
7
  }
8
- export function sanitizeCollectionName(name, apiKeyHash) {
8
+ export function hashUserAgent(userAgent) {
9
+ if (!userAgent || userAgent.trim() === "")
10
+ return undefined;
11
+ const hash = createHash("sha256").update(userAgent).digest("hex");
12
+ return hash.slice(0, 8);
13
+ }
14
+ export function sanitizeCollectionName(name, apiKeyHash, userAgentHash) {
9
15
  const cleaned = name.replace(/[^a-zA-Z0-9_]/g, "_").replace(/_+/g, "_");
10
16
  const lowered = cleaned.toLowerCase().replace(/^_+/, "");
11
17
  const base = lowered.length > 0 ? lowered : "collection";
12
- const hasHash = apiKeyHash !== undefined && apiKeyHash.trim().length > 0;
13
- return hasHash ? `${base}_${apiKeyHash}` : base;
18
+ const hasApiKey = apiKeyHash !== undefined && apiKeyHash.trim().length > 0;
19
+ const hasUserAgent = userAgentHash !== undefined && userAgentHash.trim().length > 0;
20
+ if (hasApiKey && hasUserAgent) {
21
+ return `${base}_${apiKeyHash}_${userAgentHash}`;
22
+ }
23
+ else if (hasApiKey) {
24
+ return `${base}_${apiKeyHash}`;
25
+ }
26
+ else if (hasUserAgent) {
27
+ return `${base}_${userAgentHash}`;
28
+ }
29
+ return base;
14
30
  }
15
31
  export function sanitizeTenantId(tenantId) {
16
32
  const raw = (tenantId ?? "default").toString();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ydb-qdrant",
3
- "version": "4.5.1",
3
+ "version": "4.6.0",
4
4
  "main": "dist/package/api.js",
5
5
  "types": "dist/package/api.d.ts",
6
6
  "exports": {