@based/db 0.0.14 → 0.0.16

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 (61) hide show
  1. package/dist/lib/darwin_aarch64/include/selva/hll.h +2 -1
  2. package/dist/lib/darwin_aarch64/libnode-v20.11.1.node +0 -0
  3. package/dist/lib/darwin_aarch64/libnode-v20.18.1.node +0 -0
  4. package/dist/lib/darwin_aarch64/libnode-v22.13.0.node +0 -0
  5. package/dist/lib/darwin_aarch64/libselva.dylib +0 -0
  6. package/dist/lib/darwin_aarch64/libxxhash.0.8.2.dylib +0 -0
  7. package/dist/lib/darwin_aarch64/libxxhash.0.dylib +0 -0
  8. package/dist/lib/darwin_aarch64/libxxhash.dylib +0 -0
  9. package/dist/lib/linux_aarch64/include/selva/hll.h +2 -1
  10. package/dist/lib/linux_aarch64/libnode-v20.11.1.node +0 -0
  11. package/dist/lib/linux_aarch64/libnode-v20.18.1.node +0 -0
  12. package/dist/lib/linux_aarch64/libnode-v22.13.0.node +0 -0
  13. package/dist/lib/linux_aarch64/libselva.so +0 -0
  14. package/dist/lib/linux_aarch64/libxxhash.so +0 -0
  15. package/dist/lib/linux_aarch64/libxxhash.so.0 +0 -0
  16. package/dist/lib/linux_x86_64/include/selva/hll.h +2 -1
  17. package/dist/lib/linux_x86_64/libnode-v20.11.1.node +0 -0
  18. package/dist/lib/linux_x86_64/libnode-v20.18.1.node +0 -0
  19. package/dist/lib/linux_x86_64/libnode-v22.13.0.node +0 -0
  20. package/dist/lib/linux_x86_64/libselva.so +0 -0
  21. package/dist/lib/linux_x86_64/libxxhash.so +0 -0
  22. package/dist/lib/linux_x86_64/libxxhash.so.0 +0 -0
  23. package/dist/src/client/bitWise.js +1 -0
  24. package/dist/src/client/modify/cardinality.js +8 -9
  25. package/dist/src/client/query/BasedDbQuery.d.ts +1 -1
  26. package/dist/src/client/query/BasedDbQuery.js +14 -7
  27. package/dist/src/client/query/display.js +11 -3
  28. package/dist/src/client/query/filter/FilterBranch.js +8 -3
  29. package/dist/src/client/query/filter/convertFilter.d.ts +4 -0
  30. package/dist/src/client/query/filter/convertFilter.js +56 -0
  31. package/dist/src/client/query/filter/filter.d.ts +1 -2
  32. package/dist/src/client/query/filter/filter.js +5 -56
  33. package/dist/src/client/query/filter/primitiveFilter.d.ts +2 -2
  34. package/dist/src/client/query/filter/primitiveFilter.js +5 -1
  35. package/dist/src/client/query/filter/types.d.ts +2 -1
  36. package/dist/src/client/query/filter/types.js +23 -12
  37. package/dist/src/client/query/read/read.js +21 -32
  38. package/dist/src/client/query/read/types.d.ts +4 -0
  39. package/dist/src/client/query/read/types.js +5 -0
  40. package/dist/src/client/query/validation.d.ts +7 -1
  41. package/dist/src/client/query/validation.js +129 -46
  42. package/dist/src/client/xxHash64.d.ts +1 -1
  43. package/dist/src/client/xxHash64.js +7 -2
  44. package/dist/src/index.d.ts +4 -1
  45. package/dist/src/index.js +16 -1
  46. package/dist/src/native.d.ts +1 -1
  47. package/dist/src/native.js +2 -2
  48. package/dist/src/server/schema/utils.d.ts +1 -0
  49. package/dist/src/server/schema/utils.js +18 -5
  50. package/package.json +1 -1
  51. package/dist/lib/darwin_aarch64/libnode-v22.8.0.node +0 -0
  52. package/dist/src/client/modify/create copy.d.ts +0 -5
  53. package/dist/src/client/modify/create copy.js +0 -112
  54. package/dist/src/client/modify/hll.d.ts +0 -4
  55. package/dist/src/client/modify/hll.js +0 -58
  56. package/dist/src/client/modify/remove.d.ts +0 -1
  57. package/dist/src/client/modify/remove.js +0 -39
  58. package/dist/src/client/modify/vector copy.d.ts +0 -4
  59. package/dist/src/client/modify/vector copy.js +0 -46
  60. package/dist/src/client/query/filter/operators.d.ts +0 -6
  61. package/dist/src/client/query/filter/operators.js +0 -98
