@snowtop/ent 0.0.24 → 0.0.28

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,4 +1,4 @@
1
- import { ID, Ent, Viewer, EntConstructor, Context } from "../core/base";
1
+ import { ID, Data, Ent, Viewer, EntConstructor, Context } from "../core/base";
2
2
  import { DataOperation } from "../core/ent";
3
3
  import { Changeset, Executor } from "../action";
4
4
  import { Builder } from "../action";
@@ -11,7 +11,7 @@ export declare class ListBasedExecutor<T extends Ent> implements Executor {
11
11
  private operations;
12
12
  private options?;
13
13
  private idx;
14
- constructor(viewer: Viewer, placeholderID: ID, ent: EntConstructor<T>, operations: DataOperation[], options?: OrchestratorOptions<T> | undefined);
14
+ constructor(viewer: Viewer, placeholderID: ID, ent: EntConstructor<T>, operations: DataOperation[], options?: OrchestratorOptions<T, Data> | undefined);
15
15
  private lastOp;
16
16
  private createdEnt;
17
17
  resolveValue(val: ID): Ent | null;
@@ -34,7 +34,7 @@ export declare class ComplexExecutor<T extends Ent> implements Executor {
34
34
  private changesetMap;
35
35
  private nodeOpMap;
36
36
  private executors;
37
- constructor(viewer: Viewer, placeholderID: ID, ent: EntConstructor<T>, operations: DataOperation[], dependencies: Map<ID, Builder<T>>, changesets: Changeset<T>[], options?: OrchestratorOptions<T> | undefined);
37
+ constructor(viewer: Viewer, placeholderID: ID, ent: EntConstructor<T>, operations: DataOperation[], dependencies: Map<ID, Builder<T>>, changesets: Changeset<T>[], options?: OrchestratorOptions<T, Data> | undefined);
38
38
  [Symbol.iterator](): this;
39
39
  private handleCreatedEnt;
40
40
  next(): IteratorResult<DataOperation>;
@@ -3,7 +3,7 @@ import { AssocEdgeInputOptions, DataOperation } from "../core/ent";
3
3
  import { SchemaInputType } from "../schema/schema";
4
4
  import { Changeset, Executor } from "../action";
5
5
  import { WriteOperation, Builder, Action } from "../action";
6
- export interface OrchestratorOptions<T extends Ent> {
6
+ export interface OrchestratorOptions<T extends Ent, TData extends Data> {
7
7
  viewer: Viewer;
8
8
  operation: WriteOperation;
9
9
  tableName: string;
@@ -13,6 +13,7 @@ export interface OrchestratorOptions<T extends Ent> {
13
13
  action?: Action<T>;
14
14
  schema: SchemaInputType;
15
15
  editedFields(): Map<string, any>;
16
+ updateInput?: (data: TData) => void;
16
17
  }
17
18
  interface edgeInputDataOpts {
18
19
  edgeType: string;
@@ -38,7 +39,9 @@ export declare class Orchestrator<T extends Ent> {
38
39
  private fieldsToResolve;
39
40
  private mainOp;
40
41
  viewer: Viewer;
41
- constructor(options: OrchestratorOptions<T>);
42
+ private defaultFieldsByFieldName;
43
+ private defaultFieldsByTSName;
44
+ constructor(options: OrchestratorOptions<T, Data>);
42
45
  private addEdge;
43
46
  addInboundEdge<T2 extends Ent>(id1: ID | Builder<T2>, edgeType: string, nodeType: string, options?: AssocEdgeInputOptions): void;
44
47
  addOutboundEdge<T2 extends Ent>(id2: ID | Builder<T2>, edgeType: string, nodeType: string, options?: AssocEdgeInputOptions): void;
@@ -50,11 +53,13 @@ export declare class Orchestrator<T extends Ent> {
50
53
  private getEdgeOperation;
51
54
  private buildEdgeOps;
52
55
  private throwError;
56
+ private getEntForPrivacyPolicy;
53
57
  private validate;
54
58
  private triggers;
55
59
  private validators;
56
60
  private isBuilder;
57
- private validateFields;
61
+ private getFieldsWithDefaultValues;
62
+ private formatAndValidateFields;
58
63
  valid(): Promise<boolean>;
59
64
  validX(): Promise<void>;
60
65
  build(): Promise<EntChangeset<T>>;
@@ -71,7 +76,7 @@ export declare class EntChangeset<T extends Ent> implements Changeset<T> {
71
76
  dependencies?: Map<ID, Builder<T>> | undefined;
72
77
  changesets?: Changeset<Ent>[] | undefined;
73
78
  private options?;
74
- constructor(viewer: Viewer, placeholderID: ID, ent: EntConstructor<T>, operations: DataOperation[], dependencies?: Map<ID, Builder<T>> | undefined, changesets?: Changeset<Ent>[] | undefined, options?: OrchestratorOptions<T> | undefined);
79
+ constructor(viewer: Viewer, placeholderID: ID, ent: EntConstructor<T>, operations: DataOperation[], dependencies?: Map<ID, Builder<T>> | undefined, changesets?: Changeset<Ent>[] | undefined, options?: OrchestratorOptions<T, Data> | undefined);
75
80
  executor(): Executor;
76
81
  }
77
82
  export {};
@@ -5,6 +5,7 @@ const ent_1 = require("../core/ent");
5
5
  const schema_1 = require("../schema/schema");
6
6
  const action_1 = require("../action");
7
7
  const snake_case_1 = require("snake-case");
8
+ const camel_case_1 = require("camel-case");
8
9
  const privacy_1 = require("../core/privacy");
9
10
  const executor_1 = require("./executor");
10
11
  const logger_1 = require("../core/logger");
@@ -58,6 +59,8 @@ class Orchestrator {
58
59
  this.changesets = [];
59
60
  this.dependencies = new Map();
60
61
  this.fieldsToResolve = [];
62
+ this.defaultFieldsByFieldName = {};
63
+ this.defaultFieldsByTSName = {};
61
64
  this.viewer = options.viewer;
62
65
  }
63
66
  addEdge(edge, op) {
@@ -222,16 +225,35 @@ class Orchestrator {
222
225
  }
223
226
  return new EntCannotDeleteEntError(privacyPolicy, action, this.options.builder.existingEnt);
224
227
  }
228
+ getEntForPrivacyPolicy(editedData) {
229
+ if (this.options.operation !== action_1.WriteOperation.Insert) {
230
+ return this.options.builder.existingEnt;
231
+ }
232
+ // we create an unsafe ent to be used for privacy policies
233
+ return new this.options.builder.ent(this.options.builder.viewer, editedData);
234
+ }
225
235
  async validate() {
236
+ // existing ent required for edit or delete operations
237
+ switch (this.options.operation) {
238
+ case action_1.WriteOperation.Delete:
239
+ case action_1.WriteOperation.Edit:
240
+ if (!this.options.builder.existingEnt) {
241
+ throw new Error("existing ent required with operation");
242
+ }
243
+ }
226
244
  const action = this.options.action;
227
245
  const builder = this.options.builder;
228
- // this runs in 3 phases:
229
- // * privacy policy
246
+ // future optimization: can get schemaFields to memoize based on different values
247
+ const schemaFields = (0, schema_1.getFields)(this.options.schema);
248
+ let editedData = this.getFieldsWithDefaultValues(builder, schemaFields, action);
249
+ // this runs in following phases:
250
+ // * set default fields and pass to builder so the value can be checked by triggers/observers/validators
251
+ // * privacy policy (use unsafe ent if we have it)
230
252
  // * triggers
231
253
  // * validators
232
254
  let privacyPolicy = action?.getPrivacyPolicy();
233
255
  if (privacyPolicy) {
234
- await (0, privacy_1.applyPrivacyPolicyX)(this.options.viewer, privacyPolicy, builder.existingEnt, this.throwError.bind(this));
256
+ await (0, privacy_1.applyPrivacyPolicyX)(this.options.viewer, privacyPolicy, this.getEntForPrivacyPolicy(editedData), this.throwError.bind(this));
235
257
  }
236
258
  // have to run triggers which update fields first before field and other validators
237
259
  // so running this first to build things up
@@ -241,7 +263,7 @@ class Orchestrator {
241
263
  }
242
264
  let validators = action?.validators || [];
243
265
  await Promise.all([
244
- this.validateFields(builder, action),
266
+ this.formatAndValidateFields(schemaFields),
245
267
  this.validators(validators, action, builder),
246
268
  ]);
247
269
  }
@@ -276,29 +298,14 @@ class Orchestrator {
276
298
  isBuilder(val) {
277
299
  return val.placeholderID !== undefined;
278
300
  }
279
- async validateFields(builder, action) {
280
- // existing ent required for edit or delete operations
281
- switch (this.options.operation) {
282
- case action_1.WriteOperation.Delete:
283
- case action_1.WriteOperation.Edit:
284
- if (!this.options.builder.existingEnt) {
285
- throw new Error("existing ent required with operation");
286
- }
287
- }
288
- if (this.options.operation == action_1.WriteOperation.Delete) {
289
- return;
290
- }
301
+ getFieldsWithDefaultValues(builder, schemaFields, action) {
291
302
  const editedFields = this.options.editedFields();
292
- // build up data to be saved...
293
303
  let data = {};
294
- let logValues = {};
295
- const schemaFields = (0, schema_1.getFields)(this.options.schema);
296
- let input = {};
297
- if (action !== undefined) {
298
- input = action.getInput();
299
- }
304
+ let input = action?.getInput() || {};
305
+ let updateInput = false;
300
306
  for (const [fieldName, field] of schemaFields) {
301
307
  let value = editedFields.get(fieldName);
308
+ let defaultValue = undefined;
302
309
  let dbKey = field.storageKey || (0, snake_case_1.snakeCase)(field.name);
303
310
  if (value === undefined) {
304
311
  if (this.options.operation === action_1.WriteOperation.Insert) {
@@ -306,21 +313,52 @@ class Orchestrator {
306
313
  throw new Error(`cannot set both defaultToViewerOnCreate and defaultValueOnCreate`);
307
314
  }
308
315
  if (field.defaultToViewerOnCreate) {
309
- value = builder.viewer.viewerID;
316
+ defaultValue = builder.viewer.viewerID;
310
317
  }
311
318
  if (field.defaultValueOnCreate) {
312
- value = field.defaultValueOnCreate(builder, input);
313
- if (value === undefined) {
319
+ defaultValue = field.defaultValueOnCreate(builder, input);
320
+ if (defaultValue === undefined) {
314
321
  throw new Error(`defaultValueOnCreate() returned undefined for field ${field.name}`);
315
322
  }
316
323
  }
317
324
  }
318
325
  if (field.defaultValueOnEdit &&
319
326
  this.options.operation === action_1.WriteOperation.Edit) {
320
- value = field.defaultValueOnEdit(builder, input);
321
- // TODO special case this if this is the onlything changing and don't do the write.
327
+ defaultValue = field.defaultValueOnEdit(builder, input);
328
+ // TODO special case this if this is the only thing changing and don't do the write.
322
329
  }
323
330
  }
331
+ data[dbKey] = value;
332
+ if (defaultValue !== undefined) {
333
+ updateInput = true;
334
+ data[dbKey] = defaultValue;
335
+ this.defaultFieldsByFieldName[fieldName] = defaultValue;
336
+ // TODO related to #510. we need this logic to be consistent so do this all in TypeScript or get it from go somehow
337
+ this.defaultFieldsByTSName[(0, camel_case_1.camelCase)(fieldName)] = defaultValue;
338
+ }
339
+ }
340
+ if (updateInput && this.options.updateInput) {
341
+ // this basically fixes #605. just needs to be exposed correctly
342
+ this.options.updateInput(this.defaultFieldsByTSName);
343
+ }
344
+ return data;
345
+ }
346
+ async formatAndValidateFields(schemaFields) {
347
+ if (this.options.operation == action_1.WriteOperation.Delete) {
348
+ return;
349
+ }
350
+ const editedFields = this.options.editedFields();
351
+ // build up data to be saved...
352
+ let data = {};
353
+ let logValues = {};
354
+ for (const [fieldName, field] of schemaFields) {
355
+ let value = editedFields.get(fieldName);
356
+ if (value === undefined) {
357
+ // null allowed
358
+ value = this.defaultFieldsByFieldName[fieldName];
359
+ }
360
+ let dbKey = field.storageKey || (0, snake_case_1.snakeCase)(field.name);
361
+ // now format and validate...
324
362
  if (value === null) {
325
363
  if (!field.nullable) {
326
364
  throw new Error(`field ${field.name} set to null for non-nullable field`);
@@ -364,7 +402,6 @@ class Orchestrator {
364
402
  }
365
403
  this.validatedFields = data;
366
404
  this.logValues = logValues;
367
- // console.log(this.validatedFields);
368
405
  }
369
406
  async valid() {
370
407
  try {
package/core/base.js CHANGED
@@ -9,22 +9,25 @@ var privacyResult;
9
9
  privacyResult[privacyResult["Deny"] = 401] = "Deny";
10
10
  privacyResult[privacyResult["Skip"] = 307] = "Skip";
11
11
  })(privacyResult || (privacyResult = {}));
12
+ const allow = {
13
+ result: privacyResult.Allow,
14
+ };
12
15
  function Allow() {
13
- return {
14
- result: privacyResult.Allow,
15
- };
16
+ return allow;
16
17
  }
17
18
  exports.Allow = Allow;
19
+ const skip = {
20
+ result: privacyResult.Skip,
21
+ };
18
22
  function Skip() {
19
- return {
20
- result: privacyResult.Skip,
21
- };
23
+ return skip;
22
24
  }
23
25
  exports.Skip = Skip;
26
+ const deny = {
27
+ result: privacyResult.Deny,
28
+ };
24
29
  function Deny() {
25
- return {
26
- result: privacyResult.Deny,
27
- };
30
+ return deny;
28
31
  }
29
32
  exports.Deny = Deny;
30
33
  function DenyWithReason(e) {
package/core/convert.js CHANGED
@@ -59,7 +59,8 @@ function convertList(val, conv) {
59
59
  }
60
60
  exports.convertList = convertList;
61
61
  function convertNullableList(val, conv) {
62
- if (val === null) {
62
+ // undefined can happen with unsafe ents
63
+ if (val === null || val === undefined) {
63
64
  return null;
64
65
  }
65
66
  return convertList(val, conv);
package/core/privacy.d.ts CHANGED
@@ -59,6 +59,18 @@ export declare class AllowIfViewerIsEntPropertyRule<T extends Ent> implements Pr
59
59
  constructor(property: keyof T);
60
60
  apply(v: Viewer, ent?: T): Promise<PrivacyResult>;
61
61
  }
62
+ export declare class AllowIfEntPropertyIsRule<T extends Ent> implements PrivacyPolicyRule {
63
+ private property;
64
+ private val;
65
+ constructor(property: keyof T, val: any);
66
+ apply(v: Viewer, ent?: T): Promise<PrivacyResult>;
67
+ }
68
+ export declare class DenyIfEntPropertyIsRule<T extends Ent> implements PrivacyPolicyRule {
69
+ private property;
70
+ private val;
71
+ constructor(property: keyof T, val: any);
72
+ apply(v: Viewer, ent?: T): Promise<PrivacyResult>;
73
+ }
62
74
  export declare class AllowIfEntIsVisibleRule<T extends Ent> implements PrivacyPolicyRule {
63
75
  private id;
64
76
  private options;
package/core/privacy.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AllowIfViewerHasIdentityPrivacyPolicy = exports.AllowIfViewerPrivacyPolicy = exports.AlwaysDenyPrivacyPolicy = exports.AlwaysAllowPrivacyPolicy = exports.applyPrivacyPolicyX = exports.applyPrivacyPolicy = exports.AllowIfSubPolicyAllowsRule = exports.DelayedResultRule = exports.AllowIfConditionAppliesRule = exports.DenyIfViewerOutboundEdgeDoesNotExistRule = exports.DenyIfViewerInboundEdgeDoesNotExistRule = exports.DenyIfEdgeDoesNotExistRule = exports.DenyIfViewerOutboundEdgeExistsRule = exports.DenyIfViewerInboundEdgeExistsRule = exports.DenyIfEdgeExistsRule = exports.AllowIfViewerOutboundEdgeExistsRule = exports.AllowIfViewerInboundEdgeExistsRule = exports.AllowIfEdgeExistsRule = exports.DenyIfEntIsNotVisibleRule = exports.DenyIfEntIsVisibleRule = exports.DenyIfEntIsVisiblePolicy = exports.AllowIfEntIsVisiblePolicy = exports.AllowIfEntIsNotVisibleRule = exports.AllowIfEntIsVisibleRule = exports.AllowIfViewerIsEntPropertyRule = exports.AllowIfViewerIsRule = exports.DenyIfFuncRule = exports.AllowIfFuncRule = exports.DenyIfViewerEqualsRule = exports.AllowIfViewerEqualsRule = exports.AllowIfViewerRule = exports.AllowIfHasIdentity = exports.DenyIfLoggedInRule = exports.DenyIfLoggedOutRule = exports.AlwaysDenyRule = exports.AlwaysAllowRule = exports.EntPrivacyError = void 0;
3
+ exports.AllowIfViewerHasIdentityPrivacyPolicy = exports.AllowIfViewerPrivacyPolicy = exports.AlwaysDenyPrivacyPolicy = exports.AlwaysAllowPrivacyPolicy = exports.applyPrivacyPolicyX = exports.applyPrivacyPolicy = exports.AllowIfSubPolicyAllowsRule = exports.DelayedResultRule = exports.AllowIfConditionAppliesRule = exports.DenyIfViewerOutboundEdgeDoesNotExistRule = exports.DenyIfViewerInboundEdgeDoesNotExistRule = exports.DenyIfEdgeDoesNotExistRule = exports.DenyIfViewerOutboundEdgeExistsRule = exports.DenyIfViewerInboundEdgeExistsRule = exports.DenyIfEdgeExistsRule = exports.AllowIfViewerOutboundEdgeExistsRule = exports.AllowIfViewerInboundEdgeExistsRule = exports.AllowIfEdgeExistsRule = exports.DenyIfEntIsNotVisibleRule = exports.DenyIfEntIsVisibleRule = exports.DenyIfEntIsVisiblePolicy = exports.AllowIfEntIsVisiblePolicy = exports.AllowIfEntIsNotVisibleRule = exports.AllowIfEntIsVisibleRule = exports.DenyIfEntPropertyIsRule = exports.AllowIfEntPropertyIsRule = exports.AllowIfViewerIsEntPropertyRule = exports.AllowIfViewerIsRule = exports.DenyIfFuncRule = exports.AllowIfFuncRule = exports.DenyIfViewerEqualsRule = exports.AllowIfViewerEqualsRule = exports.AllowIfViewerRule = exports.AllowIfHasIdentity = exports.DenyIfLoggedInRule = exports.DenyIfLoggedOutRule = exports.AlwaysDenyRule = exports.AlwaysAllowRule = exports.EntPrivacyError = void 0;
4
4
  const base_1 = require("./base");
5
5
  const ent_1 = require("./ent");
6
6
  const logger_1 = require("./logger");
@@ -156,6 +156,34 @@ class AllowIfViewerIsEntPropertyRule {
156
156
  }
157
157
  }
158
158
  exports.AllowIfViewerIsEntPropertyRule = AllowIfViewerIsEntPropertyRule;
159
+ class AllowIfEntPropertyIsRule {
160
+ constructor(property, val) {
161
+ this.property = property;
162
+ this.val = val;
163
+ }
164
+ async apply(v, ent) {
165
+ const result = ent && ent[this.property];
166
+ if (result === this.val) {
167
+ return (0, base_1.Allow)();
168
+ }
169
+ return (0, base_1.Skip)();
170
+ }
171
+ }
172
+ exports.AllowIfEntPropertyIsRule = AllowIfEntPropertyIsRule;
173
+ class DenyIfEntPropertyIsRule {
174
+ constructor(property, val) {
175
+ this.property = property;
176
+ this.val = val;
177
+ }
178
+ async apply(v, ent) {
179
+ const result = ent && ent[this.property];
180
+ if (result === this.val) {
181
+ return (0, base_1.Deny)();
182
+ }
183
+ return (0, base_1.Skip)();
184
+ }
185
+ }
186
+ exports.DenyIfEntPropertyIsRule = DenyIfEntPropertyIsRule;
159
187
  class AllowIfEntIsVisibleRule {
160
188
  constructor(id, options) {
161
189
  this.id = id;
@@ -3,16 +3,17 @@ import { AssocEdge } from "../ent";
3
3
  import { AssocEdgeCountLoaderFactory } from "../loaders/assoc_count_loader";
4
4
  import { AssocEdgeLoaderFactory } from "../loaders/assoc_edge_loader";
5
5
  import { EdgeQuery, BaseEdgeQuery, IDInfo } from "./query";
6
- export declare type EdgeQuerySource<T extends Ent> = T | T[] | ID | ID[] | EdgeQuery<T, Ent, AssocEdge>;
6
+ export declare type EdgeQuerySource<TSource extends Ent, TDest extends Ent = Ent> = TSource | TSource[] | ID | ID[] | EdgeQuery<TDest, Ent, AssocEdge>;
7
7
  declare type loaderOptionsFunc = (type: string) => LoadEntOptions<Ent>;
8
- export declare class AssocEdgeQueryBase<TSource extends Ent, TDest extends Ent, TEdge extends AssocEdge> extends BaseEdgeQuery<TSource, TDest, TEdge> {
8
+ export declare abstract class AssocEdgeQueryBase<TSource extends Ent, TDest extends Ent, TEdge extends AssocEdge> extends BaseEdgeQuery<TSource, TDest, TEdge> implements EdgeQuery<TSource, TDest, TEdge> {
9
9
  viewer: Viewer;
10
- src: EdgeQuerySource<TSource>;
10
+ src: EdgeQuerySource<TSource, TDest>;
11
11
  private countLoaderFactory;
12
12
  private dataLoaderFactory;
13
13
  private options;
14
- constructor(viewer: Viewer, src: EdgeQuerySource<TSource>, countLoaderFactory: AssocEdgeCountLoaderFactory, dataLoaderFactory: AssocEdgeLoaderFactory<TEdge>, options: LoadEntOptions<TDest> | loaderOptionsFunc);
14
+ constructor(viewer: Viewer, src: EdgeQuerySource<TSource, TDest>, countLoaderFactory: AssocEdgeCountLoaderFactory, dataLoaderFactory: AssocEdgeLoaderFactory<TEdge>, options: LoadEntOptions<TDest> | loaderOptionsFunc);
15
15
  private isEdgeQuery;
16
+ abstract sourceEnt(id: ID): Promise<Ent | null>;
16
17
  private getSingleID;
17
18
  queryRawCount(): Promise<number>;
18
19
  queryAllRawCount(): Promise<Map<ID, number>>;
@@ -1,5 +1,5 @@
1
1
  import { Data, Ent, ID, EdgeQueryableDataOptions, LoadEntOptions, Viewer, LoaderFactory, ConfigurableLoaderFactory } from "../base";
2
- import { BaseEdgeQuery, IDInfo } from "./query";
2
+ import { BaseEdgeQuery, IDInfo, EdgeQuery } from "./query";
3
3
  export interface CustomEdgeQueryOptions<TSource extends Ent, TDest extends Ent> {
4
4
  src: TSource | ID;
5
5
  countLoaderFactory: LoaderFactory<ID, number>;
@@ -7,11 +7,12 @@ export interface CustomEdgeQueryOptions<TSource extends Ent, TDest extends Ent>
7
7
  options: LoadEntOptions<TDest>;
8
8
  sortColumn?: string;
9
9
  }
10
- export declare class CustomEdgeQueryBase<TSource extends Ent, TDest extends Ent> extends BaseEdgeQuery<TSource, TDest, Data> {
10
+ export declare abstract class CustomEdgeQueryBase<TSource extends Ent, TDest extends Ent> extends BaseEdgeQuery<TSource, TDest, Data> implements EdgeQuery<TSource, TDest, Data> {
11
11
  viewer: Viewer;
12
12
  private options;
13
13
  private id;
14
14
  constructor(viewer: Viewer, options: CustomEdgeQueryOptions<TSource, TDest>);
15
+ abstract sourceEnt(id: ID): Promise<Ent | null>;
15
16
  private idVisible;
16
17
  queryRawCount(): Promise<number>;
17
18
  queryAllRawCount(): Promise<Map<ID, number>>;
@@ -16,7 +16,7 @@ export interface EdgeQuery<TSource extends Ent, TDest extends Ent, TEdge extends
16
16
  getCursor(row: TEdge): string;
17
17
  dataToID(edge: TEdge): ID;
18
18
  getPrivacyPolicy(): PrivacyPolicy;
19
- entForPrivacy?(id: ID): Promise<TSource | null>;
19
+ sourceEnt(id: ID): Promise<Ent | null>;
20
20
  }
21
21
  export interface EdgeQueryFilter<T extends Data> {
22
22
  filter?(id: ID, edges: T[]): T[];
@@ -42,6 +42,7 @@ export declare abstract class BaseEdgeQuery<TSource extends Ent, TDest extends E
42
42
  private idsToFetch;
43
43
  constructor(viewer: Viewer, sortCol: string);
44
44
  getPrivacyPolicy(): PrivacyPolicy;
45
+ abstract sourceEnt(id: ID): Promise<Ent | null>;
45
46
  first(n: number, after?: string): this;
46
47
  last(n: number, before?: string): this;
47
48
  private querySingleEdge;
@@ -350,8 +350,8 @@ async function applyPrivacyPolicyForEdgeQ(viewer, edgeQ, ids, map) {
350
350
  const result = [];
351
351
  await Promise.all(ids.map(async (id) => {
352
352
  let ent = map.get(id);
353
- if (!ent && edgeQ.entForPrivacy) {
354
- ent = await edgeQ.entForPrivacy(id);
353
+ if (!ent) {
354
+ ent = await edgeQ.sourceEnt(id);
355
355
  }
356
356
  const r = await (0, privacy_1.applyPrivacyPolicy)(viewer, edgeQ.getPrivacyPolicy(), ent || undefined);
357
357
  result.push({
@@ -5,6 +5,7 @@ const graphql_1 = require("graphql");
5
5
  const node_1 = require("./node");
6
6
  const edge_1 = require("./edge");
7
7
  const page_info_1 = require("../query/page_info");
8
+ // NB: if this changes, need to update renderer.go also
8
9
  exports.GraphQLConnectionInterface = new graphql_1.GraphQLInterfaceType({
9
10
  name: "Connection",
10
11
  description: "connection interface",
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GraphQLEdgeInterface = void 0;
4
4
  const graphql_1 = require("graphql");
5
5
  const node_1 = require("./node");
6
+ // NB: if this changes, need to update renderer.go also
6
7
  exports.GraphQLEdgeInterface = new graphql_1.GraphQLInterfaceType({
7
8
  name: "Edge",
8
9
  description: "edge interface",
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GraphQLNodeInterface = void 0;
4
4
  const graphql_1 = require("graphql");
5
+ // NB: if this changes, need to update renderer.go also
5
6
  exports.GraphQLNodeInterface = new graphql_1.GraphQLInterfaceType({
6
7
  name: "Node",
7
8
  description: "node interface",
@@ -8,6 +8,7 @@ export interface CustomType {
8
8
  importPath: string;
9
9
  tsType?: string;
10
10
  tsImportPath?: string;
11
+ [x: string]: any;
11
12
  }
12
13
  declare type Type = GraphQLScalarType | ClassType | string | CustomType;
13
14
  export declare type GraphQLConnection<T> = {
@@ -81,6 +82,7 @@ declare enum NullableResult {
81
82
  CONTENTS_AND_LIST = "contentsAndList",
82
83
  ITEM = "true"
83
84
  }
85
+ export declare const addCustomType: (type: CustomType) => void;
84
86
  export declare class GQLCapture {
85
87
  private static enabled;
86
88
  static enable(enabled: boolean): void;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.gqlFileUpload = exports.gqlConnection = exports.gqlContextType = exports.gqlMutation = exports.gqlQuery = exports.gqlObjectType = exports.gqlInputObjectType = exports.gqlArgType = exports.gqlArg = exports.gqlField = exports.GQLCapture = exports.CustomFieldType = void 0;
3
+ exports.gqlFileUpload = exports.gqlConnection = exports.gqlContextType = exports.gqlMutation = exports.gqlQuery = exports.gqlObjectType = exports.gqlInputObjectType = exports.gqlArgType = exports.gqlArg = exports.gqlField = exports.GQLCapture = exports.addCustomType = exports.CustomFieldType = void 0;
4
4
  require("reflect-metadata");
5
5
  // export interface gqlTopLevelOptions
6
6
  // name?: string;
@@ -20,6 +20,88 @@ var NullableResult;
20
20
  NullableResult["CONTENTS_AND_LIST"] = "contentsAndList";
21
21
  NullableResult["ITEM"] = "true";
22
22
  })(NullableResult || (NullableResult = {}));
23
+ const isArray = (type) => {
24
+ if (typeof type === "function") {
25
+ return false;
26
+ }
27
+ return type.push !== undefined;
28
+ };
29
+ const isConnection = (type) => {
30
+ if (typeof type !== "object") {
31
+ return false;
32
+ }
33
+ return type.node !== undefined;
34
+ };
35
+ const isString = (type) => {
36
+ if (type.lastIndexOf !== undefined) {
37
+ return true;
38
+ }
39
+ return false;
40
+ };
41
+ const isCustomType = (type) => {
42
+ return type.importPath !== undefined;
43
+ };
44
+ const isGraphQLScalarType = (type) => {
45
+ return type.serialize !== undefined;
46
+ };
47
+ const addCustomType = (type) => {
48
+ // TODO these should return ReadOnly objects...
49
+ const customType = GQLCapture.getCustomTypes().get(type.type);
50
+ if (customType && customType !== type) {
51
+ throw new Error(`cannot add multiple custom types of name ${type.type}`);
52
+ }
53
+ if (customType) {
54
+ return;
55
+ }
56
+ try {
57
+ const r = require(type.importPath);
58
+ const ct = r[type.type];
59
+ // this gets us the information needed for scalars
60
+ if (ct && isGraphQLScalarType(ct)) {
61
+ type.scalarInfo = {
62
+ description: ct.description,
63
+ name: ct.name,
64
+ };
65
+ if (ct.specifiedByUrl) {
66
+ type.scalarInfo.specifiedByUrl = ct.specifiedByUrl;
67
+ }
68
+ }
69
+ }
70
+ catch (e) {
71
+ return;
72
+ }
73
+ GQLCapture.getCustomTypes().set(type.type, type);
74
+ };
75
+ exports.addCustomType = addCustomType;
76
+ const getType = (typ, result) => {
77
+ if (isConnection(typ)) {
78
+ result.connection = true;
79
+ return getType(typ.node, result);
80
+ }
81
+ if (isArray(typ)) {
82
+ result.list = true;
83
+ return getType(typ[0], result);
84
+ }
85
+ if (isString(typ)) {
86
+ if (typ.lastIndexOf("]") !== -1) {
87
+ result.list = true;
88
+ result.type = typ.substr(1, typ.length - 2);
89
+ }
90
+ else {
91
+ result.type = typ;
92
+ }
93
+ return;
94
+ }
95
+ if (isCustomType(typ)) {
96
+ result.type = typ.type;
97
+ (0, exports.addCustomType)(typ);
98
+ return;
99
+ }
100
+ // GraphQLScalarType or ClassType
101
+ result.scalarType = isGraphQLScalarType(typ);
102
+ result.type = typ.name;
103
+ return;
104
+ };
23
105
  class GQLCapture {
24
106
  static enable(enabled) {
25
107
  this.enabled = enabled;
@@ -104,66 +186,6 @@ class GQLCapture {
104
186
  if ((type === "Number" || type === "Object") && !options?.type) {
105
187
  throw new Error(`type is required when accessor/function/property returns a ${type}`);
106
188
  }
107
- const isArray = (type) => {
108
- if (typeof type === "function") {
109
- return false;
110
- }
111
- return type.push !== undefined;
112
- };
113
- const isConnection = (type) => {
114
- if (typeof type !== "object") {
115
- return false;
116
- }
117
- return type.node !== undefined;
118
- };
119
- const isString = (type) => {
120
- if (type.lastIndexOf !== undefined) {
121
- return true;
122
- }
123
- return false;
124
- };
125
- const isCustomType = (type) => {
126
- return type.importPath !== undefined;
127
- };
128
- const isGraphQLScalarType = (type) => {
129
- return type.serialize !== undefined;
130
- };
131
- const addCustomType = (type) => {
132
- const customType = this.customTypes.get(type.type);
133
- if (customType && customType !== type) {
134
- throw new Error(`cannot add multiple custom types of name ${type.type}`);
135
- }
136
- this.customTypes.set(type.type, type);
137
- };
138
- const getType = (typ, result) => {
139
- if (isConnection(typ)) {
140
- result.connection = true;
141
- return getType(typ.node, result);
142
- }
143
- if (isArray(typ)) {
144
- result.list = true;
145
- return getType(typ[0], result);
146
- }
147
- if (isString(typ)) {
148
- if (typ.lastIndexOf("]") !== -1) {
149
- result.list = true;
150
- result.type = typ.substr(1, typ.length - 2);
151
- }
152
- else {
153
- result.type = typ;
154
- }
155
- return;
156
- }
157
- if (isCustomType(typ)) {
158
- result.type = typ.type;
159
- addCustomType(typ);
160
- return;
161
- }
162
- // GraphQLScalarType or ClassType
163
- result.scalarType = isGraphQLScalarType(typ);
164
- result.type = typ.name;
165
- return;
166
- };
167
189
  let list;
168
190
  let scalarType = false;
169
191
  let connection;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GraphQLPageInfo = void 0;
4
4
  const graphql_1 = require("graphql");
5
+ // NB: if this changes, need to update renderer.go also
5
6
  exports.GraphQLPageInfo = new graphql_1.GraphQLObjectType({
6
7
  name: "PageInfo",
7
8
  fields: () => ({
@@ -10,7 +10,7 @@ interface classResult {
10
10
  class: classInfo;
11
11
  file: file;
12
12
  }
13
- export declare function parseCustomInput(filePath: string, opts?: Options): PathResult;
13
+ export declare function parseCustomImports(filePath: string, opts?: Options): PathResult;
14
14
  export declare function findTSConfigFile(filePath: string): string | null;
15
15
  export interface importInfo {
16
16
  name: string;
package/imports/index.js CHANGED
@@ -22,7 +22,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
22
22
  return (mod && mod.__esModule) ? mod : { "default": mod };
23
23
  };
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.findTSConfigFile = exports.parseCustomInput = void 0;
25
+ exports.findTSConfigFile = exports.parseCustomImports = void 0;
26
26
  const glob_1 = __importDefault(require("glob"));
27
27
  const typescript_1 = __importDefault(require("typescript"));
28
28
  const json5_1 = __importDefault(require("json5"));
@@ -42,10 +42,9 @@ function getFiles(filePath, opts) {
42
42
  }
43
43
  return files;
44
44
  }
45
- function parseCustomInput(filePath, opts) {
45
+ function parseCustomImports(filePath, opts) {
46
46
  const files = getFiles(filePath, opts);
47
47
  const options = readCompilerOptions(filePath);
48
- // classMap
49
48
  let classMap = new Map();
50
49
  files.forEach((file) => {
51
50
  const sourceFile = typescript_1.default.createSourceFile(file, fs.readFileSync(file).toString(), options.target || typescript_1.default.ScriptTarget.ES2015);
@@ -77,7 +76,7 @@ function parseCustomInput(filePath, opts) {
77
76
  },
78
77
  };
79
78
  }
80
- exports.parseCustomInput = parseCustomInput;
79
+ exports.parseCustomImports = parseCustomImports;
81
80
  function findTSConfigFile(filePath) {
82
81
  while (filePath != "/") {
83
82
  let configPath = `${filePath}/tsconfig.json`;
@@ -95,7 +94,6 @@ function readCompilerOptions(filePath) {
95
94
  if (!configPath) {
96
95
  return {};
97
96
  }
98
- const root = path.join(filePath, "..");
99
97
  let json = {};
100
98
  try {
101
99
  json = json5_1.default.parse(fs.readFileSync(configPath, {
package/index.d.ts CHANGED
@@ -3,7 +3,7 @@ export { loadEnt, loadCustomData, loadCustomEnts, loadEntX, loadEnts, CustomQuer
3
3
  import DB from "./core/db";
4
4
  export * from "./core/loaders";
5
5
  export { DB };
6
- export { EntPrivacyError, AlwaysAllowRule, AlwaysDenyRule, DenyIfLoggedInRule, DenyIfLoggedOutRule, AllowIfHasIdentity, AllowIfViewerRule, AllowIfFuncRule, AllowIfViewerIsRule, AllowIfViewerIsEntPropertyRule, AllowIfViewerEqualsRule, DenyIfViewerEqualsRule, AllowIfEdgeExistsRule, AllowIfViewerInboundEdgeExistsRule, AllowIfViewerOutboundEdgeExistsRule, DenyIfEdgeExistsRule, DenyIfViewerInboundEdgeExistsRule, DenyIfViewerOutboundEdgeExistsRule, DenyIfEdgeDoesNotExistRule, DenyIfViewerInboundEdgeDoesNotExistRule, DenyIfViewerOutboundEdgeDoesNotExistRule, AllowIfEntIsVisibleRule, AllowIfEntIsNotVisibleRule, DenyIfEntIsVisibleRule, DenyIfEntIsNotVisibleRule, AllowIfEntIsVisiblePolicy, DenyIfEntIsVisiblePolicy, DelayedResultRule, applyPrivacyPolicy, applyPrivacyPolicyX, AlwaysAllowPrivacyPolicy, AlwaysDenyPrivacyPolicy, AllowIfConditionAppliesRule, AllowIfSubPolicyAllowsRule, AllowIfViewerPrivacyPolicy, AllowIfViewerHasIdentityPrivacyPolicy, } from "./core/privacy";
6
+ export { EntPrivacyError, AlwaysAllowRule, AlwaysDenyRule, DenyIfLoggedInRule, DenyIfLoggedOutRule, AllowIfHasIdentity, AllowIfViewerRule, AllowIfFuncRule, AllowIfViewerIsRule, AllowIfViewerIsEntPropertyRule, AllowIfEntPropertyIsRule, DenyIfEntPropertyIsRule, AllowIfViewerEqualsRule, DenyIfViewerEqualsRule, AllowIfEdgeExistsRule, AllowIfViewerInboundEdgeExistsRule, AllowIfViewerOutboundEdgeExistsRule, DenyIfEdgeExistsRule, DenyIfViewerInboundEdgeExistsRule, DenyIfViewerOutboundEdgeExistsRule, DenyIfEdgeDoesNotExistRule, DenyIfViewerInboundEdgeDoesNotExistRule, DenyIfViewerOutboundEdgeDoesNotExistRule, AllowIfEntIsVisibleRule, AllowIfEntIsNotVisibleRule, DenyIfEntIsVisibleRule, DenyIfEntIsNotVisibleRule, AllowIfEntIsVisiblePolicy, DenyIfEntIsVisiblePolicy, DelayedResultRule, applyPrivacyPolicy, applyPrivacyPolicyX, AlwaysAllowPrivacyPolicy, AlwaysDenyPrivacyPolicy, AllowIfConditionAppliesRule, AllowIfSubPolicyAllowsRule, AllowIfViewerPrivacyPolicy, AllowIfViewerHasIdentityPrivacyPolicy, } from "./core/privacy";
7
7
  export * from "./core/query";
8
8
  export * from "./schema/";
9
9
  import * as q from "./core/clause";
package/index.js CHANGED
@@ -25,8 +25,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
25
25
  return (mod && mod.__esModule) ? mod : { "default": mod };
26
26
  };
27
27
  Object.defineProperty(exports, "__esModule", { value: true });
28
- exports.DenyIfViewerInboundEdgeDoesNotExistRule = exports.DenyIfEdgeDoesNotExistRule = exports.DenyIfViewerOutboundEdgeExistsRule = exports.DenyIfViewerInboundEdgeExistsRule = exports.DenyIfEdgeExistsRule = exports.AllowIfViewerOutboundEdgeExistsRule = exports.AllowIfViewerInboundEdgeExistsRule = exports.AllowIfEdgeExistsRule = exports.DenyIfViewerEqualsRule = exports.AllowIfViewerEqualsRule = exports.AllowIfViewerIsEntPropertyRule = exports.AllowIfViewerIsRule = exports.AllowIfFuncRule = exports.AllowIfViewerRule = exports.AllowIfHasIdentity = exports.DenyIfLoggedOutRule = exports.DenyIfLoggedInRule = exports.AlwaysDenyRule = exports.AlwaysAllowRule = exports.EntPrivacyError = exports.DB = exports.getEdgeTypeInGroup = exports.loadNodesByEdge = exports.loadEdgeForID2 = exports.loadRawEdgeCountX = exports.loadUniqueNode = exports.loadUniqueEdge = exports.loadEdges = exports.loadEdgeDatas = exports.loadEdgeData = exports.AssocEdgeData = exports.AssocEdge = exports.DeleteNodeOperation = exports.EdgeOperation = exports.EditNodeOperation = exports.loadRows = exports.loadRow = exports.loadRowX = exports.performRawQuery = exports.applyPrivacyPolicyForEntX = exports.applyPrivacyPolicyForEnt = exports.loadEntXViaKey = exports.loadEntViaKey = exports.loadDerivedEntX = exports.loadDerivedEnt = exports.loadEnts = exports.loadEntX = exports.loadCustomEnts = exports.loadCustomData = exports.loadEnt = void 0;
29
- exports.setLogLevels = exports.loadConfig = exports.LoggedOutViewer = exports.IDViewer = exports.ContextCache = exports.query = exports.AllowIfViewerHasIdentityPrivacyPolicy = exports.AllowIfViewerPrivacyPolicy = exports.AllowIfSubPolicyAllowsRule = exports.AllowIfConditionAppliesRule = exports.AlwaysDenyPrivacyPolicy = exports.AlwaysAllowPrivacyPolicy = exports.applyPrivacyPolicyX = exports.applyPrivacyPolicy = exports.DelayedResultRule = exports.DenyIfEntIsVisiblePolicy = exports.AllowIfEntIsVisiblePolicy = exports.DenyIfEntIsNotVisibleRule = exports.DenyIfEntIsVisibleRule = exports.AllowIfEntIsNotVisibleRule = exports.AllowIfEntIsVisibleRule = exports.DenyIfViewerOutboundEdgeDoesNotExistRule = void 0;
28
+ exports.DenyIfViewerOutboundEdgeExistsRule = exports.DenyIfViewerInboundEdgeExistsRule = exports.DenyIfEdgeExistsRule = exports.AllowIfViewerOutboundEdgeExistsRule = exports.AllowIfViewerInboundEdgeExistsRule = exports.AllowIfEdgeExistsRule = exports.DenyIfViewerEqualsRule = exports.AllowIfViewerEqualsRule = exports.DenyIfEntPropertyIsRule = exports.AllowIfEntPropertyIsRule = exports.AllowIfViewerIsEntPropertyRule = exports.AllowIfViewerIsRule = exports.AllowIfFuncRule = exports.AllowIfViewerRule = exports.AllowIfHasIdentity = exports.DenyIfLoggedOutRule = exports.DenyIfLoggedInRule = exports.AlwaysDenyRule = exports.AlwaysAllowRule = exports.EntPrivacyError = exports.DB = exports.getEdgeTypeInGroup = exports.loadNodesByEdge = exports.loadEdgeForID2 = exports.loadRawEdgeCountX = exports.loadUniqueNode = exports.loadUniqueEdge = exports.loadEdges = exports.loadEdgeDatas = exports.loadEdgeData = exports.AssocEdgeData = exports.AssocEdge = exports.DeleteNodeOperation = exports.EdgeOperation = exports.EditNodeOperation = exports.loadRows = exports.loadRow = exports.loadRowX = exports.performRawQuery = exports.applyPrivacyPolicyForEntX = exports.applyPrivacyPolicyForEnt = exports.loadEntXViaKey = exports.loadEntViaKey = exports.loadDerivedEntX = exports.loadDerivedEnt = exports.loadEnts = exports.loadEntX = exports.loadCustomEnts = exports.loadCustomData = exports.loadEnt = void 0;
29
+ exports.setLogLevels = exports.loadConfig = exports.LoggedOutViewer = exports.IDViewer = exports.ContextCache = exports.query = exports.AllowIfViewerHasIdentityPrivacyPolicy = exports.AllowIfViewerPrivacyPolicy = exports.AllowIfSubPolicyAllowsRule = exports.AllowIfConditionAppliesRule = exports.AlwaysDenyPrivacyPolicy = exports.AlwaysAllowPrivacyPolicy = exports.applyPrivacyPolicyX = exports.applyPrivacyPolicy = exports.DelayedResultRule = exports.DenyIfEntIsVisiblePolicy = exports.AllowIfEntIsVisiblePolicy = exports.DenyIfEntIsNotVisibleRule = exports.DenyIfEntIsVisibleRule = exports.AllowIfEntIsNotVisibleRule = exports.AllowIfEntIsVisibleRule = exports.DenyIfViewerOutboundEdgeDoesNotExistRule = exports.DenyIfViewerInboundEdgeDoesNotExistRule = exports.DenyIfEdgeDoesNotExistRule = void 0;
30
30
  __exportStar(require("./core/base"), exports);
31
31
  var ent_1 = require("./core/ent");
32
32
  Object.defineProperty(exports, "loadEnt", { enumerable: true, get: function () { return ent_1.loadEnt; } });
@@ -74,6 +74,8 @@ Object.defineProperty(exports, "AllowIfViewerRule", { enumerable: true, get: fun
74
74
  Object.defineProperty(exports, "AllowIfFuncRule", { enumerable: true, get: function () { return privacy_1.AllowIfFuncRule; } });
75
75
  Object.defineProperty(exports, "AllowIfViewerIsRule", { enumerable: true, get: function () { return privacy_1.AllowIfViewerIsRule; } });
76
76
  Object.defineProperty(exports, "AllowIfViewerIsEntPropertyRule", { enumerable: true, get: function () { return privacy_1.AllowIfViewerIsEntPropertyRule; } });
77
+ Object.defineProperty(exports, "AllowIfEntPropertyIsRule", { enumerable: true, get: function () { return privacy_1.AllowIfEntPropertyIsRule; } });
78
+ Object.defineProperty(exports, "DenyIfEntPropertyIsRule", { enumerable: true, get: function () { return privacy_1.DenyIfEntPropertyIsRule; } });
77
79
  Object.defineProperty(exports, "AllowIfViewerEqualsRule", { enumerable: true, get: function () { return privacy_1.AllowIfViewerEqualsRule; } });
78
80
  Object.defineProperty(exports, "DenyIfViewerEqualsRule", { enumerable: true, get: function () { return privacy_1.DenyIfViewerEqualsRule; } });
79
81
  Object.defineProperty(exports, "AllowIfEdgeExistsRule", { enumerable: true, get: function () { return privacy_1.AllowIfEdgeExistsRule; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snowtop/ent",
3
- "version": "0.0.24",
3
+ "version": "0.0.28",
4
4
  "description": "snowtop ent framework",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -9,6 +9,7 @@
9
9
  },
10
10
  "dependencies": {
11
11
  "@types/node": "^15.0.2",
12
+ "camel-case": "^4.1.2",
12
13
  "dataloader": "^2.0.0",
13
14
  "glob": "^7.1.6",
14
15
  "graph-data-structure": "^1.12.0",
@@ -38,7 +39,7 @@
38
39
  }
39
40
  },
40
41
  "engines": {
41
- "node": "^16.1.0"
42
+ "node": ">=14.0"
42
43
  },
43
44
  "devDependencies": {},
44
45
  "scripts": {},
package/schema/field.d.ts CHANGED
@@ -32,10 +32,10 @@ export declare class IntegerField extends BaseField implements Field {
32
32
  constructor(options?: IntegerOptions);
33
33
  getOptions(): IntegerOptions;
34
34
  private handleOptions;
35
- min(l: number): IntegerField;
36
- max(l: number): IntegerField;
35
+ min(l: number): this;
36
+ max(l: number): this;
37
37
  valid(val: any): boolean;
38
- validate(validator: (str: number) => boolean): IntegerField;
38
+ validate(validator: (str: number) => boolean): this;
39
39
  }
40
40
  export declare function IntegerType(options: IntegerOptions): IntegerField;
41
41
  export declare class BigIntegerField extends BaseField implements Field {
@@ -70,20 +70,20 @@ export declare class StringField extends BaseField implements Field {
70
70
  constructor(options?: StringOptions);
71
71
  getOptions(): StringOptions;
72
72
  private handleOptions;
73
- minLen(l: number): StringField;
74
- maxLen(l: number): StringField;
75
- length(l: number): StringField;
73
+ minLen(l: number): this;
74
+ maxLen(l: number): this;
75
+ length(l: number): this;
76
76
  valid(val: any): boolean;
77
77
  format(val: any): any;
78
- validate(validator: (str: string) => boolean): StringField;
79
- formatter(formatter: (str: string) => string): StringField;
80
- match(pattern: string | RegExp): StringField;
81
- doesNotMatch(pattern: string | RegExp): StringField;
82
- toLowerCase(): StringField;
83
- toUpperCase(): StringField;
84
- trim(): StringField;
85
- trimLeft(): StringField;
86
- trimRight(): StringField;
78
+ validate(validator: (str: string) => boolean): this;
79
+ formatter(formatter: (str: string) => string): this;
80
+ match(pattern: string | RegExp): this;
81
+ doesNotMatch(pattern: string | RegExp): this;
82
+ toLowerCase(): this;
83
+ toUpperCase(): this;
84
+ trim(): this;
85
+ trimLeft(): this;
86
+ trimRight(): this;
87
87
  }
88
88
  export declare function StringType(options: StringOptions): StringField;
89
89
  export interface TimestampOptions extends FieldOptions {
@@ -25,6 +25,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  const glob_1 = __importDefault(require("glob"));
27
27
  const minimist_1 = __importDefault(require("minimist"));
28
+ const graphql_1 = require("../graphql/graphql");
28
29
  const readline = __importStar(require("readline"));
29
30
  const path = __importStar(require("path"));
30
31
  const fs = __importStar(require("fs"));
@@ -52,7 +53,17 @@ async function readInputs() {
52
53
  });
53
54
  });
54
55
  }
55
- async function captureCustom(filePath) {
56
+ async function captureCustom(filePath, filesCsv) {
57
+ if (filesCsv !== undefined) {
58
+ let files = filesCsv.split(",");
59
+ for (let i = 0; i < files.length; i++) {
60
+ // TODO fix. we have "src" in the path we get here
61
+ files[i] = path.join(filePath, "..", files[i]);
62
+ }
63
+ await requireFiles(files);
64
+ return;
65
+ }
66
+ // TODO delete all of this eventually
56
67
  // TODO configurable paths eventually
57
68
  // for now only files that are in the include path of the roots are allowed
58
69
  const rootFiles = [
@@ -81,18 +92,28 @@ async function captureCustom(filePath) {
81
92
  ignore: ignore,
82
93
  });
83
94
  const files = rootFiles.concat(customGQLResolvers, customGQLMutations);
84
- //console.log(files);
85
- let promises = [];
86
- files.forEach((file) => {
95
+ await requireFiles(files);
96
+ }
97
+ async function requireFiles(files) {
98
+ await Promise.all(files.map(async (file) => {
87
99
  if (fs.existsSync(file)) {
88
- promises.push(require(file));
100
+ try {
101
+ await require(file);
102
+ }
103
+ catch (e) {
104
+ throw new Error(`${e.message} loading ${file}`);
105
+ }
106
+ }
107
+ else {
108
+ throw new Error(`file ${file} doesn't exist`);
89
109
  }
110
+ })).catch((err) => {
111
+ throw new Error(err);
90
112
  });
91
- await Promise.all(promises);
92
113
  }
93
114
  async function parseImports(filePath) {
94
115
  // only do graphql files...
95
- return (0, imports_1.parseCustomInput)(path.join(filePath, "graphql"), {
116
+ return (0, imports_1.parseCustomImports)(path.join(filePath, "graphql"), {
96
117
  ignore: ["**/generated/**", "**/tests/**"],
97
118
  });
98
119
  }
@@ -110,6 +131,20 @@ function findGraphQLPath(filePath) {
110
131
  return undefined;
111
132
  }
112
133
  async function main() {
134
+ // known custom types that are not required
135
+ // if not in the schema, will be ignored
136
+ // something like GraphQLUpload gotten via gqlArg({type: gqlFileUpload})
137
+ // these 2 need this because they're added by the schema
138
+ // if this list grows too long, need to build this into golang types and passed here
139
+ // TODO foreign non-scalars eventually
140
+ (0, graphql_1.addCustomType)({
141
+ importPath: "../graphql/scalars/time",
142
+ type: "GraphQLTime",
143
+ });
144
+ (0, graphql_1.addCustomType)({
145
+ importPath: "graphql-type-json",
146
+ type: "GraphQLJSON",
147
+ });
113
148
  const options = (0, minimist_1.default)(process.argv.slice(2));
114
149
  if (!options.path) {
115
150
  throw new Error("path required");
@@ -126,7 +161,7 @@ async function main() {
126
161
  GQLCapture.enable(true);
127
162
  const [inputsRead, _, imports] = await Promise.all([
128
163
  readInputs(),
129
- captureCustom(options.path),
164
+ captureCustom(options.path, options.files),
130
165
  parseImports(options.path),
131
166
  ]);
132
167
  const { nodes, nodesMap } = inputsRead;
@@ -9,6 +9,7 @@ export declare class User implements Ent {
9
9
  accountID: string;
10
10
  nodeType: string;
11
11
  privacyPolicy: import("../core/base").PrivacyPolicy;
12
+ firstName: string;
12
13
  constructor(viewer: Viewer, data: Data);
13
14
  }
14
15
  export declare class Event implements Ent {
@@ -23,6 +23,7 @@ class User {
23
23
  this.data.created_at = (0, convert_1.convertDate)(data.created_at);
24
24
  this.data.updated_at = (0, convert_1.convertDate)(data.updated_at);
25
25
  this.id = data.id;
26
+ this.firstName = data.first_name;
26
27
  }
27
28
  }
28
29
  exports.User = User;
@@ -1,25 +1,30 @@
1
- import { Viewer } from "../../core/base";
1
+ import { ID, Viewer } from "../../core/base";
2
2
  import { AssocEdge } from "../../core/ent";
3
3
  import { AssocEdgeQueryBase, EdgeQuerySource } from "../../core/query/assoc_query";
4
4
  import { FakeUser } from "./fake_user";
5
5
  import { FakeEvent } from "./internal";
6
6
  export declare class EventToAttendeesQuery extends AssocEdgeQueryBase<FakeEvent, FakeUser, AssocEdge> {
7
- constructor(viewer: Viewer, src: EdgeQuerySource<FakeEvent>);
8
- static query(viewer: Viewer, src: EdgeQuerySource<FakeEvent>): EventToAttendeesQuery;
7
+ constructor(viewer: Viewer, src: EdgeQuerySource<FakeEvent, FakeUser>);
8
+ static query(viewer: Viewer, src: EdgeQuerySource<FakeEvent, FakeUser>): EventToAttendeesQuery;
9
+ sourceEnt(id: ID): Promise<FakeEvent | null>;
9
10
  }
10
11
  export declare class EventToInvitedQuery extends AssocEdgeQueryBase<FakeEvent, FakeUser, AssocEdge> {
11
- constructor(viewer: Viewer, src: EdgeQuerySource<FakeEvent>);
12
- static query(viewer: Viewer, src: EdgeQuerySource<FakeEvent>): EventToInvitedQuery;
12
+ constructor(viewer: Viewer, src: EdgeQuerySource<FakeEvent, FakeUser>);
13
+ static query(viewer: Viewer, src: EdgeQuerySource<FakeEvent, FakeUser>): EventToInvitedQuery;
14
+ sourceEnt(id: ID): Promise<FakeEvent | null>;
13
15
  }
14
16
  export declare class EventToDeclinedQuery extends AssocEdgeQueryBase<FakeEvent, FakeUser, AssocEdge> {
15
- constructor(viewer: Viewer, src: EdgeQuerySource<FakeEvent>);
16
- static query(viewer: Viewer, src: EdgeQuerySource<FakeEvent>): EventToDeclinedQuery;
17
+ constructor(viewer: Viewer, src: EdgeQuerySource<FakeEvent, FakeUser>);
18
+ static query(viewer: Viewer, src: EdgeQuerySource<FakeEvent, FakeUser>): EventToDeclinedQuery;
19
+ sourceEnt(id: ID): Promise<FakeEvent | null>;
17
20
  }
18
21
  export declare class EventToMaybeQuery extends AssocEdgeQueryBase<FakeEvent, FakeUser, AssocEdge> {
19
- constructor(viewer: Viewer, src: EdgeQuerySource<FakeEvent>);
20
- static query(viewer: Viewer, src: EdgeQuerySource<FakeEvent>): EventToMaybeQuery;
22
+ constructor(viewer: Viewer, src: EdgeQuerySource<FakeEvent, FakeUser>);
23
+ static query(viewer: Viewer, src: EdgeQuerySource<FakeEvent, FakeUser>): EventToMaybeQuery;
24
+ sourceEnt(id: ID): Promise<FakeEvent | null>;
21
25
  }
22
26
  export declare class EventToHostsQuery extends AssocEdgeQueryBase<FakeEvent, FakeUser, AssocEdge> {
23
- constructor(viewer: Viewer, src: EdgeQuerySource<FakeEvent>);
24
- static query(viewer: Viewer, src: EdgeQuerySource<FakeEvent>): EventToHostsQuery;
27
+ constructor(viewer: Viewer, src: EdgeQuerySource<FakeEvent, FakeUser>);
28
+ static query(viewer: Viewer, src: EdgeQuerySource<FakeEvent, FakeUser>): EventToHostsQuery;
29
+ sourceEnt(id: ID): Promise<FakeEvent | null>;
25
30
  }
@@ -14,6 +14,9 @@ class EventToAttendeesQuery extends assoc_query_1.AssocEdgeQueryBase {
14
14
  static query(viewer, src) {
15
15
  return new EventToAttendeesQuery(viewer, src);
16
16
  }
17
+ sourceEnt(id) {
18
+ return internal_1.FakeEvent.load(this.viewer, id);
19
+ }
17
20
  }
18
21
  exports.EventToAttendeesQuery = EventToAttendeesQuery;
19
22
  class EventToInvitedQuery extends assoc_query_1.AssocEdgeQueryBase {
@@ -23,6 +26,9 @@ class EventToInvitedQuery extends assoc_query_1.AssocEdgeQueryBase {
23
26
  static query(viewer, src) {
24
27
  return new EventToInvitedQuery(viewer, src);
25
28
  }
29
+ sourceEnt(id) {
30
+ return internal_1.FakeEvent.load(this.viewer, id);
31
+ }
26
32
  }
27
33
  exports.EventToInvitedQuery = EventToInvitedQuery;
28
34
  class EventToDeclinedQuery extends assoc_query_1.AssocEdgeQueryBase {
@@ -32,6 +38,9 @@ class EventToDeclinedQuery extends assoc_query_1.AssocEdgeQueryBase {
32
38
  static query(viewer, src) {
33
39
  return new EventToDeclinedQuery(viewer, src);
34
40
  }
41
+ sourceEnt(id) {
42
+ return internal_1.FakeEvent.load(this.viewer, id);
43
+ }
35
44
  }
36
45
  exports.EventToDeclinedQuery = EventToDeclinedQuery;
37
46
  class EventToMaybeQuery extends assoc_query_1.AssocEdgeQueryBase {
@@ -41,6 +50,9 @@ class EventToMaybeQuery extends assoc_query_1.AssocEdgeQueryBase {
41
50
  static query(viewer, src) {
42
51
  return new EventToMaybeQuery(viewer, src);
43
52
  }
53
+ sourceEnt(id) {
54
+ return internal_1.FakeEvent.load(this.viewer, id);
55
+ }
44
56
  }
45
57
  exports.EventToMaybeQuery = EventToMaybeQuery;
46
58
  class EventToHostsQuery extends assoc_query_1.AssocEdgeQueryBase {
@@ -50,5 +62,8 @@ class EventToHostsQuery extends assoc_query_1.AssocEdgeQueryBase {
50
62
  static query(viewer, src) {
51
63
  return new EventToHostsQuery(viewer, src);
52
64
  }
65
+ sourceEnt(id) {
66
+ return internal_1.FakeEvent.load(this.viewer, id);
67
+ }
53
68
  }
54
69
  exports.EventToHostsQuery = EventToHostsQuery;
@@ -10,16 +10,19 @@ import { QueryLoaderFactory } from "../../core/loaders/query_loader";
10
10
  export declare class UserToContactsQuery extends AssocEdgeQueryBase<FakeUser, FakeContact, AssocEdge> {
11
11
  constructor(viewer: Viewer, src: EdgeQuerySource<FakeUser>);
12
12
  static query(viewer: Viewer, src: EdgeQuerySource<FakeUser>): UserToContactsQuery;
13
+ sourceEnt(id: ID): Promise<FakeUser | null>;
13
14
  }
14
15
  export declare const userToContactsCountLoaderFactory: RawCountLoaderFactory;
15
16
  export declare const userToContactsDataLoaderFactory: IndexLoaderFactory;
16
17
  export declare class UserToContactsFkeyQuery extends CustomEdgeQueryBase<FakeUser, FakeContact> {
17
18
  constructor(viewer: Viewer, src: ID | FakeUser);
18
19
  static query(viewer: Viewer, src: FakeUser | ID): UserToContactsFkeyQuery;
20
+ sourceEnt(id: ID): Promise<FakeUser | null>;
19
21
  }
20
22
  export declare class UserToFriendsQuery extends AssocEdgeQueryBase<FakeUser, FakeUser, AssocEdge> {
21
23
  constructor(viewer: Viewer, src: EdgeQuerySource<FakeUser>);
22
24
  static query(viewer: Viewer, src: EdgeQuerySource<FakeUser>): UserToFriendsQuery;
25
+ sourceEnt(id: ID): Promise<FakeUser | null>;
23
26
  queryContacts(): UserToContactsQuery;
24
27
  queryFriends(): UserToFriendsQuery;
25
28
  queryHostedEvents(): UserToHostedEventsQuery;
@@ -32,6 +35,7 @@ export declare class CustomEdge extends AssocEdge {
32
35
  export declare class UserToCustomEdgeQuery extends AssocEdgeQueryBase<FakeUser, FakeUser, CustomEdge> {
33
36
  constructor(viewer: Viewer, src: EdgeQuerySource<FakeUser>);
34
37
  static query(viewer: Viewer, src: EdgeQuerySource<FakeUser>): UserToCustomEdgeQuery;
38
+ sourceEnt(id: ID): Promise<FakeUser | null>;
35
39
  queryContacts(): UserToContactsQuery;
36
40
  queryFriends(): UserToFriendsQuery;
37
41
  queryHostedEvents(): UserToHostedEventsQuery;
@@ -40,6 +44,7 @@ export declare class UserToCustomEdgeQuery extends AssocEdgeQueryBase<FakeUser,
40
44
  export declare class UserToFriendRequestsQuery extends AssocEdgeQueryBase<FakeUser, FakeUser, AssocEdge> {
41
45
  constructor(viewer: Viewer, src: EdgeQuerySource<FakeUser>);
42
46
  static query(viewer: Viewer, src: EdgeQuerySource<FakeUser>): UserToFriendRequestsQuery;
47
+ sourceEnt(id: ID): Promise<FakeUser | null>;
43
48
  queryContacts(): UserToContactsQuery;
44
49
  queryFriends(): UserToFriendsQuery;
45
50
  queryHostedEvents(): UserToHostedEventsQuery;
@@ -47,10 +52,10 @@ export declare class UserToFriendRequestsQuery extends AssocEdgeQueryBase<FakeUs
47
52
  queryCustomEdge(): UserToCustomEdgeQuery;
48
53
  }
49
54
  export declare class UserToIncomingFriendRequestsQuery extends AssocEdgeQueryBase<FakeUser, FakeUser, AssocEdge> {
50
- constructor(viewer: Viewer, src: EdgeQuerySource<FakeUser>);
55
+ constructor(viewer: Viewer, src: EdgeQuerySource<FakeUser, FakeUser>);
51
56
  getPrivacyPolicy(): import("../../core/base").PrivacyPolicy;
52
- entForPrivacy(id: ID): Promise<FakeUser | null>;
53
- static query(viewer: Viewer, src: EdgeQuerySource<FakeUser>): UserToIncomingFriendRequestsQuery;
57
+ sourceEnt(id: ID): Promise<FakeUser | null>;
58
+ static query(viewer: Viewer, src: EdgeQuerySource<FakeUser, FakeUser>): UserToIncomingFriendRequestsQuery;
54
59
  queryContacts(): UserToContactsQuery;
55
60
  queryFriends(): UserToFriendsQuery;
56
61
  queryHostedEvents(): UserToHostedEventsQuery;
@@ -58,8 +63,9 @@ export declare class UserToIncomingFriendRequestsQuery extends AssocEdgeQueryBas
58
63
  queryCustomEdge(): UserToCustomEdgeQuery;
59
64
  }
60
65
  export declare class UserToEventsAttendingQuery extends AssocEdgeQueryBase<FakeUser, FakeEvent, AssocEdge> {
61
- constructor(viewer: Viewer, src: EdgeQuerySource<FakeUser>);
62
- static query(viewer: Viewer, src: EdgeQuerySource<FakeUser>): UserToEventsAttendingQuery;
66
+ constructor(viewer: Viewer, src: EdgeQuerySource<FakeUser, FakeEvent>);
67
+ static query(viewer: Viewer, src: EdgeQuerySource<FakeUser, FakeEvent>): UserToEventsAttendingQuery;
68
+ sourceEnt(id: ID): Promise<FakeUser | null>;
63
69
  queryHosts(): EventToHostsQuery;
64
70
  queryAttendees(): EventToAttendeesQuery;
65
71
  queryInvited(): EventToInvitedQuery;
@@ -67,8 +73,9 @@ export declare class UserToEventsAttendingQuery extends AssocEdgeQueryBase<FakeU
67
73
  queryMaybe(): EventToMaybeQuery;
68
74
  }
69
75
  export declare class UserToHostedEventsQuery extends AssocEdgeQueryBase<FakeUser, FakeEvent, AssocEdge> {
70
- constructor(viewer: Viewer, src: EdgeQuerySource<FakeUser>);
71
- static query(viewer: Viewer, src: EdgeQuerySource<FakeUser>): UserToHostedEventsQuery;
76
+ constructor(viewer: Viewer, src: EdgeQuerySource<FakeUser, FakeEvent>);
77
+ static query(viewer: Viewer, src: EdgeQuerySource<FakeUser, FakeEvent>): UserToHostedEventsQuery;
78
+ sourceEnt(id: ID): Promise<FakeUser | null>;
72
79
  queryHosts(): EventToHostsQuery;
73
80
  queryAttendees(): EventToAttendeesQuery;
74
81
  queryInvited(): EventToInvitedQuery;
@@ -82,10 +89,11 @@ export declare const userToEventsInNextWeekDataLoaderFactory: QueryLoaderFactory
82
89
  export declare class UserToEventsInNextWeekQuery extends CustomEdgeQueryBase<FakeUser, FakeEvent> {
83
90
  constructor(viewer: Viewer, src: ID | FakeUser);
84
91
  static query(viewer: Viewer, src: FakeUser | ID): UserToEventsInNextWeekQuery;
92
+ sourceEnt(id: ID): Promise<FakeUser | null>;
85
93
  getPrivacyPolicy(): import("../../core/base").PrivacyPolicy;
86
- entForPrivacy(id: ID): Promise<FakeUser | null>;
87
94
  }
88
95
  export declare class UserToFollowingQuery extends AssocEdgeQueryBase<FakeUser, Ent, AssocEdge> {
89
- constructor(viewer: Viewer, src: EdgeQuerySource<FakeUser>);
90
- static query(viewer: Viewer, src: EdgeQuerySource<FakeUser>): UserToFollowingQuery;
96
+ constructor(viewer: Viewer, src: EdgeQuerySource<FakeUser, FakeUser>);
97
+ static query(viewer: Viewer, src: EdgeQuerySource<FakeUser, FakeUser>): UserToFollowingQuery;
98
+ sourceEnt(id: ID): Promise<FakeUser | null>;
91
99
  }
@@ -43,6 +43,9 @@ class UserToContactsQuery extends assoc_query_1.AssocEdgeQueryBase {
43
43
  static query(viewer, src) {
44
44
  return new UserToContactsQuery(viewer, src);
45
45
  }
46
+ sourceEnt(id) {
47
+ return internal_1.FakeUser.load(this.viewer, id);
48
+ }
46
49
  }
47
50
  exports.UserToContactsQuery = UserToContactsQuery;
48
51
  exports.userToContactsCountLoaderFactory = new raw_count_loader_1.RawCountLoaderFactory({
@@ -65,6 +68,9 @@ class UserToContactsFkeyQuery extends custom_query_1.CustomEdgeQueryBase {
65
68
  static query(viewer, src) {
66
69
  return new UserToContactsFkeyQuery(viewer, src);
67
70
  }
71
+ sourceEnt(id) {
72
+ return internal_1.FakeUser.load(this.viewer, id);
73
+ }
68
74
  }
69
75
  exports.UserToContactsFkeyQuery = UserToContactsFkeyQuery;
70
76
  class UserToFriendsQuery extends assoc_query_1.AssocEdgeQueryBase {
@@ -74,6 +80,9 @@ class UserToFriendsQuery extends assoc_query_1.AssocEdgeQueryBase {
74
80
  static query(viewer, src) {
75
81
  return new UserToFriendsQuery(viewer, src);
76
82
  }
83
+ sourceEnt(id) {
84
+ return internal_1.FakeUser.load(this.viewer, id);
85
+ }
77
86
  queryContacts() {
78
87
  return UserToContactsQuery.query(this.viewer, this);
79
88
  }
@@ -105,6 +114,9 @@ class UserToCustomEdgeQuery extends assoc_query_1.AssocEdgeQueryBase {
105
114
  static query(viewer, src) {
106
115
  return new UserToCustomEdgeQuery(viewer, src);
107
116
  }
117
+ sourceEnt(id) {
118
+ return internal_1.FakeUser.load(this.viewer, id);
119
+ }
108
120
  queryContacts() {
109
121
  return UserToContactsQuery.query(this.viewer, this);
110
122
  }
@@ -126,6 +138,9 @@ class UserToFriendRequestsQuery extends assoc_query_1.AssocEdgeQueryBase {
126
138
  static query(viewer, src) {
127
139
  return new UserToFriendRequestsQuery(viewer, src);
128
140
  }
141
+ sourceEnt(id) {
142
+ return internal_1.FakeUser.load(this.viewer, id);
143
+ }
129
144
  queryContacts() {
130
145
  return UserToContactsQuery.query(this.viewer, this);
131
146
  }
@@ -150,7 +165,7 @@ class UserToIncomingFriendRequestsQuery extends assoc_query_1.AssocEdgeQueryBase
150
165
  getPrivacyPolicy() {
151
166
  return privacy_1.AllowIfViewerPrivacyPolicy;
152
167
  }
153
- entForPrivacy(id) {
168
+ sourceEnt(id) {
154
169
  return internal_1.FakeUser.load(this.viewer, id);
155
170
  }
156
171
  static query(viewer, src) {
@@ -180,6 +195,9 @@ class UserToEventsAttendingQuery extends assoc_query_1.AssocEdgeQueryBase {
180
195
  static query(viewer, src) {
181
196
  return new UserToEventsAttendingQuery(viewer, src);
182
197
  }
198
+ sourceEnt(id) {
199
+ return internal_1.FakeUser.load(this.viewer, id);
200
+ }
183
201
  queryHosts() {
184
202
  return internal_1.EventToHostsQuery.query(this.viewer, this);
185
203
  }
@@ -204,6 +222,9 @@ class UserToHostedEventsQuery extends assoc_query_1.AssocEdgeQueryBase {
204
222
  static query(viewer, src) {
205
223
  return new UserToHostedEventsQuery(viewer, src);
206
224
  }
225
+ sourceEnt(id) {
226
+ return internal_1.FakeUser.load(this.viewer, id);
227
+ }
207
228
  queryHosts() {
208
229
  return internal_1.EventToHostsQuery.query(this.viewer, this);
209
230
  }
@@ -263,12 +284,12 @@ class UserToEventsInNextWeekQuery extends custom_query_1.CustomEdgeQueryBase {
263
284
  static query(viewer, src) {
264
285
  return new UserToEventsInNextWeekQuery(viewer, src);
265
286
  }
287
+ sourceEnt(id) {
288
+ return internal_1.FakeUser.load(this.viewer, id);
289
+ }
266
290
  getPrivacyPolicy() {
267
291
  return privacy_1.AllowIfViewerPrivacyPolicy;
268
292
  }
269
- async entForPrivacy(id) {
270
- return internal_1.FakeUser.load(this.viewer, id);
271
- }
272
293
  }
273
294
  exports.UserToEventsInNextWeekQuery = UserToEventsInNextWeekQuery;
274
295
  class UserToFollowingQuery extends assoc_query_1.AssocEdgeQueryBase {
@@ -278,5 +299,8 @@ class UserToFollowingQuery extends assoc_query_1.AssocEdgeQueryBase {
278
299
  static query(viewer, src) {
279
300
  return new UserToFollowingQuery(viewer, src);
280
301
  }
302
+ sourceEnt(id) {
303
+ return internal_1.FakeUser.load(this.viewer, id);
304
+ }
281
305
  }
282
306
  exports.UserToFollowingQuery = UserToFollowingQuery;