@snowtop/ent 0.1.0-alpha115 → 0.1.0-alpha117
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 +13 -13
- package/core/clause.d.ts +49 -61
- package/core/clause.js +1 -1
- package/core/context.d.ts +2 -2
- package/core/ent.d.ts +10 -10
- package/core/ent.js +5 -0
- package/core/loaders/index_loader.d.ts +1 -1
- package/core/loaders/loader.d.ts +2 -2
- package/core/loaders/object_loader.d.ts +9 -9
- package/core/loaders/object_loader.js +4 -2
- package/core/loaders/query_loader.d.ts +1 -1
- package/package.json +1 -1
- package/testutils/fake_data/fake_contact.d.ts +1 -1
- package/testutils/fake_data/fake_tag.d.ts +1 -1
- package/testutils/fake_data/fake_user.d.ts +3 -3
package/core/base.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as clause from "./clause";
|
|
2
|
-
export interface Loader<
|
|
2
|
+
export interface Loader<K, V> {
|
|
3
3
|
context?: Context;
|
|
4
|
-
load(key:
|
|
5
|
-
loadMany?(keys:
|
|
4
|
+
load(key: K): Promise<V>;
|
|
5
|
+
loadMany?(keys: K[]): Promise<(V | null)[]>;
|
|
6
6
|
clearAll(): any;
|
|
7
7
|
}
|
|
8
8
|
export interface LoaderWithLoadMany<T, V> extends Loader<T, V> {
|
|
@@ -19,13 +19,13 @@ export interface ConfigurableLoaderFactory<T, V> extends LoaderFactory<T, V> {
|
|
|
19
19
|
createConfigurableLoader(options: EdgeQueryableDataOptions, context?: Context): Loader<T, V>;
|
|
20
20
|
}
|
|
21
21
|
export type EdgeQueryableDataOptions = Partial<Pick<QueryableDataOptions, "limit" | "orderby" | "clause">>;
|
|
22
|
-
export interface PrimableLoader<
|
|
23
|
-
prime(d:
|
|
24
|
-
primeAll?(d:
|
|
22
|
+
export interface PrimableLoader<K, V> extends Loader<K, V> {
|
|
23
|
+
prime(d: V): void;
|
|
24
|
+
primeAll?(d: V): void;
|
|
25
25
|
}
|
|
26
26
|
interface cache {
|
|
27
|
-
getLoader<
|
|
28
|
-
getLoaderWithLoadMany<
|
|
27
|
+
getLoader<K, V>(name: string, create: () => Loader<K, V>): Loader<K, V>;
|
|
28
|
+
getLoaderWithLoadMany<K, V>(name: string, create: () => LoaderWithLoadMany<K, V>): LoaderWithLoadMany<K, V>;
|
|
29
29
|
getCachedRows(options: queryOptions): Data[] | null;
|
|
30
30
|
getCachedRow(options: queryOptions): Data | null;
|
|
31
31
|
primeCache(options: queryOptions, rows: Data[]): void;
|
|
@@ -75,11 +75,11 @@ export interface SelectDataOptions extends SelectBaseDataOptions {
|
|
|
75
75
|
}
|
|
76
76
|
export interface QueryableDataOptions extends SelectBaseDataOptions, QueryDataOptions {
|
|
77
77
|
}
|
|
78
|
-
export interface QueryDataOptions {
|
|
78
|
+
export interface QueryDataOptions<T extends Data = Data, K = keyof T> {
|
|
79
79
|
distinct?: boolean;
|
|
80
|
-
clause: clause.Clause
|
|
80
|
+
clause: clause.Clause<T, K>;
|
|
81
81
|
orderby?: string;
|
|
82
|
-
groupby?:
|
|
82
|
+
groupby?: K;
|
|
83
83
|
limit?: number;
|
|
84
84
|
disableTransformations?: boolean;
|
|
85
85
|
}
|
|
@@ -113,11 +113,11 @@ export interface LoadCustomEntOptions<TEnt extends Ent, TViewer extends Viewer =
|
|
|
113
113
|
ent: EntConstructor<TEnt, TViewer>;
|
|
114
114
|
fieldPrivacy?: Map<string, PrivacyPolicy>;
|
|
115
115
|
}
|
|
116
|
-
export interface LoaderInfo {
|
|
116
|
+
export interface LoaderInfo<T = Data> {
|
|
117
117
|
tableName: string;
|
|
118
118
|
fields: string[];
|
|
119
119
|
nodeType: string;
|
|
120
|
-
loaderFactory: LoaderFactory<
|
|
120
|
+
loaderFactory: LoaderFactory<ID, T | null>;
|
|
121
121
|
}
|
|
122
122
|
export interface EditEntOptions<T extends Ent> extends LoadableEntOptions<T>, EditRowOptions {
|
|
123
123
|
}
|
package/core/clause.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { Data } from "./base";
|
|
2
|
+
export interface Clause<T extends Data = Data, K = keyof T> {
|
|
2
3
|
clause(idx: number): string;
|
|
3
|
-
columns():
|
|
4
|
+
columns(): K[];
|
|
4
5
|
values(): any[];
|
|
5
6
|
instanceKey(): string;
|
|
6
7
|
logValues(): any[];
|
|
@@ -10,38 +11,25 @@ export interface SensitiveValue {
|
|
|
10
11
|
value(): any;
|
|
11
12
|
logValue(): any;
|
|
12
13
|
}
|
|
13
|
-
declare class
|
|
14
|
-
protected col: string;
|
|
15
|
-
private value;
|
|
16
|
-
private op;
|
|
17
|
-
private handleNull?;
|
|
18
|
-
constructor(col: string, value: any, op: string, handleNull?: Clause | undefined);
|
|
19
|
-
clause(idx: number): string;
|
|
20
|
-
private nullClause;
|
|
21
|
-
columns(): string[];
|
|
22
|
-
values(): any[];
|
|
23
|
-
logValues(): any[];
|
|
24
|
-
instanceKey(): string;
|
|
25
|
-
}
|
|
26
|
-
export declare class inClause implements Clause {
|
|
14
|
+
export declare class inClause<T extends Data, K = keyof T> implements Clause<T, K> {
|
|
27
15
|
private col;
|
|
28
16
|
private value;
|
|
29
17
|
private type;
|
|
30
18
|
static getPostgresInClauseValuesThreshold(): number;
|
|
31
|
-
constructor(col:
|
|
19
|
+
constructor(col: K, value: any[], type?: string);
|
|
32
20
|
clause(idx: number): string;
|
|
33
|
-
columns():
|
|
21
|
+
columns(): K[];
|
|
34
22
|
values(): any[];
|
|
35
23
|
logValues(): any[];
|
|
36
24
|
instanceKey(): string;
|
|
37
25
|
}
|
|
38
|
-
declare class compositeClause implements Clause {
|
|
26
|
+
declare class compositeClause<T extends Data, K = keyof T> implements Clause<T, K> {
|
|
39
27
|
private clauses;
|
|
40
28
|
private sep;
|
|
41
29
|
compositeOp: string;
|
|
42
|
-
constructor(clauses: Clause[], sep: string);
|
|
30
|
+
constructor(clauses: Clause<T, K>[], sep: string);
|
|
43
31
|
clause(idx: number): string;
|
|
44
|
-
columns():
|
|
32
|
+
columns(): K[];
|
|
45
33
|
values(): any[];
|
|
46
34
|
logValues(): any[];
|
|
47
35
|
instanceKey(): string;
|
|
@@ -51,92 +39,92 @@ declare class compositeClause implements Clause {
|
|
|
51
39
|
* only works with postgres gin indexes
|
|
52
40
|
* https://www.postgresql.org/docs/current/indexes-types.html#INDEXES-TYPES-GIN
|
|
53
41
|
*/
|
|
54
|
-
export declare function PostgresArrayContainsValue(col:
|
|
42
|
+
export declare function PostgresArrayContainsValue<T extends Data, K = keyof T>(col: K, value: any): Clause<T, K>;
|
|
55
43
|
/**
|
|
56
44
|
* creates a clause to determine if every item in the list is stored in the array stored in the column in the db
|
|
57
45
|
* only works with postgres gin indexes
|
|
58
46
|
* https://www.postgresql.org/docs/current/indexes-types.html#INDEXES-TYPES-GIN
|
|
59
47
|
*/
|
|
60
|
-
export declare function PostgresArrayContains(col:
|
|
48
|
+
export declare function PostgresArrayContains<T extends Data, K = keyof T>(col: K, value: any[]): Clause<T, K>;
|
|
61
49
|
/**
|
|
62
50
|
* creates a clause to determine if the given value is NOT contained in the array stored in the column in the db
|
|
63
51
|
* only works with postgres gin indexes
|
|
64
52
|
* https://www.postgresql.org/docs/current/indexes-types.html#INDEXES-TYPES-GIN
|
|
65
53
|
*/
|
|
66
|
-
export declare function PostgresArrayNotContainsValue(col:
|
|
54
|
+
export declare function PostgresArrayNotContainsValue<T extends Data, K = keyof T>(col: K, value: any): Clause<T, K>;
|
|
67
55
|
/**
|
|
68
56
|
* creates a clause to determine if every item in the list is NOT stored in the array stored in the column in the db
|
|
69
57
|
* only works with postgres gin indexes
|
|
70
58
|
* https://www.postgresql.org/docs/current/indexes-types.html#INDEXES-TYPES-GIN
|
|
71
59
|
*/
|
|
72
|
-
export declare function PostgresArrayNotContains(col:
|
|
60
|
+
export declare function PostgresArrayNotContains<T extends Data, K = keyof T>(col: K, value: any[]): Clause<T, K>;
|
|
73
61
|
/**
|
|
74
62
|
* creates a clause to determine if the arrays overlap, that is, do they have any elements in common
|
|
75
63
|
* only works with postgres gin indexes
|
|
76
64
|
* https://www.postgresql.org/docs/current/indexes-types.html#INDEXES-TYPES-GIN
|
|
77
65
|
*/
|
|
78
|
-
export declare function PostgresArrayOverlaps(col:
|
|
66
|
+
export declare function PostgresArrayOverlaps<T extends Data, K = keyof T>(col: K, value: any[]): Clause<T, K>;
|
|
79
67
|
/**
|
|
80
68
|
* creates a clause to determine if the arrays do not overlap, that is, do they have any elements in common
|
|
81
69
|
* only works with postgres gin indexes
|
|
82
70
|
* https://www.postgresql.org/docs/current/indexes-types.html#INDEXES-TYPES-GIN
|
|
83
71
|
*/
|
|
84
|
-
export declare function PostgresArrayNotOverlaps(col:
|
|
72
|
+
export declare function PostgresArrayNotOverlaps<T extends Data, K = keyof T>(col: K, value: any[]): Clause<T, K>;
|
|
85
73
|
/**
|
|
86
74
|
* @deprecated use PostgresArrayContainsValue
|
|
87
75
|
*/
|
|
88
|
-
export declare function ArrayEq(col:
|
|
76
|
+
export declare function ArrayEq<T extends Data, K = keyof T>(col: K, value: any): Clause<T, K>;
|
|
89
77
|
/**
|
|
90
78
|
* @deprecated use PostgresNotArrayContains
|
|
91
79
|
*/
|
|
92
|
-
export declare function ArrayNotEq(col:
|
|
93
|
-
export declare function Eq(col:
|
|
94
|
-
export declare function NotEq(col:
|
|
95
|
-
export declare function Greater(col:
|
|
96
|
-
export declare function Less(col:
|
|
97
|
-
export declare function GreaterEq(col:
|
|
98
|
-
export declare function LessEq(col:
|
|
99
|
-
export declare function And(...args: Clause[]): compositeClause
|
|
100
|
-
export declare function AndOptional(...args: (Clause | undefined)[]): Clause
|
|
101
|
-
export declare function Or(...args: Clause[]): compositeClause
|
|
102
|
-
export declare function OrOptional(...args: (Clause | undefined)[]): Clause
|
|
103
|
-
export declare function In(col:
|
|
104
|
-
export declare function In(col:
|
|
80
|
+
export declare function ArrayNotEq<T extends Data, K = keyof T>(col: K, value: any): Clause<T, K>;
|
|
81
|
+
export declare function Eq<T extends Data, K = keyof T>(col: K, value: any): Clause<T, K>;
|
|
82
|
+
export declare function NotEq<T extends Data, K = keyof T>(col: K, value: any): Clause<T, K>;
|
|
83
|
+
export declare function Greater<T extends Data, K = keyof T>(col: K, value: any): Clause<T, K>;
|
|
84
|
+
export declare function Less<T extends Data, K = keyof T>(col: K, value: any): Clause<T, K>;
|
|
85
|
+
export declare function GreaterEq<T extends Data, K = keyof T>(col: K, value: any): Clause<T, K>;
|
|
86
|
+
export declare function LessEq<T extends Data, K = keyof T>(col: K, value: any): Clause<T, K>;
|
|
87
|
+
export declare function And<T extends Data, K = keyof T>(...args: Clause<T, K>[]): compositeClause<T, K>;
|
|
88
|
+
export declare function AndOptional<T extends Data, K = keyof T>(...args: (Clause<T, K> | undefined)[]): Clause<T, K>;
|
|
89
|
+
export declare function Or<T extends Data, K = keyof T>(...args: Clause<T, K>[]): compositeClause<T, K>;
|
|
90
|
+
export declare function OrOptional<T extends Data, K = keyof T>(...args: (Clause<T, K> | undefined)[]): Clause<T, K>;
|
|
91
|
+
export declare function In<T extends Data, K = keyof T>(col: K, ...values: any): Clause<T, K>;
|
|
92
|
+
export declare function In<T extends Data, K = keyof T>(col: K, values: any[], type?: string): Clause<T, K>;
|
|
105
93
|
interface TsQuery {
|
|
106
94
|
language: "english" | "french" | "german" | "simple";
|
|
107
95
|
value: string;
|
|
108
96
|
}
|
|
109
|
-
export declare function TsQuery(col:
|
|
110
|
-
export declare function PlainToTsQuery(col:
|
|
111
|
-
export declare function PhraseToTsQuery(col:
|
|
112
|
-
export declare function WebsearchToTsQuery(col:
|
|
113
|
-
export declare function TsVectorColTsQuery(col:
|
|
114
|
-
export declare function TsVectorPlainToTsQuery(col:
|
|
115
|
-
export declare function TsVectorPhraseToTsQuery(col:
|
|
116
|
-
export declare function TsVectorWebsearchToTsQuery(col:
|
|
97
|
+
export declare function TsQuery<T extends Data, K = keyof T>(col: K, val: string | TsQuery): Clause<T, K>;
|
|
98
|
+
export declare function PlainToTsQuery<T extends Data, K = keyof T>(col: K, val: string | TsQuery): Clause<T, K>;
|
|
99
|
+
export declare function PhraseToTsQuery<T extends Data, K = keyof T>(col: K, val: string | TsQuery): Clause<T, K>;
|
|
100
|
+
export declare function WebsearchToTsQuery<T extends Data, K = keyof T>(col: K, val: string | TsQuery): Clause<T, K>;
|
|
101
|
+
export declare function TsVectorColTsQuery<T extends Data, K = keyof T>(col: K, val: string | TsQuery): Clause<T, K>;
|
|
102
|
+
export declare function TsVectorPlainToTsQuery<T extends Data, K = keyof T>(col: K, val: string | TsQuery): Clause<T, K>;
|
|
103
|
+
export declare function TsVectorPhraseToTsQuery<T extends Data, K = keyof T>(col: K, val: string | TsQuery): Clause<T, K>;
|
|
104
|
+
export declare function TsVectorWebsearchToTsQuery<T extends Data, K = keyof T>(col: K, val: string | TsQuery): Clause<T, K>;
|
|
117
105
|
export declare function sensitiveValue(val: any): SensitiveValue;
|
|
118
|
-
export declare function JSONObjectFieldKeyASJSON(col:
|
|
119
|
-
export declare function JSONObjectFieldKeyAsText(col:
|
|
106
|
+
export declare function JSONObjectFieldKeyASJSON<T extends Data, K = keyof T>(col: K, field: string): string;
|
|
107
|
+
export declare function JSONObjectFieldKeyAsText<T extends Data, K = keyof T>(col: K, field: string): string;
|
|
120
108
|
type predicate = "==" | ">" | "<" | "!=" | ">=" | "<=";
|
|
121
|
-
export declare function JSONPathValuePredicate(dbCol:
|
|
122
|
-
declare class paginationMultipleColumnsSubQueryClause implements Clause {
|
|
109
|
+
export declare function JSONPathValuePredicate<T extends Data, K = keyof T>(dbCol: K, path: string, val: any, pred: predicate): Clause<T, K>;
|
|
110
|
+
declare class paginationMultipleColumnsSubQueryClause<T extends Data, K = keyof T> implements Clause<T, K> {
|
|
123
111
|
private col;
|
|
124
112
|
private op;
|
|
125
113
|
private tableName;
|
|
126
114
|
private uniqueCol;
|
|
127
115
|
private val;
|
|
128
|
-
constructor(col:
|
|
116
|
+
constructor(col: K, op: string, tableName: string, uniqueCol: K, val: any);
|
|
129
117
|
private buildSimpleQuery;
|
|
130
118
|
clause(idx: number): string;
|
|
131
|
-
columns():
|
|
119
|
+
columns(): K[];
|
|
132
120
|
values(): any[];
|
|
133
121
|
logValues(): any[];
|
|
134
122
|
instanceKey(): string;
|
|
135
123
|
}
|
|
136
|
-
export declare function PaginationMultipleColsSubQuery(col:
|
|
137
|
-
export declare function Add(col:
|
|
138
|
-
export declare function Subtract(col:
|
|
139
|
-
export declare function Multiply(col:
|
|
140
|
-
export declare function Divide(col:
|
|
141
|
-
export declare function Modulo(col:
|
|
124
|
+
export declare function PaginationMultipleColsSubQuery<T extends Data, K = keyof T>(col: K, op: string, tableName: string, uniqueCol: K, val: any): paginationMultipleColumnsSubQueryClause<Data, K>;
|
|
125
|
+
export declare function Add<T extends Data, K = keyof T>(col: K, value: any): Clause<T, K>;
|
|
126
|
+
export declare function Subtract<T extends Data, K = keyof T>(col: K, value: any): Clause<T, K>;
|
|
127
|
+
export declare function Multiply<T extends Data, K = keyof T>(col: K, value: any): Clause<T, K>;
|
|
128
|
+
export declare function Divide<T extends Data, K = keyof T>(col: K, value: any): Clause<T, K>;
|
|
129
|
+
export declare function Modulo<T extends Data, K = keyof T>(col: K, value: any): Clause<T, K>;
|
|
142
130
|
export {};
|
package/core/clause.js
CHANGED
package/core/context.d.ts
CHANGED
|
@@ -12,8 +12,8 @@ export interface RequestContext<TViewer extends Viewer = Viewer> extends Context
|
|
|
12
12
|
export declare class ContextCache {
|
|
13
13
|
loaders: Map<string, Loader<any, any>>;
|
|
14
14
|
loaderWithLoadMany: Map<string, LoaderWithLoadMany<any, any>>;
|
|
15
|
-
getLoader<
|
|
16
|
-
getLoaderWithLoadMany<
|
|
15
|
+
getLoader<K, V>(name: string, create: () => Loader<K, V>): Loader<K, V>;
|
|
16
|
+
getLoaderWithLoadMany<K, V>(name: string, create: () => LoaderWithLoadMany<K, V>): LoaderWithLoadMany<K, V>;
|
|
17
17
|
private itemMap;
|
|
18
18
|
private listMap;
|
|
19
19
|
private getkey;
|
package/core/ent.d.ts
CHANGED
|
@@ -24,13 +24,13 @@ export declare function loadEntsList<TEnt extends Ent<TViewer>, TViewer extends
|
|
|
24
24
|
* @deperecated use loadCustomEnts
|
|
25
25
|
*/
|
|
26
26
|
export declare function loadEntsFromClause<TEnt extends Ent<TViewer>, TViewer extends Viewer>(viewer: TViewer, clause: clause.Clause, options: LoadEntOptions<TEnt, TViewer>): Promise<Map<ID, TEnt>>;
|
|
27
|
-
export declare function loadCustomEnts<TEnt extends Ent<TViewer>, TViewer extends Viewer>(viewer: TViewer, options: LoadCustomEntOptions<TEnt, TViewer>, query: CustomQuery): Promise<TEnt[]>;
|
|
27
|
+
export declare function loadCustomEnts<TEnt extends Ent<TViewer>, TViewer extends Viewer, TQueryData extends Data = Data, TResultData extends Data = TQueryData, TKey = keyof TQueryData>(viewer: TViewer, options: LoadCustomEntOptions<TEnt, TViewer>, query: CustomQuery<TQueryData, TKey>): Promise<TEnt[]>;
|
|
28
28
|
interface parameterizedQueryOptions {
|
|
29
29
|
query: string;
|
|
30
30
|
values?: any[];
|
|
31
31
|
logValues?: any[];
|
|
32
32
|
}
|
|
33
|
-
export type CustomQuery = string | parameterizedQueryOptions | clause.Clause | QueryDataOptions;
|
|
33
|
+
export type CustomQuery<T extends Data = Data, K = keyof T> = string | parameterizedQueryOptions | clause.Clause<T, K> | QueryDataOptions;
|
|
34
34
|
/**
|
|
35
35
|
* Note that if there's default read transformations (e.g. soft delete) and a clause is passed in
|
|
36
36
|
* either as Clause or QueryDataOptions without {disableTransformations: true}, the default transformation
|
|
@@ -55,10 +55,10 @@ export type CustomQuery = string | parameterizedQueryOptions | clause.Clause | Q
|
|
|
55
55
|
* disableTransformations: false
|
|
56
56
|
* }) // doesn't change the query
|
|
57
57
|
*/
|
|
58
|
-
export declare function loadCustomData(options: SelectCustomDataOptions, query: CustomQuery, context: Context | undefined): Promise<
|
|
58
|
+
export declare function loadCustomData<TQueryData extends Data = Data, TResultData extends Data = TQueryData, K = keyof TQueryData>(options: SelectCustomDataOptions, query: CustomQuery<TQueryData, K>, context: Context | undefined): Promise<TResultData[]>;
|
|
59
59
|
interface CustomCountOptions extends DataOptions {
|
|
60
60
|
}
|
|
61
|
-
export declare function loadCustomCount(options: CustomCountOptions, query: CustomQuery, context: Context | undefined): Promise<number>;
|
|
61
|
+
export declare function loadCustomCount<T extends Data = Data, K = keyof T>(options: CustomCountOptions, query: CustomQuery<T, K>, context: Context | undefined): Promise<number>;
|
|
62
62
|
export declare function loadDerivedEnt<TEnt extends Ent<TViewer>, TViewer extends Viewer>(viewer: TViewer, data: Data, loader: new (viewer: TViewer, data: Data) => TEnt): Promise<TEnt | null>;
|
|
63
63
|
export declare function loadDerivedEntX<TEnt extends Ent<TViewer>, TViewer extends Viewer>(viewer: TViewer, data: Data, loader: new (viewer: TViewer, data: Data) => TEnt): Promise<TEnt>;
|
|
64
64
|
export declare function logQuery(query: string, logValues: any[]): void;
|
|
@@ -68,16 +68,16 @@ export declare function ___setLogQueryErrorWithError(val: boolean | undefined):
|
|
|
68
68
|
export declare function performRawQuery(query: string, values: any[], logValues?: any[]): Promise<Data[]>;
|
|
69
69
|
export declare function loadRows(options: LoadRowsOptions): Promise<Data[]>;
|
|
70
70
|
export declare function buildQuery(options: QueryableDataOptions): string;
|
|
71
|
-
interface GroupQueryOptions {
|
|
71
|
+
interface GroupQueryOptions<T extends Data, K = keyof T> {
|
|
72
72
|
tableName: string;
|
|
73
|
-
clause?: clause.Clause
|
|
74
|
-
groupColumn:
|
|
75
|
-
fields:
|
|
73
|
+
clause?: clause.Clause<T, K>;
|
|
74
|
+
groupColumn: K;
|
|
75
|
+
fields: K[];
|
|
76
76
|
values: any[];
|
|
77
77
|
orderby?: string;
|
|
78
78
|
limit: number;
|
|
79
79
|
}
|
|
80
|
-
export declare function buildGroupQuery(options: GroupQueryOptions): [string, clause.Clause];
|
|
80
|
+
export declare function buildGroupQuery<T extends Data = Data, K = keyof T>(options: GroupQueryOptions<T, K>): [string, clause.Clause<T, K>];
|
|
81
81
|
export interface DataOperation<T extends Ent = Ent> {
|
|
82
82
|
preFetch?(queryer: Queryer, context?: Context): Promise<void>;
|
|
83
83
|
performWriteSync(queryer: SyncQueryer, context?: Context): void;
|
|
@@ -217,7 +217,7 @@ interface loadCustomEdgesOptions<T extends AssocEdge> extends loadEdgesOptions {
|
|
|
217
217
|
export declare const DefaultLimit = 1000;
|
|
218
218
|
export declare function loadEdges(options: loadEdgesOptions): Promise<AssocEdge[]>;
|
|
219
219
|
export declare function getEdgeClauseAndFields(cls: clause.Clause, options: Pick<loadEdgesOptions, "disableTransformations">): {
|
|
220
|
-
cls: clause.Clause
|
|
220
|
+
cls: clause.Clause<Data, string | number>;
|
|
221
221
|
fields: string[];
|
|
222
222
|
};
|
|
223
223
|
export declare function loadCustomEdges<T extends AssocEdge>(options: loadCustomEdgesOptions<T>): Promise<T[]>;
|
package/core/ent.js
CHANGED
|
@@ -437,11 +437,13 @@ async function loadCustomDataImpl(options, query, context) {
|
|
|
437
437
|
if (!optClause) {
|
|
438
438
|
return cls;
|
|
439
439
|
}
|
|
440
|
+
// @ts-expect-error string|ID mismatch
|
|
440
441
|
return clause.And(cls, optClause);
|
|
441
442
|
}
|
|
442
443
|
if (typeof query === "string") {
|
|
443
444
|
// no caching, perform raw query
|
|
444
445
|
return performRawQuery(query, [], []);
|
|
446
|
+
// @ts-ignore
|
|
445
447
|
}
|
|
446
448
|
else if (isClause(query)) {
|
|
447
449
|
// if a Clause is passed in and we have a default clause
|
|
@@ -451,6 +453,7 @@ async function loadCustomDataImpl(options, query, context) {
|
|
|
451
453
|
// this will have rudimentary caching but nothing crazy
|
|
452
454
|
return loadRows({
|
|
453
455
|
...options,
|
|
456
|
+
// @ts-ignore
|
|
454
457
|
clause: getClause(query),
|
|
455
458
|
context: context,
|
|
456
459
|
});
|
|
@@ -462,6 +465,7 @@ async function loadCustomDataImpl(options, query, context) {
|
|
|
462
465
|
else {
|
|
463
466
|
let cls = query.clause;
|
|
464
467
|
if (!query.disableTransformations) {
|
|
468
|
+
// @ts-ignore
|
|
465
469
|
cls = getClause(cls);
|
|
466
470
|
}
|
|
467
471
|
// this will have rudimentary caching but nothing crazy
|
|
@@ -762,6 +766,7 @@ class EditNodeOperation {
|
|
|
762
766
|
optionClause = opts.clause;
|
|
763
767
|
}
|
|
764
768
|
if (optionClause) {
|
|
769
|
+
// @ts-expect-error ID|string mismatch
|
|
765
770
|
cls = clause.And(cls, optionClause);
|
|
766
771
|
}
|
|
767
772
|
}
|
|
@@ -7,7 +7,7 @@ export declare class IndexLoaderFactory implements LoaderFactory<ID, Data[]> {
|
|
|
7
7
|
constructor(options: SelectBaseDataOptions, col: string, opts?: {
|
|
8
8
|
extraClause?: clause.Clause;
|
|
9
9
|
sortColumn?: string;
|
|
10
|
-
toPrime?: ObjectLoaderFactory<
|
|
10
|
+
toPrime?: ObjectLoaderFactory<Data>[];
|
|
11
11
|
});
|
|
12
12
|
createLoader(context?: Context): any;
|
|
13
13
|
createConfigurableLoader(options: EdgeQueryableDataOptions, context?: Context): Loader<ID, Data[]>;
|
package/core/loaders/loader.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Loader, LoaderFactory, Context, DataOptions } from "../base";
|
|
2
|
-
export declare function getLoader<
|
|
3
|
-
export declare function getCustomLoader<
|
|
2
|
+
export declare function getLoader<K, V>(factory: LoaderFactory<K, V>, create: () => Loader<K, V>, context?: Context): Loader<K, V>;
|
|
3
|
+
export declare function getCustomLoader<K, V>(key: string, create: () => Loader<K, V>, context?: Context): Loader<K, V>;
|
|
4
4
|
export declare class cacheMap {
|
|
5
5
|
private options;
|
|
6
6
|
private m;
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
import { ID, Data, SelectDataOptions, Context, Loader, LoaderFactory } from "../base";
|
|
2
|
-
export declare class ObjectLoader<
|
|
2
|
+
export declare class ObjectLoader<V = Data> implements Loader<ID, V | null> {
|
|
3
3
|
private options;
|
|
4
4
|
context?: Context<import("../base").Viewer<import("../base").Ent<any> | null, ID | null>> | undefined;
|
|
5
5
|
private toPrime?;
|
|
6
6
|
private loader;
|
|
7
7
|
private primedLoaders;
|
|
8
8
|
private memoizedInitPrime;
|
|
9
|
-
constructor(options: SelectDataOptions, context?: Context<import("../base").Viewer<import("../base").Ent<any> | null, ID | null>> | undefined, toPrime?: ObjectLoaderFactory<
|
|
9
|
+
constructor(options: SelectDataOptions, context?: Context<import("../base").Viewer<import("../base").Ent<any> | null, ID | null>> | undefined, toPrime?: ObjectLoaderFactory<V>[] | undefined);
|
|
10
10
|
getOptions(): SelectDataOptions;
|
|
11
11
|
private initPrime;
|
|
12
|
-
load(key:
|
|
12
|
+
load(key: ID): Promise<V | null>;
|
|
13
13
|
clearAll(): void;
|
|
14
|
-
loadMany(keys:
|
|
15
|
-
prime(data:
|
|
16
|
-
primeAll(data:
|
|
14
|
+
loadMany(keys: ID[]): Promise<Array<V | null>>;
|
|
15
|
+
prime(data: V): void;
|
|
16
|
+
primeAll(data: V): void;
|
|
17
17
|
}
|
|
18
18
|
interface ObjectLoaderOptions extends SelectDataOptions {
|
|
19
19
|
instanceKey?: string;
|
|
20
20
|
}
|
|
21
|
-
export declare class ObjectLoaderFactory<
|
|
21
|
+
export declare class ObjectLoaderFactory<V = Data> implements LoaderFactory<ID, V | null> {
|
|
22
22
|
options: ObjectLoaderOptions;
|
|
23
23
|
name: string;
|
|
24
24
|
private toPrime;
|
|
25
25
|
constructor(options: ObjectLoaderOptions);
|
|
26
|
-
createLoader(context?: Context): ObjectLoader<
|
|
27
|
-
addToPrime(factory: ObjectLoaderFactory<
|
|
26
|
+
createLoader(context?: Context): ObjectLoader<V>;
|
|
27
|
+
addToPrime(factory: ObjectLoaderFactory<V>): this;
|
|
28
28
|
}
|
|
29
29
|
export {};
|
|
@@ -45,6 +45,7 @@ async function loadRowsForLoader(options, ids, context) {
|
|
|
45
45
|
optionClause = options.clause;
|
|
46
46
|
}
|
|
47
47
|
if (optionClause) {
|
|
48
|
+
// @ts-expect-error id/string mismatch
|
|
48
49
|
cls = clause.And(cls, optionClause);
|
|
49
50
|
}
|
|
50
51
|
}
|
|
@@ -60,7 +61,7 @@ async function loadRowsForLoader(options, ids, context) {
|
|
|
60
61
|
// store the index....
|
|
61
62
|
m.set(ids[i], i);
|
|
62
63
|
}
|
|
63
|
-
const rows = await (0, ent_1.loadRows)(rowOptions);
|
|
64
|
+
const rows = (await (0, ent_1.loadRows)(rowOptions));
|
|
64
65
|
for (const row of rows) {
|
|
65
66
|
const id = row[col];
|
|
66
67
|
if (id === undefined) {
|
|
@@ -162,7 +163,8 @@ class ObjectLoader {
|
|
|
162
163
|
}
|
|
163
164
|
async loadMany(keys) {
|
|
164
165
|
if (this.loader) {
|
|
165
|
-
|
|
166
|
+
// @ts-expect-error TODO?
|
|
167
|
+
return this.loader.loadMany(keys);
|
|
166
168
|
}
|
|
167
169
|
return loadRowsForLoader(this.options, keys, this.context);
|
|
168
170
|
}
|
|
@@ -19,7 +19,7 @@ interface QueryOptions {
|
|
|
19
19
|
groupCol?: string;
|
|
20
20
|
clause?: clause.Clause;
|
|
21
21
|
sortColumn?: string;
|
|
22
|
-
toPrime?: ObjectLoaderFactory<
|
|
22
|
+
toPrime?: ObjectLoaderFactory<Data>[];
|
|
23
23
|
}
|
|
24
24
|
export declare class QueryLoaderFactory<K extends any> implements LoaderFactory<K, Data[]> {
|
|
25
25
|
private options;
|
package/package.json
CHANGED
|
@@ -34,4 +34,4 @@ export interface ContactCreateInput {
|
|
|
34
34
|
}
|
|
35
35
|
export declare function getContactBuilder(viewer: Viewer, input: ContactCreateInput): SimpleBuilder<FakeContact, null>;
|
|
36
36
|
export declare function createContact(viewer: Viewer, input: ContactCreateInput): Promise<void>;
|
|
37
|
-
export declare const contactLoader: ObjectLoaderFactory<
|
|
37
|
+
export declare const contactLoader: ObjectLoaderFactory<Data>;
|
|
@@ -33,4 +33,4 @@ export type TagEditInput = Partial<TagCreateInput>;
|
|
|
33
33
|
export declare function getTagBuilder(viewer: Viewer, input: TagCreateInput): import("../builder").SimpleBuilder<FakeTag, null>;
|
|
34
34
|
export declare function getTagAction(viewer: Viewer, input: TagCreateInput): SimpleAction<FakeTag, null>;
|
|
35
35
|
export declare function createTag(viewer: Viewer, input: TagCreateInput): Promise<FakeTag>;
|
|
36
|
-
export declare const tagLoader: ObjectLoaderFactory<
|
|
36
|
+
export declare const tagLoader: ObjectLoaderFactory<Data>;
|
|
@@ -46,7 +46,7 @@ export type UserEditInput = Partial<UserCreateInput>;
|
|
|
46
46
|
export declare function getUserBuilder(viewer: Viewer, input: UserCreateInput): import("../builder").SimpleBuilder<FakeUser, null>;
|
|
47
47
|
export declare function getUserAction(viewer: Viewer, input: UserCreateInput): SimpleAction<FakeUser, null>;
|
|
48
48
|
export declare function createUser(viewer: Viewer, input: UserCreateInput): Promise<FakeUser>;
|
|
49
|
-
export declare const userLoader: ObjectLoaderFactory<
|
|
50
|
-
export declare const userEmailLoader: ObjectLoaderFactory<
|
|
51
|
-
export declare const userPhoneNumberLoader: ObjectLoaderFactory<
|
|
49
|
+
export declare const userLoader: ObjectLoaderFactory<Data>;
|
|
50
|
+
export declare const userEmailLoader: ObjectLoaderFactory<Data>;
|
|
51
|
+
export declare const userPhoneNumberLoader: ObjectLoaderFactory<Data>;
|
|
52
52
|
export {};
|