@snowtop/ent 0.1.0-alpha9 → 0.1.0-alpha91

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 (135) hide show
  1. package/action/action.d.ts +36 -31
  2. package/action/action.js +2 -6
  3. package/action/executor.d.ts +3 -3
  4. package/action/executor.js +2 -2
  5. package/action/experimental_action.d.ts +29 -22
  6. package/action/experimental_action.js +29 -6
  7. package/action/orchestrator.d.ts +38 -16
  8. package/action/orchestrator.js +223 -61
  9. package/action/privacy.d.ts +2 -2
  10. package/core/base.d.ts +45 -24
  11. package/core/base.js +7 -1
  12. package/core/clause.d.ts +83 -7
  13. package/core/clause.js +334 -63
  14. package/core/config.d.ts +8 -0
  15. package/core/config.js +5 -1
  16. package/core/context.d.ts +5 -3
  17. package/core/context.js +20 -2
  18. package/core/convert.d.ts +1 -1
  19. package/core/db.d.ts +2 -2
  20. package/core/db.js +6 -2
  21. package/core/ent.d.ts +79 -24
  22. package/core/ent.js +527 -176
  23. package/core/loaders/assoc_count_loader.d.ts +3 -2
  24. package/core/loaders/assoc_count_loader.js +14 -2
  25. package/core/loaders/assoc_edge_loader.d.ts +2 -2
  26. package/core/loaders/assoc_edge_loader.js +5 -1
  27. package/core/loaders/index.d.ts +1 -1
  28. package/core/loaders/index.js +1 -3
  29. package/core/loaders/index_loader.d.ts +2 -2
  30. package/core/loaders/loader.js +5 -5
  31. package/core/loaders/object_loader.d.ts +6 -5
  32. package/core/loaders/object_loader.js +67 -59
  33. package/core/loaders/query_loader.d.ts +6 -12
  34. package/core/loaders/query_loader.js +52 -11
  35. package/core/loaders/raw_count_loader.d.ts +2 -2
  36. package/core/loaders/raw_count_loader.js +5 -1
  37. package/core/logger.d.ts +1 -1
  38. package/core/logger.js +1 -0
  39. package/core/privacy.d.ts +26 -25
  40. package/core/privacy.js +21 -25
  41. package/core/query/assoc_query.d.ts +7 -6
  42. package/core/query/assoc_query.js +9 -1
  43. package/core/query/custom_clause_query.d.ts +26 -0
  44. package/core/query/custom_clause_query.js +78 -0
  45. package/core/query/custom_query.d.ts +20 -5
  46. package/core/query/custom_query.js +87 -12
  47. package/core/query/index.d.ts +1 -0
  48. package/core/query/index.js +3 -1
  49. package/core/query/query.d.ts +8 -4
  50. package/core/query/query.js +101 -53
  51. package/core/query/shared_assoc_test.d.ts +2 -1
  52. package/core/query/shared_assoc_test.js +34 -43
  53. package/core/query/shared_test.d.ts +8 -1
  54. package/core/query/shared_test.js +470 -236
  55. package/core/viewer.d.ts +3 -3
  56. package/core/viewer.js +1 -1
  57. package/graphql/graphql.js +16 -6
  58. package/graphql/query/edge_connection.d.ts +9 -9
  59. package/graphql/query/page_info.d.ts +1 -1
  60. package/graphql/query/shared_edge_connection.js +1 -15
  61. package/imports/index.js +5 -1
  62. package/index.d.ts +11 -5
  63. package/index.js +20 -7
  64. package/package.json +1 -1
  65. package/parse_schema/parse.d.ts +12 -3
  66. package/parse_schema/parse.js +70 -11
  67. package/schema/base_schema.js +3 -0
  68. package/schema/field.d.ts +44 -8
  69. package/schema/field.js +136 -10
  70. package/schema/index.d.ts +2 -2
  71. package/schema/index.js +5 -1
  72. package/schema/json_field.d.ts +13 -1
  73. package/schema/json_field.js +28 -1
  74. package/schema/schema.d.ts +66 -11
  75. package/schema/schema.js +18 -4
  76. package/schema/struct_field.d.ts +11 -1
  77. package/schema/struct_field.js +44 -5
  78. package/scripts/custom_compiler.js +10 -6
  79. package/scripts/custom_graphql.js +13 -4
  80. package/scripts/{transform_schema.d.ts → migrate_v0.1.d.ts} +0 -0
  81. package/scripts/migrate_v0.1.js +36 -0
  82. package/scripts/read_schema.js +20 -5
  83. package/testutils/builder.d.ts +31 -21
  84. package/testutils/builder.js +83 -29
  85. package/testutils/db/fixture.d.ts +10 -0
  86. package/testutils/db/fixture.js +26 -0
  87. package/testutils/db/{test_db.d.ts → temp_db.d.ts} +20 -7
  88. package/testutils/db/{test_db.js → temp_db.js} +102 -36
  89. package/testutils/db/value.d.ts +6 -0
  90. package/testutils/db/value.js +251 -0
  91. package/testutils/db_mock.js +3 -1
  92. package/testutils/db_time_zone.d.ts +4 -0
  93. package/testutils/db_time_zone.js +41 -0
  94. package/testutils/ent-graphql-tests/index.js +8 -1
  95. package/testutils/fake_data/const.d.ts +2 -1
  96. package/testutils/fake_data/const.js +3 -0
  97. package/testutils/fake_data/fake_contact.d.ts +7 -4
  98. package/testutils/fake_data/fake_contact.js +14 -6
  99. package/testutils/fake_data/fake_event.d.ts +5 -3
  100. package/testutils/fake_data/fake_event.js +8 -5
  101. package/testutils/fake_data/fake_tag.d.ts +35 -0
  102. package/testutils/fake_data/fake_tag.js +88 -0
  103. package/testutils/fake_data/fake_user.d.ts +6 -4
  104. package/testutils/fake_data/fake_user.js +16 -13
  105. package/testutils/fake_data/index.js +5 -1
  106. package/testutils/fake_data/internal.d.ts +2 -0
  107. package/testutils/fake_data/internal.js +7 -1
  108. package/testutils/fake_data/tag_query.d.ts +13 -0
  109. package/testutils/fake_data/tag_query.js +43 -0
  110. package/testutils/fake_data/test_helpers.d.ts +11 -4
  111. package/testutils/fake_data/test_helpers.js +28 -12
  112. package/testutils/fake_data/user_query.d.ts +13 -6
  113. package/testutils/fake_data/user_query.js +54 -22
  114. package/testutils/fake_log.d.ts +3 -3
  115. package/testutils/parse_sql.d.ts +6 -0
  116. package/testutils/parse_sql.js +16 -2
  117. package/testutils/test_edge_global_schema.d.ts +15 -0
  118. package/testutils/test_edge_global_schema.js +62 -0
  119. package/testutils/write.d.ts +2 -2
  120. package/testutils/write.js +33 -7
  121. package/tsc/ast.d.ts +44 -0
  122. package/tsc/ast.js +271 -0
  123. package/tsc/compilerOptions.d.ts +6 -0
  124. package/tsc/compilerOptions.js +45 -2
  125. package/tsc/move_generated.d.ts +1 -0
  126. package/tsc/move_generated.js +164 -0
  127. package/tsc/transform.d.ts +21 -0
  128. package/tsc/transform.js +171 -0
  129. package/tsc/transform_action.d.ts +22 -0
  130. package/tsc/transform_action.js +183 -0
  131. package/tsc/transform_ent.d.ts +17 -0
  132. package/tsc/transform_ent.js +59 -0
  133. package/tsc/transform_schema.d.ts +27 -0
  134. package/tsc/transform_schema.js +383 -0
  135. package/scripts/transform_schema.js +0 -445
