@snowtop/ent 0.1.0-alpha6 → 0.1.0-alpha63
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/action/action.d.ts +28 -24
- package/action/executor.d.ts +4 -4
- package/action/executor.js +2 -2
- package/action/experimental_action.d.ts +29 -22
- package/action/experimental_action.js +29 -6
- package/action/orchestrator.d.ts +44 -16
- package/action/orchestrator.js +287 -73
- package/action/privacy.d.ts +2 -2
- package/core/base.d.ts +26 -22
- package/core/base.js +16 -0
- package/core/clause.d.ts +65 -3
- package/core/clause.js +368 -5
- package/core/config.d.ts +26 -0
- package/core/config.js +17 -0
- package/core/context.d.ts +2 -2
- package/core/context.js +2 -2
- package/core/convert.d.ts +1 -1
- package/core/db.d.ts +3 -4
- package/core/db.js +2 -0
- package/core/ent.d.ts +35 -24
- package/core/ent.js +223 -60
- package/core/loaders/assoc_count_loader.d.ts +2 -2
- package/core/loaders/assoc_count_loader.js +6 -1
- package/core/loaders/assoc_edge_loader.d.ts +3 -3
- package/core/loaders/assoc_edge_loader.js +5 -4
- package/core/loaders/index_loader.js +1 -0
- package/core/loaders/loader.js +5 -5
- package/core/loaders/object_loader.d.ts +10 -5
- package/core/loaders/object_loader.js +58 -4
- package/core/loaders/query_loader.d.ts +2 -2
- package/core/loaders/raw_count_loader.d.ts +2 -2
- package/core/logger.d.ts +1 -1
- package/core/logger.js +1 -0
- package/core/privacy.d.ts +25 -25
- package/core/privacy.js +3 -0
- package/core/query/assoc_query.d.ts +6 -6
- package/core/query/custom_query.d.ts +5 -5
- package/core/query/query.d.ts +1 -1
- package/core/query/shared_assoc_test.d.ts +1 -1
- package/core/query/shared_assoc_test.js +17 -5
- package/core/query/shared_test.d.ts +3 -0
- package/core/query/shared_test.js +95 -17
- package/core/viewer.d.ts +4 -3
- package/core/viewer.js +4 -0
- package/graphql/builtins/connection.js +3 -3
- package/graphql/builtins/edge.js +2 -2
- package/graphql/builtins/node.js +1 -1
- package/graphql/graphql.d.ts +3 -2
- package/graphql/graphql.js +30 -23
- package/graphql/node_resolver.d.ts +0 -1
- package/graphql/query/connection_type.js +6 -6
- package/graphql/query/edge_connection.d.ts +9 -9
- package/graphql/query/page_info.d.ts +1 -1
- package/graphql/query/page_info.js +4 -4
- package/graphql/query/shared_assoc_test.js +2 -2
- package/graphql/scalars/time.d.ts +1 -1
- package/index.d.ts +18 -1
- package/index.js +21 -5
- package/package.json +3 -3
- package/parse_schema/parse.d.ts +24 -5
- package/parse_schema/parse.js +90 -8
- package/schema/base_schema.d.ts +36 -1
- package/schema/base_schema.js +51 -2
- package/schema/field.d.ts +34 -6
- package/schema/field.js +68 -3
- package/schema/index.d.ts +2 -2
- package/schema/index.js +8 -1
- package/schema/schema.d.ts +95 -2
- package/schema/schema.js +127 -5
- package/scripts/custom_graphql.js +127 -16
- package/scripts/{transform_schema.d.ts → migrate_v0.1.d.ts} +0 -0
- package/scripts/migrate_v0.1.js +36 -0
- package/scripts/read_schema.js +25 -2
- package/testutils/builder.d.ts +36 -22
- package/testutils/builder.js +110 -13
- package/testutils/context/test_context.d.ts +2 -2
- package/testutils/context/test_context.js +7 -1
- package/testutils/db/{test_db.d.ts → temp_db.d.ts} +17 -4
- package/testutils/db/{test_db.js → temp_db.js} +75 -19
- package/testutils/ent-graphql-tests/index.d.ts +2 -0
- package/testutils/ent-graphql-tests/index.js +26 -17
- package/testutils/fake_data/fake_contact.d.ts +5 -9
- package/testutils/fake_data/fake_contact.js +17 -21
- package/testutils/fake_data/fake_event.d.ts +5 -9
- package/testutils/fake_data/fake_event.js +24 -28
- package/testutils/fake_data/fake_user.d.ts +6 -10
- package/testutils/fake_data/fake_user.js +25 -29
- package/testutils/fake_data/test_helpers.d.ts +2 -2
- package/testutils/fake_data/test_helpers.js +6 -6
- package/testutils/fake_data/user_query.d.ts +2 -2
- package/testutils/fake_log.d.ts +3 -3
- package/testutils/parse_sql.js +4 -0
- package/testutils/test_edge_global_schema.d.ts +15 -0
- package/testutils/test_edge_global_schema.js +58 -0
- package/testutils/write.d.ts +2 -2
- package/testutils/write.js +3 -3
- package/tsc/ast.d.ts +44 -0
- package/tsc/ast.js +267 -0
- package/tsc/compilerOptions.d.ts +6 -0
- package/tsc/compilerOptions.js +40 -1
- package/tsc/move_generated.d.ts +1 -0
- package/tsc/move_generated.js +160 -0
- package/tsc/transform.d.ts +21 -0
- package/tsc/transform.js +167 -0
- package/tsc/transform_action.d.ts +22 -0
- package/tsc/transform_action.js +179 -0
- package/tsc/transform_ent.d.ts +17 -0
- package/tsc/transform_ent.js +59 -0
- package/tsc/transform_schema.d.ts +27 -0
- package/tsc/transform_schema.js +379 -0
- package/scripts/transform_schema.js +0 -288
package/core/db.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { Pool,
|
|
2
|
-
export interface Database {
|
|
1
|
+
import { Pool, PoolClient, PoolConfig } from "pg";
|
|
2
|
+
export interface Database extends PoolConfig {
|
|
3
3
|
database?: string;
|
|
4
4
|
user?: string;
|
|
5
5
|
password?: string;
|
|
6
6
|
host?: string;
|
|
7
7
|
port?: number;
|
|
8
|
-
ssl?: boolean;
|
|
9
8
|
sslmode?: string;
|
|
10
9
|
}
|
|
11
10
|
export declare type env = "production" | "test" | "development";
|
|
@@ -16,7 +15,7 @@ export declare enum Dialect {
|
|
|
16
15
|
}
|
|
17
16
|
interface DatabaseInfo {
|
|
18
17
|
dialect: Dialect;
|
|
19
|
-
config:
|
|
18
|
+
config: PoolConfig;
|
|
20
19
|
filePath?: string;
|
|
21
20
|
}
|
|
22
21
|
export default class DB {
|
package/core/db.js
CHANGED
package/core/ent.d.ts
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { Queryer, SyncQueryer } from "./db";
|
|
2
|
-
import { Viewer, Ent, ID, LoadRowsOptions, LoadRowOptions, Data, DataOptions, QueryableDataOptions, EditRowOptions, LoadEntOptions, LoadCustomEntOptions, EdgeQueryableDataOptions, Context, SelectBaseDataOptions, CreateRowOptions, QueryDataOptions
|
|
2
|
+
import { Viewer, Ent, ID, LoadRowsOptions, LoadRowOptions, Data, DataOptions, QueryableDataOptions, EditRowOptions, LoadEntOptions, LoadCustomEntOptions, EdgeQueryableDataOptions, Context, SelectBaseDataOptions, CreateRowOptions, QueryDataOptions } from "./base";
|
|
3
3
|
import { Executor } from "../action/action";
|
|
4
4
|
import * as clause from "./clause";
|
|
5
5
|
import { Builder } from "../action";
|
|
6
6
|
import DataLoader from "dataloader";
|
|
7
|
-
|
|
8
|
-
export declare function
|
|
9
|
-
export declare function
|
|
10
|
-
export declare function
|
|
11
|
-
export declare function
|
|
12
|
-
export declare function
|
|
13
|
-
export declare function
|
|
14
|
-
export declare function
|
|
15
|
-
export declare function
|
|
16
|
-
export declare function
|
|
7
|
+
import { GlobalSchema } from "../schema/";
|
|
8
|
+
export declare function loadEnt<TEnt extends Ent<TViewer>, TViewer extends Viewer>(viewer: TViewer, id: ID, options: LoadEntOptions<TEnt, TViewer>): Promise<TEnt | null>;
|
|
9
|
+
export declare function loadEntViaKey<TEnt extends Ent<TViewer>, TViewer extends Viewer>(viewer: TViewer, key: any, options: LoadEntOptions<TEnt, TViewer>): Promise<TEnt | null>;
|
|
10
|
+
export declare function loadEntX<TEnt extends Ent<TViewer>, TViewer extends Viewer>(viewer: TViewer, id: ID, options: LoadEntOptions<TEnt, TViewer>): Promise<TEnt>;
|
|
11
|
+
export declare function loadEntXViaKey<TEnt extends Ent<TViewer>, TViewer extends Viewer>(viewer: TViewer, key: any, options: LoadEntOptions<TEnt, TViewer>): Promise<TEnt>;
|
|
12
|
+
export declare function loadEntFromClause<TEnt extends Ent<TViewer>, TViewer extends Viewer>(viewer: TViewer, options: LoadEntOptions<TEnt, TViewer>, clause: clause.Clause): Promise<TEnt | null>;
|
|
13
|
+
export declare function loadEntXFromClause<TEnt extends Ent<TViewer>, TViewer extends Viewer>(viewer: TViewer, options: LoadEntOptions<TEnt, TViewer>, clause: clause.Clause): Promise<TEnt>;
|
|
14
|
+
export declare function loadEnts<TEnt extends Ent<TViewer>, TViewer extends Viewer>(viewer: TViewer, options: LoadEntOptions<TEnt, TViewer>, ...ids: ID[]): Promise<Map<ID, TEnt>>;
|
|
15
|
+
export declare function loadEntsList<TEnt extends Ent<TViewer>, TViewer extends Viewer>(viewer: TViewer, options: LoadEntOptions<TEnt, TViewer>, ...ids: ID[]): Promise<TEnt[]>;
|
|
16
|
+
export declare function loadEntsFromClause<TEnt extends Ent<TViewer>, TViewer extends Viewer>(viewer: TViewer, clause: clause.Clause, options: LoadEntOptions<TEnt, TViewer>): Promise<Map<ID, TEnt>>;
|
|
17
|
+
export declare function loadCustomEnts<TEnt extends Ent<TViewer>, TViewer extends Viewer>(viewer: TViewer, options: LoadCustomEntOptions<TEnt, TViewer>, query: CustomQuery): Promise<TEnt[]>;
|
|
17
18
|
interface rawQueryOptions {
|
|
18
19
|
query: string;
|
|
19
20
|
values?: any[];
|
|
@@ -21,10 +22,8 @@ interface rawQueryOptions {
|
|
|
21
22
|
}
|
|
22
23
|
export declare type CustomQuery = string | rawQueryOptions | clause.Clause | QueryDataOptions;
|
|
23
24
|
export declare function loadCustomData(options: SelectBaseDataOptions, query: CustomQuery, context: Context | undefined): Promise<Data[]>;
|
|
24
|
-
export declare function loadDerivedEnt<
|
|
25
|
-
export declare function loadDerivedEntX<
|
|
26
|
-
export declare function applyPrivacyPolicyForEnt<T extends Ent>(viewer: Viewer, ent: T | null): Promise<T | null>;
|
|
27
|
-
export declare function applyPrivacyPolicyForEntX<T extends Ent>(viewer: Viewer, ent: T): Promise<T>;
|
|
25
|
+
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>;
|
|
26
|
+
export declare function loadDerivedEntX<TEnt extends Ent<TViewer>, TViewer extends Viewer>(viewer: TViewer, data: Data, loader: new (viewer: TViewer, data: Data) => TEnt): Promise<TEnt>;
|
|
28
27
|
export declare function loadRowX(options: LoadRowOptions): Promise<Data>;
|
|
29
28
|
export declare function loadRow(options: LoadRowOptions): Promise<Data | null>;
|
|
30
29
|
export declare function performRawQuery(query: string, values: any[], logValues?: any[]): Promise<Data[]>;
|
|
@@ -52,8 +51,9 @@ export interface DataOperation<T extends Ent = Ent> {
|
|
|
52
51
|
}
|
|
53
52
|
export interface EditNodeOptions<T extends Ent> extends EditRowOptions {
|
|
54
53
|
fieldsToResolve: string[];
|
|
55
|
-
|
|
54
|
+
loadEntOptions: LoadEntOptions<T>;
|
|
56
55
|
placeholderID?: ID;
|
|
56
|
+
key: string;
|
|
57
57
|
}
|
|
58
58
|
export declare class EditNodeOperation<T extends Ent> implements DataOperation {
|
|
59
59
|
options: EditNodeOptions<T>;
|
|
@@ -69,7 +69,11 @@ export declare class EditNodeOperation<T extends Ent> implements DataOperation {
|
|
|
69
69
|
returnedRow(): Data | null;
|
|
70
70
|
createdEnt(viewer: Viewer): T | null;
|
|
71
71
|
}
|
|
72
|
+
export declare function setGlobalSchema(val: GlobalSchema): void;
|
|
73
|
+
export declare function clearGlobalSchema(): void;
|
|
74
|
+
export declare function __hasGlobalSchema(): boolean;
|
|
72
75
|
export declare class EdgeOperation implements DataOperation {
|
|
76
|
+
private builder;
|
|
73
77
|
edgeInput: AssocEdgeInput;
|
|
74
78
|
private options;
|
|
75
79
|
private edgeData;
|
|
@@ -98,9 +102,9 @@ export declare class EdgeOperation implements DataOperation {
|
|
|
98
102
|
export declare function buildInsertQuery(options: CreateRowOptions, suffix?: string): [string, string[], string[]];
|
|
99
103
|
export declare function createRow(queryer: Queryer, options: CreateRowOptions, suffix: string): Promise<Data | null>;
|
|
100
104
|
export declare function createRowSync(queryer: SyncQueryer, options: CreateRowOptions, suffix: string): Data | null;
|
|
101
|
-
export declare function buildUpdateQuery(options: EditRowOptions,
|
|
102
|
-
export declare function editRow(queryer: Queryer, options: EditRowOptions,
|
|
103
|
-
export declare function editRowSync(queryer: SyncQueryer, options: EditRowOptions,
|
|
105
|
+
export declare function buildUpdateQuery(options: EditRowOptions, suffix?: string): [string, any[], any[]];
|
|
106
|
+
export declare function editRow(queryer: Queryer, options: EditRowOptions, suffix?: string): Promise<Data | null>;
|
|
107
|
+
export declare function editRowSync(queryer: SyncQueryer, options: EditRowOptions, suffix?: string): Data | null;
|
|
104
108
|
export declare function deleteRows(queryer: Queryer, options: DataOptions, cls: clause.Clause): Promise<void>;
|
|
105
109
|
export declare function deleteRowsSync(queryer: SyncQueryer, options: DataOptions, cls: clause.Clause): void;
|
|
106
110
|
export declare class DeleteNodeOperation implements DataOperation {
|
|
@@ -118,7 +122,9 @@ export declare class AssocEdge {
|
|
|
118
122
|
id2Type: string;
|
|
119
123
|
time: Date;
|
|
120
124
|
data?: string | null;
|
|
125
|
+
private rawData;
|
|
121
126
|
constructor(data: Data);
|
|
127
|
+
__getRawData(): Data;
|
|
122
128
|
getCursor(): string;
|
|
123
129
|
}
|
|
124
130
|
interface cursorOptions {
|
|
@@ -147,7 +153,7 @@ export declare class AssocEdgeData {
|
|
|
147
153
|
edgeTable: string;
|
|
148
154
|
constructor(data: Data);
|
|
149
155
|
}
|
|
150
|
-
export declare const assocEdgeLoader: DataLoader<
|
|
156
|
+
export declare const assocEdgeLoader: DataLoader<ID, Data | null, ID>;
|
|
151
157
|
export declare function loadEdgeData(edgeType: string): Promise<AssocEdgeData | null>;
|
|
152
158
|
export declare function loadEdgeDatas(...edgeTypes: string[]): Promise<Map<string, AssocEdgeData>>;
|
|
153
159
|
export interface AssocEdgeConstructor<T extends AssocEdge> {
|
|
@@ -158,6 +164,7 @@ interface loadEdgesOptions {
|
|
|
158
164
|
edgeType: string;
|
|
159
165
|
context?: Context;
|
|
160
166
|
queryOptions?: EdgeQueryableDataOptions;
|
|
167
|
+
disableTransformations?: boolean;
|
|
161
168
|
}
|
|
162
169
|
interface loadCustomEdgesOptions<T extends AssocEdge> extends loadEdgesOptions {
|
|
163
170
|
ctr: AssocEdgeConstructor<T>;
|
|
@@ -165,17 +172,21 @@ interface loadCustomEdgesOptions<T extends AssocEdge> extends loadEdgesOptions {
|
|
|
165
172
|
export declare const DefaultLimit = 1000;
|
|
166
173
|
export declare function defaultEdgeQueryOptions(id1: ID, edgeType: string): EdgeQueryableDataOptions;
|
|
167
174
|
export declare function loadEdges(options: loadEdgesOptions): Promise<AssocEdge[]>;
|
|
175
|
+
export declare function getEdgeClauseAndFields(cls: clause.Clause, options: loadEdgesOptions): {
|
|
176
|
+
cls: clause.Clause;
|
|
177
|
+
fields: string[];
|
|
178
|
+
};
|
|
168
179
|
export declare function loadCustomEdges<T extends AssocEdge>(options: loadCustomEdgesOptions<T>): Promise<T[]>;
|
|
169
180
|
export declare function loadUniqueEdge(options: loadEdgesOptions): Promise<AssocEdge | null>;
|
|
170
|
-
export declare function loadUniqueNode<
|
|
181
|
+
export declare function loadUniqueNode<TEnt extends Ent<TViewer>, TViewer extends Viewer>(viewer: TViewer, id1: ID, edgeType: string, options: LoadEntOptions<TEnt, TViewer>): Promise<TEnt | null>;
|
|
171
182
|
export declare function loadRawEdgeCountX(options: loadEdgesOptions): Promise<number>;
|
|
172
183
|
interface loadEdgeForIDOptions<T extends AssocEdge> extends loadCustomEdgesOptions<T> {
|
|
173
184
|
id2: ID;
|
|
174
185
|
}
|
|
175
186
|
export declare function loadEdgeForID2<T extends AssocEdge>(options: loadEdgeForIDOptions<T>): Promise<T | undefined>;
|
|
176
187
|
export declare function loadNodesByEdge<T extends Ent>(viewer: Viewer, id1: ID, edgeType: string, options: LoadEntOptions<T>): Promise<T[]>;
|
|
177
|
-
export declare function applyPrivacyPolicyForRow<
|
|
178
|
-
export declare function applyPrivacyPolicyForRowX<
|
|
179
|
-
export declare function applyPrivacyPolicyForRows<
|
|
188
|
+
export declare function applyPrivacyPolicyForRow<TEnt extends Ent<TViewer>, TViewer extends Viewer>(viewer: TViewer, options: LoadEntOptions<TEnt, TViewer>, row: Data | null): Promise<TEnt | null>;
|
|
189
|
+
export declare function applyPrivacyPolicyForRowX<TEnt extends Ent<TViewer>, TViewer extends Viewer>(viewer: TViewer, options: LoadEntOptions<TEnt, TViewer>, row: Data): Promise<TEnt>;
|
|
190
|
+
export declare function applyPrivacyPolicyForRows<TEnt extends Ent<TViewer>, TViewer extends Viewer>(viewer: TViewer, rows: Data[], options: LoadEntOptions<TEnt, TViewer>): Promise<Map<ID, TEnt>>;
|
|
180
191
|
export declare function getEdgeTypeInGroup<T extends string>(viewer: Viewer, id1: ID, id2: ID, m: Map<T, string>): Promise<[T, AssocEdge] | undefined>;
|
|
181
192
|
export {};
|