@snowtop/ent 0.2.0-alpha.10 → 0.2.0-alpha.11-test1
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.js +5 -5
- package/action/executor.d.ts +1 -1
- package/action/executor.js +4 -4
- package/action/experimental_action.js +5 -5
- package/action/orchestrator.d.ts +2 -2
- package/action/privacy.d.ts +2 -2
- package/action/relative_value.js +3 -3
- package/auth/auth.d.ts +0 -1
- package/auth/auth.js +4 -5
- package/core/base.js +5 -5
- package/core/clause.js +59 -60
- package/core/config.d.ts +0 -1
- package/core/config.js +1 -2
- package/core/context.d.ts +0 -1
- package/core/convert.d.ts +0 -1
- package/core/convert.js +16 -17
- package/core/date.js +1 -2
- package/core/ent.js +50 -51
- package/core/global_schema.js +6 -7
- package/core/loaders/assoc_count_loader.d.ts +2 -2
- package/core/loaders/assoc_edge_loader.d.ts +2 -2
- package/core/loaders/loader.js +3 -3
- package/core/loaders/object_loader.d.ts +4 -4
- package/core/loaders/query_loader.d.ts +2 -2
- package/core/loaders/raw_count_loader.d.ts +2 -2
- package/core/loaders/raw_count_loader.js +2 -2
- package/core/logger.js +6 -7
- package/core/privacy.d.ts +2 -2
- package/core/privacy.js +4 -4
- package/core/query/shared_assoc_test.js +1 -2
- package/core/query_impl.js +4 -5
- package/core/viewer.d.ts +2 -2
- package/graphql/graphql_field_helpers.js +22 -22
- package/graphql/mutations/union.js +1 -2
- package/graphql/node_resolver.js +7 -7
- package/graphql/query/shared_assoc_test.js +1 -2
- package/graphql/scalars/time.d.ts +1 -1
- package/imports/dataz/example1/_auth.js +14 -10
- package/imports/index.js +1 -2
- package/names/names.js +5 -6
- package/package.json +13 -13
- package/parse_schema/parse.js +2 -3
- package/schema/binary_field.d.ts +2 -2
- package/schema/binary_field.js +3 -3
- package/schema/field.js +28 -28
- package/schema/json_field.js +7 -7
- package/schema/schema.js +12 -12
- package/schema/struct_field.js +4 -4
- package/schema/union_field.js +3 -3
- package/testutils/action/complex_schemas.js +11 -11
- package/testutils/builder.d.ts +1 -1
- package/testutils/builder.js +7 -7
- package/testutils/db/fixture.js +1 -2
- package/testutils/db/temp_db.js +37 -37
- package/testutils/db/value.js +3 -4
- package/testutils/db_mock.js +38 -6
- package/testutils/ent-graphql-tests/index.d.ts +3 -3
- package/testutils/ent-graphql-tests/index.js +10 -11
- package/testutils/fake_data/const.js +2 -2
- package/testutils/fake_data/fake_contact.js +3 -3
- package/testutils/fake_data/fake_event.js +3 -3
- package/testutils/fake_data/fake_tag.js +4 -4
- package/testutils/fake_data/fake_user.js +4 -4
- package/testutils/fake_data/test_helpers.js +17 -17
- package/testutils/fake_data/user_query.js +2 -2
- package/testutils/parse_sql.js +3 -3
- package/testutils/query.js +2 -3
- package/testutils/write.js +3 -4
- package/tsc/ast.js +10 -11
- package/tsc/compilerOptions.js +4 -5
- package/tsc/move_generated.js +1 -2
- package/tsc/transform.js +1 -2
package/testutils/db/temp_db.js
CHANGED
|
@@ -26,7 +26,43 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
29
|
+
exports.TempDB = void 0;
|
|
30
|
+
exports.primaryKey = primaryKey;
|
|
31
|
+
exports.foreignKey = foreignKey;
|
|
32
|
+
exports.check = check;
|
|
33
|
+
exports.index = index;
|
|
34
|
+
exports.uuid = uuid;
|
|
35
|
+
exports.text = text;
|
|
36
|
+
exports.enumCol = enumCol;
|
|
37
|
+
exports.timestamp = timestamp;
|
|
38
|
+
exports.timestamptz = timestamptz;
|
|
39
|
+
exports.time = time;
|
|
40
|
+
exports.timetz = timetz;
|
|
41
|
+
exports.date = date;
|
|
42
|
+
exports.bool = bool;
|
|
43
|
+
exports.integer = integer;
|
|
44
|
+
exports.float = float;
|
|
45
|
+
exports.json = json;
|
|
46
|
+
exports.jsonb = jsonb;
|
|
47
|
+
exports.bytea = bytea;
|
|
48
|
+
exports.textList = textList;
|
|
49
|
+
exports.integerList = integerList;
|
|
50
|
+
exports.uuidList = uuidList;
|
|
51
|
+
exports.timestampList = timestampList;
|
|
52
|
+
exports.timestamptzList = timestamptzList;
|
|
53
|
+
exports.timeList = timeList;
|
|
54
|
+
exports.timetzList = timetzList;
|
|
55
|
+
exports.dateList = dateList;
|
|
56
|
+
exports.boolList = boolList;
|
|
57
|
+
exports.table = table;
|
|
58
|
+
exports.enumType = enumType;
|
|
59
|
+
exports.assoc_edge_config_table = assoc_edge_config_table;
|
|
60
|
+
exports.assoc_edge_table = assoc_edge_table;
|
|
61
|
+
exports.setupSqlite = setupSqlite;
|
|
62
|
+
exports.setupPostgres = setupPostgres;
|
|
63
|
+
exports.doSQLiteTestFromSchemas = doSQLiteTestFromSchemas;
|
|
64
|
+
exports.getSchemaTable = getSchemaTable;
|
|
65
|
+
exports.getColumnFromField = getColumnFromField;
|
|
30
66
|
const pg_1 = require("pg");
|
|
31
67
|
const db_1 = __importStar(require("../../core/db"));
|
|
32
68
|
// this should only be used in tests so we expect to be able to import without shenanigans
|
|
@@ -45,7 +81,6 @@ function primaryKey(name, cols) {
|
|
|
45
81
|
},
|
|
46
82
|
};
|
|
47
83
|
}
|
|
48
|
-
exports.primaryKey = primaryKey;
|
|
49
84
|
function foreignKey(name, cols, fkey) {
|
|
50
85
|
return {
|
|
51
86
|
name,
|
|
@@ -54,7 +89,6 @@ function foreignKey(name, cols, fkey) {
|
|
|
54
89
|
},
|
|
55
90
|
};
|
|
56
91
|
}
|
|
57
|
-
exports.foreignKey = foreignKey;
|
|
58
92
|
function check(name, condition) {
|
|
59
93
|
return {
|
|
60
94
|
name,
|
|
@@ -63,7 +97,6 @@ function check(name, condition) {
|
|
|
63
97
|
},
|
|
64
98
|
};
|
|
65
99
|
}
|
|
66
|
-
exports.check = check;
|
|
67
100
|
function unique(name, cols, tableName) {
|
|
68
101
|
return {
|
|
69
102
|
name,
|
|
@@ -97,7 +130,6 @@ function index(tableName, cols, opts) {
|
|
|
97
130
|
},
|
|
98
131
|
};
|
|
99
132
|
}
|
|
100
|
-
exports.index = index;
|
|
101
133
|
function uuid(name, opts) {
|
|
102
134
|
return {
|
|
103
135
|
name,
|
|
@@ -107,7 +139,6 @@ function uuid(name, opts) {
|
|
|
107
139
|
...opts,
|
|
108
140
|
};
|
|
109
141
|
}
|
|
110
|
-
exports.uuid = uuid;
|
|
111
142
|
function text(name, opts) {
|
|
112
143
|
return {
|
|
113
144
|
name,
|
|
@@ -117,7 +148,6 @@ function text(name, opts) {
|
|
|
117
148
|
...opts,
|
|
118
149
|
};
|
|
119
150
|
}
|
|
120
|
-
exports.text = text;
|
|
121
151
|
function enumCol(name, type) {
|
|
122
152
|
return {
|
|
123
153
|
name,
|
|
@@ -126,7 +156,6 @@ function enumCol(name, type) {
|
|
|
126
156
|
},
|
|
127
157
|
};
|
|
128
158
|
}
|
|
129
|
-
exports.enumCol = enumCol;
|
|
130
159
|
function timestamp(name, opts) {
|
|
131
160
|
return {
|
|
132
161
|
name,
|
|
@@ -136,7 +165,6 @@ function timestamp(name, opts) {
|
|
|
136
165
|
...opts,
|
|
137
166
|
};
|
|
138
167
|
}
|
|
139
|
-
exports.timestamp = timestamp;
|
|
140
168
|
function timestamptz(name, opts) {
|
|
141
169
|
return {
|
|
142
170
|
name,
|
|
@@ -151,7 +179,6 @@ function timestamptz(name, opts) {
|
|
|
151
179
|
...opts,
|
|
152
180
|
};
|
|
153
181
|
}
|
|
154
|
-
exports.timestamptz = timestamptz;
|
|
155
182
|
function time(name, opts) {
|
|
156
183
|
return {
|
|
157
184
|
name,
|
|
@@ -161,7 +188,6 @@ function time(name, opts) {
|
|
|
161
188
|
...opts,
|
|
162
189
|
};
|
|
163
190
|
}
|
|
164
|
-
exports.time = time;
|
|
165
191
|
function timetz(name, opts) {
|
|
166
192
|
return {
|
|
167
193
|
name,
|
|
@@ -171,7 +197,6 @@ function timetz(name, opts) {
|
|
|
171
197
|
...opts,
|
|
172
198
|
};
|
|
173
199
|
}
|
|
174
|
-
exports.timetz = timetz;
|
|
175
200
|
function date(name, opts) {
|
|
176
201
|
return {
|
|
177
202
|
name,
|
|
@@ -181,7 +206,6 @@ function date(name, opts) {
|
|
|
181
206
|
...opts,
|
|
182
207
|
};
|
|
183
208
|
}
|
|
184
|
-
exports.date = date;
|
|
185
209
|
function bool(name, opts) {
|
|
186
210
|
const dialect = db_1.default.getDialect();
|
|
187
211
|
if (opts?.default === "FALSE" && dialect === db_1.Dialect.SQLite) {
|
|
@@ -198,7 +222,6 @@ function bool(name, opts) {
|
|
|
198
222
|
...opts,
|
|
199
223
|
};
|
|
200
224
|
}
|
|
201
|
-
exports.bool = bool;
|
|
202
225
|
function integer(name, opts) {
|
|
203
226
|
return {
|
|
204
227
|
name,
|
|
@@ -208,7 +231,6 @@ function integer(name, opts) {
|
|
|
208
231
|
...opts,
|
|
209
232
|
};
|
|
210
233
|
}
|
|
211
|
-
exports.integer = integer;
|
|
212
234
|
function float(name, opts) {
|
|
213
235
|
return {
|
|
214
236
|
name,
|
|
@@ -218,7 +240,6 @@ function float(name, opts) {
|
|
|
218
240
|
...opts,
|
|
219
241
|
};
|
|
220
242
|
}
|
|
221
|
-
exports.float = float;
|
|
222
243
|
function json(name, opts) {
|
|
223
244
|
return {
|
|
224
245
|
name,
|
|
@@ -228,7 +249,6 @@ function json(name, opts) {
|
|
|
228
249
|
...opts,
|
|
229
250
|
};
|
|
230
251
|
}
|
|
231
|
-
exports.json = json;
|
|
232
252
|
function jsonb(name, opts) {
|
|
233
253
|
return {
|
|
234
254
|
name,
|
|
@@ -238,7 +258,6 @@ function jsonb(name, opts) {
|
|
|
238
258
|
...opts,
|
|
239
259
|
};
|
|
240
260
|
}
|
|
241
|
-
exports.jsonb = jsonb;
|
|
242
261
|
function bytea(name, opts) {
|
|
243
262
|
return {
|
|
244
263
|
name,
|
|
@@ -248,7 +267,6 @@ function bytea(name, opts) {
|
|
|
248
267
|
...opts,
|
|
249
268
|
};
|
|
250
269
|
}
|
|
251
|
-
exports.bytea = bytea;
|
|
252
270
|
function list(name, col, opts) {
|
|
253
271
|
return {
|
|
254
272
|
name,
|
|
@@ -261,39 +279,30 @@ function list(name, col, opts) {
|
|
|
261
279
|
function textList(name, opts) {
|
|
262
280
|
return list(name, text(name), opts);
|
|
263
281
|
}
|
|
264
|
-
exports.textList = textList;
|
|
265
282
|
function integerList(name, opts) {
|
|
266
283
|
return list(name, integer(name), opts);
|
|
267
284
|
}
|
|
268
|
-
exports.integerList = integerList;
|
|
269
285
|
function uuidList(name, opts) {
|
|
270
286
|
return list(name, uuid(name), opts);
|
|
271
287
|
}
|
|
272
|
-
exports.uuidList = uuidList;
|
|
273
288
|
function timestampList(name, opts) {
|
|
274
289
|
return list(name, timestamp(name), opts);
|
|
275
290
|
}
|
|
276
|
-
exports.timestampList = timestampList;
|
|
277
291
|
function timestamptzList(name, opts) {
|
|
278
292
|
return list(name, timestamptz(name), opts);
|
|
279
293
|
}
|
|
280
|
-
exports.timestamptzList = timestamptzList;
|
|
281
294
|
function timeList(name, opts) {
|
|
282
295
|
return list(name, time(name), opts);
|
|
283
296
|
}
|
|
284
|
-
exports.timeList = timeList;
|
|
285
297
|
function timetzList(name, opts) {
|
|
286
298
|
return list(name, timetz(name), opts);
|
|
287
299
|
}
|
|
288
|
-
exports.timetzList = timetzList;
|
|
289
300
|
function dateList(name, opts) {
|
|
290
301
|
return list(name, date(name), opts);
|
|
291
302
|
}
|
|
292
|
-
exports.dateList = dateList;
|
|
293
303
|
function boolList(name, opts) {
|
|
294
304
|
return list(name, bool(name), opts);
|
|
295
305
|
}
|
|
296
|
-
exports.boolList = boolList;
|
|
297
306
|
function table(name, ...items) {
|
|
298
307
|
let cols = [];
|
|
299
308
|
let constraints = [];
|
|
@@ -370,7 +379,6 @@ function table(name, ...items) {
|
|
|
370
379
|
},
|
|
371
380
|
};
|
|
372
381
|
}
|
|
373
|
-
exports.table = table;
|
|
374
382
|
function enumType(name, values) {
|
|
375
383
|
return {
|
|
376
384
|
name,
|
|
@@ -382,7 +390,6 @@ function enumType(name, values) {
|
|
|
382
390
|
},
|
|
383
391
|
};
|
|
384
392
|
}
|
|
385
|
-
exports.enumType = enumType;
|
|
386
393
|
function randomDB() {
|
|
387
394
|
let str = Math.random().toString(16).substring(2);
|
|
388
395
|
// always ensure it starts with an alpha character
|
|
@@ -565,7 +572,6 @@ function assoc_edge_config_table() {
|
|
|
565
572
|
// edge_type and inverse_edge_type are text intentionally instead of uuid...
|
|
566
573
|
text("edge_type", { primaryKey: true }), text("edge_name"), bool("symmetric_edge", { default: "FALSE" }), text("inverse_edge_type", { nullable: true }), text("edge_table"), timestamptz("created_at"), timestamptz("updated_at"));
|
|
567
574
|
}
|
|
568
|
-
exports.assoc_edge_config_table = assoc_edge_config_table;
|
|
569
575
|
// if global flag is true, add any column from testEdgeGlobalSchema
|
|
570
576
|
// up to caller to set/clear that as needed
|
|
571
577
|
function assoc_edge_table(name, global, unique_edge) {
|
|
@@ -592,7 +598,6 @@ function assoc_edge_table(name, global, unique_edge) {
|
|
|
592
598
|
}
|
|
593
599
|
return t;
|
|
594
600
|
}
|
|
595
|
-
exports.assoc_edge_table = assoc_edge_table;
|
|
596
601
|
function setupSqlite(connString, tables, opts) {
|
|
597
602
|
let tdb = new TempDB({
|
|
598
603
|
dialect: db_1.Dialect.SQLite,
|
|
@@ -628,7 +633,6 @@ function setupSqlite(connString, tables, opts) {
|
|
|
628
633
|
});
|
|
629
634
|
return tdb;
|
|
630
635
|
}
|
|
631
|
-
exports.setupSqlite = setupSqlite;
|
|
632
636
|
function setupPostgres(tables, opts) {
|
|
633
637
|
let tdb;
|
|
634
638
|
beforeAll(async () => {
|
|
@@ -650,7 +654,6 @@ function setupPostgres(tables, opts) {
|
|
|
650
654
|
await tdb.afterAll();
|
|
651
655
|
});
|
|
652
656
|
}
|
|
653
|
-
exports.setupPostgres = setupPostgres;
|
|
654
657
|
async function doSQLiteTestFromSchemas(schemas, doTest, db) {
|
|
655
658
|
const connString = `sqlite:///${db || randomDB()}.db`;
|
|
656
659
|
const tables = schemas.map((schema) => getSchemaTable(schema, db_1.Dialect.SQLite));
|
|
@@ -663,7 +666,6 @@ async function doSQLiteTestFromSchemas(schemas, doTest, db) {
|
|
|
663
666
|
delete process.env.DB_CONNECTION_STRING;
|
|
664
667
|
return tdb;
|
|
665
668
|
}
|
|
666
|
-
exports.doSQLiteTestFromSchemas = doSQLiteTestFromSchemas;
|
|
667
669
|
function getSchemaTable(schema, dialect) {
|
|
668
670
|
const fields = (0, schema_1.getFields)(schema);
|
|
669
671
|
const items = [];
|
|
@@ -702,7 +704,6 @@ function getSchemaTable(schema, dialect) {
|
|
|
702
704
|
}
|
|
703
705
|
return table(tableName, ...items);
|
|
704
706
|
}
|
|
705
|
-
exports.getSchemaTable = getSchemaTable;
|
|
706
707
|
function getColumnForDbType(t, dialect) {
|
|
707
708
|
switch (t) {
|
|
708
709
|
case schema_1.DBType.UUID:
|
|
@@ -762,7 +763,6 @@ function getColumnFromField(fieldName, f, dialect) {
|
|
|
762
763
|
return getColumn(fieldName, f, fn);
|
|
763
764
|
}
|
|
764
765
|
}
|
|
765
|
-
exports.getColumnFromField = getColumnFromField;
|
|
766
766
|
function getColumn(fieldName, f, col) {
|
|
767
767
|
return col(storageKey(fieldName, f), buildOpts(f));
|
|
768
768
|
}
|
package/testutils/db/value.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.randomEmail = randomEmail;
|
|
4
|
+
exports.randomPhoneNumber = randomPhoneNumber;
|
|
5
|
+
exports.getDefaultValue = getDefaultValue;
|
|
4
6
|
const uuid_1 = require("uuid");
|
|
5
7
|
const schema_1 = require("../../schema");
|
|
6
8
|
const schema_2 = require("../../schema");
|
|
@@ -11,11 +13,9 @@ function randomEmail(domain) {
|
|
|
11
13
|
domain = domain || "email.com";
|
|
12
14
|
return `test+${random()}@${domain}`;
|
|
13
15
|
}
|
|
14
|
-
exports.randomEmail = randomEmail;
|
|
15
16
|
function randomPhoneNumber() {
|
|
16
17
|
return `+1${Math.random().toString(10).substring(2, 11)}`;
|
|
17
18
|
}
|
|
18
|
-
exports.randomPhoneNumber = randomPhoneNumber;
|
|
19
19
|
function coinFlip() {
|
|
20
20
|
return Math.floor(Math.random() * 10) >= 5;
|
|
21
21
|
}
|
|
@@ -54,7 +54,6 @@ function getDefaultValue(f, col, infos) {
|
|
|
54
54
|
}
|
|
55
55
|
return getValueForType(f.type, f, infos);
|
|
56
56
|
}
|
|
57
|
-
exports.getDefaultValue = getDefaultValue;
|
|
58
57
|
function getValueForType(typ, f, infos) {
|
|
59
58
|
switch (typ.dbType) {
|
|
60
59
|
case schema_1.DBType.UUID:
|
package/testutils/db_mock.js
CHANGED
|
@@ -229,15 +229,46 @@ class QueryRecorder {
|
|
|
229
229
|
}
|
|
230
230
|
static mockPool(pool) {
|
|
231
231
|
const mockedPool = (0, jest_mock_1.mocked)(pool);
|
|
232
|
-
//
|
|
233
|
-
// TODO what changed in mockImplementation?
|
|
232
|
+
// changed to any but seems off
|
|
234
233
|
mockedPool.mockImplementation(() => {
|
|
235
234
|
return {
|
|
236
235
|
totalCount: 1,
|
|
237
236
|
idleCount: 1,
|
|
238
237
|
waitingCount: 1,
|
|
239
|
-
|
|
240
|
-
|
|
238
|
+
ending: false,
|
|
239
|
+
ended: false,
|
|
240
|
+
expiredCount: 1,
|
|
241
|
+
options: {
|
|
242
|
+
max: 1,
|
|
243
|
+
maxUses: 1,
|
|
244
|
+
allowExitOnIdle: true,
|
|
245
|
+
maxLifetimeSeconds: 1,
|
|
246
|
+
idleTimeoutMillis: 1,
|
|
247
|
+
},
|
|
248
|
+
connect: function (callback) {
|
|
249
|
+
if (callback) {
|
|
250
|
+
// return;
|
|
251
|
+
// const client = {
|
|
252
|
+
// connect: jest.fn(),
|
|
253
|
+
// release: jest.fn(),
|
|
254
|
+
// query: jest
|
|
255
|
+
// .fn()
|
|
256
|
+
// .mockImplementation((query: string, values: any[]) => {
|
|
257
|
+
// return QueryRecorder.recordQuery(query, values);
|
|
258
|
+
// }),
|
|
259
|
+
// copyFrom: jest.fn(),
|
|
260
|
+
// copyTo: jest.fn(),
|
|
261
|
+
// pauseDrain: jest.fn(),
|
|
262
|
+
// resumeDrain: jest.fn(),
|
|
263
|
+
// escapeIdentifier: jest.fn(),
|
|
264
|
+
// escapeLiteral: jest.fn(),
|
|
265
|
+
// setTypeParser: jest.fn(),
|
|
266
|
+
// getTypeParser: jest.fn(),
|
|
267
|
+
// ...eventEmitter,
|
|
268
|
+
// };
|
|
269
|
+
// callback(null as unknown as Error, client, jest.fn());
|
|
270
|
+
}
|
|
271
|
+
return Promise.resolve({
|
|
241
272
|
connect: jest.fn(),
|
|
242
273
|
release: jest.fn(),
|
|
243
274
|
query: jest
|
|
@@ -251,9 +282,10 @@ class QueryRecorder {
|
|
|
251
282
|
resumeDrain: jest.fn(),
|
|
252
283
|
escapeIdentifier: jest.fn(),
|
|
253
284
|
escapeLiteral: jest.fn(),
|
|
254
|
-
|
|
285
|
+
setTypeParser: jest.fn(),
|
|
286
|
+
getTypeParser: jest.fn(),
|
|
255
287
|
...eventEmitter,
|
|
256
|
-
};
|
|
288
|
+
});
|
|
257
289
|
},
|
|
258
290
|
end: jest.fn(),
|
|
259
291
|
query: jest.fn().mockImplementation(QueryRecorder.recordQuery),
|
|
@@ -6,7 +6,7 @@ export type Option = [string, any] | [string, any, string];
|
|
|
6
6
|
interface queryConfig {
|
|
7
7
|
viewer?: Viewer;
|
|
8
8
|
init?: (app: Express) => void;
|
|
9
|
-
test?: supertest.
|
|
9
|
+
test?: supertest.Agent | ((express: Express) => supertest.Agent);
|
|
10
10
|
schema: GraphQLSchema;
|
|
11
11
|
headers?: object;
|
|
12
12
|
debugMode?: boolean;
|
|
@@ -31,11 +31,11 @@ export interface queryRootConfig extends queryConfig {
|
|
|
31
31
|
nullQueryPaths?: string[];
|
|
32
32
|
undefinedQueryPaths?: string[];
|
|
33
33
|
}
|
|
34
|
-
export declare function expectQueryFromRoot(config: queryRootConfig, ...options: Option[]): Promise<supertest.
|
|
34
|
+
export declare function expectQueryFromRoot(config: queryRootConfig, ...options: Option[]): Promise<supertest.Agent>;
|
|
35
35
|
export interface mutationRootConfig extends queryConfig {
|
|
36
36
|
mutation: string;
|
|
37
37
|
disableInputWrapping?: boolean;
|
|
38
38
|
nullQueryPaths?: string[];
|
|
39
39
|
}
|
|
40
|
-
export declare function expectMutation(config: mutationRootConfig, ...options: Option[]): Promise<supertest.
|
|
40
|
+
export declare function expectMutation(config: mutationRootConfig, ...options: Option[]): Promise<supertest.Agent>;
|
|
41
41
|
export {};
|
|
@@ -26,7 +26,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
29
|
+
exports.expectQueryFromRoot = expectQueryFromRoot;
|
|
30
|
+
exports.expectMutation = expectMutation;
|
|
30
31
|
// NB: this is copied from ent-graphql-tests package until I have time to figure out how to share code here effectively
|
|
31
32
|
// the circular dependencies btw this package and ent-graphql-tests seems to imply something needs to change
|
|
32
33
|
const express_1 = __importDefault(require("express"));
|
|
@@ -82,17 +83,17 @@ function getInnerType(typ, list) {
|
|
|
82
83
|
return [typ, list];
|
|
83
84
|
}
|
|
84
85
|
function makeGraphQLRequest(config, query, fieldArgs) {
|
|
85
|
-
let
|
|
86
|
+
let agent;
|
|
86
87
|
if (config.test) {
|
|
87
88
|
if (typeof config.test === "function") {
|
|
88
|
-
|
|
89
|
+
agent = config.test(config.server ? config.server : server(config));
|
|
89
90
|
}
|
|
90
91
|
else {
|
|
91
|
-
|
|
92
|
+
agent = config.test;
|
|
92
93
|
}
|
|
93
94
|
}
|
|
94
95
|
else {
|
|
95
|
-
|
|
96
|
+
agent = (0, supertest_1.default)(config.server ? config.server : server(config));
|
|
96
97
|
}
|
|
97
98
|
let files = new Map();
|
|
98
99
|
// handle files
|
|
@@ -123,7 +124,7 @@ function makeGraphQLRequest(config, query, fieldArgs) {
|
|
|
123
124
|
variables[k] = config.extraVariables[k].value;
|
|
124
125
|
}
|
|
125
126
|
if (files.size) {
|
|
126
|
-
let ret =
|
|
127
|
+
let ret = agent
|
|
127
128
|
.post(config.graphQLPath || "/graphql")
|
|
128
129
|
.set((config.headers || {}));
|
|
129
130
|
ret.field("operations", JSON.stringify({
|
|
@@ -145,12 +146,12 @@ function makeGraphQLRequest(config, query, fieldArgs) {
|
|
|
145
146
|
ret.attach(`${idx}`, val, key);
|
|
146
147
|
idx++;
|
|
147
148
|
}
|
|
148
|
-
return [
|
|
149
|
+
return [agent, ret];
|
|
149
150
|
}
|
|
150
151
|
else {
|
|
151
152
|
return [
|
|
152
|
-
|
|
153
|
-
|
|
153
|
+
agent,
|
|
154
|
+
agent
|
|
154
155
|
.post(config.graphQLPath || "/graphql")
|
|
155
156
|
.set((config.headers || {}))
|
|
156
157
|
.send({
|
|
@@ -282,7 +283,6 @@ async function expectQueryFromRoot(config, ...options // TODO queries? expected
|
|
|
282
283
|
queryFN: config.schema.getQueryType(),
|
|
283
284
|
}, ...options);
|
|
284
285
|
}
|
|
285
|
-
exports.expectQueryFromRoot = expectQueryFromRoot;
|
|
286
286
|
async function expectMutation(config, ...options) {
|
|
287
287
|
// wrap args in input because we simplify the args for mutations
|
|
288
288
|
// and don't require the input
|
|
@@ -301,7 +301,6 @@ async function expectMutation(config, ...options) {
|
|
|
301
301
|
queryFN: config.schema.getMutationType(),
|
|
302
302
|
}, ...options);
|
|
303
303
|
}
|
|
304
|
-
exports.expectMutation = expectMutation;
|
|
305
304
|
const fragmentRegex = /^...on (\w+)(.*)/;
|
|
306
305
|
function splitPath(path) {
|
|
307
306
|
// handle fragment queries. we don't want to compare against this when checking the result
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.InverseEdges = exports.SymmetricEdges = exports.NodeType = exports.EdgeType = void 0;
|
|
4
|
+
exports.getLoaderOptions = getLoaderOptions;
|
|
4
5
|
const internal_1 = require("./internal");
|
|
5
6
|
var EdgeType;
|
|
6
7
|
(function (EdgeType) {
|
|
@@ -53,4 +54,3 @@ function getLoaderOptions(type) {
|
|
|
53
54
|
return internal_1.FakeTag.loaderOptions();
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
|
-
exports.getLoaderOptions = getLoaderOptions;
|
|
@@ -23,7 +23,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.contactLoader = exports.
|
|
26
|
+
exports.contactLoader = exports.FakeContactSchemaWithDeletedAt = exports.FakeContactSchema = exports.FakeContact = void 0;
|
|
27
|
+
exports.getContactBuilder = getContactBuilder;
|
|
28
|
+
exports.createContact = createContact;
|
|
27
29
|
const ent_1 = require("../../core/ent");
|
|
28
30
|
const clause = __importStar(require("../../core/clause"));
|
|
29
31
|
const privacy_1 = require("../../core/privacy");
|
|
@@ -153,12 +155,10 @@ function getContactBuilder(viewer, input) {
|
|
|
153
155
|
m.set("updatedAt", new Date());
|
|
154
156
|
return new builder_1.SimpleBuilder(viewer, exports.FakeContactSchema, m, action_1.WriteOperation.Insert, null);
|
|
155
157
|
}
|
|
156
|
-
exports.getContactBuilder = getContactBuilder;
|
|
157
158
|
async function createContact(viewer, input) {
|
|
158
159
|
const builder = getContactBuilder(viewer, input);
|
|
159
160
|
return builder.saveX();
|
|
160
161
|
}
|
|
161
|
-
exports.createContact = createContact;
|
|
162
162
|
exports.contactLoader = new loaders_1.ObjectLoaderFactory({
|
|
163
163
|
tableName: "fake_contacts",
|
|
164
164
|
fields: FakeContact.getFields(),
|
|
@@ -23,7 +23,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
26
|
+
exports.FakeEventSchema = exports.FakeEvent = void 0;
|
|
27
|
+
exports.getEventBuilder = getEventBuilder;
|
|
28
|
+
exports.createEvent = createEvent;
|
|
27
29
|
const ent_1 = require("../../core/ent");
|
|
28
30
|
const clause = __importStar(require("../../core/clause"));
|
|
29
31
|
const privacy_1 = require("../../core/privacy");
|
|
@@ -142,9 +144,7 @@ function getEventBuilder(viewer, input) {
|
|
|
142
144
|
}
|
|
143
145
|
return new builder_1.SimpleBuilder(viewer, exports.FakeEventSchema, m, action_1.WriteOperation.Insert, null);
|
|
144
146
|
}
|
|
145
|
-
exports.getEventBuilder = getEventBuilder;
|
|
146
147
|
async function createEvent(viewer, input) {
|
|
147
148
|
const builder = getEventBuilder(viewer, input);
|
|
148
149
|
return builder.saveX();
|
|
149
150
|
}
|
|
150
|
-
exports.createEvent = createEvent;
|
|
@@ -23,7 +23,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.tagLoaderWithDeletedAt = exports.tagLoader = exports.
|
|
26
|
+
exports.tagLoaderWithDeletedAt = exports.tagLoader = exports.FakeTagSchema = exports.FakeTag = void 0;
|
|
27
|
+
exports.getTagBuilder = getTagBuilder;
|
|
28
|
+
exports.getTagAction = getTagAction;
|
|
29
|
+
exports.createTag = createTag;
|
|
27
30
|
const ent_1 = require("../../core/ent");
|
|
28
31
|
const clause = __importStar(require("../../core/clause"));
|
|
29
32
|
const privacy_1 = require("../../core/privacy");
|
|
@@ -109,7 +112,6 @@ function getTagBuilder(viewer, input) {
|
|
|
109
112
|
const action = getTagAction(viewer, input);
|
|
110
113
|
return action.builder;
|
|
111
114
|
}
|
|
112
|
-
exports.getTagBuilder = getTagBuilder;
|
|
113
115
|
function getTagAction(viewer, input) {
|
|
114
116
|
const m = new Map();
|
|
115
117
|
for (const key in input) {
|
|
@@ -118,12 +120,10 @@ function getTagAction(viewer, input) {
|
|
|
118
120
|
const action = new builder_1.SimpleAction(viewer, exports.FakeTagSchema, m, action_1.WriteOperation.Insert, null);
|
|
119
121
|
return action;
|
|
120
122
|
}
|
|
121
|
-
exports.getTagAction = getTagAction;
|
|
122
123
|
async function createTag(viewer, input) {
|
|
123
124
|
const action = getTagAction(viewer, input);
|
|
124
125
|
return action.saveX();
|
|
125
126
|
}
|
|
126
|
-
exports.createTag = createTag;
|
|
127
127
|
exports.tagLoader = new loaders_1.ObjectLoaderFactory({
|
|
128
128
|
tableName: "fake_tags",
|
|
129
129
|
fields: FakeTag.getFields(),
|
|
@@ -23,7 +23,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.userPhoneNumberLoader = exports.userEmailLoader = exports.userLoaderWithDeletedAt = exports.userLoader = exports.
|
|
26
|
+
exports.userPhoneNumberLoader = exports.userEmailLoader = exports.userLoaderWithDeletedAt = exports.userLoader = exports.FakeUserSchema = exports.FakeUser = exports.ViewerWithAccessToken = void 0;
|
|
27
|
+
exports.getUserBuilder = getUserBuilder;
|
|
28
|
+
exports.getUserAction = getUserAction;
|
|
29
|
+
exports.createUser = createUser;
|
|
27
30
|
const base_1 = require("../../core/base");
|
|
28
31
|
const ent_1 = require("../../core/ent");
|
|
29
32
|
const clause = __importStar(require("../../core/clause"));
|
|
@@ -172,7 +175,6 @@ function getUserBuilder(viewer, input) {
|
|
|
172
175
|
const action = getUserAction(viewer, input);
|
|
173
176
|
return action.builder;
|
|
174
177
|
}
|
|
175
|
-
exports.getUserBuilder = getUserBuilder;
|
|
176
178
|
function getUserAction(viewer, input) {
|
|
177
179
|
const m = new Map();
|
|
178
180
|
for (const key in input) {
|
|
@@ -187,12 +189,10 @@ function getUserAction(viewer, input) {
|
|
|
187
189
|
};
|
|
188
190
|
return action;
|
|
189
191
|
}
|
|
190
|
-
exports.getUserAction = getUserAction;
|
|
191
192
|
async function createUser(viewer, input) {
|
|
192
193
|
const action = getUserAction(viewer, input);
|
|
193
194
|
return action.saveX();
|
|
194
195
|
}
|
|
195
|
-
exports.createUser = createUser;
|
|
196
196
|
exports.userLoader = new loaders_1.ObjectLoaderFactory({
|
|
197
197
|
tableName: "fake_users",
|
|
198
198
|
fields: FakeUser.getFields(),
|