@@ -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];
@@ -45,6 +49,7 @@ function server(config) {
45
49
  if (config.init) {
46
50
  config.init(app);
47
51
  }
52
+ // @ts-ignore something changed. come back
48
53
  app.use(express_1.default.json());
49
54
  let handlers = config.customHandlers || [];
50
55
  handlers.push(async (req, res) => {
@@ -56,9 +61,11 @@ function server(config) {
56
61
  request: req,
57
62
  schema: config.schema,
58
63
  contextFactory: async (executionContext) => {
64
+ // @ts-ignore something changed. come back
59
65
  return (0, auth_1.buildContext)(req, res);
60
66
  },
61
67
  });
68
+ // @ts-ignore something changed. come back
62
69
  await (0, graphql_helix_1.sendResult)(result, res);
63
70
  });
64
71
  app.use(config.graphQLPath || "/graphql", ...handlers);
@@ -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";
@@ -13,13 +13,14 @@ export declare class FakeContact implements Ent {
13
13
  readonly lastName: string;
14
14
  readonly emailAddress: string;
15
15
  readonly userID: ID;
16
- privacyPolicy: PrivacyPolicy;
16
+ getPrivacyPolicy(): PrivacyPolicy<this>;
17
17
  constructor(viewer: Viewer, data: Data);
18
18
  static getFields(): string[];
19
- static getTestTable(): import("../db/test_db").Table;
19
+ static getTestTable(): import("../db/temp_db").Table;
20
20
  static loaderOptions(): LoadEntOptions<FakeContact>;
21
21
  static load(v: Viewer, id: ID): Promise<FakeContact | null>;
22
22
  static loadX(v: Viewer, id: ID): Promise<FakeContact>;
23
+ static loadRawData(id: ID, context?: Context): Promise<Data | null>;
23
24
  }
