@lunora/bindings 1.0.0-alpha.8 → 1.0.0-alpha.80

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.
Files changed (58) hide show
  1. package/dist/analytics/index.d.mts +81 -85
  2. package/dist/analytics/index.d.ts +81 -85
  3. package/dist/analytics/index.mjs +1 -2
  4. package/dist/images/index.d.mts +159 -174
  5. package/dist/images/index.d.ts +159 -174
  6. package/dist/images/index.mjs +1 -3
  7. package/dist/kv/index.d.mts +74 -151
  8. package/dist/kv/index.d.ts +74 -151
  9. package/dist/kv/index.mjs +1 -2
  10. package/dist/packem_shared/AnalyticsSqlError-CeQ3A5Eb.mjs +1 -0
  11. package/dist/packem_shared/R2SqlError-ZHgOWClB.mjs +1 -0
  12. package/dist/packem_shared/SelectBuilder-DJXNSdqC.mjs +1 -0
  13. package/dist/packem_shared/SetOperation-kiI5Wnlm.mjs +1 -0
  14. package/dist/packem_shared/Sql-BfnxRway.mjs +1 -0
  15. package/dist/packem_shared/WindowExpression-VX7EEV3h.mjs +1 -0
  16. package/dist/packem_shared/WindowFunction-CL4jYy2l.mjs +1 -0
  17. package/dist/packem_shared/asc-DP_WFiAE.mjs +1 -0
  18. package/dist/packem_shared/buildImageDeliveryUrl-Brqs-dcZ.mjs +1 -0
  19. package/dist/packem_shared/buildSignedImageUrl-BV-iSJKA.mjs +4 -0
  20. package/dist/packem_shared/cap-error-body-YBKO32BF.mjs +1 -0
  21. package/dist/packem_shared/concurrent-vRmSvRpF.mjs +1 -0
  22. package/dist/packem_shared/createAnalytics-BXTNc57d.mjs +1 -0
  23. package/dist/packem_shared/createContextVectors-DiyO3pZU.mjs +6 -0
  24. package/dist/packem_shared/createImages-D7JExfqF.mjs +1 -0
  25. package/dist/packem_shared/createKv-mAHanD5g.mjs +1 -0
  26. package/dist/packem_shared/createKvIntrospector-BpRiFRFQ.mjs +1 -0
  27. package/dist/packem_shared/createPipelines-CIvqrc7E.mjs +1 -0
  28. package/dist/packem_shared/createVectorAdminIntrospector-Ct8v6PxJ.mjs +1 -0
  29. package/dist/packem_shared/createVectors-Dzv0ilKE.mjs +1 -0
  30. package/dist/pipelines/index.d.mts +24 -24
  31. package/dist/pipelines/index.d.ts +24 -24
  32. package/dist/pipelines/index.mjs +1 -1
  33. package/dist/r2sql/index.d.mts +169 -125
  34. package/dist/r2sql/index.d.ts +169 -125
  35. package/dist/r2sql/index.mjs +1 -7
  36. package/dist/vectors/index.d.mts +299 -134
  37. package/dist/vectors/index.d.ts +299 -134
  38. package/dist/vectors/index.mjs +1 -3
  39. package/package.json +3 -2
  40. package/dist/packem_shared/AnalyticsSqlError-C2nz3jpH.mjs +0 -41
  41. package/dist/packem_shared/R2SqlError-drPKSCZ3.mjs +0 -65
  42. package/dist/packem_shared/SelectBuilder-BOqJQHEv.mjs +0 -168
  43. package/dist/packem_shared/SetOperation-DmPgUL8W.mjs +0 -81
  44. package/dist/packem_shared/Sql-B3zq2YGx.mjs +0 -74
  45. package/dist/packem_shared/WindowExpression-BT_uA6g1.mjs +0 -44
  46. package/dist/packem_shared/WindowFunction-DrnuZUF6.mjs +0 -82
  47. package/dist/packem_shared/asc-DZbQCxh1.mjs +0 -16
  48. package/dist/packem_shared/buildImageDeliveryUrl-qZ7XbqTL.mjs +0 -35
  49. package/dist/packem_shared/buildSignedImageUrl-DNUFfyGP.mjs +0 -130
  50. package/dist/packem_shared/concurrent-CkCEVwqP.mjs +0 -39
  51. package/dist/packem_shared/createAnalytics-CEEI69o9.mjs +0 -57
  52. package/dist/packem_shared/createContextVectors-DwZtnPeC.mjs +0 -140
  53. package/dist/packem_shared/createImages-BzRnsz3H.mjs +0 -85
  54. package/dist/packem_shared/createKv-C8Iyu5hD.mjs +0 -145
  55. package/dist/packem_shared/createKvIntrospector-Byk4GfsY.mjs +0 -77
  56. package/dist/packem_shared/createPipelines-CfyJ6VGu.mjs +0 -10
  57. package/dist/packem_shared/createVectorAdminIntrospector-DuSvcBa5.mjs +0 -53
  58. package/dist/packem_shared/createVectors-CTSrctiK.mjs +0 -95
