@snowtop/ent 0.1.0-alpha13 → 0.1.0-alpha131

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 (173) hide show
  1. package/action/action.d.ts +33 -29
  2. package/action/action.js +22 -7
  3. package/action/executor.d.ts +3 -3
  4. package/action/executor.js +8 -3
  5. package/action/experimental_action.d.ts +32 -22
  6. package/action/experimental_action.js +35 -9
  7. package/action/index.d.ts +2 -0
  8. package/action/index.js +7 -1
  9. package/action/orchestrator.d.ts +32 -15
  10. package/action/orchestrator.js +249 -53
  11. package/action/privacy.d.ts +2 -2
  12. package/action/relative_value.d.ts +47 -0
  13. package/action/relative_value.js +125 -0
  14. package/action/transaction.d.ts +10 -0
  15. package/action/transaction.js +23 -0
  16. package/auth/auth.d.ts +1 -1
  17. package/core/base.d.ts +61 -37
  18. package/core/base.js +7 -1
  19. package/core/clause.d.ts +85 -40
  20. package/core/clause.js +375 -64
  21. package/core/config.d.ts +12 -1
  22. package/core/config.js +7 -1
  23. package/core/const.d.ts +3 -0
  24. package/core/const.js +6 -0
  25. package/core/context.d.ts +6 -4
  26. package/core/context.js +20 -2
  27. package/core/convert.d.ts +1 -1
  28. package/core/date.js +1 -5
  29. package/core/db.d.ts +11 -8
  30. package/core/db.js +20 -8
  31. package/core/ent.d.ts +86 -30
  32. package/core/ent.js +626 -197
  33. package/core/global_schema.d.ts +7 -0
  34. package/core/global_schema.js +51 -0
  35. package/core/loaders/assoc_count_loader.d.ts +3 -2
  36. package/core/loaders/assoc_count_loader.js +10 -2
  37. package/core/loaders/assoc_edge_loader.d.ts +2 -2
  38. package/core/loaders/assoc_edge_loader.js +8 -11
  39. package/core/loaders/index.d.ts +1 -1
  40. package/core/loaders/index.js +1 -3
  41. package/core/loaders/index_loader.d.ts +3 -3
  42. package/core/loaders/loader.d.ts +2 -2
  43. package/core/loaders/loader.js +5 -5
  44. package/core/loaders/object_loader.d.ts +32 -11
  45. package/core/loaders/object_loader.js +225 -78
  46. package/core/loaders/query_loader.d.ts +7 -13
  47. package/core/loaders/query_loader.js +52 -11
  48. package/core/loaders/raw_count_loader.d.ts +2 -2
  49. package/core/loaders/raw_count_loader.js +5 -1
  50. package/core/logger.d.ts +1 -1
  51. package/core/logger.js +1 -0
  52. package/core/privacy.d.ts +25 -24
  53. package/core/privacy.js +21 -25
  54. package/core/query/assoc_query.d.ts +7 -6
  55. package/core/query/assoc_query.js +9 -1
  56. package/core/query/custom_clause_query.d.ts +27 -0
  57. package/core/query/custom_clause_query.js +84 -0
  58. package/core/query/custom_query.d.ts +20 -5
  59. package/core/query/custom_query.js +87 -12
  60. package/core/query/index.d.ts +1 -0
  61. package/core/query/index.js +3 -1
  62. package/core/query/query.d.ts +8 -4
  63. package/core/query/query.js +101 -53
  64. package/core/query/shared_assoc_test.d.ts +2 -1
  65. package/core/query/shared_assoc_test.js +35 -45
  66. package/core/query/shared_test.d.ts +8 -1
  67. package/core/query/shared_test.js +470 -236
  68. package/core/viewer.d.ts +3 -3
  69. package/core/viewer.js +1 -1
  70. package/graphql/graphql.d.ts +51 -19
  71. package/graphql/graphql.js +160 -136
  72. package/graphql/graphql_field_helpers.d.ts +7 -1
  73. package/graphql/graphql_field_helpers.js +21 -1
  74. package/graphql/index.d.ts +2 -2
  75. package/graphql/index.js +3 -5
  76. package/graphql/query/connection_type.d.ts +9 -9
  77. package/graphql/query/edge_connection.d.ts +9 -9
  78. package/graphql/query/page_info.d.ts +1 -1
  79. package/graphql/query/shared_assoc_test.js +1 -1
  80. package/graphql/query/shared_edge_connection.js +1 -19
  81. package/graphql/scalars/orderby_direction.d.ts +2 -0
  82. package/graphql/scalars/orderby_direction.js +15 -0
  83. package/imports/dataz/example1/_auth.js +128 -47
  84. package/imports/dataz/example1/_viewer.js +87 -39
  85. package/imports/index.d.ts +6 -1
  86. package/imports/index.js +19 -4
  87. package/index.d.ts +13 -5
  88. package/index.js +21 -7
  89. package/package.json +17 -17
  90. package/parse_schema/parse.d.ts +31 -9
  91. package/parse_schema/parse.js +155 -13
  92. package/schema/base_schema.d.ts +7 -3
  93. package/schema/base_schema.js +10 -0
  94. package/schema/field.d.ts +78 -21
  95. package/schema/field.js +231 -71
  96. package/schema/index.d.ts +2 -2
  97. package/schema/index.js +5 -1
  98. package/schema/json_field.d.ts +16 -4
  99. package/schema/json_field.js +32 -2
  100. package/schema/schema.d.ts +89 -19
  101. package/schema/schema.js +11 -13
  102. package/schema/struct_field.d.ts +15 -3
  103. package/schema/struct_field.js +117 -22
  104. package/schema/union_field.d.ts +1 -1
  105. package/scripts/custom_compiler.js +10 -6
  106. package/scripts/custom_graphql.js +128 -31
  107. package/scripts/migrate_v0.1.js +36 -0
  108. package/scripts/move_types.js +120 -0
  109. package/scripts/read_schema.js +20 -5
  110. package/testutils/action/complex_schemas.d.ts +69 -0
  111. package/testutils/action/complex_schemas.js +398 -0
  112. package/testutils/builder.d.ts +41 -47
  113. package/testutils/builder.js +76 -49
  114. package/testutils/db/fixture.d.ts +10 -0
  115. package/testutils/db/fixture.js +26 -0
  116. package/testutils/db/{test_db.d.ts → temp_db.d.ts} +24 -8
  117. package/testutils/db/{test_db.js → temp_db.js} +182 -45
  118. package/testutils/db/value.d.ts +7 -0
  119. package/testutils/db/value.js +251 -0
  120. package/testutils/db_mock.d.ts +16 -4
  121. package/testutils/db_mock.js +52 -7
  122. package/testutils/db_time_zone.d.ts +4 -0
  123. package/testutils/db_time_zone.js +41 -0
  124. package/testutils/ent-graphql-tests/index.d.ts +7 -1
  125. package/testutils/ent-graphql-tests/index.js +52 -23
  126. package/testutils/fake_comms.js +1 -1
  127. package/testutils/fake_data/const.d.ts +2 -1
  128. package/testutils/fake_data/const.js +3 -0
  129. package/testutils/fake_data/fake_contact.d.ts +7 -3
  130. package/testutils/fake_data/fake_contact.js +13 -7
  131. package/testutils/fake_data/fake_event.d.ts +4 -1
  132. package/testutils/fake_data/fake_event.js +7 -6
  133. package/testutils/fake_data/fake_tag.d.ts +36 -0
  134. package/testutils/fake_data/fake_tag.js +89 -0
  135. package/testutils/fake_data/fake_user.d.ts +8 -5
  136. package/testutils/fake_data/fake_user.js +16 -15
  137. package/testutils/fake_data/index.js +5 -1
  138. package/testutils/fake_data/internal.d.ts +2 -0
  139. package/testutils/fake_data/internal.js +7 -1
  140. package/testutils/fake_data/tag_query.d.ts +13 -0
  141. package/testutils/fake_data/tag_query.js +43 -0
  142. package/testutils/fake_data/test_helpers.d.ts +11 -4
  143. package/testutils/fake_data/test_helpers.js +28 -12
  144. package/testutils/fake_data/user_query.d.ts +13 -6
  145. package/testutils/fake_data/user_query.js +54 -22
  146. package/testutils/fake_log.d.ts +3 -3
  147. package/testutils/fake_log.js +1 -1
  148. package/testutils/parse_sql.d.ts +6 -0
  149. package/testutils/parse_sql.js +16 -2
  150. package/testutils/test_edge_global_schema.d.ts +15 -0
  151. package/testutils/test_edge_global_schema.js +62 -0
  152. package/testutils/write.d.ts +2 -2
  153. package/testutils/write.js +33 -7
  154. package/tsc/ast.d.ts +25 -2
  155. package/tsc/ast.js +141 -17
  156. package/tsc/compilerOptions.js +5 -1
  157. package/tsc/move_generated.d.ts +1 -0
  158. package/tsc/move_generated.js +164 -0
  159. package/tsc/transform.d.ts +22 -0
  160. package/tsc/transform.js +181 -0
  161. package/tsc/transform_action.d.ts +22 -0
  162. package/tsc/transform_action.js +183 -0
  163. package/tsc/transform_ent.d.ts +17 -0
  164. package/tsc/transform_ent.js +60 -0
  165. package/tsc/transform_schema.d.ts +27 -0
  166. package/{scripts → tsc}/transform_schema.js +146 -117
  167. package/graphql/enums.d.ts +0 -3
  168. package/graphql/enums.js +0 -25
  169. package/scripts/move_generated.js +0 -142
  170. package/scripts/transform_code.js +0 -113
  171. package/scripts/transform_schema.d.ts +0 -1
  172. /package/scripts/{move_generated.d.ts → migrate_v0.1.d.ts} +0 -0
  173. /package/scripts/{transform_code.d.ts → move_types.d.ts} +0 -0