24
25
  export declare const FakeContactSchema: import("../builder").BuilderSchema<FakeContact>;
25
26
  export interface ContactCreateInput {
@@ -27,7 +28,9 @@ export interface ContactCreateInput {
27
28
  lastName: string;
28
29
  emailAddress: string;
29
30
  userID: ID;
31
+ createdAt?: Date;
32
+ updatedAt?: Date;
30
33
  }
31
- export declare function getContactBuilder(viewer: Viewer, input: ContactCreateInput): SimpleBuilder<FakeContact>;
34
+ export declare function getContactBuilder(viewer: Viewer, input: ContactCreateInput): SimpleBuilder<FakeContact, null>;
32
35
  export declare function createContact(viewer: Viewer, input: ContactCreateInput): Promise<void>;
33
36
  export declare const contactLoader: ObjectLoaderFactory<unknown>;
@@ -6,16 +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
+ const action_1 = require("../../action");
12
13
  class FakeContact {
13
14
  constructor(viewer, data) {
14
15
  this.viewer = viewer;
15
16
  this.nodeType = const_1.NodeType.FakeContact;
16
- this.privacyPolicy = {
17
- rules: [new privacy_1.AllowIfViewerIsRule("userID"), privacy_1.AlwaysDenyRule],
18
- };
19
17
  this.data = data;
20
18
  this.id = data.id;
21
19
  this.createdAt = (0, convert_1.convertDate)(data.created_at);
@@ -25,6 +23,11 @@ class FakeContact {
25
23
  this.emailAddress = data.email_address;
26
24
  this.userID = data.user_id;
27
25
  }
26
+ getPrivacyPolicy() {
27
+ return {
28
+ rules: [new privacy_1.AllowIfViewerIsRule("userID"), privacy_1.AlwaysDenyRule],
29
+ };
30
+ }
28
31
  static getFields() {
29
32
  return [
30
33
  "id",
@@ -37,7 +40,7 @@ class FakeContact {
37
40
  ];
38
41
  }
39
42
  static getTestTable() {
40
- 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"));
43
+ 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"));
41
44
  }
42
45
  static loaderOptions() {
43
46
  return {
@@ -57,6 +60,11 @@ class FakeContact {
57
60
  static async loadX(v, id) {
58
61
  return (0, ent_1.loadEntX)(v, id, FakeContact.loaderOptions());
59
62
  }
63
+ static async loadRawData(id, context) {
64
+ return FakeContact.loaderOptions()
65
+ .loaderFactory.createLoader(context)
66
+ .load(id);
67
+ }
60
68
  }
61
69
  exports.FakeContact = FakeContact;
62
70
  exports.FakeContactSchema = (0, builder_1.getBuilderSchemaFromFields)({
@@ -75,7 +83,7 @@ function getContactBuilder(viewer, input) {
75
83
  //To lock in the value of Date now incase of advanceTo/advanceBy
76
84
  m.set("createdAt", new Date());
77
85
  m.set("updatedAt", new Date());
78
- return new builder_1.SimpleBuilder(viewer, exports.FakeContactSchema, m);
86
+ return new builder_1.SimpleBuilder(viewer, exports.FakeContactSchema, m, action_1.WriteOperation.Insert, null);
79
87
  }
80
88
  exports.getContactBuilder = getContactBuilder;
81
89
  async function createContact(viewer, input) {
@@ -14,16 +14,18 @@ export declare class FakeEvent implements Ent {
14
14
  readonly title: string;
15
15
  readonly description: string | null;
16
16
  readonly userID: ID;
17
- privacyPolicy: PrivacyPolicy;
17
+ getPrivacyPolicy(): PrivacyPolicy<this>;
18
18
  constructor(viewer: Viewer, data: Data);
19
19
  private static getFields;
20
- static getTestTable(): import("../db/test_db").Table;
20
+ static getTestTable(): import("../db/temp_db").Table;
21
21
  static loaderOptions(): LoadEntOptions<FakeEvent>;
22
22
  static load(v: Viewer, id: ID): Promise<FakeEvent | null>;
23
23
  static loadX(v: Viewer, id: ID): Promise<FakeEvent>;
24
24
  }
25
25
  export declare const FakeEventSchema: import("../builder").BuilderSchema<FakeEvent>;
26
26
  export interface EventCreateInput {
27
+ createdAt?: Date;
28
+ updatedAt?: Date;
27
29
  startTime: Date;
28
30
  endTime?: Date | null;
29
31
  location: string;
@@ -31,5 +33,5 @@ export interface EventCreateInput {
31
33
  description?: string | null;
32
34
  userID: ID;
33
35
  }
34
- export declare function getEventBuilder(viewer: Viewer, input: EventCreateInput): SimpleBuilder<FakeEvent>;
36
+ export declare function getEventBuilder(viewer: Viewer, input: EventCreateInput): SimpleBuilder<FakeEvent, null>;
35
37
  export declare function createEvent(viewer: Viewer, input: EventCreateInput): Promise<void>;
@@ -6,14 +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
+ const action_1 = require("../../action");
12
13
  class FakeEvent {
13
14
  constructor(viewer, data) {
14
15
  this.viewer = viewer;
15
16
  this.nodeType = const_1.NodeType.FakeEvent;
16
- this.privacyPolicy = privacy_1.AlwaysAllowPrivacyPolicy;
17
17
  this.data = data;
18
18
  this.id = data.id;
19
19
  this.createdAt = (0, convert_1.convertDate)(data.created_at);
@@ -25,6 +25,9 @@ class FakeEvent {
25
25
  this.description = data.description;
26
26
  this.userID = data.user_id;
27
27
  }
28
+ getPrivacyPolicy() {
29
+ return privacy_1.AlwaysAllowPrivacyPolicy;
30
+ }
28
31
  static getFields() {
29
32
  return [
30
33
  "id",
@@ -39,9 +42,9 @@ class FakeEvent {
39
42
  ];
40
43
  }
41
44
  static getTestTable() {
42
- 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"),
45
+ 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"),
43
46
  // TODO index:true
44
- (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"));
47
+ (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"));
45
48
  }
46
49
  static loaderOptions() {
47
50
  return {
@@ -84,7 +87,7 @@ function getEventBuilder(viewer, input) {
84
87
  for (const key in input) {
85
88
  m.set(key, input[key]);
86
89
  }
87
- return new builder_1.SimpleBuilder(viewer, exports.FakeEventSchema, m);
90
+ return new builder_1.SimpleBuilder(viewer, exports.FakeEventSchema, m, action_1.WriteOperation.Insert, null);
88
91
  }
89
92
  exports.getEventBuilder = getEventBuilder;
90
93
  async function createEvent(viewer, input) {
@@ -0,0 +1,35 @@
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
+ static getFields(): string[];
18
+ static getTestTable(): import("../db/temp_db").Table;
19
+ static loaderOptions(): LoadEntOptions<FakeTag>;
20
+ static load(v: Viewer, id: ID): Promise<FakeTag | null>;
21
+ static loadX(v: Viewer, id: ID): Promise<FakeTag>;
22
+ }
23
+ export declare const FakeTagSchema: import("../builder").BuilderSchema<FakeTag>;
24
+ export interface TagCreateInput {
25
+ displayName: string;
26
+ canonicalName: string;
27
+ ownerID: ID;
28
+ createdAt?: Date;
29
+ updatedAt?: Date;
30
+ }
31
+ export declare type TagEditInput = Partial<TagCreateInput>;
32
+ export declare function getTagBuilder(viewer: Viewer, input: TagCreateInput): import("../builder").SimpleBuilder<FakeTag, null>;
33
+ export declare function getTagAction(viewer: Viewer, input: TagCreateInput): SimpleAction<FakeTag, null>;
34
+ export declare function createTag(viewer: Viewer, input: TagCreateInput): Promise<FakeTag>;
35
+ export declare const tagLoader: ObjectLoaderFactory<unknown>;
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.tagLoader = exports.createTag = exports.getTagAction = exports.getTagBuilder = exports.FakeTagSchema = exports.FakeTag = void 0;
4
+ const ent_1 = require("../../core/ent");
5
+ const privacy_1 = require("../../core/privacy");
6
+ const builder_1 = require("../builder");
7
+ const schema_1 = require("../../schema");
8
+ const const_1 = require("./const");
9
+ const temp_db_1 = require("../db/temp_db");
10
+ const loaders_1 = require("../../core/loaders");
11
+ const convert_1 = require("../../core/convert");
12
+ const action_1 = require("../../action");
13
+ class FakeTag {
14
+ constructor(viewer, data) {
15
+ this.viewer = viewer;
16
+ this.nodeType = const_1.NodeType.FakeUser;
17
+ this.data = data;
18
+ this.id = data.id;
19
+ this.createdAt = (0, convert_1.convertDate)(data.created_at);
20
+ this.updatedAt = (0, convert_1.convertDate)(data.updated_at);
21
+ this.displayName = data.display_name;
22
+ this.canonicalName = data.canonical_name;
23
+ this.ownerID = data.owner_id;
24
+ }
25
+ getPrivacyPolicy() {
26
+ return {
27
+ rules: [new privacy_1.AllowIfViewerIsEntPropertyRule("ownerID"), privacy_1.AlwaysDenyRule],
28
+ };
29
+ }
30
+ static getFields() {
31
+ return [
32
+ "id",
33
+ "created_at",
34
+ "updated_at",
35
+ "display_name",
36
+ "canonical_name",
37
+ "owner_id",
38
+ ];
39
+ }
40
+ static getTestTable() {
41
+ return (0, temp_db_1.table)("fake_tags", (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)("display_name"), (0, temp_db_1.text)("canonical_name"), (0, temp_db_1.uuid)("owner_id"), // TODO index: true sqlite broken?
42
+ (0, temp_db_1.index)("fake_tags", ["canonical_name", "owner_id"], { unique: true }));
43
+ }
44
+ static loaderOptions() {
45
+ return {
46
+ tableName: "fake_tags",
47
+ fields: FakeTag.getFields(),
48
+ ent: this,
49
+ loaderFactory: exports.tagLoader,
50
+ };
51
+ }
52
+ static async load(v, id) {
53
+ return (0, ent_1.loadEnt)(v, id, FakeTag.loaderOptions());
54
+ }
55
+ static async loadX(v, id) {
56
+ return (0, ent_1.loadEntX)(v, id, FakeTag.loaderOptions());
57
+ }
58
+ }
59
+ exports.FakeTag = FakeTag;
60
+ exports.FakeTagSchema = (0, builder_1.getBuilderSchemaFromFields)({
61
+ displayName: (0, schema_1.StringType)(),
62
+ canonicalName: (0, schema_1.StringType)().trim().toLowerCase(),
63
+ ownerID: (0, schema_1.UUIDType)({}),
64
+ }, FakeTag);
65
+ function getTagBuilder(viewer, input) {
66
+ const action = getTagAction(viewer, input);
67
+ return action.builder;
68
+ }
69
+ exports.getTagBuilder = getTagBuilder;
70
+ function getTagAction(viewer, input) {
71
+ const m = new Map();
72
+ for (const key in input) {
73
+ m.set(key, input[key]);
74
+ }
75
+ const action = new builder_1.SimpleAction(viewer, exports.FakeTagSchema, m, action_1.WriteOperation.Insert, null);
76
+ return action;
77
+ }
78
+ exports.getTagAction = getTagAction;
79
+ async function createTag(viewer, input) {
80
+ const action = getTagAction(viewer, input);
81
+ return action.saveX();
82
+ }
83
+ exports.createTag = createTag;
84
+ exports.tagLoader = new loaders_1.ObjectLoaderFactory({
85
+ tableName: "fake_tags",
86
+ fields: FakeTag.getFields(),
87
+ key: "id",
88
+ });
@@ -23,10 +23,10 @@ export declare class FakeUser implements Ent {
23
23
  readonly emailAddress: string;
24
24
  readonly phoneNumber: string | null;
25
25
  protected readonly password: string | null;
26
- privacyPolicy: PrivacyPolicy;
26
+ getPrivacyPolicy(): PrivacyPolicy<this>;
27
27
  constructor(viewer: Viewer, data: Data);
28
28
  static getFields(): string[];
29
- static getTestTable(): import("../db/test_db").Table;
29
+ static getTestTable(): import("../db/temp_db").Table;
30
30
  static loaderOptions(): LoadEntOptions<FakeUser>;
31
31
  static load(v: Viewer, id: ID): Promise<FakeUser | null>;
32
32
  static loadX(v: Viewer, id: ID): Promise<FakeUser>;
@@ -38,10 +38,12 @@ export interface UserCreateInput {
38
38
  emailAddress: string;
39
39
  phoneNumber: string | null;
40
40
  password: string | null;
41
+ createdAt?: Date;
42
+ updatedAt?: Date;
41
43
  }
42
44
  export declare type UserEditInput = Partial<UserCreateInput>;
43
- export declare function getUserBuilder(viewer: Viewer, input: UserCreateInput): import("../builder").SimpleBuilder<FakeUser>;
44
- export declare function getUserAction(viewer: Viewer, input: UserCreateInput): SimpleAction<FakeUser>;
45
+ export declare function getUserBuilder(viewer: Viewer, input: UserCreateInput): import("../builder").SimpleBuilder<FakeUser, null>;
46
+ export declare function getUserAction(viewer: Viewer, input: UserCreateInput): SimpleAction<FakeUser, null>;
45
47
  export declare function createUser(viewer: Viewer, input: UserCreateInput): Promise<FakeUser>;
46
48
  export declare const userLoader: ObjectLoaderFactory<unknown>;
47
49
  export declare const userEmailLoader: ObjectLoaderFactory<unknown>;
@@ -8,9 +8,10 @@ const schema_1 = require("../../schema");
8
8
  const internal_1 = require("./internal");
9
9
  const const_1 = require("./const");
10
10
  const viewer_1 = require("../../core/viewer");
11
- const test_db_1 = require("../db/test_db");
11
+ const temp_db_1 = require("../db/temp_db");
12
12
  const loaders_1 = require("../../core/loaders");
13
13
  const convert_1 = require("../../core/convert");
14
+ const action_1 = require("../../action");
14
15
  class ViewerWithAccessToken extends viewer_1.IDViewer {
15
16
  constructor(viewerID, opts) {
16
17
  super(viewerID, opts);
@@ -26,7 +27,18 @@ class FakeUser {
26
27
  constructor(viewer, data) {
27
28
  this.viewer = viewer;
28
29
  this.nodeType = const_1.NodeType.FakeUser;
29
- this.privacyPolicy = {
30
+ this.data = data;
31
+ this.id = data.id;
32
+ this.createdAt = (0, convert_1.convertDate)(data.created_at);
33
+ this.updatedAt = (0, convert_1.convertDate)(data.updated_at);
34
+ this.firstName = data.first_name;
35
+ this.lastName = data.last_name;
36
+ this.emailAddress = data.email_address;
37
+ this.phoneNumber = data.phone_number;
38
+ this.password = data.password;
39
+ }
40
+ getPrivacyPolicy() {
41
+ return {
30
42
  rules: [
31
43
  privacy_1.AllowIfViewerRule,
32
44
  //can view user if friends
@@ -48,15 +60,6 @@ class FakeUser {
48
60
  privacy_1.AlwaysDenyRule,
49
61
  ],
50
62
  };
51
- this.data = data;
52
- this.id = data.id;
53
- this.createdAt = (0, convert_1.convertDate)(data.created_at);
54
- this.updatedAt = (0, convert_1.convertDate)(data.updated_at);
55
- this.firstName = data.first_name;
56
- this.lastName = data.last_name;
57
- this.emailAddress = data.email_address;
58
- this.phoneNumber = data.phone_number;
59
- this.password = data.password;
60
63
  }
61
64
  static getFields() {
62
65
  return [
@@ -71,7 +74,7 @@ class FakeUser {
71
74
  ];
72
75
  }
73
76
  static getTestTable() {
74
- return (0, test_db_1.table)("fake_users", (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.text)("phone_number"), (0, test_db_1.text)("password"));
77
+ return (0, temp_db_1.table)("fake_users", (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.text)("phone_number"), (0, temp_db_1.text)("password"));
75
78
  }
76
79
  static loaderOptions() {
77
80
  return {
@@ -108,7 +111,7 @@ function getUserAction(viewer, input) {
108
111
  for (const key in input) {
109
112
  m.set(key, input[key]);
110
113
  }
111
- const action = new builder_1.SimpleAction(viewer, exports.FakeUserSchema, m);
114
+ const action = new builder_1.SimpleAction(viewer, exports.FakeUserSchema, m, action_1.WriteOperation.Insert, null);
112
115
  action.viewerForEntLoad = (data) => {
113
116
  // load the created ent using a VC of the newly created user.
114
117
  return new viewer_1.IDViewer(data.id);
@@ -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];
@@ -2,5 +2,7 @@ export * from "./const";
2
2
  export * from "./fake_contact";
3
3
  export * from "./fake_user";
4
4
  export * from "./fake_event";
5
+ export * from "./fake_tag";
5
6
  export * from "./events_query";
6
7
  export * from "./user_query";
8
+ export * from "./tag_query";
@@ -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];
@@ -14,5 +18,7 @@ __exportStar(require("./const"), exports);
14
18
  __exportStar(require("./fake_contact"), exports);
15
19
  __exportStar(require("./fake_user"), exports);
16
20
  __exportStar(require("./fake_event"), exports);
21
+ __exportStar(require("./fake_tag"), exports);
17
22
  __exportStar(require("./events_query"), exports);
18
23
  __exportStar(require("./user_query"), exports);
24
+ __exportStar(require("./tag_query"), exports);
@@ -0,0 +1,13 @@
1
+ import { ID, Viewer } from "../../core/base";
2
+ import { CustomEdgeQueryBase } from "../../core/query/custom_query";
3
+ import { FakeUser, FakeTag } from "./internal";
4
+ export declare class UserToTagsFkeyQuery extends CustomEdgeQueryBase<FakeUser, FakeTag> {
5
+ constructor(viewer: Viewer, src: ID | FakeUser);
6
+ static query(viewer: Viewer, src: FakeUser | ID): UserToTagsFkeyQuery;
7
+ sourceEnt(id: ID): Promise<FakeUser | null>;
8
+ }
9
+ export declare class UserToTagsFkeyQueryAsc extends CustomEdgeQueryBase<FakeUser, FakeTag> {
10
+ constructor(viewer: Viewer, src: ID | FakeUser);
11
+ static query(viewer: Viewer, src: FakeUser | ID): UserToTagsFkeyQueryAsc;
12
+ sourceEnt(id: ID): Promise<FakeUser | null>;
13
+ }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UserToTagsFkeyQueryAsc = exports.UserToTagsFkeyQuery = void 0;
4
+ const custom_query_1 = require("../../core/query/custom_query");
5
+ const internal_1 = require("./internal");
6
+ class UserToTagsFkeyQuery extends custom_query_1.CustomEdgeQueryBase {
7
+ constructor(viewer, src) {
8
+ super(viewer, {
9
+ src,
10
+ loadEntOptions: internal_1.FakeTag.loaderOptions(),
11
+ groupCol: "owner_id",
12
+ name: "user_to_tags",
13
+ sortColumn: "canonical_name",
14
+ sortColumnUnique: true,
15
+ });
16
+ }
17
+ static query(viewer, src) {
18
+ return new UserToTagsFkeyQuery(viewer, src);
19
+ }
20
+ sourceEnt(id) {
21
+ return internal_1.FakeUser.load(this.viewer, id);
22
+ }
23
+ }
24
+ exports.UserToTagsFkeyQuery = UserToTagsFkeyQuery;
25
+ class UserToTagsFkeyQueryAsc extends custom_query_1.CustomEdgeQueryBase {
26
+ constructor(viewer, src) {
27
+ super(viewer, {
28
+ src,
29
+ loadEntOptions: internal_1.FakeTag.loaderOptions(),
30
+ groupCol: "owner_id",
31
+ name: "user_to_tags_asc",
32
+ sortColumn: "canonical_name ASC",
33
+ sortColumnUnique: true,
34
+ });
35
+ }
36
+ static query(viewer, src) {
37
+ return new UserToTagsFkeyQueryAsc(viewer, src);
38
+ }
39
+ sourceEnt(id) {
40
+ return internal_1.FakeUser.load(this.viewer, id);
41
+ }
42
+ }
43
+ exports.UserToTagsFkeyQueryAsc = UserToTagsFkeyQueryAsc;
@@ -1,6 +1,6 @@
1
1
  import { Data, Ent } from "../../core/base";
2
2
  import { AssocEdge } from "../../core/ent";
3
- import { TempDB } from "../db/test_db";
3
+ import { TempDB } from "../db/temp_db";
4
4
  import { FakeUser, UserCreateInput, ContactCreateInput, FakeContact } from ".";
5
5
  import { EventCreateInput, FakeEvent } from "./fake_event";
6
6
  import { BuilderSchema } from "../builder";
@@ -9,7 +9,13 @@ export declare function getUserInput(input?: Partial<UserCreateInput>): UserCrea
9
9
  export declare function getEventInput(user: FakeUser, input?: Partial<EventCreateInput>): EventCreateInput;
10
10
  export declare function createTestUser(input?: Partial<UserCreateInput>): Promise<FakeUser>;
11
11
  export declare const inputs: Partial<ContactCreateInput>[];
12
- export declare function createAllContacts(input?: Partial<UserCreateInput>, slice?: number): Promise<[FakeUser, FakeContact[]]>;
12
+ interface createContactOptions {
13
+ input?: Partial<UserCreateInput>;
14
+ slice?: number;
15
+ user?: FakeUser;
16
+ start?: number;
17
+ }
18
+ export declare function createAllContacts(opts?: createContactOptions): Promise<[FakeUser, FakeContact[]]>;
13
19
  export declare function createUserPlusFriendRequests(input?: Partial<UserCreateInput>, slice?: number): Promise<[FakeUser, FakeUser[]]>;
14
20
  export declare function addEdge<T extends Ent>(source: T, schema: BuilderSchema<T>, edgeType: string, inbound: boolean, // inbound or outbound
15
21
  ...dest: Ent[]): Promise<void>;
@@ -19,13 +25,14 @@ export declare function verifyUserToContacts(user: FakeUser, ents: FakeContact[]
19
25
  export declare function createEdges(): Promise<void>;
20
26
  export declare function edgeTableNames(): string[];
21
27
  export declare function createTestEvent(user: FakeUser, input?: Partial<EventCreateInput>): Promise<FakeEvent>;
22
- export declare function setupTempDB(): Promise<TempDB>;
23
- export declare function tempDBTables(): import("../db/test_db").Table[];
28
+ export declare function setupTempDB(global?: boolean): Promise<TempDB>;
29
+ export declare function tempDBTables(global?: boolean): import("../db/temp_db").Table[];
24
30
  interface options {
25
31
  howMany: number;
26
32
  interval: number;
27
33
  userInput?: Partial<UserCreateInput>;
28
34
  eventInputs?: Partial<EventCreateInput>[];
35
+ startTime?: number | Date;
29
36
  }
30
37
  export declare function createAllEvents(opts: options): Promise<[FakeUser, FakeEvent[]]>;
31
38
  export {};