@snowtop/ent 0.1.0-alpha3 → 0.1.0-alpha34
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 +21 -20
- package/action/experimental_action.js +11 -5
- package/action/orchestrator.d.ts +31 -16
- package/action/orchestrator.js +164 -43
- package/action/privacy.d.ts +2 -2
- package/core/base.d.ts +25 -21
- package/core/base.js +16 -0
- package/core/clause.d.ts +24 -3
- package/core/clause.js +246 -5
- package/core/config.d.ts +23 -0
- package/core/config.js +17 -0
- package/core/context.d.ts +2 -2
- package/core/convert.d.ts +1 -1
- package/core/db.d.ts +3 -3
- package/core/db.js +2 -0
- package/core/ent.d.ts +19 -21
- package/core/ent.js +76 -25
- package/core/loaders/assoc_count_loader.d.ts +2 -2
- 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/object_loader.d.ts +10 -5
- package/core/loaders/object_loader.js +59 -4
- package/core/loaders/query_loader.d.ts +2 -2
- package/core/loaders/raw_count_loader.d.ts +2 -2
- 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/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 +24 -23
- package/graphql/index.d.ts +1 -0
- package/graphql/index.js +3 -1
- package/graphql/mutations/union.d.ts +2 -0
- package/graphql/mutations/union.js +35 -0
- 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 +16 -1
- package/index.js +18 -5
- package/package.json +3 -3
- package/parse_schema/parse.d.ts +18 -5
- package/parse_schema/parse.js +55 -6
- package/schema/base_schema.d.ts +36 -1
- package/schema/base_schema.js +51 -2
- package/schema/field.d.ts +1 -1
- package/schema/field.js +1 -1
- package/schema/index.d.ts +2 -2
- package/schema/index.js +8 -1
- package/schema/schema.d.ts +61 -1
- package/schema/schema.js +126 -5
- package/schema/union_field.d.ts +2 -1
- package/schema/union_field.js +32 -14
- package/scripts/custom_graphql.js +122 -15
- 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 +15 -1
- package/testutils/builder.d.ts +31 -21
- package/testutils/builder.js +98 -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 +2 -1
- package/testutils/db/test_db.js +13 -4
- 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 +4 -8
- package/testutils/fake_data/fake_contact.js +15 -19
- package/testutils/fake_data/fake_event.d.ts +4 -8
- package/testutils/fake_data/fake_event.js +21 -25
- package/testutils/fake_data/fake_user.d.ts +5 -9
- package/testutils/fake_data/fake_user.js +23 -27
- package/testutils/fake_data/test_helpers.js +1 -1
- package/testutils/fake_data/user_query.d.ts +2 -2
- package/testutils/fake_log.d.ts +3 -3
- package/tsc/ast.d.ts +43 -0
- package/tsc/ast.js +264 -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 +20 -0
- package/tsc/transform_action.js +169 -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 +354 -0
- package/scripts/transform_schema.js +0 -288
package/core/clause.js
CHANGED
|
@@ -19,10 +19,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.sensitiveValue = exports.In = exports.Or = exports.And = exports.LessEq = exports.GreaterEq = exports.Less = exports.Greater = exports.NotEq = exports.Eq = void 0;
|
|
22
|
+
exports.sensitiveValue = exports.TsVectorWebsearchToTsQuery = exports.TsVectorPhraseToTsQuery = exports.TsVectorPlainToTsQuery = exports.TsVectorColTsQuery = exports.WebsearchToTsQuery = exports.PhraseToTsQuery = exports.PlainToTsQuery = exports.TsQuery = exports.In = exports.Or = exports.AndOptional = exports.And = exports.LessEq = exports.GreaterEq = exports.Less = exports.Greater = exports.NotEq = exports.Eq = exports.ArrayLessEq = exports.ArrayGreaterEq = exports.ArrayLess = exports.ArrayGreater = exports.ArrayNotEq = exports.ArrayEq = void 0;
|
|
23
23
|
const db_1 = __importStar(require("./db"));
|
|
24
24
|
function isSensitive(val) {
|
|
25
|
-
return (
|
|
25
|
+
return (val !== null &&
|
|
26
|
+
typeof val === "object" &&
|
|
27
|
+
val.logValue !== undefined);
|
|
26
28
|
}
|
|
27
29
|
function rawValue(val) {
|
|
28
30
|
if (isSensitive(val)) {
|
|
@@ -31,17 +33,105 @@ function rawValue(val) {
|
|
|
31
33
|
return val;
|
|
32
34
|
}
|
|
33
35
|
class simpleClause {
|
|
34
|
-
constructor(col, value, op) {
|
|
36
|
+
constructor(col, value, op, handleSqliteNull) {
|
|
35
37
|
this.col = col;
|
|
36
38
|
this.value = value;
|
|
37
39
|
this.op = op;
|
|
40
|
+
this.handleSqliteNull = handleSqliteNull;
|
|
38
41
|
}
|
|
39
42
|
clause(idx) {
|
|
43
|
+
const sqliteClause = this.sqliteNull();
|
|
44
|
+
if (sqliteClause) {
|
|
45
|
+
return sqliteClause.clause(idx);
|
|
46
|
+
}
|
|
40
47
|
if (db_1.default.getDialect() === db_1.Dialect.Postgres) {
|
|
41
48
|
return `${this.col} ${this.op} $${idx}`;
|
|
42
49
|
}
|
|
43
50
|
return `${this.col} ${this.op} ?`;
|
|
44
51
|
}
|
|
52
|
+
sqliteNull() {
|
|
53
|
+
if (!this.handleSqliteNull || this.value !== null) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (db_1.default.getDialect() !== db_1.Dialect.SQLite) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
return this.handleSqliteNull;
|
|
60
|
+
}
|
|
61
|
+
values() {
|
|
62
|
+
const sqliteClause = this.sqliteNull();
|
|
63
|
+
if (sqliteClause) {
|
|
64
|
+
return sqliteClause.values();
|
|
65
|
+
}
|
|
66
|
+
if (isSensitive(this.value)) {
|
|
67
|
+
return [this.value.value()];
|
|
68
|
+
}
|
|
69
|
+
return [this.value];
|
|
70
|
+
}
|
|
71
|
+
logValues() {
|
|
72
|
+
const sqliteClause = this.sqliteNull();
|
|
73
|
+
if (sqliteClause) {
|
|
74
|
+
return sqliteClause.logValues();
|
|
75
|
+
}
|
|
76
|
+
if (isSensitive(this.value)) {
|
|
77
|
+
return [this.value.logValue()];
|
|
78
|
+
}
|
|
79
|
+
return [this.value];
|
|
80
|
+
}
|
|
81
|
+
instanceKey() {
|
|
82
|
+
const sqliteClause = this.sqliteNull();
|
|
83
|
+
if (sqliteClause) {
|
|
84
|
+
return sqliteClause.instanceKey();
|
|
85
|
+
}
|
|
86
|
+
return `${this.col}${this.op}${rawValue(this.value)}`;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
class isNullClause {
|
|
90
|
+
constructor(col) {
|
|
91
|
+
this.col = col;
|
|
92
|
+
}
|
|
93
|
+
clause(idx) {
|
|
94
|
+
return `${this.col} IS NULL`;
|
|
95
|
+
}
|
|
96
|
+
values() {
|
|
97
|
+
return [];
|
|
98
|
+
}
|
|
99
|
+
logValues() {
|
|
100
|
+
return [];
|
|
101
|
+
}
|
|
102
|
+
instanceKey() {
|
|
103
|
+
return `${this.col} IS NULL`;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
class isNotNullClause {
|
|
107
|
+
constructor(col) {
|
|
108
|
+
this.col = col;
|
|
109
|
+
}
|
|
110
|
+
clause(idx) {
|
|
111
|
+
return `${this.col} IS NOT NULL`;
|
|
112
|
+
}
|
|
113
|
+
values() {
|
|
114
|
+
return [];
|
|
115
|
+
}
|
|
116
|
+
logValues() {
|
|
117
|
+
return [];
|
|
118
|
+
}
|
|
119
|
+
instanceKey() {
|
|
120
|
+
return `${this.col} IS NOT NULL`;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
class arraySimpleClause {
|
|
124
|
+
constructor(col, value, op) {
|
|
125
|
+
this.col = col;
|
|
126
|
+
this.value = value;
|
|
127
|
+
this.op = op;
|
|
128
|
+
}
|
|
129
|
+
clause(idx) {
|
|
130
|
+
if (db_1.default.getDialect() === db_1.Dialect.Postgres) {
|
|
131
|
+
return `$${idx} ${this.op} ANY(${this.col})`;
|
|
132
|
+
}
|
|
133
|
+
return `${this.col} ${this.op} ?`;
|
|
134
|
+
}
|
|
45
135
|
values() {
|
|
46
136
|
if (isSensitive(this.value)) {
|
|
47
137
|
return [this.value.value()];
|
|
@@ -145,12 +235,100 @@ class compositeClause {
|
|
|
145
235
|
return keys.join(this.sep);
|
|
146
236
|
}
|
|
147
237
|
}
|
|
238
|
+
class tsQueryClause {
|
|
239
|
+
constructor(col, val, tsVectorCol) {
|
|
240
|
+
this.col = col;
|
|
241
|
+
this.val = val;
|
|
242
|
+
this.tsVectorCol = tsVectorCol;
|
|
243
|
+
}
|
|
244
|
+
isTsQuery(val) {
|
|
245
|
+
return typeof val !== "string";
|
|
246
|
+
}
|
|
247
|
+
getInfo() {
|
|
248
|
+
if (this.isTsQuery(this.val)) {
|
|
249
|
+
return { value: this.val.value, language: this.val.language };
|
|
250
|
+
}
|
|
251
|
+
return {
|
|
252
|
+
language: "english",
|
|
253
|
+
value: this.val,
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
clause(idx) {
|
|
257
|
+
const { language } = this.getInfo();
|
|
258
|
+
if (db_1.Dialect.Postgres === db_1.default.getDialect()) {
|
|
259
|
+
if (this.tsVectorCol) {
|
|
260
|
+
return `to_tsvector(${this.col}) @@ ${this.getFunction()}('${language}', $${idx})`;
|
|
261
|
+
}
|
|
262
|
+
return `${this.col} @@ ${this.getFunction()}('${language}', $${idx})`;
|
|
263
|
+
}
|
|
264
|
+
// FYI this doesn't actually work for sqlite since different
|
|
265
|
+
return `${this.col} @@ ${this.getFunction()}('${language}', ?)`;
|
|
266
|
+
}
|
|
267
|
+
values() {
|
|
268
|
+
const { value } = this.getInfo();
|
|
269
|
+
return [value];
|
|
270
|
+
}
|
|
271
|
+
logValues() {
|
|
272
|
+
const { value } = this.getInfo();
|
|
273
|
+
return [value];
|
|
274
|
+
}
|
|
275
|
+
getFunction() {
|
|
276
|
+
return "to_tsquery";
|
|
277
|
+
}
|
|
278
|
+
instanceKey() {
|
|
279
|
+
const { language, value } = this.getInfo();
|
|
280
|
+
if (this.tsVectorCol) {
|
|
281
|
+
return `to_tsvector(${this.col})@@${this.getFunction()}:${language}:${value}`;
|
|
282
|
+
}
|
|
283
|
+
return `${this.col}@@${this.getFunction()}:${language}:${value}`;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
class plainToTsQueryClause extends tsQueryClause {
|
|
287
|
+
getFunction() {
|
|
288
|
+
return "plainto_tsquery";
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
class phraseToTsQueryClause extends tsQueryClause {
|
|
292
|
+
getFunction() {
|
|
293
|
+
return "phraseto_tsquery";
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
class websearchTosQueryClause extends tsQueryClause {
|
|
297
|
+
getFunction() {
|
|
298
|
+
return "websearch_to_tsquery";
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
// TODO we need to check sqlite version...
|
|
302
|
+
function ArrayEq(col, value) {
|
|
303
|
+
return new arraySimpleClause(col, value, "=");
|
|
304
|
+
}
|
|
305
|
+
exports.ArrayEq = ArrayEq;
|
|
306
|
+
function ArrayNotEq(col, value) {
|
|
307
|
+
return new arraySimpleClause(col, value, "!=");
|
|
308
|
+
}
|
|
309
|
+
exports.ArrayNotEq = ArrayNotEq;
|
|
310
|
+
function ArrayGreater(col, value) {
|
|
311
|
+
return new arraySimpleClause(col, value, ">");
|
|
312
|
+
}
|
|
313
|
+
exports.ArrayGreater = ArrayGreater;
|
|
314
|
+
function ArrayLess(col, value) {
|
|
315
|
+
return new arraySimpleClause(col, value, "<");
|
|
316
|
+
}
|
|
317
|
+
exports.ArrayLess = ArrayLess;
|
|
318
|
+
function ArrayGreaterEq(col, value) {
|
|
319
|
+
return new arraySimpleClause(col, value, ">=");
|
|
320
|
+
}
|
|
321
|
+
exports.ArrayGreaterEq = ArrayGreaterEq;
|
|
322
|
+
function ArrayLessEq(col, value) {
|
|
323
|
+
return new arraySimpleClause(col, value, "<=");
|
|
324
|
+
}
|
|
325
|
+
exports.ArrayLessEq = ArrayLessEq;
|
|
148
326
|
function Eq(col, value) {
|
|
149
|
-
return new simpleClause(col, value, "=");
|
|
327
|
+
return new simpleClause(col, value, "=", new isNullClause(col));
|
|
150
328
|
}
|
|
151
329
|
exports.Eq = Eq;
|
|
152
330
|
function NotEq(col, value) {
|
|
153
|
-
return new simpleClause(col, value, "!=");
|
|
331
|
+
return new simpleClause(col, value, "!=", new isNotNullClause(col));
|
|
154
332
|
}
|
|
155
333
|
exports.NotEq = NotEq;
|
|
156
334
|
function Greater(col, value) {
|
|
@@ -173,6 +351,15 @@ function And(...args) {
|
|
|
173
351
|
return new compositeClause(args, " AND ");
|
|
174
352
|
}
|
|
175
353
|
exports.And = And;
|
|
354
|
+
function AndOptional(...args) {
|
|
355
|
+
// @ts-ignore
|
|
356
|
+
let filtered = args.filter((v) => v !== undefined);
|
|
357
|
+
if (filtered.length === 1) {
|
|
358
|
+
return filtered[0];
|
|
359
|
+
}
|
|
360
|
+
return And(...filtered);
|
|
361
|
+
}
|
|
362
|
+
exports.AndOptional = AndOptional;
|
|
176
363
|
function Or(...args) {
|
|
177
364
|
return new compositeClause(args, " OR ");
|
|
178
365
|
}
|
|
@@ -182,6 +369,60 @@ function In(col, ...values) {
|
|
|
182
369
|
return new inClause(col, values);
|
|
183
370
|
}
|
|
184
371
|
exports.In = In;
|
|
372
|
+
// if string defaults to english
|
|
373
|
+
// https://www.postgresql.org/docs/current/textsearch-controls.html#TEXTSEARCH-PARSING-QUERIES
|
|
374
|
+
// to_tsquery
|
|
375
|
+
// plainto_tsquery
|
|
376
|
+
// phraseto_tsquery;
|
|
377
|
+
// websearch_to_tsquery
|
|
378
|
+
function TsQuery(col, val) {
|
|
379
|
+
return new tsQueryClause(col, val);
|
|
380
|
+
}
|
|
381
|
+
exports.TsQuery = TsQuery;
|
|
382
|
+
function PlainToTsQuery(col, val) {
|
|
383
|
+
return new plainToTsQueryClause(col, val);
|
|
384
|
+
}
|
|
385
|
+
exports.PlainToTsQuery = PlainToTsQuery;
|
|
386
|
+
function PhraseToTsQuery(col, val) {
|
|
387
|
+
return new phraseToTsQueryClause(col, val);
|
|
388
|
+
}
|
|
389
|
+
exports.PhraseToTsQuery = PhraseToTsQuery;
|
|
390
|
+
function WebsearchToTsQuery(col, val) {
|
|
391
|
+
return new websearchTosQueryClause(col, val);
|
|
392
|
+
}
|
|
393
|
+
exports.WebsearchToTsQuery = WebsearchToTsQuery;
|
|
394
|
+
// TsVectorColTsQuery is used when the column is not a tsvector field e.g.
|
|
395
|
+
// when there's an index just on the field and is not a combination of multiple fields
|
|
396
|
+
function TsVectorColTsQuery(col, val) {
|
|
397
|
+
return new tsQueryClause(col, val, true);
|
|
398
|
+
}
|
|
399
|
+
exports.TsVectorColTsQuery = TsVectorColTsQuery;
|
|
400
|
+
// TsVectorPlainToTsQuery is used when the column is not a tsvector field e.g.
|
|
401
|
+
// when there's an index just on the field and is not a combination of multiple fields
|
|
402
|
+
// TODO do these 4 need TsQuery because would be nice to have language?
|
|
403
|
+
// it seems to default to the config of the column
|
|
404
|
+
function TsVectorPlainToTsQuery(col, val) {
|
|
405
|
+
return new plainToTsQueryClause(col, val, true);
|
|
406
|
+
}
|
|
407
|
+
exports.TsVectorPlainToTsQuery = TsVectorPlainToTsQuery;
|
|
408
|
+
// TsVectorPhraseToTsQuery is used when the column is not a tsvector field e.g.
|
|
409
|
+
// when there's an index just on the field and is not a combination of multiple fields
|
|
410
|
+
function TsVectorPhraseToTsQuery(col, val) {
|
|
411
|
+
return new phraseToTsQueryClause(col, val, true);
|
|
412
|
+
}
|
|
413
|
+
exports.TsVectorPhraseToTsQuery = TsVectorPhraseToTsQuery;
|
|
414
|
+
// TsVectorWebsearchToTsQuery is used when the column is not a tsvector field e.g.
|
|
415
|
+
// when there's an index just on the field and is not a combination of multiple fields
|
|
416
|
+
function TsVectorWebsearchToTsQuery(col, val) {
|
|
417
|
+
return new websearchTosQueryClause(col, val, true);
|
|
418
|
+
}
|
|
419
|
+
exports.TsVectorWebsearchToTsQuery = TsVectorWebsearchToTsQuery;
|
|
420
|
+
// TODO would be nice to support this with building blocks but not supporting for now
|
|
421
|
+
// AND: foo & bar,
|
|
422
|
+
// OR: foo | bar
|
|
423
|
+
// followed by: foo <-> bar
|
|
424
|
+
// NOT: !foo
|
|
425
|
+
// starts_with: theo:*
|
|
185
426
|
// wrap a query in the db with this to ensure that it doesn't show up in the logs
|
|
186
427
|
// e.g. if querying for password, SSN, etc
|
|
187
428
|
// we'll pass the right fields to query and log something along the lines of `****`
|
package/core/config.d.ts
CHANGED
|
@@ -1,12 +1,25 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Database, DBDict } from "./db";
|
|
3
3
|
declare type logType = "query" | "warn" | "info" | "error" | "debug";
|
|
4
|
+
declare enum graphqlMutationName {
|
|
5
|
+
NOUN_VERB = "NounVerb",
|
|
6
|
+
VERB_NOUN = "VerbNoun"
|
|
7
|
+
}
|
|
8
|
+
declare enum graphQLFieldFormat {
|
|
9
|
+
LOWER_CAMEL = "lowerCamel",
|
|
10
|
+
SNAKE_CASE = "snake_case"
|
|
11
|
+
}
|
|
12
|
+
declare enum fieldPrivacyEvaluated {
|
|
13
|
+
AT_ENT_LOAD = "at_ent_load",
|
|
14
|
+
ON_DEMAND = "on_demand"
|
|
15
|
+
}
|
|
4
16
|
export interface Config {
|
|
5
17
|
dbConnectionString?: string;
|
|
6
18
|
dbFile?: string;
|
|
7
19
|
db?: Database | DBDict;
|
|
8
20
|
log?: logType | logType[];
|
|
9
21
|
codegen?: CodegenConfig;
|
|
22
|
+
customGraphQLJSONPath?: string;
|
|
10
23
|
}
|
|
11
24
|
interface CodegenConfig {
|
|
12
25
|
defaultEntPolicy?: PrivacyConfig;
|
|
@@ -17,6 +30,12 @@ interface CodegenConfig {
|
|
|
17
30
|
generatedHeader?: string;
|
|
18
31
|
disableBase64Encoding?: boolean;
|
|
19
32
|
generateRootResolvers?: boolean;
|
|
33
|
+
defaultGraphQLMutationName?: graphqlMutationName;
|
|
34
|
+
defaultGraphQLFieldFormat?: graphQLFieldFormat;
|
|
35
|
+
schemaSQLFilePath?: boolean;
|
|
36
|
+
databaseToCompareTo?: string;
|
|
37
|
+
fieldPrivacyEvaluated?: fieldPrivacyEvaluated;
|
|
38
|
+
templatizedViewer?: templatizedViewer;
|
|
20
39
|
}
|
|
21
40
|
interface PrettierConfig {
|
|
22
41
|
custom?: boolean;
|
|
@@ -27,5 +46,9 @@ interface PrivacyConfig {
|
|
|
27
46
|
policyName: string;
|
|
28
47
|
class?: boolean;
|
|
29
48
|
}
|
|
49
|
+
interface templatizedViewer {
|
|
50
|
+
path: string;
|
|
51
|
+
name: string;
|
|
52
|
+
}
|
|
30
53
|
export declare function loadConfig(file?: string | Buffer | Config): void;
|
|
31
54
|
export {};
|
package/core/config.js
CHANGED
|
@@ -28,6 +28,23 @@ const js_yaml_1 = require("js-yaml");
|
|
|
28
28
|
const db_1 = __importDefault(require("./db"));
|
|
29
29
|
const path = __importStar(require("path"));
|
|
30
30
|
const logger_1 = require("./logger");
|
|
31
|
+
// ent.config.ts eventually. for now ent.yml
|
|
32
|
+
// or ent.yml?
|
|
33
|
+
var graphqlMutationName;
|
|
34
|
+
(function (graphqlMutationName) {
|
|
35
|
+
graphqlMutationName["NOUN_VERB"] = "NounVerb";
|
|
36
|
+
graphqlMutationName["VERB_NOUN"] = "VerbNoun";
|
|
37
|
+
})(graphqlMutationName || (graphqlMutationName = {}));
|
|
38
|
+
var graphQLFieldFormat;
|
|
39
|
+
(function (graphQLFieldFormat) {
|
|
40
|
+
graphQLFieldFormat["LOWER_CAMEL"] = "lowerCamel";
|
|
41
|
+
graphQLFieldFormat["SNAKE_CASE"] = "snake_case";
|
|
42
|
+
})(graphQLFieldFormat || (graphQLFieldFormat = {}));
|
|
43
|
+
var fieldPrivacyEvaluated;
|
|
44
|
+
(function (fieldPrivacyEvaluated) {
|
|
45
|
+
fieldPrivacyEvaluated["AT_ENT_LOAD"] = "at_ent_load";
|
|
46
|
+
fieldPrivacyEvaluated["ON_DEMAND"] = "on_demand";
|
|
47
|
+
})(fieldPrivacyEvaluated || (fieldPrivacyEvaluated = {}));
|
|
31
48
|
function setConfig(cfg) {
|
|
32
49
|
if (cfg.log) {
|
|
33
50
|
(0, logger_1.setLogLevels)(cfg.log);
|
package/core/context.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ import { Viewer, Data, Loader } from "./base";
|
|
|
3
3
|
import { IncomingMessage, ServerResponse } from "http";
|
|
4
4
|
import * as clause from "./clause";
|
|
5
5
|
import { Context } from "./base";
|
|
6
|
-
export interface RequestContext extends Context {
|
|
7
|
-
authViewer(viewer:
|
|
6
|
+
export interface RequestContext<TViewer extends Viewer = Viewer> extends Context<TViewer> {
|
|
7
|
+
authViewer(viewer: TViewer): Promise<void>;
|
|
8
8
|
logout(): Promise<void>;
|
|
9
9
|
request: IncomingMessage;
|
|
10
10
|
response: ServerResponse;
|
package/core/convert.d.ts
CHANGED
|
@@ -10,5 +10,5 @@ export declare function convertBoolList(val: any): boolean[];
|
|
|
10
10
|
export declare function convertNullableBoolList(val: any): boolean[] | null;
|
|
11
11
|
export declare function convertJSON(val: any): any;
|
|
12
12
|
export declare function convertNullableJSON(val: any): any | null;
|
|
13
|
-
export declare function convertJSONList(val: any):
|
|
13
|
+
export declare function convertJSONList(val: any): any[];
|
|
14
14
|
export declare function convertNullableJSONList(val: any): any[] | null;
|
package/core/db.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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;
|
|
@@ -16,7 +16,7 @@ export declare enum Dialect {
|
|
|
16
16
|
}
|
|
17
17
|
interface DatabaseInfo {
|
|
18
18
|
dialect: Dialect;
|
|
19
|
-
config:
|
|
19
|
+
config: PoolConfig;
|
|
20
20
|
filePath?: string;
|
|
21
21
|
}
|
|
22
22
|
export default class DB {
|
package/core/db.js
CHANGED
package/core/ent.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
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
|
-
export declare function loadEnt<
|
|
8
|
-
export declare function loadEntViaKey<
|
|
9
|
-
export declare function loadEntX<
|
|
10
|
-
export declare function loadEntXViaKey<
|
|
11
|
-
export declare function loadEntFromClause<
|
|
12
|
-
export declare function loadEntXFromClause<
|
|
13
|
-
export declare function loadEnts<
|
|
14
|
-
export declare function loadEntsList<
|
|
15
|
-
export declare function loadEntsFromClause<
|
|
16
|
-
export declare function loadCustomEnts<
|
|
7
|
+
export declare function loadEnt<TEnt extends Ent<TViewer>, TViewer extends Viewer>(viewer: TViewer, id: ID, options: LoadEntOptions<TEnt, TViewer>): Promise<TEnt | null>;
|
|
8
|
+
export declare function loadEntViaKey<TEnt extends Ent<TViewer>, TViewer extends Viewer>(viewer: TViewer, key: any, options: LoadEntOptions<TEnt, TViewer>): Promise<TEnt | null>;
|
|
9
|
+
export declare function loadEntX<TEnt extends Ent<TViewer>, TViewer extends Viewer>(viewer: TViewer, id: ID, options: LoadEntOptions<TEnt, TViewer>): Promise<TEnt>;
|
|
10
|
+
export declare function loadEntXViaKey<TEnt extends Ent<TViewer>, TViewer extends Viewer>(viewer: TViewer, key: any, options: LoadEntOptions<TEnt, TViewer>): Promise<TEnt>;
|
|
11
|
+
export declare function loadEntFromClause<TEnt extends Ent<TViewer>, TViewer extends Viewer>(viewer: TViewer, options: LoadEntOptions<TEnt, TViewer>, clause: clause.Clause): Promise<TEnt | null>;
|
|
12
|
+
export declare function loadEntXFromClause<TEnt extends Ent<TViewer>, TViewer extends Viewer>(viewer: TViewer, options: LoadEntOptions<TEnt, TViewer>, clause: clause.Clause): Promise<TEnt>;
|
|
13
|
+
export declare function loadEnts<TEnt extends Ent<TViewer>, TViewer extends Viewer>(viewer: TViewer, options: LoadEntOptions<TEnt, TViewer>, ...ids: ID[]): Promise<Map<ID, TEnt>>;
|
|
14
|
+
export declare function loadEntsList<TEnt extends Ent<TViewer>, TViewer extends Viewer>(viewer: TViewer, options: LoadEntOptions<TEnt, TViewer>, ...ids: ID[]): Promise<TEnt[]>;
|
|
15
|
+
export declare function loadEntsFromClause<TEnt extends Ent<TViewer>, TViewer extends Viewer>(viewer: TViewer, clause: clause.Clause, options: LoadEntOptions<TEnt, TViewer>): Promise<Map<ID, TEnt>>;
|
|
16
|
+
export declare function loadCustomEnts<TEnt extends Ent<TViewer>, TViewer extends Viewer>(viewer: TViewer, options: LoadCustomEntOptions<TEnt, TViewer>, query: CustomQuery): Promise<TEnt[]>;
|
|
17
17
|
interface rawQueryOptions {
|
|
18
18
|
query: string;
|
|
19
19
|
values?: any[];
|
|
@@ -21,10 +21,8 @@ interface rawQueryOptions {
|
|
|
21
21
|
}
|
|
22
22
|
export declare type CustomQuery = string | rawQueryOptions | clause.Clause | QueryDataOptions;
|
|
23
23
|
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>;
|
|
24
|
+
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>;
|
|
25
|
+
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
26
|
export declare function loadRowX(options: LoadRowOptions): Promise<Data>;
|
|
29
27
|
export declare function loadRow(options: LoadRowOptions): Promise<Data | null>;
|
|
30
28
|
export declare function performRawQuery(query: string, values: any[], logValues?: any[]): Promise<Data[]>;
|
|
@@ -52,7 +50,7 @@ export interface DataOperation<T extends Ent = Ent> {
|
|
|
52
50
|
}
|
|
53
51
|
export interface EditNodeOptions<T extends Ent> extends EditRowOptions {
|
|
54
52
|
fieldsToResolve: string[];
|
|
55
|
-
|
|
53
|
+
loadEntOptions: LoadEntOptions<T>;
|
|
56
54
|
placeholderID?: ID;
|
|
57
55
|
}
|
|
58
56
|
export declare class EditNodeOperation<T extends Ent> implements DataOperation {
|
|
@@ -147,7 +145,7 @@ export declare class AssocEdgeData {
|
|
|
147
145
|
edgeTable: string;
|
|
148
146
|
constructor(data: Data);
|
|
149
147
|
}
|
|
150
|
-
export declare const assocEdgeLoader: DataLoader<
|
|
148
|
+
export declare const assocEdgeLoader: DataLoader<ID, Data | null, ID>;
|
|
151
149
|
export declare function loadEdgeData(edgeType: string): Promise<AssocEdgeData | null>;
|
|
152
150
|
export declare function loadEdgeDatas(...edgeTypes: string[]): Promise<Map<string, AssocEdgeData>>;
|
|
153
151
|
export interface AssocEdgeConstructor<T extends AssocEdge> {
|
|
@@ -167,15 +165,15 @@ export declare function defaultEdgeQueryOptions(id1: ID, edgeType: string): Edge
|
|
|
167
165
|
export declare function loadEdges(options: loadEdgesOptions): Promise<AssocEdge[]>;
|
|
168
166
|
export declare function loadCustomEdges<T extends AssocEdge>(options: loadCustomEdgesOptions<T>): Promise<T[]>;
|
|
169
167
|
export declare function loadUniqueEdge(options: loadEdgesOptions): Promise<AssocEdge | null>;
|
|
170
|
-
export declare function loadUniqueNode<
|
|
168
|
+
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
169
|
export declare function loadRawEdgeCountX(options: loadEdgesOptions): Promise<number>;
|
|
172
170
|
interface loadEdgeForIDOptions<T extends AssocEdge> extends loadCustomEdgesOptions<T> {
|
|
173
171
|
id2: ID;
|
|
174
172
|
}
|
|
175
173
|
export declare function loadEdgeForID2<T extends AssocEdge>(options: loadEdgeForIDOptions<T>): Promise<T | undefined>;
|
|
176
174
|
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<
|
|
175
|
+
export declare function applyPrivacyPolicyForRow<TEnt extends Ent<TViewer>, TViewer extends Viewer>(viewer: TViewer, options: LoadEntOptions<TEnt, TViewer>, row: Data | null): Promise<TEnt | null>;
|
|
176
|
+
export declare function applyPrivacyPolicyForRowX<TEnt extends Ent<TViewer>, TViewer extends Viewer>(viewer: TViewer, options: LoadEntOptions<TEnt, TViewer>, row: Data): Promise<TEnt>;
|
|
177
|
+
export declare function applyPrivacyPolicyForRows<TEnt extends Ent<TViewer>, TViewer extends Viewer>(viewer: TViewer, rows: Data[], options: LoadEntOptions<TEnt, TViewer>): Promise<Map<ID, TEnt>>;
|
|
180
178
|
export declare function getEdgeTypeInGroup<T extends string>(viewer: Viewer, id1: ID, id2: ID, m: Map<T, string>): Promise<[T, AssocEdge] | undefined>;
|
|
181
179
|
export {};
|