@based/schema 5.0.0-alpha.11 → 5.0.0-alpha.12

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.
@@ -16,6 +16,8 @@ export declare const createEmptyDef: (typeName: string, type: StrictSchemaType |
16
16
  lastId: number;
17
17
  locales: {};
18
18
  main: {};
19
+ separateSortProps: number;
20
+ separateSortText: number;
19
21
  localeSize: number;
20
22
  hasSeperateSort: boolean;
21
23
  seperateSort: {
@@ -18,6 +18,8 @@ export const createEmptyDef = (typeName, type, locales) => {
18
18
  lastId: 0,
19
19
  locales: {},
20
20
  main: {},
21
+ separateSortProps: 0,
22
+ separateSortText: 0,
21
23
  localeSize: 0,
22
24
  hasSeperateSort: false,
23
25
  seperateSort: {
@@ -2,7 +2,6 @@ export * from './types.js';
2
2
  export * from './typeDef.js';
3
3
  export * from './utils.js';
4
4
  export * from './selvaBuffer.js';
5
- export * from './readFromPacked.js';
6
5
  export * from './createEmptyDef.js';
7
6
  export * from './defaultMap.js';
8
7
  export * from './validation.js';
package/dist/def/index.js CHANGED
@@ -3,7 +3,6 @@ export * from './types.js';
3
3
  export * from './typeDef.js';
4
4
  export * from './utils.js';
5
5
  export * from './selvaBuffer.js';
6
- export * from './readFromPacked.js';
7
6
  export * from './createEmptyDef.js';
8
7
  export * from './defaultMap.js';
9
8
  export * from './validation.js';
@@ -2,7 +2,6 @@ import { isPropType, getPropType, } from '../index.js';
2
2
  import { setByPath } from '@saulx/utils';
3
3
  import { TYPE_INDEX_MAP, REFERENCES, REFERENCE, NUMBER, } from './types.js';
4
4
  import { DEFAULT_MAP } from './defaultMap.js';
5
- import { makePacked } from './makePacked.js';
6
5
  import { makeSeparateTextSort } from './makeSeparateTextSort.js';
7
6
  import { makeSeparateSort } from './makeSeparateSort.js';
8
7
  import { getPropLen } from './getPropLen.js';
@@ -58,8 +57,6 @@ export const createSchemaTypeDef = (typeName, type, parsed, locales, result = cr
58
57
  result.idUint8[0] = result.id & 255;
59
58
  result.idUint8[1] = result.id >> 8;
60
59
  const target = type.props;
61
- let separateSortProps = 0;
62
- let separateSortText = 0;
63
60
  for (const key in target) {
64
61
  // Create prop def
65
62
  const schemaProp = target[key];
@@ -76,15 +73,15 @@ export const createSchemaTypeDef = (typeName, type, parsed, locales, result = cr
76
73
  if (typeof schemaProp === 'object') {
77
74
  if (!(schemaProp.maxBytes < 61) ||
78
75
  !('max' in schemaProp && schemaProp.max < 31)) {
79
- separateSortProps++;
76
+ result.separateSortProps++;
80
77
  }
81
78
  }
82
79
  else {
83
- separateSortProps++;
80
+ result.separateSortProps++;
84
81
  }
85
82
  }
86
83
  else if (isPropType('text', schemaProp)) {
87
- separateSortText++;
84
+ result.separateSortText++;
88
85
  }
89
86
  const isseparate = isSeparate(schemaProp, len);
90
87
  const typeIndex = TYPE_INDEX_MAP[propType];
@@ -193,11 +190,10 @@ export const createSchemaTypeDef = (typeName, type, parsed, locales, result = cr
193
190
  }
194
191
  result.mainEmpty = fillEmptyMain(vals, result.mainLen);
195
192
  result.mainEmptyAllZeroes = isZeroes(result.mainEmpty);
196
- makePacked(result, typeName, vals, len);
197
- if (separateSortText > 0) {
193
+ if (result.separateSortText > 0) {
198
194
  makeSeparateTextSort(result);
199
195
  }
200
- if (separateSortProps > 0) {
196
+ if (result.separateSortProps > 0) {
201
197
  makeSeparateSort(result);
202
198
  }
203
199
  for (const p in result.props) {
@@ -125,7 +125,6 @@ export type SchemaTypeDef = {
125
125
  mainLen: number;
126
126
  buf: Uint8Array;
127
127
  propNames: Uint8Array;
128
- packed: Uint8Array;
129
128
  props: {
130
129
  [path: string]: PropDef;
131
130
  };
@@ -141,6 +140,8 @@ export type SchemaTypeDef = {
141
140
  mainEmpty: Uint8Array;
142
141
  mainEmptyAllZeroes: boolean;
143
142
  tree: SchemaPropTree;
143
+ separateSortProps: number;
144
+ separateSortText: number;
144
145
  hasSeperateSort: boolean;
145
146
  seperateSort: SchemaSortUndefinedHandler;
146
147
  hasSeperateTextSort: boolean;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  export * from './types.js';
2
2
  export * from './parse/index.js';
3
3
  export * from './lang.js';
4
- export * from './mermaid.js';
5
4
  export * from './def/validation.js';
6
5
  export * from './serialize.js';
7
6
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  export * from './types.js';
2
2
  export * from './parse/index.js';
3
3
  export * from './lang.js';
4
- export * from './mermaid.js';
5
4
  export * from './def/validation.js';
6
5
  export * from './serialize.js';
7
6
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,3 @@
1
- import { isFloat32Array } from 'util/types';
2
1
  import { EXPECTED_ARR, EXPECTED_BOOL, EXPECTED_FN, EXPECTED_NUM, EXPECTED_OBJ, EXPECTED_STR, } from './errors.js';
3
2
  export const expectObject = (obj, msg) => {
4
3
  if (typeof obj !== 'object' || obj === null) {
@@ -6,7 +5,7 @@ export const expectObject = (obj, msg) => {
6
5
  }
7
6
  };
8
7
  export const expectFloat32Array = (arr) => {
9
- if (!isFloat32Array(arr)) {
8
+ if (!(arr instanceof Float32Array)) {
10
9
  throw Error(EXPECTED_ARR);
11
10
  }
12
11
  };
package/dist/serialize.js CHANGED
@@ -1,8 +1,11 @@
1
1
  import * as deflate from 'fflate';
2
2
  import { REVERSE_TYPE_INDEX_MAP, TYPE_INDEX_MAP } from './def/types.js';
3
- const hasNative = '__basedDb__native__' in global;
4
3
  const ENCODER = new TextEncoder();
5
4
  let schemaBuffer;
5
+ // 3 level
6
+ // 0 for queries (min)
7
+ // 1 for modify
8
+ // 2 fulls schema
6
9
  const walk = (obj, prev, prev2, fromObject, schemaBuffer) => {
7
10
  let start = schemaBuffer.len;
8
11
  // HANDLE ENUM
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@based/schema",
3
- "version": "5.0.0-alpha.11",
3
+ "version": "5.0.0-alpha.12",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "dist",
@@ -30,7 +30,7 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "fflate": "0.8.1",
33
- "@saulx/utils": "^6.4.0",
33
+ "@saulx/utils": "^6.5.0",
34
34
  "picocolors": "^1.1.0"
35
35
  }
36
36
  }