@based/db 0.0.15 → 0.0.17

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 (94) hide show
  1. package/dist/lib/darwin_aarch64/include/selva/db.h +3 -0
  2. package/dist/lib/darwin_aarch64/include/selva/fields.h +1 -2
  3. package/dist/lib/darwin_aarch64/include/selva/history.h +16 -1
  4. package/dist/lib/darwin_aarch64/include/selva/hll.h +2 -1
  5. package/dist/lib/darwin_aarch64/include/selva/types.h +4 -0
  6. package/dist/lib/darwin_aarch64/libnode-v20.11.1.node +0 -0
  7. package/dist/lib/darwin_aarch64/libnode-v20.18.1.node +0 -0
  8. package/dist/lib/darwin_aarch64/libnode-v22.13.0.node +0 -0
  9. package/dist/lib/darwin_aarch64/libselva.dylib +0 -0
  10. package/dist/lib/linux_aarch64/include/selva/db.h +3 -0
  11. package/dist/lib/linux_aarch64/include/selva/fields.h +1 -2
  12. package/dist/lib/linux_aarch64/include/selva/history.h +16 -1
  13. package/dist/lib/linux_aarch64/include/selva/hll.h +2 -1
  14. package/dist/lib/linux_aarch64/include/selva/types.h +4 -0
  15. package/dist/lib/linux_aarch64/libnode-v20.11.1.node +0 -0
  16. package/dist/lib/linux_aarch64/libnode-v20.18.1.node +0 -0
  17. package/dist/lib/linux_aarch64/libnode-v22.13.0.node +0 -0
  18. package/dist/lib/linux_aarch64/libselva.so +0 -0
  19. package/dist/lib/linux_x86_64/include/selva/db.h +3 -0
  20. package/dist/lib/linux_x86_64/include/selva/fields.h +1 -2
  21. package/dist/lib/linux_x86_64/include/selva/history.h +16 -1
  22. package/dist/lib/linux_x86_64/include/selva/hll.h +2 -1
  23. package/dist/lib/linux_x86_64/include/selva/types.h +4 -0
  24. package/dist/lib/linux_x86_64/libnode-v20.11.1.node +0 -0
  25. package/dist/lib/linux_x86_64/libnode-v20.18.1.node +0 -0
  26. package/dist/lib/linux_x86_64/libnode-v22.13.0.node +0 -0
  27. package/dist/lib/linux_x86_64/libselva.so +0 -0
  28. package/dist/src/client/bitWise.js +1 -0
  29. package/dist/src/client/crc32.js +0 -276
  30. package/dist/src/client/modify/ModifyRes.d.ts +4 -2
  31. package/dist/src/client/modify/ModifyRes.js +11 -6
  32. package/dist/src/client/modify/alias.js +2 -2
  33. package/dist/src/client/modify/cardinality.js +14 -10
  34. package/dist/src/client/modify/create.js +8 -9
  35. package/dist/src/client/modify/references/reference.js +14 -7
  36. package/dist/src/client/modify/references/references.js +10 -4
  37. package/dist/src/client/modify/string.js +2 -2
  38. package/dist/src/client/modify/text.js +1 -1
  39. package/dist/src/client/modify/types.d.ts +3 -1
  40. package/dist/src/client/modify/types.js +2 -0
  41. package/dist/src/client/modify/update.js +1 -1
  42. package/dist/src/client/operations.d.ts +2 -2
  43. package/dist/src/client/operations.js +19 -3
  44. package/dist/src/client/query/BasedDbQuery.d.ts +5 -4
  45. package/dist/src/client/query/BasedDbQuery.js +28 -13
  46. package/dist/src/client/query/BasedIterable.js +3 -10
  47. package/dist/src/client/query/display.d.ts +6 -0
  48. package/dist/src/client/query/display.js +63 -4
  49. package/dist/src/client/query/filter/FilterBranch.js +8 -3
  50. package/dist/src/client/query/filter/convertFilter.d.ts +4 -0
  51. package/dist/src/client/query/filter/convertFilter.js +56 -0
  52. package/dist/src/client/query/filter/createFixedFilterBuffer.js +9 -8
  53. package/dist/src/client/query/filter/createReferenceFilter.js +5 -4
  54. package/dist/src/client/query/filter/createVariableFilterBuffer.js +6 -10
  55. package/dist/src/client/query/filter/filter.d.ts +1 -2
  56. package/dist/src/client/query/filter/filter.js +5 -56
  57. package/dist/src/client/query/filter/primitiveFilter.d.ts +2 -2
  58. package/dist/src/client/query/filter/primitiveFilter.js +5 -1
  59. package/dist/src/client/query/filter/toBuffer.js +1 -6
  60. package/dist/src/client/query/filter/types.d.ts +2 -1
  61. package/dist/src/client/query/filter/types.js +23 -12
  62. package/dist/src/client/query/include/props.js +14 -6
  63. package/dist/src/client/query/include/utils.js +2 -2
  64. package/dist/src/client/query/include/walk.js +1 -7
  65. package/dist/src/client/query/queryDef.d.ts +1 -1
  66. package/dist/src/client/query/queryDef.js +4 -3
  67. package/dist/src/client/query/read/read.js +21 -32
  68. package/dist/src/client/query/read/types.d.ts +4 -0
  69. package/dist/src/client/query/read/types.js +5 -0
  70. package/dist/src/client/query/registerQuery.js +1 -0
  71. package/dist/src/client/query/search/index.js +12 -6
  72. package/dist/src/client/query/sort.js +7 -6
  73. package/dist/src/client/query/thresholds.d.ts +0 -1
  74. package/dist/src/client/query/thresholds.js +0 -8
  75. package/dist/src/client/query/toBuffer.js +0 -3
  76. package/dist/src/client/query/types.d.ts +2 -0
  77. package/dist/src/client/query/validation.d.ts +39 -1
  78. package/dist/src/client/query/validation.js +299 -93
  79. package/dist/src/client/xxHash64.d.ts +1 -1
  80. package/dist/src/client/xxHash64.js +7 -2
  81. package/dist/src/index.d.ts +6 -1
  82. package/dist/src/index.js +31 -1
  83. package/dist/src/native.d.ts +3 -1
  84. package/dist/src/native.js +8 -2
  85. package/dist/src/server/index.d.ts +8 -6
  86. package/dist/src/server/index.js +56 -30
  87. package/dist/src/server/migrate/index.js +10 -2
  88. package/dist/src/server/migrate/worker.js +1 -1
  89. package/dist/src/server/schema/typeDef.js +35 -25
  90. package/dist/src/server/schema/types.d.ts +10 -5
  91. package/dist/src/server/schema/types.js +1 -1
  92. package/dist/src/server/schema/utils.d.ts +1 -0
  93. package/dist/src/server/schema/utils.js +18 -5
  94. package/package.json +5 -3
