@snowtop/ent 0.1.0-alpha88 → 0.1.0-alpha89-16dc3410-33c4-11ed-9fc4-5d4a927887be

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.
@@ -1,11 +1,54 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CustomEdgeQueryBase = void 0;
4
+ const clause_1 = require("../clause");
4
5
  const ent_1 = require("../ent");
6
+ const loaders_1 = require("../loaders");
5
7
  const query_1 = require("./query");
8
+ function getClause(opts) {
9
+ let cls = opts.clause;
10
+ if (opts.disableTransformations) {
11
+ return cls;
12
+ }
13
+ let optClause = opts.loadEntOptions.loaderFactory?.options?.clause;
14
+ if (typeof optClause === "function") {
15
+ optClause = optClause();
16
+ }
17
+ if (!optClause) {
18
+ return cls;
19
+ }
20
+ return (0, clause_1.AndOptional)(cls, optClause);
21
+ }
22
+ function getRawCountLoader(viewer, opts) {
23
+ if (!viewer.context?.cache) {
24
+ return new loaders_1.RawCountLoader({
25
+ tableName: opts.loadEntOptions.tableName,
26
+ groupCol: opts.groupCol,
27
+ clause: getClause(opts),
28
+ });
29
+ }
30
+ const name = `custom_query_count_loader:${opts.name}`;
31
+ return viewer.context.cache.getLoader(name, () => new loaders_1.RawCountLoader({
32
+ tableName: opts.loadEntOptions.tableName,
33
+ groupCol: opts.groupCol,
34
+ clause: getClause(opts),
35
+ }));
36
+ }
37
+ function getQueryLoader(viewer, opts, options) {
38
+ const loader = opts.loadEntOptions.loaderFactory;
39
+ const name = `custom_query_loader:${opts.name}`;
40
+ return loaders_1.QueryLoaderFactory.createConfigurableLoader(name, {
41
+ tableName: opts.loadEntOptions.tableName,
42
+ fields: opts.loadEntOptions.fields,
43
+ groupCol: opts.groupCol,
44
+ clause: getClause(opts),
45
+ toPrime: [loader],
46
+ }, options, viewer.context);
47
+ }
6
48
  class CustomEdgeQueryBase extends query_1.BaseEdgeQuery {
7
49
  constructor(viewer, options) {
8
- super(viewer, options.sortColumn || "created_at");
50
+ // @ts-ignore
51
+ super(viewer, options?.sortColumn || "created_at");
9
52
  this.viewer = viewer;
10
53
  this.options = options;
11
54
  options.sortColumn = options.sortColumn || "created_at";
@@ -15,6 +58,7 @@ class CustomEdgeQueryBase extends query_1.BaseEdgeQuery {
15
58
  else {
16
59
  this.id = options.src;
17
60
  }
61
+ this.opts = this.getLoadEntOptions();
18
62
  }
19
63
  async idVisible() {
20
64
  const ids = await this.genIDInfosToFetch();
@@ -23,14 +67,28 @@ class CustomEdgeQueryBase extends query_1.BaseEdgeQuery {
23
67
  }
24
68
  return !ids[0].invalidated;
25
69
  }
70
+ isDeprecatedOptions(options) {
71
+ return (options
72
+ .countLoaderFactory !== undefined);
73
+ }
74
+ getCountLoader() {
75
+ if (this.isDeprecatedOptions(this.options)) {
76
+ return this.options.countLoaderFactory.createLoader(this.viewer.context);
77
+ }
78
+ return getRawCountLoader(this.viewer, this.options);
79
+ }
80
+ getQueryLoader(options) {
81
+ if (this.isDeprecatedOptions(this.options)) {
82
+ return this.options.dataLoaderFactory.createConfigurableLoader(options, this.viewer.context);
83
+ }
84
+ return getQueryLoader(this.viewer, this.options, options);
85
+ }
26
86
  async queryRawCount() {
27
87
  const idVisible = await this.idVisible();
28
88
  if (!idVisible) {
29
89
  return 0;
30
90
  }
31
- return await this.options.countLoaderFactory
32
- .createLoader(this.viewer.context)
33
- .load(this.id);
91
+ return this.getCountLoader().load(this.id);
34
92
  }
35
93
  async queryAllRawCount() {
36
94
  let count = 0;
@@ -43,17 +101,27 @@ class CustomEdgeQueryBase extends query_1.BaseEdgeQuery {
43
101
  async loadRawIDs(addID) {
44
102
  addID(this.options.src);
45
103
  }
104
+ getLoadEntOptions() {
105
+ let opts;
106
+ if (this.isDeprecatedOptions(this.options)) {
107
+ opts = this.options.options;
108
+ }
109
+ else {
110
+ opts = this.options.loadEntOptions;
111
+ }
112
+ return opts;
113
+ }
46
114
  async loadRawData(infos, options) {
47
- const loader = this.options.dataLoaderFactory.createConfigurableLoader(options, this.viewer.context);
115
+ if (infos.length !== 1) {
116
+ throw new Error(`expected 1 info passed to loadRawData. ${infos.length} passed`);
117
+ }
48
118
  if (!options.orderby) {
49
119
  options.orderby = `${this.options.sortColumn} DESC`;
50
120
  }
51
121
  if (!options.limit) {
52
122
  options.limit = ent_1.DefaultLimit;
53
123
  }
54
- if (infos.length !== 1) {
55
- throw new Error(`expected 1 info passed to loadRawData. ${infos.length} passed`);
56
- }
124
+ const loader = this.getQueryLoader(options);
57
125
  const info = infos[0];
58
126
  if (info.invalidated) {
59
127
  this.edges.set(this.id, []);
@@ -66,8 +134,7 @@ class CustomEdgeQueryBase extends query_1.BaseEdgeQuery {
66
134
  return edge.id;
67
135
  }
68
136
  async loadEntsFromEdges(id, rows) {
69
- const ents = await (0, ent_1.applyPrivacyPolicyForRows)(this.viewer, rows, this.options.options);
70
- return Array.from(ents.values());
137
+ return (0, ent_1.applyPrivacyPolicyForRows)(this.viewer, rows, this.opts);
71
138
  }
72
139
  }
73
140
  exports.CustomEdgeQueryBase = CustomEdgeQueryBase;
@@ -1,3 +1,4 @@
1
1
  export { EdgeQuery, BaseEdgeQuery, EdgeQueryFilter, PaginationInfo, } from "./query";
2
2
  export { AssocEdgeQueryBase, EdgeQuerySource } from "./assoc_query";
3
3
  export { CustomEdgeQueryBase } from "./custom_query";
4
+ export { CustomClauseQuery } from "./custom_clause_query";
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CustomEdgeQueryBase = exports.AssocEdgeQueryBase = exports.BaseEdgeQuery = void 0;
3
+ exports.CustomClauseQuery = exports.CustomEdgeQueryBase = exports.AssocEdgeQueryBase = exports.BaseEdgeQuery = void 0;
4
4
  var query_1 = require("./query");
5
5
  Object.defineProperty(exports, "BaseEdgeQuery", { enumerable: true, get: function () { return query_1.BaseEdgeQuery; } });
6
6
  var assoc_query_1 = require("./assoc_query");
7
7
  Object.defineProperty(exports, "AssocEdgeQueryBase", { enumerable: true, get: function () { return assoc_query_1.AssocEdgeQueryBase; } });
8
8
  var custom_query_1 = require("./custom_query");
9
9
  Object.defineProperty(exports, "CustomEdgeQueryBase", { enumerable: true, get: function () { return custom_query_1.CustomEdgeQueryBase; } });
10
+ var custom_clause_query_1 = require("./custom_clause_query");
11
+ Object.defineProperty(exports, "CustomClauseQuery", { enumerable: true, get: function () { return custom_clause_query_1.CustomClauseQuery; } });
@@ -89,7 +89,13 @@ class FirstFilter {
89
89
  // todo may not be desc
90
90
  // and if asc
91
91
  // clause below should switch to greater...
92
- options.orderby = `${this.sortCol} DESC`;
92
+ const sortCol = this.sortCol.toLowerCase();
93
+ if (sortCol.endsWith("desc") || sortCol.endsWith("asc")) {
94
+ options.orderby = `${this.sortCol}`;
95
+ }
96
+ else {
97
+ options.orderby = `${this.sortCol} DESC`;
98
+ }
93
99
  // we sort by most recent first
94
100
  // so when paging, we fetch afterCursor X
95
101
  if (this.offset) {
@@ -100,6 +106,7 @@ class FirstFilter {
100
106
  options.clause = clause.Less(this.sortCol, new Date(this.offset).toISOString());
101
107
  }
102
108
  }
109
+ // console.debug("filter opts", options, this.options);
103
110
  return options;
104
111
  }
105
112
  // TODO?
@@ -12,6 +12,7 @@ const logger_1 = require("../logger");
12
12
  const test_edge_global_schema_1 = require("../../testutils/test_edge_global_schema");
13
13
  const builder_1 = require("../../testutils/builder");
14
14
  const action_1 = require("../../action");
15
+ const mock_log_1 = require("../../testutils/mock_log");
15
16
  class TestQueryFilter {
16
17
  constructor(filter, newQuery, ents, defaultViewer) {
17
18
  this.filter = filter;
@@ -20,11 +21,15 @@ class TestQueryFilter {
20
21
  this.defaultViewer = defaultViewer;
21
22
  this.allContacts = [];
22
23
  this.filteredContacts = [];
24
+ // @ts-ignore
25
+ const q = this.newQuery(this.defaultViewer);
26
+ // TODO sad not generic enough
27
+ this.customQuery =
28
+ q instanceof index_1.UserToContactsFkeyQuery ||
29
+ q instanceof index_1.UserToContactsFkeyQueryDeprecated;
23
30
  }
24
- async beforeEach() {
25
- // console.log("sss");
31
+ async createData() {
26
32
  [this.user, this.allContacts] = await (0, test_helpers_1.createAllContacts)();
27
- // console.log(this.user, this.contacts);
28
33
  // this.allContacts = this.allContacts.reverse();
29
34
  this.filteredContacts = this.ents(this.allContacts);
30
35
  db_mock_1.QueryRecorder.clearQueries();
@@ -61,16 +66,55 @@ class TestQueryFilter {
61
66
  verifyEdges(edges) {
62
67
  const q = this.getQuery();
63
68
  // TODO sad not generic enough
64
- if (q instanceof index_1.UserToContactsFkeyQuery) {
69
+ if (this.customQuery) {
65
70
  (0, test_helpers_1.verifyUserToContactRawData)(this.user, edges, this.filteredContacts);
66
71
  }
67
72
  else {
68
73
  (0, test_helpers_1.verifyUserToContactEdges)(this.user, edges, this.filteredContacts);
69
74
  }
70
75
  }
71
- async testEnts() {
72
- const entsMap = await this.getQuery(new viewer_1.IDViewer(this.user.id)).queryEnts();
73
- this.verifyEnts(entsMap);
76
+ async testEnts(v) {
77
+ const ents = await this.getQuery(v || new viewer_1.IDViewer(this.user.id)).queryEnts();
78
+ this.verifyEnts(ents);
79
+ return ents;
80
+ }
81
+ async testEntsCache() {
82
+ if (!this.customQuery) {
83
+ return;
84
+ }
85
+ (0, logger_1.setLogLevels)(["query", "cache"]);
86
+ const ml = new mock_log_1.MockLogs();
87
+ ml.mock();
88
+ const v = new test_context_1.TestContext(new viewer_1.IDViewer(this.user.id)).getViewer();
89
+ const ents = await this.testEnts(v);
90
+ expect(ml.logs.length).toBe(1);
91
+ expect(ml.logs[0].query).toMatch(/SELECT (.+) FROM /);
92
+ await Promise.all(ents.map((ent) => index_1.FakeContact.loadX(v, ent.id)));
93
+ expect(ml.logs.length).toBe(this.filteredContacts.length + 1);
94
+ for (const log of ml.logs.slice(1)) {
95
+ expect(log["ent-cache-hit"]).toBeDefined();
96
+ }
97
+ ml.restore();
98
+ (0, logger_1.clearLogLevels)();
99
+ }
100
+ async testDataCache() {
101
+ if (!this.customQuery) {
102
+ return;
103
+ }
104
+ (0, logger_1.setLogLevels)(["query", "cache"]);
105
+ const ml = new mock_log_1.MockLogs();
106
+ ml.mock();
107
+ const v = new test_context_1.TestContext(new viewer_1.IDViewer(this.user.id)).getViewer();
108
+ const ents = await this.testEnts(v);
109
+ expect(ml.logs.length).toBe(1);
110
+ expect(ml.logs[0].query).toMatch(/SELECT (.+) FROM /);
111
+ await Promise.all(ents.map((ent) => index_1.FakeContact.loadRawData(ent.id, v.context)));
112
+ expect(ml.logs.length).toBe(this.filteredContacts.length + 1);
113
+ for (const log of ml.logs.slice(1)) {
114
+ expect(log["dataloader-cache-hit"]).toBeDefined();
115
+ }
116
+ ml.restore();
117
+ (0, logger_1.clearLogLevels)();
74
118
  }
75
119
  verifyEnts(ents) {
76
120
  (0, test_helpers_1.verifyUserToContacts)(this.user, ents, this.filteredContacts);
@@ -203,17 +247,21 @@ const commonTests = (opts) => {
203
247
  }
204
248
  let tdb;
205
249
  if (opts.sqlite) {
206
- (0, temp_db_1.setupSqlite)(`sqlite:///shared_test+${opts.uniqKey}.db`, () => (0, test_helpers_1.tempDBTables)(opts.globalSchema));
250
+ (0, temp_db_1.setupSqlite)(`sqlite:///shared_test+${opts.uniqKey}.db`, () => (0, test_helpers_1.tempDBTables)(opts.globalSchema), {
251
+ disableDeleteAfterEachTest: true,
252
+ });
207
253
  }
208
254
  beforeAll(async () => {
209
255
  // want error on by default in tests?
210
256
  (0, logger_1.setLogLevels)(["error", "warn", "info"]);
211
257
  if (opts.livePostgresDB) {
212
258
  tdb = await (0, test_helpers_1.setupTempDB)();
259
+ return;
213
260
  }
261
+ await (0, test_helpers_1.createEdges)();
214
262
  });
215
263
  beforeEach(async () => {
216
- if (opts.livePostgresDB) {
264
+ if (opts.livePostgresDB || opts.sqlite) {
217
265
  return;
218
266
  }
219
267
  await (0, test_helpers_1.createEdges)();
@@ -233,7 +281,7 @@ const commonTests = (opts) => {
233
281
  return contacts.reverse();
234
282
  }, getViewer());
235
283
  beforeEach(async () => {
236
- await filter.beforeEach();
284
+ await filter.createData();
237
285
  });
238
286
  test("ids", async () => {
239
287
  await filter.testIDs();
@@ -258,6 +306,12 @@ const commonTests = (opts) => {
258
306
  test("all", async () => {
259
307
  await filter.testAll();
260
308
  });
309
+ test("ents cache", async () => {
310
+ await filter.testEntsCache();
311
+ });
312
+ test("data cache", async () => {
313
+ await filter.testDataCache();
314
+ });
261
315
  });
262
316
  describe("after delete", () => {
263
317
  const filter = new TestQueryFilter((q) => {
@@ -268,7 +322,7 @@ const commonTests = (opts) => {
268
322
  return [];
269
323
  }, getViewer());
270
324
  beforeEach(async () => {
271
- await filter.beforeEach();
325
+ await filter.createData();
272
326
  const action = new builder_1.SimpleAction(filter.user.viewer, index_1.FakeUserSchema, new Map(), action_1.WriteOperation.Edit, filter.user);
273
327
  await Promise.all(filter.allContacts.map(async (contact) => {
274
328
  action.builder.orchestrator.removeOutboundEdge(contact.id, index_1.EdgeType.UserToContacts);
@@ -307,6 +361,12 @@ const commonTests = (opts) => {
307
361
  await opts.rawDataVerify(filter.user);
308
362
  }
309
363
  });
364
+ test("ents cache", async () => {
365
+ await filter.testEntsCache();
366
+ });
367
+ test("data cache", async () => {
368
+ await filter.testDataCache();
369
+ });
310
370
  });
311
371
  describe("first. no cursor", () => {
312
372
  const N = 2;
@@ -317,7 +377,7 @@ const commonTests = (opts) => {
317
377
  return contacts.reverse().slice(0, N);
318
378
  }, getViewer());
319
379
  beforeEach(async () => {
320
- await filter.beforeEach();
380
+ await filter.createData();
321
381
  });
322
382
  test("ids", async () => {
323
383
  await filter.testIDs();
@@ -342,6 +402,12 @@ const commonTests = (opts) => {
342
402
  test("all", async () => {
343
403
  await filter.testAll();
344
404
  });
405
+ test("ents cache", async () => {
406
+ await filter.testEntsCache();
407
+ });
408
+ test("data cache", async () => {
409
+ await filter.testDataCache();
410
+ });
345
411
  });
346
412
  describe("last", () => {
347
413
  const N = 2;
@@ -353,7 +419,7 @@ const commonTests = (opts) => {
353
419
  return contacts.slice(0, N).reverse();
354
420
  }, getViewer());
355
421
  beforeEach(async () => {
356
- await filter.beforeEach();
422
+ await filter.createData();
357
423
  });
358
424
  test("ids", async () => {
359
425
  await filter.testIDs();
@@ -378,6 +444,12 @@ const commonTests = (opts) => {
378
444
  test("all", async () => {
379
445
  await filter.testAll();
380
446
  });
447
+ test("ents cache", async () => {
448
+ await filter.testEntsCache();
449
+ });
450
+ test("data cache", async () => {
451
+ await filter.testDataCache();
452
+ });
381
453
  });
382
454
  describe("first after cursor", () => {
383
455
  const idx = 2;
@@ -388,8 +460,18 @@ const commonTests = (opts) => {
388
460
  // < check so we shouldn't get that index
389
461
  return contacts.reverse().slice(idx + 1, idx + N);
390
462
  }, getViewer());
463
+ beforeAll(async () => {
464
+ if (opts.livePostgresDB || opts.sqlite) {
465
+ await filter.createData();
466
+ }
467
+ });
468
+ // TODO do we still need QueryRecorder?
469
+ // should just delete this...
391
470
  beforeEach(async () => {
392
- await filter.beforeEach();
471
+ if (opts.livePostgresDB || opts.sqlite) {
472
+ return;
473
+ }
474
+ await filter.createData();
393
475
  });
394
476
  test("ids", async () => {
395
477
  await filter.testIDs();
@@ -414,6 +496,12 @@ const commonTests = (opts) => {
414
496
  test("all", async () => {
415
497
  await filter.testAll();
416
498
  });
499
+ test("ents cache", async () => {
500
+ await filter.testEntsCache();
501
+ });
502
+ test("data cache", async () => {
503
+ await filter.testDataCache();
504
+ });
417
505
  });
418
506
  test("first. after each cursor", async () => {
419
507
  let [user, contacts] = await (0, test_helpers_1.createAllContacts)();
@@ -456,8 +544,17 @@ const commonTests = (opts) => {
456
544
  // > check so we don't want that index
457
545
  return contacts.reverse().slice(0, idx).reverse(); // because of order returned
458
546
  }, getViewer());
547
+ beforeAll(async () => {
548
+ if (opts.livePostgresDB || opts.sqlite) {
549
+ await filter.createData();
550
+ }
551
+ });
552
+ // same TODO above
459
553
  beforeEach(async () => {
460
- await filter.beforeEach();
554
+ if (opts.livePostgresDB || opts.sqlite) {
555
+ return;
556
+ }
557
+ await filter.createData();
461
558
  });
462
559
  test("ids", async () => {
463
560
  await filter.testIDs();
@@ -482,6 +579,12 @@ const commonTests = (opts) => {
482
579
  test("all", async () => {
483
580
  await filter.testAll();
484
581
  });
582
+ test("ents cache", async () => {
583
+ await filter.testEntsCache();
584
+ });
585
+ test("data cache", async () => {
586
+ await filter.testDataCache();
587
+ });
485
588
  });
486
589
  test("last. before each cursor", async () => {
487
590
  let [user, contacts] = await (0, test_helpers_1.createAllContacts)();
package/index.d.ts CHANGED
@@ -13,6 +13,7 @@ declare const query: {
13
13
  And: typeof q.And;
14
14
  AndOptional: typeof q.AndOptional;
15
15
  Or: typeof q.Or;
16
+ OrOptional: typeof q.OrOptional;
16
17
  In: typeof q.In;
17
18
  Greater: typeof q.Greater;
18
19
  Less: typeof q.Less;
package/index.js CHANGED
@@ -112,6 +112,7 @@ const query = {
112
112
  And: q.And,
113
113
  AndOptional: q.AndOptional,
114
114
  Or: q.Or,
115
+ OrOptional: q.OrOptional,
115
116
  In: q.In,
116
117
  Greater: q.Greater,
117
118
  Less: q.Less,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snowtop/ent",
3
- "version": "0.1.0-alpha88",
3
+ "version": "0.1.0-alpha89-16dc3410-33c4-11ed-9fc4-5d4a927887be",
4
4
  "description": "snowtop ent framework",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -68,7 +68,8 @@ export interface AssocEdgeGroup {
68
68
  tableName?: string;
69
69
  assocEdges: AssocEdge[];
70
70
  statusEnums?: string[];
71
- nullStates: string | string[];
71
+ viewerBased?: boolean;
72
+ nullStates?: string | string[];
72
73
  nullStateFn?: string;
73
74
  edgeAction?: EdgeGroupAction;
74
75
  }
@@ -210,6 +211,7 @@ export interface FieldOptions {
210
211
  [x: string]: any;
211
212
  }
212
213
  export interface PolymorphicOptions {
214
+ name?: string;
213
215
  types?: string[];
214
216
  hideFromInverseGraphQL?: boolean;
215
217
  disableBuilderType?: boolean;
@@ -95,6 +95,7 @@ function transformResultType(f) {
95
95
  type: f.resultType,
96
96
  tsType: graphql_1.knownAllowedNames.get(f.resultType),
97
97
  list: f.list,
98
+ connection: f.connection,
98
99
  nullable: f.nullable,
99
100
  },
100
101
  ]
@@ -304,7 +304,12 @@ function table(name, ...items) {
304
304
  parts.push("PRIMARY KEY");
305
305
  }
306
306
  if (col.default !== undefined) {
307
- parts.push(`DEFAULT ${col.default}`);
307
+ if (db_1.Dialect.SQLite === db_1.default.getDialect()) {
308
+ parts.push(`DEFAULT "${col.default}"`);
309
+ }
310
+ else {
311
+ parts.push(`DEFAULT ${col.default}`);
312
+ }
308
313
  }
309
314
  if (col.unique) {
310
315
  parts.push("UNIQUE");
@@ -384,6 +389,7 @@ class TempDB {
384
389
  else {
385
390
  process.env.DB_CONNECTION_STRING = `postgres://localhost/${this.db}?`;
386
391
  }
392
+ db_1.default.initDB();
387
393
  }
388
394
  else {
389
395
  // will probably be setup via loadConfig
@@ -1,4 +1,4 @@
1
- import { ID, Ent, Viewer, Data, LoadEntOptions, PrivacyPolicy } from "../../core/base";
1
+ import { ID, Ent, Viewer, Data, LoadEntOptions, PrivacyPolicy, Context } from "../../core/base";
2
2
  import { SimpleBuilder } from "../builder";
3
3
  import { NodeType } from "./const";
4
4
  import { ObjectLoaderFactory } from "../../core/loaders";
@@ -20,6 +20,7 @@ export declare class FakeContact implements Ent {
20
20
  static loaderOptions(): LoadEntOptions<FakeContact>;
21
21
  static load(v: Viewer, id: ID): Promise<FakeContact | null>;
22
22
  static loadX(v: Viewer, id: ID): Promise<FakeContact>;
23
+ static loadRawData(id: ID, context?: Context): Promise<Data | null>;
23
24
  }
24
25
  export declare const FakeContactSchema: import("../builder").BuilderSchema<FakeContact>;
25
26
  export interface ContactCreateInput {
@@ -60,6 +60,11 @@ class FakeContact {
60
60
  static async loadX(v, id) {
61
61
  return (0, ent_1.loadEntX)(v, id, FakeContact.loaderOptions());
62
62
  }
63
+ static async loadRawData(id, context) {
64
+ return FakeContact.loaderOptions()
65
+ .loaderFactory.createLoader(context)
66
+ .load(id);
67
+ }
63
68
  }
64
69
  exports.FakeContact = FakeContact;
65
70
  exports.FakeContactSchema = (0, builder_1.getBuilderSchemaFromFields)({
@@ -24,6 +24,8 @@ export declare class FakeEvent implements Ent {
24
24
  }
25
25
  export declare const FakeEventSchema: import("../builder").BuilderSchema<FakeEvent>;
26
26
  export interface EventCreateInput {
27
+ createdAt?: Date;
28
+ updatedAt?: Date;
27
29
  startTime: Date;
28
30
  endTime?: Date | null;
29
31
  location: string;
@@ -26,6 +26,7 @@ interface options {
26
26
  interval: number;
27
27
  userInput?: Partial<UserCreateInput>;
28
28
  eventInputs?: Partial<EventCreateInput>[];
29
+ startTime?: number | Date;
29
30
  }
30
31
  export declare function createAllEvents(opts: options): Promise<[FakeUser, FakeEvent[]]>;
31
32
  export {};
@@ -41,6 +41,8 @@ function getEventInput(user, input) {
41
41
  title: "title",
42
42
  description: "fun event",
43
43
  userID: user.id,
44
+ createdAt: new Date(),
45
+ updatedAt: new Date(),
44
46
  ...input,
45
47
  };
46
48
  }
@@ -232,7 +234,7 @@ async function createAllEvents(opts) {
232
234
  let arr = new Array(opts.howMany);
233
235
  arr.fill(1);
234
236
  // start at date in case something else has used a date already
235
- (0, jest_date_mock_1.advanceTo)(mock_date_1.MockDate.getDate());
237
+ (0, jest_date_mock_1.advanceTo)(opts.startTime || mock_date_1.MockDate.getDate());
236
238
  const events = await Promise.all(arr.map(async (v, idx) => {
237
239
  // just to make times deterministic so that tests can consistently work
238
240
  if (opts.interval > 0) {
@@ -5,7 +5,6 @@ import * as clause from "../../core/clause";
5
5
  import { AssocEdgeQueryBase, EdgeQuerySource } from "../../core/query/assoc_query";
6
6
  import { FakeUser, FakeEvent, FakeContact, EventToAttendeesQuery, EventToDeclinedQuery, EventToHostsQuery, EventToInvitedQuery, EventToMaybeQuery } from "./internal";
7
7
  import { RawCountLoaderFactory } from "../../core/loaders/raw_count_loader";
8
- import { IndexLoaderFactory } from "../../core/loaders/index_loader";
9
8
  import { QueryLoaderFactory } from "../../core/loaders/query_loader";
10
9
  export declare class UserToContactsQuery extends AssocEdgeQueryBase<FakeUser, FakeContact, AssocEdge> {
11
10
  constructor(viewer: Viewer, src: EdgeQuerySource<FakeUser>);
@@ -13,7 +12,12 @@ export declare class UserToContactsQuery extends AssocEdgeQueryBase<FakeUser, Fa
13
12
  sourceEnt(id: ID): Promise<FakeUser | null>;
14
13
  }
15
14
  export declare const userToContactsCountLoaderFactory: RawCountLoaderFactory;
16
- export declare const userToContactsDataLoaderFactory: IndexLoaderFactory;
15
+ export declare const userToContactsDataLoaderFactory: QueryLoaderFactory<unknown>;
16
+ export declare class UserToContactsFkeyQueryDeprecated extends CustomEdgeQueryBase<FakeUser, FakeContact> {
17
+ constructor(viewer: Viewer, src: ID | FakeUser);
18
+ static query(viewer: Viewer, src: FakeUser | ID): UserToContactsFkeyQueryDeprecated;
19
+ sourceEnt(id: ID): Promise<FakeUser | null>;
20
+ }
17
21
  export declare class UserToContactsFkeyQuery extends CustomEdgeQueryBase<FakeUser, FakeContact> {
18
22
  constructor(viewer: Viewer, src: ID | FakeUser);
19
23
  static query(viewer: Viewer, src: FakeUser | ID): UserToContactsFkeyQuery;
@@ -84,8 +88,6 @@ export declare class UserToHostedEventsQuery extends AssocEdgeQueryBase<FakeUser
84
88
  }
85
89
  export declare const getNextWeekClause: () => clause.Clause;
86
90
  export declare function getCompleteClause(id: ID): clause.Clause;
87
- export declare const userToEventsInNextWeekCountLoaderFactory: RawCountLoaderFactory;
88
- export declare const userToEventsInNextWeekDataLoaderFactory: QueryLoaderFactory<unknown>;
89
91
  export declare class UserToEventsInNextWeekQuery extends CustomEdgeQueryBase<FakeUser, FakeEvent> {
90
92
  constructor(viewer: Viewer, src: ID | FakeUser);
91
93
  static query(viewer: Viewer, src: FakeUser | ID): UserToEventsInNextWeekQuery;