@snowtop/ent 0.1.0-alpha150 → 0.1.0-alpha152
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/core/base.d.ts +1 -0
- package/core/clause.d.ts +11 -1
- package/core/clause.js +21 -1
- package/core/ent.js +4 -2
- package/core/loaders/object_loader.js +1 -1
- package/core/loaders/raw_count_loader.d.ts +1 -0
- package/core/loaders/raw_count_loader.js +2 -1
- package/core/query/query.js +1 -1
- package/index.d.ts +4 -0
- package/index.js +4 -0
- package/package.json +1 -1
package/core/base.d.ts
CHANGED
|
@@ -72,6 +72,7 @@ export interface SelectBaseDataOptions extends DataOptions {
|
|
|
72
72
|
}
|
|
73
73
|
export interface SelectDataOptions extends SelectBaseDataOptions {
|
|
74
74
|
key: string;
|
|
75
|
+
keyType?: string;
|
|
75
76
|
clause?: clause.Clause | (() => clause.Clause | undefined);
|
|
76
77
|
}
|
|
77
78
|
export interface QueryableDataOptions extends SelectBaseDataOptions, QueryDataOptions {
|
package/core/clause.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Data, SelectDataOptions } from "./base";
|
|
1
|
+
import { Data, ID, SelectDataOptions } from "./base";
|
|
2
2
|
export interface Clause<T extends Data = Data, K = keyof T> {
|
|
3
3
|
clause(idx: number): string;
|
|
4
4
|
columns(): K[];
|
|
@@ -77,8 +77,18 @@ export declare function And<T extends Data, K = keyof T>(...args: Clause<T, K>[]
|
|
|
77
77
|
export declare function AndOptional<T extends Data, K = keyof T>(...args: (Clause<T, K> | undefined)[]): Clause<T, K>;
|
|
78
78
|
export declare function Or<T extends Data, K = keyof T>(...args: Clause<T, K>[]): Clause<T, K>;
|
|
79
79
|
export declare function OrOptional<T extends Data, K = keyof T>(...args: (Clause<T, K> | undefined)[]): Clause<T, K>;
|
|
80
|
+
/**
|
|
81
|
+
* @deprecated use UUidIn, TextIn, IntegerIn, or TypeIn
|
|
82
|
+
*/
|
|
80
83
|
export declare function In<T extends Data, K = keyof T>(col: K, ...values: any): Clause<T, K>;
|
|
84
|
+
/**
|
|
85
|
+
* @deprecated use UUidIn, TextIn, IntegerIn, or TypeIn
|
|
86
|
+
*/
|
|
81
87
|
export declare function In<T extends Data, K = keyof T>(col: K, values: any[], type?: string): Clause<T, K>;
|
|
88
|
+
export declare function UuidIn<T extends Data, K = keyof T>(col: K, values: ID[]): Clause<T, K>;
|
|
89
|
+
export declare function IntegerIn<T extends Data, K = keyof T>(col: K, values: number[]): Clause<T, K>;
|
|
90
|
+
export declare function TextIn<T extends Data, K = keyof T>(col: K, values: any[]): Clause<T, K>;
|
|
91
|
+
export declare function DBTypeIn<T extends Data, K = keyof T>(col: K, values: any[], typ: string): Clause<T, K>;
|
|
82
92
|
interface TsQuery {
|
|
83
93
|
language: "english" | "french" | "german" | "simple";
|
|
84
94
|
value: string;
|
package/core/clause.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.getCombinedClause = exports.Modulo = exports.Divide = exports.Multiply = exports.Subtract = exports.Add = exports.PaginationMultipleColsSubQuery = exports.JSONPathValuePredicate = exports.JSONObjectFieldKeyAsText = exports.JSONObjectFieldKeyASJSON = exports.sensitiveValue = exports.TsVectorWebsearchToTsQuery = exports.TsVectorPhraseToTsQuery = exports.TsVectorPlainToTsQuery = exports.TsVectorColTsQuery = exports.WebsearchToTsQuery = exports.PhraseToTsQuery = exports.PlainToTsQuery = exports.TsQuery = exports.In = exports.OrOptional = exports.Or = exports.AndOptional = exports.And = exports.LessEq = exports.GreaterEq = exports.Less = exports.Greater = exports.NotEq = exports.Eq = exports.ArrayNotEq = exports.ArrayEq = exports.PostgresArrayNotOverlaps = exports.PostgresArrayOverlaps = exports.PostgresArrayNotContains = exports.PostgresArrayNotContainsValue = exports.PostgresArrayContains = exports.PostgresArrayContainsValue = exports.inClause = void 0;
|
|
26
|
+
exports.getCombinedClause = exports.Modulo = exports.Divide = exports.Multiply = exports.Subtract = exports.Add = exports.PaginationMultipleColsSubQuery = exports.JSONPathValuePredicate = exports.JSONObjectFieldKeyAsText = exports.JSONObjectFieldKeyASJSON = exports.sensitiveValue = exports.TsVectorWebsearchToTsQuery = exports.TsVectorPhraseToTsQuery = exports.TsVectorPlainToTsQuery = exports.TsVectorColTsQuery = exports.WebsearchToTsQuery = exports.PhraseToTsQuery = exports.PlainToTsQuery = exports.TsQuery = exports.DBTypeIn = exports.TextIn = exports.IntegerIn = exports.UuidIn = exports.In = exports.OrOptional = exports.Or = exports.AndOptional = exports.And = exports.LessEq = exports.GreaterEq = exports.Less = exports.Greater = exports.NotEq = exports.Eq = exports.ArrayNotEq = exports.ArrayEq = exports.PostgresArrayNotOverlaps = exports.PostgresArrayOverlaps = exports.PostgresArrayNotContains = exports.PostgresArrayNotContainsValue = exports.PostgresArrayContains = exports.PostgresArrayContainsValue = exports.inClause = void 0;
|
|
27
27
|
const db_1 = __importStar(require("./db"));
|
|
28
28
|
function isSensitive(val) {
|
|
29
29
|
return (val !== null &&
|
|
@@ -550,6 +550,26 @@ function In(...args) {
|
|
|
550
550
|
return new inClause(args[0], args.slice(1));
|
|
551
551
|
}
|
|
552
552
|
exports.In = In;
|
|
553
|
+
function UuidIn(col, values) {
|
|
554
|
+
return new inClause(col, values, "uuid");
|
|
555
|
+
}
|
|
556
|
+
exports.UuidIn = UuidIn;
|
|
557
|
+
function IntegerIn(col, values) {
|
|
558
|
+
return new inClause(col, values, "integer");
|
|
559
|
+
}
|
|
560
|
+
exports.IntegerIn = IntegerIn;
|
|
561
|
+
function TextIn(col, values) {
|
|
562
|
+
return new inClause(col, values, "text");
|
|
563
|
+
}
|
|
564
|
+
exports.TextIn = TextIn;
|
|
565
|
+
/*
|
|
566
|
+
* if not uuid or text, pass the db type that can be used to cast this query
|
|
567
|
+
* if we end up with a large list of ids
|
|
568
|
+
*/
|
|
569
|
+
function DBTypeIn(col, values, typ) {
|
|
570
|
+
return new inClause(col, values, typ);
|
|
571
|
+
}
|
|
572
|
+
exports.DBTypeIn = DBTypeIn;
|
|
553
573
|
// if string defaults to english
|
|
554
574
|
// https://www.postgresql.org/docs/current/textsearch-controls.html#TEXTSEARCH-PARSING-QUERIES
|
|
555
575
|
// to_tsquery
|
package/core/ent.js
CHANGED
|
@@ -99,9 +99,11 @@ function createDataLoader(options) {
|
|
|
99
99
|
return [];
|
|
100
100
|
}
|
|
101
101
|
let col = options.key;
|
|
102
|
+
// defaults to uuid
|
|
103
|
+
let typ = options.keyType || "uuid";
|
|
102
104
|
const rowOptions = {
|
|
103
105
|
...options,
|
|
104
|
-
clause: clause.
|
|
106
|
+
clause: clause.DBTypeIn(col, ids, typ),
|
|
105
107
|
};
|
|
106
108
|
// TODO is there a better way of doing this?
|
|
107
109
|
// context not needed because we're creating a loader which has its own cache which is being used here
|
|
@@ -1162,7 +1164,7 @@ async function getEdgeTypeInGroup(viewer, id1, id2, m) {
|
|
|
1162
1164
|
tableToEdgeEnumMap.forEach((edgeEnums, tableName) => {
|
|
1163
1165
|
promises.push((async () => {
|
|
1164
1166
|
const edgeTypes = edgeEnums.map((edgeEnum) => m.get(edgeEnum));
|
|
1165
|
-
const { cls, fields } = getEdgeClauseAndFields(clause.And(clause.Eq("id1", id1), clause.
|
|
1167
|
+
const { cls, fields } = getEdgeClauseAndFields(clause.And(clause.Eq("id1", id1), clause.UuidIn("edge_type", edgeTypes), clause.Eq("id2", id2)), {});
|
|
1166
1168
|
const rows = await loadRows({
|
|
1167
1169
|
tableName,
|
|
1168
1170
|
fields,
|
|
@@ -36,7 +36,7 @@ const loader_1 = require("./loader");
|
|
|
36
36
|
const memoizee_1 = __importDefault(require("memoizee"));
|
|
37
37
|
async function loadRowsForIDLoader(options, ids, context) {
|
|
38
38
|
let col = options.key;
|
|
39
|
-
const cls = (0, clause_1.getCombinedClause)(options, clause.
|
|
39
|
+
const cls = (0, clause_1.getCombinedClause)(options, clause.DBTypeIn(col, ids, options.keyType || "uuid"));
|
|
40
40
|
const rowOptions = {
|
|
41
41
|
...options,
|
|
42
42
|
clause: cls,
|
|
@@ -4,6 +4,7 @@ import * as clause from "../clause";
|
|
|
4
4
|
interface QueryCountOptions {
|
|
5
5
|
tableName: string;
|
|
6
6
|
groupCol?: string;
|
|
7
|
+
groupColType?: string;
|
|
7
8
|
clause?: clause.Clause;
|
|
8
9
|
}
|
|
9
10
|
export declare function createCountDataLoader<K extends any>(options: QueryCountOptions): DataLoader<K, number, K>;
|
|
@@ -69,7 +69,8 @@ function createCountDataLoader(options) {
|
|
|
69
69
|
if (keys.length == 1 || !options.groupCol) {
|
|
70
70
|
return simpleCase(options, keys[0]);
|
|
71
71
|
}
|
|
72
|
-
let
|
|
72
|
+
let typ = options.groupColType || "uuid";
|
|
73
|
+
let cls = clause.DBTypeIn(options.groupCol, keys, typ);
|
|
73
74
|
if (options.clause) {
|
|
74
75
|
cls = clause.And(cls, options.clause);
|
|
75
76
|
}
|
package/core/query/query.js
CHANGED
|
@@ -120,7 +120,7 @@ class FirstFilter {
|
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
else {
|
|
123
|
-
options.orderby = `${this.sortCol}${
|
|
123
|
+
options.orderby = `${this.sortCol} ${orderby}${nullsPlacement}`;
|
|
124
124
|
if (this.offset) {
|
|
125
125
|
let clauseFn = less ? clause.Less : clause.Greater;
|
|
126
126
|
let val = this.options.sortColTime
|
package/index.d.ts
CHANGED
|
@@ -18,6 +18,10 @@ declare const query: {
|
|
|
18
18
|
Or: typeof q.Or;
|
|
19
19
|
OrOptional: typeof q.OrOptional;
|
|
20
20
|
In: typeof q.In;
|
|
21
|
+
UuidIn: typeof q.UuidIn;
|
|
22
|
+
IntegerIn: typeof q.IntegerIn;
|
|
23
|
+
TextIn: typeof q.TextIn;
|
|
24
|
+
DBTypeIn: typeof q.DBTypeIn;
|
|
21
25
|
Greater: typeof q.Greater;
|
|
22
26
|
Less: typeof q.Less;
|
|
23
27
|
GreaterEq: typeof q.GreaterEq;
|
package/index.js
CHANGED