@@ -8,13 +8,14 @@
8
8
  #include <stdbool.h>
9
9
  #include "cdefs.h"
10
10
 
11
+ #define HLL_INIT_SIZE 8
11
12
 
12
13
  SELVA_EXPORT
13
14
  void hll_init(struct selva_string *hllss, uint8_t precision, bool is_sparse);
14
15
  SELVA_EXPORT
15
16
  void hll_add(struct selva_string *hllss, uint64_t element);
16
17
  SELVA_EXPORT
17
- double hll_count(struct selva_string *hllss);
18
+ uint8_t *hll_count(struct selva_string *hllss);
18
19
  SELVA_EXPORT
19
20
  struct selva_string hll_array_union(struct selva_string *hll_array, size_t count);
20
21
 
@@ -8,13 +8,14 @@
8
8
  #include <stdbool.h>
9
9
  #include "cdefs.h"
10
10
 
11
+ #define HLL_INIT_SIZE 8
11
12
 
12
13
  SELVA_EXPORT
13
14
  void hll_init(struct selva_string *hllss, uint8_t precision, bool is_sparse);
14
15
  SELVA_EXPORT
15
16
  void hll_add(struct selva_string *hllss, uint64_t element);
16
17
  SELVA_EXPORT
17
- double hll_count(struct selva_string *hllss);
18
+ uint8_t *hll_count(struct selva_string *hllss);
18
19
  SELVA_EXPORT
19
20
  struct selva_string hll_array_union(struct selva_string *hll_array, size_t count);
20
21
 
Binary file
@@ -8,13 +8,14 @@
8
8
  #include <stdbool.h>
9
9
  #include "cdefs.h"
10
10
 
11
+ #define HLL_INIT_SIZE 8
11
12
 
12
13
  SELVA_EXPORT
13
14
  void hll_init(struct selva_string *hllss, uint8_t precision, bool is_sparse);
14
15
  SELVA_EXPORT
15
16
  void hll_add(struct selva_string *hllss, uint64_t element);
16
17
  SELVA_EXPORT
17
- double hll_count(struct selva_string *hllss);
18
+ uint8_t *hll_count(struct selva_string *hllss);
18
19
  SELVA_EXPORT
19
20
  struct selva_string hll_array_union(struct selva_string *hll_array, size_t count);
20
21
 
Binary file
@@ -79,4 +79,5 @@ export const concatUint8Arr = (arrs) => {
79
79
  });
80
80
  return result;
81
81
  };
82
+ const textDecoder = new TextDecoder('utf-8');
82
83
  //# sourceMappingURL=bitWise.js.map
@@ -17,25 +17,24 @@ export function writeHll(value, ctx, def, t, parentId, modifyOp) {
17
17
  }
