@snowtop/ent 0.2.0-alpha.1 → 0.2.0-alpha.10

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.
Files changed (43) hide show
  1. package/action/orchestrator.js +13 -7
  2. package/core/base.d.ts +1 -0
  3. package/core/clause.d.ts +44 -0
  4. package/core/clause.js +75 -2
  5. package/core/db.d.ts +1 -1
  6. package/core/db.js +2 -2
  7. package/core/ent.d.ts +10 -2
  8. package/core/ent.js +11 -18
  9. package/core/loaders/assoc_edge_loader.d.ts +1 -1
  10. package/core/loaders/assoc_edge_loader.js +3 -3
  11. package/core/query/assoc_query.d.ts +2 -2
  12. package/core/query/assoc_query.js +14 -2
  13. package/core/query/custom_clause_query.d.ts +8 -6
  14. package/core/query/custom_clause_query.js +22 -7
  15. package/core/query/custom_query.d.ts +2 -2
  16. package/core/query/custom_query.js +1 -1
  17. package/core/query/query.d.ts +3 -7
  18. package/core/query/query.js +73 -199
  19. package/core/query/shared_test.d.ts +3 -3
  20. package/core/query/shared_test.js +31 -23
  21. package/core/query_impl.d.ts +0 -1
  22. package/core/query_impl.js +18 -1
  23. package/graphql/graphql.js +3 -0
  24. package/graphql/query/edge_connection.d.ts +5 -4
  25. package/graphql/query/edge_connection.js +34 -14
  26. package/graphql/query/shared_edge_connection.d.ts +2 -2
  27. package/graphql/query/shared_edge_connection.js +26 -13
  28. package/package.json +1 -1
  29. package/schema/base_schema.js +2 -2
  30. package/schema/field.js +1 -0
  31. package/schema/schema.d.ts +1 -0
  32. package/schema/struct_field.js +35 -11
  33. package/testutils/builder.js +1 -1
  34. package/testutils/db/value.d.ts +1 -0
  35. package/testutils/db/value.js +2 -1
  36. package/testutils/db_mock.d.ts +1 -1
  37. package/testutils/db_mock.js +1 -1
  38. package/testutils/ent-graphql-tests/index.d.ts +1 -1
  39. package/testutils/ent-graphql-tests/index.js +5 -5
  40. package/testutils/fake_data/fake_contact.js +2 -2
  41. package/testutils/fake_data/fake_event.js +1 -1
  42. package/testutils/fake_data/user_query.d.ts +5 -5
  43. package/testutils/fake_data/user_query.js +11 -14
@@ -1,23 +1,38 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GraphQLEdgeConnection = void 0;
4
+ const query_1 = require("../../core/query");
4
5
  // TODO probably need to template Ent. maybe 2 ents?
5
6
  class GraphQLEdgeConnection {
6
7
  constructor(viewer, arg2, arg3, args) {
7
8
  this.results = [];
8
9
  this.viewer = viewer;
10
+ async function resolveQuery(query, source) {
11
+ const resolved = await query;
12
+ // To have pagination correctly work with CustomClauseQuery in GraphQL contexts, we need to
13
+ // pass the source to the query so that we can set the page info correctly
14
+ // See https://github.com/lolopinto/ent/issues/1836 for full details of how this breaks down
15
+ if (resolved instanceof query_1.CustomClauseQuery && source !== undefined) {
16
+ resolved.__maybeSetSource(source);
17
+ }
18
+ return resolved;
19
+ }
20
+ let query;
21
+ let source;
9
22
  if (typeof arg2 === "function") {
10
- this.query = arg2(this.viewer);
23
+ query = arg2(this.viewer);
11
24
  }
12
25
  else {
13
26
  this.source = arg2;
27
+ source = arg2;
14
28
  }
15
29
  if (typeof arg3 === "function") {
16
- this.query = arg3(this.viewer, this.source);
30
+ query = arg3(this.viewer, this.source);
17
31
  }
18
32
  else {
19
33
  this.args = arg3;
20
34
  }
35
+ this.query = Promise.resolve(resolveQuery(query, source));
21
36
  if (args !== undefined) {
22
37
  this.args = args;
23
38
  }
@@ -29,27 +44,31 @@ class GraphQLEdgeConnection {
29
44
  throw new Error("cannot process before without last");
30
45
  }
31
46
  if (this.args.first) {
32
- this.query = this.query.first(this.args.first, this.args.after);
47
+ const argFirst = this.args.first;
48
+ const argAfter = this.args.after;
49
+ this.query = this.query.then((query) => query.first(argFirst, argAfter));
33
50
  }
34
51
  if (this.args.last) {
35
- this.query = this.query.last(this.args.last, this.args.cursor);
52
+ const argLast = this.args.last;
53
+ const argBefore = this.args.before;
54
+ this.query = this.query.then((query) => query.last(argLast, argBefore));
36
55
  }
37
56
  // TODO custom args
38
57
  // how to proceed
39
58
  }
40
59
  }
