@based/db 0.0.70 → 0.1.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.
- package/LICENSE +201 -0
- package/README.md +105 -77
- package/dist/lib/darwin_aarch64/include/libdeflate.h +23 -0
- package/dist/lib/darwin_aarch64/include/selva/db.h +0 -41
- package/dist/lib/darwin_aarch64/include/selva/fast_linear_search.h +6 -2
- package/dist/lib/darwin_aarch64/include/selva/fields.h +52 -37
- package/dist/lib/darwin_aarch64/include/selva/gmtime.h +137 -0
- package/dist/lib/darwin_aarch64/include/selva/hll.h +1 -1
- package/dist/lib/darwin_aarch64/include/selva/mblen.h +40 -0
- package/dist/lib/darwin_aarch64/include/selva/selva_string.h +8 -5
- package/dist/lib/darwin_aarch64/include/selva/thread.h +37 -0
- package/dist/lib/darwin_aarch64/include/selva/types.h +18 -4
- package/dist/lib/darwin_aarch64/libdeflate.dylib +0 -0
- package/dist/lib/darwin_aarch64/libjemalloc_selva.2.dylib +0 -0
- package/dist/lib/darwin_aarch64/libnode-v22.node +0 -0
- package/dist/lib/darwin_aarch64/libnode-v23.node +0 -0
- package/dist/lib/darwin_aarch64/libnode-v24.node +0 -0
- package/dist/lib/darwin_aarch64/libselva.dylib +0 -0
- package/dist/lib/darwin_aarch64/libxxhash.dylib +0 -0
- package/dist/lib/linux_aarch64/include/libdeflate.h +23 -0
- package/dist/lib/linux_aarch64/include/selva/db.h +0 -41
- package/dist/lib/linux_aarch64/include/selva/fast_linear_search.h +6 -2
- package/dist/lib/linux_aarch64/include/selva/fields.h +52 -37
- package/dist/lib/linux_aarch64/include/selva/gmtime.h +137 -0
- package/dist/lib/linux_aarch64/include/selva/hll.h +1 -1
- package/dist/lib/linux_aarch64/include/selva/mblen.h +40 -0
- package/dist/lib/linux_aarch64/include/selva/selva_string.h +8 -5
- package/dist/lib/linux_aarch64/include/selva/thread.h +37 -0
- package/dist/lib/linux_aarch64/include/selva/types.h +18 -4
- package/dist/lib/linux_aarch64/libdeflate.so +0 -0
- package/dist/lib/linux_aarch64/libnode-v22.node +0 -0
- package/dist/lib/linux_aarch64/libnode-v23.node +0 -0
- package/dist/lib/linux_aarch64/libnode-v24.node +0 -0
- package/dist/lib/linux_aarch64/libselva.so +0 -0
- package/dist/lib/linux_x86_64/include/libdeflate.h +23 -0
- package/dist/lib/linux_x86_64/include/selva/db.h +0 -41
- package/dist/lib/linux_x86_64/include/selva/fast_linear_search.h +6 -2
- package/dist/lib/linux_x86_64/include/selva/fields.h +52 -37
- package/dist/lib/linux_x86_64/include/selva/gmtime.h +137 -0
- package/dist/lib/linux_x86_64/include/selva/hll.h +1 -1
- package/dist/lib/linux_x86_64/include/selva/mblen.h +40 -0
- package/dist/lib/linux_x86_64/include/selva/selva_string.h +8 -5
- package/dist/lib/linux_x86_64/include/selva/thread.h +37 -0
- package/dist/lib/linux_x86_64/include/selva/types.h +18 -4
- package/dist/lib/linux_x86_64/libdeflate.so +0 -0
- package/dist/lib/linux_x86_64/libnode-v22.node +0 -0
- package/dist/lib/linux_x86_64/libnode-v23.node +0 -0
- package/dist/lib/linux_x86_64/libnode-v24.node +0 -0
- package/dist/lib/linux_x86_64/libselva.so +0 -0
- package/dist/src/client/index.d.ts +16 -21
- package/dist/src/client/index.js +48 -59
- package/dist/src/client/modify/Ctx.d.ts +38 -0
- package/dist/src/client/modify/Ctx.js +30 -0
- package/dist/src/client/modify/Tmp.d.ts +19 -0
- package/dist/src/client/modify/Tmp.js +67 -0
- package/dist/src/client/modify/create/index.d.ts +6 -0
- package/dist/src/client/modify/create/index.js +191 -0
- package/dist/src/client/modify/create/mark.d.ts +7 -0
- package/dist/src/client/modify/create/mark.js +42 -0
- package/dist/src/client/modify/cursor.d.ts +10 -0
- package/dist/src/client/modify/cursor.js +48 -0
- package/dist/src/client/modify/delete/index.d.ts +2 -0
- package/dist/src/client/modify/delete/index.js +39 -0
- package/dist/src/client/modify/drain.d.ts +7 -0
- package/dist/src/client/modify/drain.js +77 -0
- package/dist/src/client/modify/edges/binary.d.ts +3 -0
- package/dist/src/client/modify/edges/binary.js +28 -0
- package/dist/src/client/modify/edges/cardinality.d.ts +3 -0
- package/dist/src/client/modify/edges/cardinality.js +15 -0
- package/dist/src/client/modify/edges/header.d.ts +5 -0
- package/dist/src/client/modify/edges/header.js +21 -0
- package/dist/src/client/modify/edges/index.d.ts +3 -0
- package/dist/src/client/modify/edges/index.js +128 -0
- package/dist/src/client/modify/edges/reference.d.ts +3 -0
- package/dist/src/client/modify/edges/reference.js +31 -0
- package/dist/src/client/modify/edges/references.d.ts +3 -0
- package/dist/src/client/modify/edges/references.js +38 -0
- package/dist/src/client/modify/edges/separate.d.ts +3 -0
- package/dist/src/client/modify/edges/separate.js +24 -0
- package/dist/src/client/modify/edges/string.d.ts +3 -0
- package/dist/src/client/modify/edges/string.js +30 -0
- package/dist/src/client/modify/error.d.ts +7 -0
- package/dist/src/client/modify/error.js +68 -0
- package/dist/src/client/modify/expire/index.d.ts +2 -0
- package/dist/src/client/modify/expire/index.js +31 -0
- package/dist/src/client/modify/props/alias.d.ts +3 -0
- package/dist/src/client/modify/props/alias.js +26 -0
- package/dist/src/client/modify/props/binary.d.ts +5 -0
- package/dist/src/client/modify/props/binary.js +52 -0
- package/dist/src/client/modify/props/cardinality.d.ts +4 -0
- package/dist/src/client/modify/props/cardinality.js +46 -0
- package/dist/src/client/modify/props/delete.d.ts +3 -0
- package/dist/src/client/modify/props/delete.js +13 -0
- package/dist/src/client/modify/props/fixed.d.ts +4 -0
- package/dist/src/client/modify/props/fixed.js +105 -0
- package/dist/src/client/modify/props/increment.d.ts +3 -0
- package/dist/src/client/modify/props/increment.js +28 -0
- package/dist/src/client/modify/props/json.d.ts +3 -0
- package/dist/src/client/modify/props/json.js +5 -0
- package/dist/src/client/modify/props/main.d.ts +4 -0
- package/dist/src/client/modify/props/main.js +22 -0
- package/dist/src/client/modify/props/object.d.ts +3 -0
- package/dist/src/client/modify/props/object.js +37 -0
- package/dist/src/client/modify/props/reference.d.ts +6 -0
- package/dist/src/client/modify/props/reference.js +92 -0
- package/dist/src/client/modify/props/references.d.ts +3 -0
- package/dist/src/client/modify/props/references.js +231 -0
- package/dist/src/client/modify/props/separate.d.ts +3 -0
- package/dist/src/client/modify/props/separate.js +43 -0
- package/dist/src/client/modify/props/string.d.ts +5 -0
- package/dist/src/client/modify/props/string.js +51 -0
- package/dist/src/client/modify/props/text.d.ts +3 -0
- package/dist/src/client/modify/props/text.js +35 -0
- package/dist/src/client/modify/props/vector.d.ts +3 -0
- package/dist/src/client/modify/props/vector.js +30 -0
- package/dist/src/client/modify/resize.d.ts +3 -0
- package/dist/src/client/modify/resize.js +20 -0
- package/dist/src/client/modify/types.d.ts +3 -4
- package/dist/src/client/modify/types.js +2 -1
- package/dist/src/client/modify/uint.d.ts +7 -0
- package/dist/src/client/modify/uint.js +27 -0
- package/dist/src/client/modify/update/index.d.ts +3 -0
- package/dist/src/client/modify/update/index.js +75 -0
- package/dist/src/client/modify/upsert/index.d.ts +3 -0
- package/dist/src/client/modify/{upsert.js → upsert/index.js} +4 -4
- package/dist/src/client/modify/validate.d.ts +6 -0
- package/dist/src/client/modify/validate.js +24 -0
- package/dist/src/client/query/BasedDbQuery.d.ts +18 -15
- package/dist/src/client/query/BasedDbQuery.js +93 -96
- package/dist/src/client/query/{BasedIterable.d.ts → BasedQueryResponse.d.ts} +5 -4
- package/dist/src/client/query/{BasedIterable.js → BasedQueryResponse.js} +15 -10
- package/dist/src/client/query/aggregates/aggregation.d.ts +5 -3
- package/dist/src/client/query/aggregates/aggregation.js +105 -48
- package/dist/src/client/query/aggregates/types.d.ts +34 -12
- package/dist/src/client/query/aggregates/types.js +30 -12
- package/dist/src/client/query/debug.js +1 -1
- package/dist/src/client/query/display.d.ts +1 -1
- package/dist/src/client/query/display.js +21 -4
- package/dist/src/client/query/filter/FilterBranch.js +2 -2
- package/dist/src/client/query/filter/convertFilter.d.ts +3 -2
- package/dist/src/client/query/filter/convertFilter.js +13 -1
- package/dist/src/client/query/filter/createFixedFilterBuffer.js +16 -30
- package/dist/src/client/query/filter/createReferenceFilter.js +6 -20
- package/dist/src/client/query/filter/createVariableFilterBuffer.js +15 -32
- package/dist/src/client/query/filter/parseFilterValue.js +3 -11
- package/dist/src/client/query/filter/primitiveFilter.js +1 -1
- package/dist/src/client/query/filter/toBuffer.js +9 -15
- package/dist/src/client/query/filter/types.d.ts +6 -6
- package/dist/src/client/query/filter/types.js +8 -8
- package/dist/src/client/query/include/include.d.ts +3 -0
- package/dist/src/client/query/include/include.js +58 -0
- package/dist/src/client/query/include/props.d.ts +7 -7
- package/dist/src/client/query/include/props.js +26 -21
- package/dist/src/client/query/include/toByteCode.js +188 -0
- package/dist/src/client/query/include/utils.d.ts +3 -1
- package/dist/src/client/query/include/utils.js +13 -0
- package/dist/src/client/query/include/walk.d.ts +2 -2
- package/dist/src/client/query/include/walk.js +38 -23
- package/dist/src/client/query/query.d.ts +2 -3
- package/dist/src/client/query/query.js +2 -3
- package/dist/src/client/query/queryDef.d.ts +4 -2
- package/dist/src/client/query/queryDef.js +3 -5
- package/dist/src/client/query/queryDefToReadSchema.d.ts +3 -0
- package/dist/src/client/query/queryDefToReadSchema.js +126 -0
- package/dist/src/client/query/registerQuery.js +15 -4
- package/dist/src/client/query/search/index.d.ts +2 -1
- package/dist/src/client/query/search/index.js +9 -2
- package/dist/src/client/query/sort.js +3 -0
- package/dist/src/client/query/subscription/index.d.ts +1 -1
- package/dist/src/client/query/subscription/index.js +2 -2
- package/dist/src/client/query/subscription/types.d.ts +1 -1
- package/dist/src/client/query/thresholds.d.ts +1 -1
- package/dist/src/client/query/thresholds.js +1 -1
- package/dist/src/client/query/toByteCode/{toBuffer.js → toByteCode.js} +8 -8
- package/dist/src/client/query/types.d.ts +40 -25
- package/dist/src/client/query/types.js +2 -6
- package/dist/src/client/query/validation.d.ts +6 -0
- package/dist/src/client/query/validation.js +32 -8
- package/dist/src/client/setLocalClientSchema.js +6 -10
- package/dist/src/client/string.d.ts +3 -7
- package/dist/src/client/string.js +18 -47
- package/dist/src/hooks.d.ts +2 -3
- package/dist/src/hooks.js +14 -9
- package/dist/src/index.d.ts +3 -5
- package/dist/src/index.js +4 -6
- package/dist/src/native.d.ts +3 -2
- package/dist/src/native.js +9 -8
- package/dist/src/server/IoWorker.js +2 -3
- package/dist/src/server/QueryWorker.js +1 -1
- package/dist/src/server/blocks.js +5 -4
- package/dist/src/server/dbHash.js +1 -1
- package/dist/src/server/index.d.ts +4 -6
- package/dist/src/server/index.js +63 -96
- package/dist/src/server/migrate/index.d.ts +2 -4
- package/dist/src/server/migrate/index.js +31 -16
- package/dist/src/server/migrate/worker.js +2 -27
- package/dist/src/server/save.js +10 -8
- package/dist/src/server/schema.js +17 -25
- package/dist/src/server/start.d.ts +1 -0
- package/dist/src/server/start.js +18 -10
- package/dist/src/server/tree.d.ts +20 -0
- package/dist/src/server/tree.js +17 -2
- package/dist/src/server/workers/DbWorker.d.ts +1 -0
- package/dist/src/server/workers/DbWorker.js +8 -1
- package/dist/src/server/workers/io_worker.js +1 -1
- package/dist/src/server/workers/worker.js +9 -4
- package/dist/src/table.d.ts +4 -0
- package/dist/src/table.js +97 -0
- package/dist/src/types.d.ts +1 -1
- package/package.json +18 -17
- package/dist/lib/darwin_aarch64/include/selva/worker_ctx.h +0 -29
- package/dist/lib/linux_aarch64/include/selva/worker_ctx.h +0 -29
- package/dist/lib/linux_x86_64/include/selva/worker_ctx.h +0 -29
- package/dist/src/client/flushModify.d.ts +0 -36
- package/dist/src/client/flushModify.js +0 -197
- package/dist/src/client/modify/ModifyRes.d.ts +0 -23
- package/dist/src/client/modify/ModifyRes.js +0 -101
- package/dist/src/client/modify/alias.d.ts +0 -4
- package/dist/src/client/modify/alias.js +0 -57
- package/dist/src/client/modify/binary.d.ts +0 -6
- package/dist/src/client/modify/binary.js +0 -80
- package/dist/src/client/modify/cardinality.d.ts +0 -6
- package/dist/src/client/modify/cardinality.js +0 -63
- package/dist/src/client/modify/create.d.ts +0 -5
- package/dist/src/client/modify/create.js +0 -228
- package/dist/src/client/modify/delete.d.ts +0 -4
- package/dist/src/client/modify/delete.js +0 -47
- package/dist/src/client/modify/expire.d.ts +0 -3
- package/dist/src/client/modify/expire.js +0 -25
- package/dist/src/client/modify/fixed.d.ts +0 -5
- package/dist/src/client/modify/fixed.js +0 -235
- package/dist/src/client/modify/index.d.ts +0 -4
- package/dist/src/client/modify/index.js +0 -4
- package/dist/src/client/modify/json.d.ts +0 -4
- package/dist/src/client/modify/json.js +0 -26
- package/dist/src/client/modify/modify.d.ts +0 -5
- package/dist/src/client/modify/modify.js +0 -134
- package/dist/src/client/modify/references/appendEdgeRefs.d.ts +0 -4
- package/dist/src/client/modify/references/appendEdgeRefs.js +0 -33
- package/dist/src/client/modify/references/edge.d.ts +0 -5
- package/dist/src/client/modify/references/edge.js +0 -322
- package/dist/src/client/modify/references/getEdgeSize.d.ts +0 -3
- package/dist/src/client/modify/references/getEdgeSize.js +0 -27
- package/dist/src/client/modify/references/reference.d.ts +0 -11
- package/dist/src/client/modify/references/reference.js +0 -112
- package/dist/src/client/modify/references/references.d.ts +0 -16
- package/dist/src/client/modify/references/references.js +0 -308
- package/dist/src/client/modify/setCursor.d.ts +0 -5
- package/dist/src/client/modify/setCursor.js +0 -33
- package/dist/src/client/modify/string.d.ts +0 -5
- package/dist/src/client/modify/string.js +0 -71
- package/dist/src/client/modify/text.d.ts +0 -8
- package/dist/src/client/modify/text.js +0 -69
- package/dist/src/client/modify/update.d.ts +0 -6
- package/dist/src/client/modify/update.js +0 -90
- package/dist/src/client/modify/upsert.d.ts +0 -3
- package/dist/src/client/modify/vector.d.ts +0 -4
- package/dist/src/client/modify/vector.js +0 -53
- package/dist/src/client/query/include/toBuffer.js +0 -123
- package/dist/src/client/query/read/read.d.ts +0 -9
- package/dist/src/client/query/read/read.js +0 -483
- /package/dist/src/client/query/include/{toBuffer.d.ts → toByteCode.d.ts} +0 -0
- /package/dist/src/client/query/toByteCode/{toBuffer.d.ts → toByteCode.d.ts} +0 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { QueryBranch } from '../BasedDbQuery.js';
|
|
2
|
+
import { includeField } from './props.js';
|
|
3
|
+
import { REFERENCE, REFERENCES } from '@based/schema/def';
|
|
4
|
+
import { createOrGetEdgeRefQueryDef, createOrGetRefQueryDef } from './utils.js';
|
|
5
|
+
export const include = (query, fields) => {
|
|
6
|
+
for (let i = 0; i < fields.length; i++) {
|
|
7
|
+
const f = fields[i];
|
|
8
|
+
const opts = typeof fields[i + 1] === 'object' && typeof fields[i + 1] !== 'function'
|
|
9
|
+
? fields[i + 1]
|
|
10
|
+
: undefined;
|
|
11
|
+
if (opts) {
|
|
12
|
+
i++;
|
|
13
|
+
}
|
|
14
|
+
if (typeof f === 'string') {
|
|
15
|
+
includeField(query.def, { field: f, opts });
|
|
16
|
+
}
|
|
17
|
+
else if (typeof f === 'function') {
|
|
18
|
+
f((field) => {
|
|
19
|
+
if (field[0] == '$') {
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
const prop = query.def.target?.propDef?.edges[field];
|
|
22
|
+
if (prop &&
|
|
23
|
+
(prop.typeIndex === REFERENCE || prop.typeIndex === REFERENCES)) {
|
|
24
|
+
const refDef = createOrGetEdgeRefQueryDef(query.db, query.def, prop);
|
|
25
|
+
// @ts-ignore
|
|
26
|
+
return new QueryBranch(query.db, refDef);
|
|
27
|
+
}
|
|
28
|
+
throw new Error(`No edge reference or edge references field named "${field}"`);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
const prop = field[0] == '$'
|
|
32
|
+
? // @ts-ignore
|
|
33
|
+
query.def.target?.propDef?.edges[field]
|
|
34
|
+
: query.def.props[field];
|
|
35
|
+
if (prop &&
|
|
36
|
+
(prop.typeIndex === REFERENCE || prop.typeIndex === REFERENCES)) {
|
|
37
|
+
const refDef = createOrGetRefQueryDef(query.db, query.def, prop);
|
|
38
|
+
// @ts-ignore
|
|
39
|
+
return new QueryBranch(query.db, refDef);
|
|
40
|
+
}
|
|
41
|
+
throw new Error(`No reference or references field named "${field}"`);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
else if (Array.isArray(f)) {
|
|
46
|
+
if (f.length === 0) {
|
|
47
|
+
includeField(query.def, { field: 'id', opts });
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
include(query, f);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else if (f !== undefined) {
|
|
54
|
+
throw new Error('Invalid include statement: expected props, refs and edges (string or array) or function');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=include.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { PropDef, PropDefEdge } from '@based/schema/def';
|
|
2
|
-
import { QueryDef } from '../types.js';
|
|
3
|
-
export declare const getAll: (props: QueryDef["props"]) =>
|
|
4
|
-
export declare const getAllRefs: (props: QueryDef["props"], affix?: string) =>
|
|
5
|
-
export declare const includeField: (def: QueryDef,
|
|
6
|
-
export declare const includeFields: (def: QueryDef, fields:
|
|
7
|
-
export declare const includeAllProps: (def: QueryDef) => void;
|
|
8
|
-
export declare const includeProp: (def: QueryDef, prop: PropDef | PropDefEdge) => boolean;
|
|
2
|
+
import { IncludeField, IncludeOpts, QueryDef } from '../types.js';
|
|
3
|
+
export declare const getAll: (props: QueryDef["props"], opts?: IncludeOpts) => IncludeField[];
|
|
4
|
+
export declare const getAllRefs: (props: QueryDef["props"], affix?: string, opts?: IncludeOpts) => IncludeField[];
|
|
5
|
+
export declare const includeField: (def: QueryDef, include: IncludeField) => void;
|
|
6
|
+
export declare const includeFields: (def: QueryDef, fields: IncludeField[]) => void;
|
|
7
|
+
export declare const includeAllProps: (def: QueryDef, opts?: IncludeOpts) => void;
|
|
8
|
+
export declare const includeProp: (def: QueryDef, prop: PropDef | PropDefEdge, opts?: IncludeOpts) => boolean;
|
|
@@ -1,53 +1,54 @@
|
|
|
1
1
|
import { REFERENCE, REFERENCES, TEXT, } from '@based/schema/def';
|
|
2
2
|
import { QueryDefType } from '../types.js';
|
|
3
|
-
export const getAll = (props) => {
|
|
3
|
+
export const getAll = (props, opts) => {
|
|
4
4
|
const fields = [];
|
|
5
5
|
for (const key in props) {
|
|
6
6
|
const prop = props[key];
|
|
7
7
|
if (prop.typeIndex !== REFERENCE && prop.typeIndex !== REFERENCES) {
|
|
8
|
-
fields.push(prop.path.join('.'));
|
|
8
|
+
fields.push({ field: prop.path.join('.'), opts });
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
return fields;
|
|
12
12
|
};
|
|
13
|
-
export const getAllRefs = (props, affix = '') => {
|
|
13
|
+
export const getAllRefs = (props, affix = '', opts) => {
|
|
14
14
|
const fields = [];
|
|
15
15
|
for (const key in props) {
|
|
16
16
|
const prop = props[key];
|
|
17
17
|
if (prop.typeIndex === REFERENCE || prop.typeIndex === REFERENCES) {
|
|
18
18
|
const refPath = prop.path.join('.') + affix;
|
|
19
|
-
fields.push(refPath);
|
|
19
|
+
fields.push({ field: refPath, opts });
|
|
20
20
|
if (prop.edges) {
|
|
21
21
|
for (const edge in prop.edges) {
|
|
22
|
-
fields.push(refPath + '.' + edge);
|
|
22
|
+
fields.push({ field: refPath + '.' + edge, opts });
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
return fields;
|
|
28
28
|
};
|
|
29
|
-
export const includeField = (def,
|
|
29
|
+
export const includeField = (def, include) => {
|
|
30
|
+
const { field, opts } = include;
|
|
30
31
|
if (field === '*') {
|
|
31
32
|
if (def.type === QueryDefType.Reference ||
|
|
32
33
|
def.type === QueryDefType.References) {
|
|
33
34
|
const fields = [];
|
|
34
35
|
if (def.target.propDef.edges) {
|
|
35
36
|
for (const edge in def.target.propDef.edges) {
|
|
36
|
-
fields.push(edge);
|
|
37
|
+
fields.push({ field: edge, opts });
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
includeFields(def, fields);
|
|
40
41
|
}
|
|
41
|
-
includeFields(def, getAll(def.props));
|
|
42
|
+
includeFields(def, getAll(def.props, opts));
|
|
42
43
|
}
|
|
43
44
|
else if (field === '**') {
|
|
44
|
-
includeFields(def, getAllRefs(def.props));
|
|
45
|
+
includeFields(def, getAllRefs(def.props, '', opts));
|
|
45
46
|
}
|
|
46
47
|
else if (field.startsWith('**.')) {
|
|
47
|
-
includeFields(def, getAllRefs(def.props, field.substring(2)));
|
|
48
|
+
includeFields(def, getAllRefs(def.props, field.substring(2), opts));
|
|
48
49
|
}
|
|
49
50
|
else {
|
|
50
|
-
def.include.stringFields.
|
|
51
|
+
def.include.stringFields.set(include.field, include);
|
|
51
52
|
}
|
|
52
53
|
};
|
|
53
54
|
export const includeFields = (def, fields) => {
|
|
@@ -55,27 +56,31 @@ export const includeFields = (def, fields) => {
|
|
|
55
56
|
includeField(def, field);
|
|
56
57
|
}
|
|
57
58
|
};
|
|
58
|
-
export const includeAllProps = (def) => {
|
|
59
|
+
export const includeAllProps = (def, opts) => {
|
|
59
60
|
for (const key in def.props) {
|
|
60
61
|
const prop = def.props[key];
|
|
61
62
|
if (prop.typeIndex !== REFERENCE && prop.typeIndex !== REFERENCES) {
|
|
62
|
-
includeProp(def, prop);
|
|
63
|
+
includeProp(def, prop, opts);
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
66
|
};
|
|
66
|
-
export const includeProp = (def, prop) => {
|
|
67
|
+
export const includeProp = (def, prop, opts) => {
|
|
67
68
|
if (!prop || prop.typeIndex === REFERENCE || prop.typeIndex === REFERENCES) {
|
|
68
69
|
return false;
|
|
69
70
|
}
|
|
70
71
|
if (prop.typeIndex === TEXT) {
|
|
71
|
-
if (!def.include.
|
|
72
|
-
def.include.
|
|
72
|
+
if (!def.include.props.has(prop.prop)) {
|
|
73
|
+
def.include.props.set(prop.prop, {
|
|
73
74
|
def: prop,
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
opts: {
|
|
76
|
+
codes: new Set(),
|
|
77
|
+
fallBacks: [],
|
|
78
|
+
...opts,
|
|
79
|
+
localeFromDef: def.lang.lang,
|
|
80
|
+
},
|
|
76
81
|
});
|
|
77
82
|
}
|
|
78
|
-
const langs = def.include.
|
|
83
|
+
const langs = def.include.props.get(prop.prop).opts;
|
|
79
84
|
if (def.lang.fallback.length > 0) {
|
|
80
85
|
for (const fallback of def.lang.fallback) {
|
|
81
86
|
if (!langs.fallBacks.includes(fallback)) {
|
|
@@ -91,11 +96,11 @@ export const includeProp = (def, prop) => {
|
|
|
91
96
|
}
|
|
92
97
|
else {
|
|
93
98
|
if (prop.separate) {
|
|
94
|
-
def.include.props.set(prop.prop, prop);
|
|
99
|
+
def.include.props.set(prop.prop, { def: prop, opts });
|
|
95
100
|
}
|
|
96
101
|
else {
|
|
97
102
|
def.include.main.len += prop.len;
|
|
98
|
-
def.include.main.include[prop.start] = [0, prop];
|
|
103
|
+
def.include.main.include[prop.start] = [0, prop, opts];
|
|
99
104
|
return true;
|
|
100
105
|
}
|
|
101
106
|
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { MICRO_BUFFER, STRING, TEXT, JSON } from '@based/schema/def';
|
|
2
|
+
import { QueryDefType } from '../types.js';
|
|
3
|
+
import { walkDefs } from './walk.js';
|
|
4
|
+
import { langCodesMap } from '@based/schema';
|
|
5
|
+
import { writeUint32 } from '@based/utils';
|
|
6
|
+
import { getEnd } from './utils.js';
|
|
7
|
+
const EMPTY_BUFFER = new Uint8Array(0);
|
|
8
|
+
export const includeToBuffer = (db, def) => {
|
|
9
|
+
const result = [];
|
|
10
|
+
if (!def.include.stringFields.size &&
|
|
11
|
+
!def.include.props.size &&
|
|
12
|
+
!def.references.size &&
|
|
13
|
+
!def.include.main.len) {
|
|
14
|
+
return result;
|
|
15
|
+
}
|
|
16
|
+
let mainBuffer;
|
|
17
|
+
if (def.include.stringFields) {
|
|
18
|
+
for (const [field, include] of def.include.stringFields.entries()) {
|
|
19
|
+
walkDefs(db, def, { field, opts: include.opts });
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if (def.include.main.len > 0) {
|
|
23
|
+
const len = def.type === QueryDefType.Edge
|
|
24
|
+
? def.target.ref.edgeMainLen
|
|
25
|
+
: def.schema.mainLen;
|
|
26
|
+
if (def.include.main.len === len) {
|
|
27
|
+
// GET ALL MAIN FIELDS
|
|
28
|
+
mainBuffer = EMPTY_BUFFER;
|
|
29
|
+
let i = 2;
|
|
30
|
+
for (const key in def.include.main.include) {
|
|
31
|
+
const v = def.include.main.include[key];
|
|
32
|
+
v[0] = v[1].start;
|
|
33
|
+
i += 4;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
// GET SOME MAIN FIELDS
|
|
38
|
+
const size = Object.keys(def.include.main.include).length;
|
|
39
|
+
mainBuffer = new Uint8Array(size * 4 + 2);
|
|
40
|
+
mainBuffer[0] = def.include.main.len;
|
|
41
|
+
mainBuffer[1] = def.include.main.len >>> 8;
|
|
42
|
+
let i = 2;
|
|
43
|
+
let m = 0;
|
|
44
|
+
for (const key in def.include.main.include) {
|
|
45
|
+
const v = def.include.main.include[key];
|
|
46
|
+
mainBuffer[i] = v[1].start;
|
|
47
|
+
mainBuffer[i + 1] = v[1].start >>> 8;
|
|
48
|
+
const len = v[1].len;
|
|
49
|
+
v[0] = m;
|
|
50
|
+
mainBuffer[i + 2] = len;
|
|
51
|
+
mainBuffer[i + 3] = len >>> 8;
|
|
52
|
+
i += 4;
|
|
53
|
+
m += len;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const propSize = def.include.props.size ?? 0;
|
|
58
|
+
if (mainBuffer) {
|
|
59
|
+
if (mainBuffer.byteLength !== 0) {
|
|
60
|
+
const buf = new Uint8Array(5);
|
|
61
|
+
buf[0] = 7 /* includeOp.PARTIAL */;
|
|
62
|
+
buf[1] = 0; // field name 0
|
|
63
|
+
buf[2] = MICRO_BUFFER;
|
|
64
|
+
buf[3] = mainBuffer.byteLength;
|
|
65
|
+
buf[4] = mainBuffer.byteLength >>> 8;
|
|
66
|
+
result.push(buf, mainBuffer);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
const buf = new Uint8Array(4);
|
|
70
|
+
buf[0] = 1 /* includeOp.DEFAULT */;
|
|
71
|
+
buf[1] = 0; // field name 0
|
|
72
|
+
buf[2] = MICRO_BUFFER;
|
|
73
|
+
buf[3] = 0; // opts len
|
|
74
|
+
result.push(buf);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (propSize) {
|
|
78
|
+
for (const [prop, propDef] of def.include.props.entries()) {
|
|
79
|
+
if (propDef.opts?.meta) {
|
|
80
|
+
if (propDef.opts.codes) {
|
|
81
|
+
if (propDef.opts.codes.has(0)) {
|
|
82
|
+
// TODO use locales for 0 make this NICE
|
|
83
|
+
for (const code in def.schema.locales) {
|
|
84
|
+
const buf = new Uint8Array(4);
|
|
85
|
+
buf[0] = 6 /* includeOp.META */;
|
|
86
|
+
buf[1] = prop;
|
|
87
|
+
buf[2] = propDef.def.typeIndex;
|
|
88
|
+
buf[3] = langCodesMap.get(code);
|
|
89
|
+
result.push(buf);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
for (const code of propDef.opts.codes) {
|
|
94
|
+
const buf = new Uint8Array(4);
|
|
95
|
+
buf[0] = 6 /* includeOp.META */;
|
|
96
|
+
buf[1] = prop;
|
|
97
|
+
buf[2] = propDef.def.typeIndex;
|
|
98
|
+
buf[3] = code;
|
|
99
|
+
result.push(buf);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
const buf = new Uint8Array(4);
|
|
105
|
+
buf[0] = 6 /* includeOp.META */;
|
|
106
|
+
buf[1] = prop;
|
|
107
|
+
buf[2] = propDef.def.typeIndex;
|
|
108
|
+
buf[3] = 0;
|
|
109
|
+
result.push(buf);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (propDef.opts?.meta !== 'only') {
|
|
113
|
+
const hasEnd = propDef.opts?.end;
|
|
114
|
+
const t = propDef.def.typeIndex;
|
|
115
|
+
if (t === TEXT) {
|
|
116
|
+
const codes = propDef.opts.codes;
|
|
117
|
+
if (codes.has(0)) {
|
|
118
|
+
const b = new Uint8Array(hasEnd ? 12 : 4);
|
|
119
|
+
b[0] = 1 /* includeOp.DEFAULT */;
|
|
120
|
+
b[1] = prop;
|
|
121
|
+
b[2] = propDef.def.typeIndex;
|
|
122
|
+
if (hasEnd) {
|
|
123
|
+
b[3] = 8; // opts len
|
|
124
|
+
b[4] = 0; // lang code
|
|
125
|
+
b[5] = 0; // fallbackSize
|
|
126
|
+
b[6] = 1; // has end
|
|
127
|
+
b[7] = propDef.opts?.bytes ? 0 : 1; // is string
|
|
128
|
+
writeUint32(b, getEnd(propDef.opts), 8);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
b[3] = 0; // opts len
|
|
132
|
+
}
|
|
133
|
+
result.push(b);
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
for (const code of codes) {
|
|
137
|
+
const fallBackSize = propDef.opts.fallBacks.length;
|
|
138
|
+
const endCode = getEnd(propDef.opts, code);
|
|
139
|
+
const b = new Uint8Array(7 + (endCode ? 5 : 0) + fallBackSize);
|
|
140
|
+
b[0] = 1 /* includeOp.DEFAULT */;
|
|
141
|
+
b[1] = prop;
|
|
142
|
+
b[2] = propDef.def.typeIndex;
|
|
143
|
+
let i = 0;
|
|
144
|
+
if (endCode) {
|
|
145
|
+
b[3] = fallBackSize + 8; // opts
|
|
146
|
+
b[4] = code; // say if there is a end option
|
|
147
|
+
b[5] = fallBackSize;
|
|
148
|
+
b[6] = 1; // has end
|
|
149
|
+
b[7] = propDef.opts?.bytes ? 0 : 1; // is string use chars (can be optional)
|
|
150
|
+
writeUint32(b, endCode, 8);
|
|
151
|
+
i = 11;
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
b[3] = fallBackSize + 3; // opts
|
|
155
|
+
b[4] = code; // say if there is a end option
|
|
156
|
+
b[5] = fallBackSize;
|
|
157
|
+
b[6] = 0; // no end
|
|
158
|
+
i = 7;
|
|
159
|
+
}
|
|
160
|
+
for (const fallback of propDef.opts.fallBacks) {
|
|
161
|
+
b[i] = fallback;
|
|
162
|
+
i++;
|
|
163
|
+
}
|
|
164
|
+
result.push(b);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
const buf = new Uint8Array(hasEnd ? 9 : 4);
|
|
170
|
+
buf[0] = 1 /* includeOp.DEFAULT */;
|
|
171
|
+
buf[1] = prop;
|
|
172
|
+
buf[2] = propDef.def.typeIndex;
|
|
173
|
+
if (hasEnd) {
|
|
174
|
+
buf[3] = 5; // opts len
|
|
175
|
+
buf[4] = propDef.opts?.bytes || (t !== JSON && t !== STRING) ? 0 : 1;
|
|
176
|
+
writeUint32(buf, getEnd(propDef.opts), 5);
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
buf[3] = 0; // opts len
|
|
180
|
+
}
|
|
181
|
+
result.push(buf);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return result;
|
|
187
|
+
};
|
|
188
|
+
//# sourceMappingURL=toByteCode.js.map
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { PropDef, PropDefEdge, SchemaPropTree } from '@based/schema/def';
|
|
2
2
|
import { DbClient } from '../../index.js';
|
|
3
|
-
import { QueryDef } from '../types.js';
|
|
3
|
+
import { IncludeOpts, QueryDef } from '../types.js';
|
|
4
|
+
import { LangCode } from '@based/schema';
|
|
4
5
|
export declare const getAllFieldFromObject: (tree: SchemaPropTree | PropDef, arr?: string[]) => string[];
|
|
5
6
|
export declare const createOrGetRefQueryDef: (db: DbClient, def: QueryDef, t: PropDef | PropDefEdge) => QueryDef;
|
|
6
7
|
export declare const createOrGetEdgeRefQueryDef: (db: DbClient, def: QueryDef, t: PropDefEdge) => QueryDef;
|
|
8
|
+
export declare const getEnd: (opts?: IncludeOpts, lang?: LangCode) => number;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { REFERENCE, } from '@based/schema/def';
|
|
2
2
|
import { createQueryDef } from '../queryDef.js';
|
|
3
3
|
import { QueryDefType } from '../types.js';
|
|
4
|
+
import { inverseLangMap } from '@based/schema';
|
|
4
5
|
export const getAllFieldFromObject = (tree, arr = []) => {
|
|
5
6
|
for (const key in tree) {
|
|
6
7
|
const leaf = tree[key];
|
|
@@ -39,4 +40,16 @@ export const createOrGetEdgeRefQueryDef = (db, def, t) => {
|
|
|
39
40
|
const refDef = createOrGetRefQueryDef(db, def.edges, t);
|
|
40
41
|
return refDef;
|
|
41
42
|
};
|
|
43
|
+
export const getEnd = (opts, lang) => {
|
|
44
|
+
if (!opts || !opts.end) {
|
|
45
|
+
return 0;
|
|
46
|
+
}
|
|
47
|
+
if (typeof opts.end === 'object') {
|
|
48
|
+
if (lang) {
|
|
49
|
+
return opts.end[inverseLangMap.get(lang)] ?? opts.end[0] ?? undefined;
|
|
50
|
+
}
|
|
51
|
+
return opts.end[0] ?? undefined;
|
|
52
|
+
}
|
|
53
|
+
return opts.end;
|
|
54
|
+
};
|
|
42
55
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { QueryDef } from '../types.js';
|
|
1
|
+
import { IncludeField, QueryDef } from '../types.js';
|
|
2
2
|
import { DbClient } from '../../index.js';
|
|
3
|
-
export declare const walkDefs: (db: DbClient, def: QueryDef,
|
|
3
|
+
export declare const walkDefs: (db: DbClient, def: QueryDef, include: IncludeField) => void;
|
|
@@ -5,13 +5,13 @@ import { getAllFieldFromObject, createOrGetRefQueryDef } from './utils.js';
|
|
|
5
5
|
import { includeProp, includeAllProps, includeField } from './props.js';
|
|
6
6
|
import { langCodesMap } from '@based/schema';
|
|
7
7
|
import { includeDoesNotExist, includeLangDoesNotExist } from '../validation.js';
|
|
8
|
-
export const walkDefs = (db, def,
|
|
9
|
-
const prop = def.props[
|
|
10
|
-
const path =
|
|
8
|
+
export const walkDefs = (db, def, include) => {
|
|
9
|
+
const prop = def.props[include.field];
|
|
10
|
+
const path = include.field.split('.');
|
|
11
11
|
if (!prop) {
|
|
12
12
|
let t = def.schema.tree;
|
|
13
13
|
for (let i = 0; i < path.length; i++) {
|
|
14
|
-
|
|
14
|
+
let p = path[i];
|
|
15
15
|
if (isRefDef(def) && p[0] == '$') {
|
|
16
16
|
if (!def.edges) {
|
|
17
17
|
def.edges = createQueryDef(db, QueryDefType.Edge, {
|
|
@@ -20,6 +20,10 @@ export const walkDefs = (db, def, f) => {
|
|
|
20
20
|
def.edges.lang = def.lang;
|
|
21
21
|
}
|
|
22
22
|
const edgeProp = def.edges.props[p];
|
|
23
|
+
if (!edgeProp) {
|
|
24
|
+
includeDoesNotExist(def, include.field);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
23
27
|
if (edgeProp.typeIndex === REFERENCE ||
|
|
24
28
|
edgeProp.typeIndex === REFERENCES) {
|
|
25
29
|
const refDef = createOrGetRefQueryDef(db, def.edges, edgeProp);
|
|
@@ -28,22 +32,22 @@ export const walkDefs = (db, def, f) => {
|
|
|
28
32
|
}
|
|
29
33
|
else {
|
|
30
34
|
const f = path.slice(i + 1).join('.');
|
|
31
|
-
if (!includeProp(refDef, refDef.props[f])) {
|
|
32
|
-
includeField(refDef, f);
|
|
35
|
+
if (!includeProp(refDef, refDef.props[f], include.opts)) {
|
|
36
|
+
includeField(refDef, { field: f, opts: include.opts });
|
|
33
37
|
}
|
|
34
38
|
return;
|
|
35
39
|
}
|
|
36
40
|
}
|
|
37
41
|
else {
|
|
38
|
-
//
|
|
39
|
-
includeProp(def.edges, edgeProp);
|
|
42
|
+
// add text for edges
|
|
43
|
+
includeProp(def.edges, edgeProp, include.opts);
|
|
40
44
|
}
|
|
41
45
|
return;
|
|
42
46
|
}
|
|
43
47
|
t = t[p];
|
|
44
48
|
if (!t) {
|
|
45
|
-
if (
|
|
46
|
-
includeDoesNotExist(def,
|
|
49
|
+
if (include.field != 'id') {
|
|
50
|
+
includeDoesNotExist(def, include.field);
|
|
47
51
|
}
|
|
48
52
|
return;
|
|
49
53
|
}
|
|
@@ -51,25 +55,36 @@ export const walkDefs = (db, def, f) => {
|
|
|
51
55
|
const lang = path[path.length - 1];
|
|
52
56
|
const langCode = langCodesMap.get(lang);
|
|
53
57
|
if (!langCode || !db.schema.locales[lang]) {
|
|
54
|
-
includeLangDoesNotExist(def,
|
|
58
|
+
includeLangDoesNotExist(def, include.field);
|
|
55
59
|
return;
|
|
56
60
|
}
|
|
57
|
-
if (!def.include.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
if (!def.include.props.has(t.prop)) {
|
|
62
|
+
const opts = include.opts ?? {};
|
|
63
|
+
opts.codes = new Set();
|
|
64
|
+
opts.fallBacks = [];
|
|
65
|
+
if (opts.end && typeof opts.end === 'number') {
|
|
66
|
+
opts.end = { [lang]: opts.end };
|
|
67
|
+
}
|
|
68
|
+
def.include.props.set(t.prop, { def: t, opts });
|
|
69
|
+
}
|
|
70
|
+
const opts = def.include.props.get(t.prop).opts;
|
|
71
|
+
if (include.opts?.end) {
|
|
72
|
+
if (typeof include.opts?.end === 'number') {
|
|
73
|
+
opts.end[lang] = include.opts?.end;
|
|
74
|
+
}
|
|
75
|
+
else if (typeof opts.end === 'object') {
|
|
76
|
+
opts.end = { ...opts.end, ...include.opts.end };
|
|
77
|
+
}
|
|
63
78
|
}
|
|
64
|
-
|
|
79
|
+
opts.codes.add(langCode);
|
|
65
80
|
return;
|
|
66
81
|
}
|
|
67
82
|
else if (isPropDef(t) &&
|
|
68
83
|
(t.typeIndex === REFERENCE || t.typeIndex === REFERENCES)) {
|
|
69
84
|
const refDef = createOrGetRefQueryDef(db, def, t);
|
|
70
85
|
const f = path.slice(i + 1).join('.');
|
|
71
|
-
if (!includeProp(refDef, refDef.props[f])) {
|
|
72
|
-
includeField(refDef, f);
|
|
86
|
+
if (!includeProp(refDef, refDef.props[f], include.opts)) {
|
|
87
|
+
includeField(refDef, { field: f, opts: include.opts });
|
|
73
88
|
}
|
|
74
89
|
return;
|
|
75
90
|
}
|
|
@@ -78,17 +93,17 @@ export const walkDefs = (db, def, f) => {
|
|
|
78
93
|
if (tree) {
|
|
79
94
|
const endFields = getAllFieldFromObject(tree);
|
|
80
95
|
for (const field of endFields) {
|
|
81
|
-
walkDefs(db, def, field);
|
|
96
|
+
walkDefs(db, def, { field, opts: include.opts });
|
|
82
97
|
}
|
|
83
98
|
}
|
|
84
99
|
}
|
|
85
100
|
else if (prop.typeIndex === REFERENCE || prop.typeIndex === REFERENCES) {
|
|
86
101
|
const refDef = createOrGetRefQueryDef(db, def, prop);
|
|
87
|
-
includeAllProps(refDef);
|
|
102
|
+
includeAllProps(refDef, include.opts);
|
|
88
103
|
return;
|
|
89
104
|
}
|
|
90
105
|
else {
|
|
91
|
-
includeProp(def, prop);
|
|
106
|
+
includeProp(def, prop, include.opts);
|
|
92
107
|
}
|
|
93
108
|
};
|
|
94
109
|
//# sourceMappingURL=walk.js.map
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
export * from './queryDef.js';
|
|
2
2
|
export * from './types.js';
|
|
3
3
|
export * from './include/props.js';
|
|
4
|
-
export * from './include/
|
|
5
|
-
export * from './toByteCode/
|
|
4
|
+
export * from './include/toByteCode.js';
|
|
5
|
+
export * from './toByteCode/toByteCode.js';
|
|
6
6
|
export * from './filter/filter.js';
|
|
7
7
|
export * from './filter/toBuffer.js';
|
|
8
8
|
export * from './sort.js';
|
|
9
9
|
export * from './debug.js';
|
|
10
|
-
export * from './read/read.js';
|
|
11
10
|
export * from './aggregates/aggregation.js';
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
export * from './queryDef.js';
|
|
2
2
|
export * from './types.js';
|
|
3
3
|
export * from './include/props.js';
|
|
4
|
-
export * from './include/
|
|
5
|
-
export * from './toByteCode/
|
|
4
|
+
export * from './include/toByteCode.js';
|
|
5
|
+
export * from './toByteCode/toByteCode.js';
|
|
6
6
|
export * from './filter/filter.js';
|
|
7
7
|
export * from './filter/toBuffer.js';
|
|
8
8
|
export * from './sort.js';
|
|
9
9
|
export * from './debug.js';
|
|
10
|
-
export * from './read/read.js';
|
|
11
10
|
export * from './aggregates/aggregation.js';
|
|
12
11
|
//# sourceMappingURL=query.js.map
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { DbClient } from '../index.js';
|
|
2
|
-
import { QueryDef, QueryDefType,
|
|
3
|
-
|
|
2
|
+
import { EdgeTarget, QueryDef, QueryDefEdges, QueryDefRest, QueryDefType, Target } from './types.js';
|
|
3
|
+
type CreateQueryDefReturn<T extends QueryDefType> = T extends QueryDefType.Edge ? QueryDefEdges : T extends QueryDefType.Root | QueryDefType.Reference | QueryDefType.References ? QueryDefRest : QueryDef;
|
|
4
|
+
export declare function createQueryDef<T extends QueryDefType>(db: DbClient, type: T, target: T extends QueryDefType.Edge ? EdgeTarget : Target, skipValidation: boolean): CreateQueryDefReturn<T>;
|
|
5
|
+
export {};
|
|
@@ -13,10 +13,8 @@ const createEmptySharedDef = (skipValidation) => {
|
|
|
13
13
|
fallback: [],
|
|
14
14
|
},
|
|
15
15
|
include: {
|
|
16
|
-
|
|
17
|
-
stringFields: new Set(),
|
|
16
|
+
stringFields: new Map(),
|
|
18
17
|
props: new Map(),
|
|
19
|
-
propsRead: {},
|
|
20
18
|
main: {
|
|
21
19
|
len: 0,
|
|
22
20
|
include: {},
|
|
@@ -28,7 +26,7 @@ const createEmptySharedDef = (skipValidation) => {
|
|
|
28
26
|
};
|
|
29
27
|
return q;
|
|
30
28
|
};
|
|
31
|
-
export
|
|
29
|
+
export function createQueryDef(db, type, target, skipValidation) {
|
|
32
30
|
const queryDef = createEmptySharedDef(skipValidation);
|
|
33
31
|
if (type === QueryDefType.Edge) {
|
|
34
32
|
const t = target;
|
|
@@ -65,5 +63,5 @@ export const createQueryDef = (db, type, target, skipValidation) => {
|
|
|
65
63
|
}
|
|
66
64
|
return q;
|
|
67
65
|
}
|
|
68
|
-
}
|
|
66
|
+
}
|
|
69
67
|
//# sourceMappingURL=queryDef.js.map
|