@@ -1,12 +1,12 @@
1
1
  import native from '../native.js';
2
2
  import { rm, writeFile } from 'node:fs/promises';
3
3
  import { dirname, join } from 'node:path';
4
- import { getPropType } from '@based/schema';
4
+ import { getPropType, langCodesMap, } from '@based/schema';
5
5
  import { genRootId } from './schema/utils.js';
6
6
  import { updateTypeDefs } from './schema/typeDef.js';
7
7
  import { schemaToSelvaBuffer } from './schema/selvaBuffer.js';
8
8
  import { start } from './start.js';
9
- import { foreachDirtyBlock, makeCsmtKey } from './tree.js';
9
+ import { foreachDirtyBlock, makeCsmtKey, makeCsmtKeyFromNodeId, } from './tree.js';
10
10
  import { save } from './save.js';
11
11
  import { Worker, MessageChannel } from 'node:worker_threads';
12
12
  import { fileURLToPath } from 'node:url';
@@ -112,14 +112,16 @@ export class DbServer {
112
112
  for (const type in this.sortIndexes) {
113
113
  for (const field in this.sortIndexes[type]) {
114
114
  for (const start in this.sortIndexes[type][field]) {
115
- const sortIndex = this.sortIndexes[type][field][start];
116
- sortIndex.cnt /= 2;
117
- if (sortIndex.cnt < 1) {
118
- native.destroySortIndex(sortIndex.buf, this.dbCtxExternal);
119
- delete this.sortIndexes[type][field][start];
120
- }
121
- else {
122
- remaining = true;
115
+ for (const lang in this.sortIndexes[type][field][start]) {
116
+ const sortIndex = this.sortIndexes[type][field][start][lang];
117
+ sortIndex.cnt /= 2;
118
+ if (sortIndex.cnt < 1) {
119
+ native.destroySortIndex(sortIndex.buf, this.dbCtxExternal);
120
+ delete this.sortIndexes[type][field][start][lang];
121
+ }
122
+ else {
123
+ remaining = true;
124
+ }
123
125
  }
124
126
  }
125
127
  }
@@ -130,33 +132,41 @@ export class DbServer {
130
132
  }, 60e3);
131
133
  }
132
134
  }