@@ -1,53 +0,0 @@
1
- import { LunoraError } from '@lunora/errors';
2
-
3
- const MAX_TOP_K = 20;
4
- const DEFAULT_TOP_K = 10;
5
- const createVectorAdminIntrospector = (options) => {
6
- const { embedders, indexes, registry } = options;
7
- const listIndexes = async () => Promise.all(
8
- registry.map(async (entry) => {
9
- const binding = indexes[entry.name];
10
- if (binding?.describe === void 0) {
11
- return { ...entry };
12
- }
13
- try {
14
- const details = await binding.describe();
15
- return {
16
- ...entry,
17
- dimensions: entry.dimensions ?? details.dimensions,
18
- processedUpToMutation: details.processedUpToMutation,
19
- vectorsCount: details.vectorsCount
20
- };
21
- } catch {
22
- return { ...entry };
23
- }
24
- })
25
- );
26
- const hasEmbedders = embedders !== void 0 && Object.keys(embedders).length > 0;
27
- if (!hasEmbedders) {
28
- return { listIndexes };
29
- }
30
- const queryIndex = async ({ name, text, topK }) => {
31
- const binding = indexes[name];
32
- if (!Object.hasOwn(indexes, name) || binding === void 0) {
33
- throw new LunoraError("INTERNAL", `@lunora/bindings/vectors: no Vectorize binding registered for index "${name}"`);
34
- }
35
- const embed = embedders[name];
36
- if (!Object.hasOwn(embedders, name) || embed === void 0) {
37
- throw new LunoraError("INTERNAL", `@lunora/bindings/vectors: no embedder registered for index "${name}" — it lists read-only`);
38
- }
39
- const vector = await embed(text);
40
- const result = await binding.query(vector, {
41
- returnMetadata: "all",
42
- topK: Math.min(topK ?? DEFAULT_TOP_K, MAX_TOP_K)
43
- });
44
- return {
45
- matches: result.matches.map((match) => {
46
- return { id: match.id, metadata: match.metadata, score: match.score };
47
- })
48
- };
49
- };
50
- return { listIndexes, queryIndex };
51
- };
52
-
53
- export { createVectorAdminIntrospector };
@@ -1,95 +0,0 @@
1
- import { LunoraError } from '@lunora/errors';
2
- import { c as concurrentMap, U as UPSERT_EMBED_CONCURRENCY } from './concurrent-CkCEVwqP.mjs';
3
-
4
- const resolveIndex = (indexes, name) => {
5
- const index = indexes[name];
6
- if (!Object.hasOwn(indexes, name) || index === void 0) {
7
- throw new LunoraError(
8
- "INTERNAL",
9
- `@lunora/bindings/vectors: no index registered for "${name}". Known indexes: ${Object.keys(indexes).join(", ") || "(none)"}`
10
- );
11
- }
12
- return index;
13
- };
14
- const toVector = async (input) => {
15
- const values = await input.embed(input.input);
16
- return {
17
- id: input.id,
18
- metadata: input.metadata,
19
- namespace: input.namespace,
20
- values
21
- };
22
- };
23
- const MAX_TOP_K = 100;
24
- const MAX_TOP_K_WITH_VALUES = 20;
25
- const MAX_ID_BATCH = 1e3;
26
- const MAX_UPSERT_BATCH = 1e3;
27
- const createVectors = (options) => {
28
- if (Object.keys(options.indexes).length === 0) {
29
- throw new TypeError("@lunora/bindings/vectors: at least one index binding is required");
30
- }
31
- const upsert = async (indexName, input) => {
32
- const index = resolveIndex(options.indexes, indexName);
33
- const vector = await toVector(input);
34
- return index.upsert([vector]);
35
- };
36
- const upsertMany = async (indexName, inputs) => {
37
- const index = resolveIndex(options.indexes, indexName);
38
- if (inputs.length > MAX_UPSERT_BATCH) {
39
- throw new RangeError(
40
- `@lunora/bindings/vectors: upsertMany batch exceeds ${String(MAX_UPSERT_BATCH)} (got ${String(inputs.length)}) — split across calls`
41
- );
42
- }
43
- const vectors = await concurrentMap(inputs, UPSERT_EMBED_CONCURRENCY, toVector);
44
- return index.upsert(vectors);
45
- };
46
- const query = async (indexName, input) => {
47
- const index = resolveIndex(options.indexes, indexName);
48
- const wantsHeavyPayload = input.returnValues === true || input.returnMetadata === "all";
49
- const topKCeiling = wantsHeavyPayload ? MAX_TOP_K_WITH_VALUES : MAX_TOP_K;
50
- if (input.topK !== void 0 && (!Number.isInteger(input.topK) || input.topK < 1 || input.topK > topKCeiling)) {
51
- const reason = wantsHeavyPayload ? ' (lowered to 20 because returnValues/returnMetadata:"all" is set)' : "";
52
- throw new RangeError(`@lunora/bindings/vectors: topK must be an integer in [1, ${String(topKCeiling)}]${reason} (got ${String(input.topK)})`);
53
- }
54
- let values;
55
- if (input.vector && input.vector.length > 0) {
56
- values = input.vector;
57
- } else {
58
- if (!input.embed || input.input === void 0) {
59
- throw new TypeError("@lunora/bindings/vectors: query requires either `vector` or both `input` and `embed`");
60
- }
61
- values = await input.embed(input.input);
62
- }
63
- return index.query(values, {
64
- filter: input.filter,
65
- namespace: input.namespace,
66
- returnMetadata: input.returnMetadata,
67
- returnValues: input.returnValues,
68
- topK: input.topK
69
- });
70
- };
71
- const getByIds = async (indexName, ids) => {
72
- const index = resolveIndex(options.indexes, indexName);
73
- if (ids.length > MAX_ID_BATCH) {
74
- throw new RangeError(`@lunora/bindings/vectors: getByIds accepts at most ${String(MAX_ID_BATCH)} ids (got ${String(ids.length)})`);
75
- }
76
- return index.getByIds(ids);
77
- };
78
- const deleteByIds = async (indexName, ids) => {
79
- const index = resolveIndex(options.indexes, indexName);
80
- if (ids.length > MAX_ID_BATCH) {
81
- throw new RangeError(`@lunora/bindings/vectors: deleteByIds accepts at most ${String(MAX_ID_BATCH)} ids (got ${String(ids.length)})`);
82
- }
83
- return index.deleteByIds(ids);
84
- };
85
- const describe = async (indexName) => {
86
- const index = resolveIndex(options.indexes, indexName);
87
- if (!index.describe) {
88
- throw new LunoraError("INTERNAL", `@lunora/bindings/vectors: binding for "${indexName}" does not implement describe()`);
89
- }
90
- return index.describe();
91
- };
92
- return { deleteByIds, describe, getByIds, query, upsert, upsertMany };
93
- };
94
-
95
- export { createVectors as default };