@@ -29,7 +29,11 @@ var queryType;
29
29
  queryType[queryType["BEGIN"] = 3] = "BEGIN";
30
30
  queryType[queryType["COMMIT"] = 4] = "COMMIT";
31
31
  queryType[queryType["ROLLBACK"] = 5] = "ROLLBACK";
32
+ queryType[queryType["DELETE"] = 6] = "DELETE";
32
33
  })(queryType = exports.queryType || (exports.queryType = {}));
34
+ /**
35
+ * @deprecated
36
+ */
33
37
  class QueryRecorder {
34
38
  // TODO kill use AST or just throw away
35
39
  static getQueryStructure(query) {
@@ -76,6 +80,36 @@ class QueryRecorder {
76
80
  };
77
81
  }
78
82
  }
83
+ if (/^DELETE/.test(query)) {
84
+ // regex can't do returning
85
+ let execArray = /^DELETE FROM (.+) WHERE (.+) /.exec(query);
86
+ if (execArray) {
87
+ return {
88
+ tableName: execArray[1],
89
+ whereClause: execArray[2],
90
+ type: queryType.DELETE,
91
+ query: execArray[0],
92
+ };
93
+ }
94
+ }
95
+ if (/^BEGIN/.test(query)) {
96
+ return {
97
+ type: queryType.BEGIN,
98
+ query: query,
99
+ };
100
+ }
101
+ if (/^COMMIT/.test(query)) {
102
+ return {
103
+ type: queryType.COMMIT,
104
+ query: query,
105
+ };
106
+ }
107
+ if (/^ROLLBACK/.test(query)) {
108
+ return {
109
+ type: queryType.ROLLBACK,
110
+ query: query,
111
+ };
112
+ }
79
113
  return null;