41
60
  first(limit, cursor) {
42
- this.query = this.query.first(limit, cursor);
61
+ this.query = this.query.then((query) => query.first(limit, cursor));
43
62
  }
44
63
  last(limit, cursor) {
45
- this.query = this.query.last(limit, cursor);
64
+ this.query = this.query.then((query) => query.last(limit, cursor));
46
65
  }
47
66
  // any custom filters can be applied here...
48
67
  modifyQuery(fn) {
49
- this.query = fn(this.query);
68
+ this.query = this.query.then((query) => fn(query));
50
69
  }
51
70
  async queryTotalCount() {
52
- return this.query.queryRawCount();
71
+ return (await this.query).queryRawCount();
53
72
  }
54
73
  async queryEdges() {
55
74
  // because of privacy, we need to query the node regardless of if the node is there
@@ -60,7 +79,7 @@ class GraphQLEdgeConnection {
60
79
  // if nodes queried just return ents
61
80
  // unlikely to query nodes and pageInfo so we just load this separately for now
62
81
  async queryNodes() {
63
- return this.query.queryEnts();
82
+ return (await this.query).queryEnts();
64
83
  }
65
84
  defaultPageInfo() {
66
85
  return {
@@ -72,7 +91,7 @@ class GraphQLEdgeConnection {
72
91
  }
73
92
  async queryPageInfo() {
74
93
  await this.queryData();
75
- const paginationInfo = this.query.paginationInfo();
94
+ const paginationInfo = (await this.query).paginationInfo();
76
95
  if (this.source !== undefined) {
77
96
  return paginationInfo.get(this.source.id) || this.defaultPageInfo();
78
97
  }
@@ -85,24 +104,25 @@ class GraphQLEdgeConnection {
85
104
  return this.defaultPageInfo();
86
105
  }
87
106
  async queryData() {
107
+ const query = await this.query;
88
108
  const [edges, ents] = await Promise.all([
89
109
  // TODO need a test that this will only fetch edges once
90
110
  // and then fetch ents afterward
91
- this.query.queryEdges(),
92
- this.query.queryEnts(),
111
+ query.queryEdges(),
112
+ query.queryEnts(),
93
113
  ]);
94
114
  let entsMap = new Map();
95
115
  ents.forEach((ent) => entsMap.set(ent.id, ent));
96
116
  let results = [];
97
117
  for (const edge of edges) {
98
- const node = entsMap.get(this.query.dataToID(edge));
118
+ const node = entsMap.get(query.dataToID(edge));
99
119
  if (!node) {
100
120
  continue;
101
121
  }
102
122
  results.push({
103
123
  edge,
104
124
  node,
105
- cursor: this.query.getCursor(edge),
125
+ cursor: query.getCursor(edge),
106
126
  });
107
127
  }
108
128
  this.results = results;
@@ -1,6 +1,6 @@
1
- import { Viewer, Data, Ent } from "../../core/base";
2
- import { FakeContact } from "../../testutils/fake_data/index";
1
+ import { Data, Ent, Viewer } from "../../core/base";
3
2
  import { EdgeQuery } from "../../core/query/query";
3
+ import { FakeContact } from "../../testutils/fake_data/index";
4
4
  interface options<TEnt extends Ent, TEdge extends Data> {
5
5
  getQuery: (v: Viewer, src: Ent) => EdgeQuery<TEnt, Ent, TEdge>;
6
6
  tableName: string;
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.commonTests = void 0;
4
- const viewer_1 = require("../../core/viewer");
4
+ const query_1 = require("../../core/query");
5
5
  const ent_1 = require("../../core/ent");
6
- const edge_connection_1 = require("./edge_connection");
6
+ const viewer_1 = require("../../core/viewer");
7
7
  const index_1 = require("../../testutils/fake_data/index");
8
8
  const test_helpers_1 = require("../../testutils/fake_data/test_helpers");
9
+ const edge_connection_1 = require("./edge_connection");
9
10
  class TestConnection {
10
11
  constructor(getQuery, ents, filter) {
11
12
  this.getQuery = getQuery;
@@ -18,10 +19,20 @@ class TestConnection {
18
19
  this.allContacts = this.allContacts.reverse();
19
20
  this.conn = new edge_connection_1.GraphQLEdgeConnection(new viewer_1.IDViewer(this.user.id), this.user, (v, user) => this.getQuery(v, user));
20
21
  if (this.filter) {
21
- this.filter(this.conn, this.user, this.allContacts);
22
+ await this.filter(this.conn, this.user, this.allContacts);
22
23
  }
23
24
  this.filteredContacts = this.ents(this.allContacts);
24
25
  }
26
+ async testAsyncConn() {
27
+ const asyncConn = new edge_connection_1.GraphQLEdgeConnection(new viewer_1.IDViewer(this.user.id), this.user, (v, user) => new Promise((resolve) => {
28
+ setTimeout(() => resolve(this.getQuery(v, user)), 0);
29
+ }));
30
+ if (this.filter) {
31
+ await this.filter(asyncConn, this.user, this.allContacts);
32
+ }
33
+ const count = await asyncConn.queryTotalCount();
34
+ expect(count).toBe(test_helpers_1.inputs.length);
35
+ }
25
36
  async testTotalCount() {
26
37
  const count = await this.conn.queryTotalCount();
27
38
  expect(count).toBe(test_helpers_1.inputs.length);
@@ -39,7 +50,7 @@ class TestConnection {
39
50
  for (let i = 0; i < this.filteredContacts.length; i++) {
40
51
  const edge = edges[i];
41
52
  expect(edge.node.id).toBe(this.filteredContacts[i].id);
42
- expect(this.conn.query.dataToID(edge.edge)).toBe(this.filteredContacts[i].id);
53
+ expect((await this.conn.query).dataToID(edge.edge)).toBe(this.filteredContacts[i].id);
43
54
  }
44
55
  }
45
56
  }
@@ -50,14 +61,16 @@ const commonTests = (opts) => {
50
61
  q instanceof index_1.UserToContactsFkeyQueryDeprecated ||
51
62
  q instanceof index_1.UserToContactsFkeyQueryAsc ||
52
63
  q instanceof index_1.UserToContactsFkeyQueryDeletedAt ||
53
- q instanceof index_1.UserToContactsFkeyQueryDeletedAtAsc);
64
+ q instanceof index_1.UserToContactsFkeyQueryDeletedAtAsc ||
65
+ q instanceof query_1.CustomClauseQuery);
54
66
  }
55
67
  function getCursorFrom(q, contacts, idx) {
56
68
  let opts;
57
69
  if (isCustomQuery(q)) {
58
70
  opts = {
59
71
  row: contacts[idx],
60
- keys: ["id"],
72
+ cursorKeys: ["created_at", "id"],
73
+ rowKeys: ["createdAt", "id"],
61
74
  };
62
75
  }
63
76
  else {
@@ -65,8 +78,8 @@ const commonTests = (opts) => {
65
78
  // is from assoc_edge table id2 field and so cursor takes it from there
66
79
  opts = {
67
80
  row: contacts[idx],
68
- keys: ["id2"],
69
- cursorKeys: ["id"],
81
+ cursorKeys: ["time", "id2"],
82
+ rowKeys: ["createdAt", "id"],
70
83
  };
71
84
  }
72
85
  return (0, ent_1.getCursor)(opts);
@@ -92,7 +105,7 @@ const commonTests = (opts) => {
92
105
  });
93
106
  });
94
107
  describe("filters. firstN", () => {
95
- const filter = new TestConnection((v, user) => opts.getQuery(v, user), (contacts) => contacts.slice(0, 2), (conn) => {
108
+ const filter = new TestConnection((v, user) => opts.getQuery(v, user), (contacts) => contacts.slice(0, 2), async (conn) => {
96
109
  conn.first(2);
97
110
  });
98
111
  beforeEach(async () => {
@@ -124,8 +137,8 @@ const commonTests = (opts) => {
124
137
  const N = 3;
125
138
  const filter = new TestConnection((v, user) => opts.getQuery(v, user),
126
139
  // get the next 2
127
- (contacts) => contacts.slice(idx + 1, idx + N), (conn, user, contacts) => {
128
- const cursor = getCursorFrom(conn.query, contacts, idx);
140
+ (contacts) => contacts.slice(idx + 1, idx + N), async (conn, user, contacts) => {
141
+ const cursor = getCursorFrom(await conn.query, contacts, idx);
129
142
  conn.first(2, cursor);
130
143
  });
131
144
  beforeEach(async () => {
@@ -153,9 +166,9 @@ const commonTests = (opts) => {
153
166
  });
154
167
  });
155
168
  describe("filters. before cursor", () => {
156
- const filter = new TestConnection((v, user) => opts.getQuery(v, user), (contacts) => contacts.slice(2, 4).reverse(), (conn, user, contacts) => {
169
+ const filter = new TestConnection((v, user) => opts.getQuery(v, user), (contacts) => contacts.slice(2, 4).reverse(), async (conn, user, contacts) => {
157
170
  // get the 2 before it
158
- const cursor = getCursorFrom(conn.query, contacts, 4);
171
+ const cursor = getCursorFrom(await conn.query, contacts, 4);
159
172
  conn.last(2, cursor);
160
173
  });
161
174
  beforeEach(async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snowtop/ent",
3
- "version": "0.2.0-alpha.1",
3
+ "version": "0.2.0-alpha.10",
4
4
  "description": "snowtop ent framework",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -37,12 +37,12 @@ let nodeField = (0, field_1.UUIDType)({
37
37
  });
38
38
  let nodeFields = {
39
39
  // inconsistent naming :(
40
- ID: nodeField,
40
+ id: nodeField,
41
41
  ...tsFields,
42
42
  };
43
43
  let nodeFieldsWithTZ = {
44
44
  // inconsistent naming :(
45
- ID: nodeField,
45
+ id: nodeField,
46
46
  createdAt: (0, field_1.TimestampType)({
47
47
  hideFromGraphQL: true,
48
48
  disableUserEditable: true,
package/schema/field.js CHANGED
@@ -57,6 +57,7 @@ class UUIDField extends BaseField {
57
57
  const polymorphic = this.options?.polymorphic;
58
58
  if (polymorphic) {
59
59
  let name = "";
60
+ // TODO followup to https://github.com/lolopinto/ent/pull/1757
60
61
  if (fieldName.endsWith("_id")) {
61
62
  let idx = fieldName.indexOf("_id");
62
63
  name = fieldName.substring(0, idx) + "_type";
@@ -67,6 +67,7 @@ export interface EdgeAction {
67
67
  export interface InverseAssocEdge {
68
68
  name: string;
69
69
  edgeConstName?: string;
70
+ hideFromGraphQL?: boolean;
70
71
  }
71
72
  export interface EdgeGroupAction {
72
73
  operation: ActionOperation.EdgeGroup;
@@ -36,8 +36,7 @@ class StructField extends field_1.BaseField {
36
36
  throw new Error("valid was not called");
37
37
  }
38
38
  let ret = {};
39
- for (const k in this.options.fields) {
40
- const field = this.options.fields[k];
39
+ const processField = (k, field) => {
41
40
  // check two values
42
41
  // store in dbKey format
43
42
  // check both fieldName and dbKey and store in dbKey for
@@ -52,7 +51,7 @@ class StructField extends field_1.BaseField {
52
51
  val = obj[dbKey];
53
52
  }
54
53
  if (val === undefined) {
55
- continue;
54
+ return;
56
55
  }
57
56
  if (field.format) {
58
57
  // indicate nested so this isn't JSON stringified
@@ -61,6 +60,16 @@ class StructField extends field_1.BaseField {
61
60
  else {
62
61
  ret[dbKey] = val;
63
62
  }
63
+ };
64
+ for (const k in this.options.fields) {
65
+ const field = this.options.fields[k];
66
+ processField(k, field);
67
+ if (field.getDerivedFields) {
68
+ const derivedFields = field.getDerivedFields(k);
69
+ for (const k in derivedFields) {
70
+ processField(k, derivedFields[k]);
71
+ }
72
+ }
64
73
  }
65
74
  // don't json.stringify if nested or list
66
75
  if (nested) {
@@ -114,11 +123,7 @@ class StructField extends field_1.BaseField {
114
123
  return false;
115
124
  }
116
125
  let promises = [];
117
- // TODO probably need to support optional fields...
118
- let valid = true;
119
- for (const k in this.options.fields) {
120
- const field = this.options.fields[k];
121
- let dbKey = (0, schema_1.getStorageKey)(field, k);
126
+ const processField = (k, dbKey, field) => {
122
127
  let fieldName = (0, names_1.toFieldName)(k);
123
128
  let val = obj[fieldName];
124
129
  let uniqueKeyField = false;
@@ -145,15 +150,34 @@ class StructField extends field_1.BaseField {
145
150
  if (val === undefined || val === null) {
146
151
  // nullable, nothing to do here
147
152
  if (field.nullable) {
148
- continue;
153
+ return;
149
154
  }
150
155
  valid = false;
151
- break;
156
+ return false;
152
157
  }
153
158
  if (!field.valid) {
154
- continue;
159
+ return;
155
160
  }
156
161
  promises.push(field.valid(val));
162
+ };
163
+ // TODO probably need to support optional fields...
164
+ let valid = true;
165
+ for (const k in this.options.fields) {
166
+ const field = this.options.fields[k];
167
+ let dbKey = (0, schema_1.getStorageKey)(field, k);
168
+ if (processField(k, dbKey, field) === false) {
169
+ valid = false;
170
+ }
171
+ if (field.getDerivedFields) {
172
+ const derivedFields = field.getDerivedFields(k);
173
+ for (const k in derivedFields) {
174
+ const derivedField = derivedFields[k];
175
+ let dbKey = (0, schema_1.getStorageKey)(derivedField, k);
176
+ if (processField(k, dbKey, derivedField) === false) {
177
+ valid = false;
178
+ }
179
+ }
180
+ }
157
181
  }
158
182
  if (!valid) {
159
183
  return valid;
@@ -211,7 +211,7 @@ class SimpleBuilder {
211
211
  for (const [name, f] of schemaFields) {
212
212
  dbFields.push((0, schema_2.getStorageKey)(f, name));
213
213
  }
214
- if (!schemaFields.has("id") && !schemaFields.has("ID")) {
214
+ if (!schemaFields.has("id")) {
215
215
  if (schemaFields.size !== 1) {
216
216
  throw new Error(`no id field and multiple fields so can't deduce key. add an id field to schema`);
217
217
  }
@@ -1,5 +1,6 @@
1
1
  import { Field, Schema } from "../../schema";
2
2
  export declare function randomEmail(domain?: string): string;
3
+ export declare function randomPhoneNumber(): string;
3
4
  interface Info {
4
5
  schema: Schema;
5
6
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getDefaultValue = exports.randomEmail = void 0;
3
+ exports.getDefaultValue = exports.randomPhoneNumber = exports.randomEmail = void 0;
4
4
  const uuid_1 = require("uuid");
5
5
  const schema_1 = require("../../schema");
6
6
  const schema_2 = require("../../schema");
@@ -15,6 +15,7 @@ exports.randomEmail = randomEmail;
15
15
  function randomPhoneNumber() {
16
16
  return `+1${Math.random().toString(10).substring(2, 11)}`;
17
17
  }
18
+ exports.randomPhoneNumber = randomPhoneNumber;
18
19
  function coinFlip() {
19
20
  return Math.floor(Math.random() * 10) >= 5;
20
21
  }
@@ -1,5 +1,5 @@
1
1
  import { Pool } from "pg";
2
- import { ID, Data } from "../core/base";
2
+ import { Data, ID } from "../core/base";
3
3
  import { Clause } from "../core/clause";
4
4
  import { MockLogs } from "./mock_log";
5
5
  export interface queryOptions {
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.QueryRecorder = exports.queryType = void 0;
4
- const uuid_1 = require("uuid");
5
4
  const jest_mock_1 = require("jest-mock");
5
+ const uuid_1 = require("uuid");
6
6
  const parse_sql_1 = require("./parse_sql");
7
7
  const eventEmitter = {
8
8
  on: jest.fn(),
@@ -1,7 +1,7 @@
1
1
  import { Express, RequestHandler } from "express";
2
- import { Viewer } from "../../core/base";
3
2
  import { GraphQLSchema } from "graphql";
4
3
  import supertest from "supertest";
4
+ import { Viewer } from "../../core/base";
5
5
  export type Option = [string, any] | [string, any, string];
6
6
  interface queryConfig {
7
7
  viewer?: Viewer;
@@ -30,12 +30,12 @@ exports.expectMutation = exports.expectQueryFromRoot = void 0;
30
30
  // NB: this is copied from ent-graphql-tests package until I have time to figure out how to share code here effectively
31
31
  // the circular dependencies btw this package and ent-graphql-tests seems to imply something needs to change
32
32
  const express_1 = __importDefault(require("express"));
33
- const graphql_helix_1 = require("graphql-helix");
33
+ const fs = __importStar(require("fs"));
34
34
  const graphql_1 = require("graphql");
35
- const auth_1 = require("../../auth");
35
+ const graphql_helix_1 = require("graphql-helix");
36
36
  const supertest_1 = __importDefault(require("supertest"));
37
- const fs = __importStar(require("fs"));
38
37
  const util_1 = require("util");
38
+ const auth_1 = require("../../auth");
39
39
  function server(config) {
40
40
  const viewer = config.viewer;
41
41
  if (viewer) {
@@ -125,7 +125,7 @@ function makeGraphQLRequest(config, query, fieldArgs) {
125
125
  if (files.size) {
126
126
  let ret = test
127
127
  .post(config.graphQLPath || "/graphql")
128
- .set(config.headers || {});
128
+ .set((config.headers || {}));
129
129
  ret.field("operations", JSON.stringify({
130
130
  query: query,
131
131
  variables: variables,
@@ -152,7 +152,7 @@ function makeGraphQLRequest(config, query, fieldArgs) {
152
152
  test,
153
153
  test
154
154
  .post(config.graphQLPath || "/graphql")
155
- .set(config.headers || {})
155
+ .set((config.headers || {}))
156
156
  .send({
157
157
  query: query,
158
158
  variables: JSON.stringify(variables),
@@ -130,7 +130,7 @@ exports.FakeContactSchema = (0, builder_1.getBuilderSchemaFromFields)({
130
130
  lastName: (0, schema_1.StringType)(),
131
131
  emailAddress: (0, schema_1.StringType)(),
132
132
  userID: (0, schema_1.UUIDType)({
133
- foreignKey: { schema: "User", column: "ID" },
133
+ foreignKey: { schema: "User", column: "id" },
134
134
  }),
135
135
  }, FakeContact);
136
136
  exports.FakeContactSchemaWithDeletedAt = (0, builder_1.getBuilderSchemaFromFields)({
@@ -138,7 +138,7 @@ exports.FakeContactSchemaWithDeletedAt = (0, builder_1.getBuilderSchemaFromField
138
138
  lastName: (0, schema_1.StringType)(),
139
139
  emailAddress: (0, schema_1.StringType)(),
140
140
  userID: (0, schema_1.UUIDType)({
141
- foreignKey: { schema: "User", column: "ID" },
141
+ foreignKey: { schema: "User", column: "id" },
142
142
  }),
143
143
  }, FakeContact, {
144
144
  patterns: [new soft_delete_1.DeletedAtPattern()],
@@ -132,7 +132,7 @@ exports.FakeEventSchema = (0, builder_1.getBuilderSchemaFromFields)({
132
132
  nullable: true,
133
133
  }),
134
134
  userID: (0, schema_1.UUIDType)({
135
- foreignKey: { schema: "User", column: "ID" },
135
+ foreignKey: { schema: "User", column: "id" },
136
136
  }),
137
137
  }, FakeEvent);
138
138
  function getEventBuilder(viewer, input) {
@@ -1,11 +1,11 @@
1
1
  import { Data, Ent, ID, Viewer } from "../../core/base";
2
- import { CustomEdgeQueryBase } from "../../core/query/custom_query";
3
- import { AssocEdge } from "../../core/ent";
4
2
  import * as clause from "../../core/clause";
5
- import { AssocEdgeQueryBase, EdgeQuerySource } from "../../core/query/assoc_query";
6
- import { FakeUser, FakeEvent, FakeContact, EventToAttendeesQuery, EventToDeclinedQuery, EventToHostsQuery, EventToInvitedQuery, EventToMaybeQuery } from "./internal";
7
- import { RawCountLoaderFactory } from "../../core/loaders/raw_count_loader";
3
+ import { AssocEdge } from "../../core/ent";
8
4
  import { QueryLoaderFactory } from "../../core/loaders/query_loader";
5
+ import { RawCountLoaderFactory } from "../../core/loaders/raw_count_loader";
6
+ import { AssocEdgeQueryBase, EdgeQuerySource } from "../../core/query/assoc_query";
7
+ import { CustomEdgeQueryBase } from "../../core/query/custom_query";
8
+ import { EventToAttendeesQuery, EventToDeclinedQuery, EventToHostsQuery, EventToInvitedQuery, EventToMaybeQuery, FakeContact, FakeEvent, FakeUser } from "./internal";
9
9
  export declare class UserToContactsQuery extends AssocEdgeQueryBase<FakeUser, FakeContact, AssocEdge> {
10
10
  constructor(viewer: Viewer, src: EdgeQuerySource<FakeUser>);
11
11
  static query(viewer: Viewer, src: EdgeQuerySource<FakeUser>): UserToContactsQuery;
@@ -24,21 +24,20 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.UserToFollowingQuery = exports.UserToEventsInNextWeekQuery = exports.getCompleteClause = exports.getNextWeekClause = exports.UserToHostedEventsQuery = exports.UserToEventsAttendingQuery = exports.UserToIncomingFriendRequestsQuery = exports.UserToFriendRequestsQuery = exports.UserToCustomEdgeQuery = exports.CustomEdge = exports.UserToFriendsQuery = exports.UserToContactsFkeyQueryDeletedAtAsc = exports.UserToContactsFkeyQueryAsc = exports.UserToContactsFkeyQueryDeletedAt = exports.UserToContactsFkeyQuery = exports.UserToContactsFkeyQueryDeprecated = exports.userToContactsDataLoaderFactory = exports.userToContactsCountLoaderFactory = exports.UserToContactsQuery = void 0;
27
- const custom_query_1 = require("../../core/query/custom_query");
28
- const ent_1 = require("../../core/ent");
27
+ const jest_date_mock_1 = require("jest-date-mock");
28
+ const _1 = require(".");
29
29
  const clause = __importStar(require("../../core/clause"));
30
- const assoc_query_1 = require("../../core/query/assoc_query");
31
- const internal_1 = require("./internal");
32
- const raw_count_loader_1 = require("../../core/loaders/raw_count_loader");
30
+ const ent_1 = require("../../core/ent");
33
31
  const assoc_count_loader_1 = require("../../core/loaders/assoc_count_loader");
34
32
  const assoc_edge_loader_1 = require("../../core/loaders/assoc_edge_loader");
35
- const fake_contact_1 = require("./fake_contact");
36
- const jest_date_mock_1 = require("jest-date-mock");
37
- const luxon_1 = require("luxon");
38
33
  const query_loader_1 = require("../../core/loaders/query_loader");
39
- const mock_date_1 = require("./../mock_date");
40
- const _1 = require(".");
34
+ const raw_count_loader_1 = require("../../core/loaders/raw_count_loader");
41
35
  const privacy_1 = require("../../core/privacy");
36
+ const assoc_query_1 = require("../../core/query/assoc_query");
37
+ const custom_query_1 = require("../../core/query/custom_query");
38
+ const mock_date_1 = require("./../mock_date");
39
+ const fake_contact_1 = require("./fake_contact");
40
+ const internal_1 = require("./internal");
42
41
  class UserToContactsQuery extends assoc_query_1.AssocEdgeQueryBase {
43
42
  constructor(viewer, src) {
44
43
  super(viewer, src, new assoc_count_loader_1.AssocEdgeCountLoaderFactory(internal_1.EdgeType.UserToContacts), new assoc_edge_loader_1.AssocEdgeLoaderFactory(internal_1.EdgeType.UserToContacts, ent_1.AssocEdge), internal_1.FakeContact.loaderOptions());
@@ -351,10 +350,8 @@ const getNextWeekClause = () => {
351
350
  (0, jest_date_mock_1.clear)();
352
351
  const start = mock_date_1.MockDate.getDate();
353
352
  // 7 days
354
- const end = luxon_1.Interval.after(start, 86400 * 1000 * 7)
355
- .end.toUTC()
356
- .toISO();
357
- return clause.And(clause.GreaterEq("start_time", start.toISOString()), clause.LessEq("start_time", end));
353
+ const end = new Date(start.getTime() + 86400 * 1000 * 7);
354
+ return clause.And(clause.GreaterEq("start_time", start.toISOString()), clause.LessEq("start_time", end.toISOString()));
358
355
  };
359
356
  exports.getNextWeekClause = getNextWeekClause;
360
357
  function getCompleteClause(id) {