18
18
  function addHll(value, ctx, def, t, parentId, modifyOp) {
19
19
  const len = value.length;
20
- let size = 2 + len * 8;
20
+ let size = 4 + len * 8;
21
21
  if (ctx.len + size + 11 > ctx.max) {
22
22
  return RANGE_ERR;
23
23
  }
24
24
  setCursor(ctx, def, t.prop, t.typeIndex, parentId, modifyOp);
25
25
  ctx.buf[ctx.len++] = modifyOp;
26
- ctx.buf.writeUint16LE(len, ctx.len);
27
- ctx.len += 2;
26
+ ctx.buf.writeUint32LE(len, ctx.len);
27
+ ctx.len += 4;
28
28
  for (let val of value) {
29
- let b;
30
29
  if (typeof val === 'string') {
31
- b = Buffer.from(val);
30
+ xxHash64(Buffer.from(val), ctx.buf, ctx.len);
32
31
  }
33
- else if (!(val instanceof Buffer)) {
34
- b = val;
32
+ else if (val instanceof Buffer && val.byteLength === 8) {
33
+ ctx.buf.set(val, ctx.len);
34
+ }
35
+ else {
35
36
  return new ModifyError(t, val);
36
37
  }
37
- const hash = xxHash64(b);
38
- ctx.buf.writeBigUInt64LE(hash, ctx.len);
39
38
  ctx.len += 8;
40
39
  }
41
40
  }
@@ -14,9 +14,9 @@ export declare class QueryBranch<T> {
14
14
  constructor(db: DbClient, def: QueryDef);
15
15
  sort(field: string, order?: 'asc' | 'desc'): T;
16
16
  filter<O extends Operator>(field: string, operator?: O | boolean, value?: any, opts?: FilterOpts<O>): T;
17
+ filterBatch(f: FilterAst): this;
17
18
  search(query: string, ...fields: Search[]): T;
18
19
  search(query: ArrayBufferView, field: string, opts?: Omit<FilterOpts, 'lowerCase'>): T;
19
- filterBatch(f: FilterAst): this;
20
20
  or(fn: FilterBranchFn): T;
21
21
  or(field: string, operator?: Operator | boolean, value?: any, opts?: FilterOpts): T;
22
22
  range(offset: number, limit: number): T;
@@ -1,4 +1,4 @@
1
- import { createQueryDef, QueryDefType, filter, sort, defToBuffer, filterOr, convertFilter, isAlias, includeField, includeFields, } from './query.js';
1
+ import { createQueryDef, QueryDefType, filter, sort, defToBuffer, filterOr, isAlias, includeField, includeFields, } from './query.js';
2
2
  import { BasedQueryResponse } from './BasedIterable.js';
3
3
  import { createOrGetEdgeRefQueryDef, createOrGetRefQueryDef, } from './include/utils.js';
4
4
  import { FilterBranch } from './filter/FilterBranch.js';
@@ -8,6 +8,7 @@ import { REFERENCE, REFERENCES } from '../../server/schema/types.js';
8
8
  import { subscribe } from './subscription/index.js';
9
9
  import { registerQuery } from './registerQuery.js';
10
10
  import { langCodesMap } from '@based/schema';
11
+ import { convertFilter } from './filter/convertFilter.js';
11
12
  export class QueryBranch {
12
13
  db;
13
14
  def;
@@ -22,6 +23,15 @@ export class QueryBranch {
22
23
  }
23
24
  filter(field, operator, value, opts) {
24
25
  const f = convertFilter(this.def, field, operator, value, opts);
26
+ if (!f) {
27
+ // @ts-ignore
28
+ return this;
29
+ }
30
+ filter(this.db, this.def, f, this.def.filter);
31
+ // @ts-ignore
32
+ return this;
33
+ }
34
+ filterBatch(f) {
25
35
  filter(this.db, this.def, f, this.def.filter);
26
36
  // @ts-ignore
27
37
  return this;
@@ -81,11 +91,6 @@ export class QueryBranch {
81
91
  // @ts-ignore
82
92
  return this;
83
93
  }
84
- filterBatch(f) {
85
- filter(this.db, this.def, f, this.def.filter);
86
- // @ts-ignore
87
- return this;
88
- }
89
94
  or(field, operator, value, opts) {
90
95
  if (typeof field === 'function') {
91
96
  const f = new FilterBranch(this.db, filterOr(this.db, this.def, [], this.def.filter), this.def);
@@ -94,7 +99,9 @@ export class QueryBranch {
94
99
  }
95
100
  else {
96
101
  const f = convertFilter(this.def, field, operator, value, opts);
97
- filterOr(this.db, this.def, f, this.def.filter);
102
+ if (f) {
103
+ filterOr(this.db, this.def, f, this.def.filter);
104
+ }
98
105
  }
99
106
  // @ts-ignore
100
107
  return this;
@@ -1,5 +1,5 @@
1
1
  import picocolors from 'picocolors';
2
- import { BINARY, NUMBER, REFERENCE, REFERENCES, STRING, TEXT, TIMESTAMP, } from '../../server/schema/types.js';
2
+ import { BINARY, CARDINALITY, NUMBER, REFERENCE, REFERENCES, STRING, TEXT, TIMESTAMP, } from '../../server/schema/types.js';
3
3
  const decimals = (v) => ~~(v * 100) / 100;
4
4
  const sizeCalc = (size) => {
5
5
  if (size > 1e6) {
@@ -59,6 +59,9 @@ const prettyPrintVal = (v, type) => {
59
59
  return `"${v}"`;
60
60
  }
61
61
  }
62
+ if (type === CARDINALITY) {
63
+ return `${picocolors.blue(v)} ${picocolors.italic(picocolors.dim('unique'))}`;
64
+ }
62
65
  if (type === TIMESTAMP) {
63
66
  if (v === 0) {
64
67
  return `0 ${picocolors.italic(picocolors.dim('No date'))}`;
@@ -100,8 +103,10 @@ const inspectObject = (object, q, path, level, isLast, isFirst, isObject, depth)
100
103
  // skip
101
104
  }
102
105
  else if (key === 'id') {
103
- // @ts-ignore
104
- str += v + picocolors.italic(picocolors.dim(` ${q.target.type}`));
106
+ str +=
107
+ picocolors.blue(v) +
108
+ // @ts-ignore
109
+ picocolors.italic(picocolors.dim(` ${q.target.type}`));
105
110
  str += ',\n';
106
111
  }
107
112
  else if (!def) {
@@ -146,6 +151,9 @@ const inspectObject = (object, q, path, level, isLast, isFirst, isObject, depth)
146
151
  }
147
152
  str += prettyPrintVal(v, def.typeIndex);
148
153
  }
154
+ else if (def.typeIndex === CARDINALITY) {
155
+ str += prettyPrintVal(v, def.typeIndex);
156
+ }
149
157
  else if (def.typeIndex === TIMESTAMP) {
150
158
  str += prettyPrintVal(v, def.typeIndex);
151
159
  }
@@ -1,4 +1,5 @@
1
- import { convertFilter, filter, filterOr } from './filter.js';
1
+ import { filter, filterOr } from './filter.js';
2
+ import { convertFilter } from './convertFilter.js';
2
3
  export class FilterBranch {
3
4
  constructor(db, filterBranch, def) {
4
5
  this.def = def;
@@ -16,13 +17,17 @@ export class FilterBranch {
16
17
  }
17
18
  else {
18
19
  const f = convertFilter(this.def, field, operator, value, opts);
19
- filterOr(this.db, this.def, f, this.filterBranch);
20
+ if (f) {
21
+ filterOr(this.db, this.def, f, this.filterBranch);
22
+ }
20
23
  }
21
24
  return this;
22
25
  }
23
26
  filter(field, operator, value) {
24
27
  const f = convertFilter(this.def, field, operator, value);
25
- filter(this.db, this.def, f, this.filterBranch);
28
+ if (f) {
29
+ filter(this.db, this.def, f, this.filterBranch);
30
+ }
26
31
  return this;
27
32
  }
28
33
  }
@@ -0,0 +1,4 @@
1
+ import { QueryDef } from '../types.js';
2
+ import { Operator } from './filter.js';
3
+ import { FilterOpts, FilterAst } from './types.js';
4
+ export declare const convertFilter: (def: QueryDef, field: string, operator?: Operator | boolean, value?: any, opts?: FilterOpts | undefined) => FilterAst;
@@ -0,0 +1,56 @@
1
+ import { toFilterCtx } from './types.js';
2
+ const normalizeNeedle = (s) => {
3
+ return s
4
+ .normalize('NFKD')
5
+ .split('')
6
+ .filter((ch) => ch.charCodeAt(0) <= 127)
7
+ .join('');
8
+ };
9
+ export const convertFilter = (def, field, operator, value, opts) => {
10
+ if (operator === undefined) {
11
+ operator = '=';
12
+ value = true;
13
+ }
14
+ else if (typeof operator === 'boolean') {
15
+ value = operator;
16
+ operator = '=';
17
+ }
18
+ if (value === '' || value === undefined) {
19
+ return;
20
+ }
21
+ if (operator === '!..') {
22
+ return [
23
+ [field, toFilterCtx(def, '>', opts), value[1]],
24
+ [field, toFilterCtx(def, '<', opts), value[0]],
25
+ ];
26
+ }
27
+ else if (operator === '..') {
28
+ return [
29
+ [field, toFilterCtx(def, '>', opts), value[0]],
30
+ [field, toFilterCtx(def, '<', opts), value[1]],
31
+ ];
32
+ }
33
+ else {
34
+ if (operator == 'like') {
35
+ if (value == null) {
36
+ throw new Error('Value is required');
37
+ }
38
+ if (value?.normalize) {
39
+ value = normalizeNeedle(value);
40
+ }
41
+ else if (Array.isArray(value)) {
42
+ if (value[0]?.normalize) {
43
+ value = value.map(normalizeNeedle);
44
+ }
45
+ else if (value[0]?.BYTES_PER_ELEMENT > 1) {
46
+ value = value.map((v) => v.buffer);
47
+ }
48
+ }
49
+ else if (value?.BYTES_PER_ELEMENT > 1) {
50
+ value = value.buffer;
51
+ }
52
+ }
53
+ return [[field, toFilterCtx(def, operator, opts), value]];
54
+ }
55
+ };
56
+ //# sourceMappingURL=convertFilter.js.map
@@ -1,10 +1,9 @@
1
1
  import { QueryDef, QueryDefFilter } from '../types.js';
2
2
  import { SchemaTypeDef } from '../../../server/schema/schema.js';
3
- import { FilterOpts, Operator } from './types.js';
3
+ import { Operator } from './types.js';
4
4
  import { Filter, FilterAst } from './types.js';
5
5
  import { DbClient } from '../../index.js';
6
6
  export { Operator, Filter };
7
7
  export declare const filterRaw: (db: DbClient, filter: Filter, schema: SchemaTypeDef, conditions: QueryDefFilter, def: QueryDef) => number;
8
8
  export declare const filter: (db: DbClient, def: QueryDef, filterAst: FilterAst, conditions: QueryDefFilter) => void;
9
9
  export declare const filterOr: (db: DbClient, def: QueryDef, filterAst: FilterAst[], conditions: QueryDefFilter) => QueryDefFilter;
10
- export declare const convertFilter: (def: QueryDef, field: string, operator?: Operator | boolean, value?: any, opts?: FilterOpts) => FilterAst;
@@ -1,6 +1,5 @@
1
1
  import { isPropDef, ID_FIELD_DEF, TEXT, REFERENCE, } from '../../../server/schema/schema.js';
2
2
  import { primitiveFilter } from './primitiveFilter.js';
3
- import { toFilterCtx } from './types.js';
4
3
  import { IsFilter } from './types.js';
5
4
  import { langCodesMap } from '@based/schema';
6
5
  import { filterFieldDoesNotExist, filterInvalidLang } from '../validation.js';
@@ -22,7 +21,8 @@ const referencesFilter = (db, filter, schema, conditions, def) => {
22
21
  const edgeDef = edges[p];
23
22
  if (edgeDef) {
24
23
  conditions.edges ??= new Map();
25
- size += 3 + primitiveFilter(edgeDef, filter, conditions, def.lang);
24
+ size +=
25
+ 3 + primitiveFilter(def, edgeDef, filter, conditions, def.lang);
26
26
  }
27
27
  }
28
28
  }
@@ -71,16 +71,16 @@ export const filterRaw = (db, filter, schema, conditions, def) => {
71
71
  filterInvalidLang(def, field);
72
72
  return 0;
73
73
  }
74
- return primitiveFilter(fieldDef, filter, conditions, code);
74
+ return primitiveFilter(def, fieldDef, filter, conditions, code);
75
75
  }
76
76
  }
77
77
  if (field === 'id') {
78
78
  fieldDef = ID_FIELD_DEF;
79
- return primitiveFilter(fieldDef, filter, conditions, def.lang);
79
+ return primitiveFilter(def, fieldDef, filter, conditions, def.lang);
80
80
  }
81
81
  return referencesFilter(db, filter, schema, conditions, def);
82
82
  }
83
- return primitiveFilter(fieldDef, filter, conditions, def.lang);
83
+ return primitiveFilter(def, fieldDef, filter, conditions, def.lang);
84
84
  };
85
85
  export const filter = (db, def, filterAst, conditions) => {
86
86
  for (const f of filterAst) {
@@ -104,55 +104,4 @@ export const filterOr = (db, def, filterAst, conditions) => {
104
104
  conditions.size += conditions.or.size;
105
105
  return conditions.or;
106
106
  };
107
- const normalizeNeedle = (s) => {
108
- return s
109
- .normalize('NFKD')
110
- .split('')
111
- .filter((ch) => ch.charCodeAt(0) <= 127)
112
- .join('');
113
- };
114
- export const convertFilter = (def, field, operator, value, opts) => {
115
- if (operator === undefined) {
116
- operator = '=';
117
- value = true;
118
- }
119
- else if (typeof operator === 'boolean') {
120
- value = operator;
121
- operator = '=';
122
- }
123
- if (operator === '!..') {
124
- return [
125
- [field, toFilterCtx(def, '>', opts), value[1]],
126
- [field, toFilterCtx(def, '<', opts), value[0]],
127
- ];
128
- }
129
- else if (operator === '..') {
130
- return [
131
- [field, toFilterCtx(def, '>', opts), value[0]],
132
- [field, toFilterCtx(def, '<', opts), value[1]],
133
- ];
134
- }
135
- else {
136
- if (operator == 'like') {
137
- if (value == null) {
138
- throw new Error('Value is required');
139
- }
140
- if (value?.normalize) {
141
- value = normalizeNeedle(value);
142
- }
143
- else if (Array.isArray(value)) {
144
- if (value[0]?.normalize) {
145
- value = value.map(normalizeNeedle);
146
- }
147
- else if (value[0]?.BYTES_PER_ELEMENT > 1) {
148
- value = value.map((v) => v.buffer);
149
- }
150
- }
151
- else if (value?.BYTES_PER_ELEMENT > 1) {
152
- value = value.buffer;
153
- }
154
- }
155
- return [[field, toFilterCtx(def, operator, opts), value]];
156
- }
157
- };
158
107
  //# sourceMappingURL=filter.js.map
@@ -1,5 +1,5 @@
1
1
  import { PropDef, PropDefEdge } from '../../../server/schema/types.js';
2
- import { QueryDefFilter } from '../types.js';
2
+ import { QueryDef, QueryDefFilter } from '../types.js';
3
3
  import { Filter } from './types.js';
4
4
  import { LangCode } from '@based/schema';
5
- export declare const primitiveFilter: (prop: PropDef | PropDefEdge, filter: Filter, conditions: QueryDefFilter, lang: LangCode) => number;
5
+ export declare const primitiveFilter: (def: QueryDef, prop: PropDef | PropDefEdge, filter: Filter, conditions: QueryDefFilter, lang: LangCode) => number;
@@ -3,7 +3,11 @@ import { EQUAL, isNumerical } from './types.js';
3
3
  import { createVariableFilterBuffer } from './createVariableFilterBuffer.js';
4
4
  import { createFixedFilterBuffer } from './createFixedFilterBuffer.js';
5
5
  import { createReferenceFilter } from './createReferenceFilter.js';
6
- export const primitiveFilter = (prop, filter, conditions, lang) => {
6
+ import { validateFilter } from '../validation.js';
7
+ export const primitiveFilter = (def, prop, filter, conditions, lang) => {
8
+ if (validateFilter(def, prop, filter)) {
9
+ return;
10
+ }
7
11
  let [, ctx, value] = filter;
8
12
  const fieldIndexChar = prop.prop;
9
13
  let buf;
@@ -4,8 +4,8 @@ export type Filter = [fieldStr: string, ctx: FilterCtx, value: any];
4
4
  export type FilterBranchFn = (filterBranch: FilterBranch) => void;
5
5
  export type FilterAst = (Filter | FilterAst)[];
6
6
  export declare const IsFilter: (f: FilterAst) => f is Filter;
7
- export declare const validOperators: readonly ["=", "has", "!has", "<", ">", "!=", "like", ">=", "<=", "..", "!.."];
8
7
  export type Operator = '=' | 'has' | '!has' | '<' | '>' | '!=' | 'like' | '>=' | '<=' | '..' | '!..' | 'like';
8
+ export declare const VECTOR_FNS: string[];
9
9
  export type FilterOpts<O = Operator> = {
10
10
  lowerCase?: boolean;
11
11
  fn?: 'dotProduct' | 'manhattanDistance' | 'cosineSimilarity' | 'euclideanDistance';
@@ -54,3 +54,4 @@ export declare const VECTOR_COSTINE_SIMILARITY = 2;
54
54
  export declare const VECTOR_EUCLIDEAN_DIST = 3;
55
55
  export declare const getVectorFn: (optsFn?: FilterOpts["fn"]) => 0 | 1 | 2 | 3;
56
56
  export declare const toFilterCtx: (def: QueryDef, op: Operator, opts?: FilterOpts) => FilterCtx;
57
+ export declare const operatorReverseMap: Record<OPERATOR, string>;
@@ -5,18 +5,11 @@ export const IsFilter = (f) => {
5
5
  }
6
6
  return false;
7
7
  };
8
- export const validOperators = [
9
- '=',
10
- 'has',
11
- '!has',
12
- '<',
13
- '>',
14
- '!=',
15
- 'like',
16
- '>=',
17
- '<=',
18
- '..',
19
- '!..',
8
+ export const VECTOR_FNS = [
9
+ 'dotProduct',
10
+ 'manhattanDistance',
11
+ 'cosineSimilarity',
12
+ 'euclideanDistance',
20
13
  ];
21
14
  // -------------------------------------------
22
15
  // operations shared
@@ -119,4 +112,22 @@ export const toFilterCtx = (def, op, opts = {}) => {
119
112
  }
120
113
  filterOperatorDoesNotExist(def, op);
121
114
  };
115
+ export const operatorReverseMap = {
116
+ [EQUAL]: '=',
117
+ [HAS]: 'has',
118
+ [ENDS_WITH]: 'endsWith',
119
+ [STARTS_WITH]: 'startsWith',
120
+ [GREATER_THAN]: '>',
121
+ [SMALLER_THAN]: '<',
122
+ [GREATER_THAN_INCLUSIVE]: '>=',
123
+ [SMALLER_THAN_INCLUSIVE]: '<=',
124
+ [RANGE]: '..',
125
+ [RANGE_EXCLUDE]: '!..',
126
+ [EQUAL_LOWER_CASE]: '= (lowerCase)',
127
+ [HAS_TO_LOWER_CASE]: 'has (lowerCase)',
128
+ [STARTS_WITH_LOWER_CASE]: 'startsWith (lowerCase)',
129
+ [ENDS_WITH_LOWER_CASE]: 'endsWith (lowerCase)',
130
+ [LIKE]: 'like',
131
+ [EQUAL_CRC32]: '= (crc32)',
132
+ };
122
133
  //# sourceMappingURL=types.js.map