133
- createSortIndex(type, field) {
135
+ createSortIndex(type, field, lang = 'none') {
134
136
  const t = this.schemaTypesParsed[type];
135
137
  const prop = t.props[field];
138
+ const langCode = langCodesMap.get(lang ?? Object.keys(this.schema?.locales ?? 'en')[0]) ??
139
+ 0;
136
140
  let types = this.sortIndexes[t.id];
137
141
  if (!types) {
138
142
  types = this.sortIndexes[t.id] = {};
139
143
  }
140
- let fields = types[prop.prop];
144
+ let f = types[prop.prop];
145
+ if (!f) {
146
+ f = types[prop.prop] = {};
147
+ }
148
+ let fields = f[prop.start];
141
149
  if (!fields) {
142
- fields = types[prop.prop] = {};
150
+ fields = f[prop.start] = {};
143
151
  }
144
- let sortIndex = fields[prop.start];
152
+ let sortIndex = fields[langCode];
145
153
  if (sortIndex) {
146
154
  return sortIndex;
147
155
  }
148
156
  const buf = Buffer.allocUnsafe(8);
149
- // size [2 type] [1 field] [2 start] [2 len]
157
+ // size [2 type] [1 field] [2 start] [2 len] [propIndex] [lang]
158
+ // call createSortBuf here
150
159
  buf.writeUint16LE(t.id, 0);
151
160
  buf[2] = prop.prop;
152
161
  buf.writeUint16LE(prop.start, 3);
153
162
  buf.writeUint16LE(prop.len, 5);
154
163
  buf[7] = prop.typeIndex;
164
+ buf[8] = langCode;
155
165
  sortIndex = new SortIndex(buf, this.dbCtxExternal);
156
- fields[prop.start] = sortIndex;
166
+ fields[langCode] = sortIndex;
157
167
  return sortIndex;
158
168
  }
159
- destroySortIndex(type, field) {
169
+ destroySortIndex(type, field, lang = 'none') {
160
170
  const t = this.schemaTypesParsed[type];
161
171
  const prop = t.props[field];
162
172
  let types = this.sortIndexes[t.id];
@@ -169,30 +179,37 @@ export class DbServer {
169
179
  }
170
180
  let sortIndex = fields[prop.start];
171
181
  if (sortIndex) {
172
- const buf = Buffer.allocUnsafe(5);
182
+ // [2 type] [1 field] [2 start] [1 lang]
183
+ const buf = Buffer.allocUnsafe(6);
173
184
  buf.writeUint16LE(t.id, 0);
174
185
  buf[2] = prop.prop;
175
186
  buf.writeUint16LE(prop.start, 3);
187
+ buf[5] =
188
+ langCodesMap.get(lang ?? Object.keys(this.schema?.locales ?? 'en')[0]) ?? 0;
176
189
  native.destroySortIndex(buf, this.dbCtxExternal);
177
190
  delete fields[prop.start];
178
191
  }
179
192
  }
180
- getSortIndex(typeId, field, start) {
193
+ getSortIndex(typeId, field, start, lang) {
181
194
  let types = this.sortIndexes[typeId];
182
195
  if (!types) {
183
196
  types = this.sortIndexes[typeId] = {};
184
197
  }
185
- let fields = types[field];
198
+ let f = types[field];
199
+ if (!f) {
200
+ f = types[field] = {};
201
+ }
202
+ let fields = f[start];
186
203
  if (!fields) {
187
- fields = types[field] = {};
204
+ fields = f[start] = {};
188
205
  }
189
- return fields[start];
206
+ return fields[lang];
190
207
  }
191
208
  migrateSchema(schema, transform) {
192
209
  return migrate(this, schema, transform);
193
210
  }
194
- createSortIndexBuffer(typeId, field, start) {
195
- const buf = Buffer.allocUnsafe(8);
211
+ createSortIndexBuffer(typeId, field, start, lang) {
212
+ const buf = Buffer.allocUnsafe(9);
196
213
  buf.writeUint16LE(typeId, 0);
197
214
  buf[2] = field;
198
215
  buf.writeUint16LE(start, 3);
@@ -219,11 +236,13 @@ export class DbServer {
219
236
  }
220
237
  buf.writeUint16LE(prop.len, 5);
221
238
  buf[7] = prop.typeIndex;
239
+ buf[8] = lang;
222
240
  // put in modify stuff
223
- const sortIndex = new SortIndex(buf, this.dbCtxExternal);
241
+ const sortIndex = this.getSortIndex(typeId, prop.prop, prop.start, lang) ??
242
+ new SortIndex(buf, this.dbCtxExternal);
224
243
  const types = this.sortIndexes[typeId];
225
244
  const fields = types[field];
226
- fields[start] = sortIndex;
245
+ fields[start][lang] = sortIndex;
227
246
  return sortIndex;
228
247
  }
229
248
  updateMerkleTree() {
@@ -360,11 +379,18 @@ export class DbServer {
360
379
  #modify(buf) {
361
380
  const end = buf.length - 4;
362
381
  const dataLen = buf.readUint32LE(end);
363
- const typesSize = buf.readUint16LE(dataLen);
382
+ let typesSize = buf.readUint16LE(dataLen);
364
383
  const typesLen = typesSize * 10;
365
384
  const types = buf.subarray(dataLen + 2, dataLen + typesLen + 2);
366
385
  const data = buf.subarray(0, dataLen);
367
- let i = dataLen + 2 + typesLen;
386
+ let i = dataLen + 2;
387
+ while (typesSize--) {
388
+ const typeId = buf.readUint16LE(i);
389
+ const def = this.schemaTypesParsedById[typeId];
390
+ const key = makeCsmtKeyFromNodeId(def.id, def.blockCapacity, def.lastId);
391
+ this.dirtyRanges.add(key);
392
+ i += 10;
393
+ }
368
394
  while (i < end) {
369
395
  const key = buf.readDoubleLE(i);
370
396
  this.dirtyRanges.add(key);
@@ -388,14 +414,14 @@ export class DbServer {
388
414
  const sort = buf.slice(s + 2, s + 2 + sortLen);
389
415
  const field = sort[1];
390
416
  const start = sort.readUint16LE(2 + 1);
391
- let sortIndex = this.getSortIndex(typeId, field, start);
417
+ let sortIndex = this.getSortIndex(typeId, field, start, 0);
392
418
  if (!sortIndex) {
393
419
  if (this.processingQueries) {
394
420
  return new Promise((resolve) => {
395
421
  this.queryQueue.set(resolve, buf);
396
422
  });
397
423
  }
398
- sortIndex = this.createSortIndexBuffer(typeId, field, start);
424
+ sortIndex = this.createSortIndexBuffer(typeId, field, start, sort[sort.byteLength - 1]);
399
425
  }
400
426
  // increment
401
427
  sortIndex.cnt++;
@@ -1,7 +1,7 @@
1
1
  import { BasedDb } from '../../index.js';
2
2
  import { dirname, join } from 'path';
3
3
  import { tmpdir } from 'os';
4
- import { Worker, MessageChannel } from 'node:worker_threads';
4
+ import { Worker, MessageChannel, receiveMessageOnPort, } from 'node:worker_threads';
5
5
  import native from '../../native.js';
6
6
  import './worker.js';
7
7
  import { foreachDirtyBlock } from '../tree.js';
@@ -99,7 +99,15 @@ export const migrate = async (fromDbServer, toSchema, transform) => {
99
99
  }
100
100
  }
101
101
  if (!abort()) {
102
- fromDbServer.putSchema(toSchema, true);
102
+ let msg;
103
+ let schema;
104
+ let schemaTypesParsed;
105
+ while ((msg = receiveMessageOnPort(port1))) {
106
+ ;
107
+ [schema, schemaTypesParsed] = msg.message;
108
+ }
109
+ fromDbServer.schema = schema;
110
+ fromDbServer.schemaTypesParsed = schemaTypesParsed;
103
111
  fromDbServer.dbCtxExternal = toCtx;
104
112
  toDb.server.dbCtxExternal = fromCtx;
105
113
  }
@@ -71,7 +71,7 @@ else {
71
71
  }
72
72
  }
73
73
  await toDb.drain();
74
- // await setTimeout()
74
+ channel.postMessage([toDb.server.schema, toDb.server.schemaTypesParsed]);
75
75
  // put it to sleep
76
76
  atomics[0] = 0;
77
77
  Atomics.notify(atomics, 0);
@@ -1,7 +1,7 @@
1
1
  import { isPropType, getPropType, } from '@based/schema';
2
2
  import { setByPath } from '@saulx/utils';
3
3
  import { hashObjectIgnoreKeyOrder } from '@saulx/hash';
4
- import { SIZE_MAP, TYPE_INDEX_MAP, } from './types.js';
4
+ import { SIZE_MAP, TYPE_INDEX_MAP, STRING, ALIAS, CARDINALITY, } from './types.js';
5
5
  import { genId } from './utils.js';
6
6
  import { DEFAULT_BLOCK_CAPACITY } from '../start.js';
7
7
  const addEdges = (prop, refProp) => {
@@ -95,9 +95,21 @@ export const createSchemaTypeDef = (typeName, type, parsed, locales, result = {
95
95
  tree: {},
96
96
  total: 0,
97
97
  lastId: 0,
98
- stringPropsSize: 0,
99
- stringPropsLoop: [],
100
98
  main: {},
99
+ hasSeperateSort: false,
100
+ seperateSort: {
101
+ size: 0,
102
+ props: [],
103
+ buffer: Buffer.allocUnsafe(0),
104
+ bufferTmp: Buffer.allocUnsafe(0),
105
+ },
106
+ hasSeperateTextSort: false,
107
+ seperateTextSort: {
108
+ size: 0,
109
+ props: [],
110
+ buffer: Buffer.allocUnsafe(0),
111
+ bufferTmp: Buffer.allocUnsafe(0),
112
+ },
101
113
  }, path = [], top = true) => {
102
114
  if (result.id == 0 && top) {
103
115
  if ('id' in type) {
@@ -112,7 +124,8 @@ export const createSchemaTypeDef = (typeName, type, parsed, locales, result = {
112
124
  result.idUint8[1] = result.id >> 8;
113
125
  const encoder = new TextEncoder();
114
126
  const target = type.props;
115
- let stringFields = 0;
127
+ let separateSortProps = 0;
128
+ let separateSortText = 0;
116
129
  for (const key in target) {
117
130
  const schemaProp = target[key];
118
131
  const propPath = [...path, key];
@@ -124,9 +137,7 @@ export const createSchemaTypeDef = (typeName, type, parsed, locales, result = {
124
137
  let len = SIZE_MAP[propType];
125
138
  if (isPropType('string', schemaProp) ||
126
139
  isPropType('alias', schemaProp) ||
127
- isPropType('binary', schemaProp) ||
128
- isPropType('cardinality', schemaProp) // TODO: maieutica
129
- ) {
140
+ isPropType('cardinality', schemaProp)) {
130
141
  if (typeof schemaProp === 'object') {
131
142
  if (schemaProp.maxBytes < 61) {
132
143
  len = schemaProp.maxBytes + 1;
@@ -135,18 +146,13 @@ export const createSchemaTypeDef = (typeName, type, parsed, locales, result = {
135
146
  len = schemaProp.max * 2 + 1;
136
147
  }
137
148
  else {
138
- stringFields++;
149
+ separateSortProps++;
139
150
  }
140
151
  }
141
152
  else {
142
- stringFields++;
153
+ separateSortProps++;
143
154
  }
144
155
  }
145
- else if (isPropType('text', schemaProp) ||
146
- isPropType('cardinality', schemaProp)) {
147
- // TODO: maieutica
148
- stringFields++;
149
- }
150
156
  else if (isPropType('vector', schemaProp)) {
151
157
  len = 4 * schemaProp.size;
152
158
  }
@@ -290,27 +296,31 @@ export const createSchemaTypeDef = (typeName, type, parsed, locales, result = {
290
296
  result.propNames.set(f, lastWritten + 1);
291
297
  lastWritten += f.byteLength + 1;
292
298
  }
293
- // result.responseCtx = new BasedNode(result as SchemaTypeDef, parsed)
294
- if (stringFields > 0) {
295
- result.hasStringProp = true;
299
+ if (separateSortProps > 0) {
300
+ result.hasSeperateSort = true;
296
301
  let max = 0;
297
302
  for (const f of result.separate) {
298
- if (f.typeIndex === 11) {
303
+ // Does not only need to be on string can also be HLL
304
+ if (f.typeIndex === STRING ||
305
+ f.typeIndex === ALIAS ||
306
+ f.typeIndex === CARDINALITY) {
299
307
  if (f.prop > max) {
300
308
  max = f.prop;
301
309
  }
302
310
  }
303
311
  }
304
- result.stringProps = Buffer.allocUnsafe(max + 1);
312
+ result.seperateSort.buffer = Buffer.allocUnsafe(max + 1);
305
313
  for (const f of result.separate) {
306
- if (f.typeIndex === 11) {
307
- result.stringProps[f.prop] = 1;
308
- result.stringPropsLoop.push(f);
309
- result.stringPropsSize++;
314
+ if (f.typeIndex === STRING ||
315
+ f.typeIndex === ALIAS ||
316
+ f.typeIndex === CARDINALITY) {
317
+ result.seperateSort.buffer[f.prop] = 1;
318
+ result.seperateSort.props.push(f);
319
+ result.seperateSort.size++;
310
320
  }
311
321
  }
312
- result.stringPropsCurrent = Buffer.allocUnsafe(max + 1);
313
- result.stringProps.copy(result.stringPropsCurrent);
322
+ result.seperateSort.bufferTmp = Buffer.allocUnsafe(max + 1);
323
+ result.seperateSort.buffer.copy(result.seperateSort.bufferTmp);
314
324
  }
315
325
  for (const p in result.props) {
316
326
  const x = result.props[p];
@@ -94,6 +94,12 @@ export type PropDefEdge = Partial<PropDef> & {
94
94
  export type SchemaPropTree = {
95
95
  [key: string]: SchemaPropTree | PropDef;
96
96
  };
97
+ export type SchemaSortUndefinedHandler = {
98
+ size: number;
99
+ buffer: Buffer;
100
+ bufferTmp: Buffer;
101
+ props: PropDef[];
102
+ };
97
103
  export type SchemaTypeDef = {
98
104
  cnt: number;
99
105
  checksum: number;
@@ -117,11 +123,10 @@ export type SchemaTypeDef = {
117
123
  [start: string]: PropDef;
118
124
  };
119
125
  tree: SchemaPropTree;
120
- hasStringProp: boolean;
121
- stringPropsSize: number;
122
- stringProps: Buffer;
123
- stringPropsCurrent: Buffer;
124
- stringPropsLoop: PropDef[];
126
+ hasSeperateSort: boolean;
127
+ seperateSort: SchemaSortUndefinedHandler;
128
+ hasSeperateTextSort: boolean;
129
+ seperateTextSort: SchemaSortUndefinedHandler;
125
130
  createTs?: PropDef[];
126
131
  updateTs?: PropDef[];
127
132
  locales: Partial<SchemaLocales>;
@@ -4,7 +4,7 @@ export const TIMESTAMP = 1;
4
4
  export const CREATED = 2;
5
5
  export const UPDATED = 3;
6
6
  export const NUMBER = 4;
7
- export const CARDINALITY = 5; //se colocar 11 ele faz o console de Ao menos entra aqui?
7
+ export const CARDINALITY = 5;
8
8
  export const INT8 = 20;
9
9
  export const UINT8 = 6;
10
10
  export const INT16 = 21;
@@ -2,5 +2,6 @@ import { DbClient } from '../../client/index.js';
2
2
  import { DbServer } from '../index.js';
3
3
  import { PropDef, PropDefEdge } from './types.js';
4
4
  export declare const propIsSigned: (prop: PropDef | PropDefEdge) => boolean;
5
+ export declare const propIsNumerical: (prop: PropDef | PropDefEdge) => boolean;
5
6
  export declare const genRootId: () => number;
6
7
  export declare const genId: (db: DbServer | DbClient) => number;
@@ -1,9 +1,22 @@
1
- import { INT16, INT32, INT64, INT8 } from './types.js';
1
+ import { INT16, INT32, INT64, INT8, UINT16, UINT32, UINT8, NUMBER, TIMESTAMP, } from './types.js';
2
2
  export const propIsSigned = (prop) => {
3
- if (prop.typeIndex === INT16 ||
4
- prop.typeIndex === INT32 ||
5
- prop.typeIndex === INT64 ||
6
- prop.typeIndex === INT8) {
3
+ const t = prop.typeIndex;
4
+ if (t === INT16 || t === INT32 || t === INT64 || t === INT8) {
5
+ return true;
6
+ }
7
+ return false;
8
+ };
9
+ export const propIsNumerical = (prop) => {
10
+ const t = prop.typeIndex;
11
+ if (t === INT16 ||
12
+ t === INT32 ||
13
+ t === INT64 ||
14
+ t === INT8 ||
15
+ t === UINT8 ||
16
+ t === UINT16 ||
17
+ t === UINT32 ||
18
+ t === NUMBER ||
19
+ t === TIMESTAMP) {
7
20
  return true;
8
21
  }
9
22
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@based/db",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/src/index.js",
@@ -17,7 +17,7 @@
17
17
  "test": "npm run build && LOCPATH=../locale/locale-x86_64-gnu/locale lldb -b -o run --one-line-on-crash bt -o \"script import os; os._exit(0)\" node ./scripts/test.js",
18
18
  "test-gdb": "npm run build && LOCPATH=../locale/locale-x86_64-gnu/locale gdb -ex run --args node ./scripts/test.js",
19
19
  "test-fast": "LOCPATH=../locale/locale-x86_64-gnu/locale node ./scripts/test.js",
20
- "test-zig": "npm run build-zig && tsc && npm run test-fast",
20
+ "test-zig": "npm run build-zig -- debug && tsc && npm run test-fast",
21
21
  "test-ts": "tsc && node ./scripts/test.js",
22
22
  "perf": "npm run build && node benchmarks/references.js && node benchmarks/transfermarkt/transfermarkt-based.js"
23
23
  },
@@ -35,12 +35,14 @@
35
35
  "@saulx/hash": "^3.0.0",
36
36
  "@saulx/utils": "^4.3.2",
37
37
  "exit-hook": "^4.0.0",
38
- "picocolors": "^1.1.0"
38
+ "picocolors": "^1.1.0",
39
+ "@based/crc32c": "^1.0.0"
39
40
  },
40
41
  "optionalDependencies": {
41
42
  "@based/locale-x86-64-gnu": "*"
42
43
  },
43
44
  "devDependencies": {
45
+ "@based/crc32c": "^1.0.0",
44
46
  "@types/node": "^22.5.3",
45
47
  "axios": "^1.7.9",
46
48
  "rimraf": "^3.0.2",