80
114
  }
81
115
  static recordQuery(query, values) {
@@ -131,7 +165,12 @@ class QueryRecorder {
131
165
  static getCurrentQueries() {
132
166
  return QueryRecorder.queries;
133
167
  }
134
- static validateQueryStructuresFromLogs(ml, expected, skipSelect) {
168
+ /**
169
+ * @deprecated will keep this since it's just using ml.logs
170
+ * which we still want around (I think) but we should eventually
171
+ * probably stop using this
172
+ */
173
+ static validateQueryStructuresFromLogs(ml, expected, opts) {
135
174
  const queries = ml.logs.map((log) => {
136
175
  const qs = QueryRecorder.getQueryStructure(log.query);
137
176
  if (!qs) {
@@ -142,12 +181,16 @@ class QueryRecorder {
142
181
  qs,
143
182
  };
144
183
  });
145
- QueryRecorder.validateQuryStructuresImpl(expected, queries, skipSelect);
184
+ QueryRecorder.validateQueryStructuresImpl(expected, queries, opts);
146
185
  }
147
- static validateQuryStructuresImpl(expected, queries, skipSelect) {
148
- if (skipSelect) {
186
+ static validateQueryStructuresImpl(expected, queries, opts) {
187
+ if (opts?.skipSelect) {
149
188
  queries = queries.filter((query) => query.qs?.type !== queryType.SELECT);
150
189
  }
190
+ if (!opts?.flagBeginCommit) {
191
+ queries = queries.filter((query) => query.qs?.type !== queryType.BEGIN &&
192
+ query.qs?.type !== queryType.COMMIT);
193
+ }
151
194
  // console.log(queries, expected);
152
195
  expect(queries.length).toBe(expected.length);
153
196
  for (let i = 0; i < expected.length; i++) {
@@ -167,7 +210,7 @@ class QueryRecorder {
167
210
  expect(query.values).toBe(undefined);
168
211
  break;
169
212
  case queryType.SELECT:
170
- if (!skipSelect) {
213
+ if (!opts?.skipSelect) {
171
214
  console.error("validating select query structure not supported yet");
172
215
  }
173
216
  // TODO INSERT and UPDATE tests here...
@@ -185,7 +228,9 @@ class QueryRecorder {
185
228
  }
186
229
  }
187
230
  static mockPool(pool) {
188
- const mockedPool = (0, jest_mock_1.mocked)(pool, true);
231
+ const mockedPool = (0, jest_mock_1.mocked)(pool);
232
+ // @ts-ignore
233
+ // TODO what changed in mockImplementation?
189
234
  mockedPool.mockImplementation(() => {
190
235
  return {
191
236
  totalCount: 1,
@@ -218,10 +263,10 @@ class QueryRecorder {
218
263
  });
219
264
  }
220
265
  }
221
- exports.QueryRecorder = QueryRecorder;
222
266
  QueryRecorder.queries = [];
223
267
  QueryRecorder.ids = [];
224
268
  // we need pkeys when storing...
225
269
  QueryRecorder.data = new Map();
270
+ exports.QueryRecorder = QueryRecorder;
226
271
  // TODO
227
272
  process.env.DB_CONNECTION_STRING = "INVALID DATABASE";
@@ -0,0 +1,4 @@
1
+ export declare class DBTimeZone {
2
+ private static getVal;
3
+ static getDateOffset(d: Date): Promise<string>;
4
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.DBTimeZone = void 0;
7
+ const luxon_1 = require("luxon");
8
+ const schema_1 = require("../schema");
9
+ const db_1 = __importDefault(require("../core/db"));
10
+ let dbCurrentZone = undefined;
11
+ class DBTimeZone {
12
+ static async getVal() {
13
+ if (dbCurrentZone !== undefined) {
14
+ return dbCurrentZone;
15
+ }
16
+ const r = await db_1.default.getInstance()
17
+ .getPool()
18
+ .query("SELECT current_setting('TIMEZONE');");
19
+ if (r.rows.length) {
20
+ dbCurrentZone = r.rows[0].current_setting;
21
+ }
22
+ else {
23
+ dbCurrentZone = null;
24
+ }
25
+ return dbCurrentZone;
26
+ }
27
+ static async getDateOffset(d) {
28
+ let zone = await DBTimeZone.getVal();
29
+ let dt = luxon_1.DateTime.fromJSDate(d);
30
+ if (zone) {
31
+ dt = dt.setZone(zone);
32
+ }
33
+ // use
34
+ const val = (0, schema_1.leftPad)(dt.get("offset") / 60);
35
+ if (val == "00") {
36
+ return "+00";
37
+ }
38
+ return val;
39
+ }
40
+ }
41
+ exports.DBTimeZone = DBTimeZone;
@@ -2,7 +2,7 @@ import { Express, RequestHandler } from "express";
2
2
  import { Viewer } from "../../core/base";
3
3
  import { GraphQLSchema } from "graphql";
4
4
  import supertest from "supertest";
5
- export declare type Option = [string, any];
5
+ export type Option = [string, any];
6
6
  interface queryConfig {
7
7
  viewer?: Viewer;
8
8
  init?: (app: Express) => void;
@@ -11,6 +11,12 @@ interface queryConfig {
11
11
  headers?: object;
12
12
  debugMode?: boolean;
13
13
  args: {};
14
+ extraVariables?: {
15
+ [key: string]: {
16
+ graphqlType: string;
17
+ value: string;
18
+ };
19
+ };
14
20
  expectedStatus?: number;
15
21
  expectedError?: string | RegExp;
16
22
  callback?: (res: supertest.Response) => void;
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -31,6 +35,7 @@ const graphql_1 = require("graphql");
31
35
  const auth_1 = require("../../auth");
32
36
  const supertest_1 = __importDefault(require("supertest"));
33
37
  const fs = __importStar(require("fs"));
38
+ const util_1 = require("util");
34
39
  function server(config) {
35
40
  const viewer = config.viewer;
36
41
  if (viewer) {
@@ -45,6 +50,7 @@ function server(config) {
45
50
  if (config.init) {
46
51
  config.init(app);
47
52
  }
53
+ // @ts-ignore something changed. come back
48
54
  app.use(express_1.default.json());
49
55
  let handlers = config.customHandlers || [];
50
56
  handlers.push(async (req, res) => {
@@ -56,9 +62,11 @@ function server(config) {
56
62
  request: req,
57
63
  schema: config.schema,
58
64
  contextFactory: async (executionContext) => {
65
+ // @ts-ignore something changed. come back
59
66
  return (0, auth_1.buildContext)(req, res);
60
67
  },
61
68
  });
69
+ // @ts-ignore something changed. come back
62
70
  await (0, graphql_helix_1.sendResult)(result, res);
63
71
  });
64
72
  app.use(config.graphQLPath || "/graphql", ...handlers);
@@ -108,17 +116,23 @@ function makeGraphQLRequest(config, query, fieldArgs) {
108
116
  }
109
117
  }
110
118
  });
119
+ let variables = {
120
+ ...config.args,
121
+ };
122
+ for (const k in config.extraVariables) {
123
+ variables[k] = config.extraVariables[k].value;
124
+ }
111
125
  if (files.size) {
112
126
  let ret = test
113
127
  .post(config.graphQLPath || "/graphql")
114
128
  .set(config.headers || {});
115
129
  ret.field("operations", JSON.stringify({
116
130
  query: query,
117
- variables: config.args,
131
+ variables: variables,
118
132
  }));
119
133
  let m = {};
120
134
  let idx = 0;
121
- for (const [key, val] of files) {
135
+ for (const [key] of files) {
122
136
  m[idx] = [`variables.${key}`];
123
137
  idx++;
124
138
  }
@@ -141,15 +155,16 @@ function makeGraphQLRequest(config, query, fieldArgs) {
141
155
  .set(config.headers || {})
142
156
  .send({
143
157
  query: query,
144
- variables: JSON.stringify(config.args),
158
+ variables: JSON.stringify(variables),
145
159
  }),
146
160
  ];
147
161
  }
148
162
  }
149
163
  function buildTreeFromQueryPaths(schema, fieldType, ...options) {
150
164
  let fields;
151
- if (fieldType instanceof graphql_1.GraphQLObjectType) {
152
- fields = fieldType.getFields();
165
+ const [typ] = getInnerType(fieldType, false);
166
+ if (typ instanceof graphql_1.GraphQLObjectType) {
167
+ fields = typ.getFields();
153
168
  }
154
169
  let topLevelTree = {};
155
170
  options.forEach((option) => {
@@ -157,7 +172,7 @@ function buildTreeFromQueryPaths(schema, fieldType, ...options) {
157
172
  let parts = [];
158
173
  let match = fragmentRegex.exec(path);
159
174
  if (match) {
160
- // fragment, keep the part of the fragment e.g. ...onUser, and then split the rest....
175
+ // fragment, keep the part of the fragment e.g. `...on User`, and then split the rest....
161
176
  parts = [match[0], ...match[2].split(".")];
162
177
  const typ = schema.getType(match[1]);
163
178
  if (!typ) {
@@ -187,10 +202,11 @@ function buildTreeFromQueryPaths(schema, fieldType, ...options) {
187
202
  }
188
203
  // TODO this needs to be aware of paths etc so this part works for complicated
189
204
  // cases but inlineFragmentRoot is a workaround for now.
190
- function handleSubtree(obj, tree) {
205
+ function handleSubtree(obj, tree, parts) {
206
+ let parts2 = [...parts];
191
207
  if (Array.isArray(obj)) {
192
208
  for (const obj2 of obj) {
193
- handleSubtree(obj2, tree);
209
+ handleSubtree(obj2, tree, parts2);
194
210
  }
195
211
  return;
196
212
  }
@@ -199,28 +215,36 @@ function buildTreeFromQueryPaths(schema, fieldType, ...options) {
199
215
  tree[key] = {};
200
216
  }
201
217
  if (typeof obj[key] === "object") {
202
- if (!isScalarField(key)) {
203
- handleSubtree(obj[key], tree[key]);
218
+ let parts2 = [...parts, key];
219
+ if (!scalarFieldAtLeaf(parts2)) {
220
+ handleSubtree(obj[key], tree[key], parts2);
204
221
  }
205
222
  }
206
223
  }
207
224
  }
208
- // TODO this needs to work for super complicated objects and have fields update as nesting applies...
209
- function isScalarField(f) {
210
- const subField = fields?.[f];
211
- if (!subField) {
225
+ function scalarFieldAtLeaf(pathFromRoot) {
226
+ let root = fields;
227
+ if (!root) {
212
228
  return false;
213
229
  }
214
- if (!(0, graphql_1.isWrappingType)(subField.type)) {
230
+ let subField;
231
+ for (const p of pathFromRoot) {
232
+ subField = root?.[p];
233
+ if (subField) {
234
+ [subField] = getInnerType(subField.type, false);
235
+ if (subField instanceof graphql_1.GraphQLObjectType) {
236
+ root = subField.getFields();
237
+ }
238
+ }
239
+ }
240
+ if (!subField) {
215
241
  return false;
216
242
  }
217
- // only spread out if an object
218
- const [typ, _] = getInnerType(subField.type, true);
219
- return (0, graphql_1.isScalarType)(typ);
243
+ return (0, graphql_1.isScalarType)(subField) || (0, graphql_1.isEnumType)(subField);
220
244
  }
221
245
  if (i === parts.length - 1 && typeof option[1] === "object") {
222
- if (!isScalarField(part)) {
223
- handleSubtree(option[1], tree);
246
+ if (!scalarFieldAtLeaf(parts)) {
247
+ handleSubtree(option[1], tree, parts);
224
248
  }
225
249
  }
226
250
  }
@@ -302,13 +326,18 @@ async function expectFromRoot(config, ...options) {
302
326
  let fieldArgs = field.args;
303
327
  let queryParams = [];
304
328
  fieldArgs.forEach((fieldArg) => {
305
- let arg = config.args[fieldArg.name];
329
+ const arg = config.args[fieldArg.name];
306
330
  // let the graphql runtime handle this (it may be optional for example)
307
331
  if (arg === undefined) {
308
332
  return;
309
333
  }
310
334
  queryParams.push(`$${fieldArg.name}: ${fieldArg.type}`);
311
335
  });
336
+ // add extra variables in queryArgs...
337
+ for (const key in config.extraVariables) {
338
+ const v = config.extraVariables[key];
339
+ queryParams.push(`$${key}: ${v.graphqlType}`);
340
+ }
312
341
  let params = [];
313
342
  for (let key in config.args) {
314
343
  params.push(`${key}: $${key}`);
@@ -347,7 +376,7 @@ async function expectFromRoot(config, ...options) {
347
376
  let [st, temp] = makeGraphQLRequest(config, q, fieldArgs);
348
377
  const res = await temp.expect("Content-Type", /json/);
349
378
  if (config.debugMode) {
350
- console.log(res.body);
379
+ console.log((0, util_1.inspect)(res.body, false, 3));
351
380
  }
352
381
  // if there's a callback, let everything be done there and we're done
353
382
  if (config.callback) {
@@ -32,5 +32,5 @@ class FakeComms {
32
32
  this.sent = [];
33
33
  }
34
34
  }
35
- exports.FakeComms = FakeComms;
36
35
  FakeComms.sent = [];
36
+ exports.FakeComms = FakeComms;
@@ -18,7 +18,8 @@ export declare enum EdgeType {
18
18
  export declare enum NodeType {
19
19
  FakeUser = "user",
20
20
  FakeContact = "contact",
21
- FakeEvent = "event"
21
+ FakeEvent = "event",
22
+ FakeTag = "tag"
22
23
  }
23
24
  export declare const SymmetricEdges: Set<string>;
24
25
  export declare const InverseEdges: Map<EdgeType, EdgeType>;
@@ -27,6 +27,7 @@ var NodeType;
27
27
  NodeType["FakeUser"] = "user";
28
28
  NodeType["FakeContact"] = "contact";
29
29
  NodeType["FakeEvent"] = "event";
30
+ NodeType["FakeTag"] = "tag";
30
31
  })(NodeType = exports.NodeType || (exports.NodeType = {}));
31
32
  exports.SymmetricEdges = new Set();
32
33
  exports.SymmetricEdges.add(EdgeType.UserToFriends);
@@ -48,6 +49,8 @@ function getLoaderOptions(type) {
48
49
  return internal_1.FakeUser.loaderOptions();
49
50
  case NodeType.FakeEvent:
50
51
  return internal_1.FakeEvent.loaderOptions();
52
+ case NodeType.FakeTag:
53
+ return internal_1.FakeTag.loaderOptions();
51
54
  }
52
55
  }
53
56
  exports.getLoaderOptions = getLoaderOptions;
@@ -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";
@@ -15,11 +15,13 @@ export declare class FakeContact implements Ent {
15
15
  readonly userID: ID;
16
16
  getPrivacyPolicy(): PrivacyPolicy<this>;
17
17
  constructor(viewer: Viewer, data: Data);
18
+ __setRawDBData(data: Data): void;
18
19
  static getFields(): string[];
19
- static getTestTable(): import("../db/test_db").Table;
20
+ static getTestTable(): import("../db/temp_db").Table;
20
21
  static loaderOptions(): LoadEntOptions<FakeContact>;
21
22
  static load(v: Viewer, id: ID): Promise<FakeContact | null>;
22
23
  static loadX(v: Viewer, id: ID): Promise<FakeContact>;
24
+ static loadRawData(id: ID, context?: Context): Promise<Data | null>;
23
25
  }
24
26
  export declare const FakeContactSchema: import("../builder").BuilderSchema<FakeContact>;
25
27
  export interface ContactCreateInput {
@@ -27,7 +29,9 @@ export interface ContactCreateInput {
27
29
  lastName: string;
28
30
  emailAddress: string;
29
31
  userID: ID;
32
+ createdAt?: Date;
33
+ updatedAt?: Date;
30
34
  }
31
35
  export declare function getContactBuilder(viewer: Viewer, input: ContactCreateInput): SimpleBuilder<FakeContact, null>;
32
36
  export declare function createContact(viewer: Viewer, input: ContactCreateInput): Promise<void>;
33
- export declare const contactLoader: ObjectLoaderFactory<unknown>;
37
+ export declare const contactLoader: ObjectLoaderFactory<Data>;
@@ -6,11 +6,16 @@ const privacy_1 = require("../../core/privacy");
6
6
  const builder_1 = require("../builder");
7
7
  const schema_1 = require("../../schema");
8
8
  const const_1 = require("./const");
9
- const test_db_1 = require("../db/test_db");
9
+ const temp_db_1 = require("../db/temp_db");
10
10
  const loaders_1 = require("../../core/loaders");
11
11
  const convert_1 = require("../../core/convert");
12
12
  const action_1 = require("../../action");
13
13
  class FakeContact {
14
+ getPrivacyPolicy() {
15
+ return {
16
+ rules: [new privacy_1.AllowIfViewerIsRule("userID"), privacy_1.AlwaysDenyRule],
17
+ };
18
+ }
14
19
  constructor(viewer, data) {
15
20
  this.viewer = viewer;
16
21
  this.nodeType = const_1.NodeType.FakeContact;
@@ -23,11 +28,7 @@ class FakeContact {
23
28
  this.emailAddress = data.email_address;
24
29
  this.userID = data.user_id;
25
30
  }
26
- getPrivacyPolicy() {
27
- return {
28
- rules: [new privacy_1.AllowIfViewerIsRule("userID"), privacy_1.AlwaysDenyRule],
29
- };
30
- }
31
+ __setRawDBData(data) { }
31
32
  static getFields() {
32
33
  return [
33
34
  "id",
@@ -40,7 +41,7 @@ class FakeContact {
40
41
  ];
41
42
  }
42
43
  static getTestTable() {
43
- return (0, test_db_1.table)("fake_contacts", (0, test_db_1.uuid)("id", { primaryKey: true }), (0, test_db_1.timestamptz)("created_at"), (0, test_db_1.timestamptz)("updated_at"), (0, test_db_1.text)("first_name"), (0, test_db_1.text)("last_name"), (0, test_db_1.text)("email_address"), (0, test_db_1.uuid)("user_id"));
44
+ return (0, temp_db_1.table)("fake_contacts", (0, temp_db_1.uuid)("id", { primaryKey: true }), (0, temp_db_1.timestamptz)("created_at"), (0, temp_db_1.timestamptz)("updated_at"), (0, temp_db_1.text)("first_name"), (0, temp_db_1.text)("last_name"), (0, temp_db_1.text)("email_address"), (0, temp_db_1.uuid)("user_id"));
44
45
  }
45
46
  static loaderOptions() {
46
47
  return {
@@ -60,6 +61,11 @@ class FakeContact {
60
61
  static async loadX(v, id) {
61
62
  return (0, ent_1.loadEntX)(v, id, FakeContact.loaderOptions());
62
63
  }
64
+ static async loadRawData(id, context) {
65
+ return FakeContact.loaderOptions()
66
+ .loaderFactory.createLoader(context)
67
+ .load(id);
68
+ }
63
69
  }
64
70
  exports.FakeContact = FakeContact;
65
71
  exports.FakeContactSchema = (0, builder_1.getBuilderSchemaFromFields)({
@@ -16,14 +16,17 @@ export declare class FakeEvent implements Ent {
16
16
  readonly userID: ID;
17
17
  getPrivacyPolicy(): PrivacyPolicy<this>;
18
18
  constructor(viewer: Viewer, data: Data);
19
+ __setRawDBData(data: Data): void;
19
20
  private static getFields;
20
- static getTestTable(): import("../db/test_db").Table;
21
+ static getTestTable(): import("../db/temp_db").Table;
21
22
  static loaderOptions(): LoadEntOptions<FakeEvent>;
22
23
  static load(v: Viewer, id: ID): Promise<FakeEvent | null>;
23
24
  static loadX(v: Viewer, id: ID): Promise<FakeEvent>;
24
25
  }
25
26
  export declare const FakeEventSchema: import("../builder").BuilderSchema<FakeEvent>;
26
27
  export interface EventCreateInput {
28
+ createdAt?: Date;
29
+ updatedAt?: Date;
27
30
  startTime: Date;
28
31
  endTime?: Date | null;
29
32
  location: string;
@@ -6,11 +6,14 @@ const privacy_1 = require("../../core/privacy");
6
6
  const builder_1 = require("../builder");
7
7
  const schema_1 = require("../../schema");
8
8
  const const_1 = require("./const");
9
- const test_db_1 = require("../db/test_db");
9
+ const temp_db_1 = require("../db/temp_db");
10
10
  const loaders_1 = require("../../core/loaders");
11
11
  const convert_1 = require("../../core/convert");
12
12
  const action_1 = require("../../action");
13
13
  class FakeEvent {
14
+ getPrivacyPolicy() {
15
+ return privacy_1.AlwaysAllowPrivacyPolicy;
16
+ }
14
17
  constructor(viewer, data) {
15
18
  this.viewer = viewer;
16
19
  this.nodeType = const_1.NodeType.FakeEvent;
@@ -25,9 +28,7 @@ class FakeEvent {
25
28
  this.description = data.description;
26
29
  this.userID = data.user_id;
27
30
  }
28
- getPrivacyPolicy() {
29
- return privacy_1.AlwaysAllowPrivacyPolicy;
30
- }
31
+ __setRawDBData(data) { }
31
32
  static getFields() {
32
33
  return [
33
34
  "id",
@@ -42,9 +43,9 @@ class FakeEvent {
42
43
  ];
43
44
  }
44
45
  static getTestTable() {
45
- return (0, test_db_1.table)("fake_events", (0, test_db_1.uuid)("id", { primaryKey: true }), (0, test_db_1.timestamptz)("created_at"), (0, test_db_1.timestamptz)("updated_at"),
46
+ return (0, temp_db_1.table)("fake_events", (0, temp_db_1.uuid)("id", { primaryKey: true }), (0, temp_db_1.timestamptz)("created_at"), (0, temp_db_1.timestamptz)("updated_at"),
46
47
  // TODO index:true
47
- (0, test_db_1.timestamptz)("start_time"), (0, test_db_1.timestamptz)("end_time", { nullable: true }), (0, test_db_1.text)("location"), (0, test_db_1.text)("title"), (0, test_db_1.text)("description", { nullable: true }), (0, test_db_1.uuid)("user_id"));
48
+ (0, temp_db_1.timestamptz)("start_time"), (0, temp_db_1.timestamptz)("end_time", { nullable: true }), (0, temp_db_1.text)("location"), (0, temp_db_1.text)("title"), (0, temp_db_1.text)("description", { nullable: true }), (0, temp_db_1.uuid)("user_id"));
48
49
  }
49
50
  static loaderOptions() {
50
51
  return {
@@ -0,0 +1,36 @@
1
+ import { ID, Ent, Viewer, Data, LoadEntOptions, PrivacyPolicy } from "../../core/base";
2
+ import { SimpleAction } from "../builder";
3
+ import { NodeType } from "./const";
4
+ import { ObjectLoaderFactory } from "../../core/loaders";
5
+ export declare class FakeTag implements Ent {
6
+ viewer: Viewer;
7
+ readonly id: ID;
8
+ readonly data: Data;
9
+ readonly nodeType = NodeType.FakeUser;
10
+ readonly createdAt: Date;
11
+ readonly updatedAt: Date;
12
+ readonly displayName: string;
13
+ readonly canonicalName: string;
14
+ readonly ownerID: string;
15
+ getPrivacyPolicy(): PrivacyPolicy<this>;
16
+ constructor(viewer: Viewer, data: Data);
17
+ __setRawDBData(data: Data): void;
18
+ static getFields(): string[];
19
+ static getTestTable(): import("../db/temp_db").Table;
20
+ static loaderOptions(): LoadEntOptions<FakeTag>;
21
+ static load(v: Viewer, id: ID): Promise<FakeTag | null>;
22
+ static loadX(v: Viewer, id: ID): Promise<FakeTag>;
23
+ }
24
+ export declare const FakeTagSchema: import("../builder").BuilderSchema<FakeTag>;
25
+ export interface TagCreateInput {
26
+ displayName: string;
27
+ canonicalName: string;
28
+ ownerID: ID;
29
+ createdAt?: Date;
30
+ updatedAt?: Date;
31
+ }
32
+ export type TagEditInput = Partial<TagCreateInput>;
33
+ export declare function getTagBuilder(viewer: Viewer, input: TagCreateInput): import("../builder").SimpleBuilder<FakeTag, null>;
34
+ export declare function getTagAction(viewer: Viewer, input: TagCreateInput): SimpleAction<FakeTag, null>;
35
+ export declare function createTag(viewer: Viewer, input: TagCreateInput): Promise<FakeTag>;
36
+ export declare const tagLoader: ObjectLoaderFactory<Data>;