@snowtop/ent 0.1.0-alpha16 → 0.1.0-alpha160-test2
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.
- package/action/action.d.ts +25 -14
- package/action/action.js +22 -7
- package/action/executor.d.ts +16 -3
- package/action/executor.js +89 -28
- package/action/experimental_action.d.ts +25 -16
- package/action/experimental_action.js +34 -14
- package/action/index.d.ts +4 -1
- package/action/index.js +7 -1
- package/action/operations.d.ts +126 -0
- package/action/operations.js +686 -0
- package/action/orchestrator.d.ts +43 -12
- package/action/orchestrator.js +461 -101
- package/action/relative_value.d.ts +47 -0
- package/action/relative_value.js +125 -0
- package/action/transaction.d.ts +10 -0
- package/action/transaction.js +23 -0
- package/auth/auth.d.ts +1 -1
- package/core/base.d.ts +56 -23
- package/core/base.js +7 -1
- package/core/clause.d.ts +103 -39
- package/core/clause.js +430 -66
- package/core/config.d.ts +13 -3
- package/core/config.js +10 -1
- package/core/const.d.ts +3 -0
- package/core/const.js +6 -0
- package/core/context.d.ts +6 -3
- package/core/context.js +22 -3
- package/core/convert.d.ts +1 -1
- package/core/date.js +1 -5
- package/core/db.d.ts +12 -8
- package/core/db.js +21 -9
- package/core/ent.d.ts +99 -95
- package/core/ent.js +550 -602
- package/core/global_schema.d.ts +7 -0
- package/core/global_schema.js +51 -0
- package/core/loaders/assoc_count_loader.d.ts +5 -2
- package/core/loaders/assoc_count_loader.js +19 -3
- package/core/loaders/assoc_edge_loader.d.ts +2 -3
- package/core/loaders/assoc_edge_loader.js +23 -17
- package/core/loaders/index.d.ts +1 -2
- package/core/loaders/index.js +1 -5
- package/core/loaders/loader.d.ts +3 -3
- package/core/loaders/loader.js +4 -21
- package/core/loaders/object_loader.d.ts +30 -9
- package/core/loaders/object_loader.js +226 -79
- package/core/loaders/query_loader.d.ts +7 -13
- package/core/loaders/query_loader.js +60 -24
- package/core/loaders/raw_count_loader.d.ts +1 -0
- package/core/loaders/raw_count_loader.js +8 -3
- package/core/logger.d.ts +1 -1
- package/core/logger.js +1 -0
- package/core/privacy.d.ts +26 -16
- package/core/privacy.js +68 -51
- package/core/query/assoc_query.d.ts +3 -2
- package/core/query/assoc_query.js +10 -2
- package/core/query/custom_clause_query.d.ts +29 -0
- package/core/query/custom_clause_query.js +105 -0
- package/core/query/custom_query.d.ts +19 -2
- package/core/query/custom_query.js +111 -13
- package/core/query/index.d.ts +1 -0
- package/core/query/index.js +3 -1
- package/core/query/query.d.ts +18 -4
- package/core/query/query.js +135 -58
- package/core/query/shared_assoc_test.d.ts +2 -1
- package/core/query/shared_assoc_test.js +186 -55
- package/core/query/shared_test.d.ts +9 -2
- package/core/query/shared_test.js +529 -236
- package/core/query_impl.d.ts +8 -0
- package/core/query_impl.js +28 -0
- package/core/viewer.d.ts +2 -0
- package/core/viewer.js +3 -1
- package/graphql/graphql.d.ts +108 -22
- package/graphql/graphql.js +183 -137
- package/graphql/graphql_field_helpers.d.ts +9 -3
- package/graphql/graphql_field_helpers.js +22 -2
- package/graphql/index.d.ts +2 -2
- package/graphql/index.js +5 -5
- package/graphql/query/connection_type.d.ts +9 -9
- package/graphql/query/shared_assoc_test.js +1 -1
- package/graphql/query/shared_edge_connection.js +1 -19
- package/graphql/scalars/orderby_direction.d.ts +2 -0
- package/graphql/scalars/orderby_direction.js +15 -0
- package/imports/dataz/example1/_auth.js +128 -47
- package/imports/dataz/example1/_viewer.js +87 -39
- package/imports/index.d.ts +7 -2
- package/imports/index.js +20 -5
- package/index.d.ts +23 -5
- package/index.js +35 -10
- package/package.json +20 -19
- package/parse_schema/parse.d.ts +33 -9
- package/parse_schema/parse.js +182 -33
- package/schema/base_schema.d.ts +13 -3
- package/schema/base_schema.js +13 -0
- package/schema/field.d.ts +78 -21
- package/schema/field.js +232 -72
- package/schema/index.d.ts +2 -2
- package/schema/index.js +7 -2
- package/schema/json_field.d.ts +16 -4
- package/schema/json_field.js +32 -2
- package/schema/schema.d.ts +109 -20
- package/schema/schema.js +42 -53
- package/schema/struct_field.d.ts +15 -3
- package/schema/struct_field.js +117 -22
- package/schema/union_field.d.ts +1 -1
- package/scripts/custom_compiler.js +12 -8
- package/scripts/custom_graphql.js +167 -64
- package/scripts/migrate_v0.1.js +36 -0
- package/scripts/move_types.js +120 -0
- package/scripts/read_schema.js +22 -7
- package/testutils/action/complex_schemas.d.ts +69 -0
- package/testutils/action/complex_schemas.js +405 -0
- package/testutils/builder.d.ts +37 -41
- package/testutils/builder.js +66 -46
- package/testutils/db/fixture.d.ts +10 -0
- package/testutils/db/fixture.js +26 -0
- package/testutils/db/{test_db.d.ts → temp_db.d.ts} +32 -8
- package/testutils/db/{test_db.js → temp_db.js} +251 -48
- package/testutils/db/value.d.ts +7 -0
- package/testutils/db/value.js +251 -0
- package/testutils/db_mock.d.ts +16 -4
- package/testutils/db_mock.js +52 -9
- package/testutils/db_time_zone.d.ts +4 -0
- package/testutils/db_time_zone.js +41 -0
- package/testutils/ent-graphql-tests/index.d.ts +7 -1
- package/testutils/ent-graphql-tests/index.js +56 -26
- package/testutils/fake_comms.js +1 -1
- package/testutils/fake_data/const.d.ts +2 -1
- package/testutils/fake_data/const.js +3 -0
- package/testutils/fake_data/fake_contact.d.ts +7 -3
- package/testutils/fake_data/fake_contact.js +13 -7
- package/testutils/fake_data/fake_event.d.ts +4 -1
- package/testutils/fake_data/fake_event.js +7 -6
- package/testutils/fake_data/fake_tag.d.ts +36 -0
- package/testutils/fake_data/fake_tag.js +89 -0
- package/testutils/fake_data/fake_user.d.ts +8 -5
- package/testutils/fake_data/fake_user.js +31 -19
- package/testutils/fake_data/index.js +5 -1
- package/testutils/fake_data/internal.d.ts +2 -0
- package/testutils/fake_data/internal.js +7 -1
- package/testutils/fake_data/tag_query.d.ts +13 -0
- package/testutils/fake_data/tag_query.js +48 -0
- package/testutils/fake_data/test_helpers.d.ts +14 -6
- package/testutils/fake_data/test_helpers.js +31 -15
- package/testutils/fake_data/user_query.d.ts +16 -6
- package/testutils/fake_data/user_query.js +72 -23
- package/testutils/fake_log.js +1 -1
- package/testutils/parse_sql.d.ts +6 -0
- package/testutils/parse_sql.js +16 -2
- package/testutils/test_edge_global_schema.d.ts +15 -0
- package/testutils/test_edge_global_schema.js +62 -0
- package/testutils/write.d.ts +2 -2
- package/testutils/write.js +33 -7
- package/tsc/ast.d.ts +15 -3
- package/tsc/ast.js +114 -23
- package/tsc/compilerOptions.js +5 -1
- package/tsc/move_generated.d.ts +1 -0
- package/tsc/move_generated.js +164 -0
- package/tsc/transform.d.ts +22 -0
- package/tsc/transform.js +182 -0
- package/tsc/transform_action.d.ts +22 -0
- package/tsc/transform_action.js +183 -0
- package/tsc/transform_ent.d.ts +17 -0
- package/tsc/transform_ent.js +60 -0
- package/tsc/transform_schema.d.ts +27 -0
- package/{scripts → tsc}/transform_schema.js +146 -117
- package/core/loaders/index_loader.d.ts +0 -14
- package/core/loaders/index_loader.js +0 -27
- package/graphql/enums.d.ts +0 -3
- package/graphql/enums.js +0 -25
- package/scripts/move_generated.js +0 -141
- package/scripts/transform_actions.js +0 -266
- package/scripts/transform_code.d.ts +0 -1
- package/scripts/transform_code.js +0 -111
- package/scripts/transform_schema.d.ts +0 -1
- /package/scripts/{move_generated.d.ts → migrate_v0.1.d.ts} +0 -0
- /package/scripts/{transform_actions.d.ts → move_types.d.ts} +0 -0
|
@@ -18,7 +18,8 @@ export declare enum EdgeType {
|
|
|
18
18
|
export declare enum NodeType {
|
|
19
19
|
FakeUser = "user",
|
|
20
20
|
FakeContact = "contact",
|
|
21
|
-
FakeEvent = "event"
|
|
21
|
+
FakeEvent = "event",
|
|
22
|
+
FakeTag = "tag"
|
|
22
23
|
}
|
|
23
24
|
export declare const SymmetricEdges: Set<string>;
|
|
24
25
|
export declare const InverseEdges: Map<EdgeType, EdgeType>;
|
|
@@ -27,6 +27,7 @@ var NodeType;
|
|
|
27
27
|
NodeType["FakeUser"] = "user";
|
|
28
28
|
NodeType["FakeContact"] = "contact";
|
|
29
29
|
NodeType["FakeEvent"] = "event";
|
|
30
|
+
NodeType["FakeTag"] = "tag";
|
|
30
31
|
})(NodeType = exports.NodeType || (exports.NodeType = {}));
|
|
31
32
|
exports.SymmetricEdges = new Set();
|
|
32
33
|
exports.SymmetricEdges.add(EdgeType.UserToFriends);
|
|
@@ -48,6 +49,8 @@ function getLoaderOptions(type) {
|
|
|
48
49
|
return internal_1.FakeUser.loaderOptions();
|
|
49
50
|
case NodeType.FakeEvent:
|
|
50
51
|
return internal_1.FakeEvent.loaderOptions();
|
|
52
|
+
case NodeType.FakeTag:
|
|
53
|
+
return internal_1.FakeTag.loaderOptions();
|
|
51
54
|
}
|
|
52
55
|
}
|
|
53
56
|
exports.getLoaderOptions = getLoaderOptions;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ID, Ent, Viewer, Data, LoadEntOptions, PrivacyPolicy } from "../../core/base";
|
|
1
|
+
import { ID, Ent, Viewer, Data, LoadEntOptions, PrivacyPolicy, Context } from "../../core/base";
|
|
2
2
|
import { SimpleBuilder } from "../builder";
|
|
3
3
|
import { NodeType } from "./const";
|
|
4
4
|
import { ObjectLoaderFactory } from "../../core/loaders";
|
|
@@ -15,11 +15,13 @@ export declare class FakeContact implements Ent {
|
|
|
15
15
|
readonly userID: ID;
|
|
16
16
|
getPrivacyPolicy(): PrivacyPolicy<this>;
|
|
17
17
|
constructor(viewer: Viewer, data: Data);
|
|
18
|
+
__setRawDBData(data: Data): void;
|
|
18
19
|
static getFields(): string[];
|
|
19
|
-
static getTestTable(): import("../db/
|
|
20
|
+
static getTestTable(): import("../db/temp_db").Table;
|
|
20
21
|
static loaderOptions(): LoadEntOptions<FakeContact>;
|
|
21
22
|
static load(v: Viewer, id: ID): Promise<FakeContact | null>;
|
|
22
23
|
static loadX(v: Viewer, id: ID): Promise<FakeContact>;
|
|
24
|
+
static loadRawData(id: ID, context?: Context): Promise<Data | null>;
|
|
23
25
|
}
|
|
24
26
|
export declare const FakeContactSchema: import("../builder").BuilderSchema<FakeContact>;
|
|
25
27
|
export interface ContactCreateInput {
|
|
@@ -27,7 +29,9 @@ export interface ContactCreateInput {
|
|
|
27
29
|
lastName: string;
|
|
28
30
|
emailAddress: string;
|
|
29
31
|
userID: ID;
|
|
32
|
+
createdAt?: Date;
|
|
33
|
+
updatedAt?: Date;
|
|
30
34
|
}
|
|
31
35
|
export declare function getContactBuilder(viewer: Viewer, input: ContactCreateInput): SimpleBuilder<FakeContact, null>;
|
|
32
36
|
export declare function createContact(viewer: Viewer, input: ContactCreateInput): Promise<void>;
|
|
33
|
-
export declare const contactLoader: ObjectLoaderFactory<
|
|
37
|
+
export declare const contactLoader: ObjectLoaderFactory<Data>;
|
|
@@ -6,11 +6,16 @@ const privacy_1 = require("../../core/privacy");
|
|
|
6
6
|
const builder_1 = require("../builder");
|
|
7
7
|
const schema_1 = require("../../schema");
|
|
8
8
|
const const_1 = require("./const");
|
|
9
|
-
const
|
|
9
|
+
const temp_db_1 = require("../db/temp_db");
|
|
10
10
|
const loaders_1 = require("../../core/loaders");
|
|
11
11
|
const convert_1 = require("../../core/convert");
|
|
12
12
|
const action_1 = require("../../action");
|
|
13
13
|
class FakeContact {
|
|
14
|
+
getPrivacyPolicy() {
|
|
15
|
+
return {
|
|
16
|
+
rules: [new privacy_1.AllowIfViewerIsRule("userID"), privacy_1.AlwaysDenyRule],
|
|
17
|
+
};
|
|
18
|
+
}
|
|
14
19
|
constructor(viewer, data) {
|
|
15
20
|
this.viewer = viewer;
|
|
16
21
|
this.nodeType = const_1.NodeType.FakeContact;
|
|
@@ -23,11 +28,7 @@ class FakeContact {
|
|
|
23
28
|
this.emailAddress = data.email_address;
|
|
24
29
|
this.userID = data.user_id;
|
|
25
30
|
}
|
|
26
|
-
|
|
27
|
-
return {
|
|
28
|
-
rules: [new privacy_1.AllowIfViewerIsRule("userID"), privacy_1.AlwaysDenyRule],
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
+
__setRawDBData(data) { }
|
|
31
32
|
static getFields() {
|
|
32
33
|
return [
|
|
33
34
|
"id",
|
|
@@ -40,7 +41,7 @@ class FakeContact {
|
|
|
40
41
|
];
|
|
41
42
|
}
|
|
42
43
|
static getTestTable() {
|
|
43
|
-
return (0,
|
|
44
|
+
return (0, temp_db_1.table)("fake_contacts", (0, temp_db_1.uuid)("id", { primaryKey: true }), (0, temp_db_1.timestamptz)("created_at"), (0, temp_db_1.timestamptz)("updated_at"), (0, temp_db_1.text)("first_name"), (0, temp_db_1.text)("last_name"), (0, temp_db_1.text)("email_address"), (0, temp_db_1.uuid)("user_id"));
|
|
44
45
|
}
|
|
45
46
|
static loaderOptions() {
|
|
46
47
|
return {
|
|
@@ -60,6 +61,11 @@ class FakeContact {
|
|
|
60
61
|
static async loadX(v, id) {
|
|
61
62
|
return (0, ent_1.loadEntX)(v, id, FakeContact.loaderOptions());
|
|
62
63
|
}
|
|
64
|
+
static async loadRawData(id, context) {
|
|
65
|
+
return FakeContact.loaderOptions()
|
|
66
|
+
.loaderFactory.createLoader(context)
|
|
67
|
+
.load(id);
|
|
68
|
+
}
|
|
63
69
|
}
|
|
64
70
|
exports.FakeContact = FakeContact;
|
|
65
71
|
exports.FakeContactSchema = (0, builder_1.getBuilderSchemaFromFields)({
|
|
@@ -16,14 +16,17 @@ export declare class FakeEvent implements Ent {
|
|
|
16
16
|
readonly userID: ID;
|
|
17
17
|
getPrivacyPolicy(): PrivacyPolicy<this>;
|
|
18
18
|
constructor(viewer: Viewer, data: Data);
|
|
19
|
+
__setRawDBData(data: Data): void;
|
|
19
20
|
private static getFields;
|
|
20
|
-
static getTestTable(): import("../db/
|
|
21
|
+
static getTestTable(): import("../db/temp_db").Table;
|
|
21
22
|
static loaderOptions(): LoadEntOptions<FakeEvent>;
|
|
22
23
|
static load(v: Viewer, id: ID): Promise<FakeEvent | null>;
|
|
23
24
|
static loadX(v: Viewer, id: ID): Promise<FakeEvent>;
|
|
24
25
|
}
|
|
25
26
|
export declare const FakeEventSchema: import("../builder").BuilderSchema<FakeEvent>;
|
|
26
27
|
export interface EventCreateInput {
|
|
28
|
+
createdAt?: Date;
|
|
29
|
+
updatedAt?: Date;
|
|
27
30
|
startTime: Date;
|
|
28
31
|
endTime?: Date | null;
|
|
29
32
|
location: string;
|
|
@@ -6,11 +6,14 @@ const privacy_1 = require("../../core/privacy");
|
|
|
6
6
|
const builder_1 = require("../builder");
|
|
7
7
|
const schema_1 = require("../../schema");
|
|
8
8
|
const const_1 = require("./const");
|
|
9
|
-
const
|
|
9
|
+
const temp_db_1 = require("../db/temp_db");
|
|
10
10
|
const loaders_1 = require("../../core/loaders");
|
|
11
11
|
const convert_1 = require("../../core/convert");
|
|
12
12
|
const action_1 = require("../../action");
|
|
13
13
|
class FakeEvent {
|
|
14
|
+
getPrivacyPolicy() {
|
|
15
|
+
return privacy_1.AlwaysAllowPrivacyPolicy;
|
|
16
|
+
}
|
|
14
17
|
constructor(viewer, data) {
|
|
15
18
|
this.viewer = viewer;
|
|
16
19
|
this.nodeType = const_1.NodeType.FakeEvent;
|
|
@@ -25,9 +28,7 @@ class FakeEvent {
|
|
|
25
28
|
this.description = data.description;
|
|
26
29
|
this.userID = data.user_id;
|
|
27
30
|
}
|
|
28
|
-
|
|
29
|
-
return privacy_1.AlwaysAllowPrivacyPolicy;
|
|
30
|
-
}
|
|
31
|
+
__setRawDBData(data) { }
|
|
31
32
|
static getFields() {
|
|
32
33
|
return [
|
|
33
34
|
"id",
|
|
@@ -42,9 +43,9 @@ class FakeEvent {
|
|
|
42
43
|
];
|
|
43
44
|
}
|
|
44
45
|
static getTestTable() {
|
|
45
|
-
return (0,
|
|
46
|
+
return (0, temp_db_1.table)("fake_events", (0, temp_db_1.uuid)("id", { primaryKey: true }), (0, temp_db_1.timestamptz)("created_at"), (0, temp_db_1.timestamptz)("updated_at"),
|
|
46
47
|
// TODO index:true
|
|
47
|
-
(0,
|
|
48
|
+
(0, temp_db_1.timestamptz)("start_time"), (0, temp_db_1.timestamptz)("end_time", { nullable: true }), (0, temp_db_1.text)("location"), (0, temp_db_1.text)("title"), (0, temp_db_1.text)("description", { nullable: true }), (0, temp_db_1.uuid)("user_id"));
|
|
48
49
|
}
|
|
49
50
|
static loaderOptions() {
|
|
50
51
|
return {
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ID, Ent, Viewer, Data, LoadEntOptions, PrivacyPolicy } from "../../core/base";
|
|
2
|
+
import { SimpleAction } from "../builder";
|
|
3
|
+
import { NodeType } from "./const";
|
|
4
|
+
import { ObjectLoaderFactory } from "../../core/loaders";
|
|
5
|
+
export declare class FakeTag implements Ent {
|
|
6
|
+
viewer: Viewer;
|
|
7
|
+
readonly id: ID;
|
|
8
|
+
readonly data: Data;
|
|
9
|
+
readonly nodeType = NodeType.FakeUser;
|
|
10
|
+
readonly createdAt: Date;
|
|
11
|
+
readonly updatedAt: Date;
|
|
12
|
+
readonly displayName: string;
|
|
13
|
+
readonly canonicalName: string;
|
|
14
|
+
readonly ownerID: string;
|
|
15
|
+
getPrivacyPolicy(): PrivacyPolicy<this>;
|
|
16
|
+
constructor(viewer: Viewer, data: Data);
|
|
17
|
+
__setRawDBData(data: Data): void;
|
|
18
|
+
static getFields(): string[];
|
|
19
|
+
static getTestTable(): import("../db/temp_db").Table;
|
|
20
|
+
static loaderOptions(): LoadEntOptions<FakeTag>;
|
|
21
|
+
static load(v: Viewer, id: ID): Promise<FakeTag | null>;
|
|
22
|
+
static loadX(v: Viewer, id: ID): Promise<FakeTag>;
|
|
23
|
+
}
|
|
24
|
+
export declare const FakeTagSchema: import("../builder").BuilderSchema<FakeTag>;
|
|
25
|
+
export interface TagCreateInput {
|
|
26
|
+
displayName: string;
|
|
27
|
+
canonicalName: string;
|
|
28
|
+
ownerID: ID;
|
|
29
|
+
createdAt?: Date;
|
|
30
|
+
updatedAt?: Date;
|
|
31
|
+
}
|
|
32
|
+
export type TagEditInput = Partial<TagCreateInput>;
|
|
33
|
+
export declare function getTagBuilder(viewer: Viewer, input: TagCreateInput): import("../builder").SimpleBuilder<FakeTag, null>;
|
|
34
|
+
export declare function getTagAction(viewer: Viewer, input: TagCreateInput): SimpleAction<FakeTag, null>;
|
|
35
|
+
export declare function createTag(viewer: Viewer, input: TagCreateInput): Promise<FakeTag>;
|
|
36
|
+
export declare const tagLoader: ObjectLoaderFactory<Data>;
|
|
@@ -0,0 +1,89 @@
|
|
|
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
|
+
getPrivacyPolicy() {
|
|
15
|
+
return {
|
|
16
|
+
rules: [new privacy_1.AllowIfViewerIsEntPropertyRule("ownerID"), privacy_1.AlwaysDenyRule],
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
constructor(viewer, data) {
|
|
20
|
+
this.viewer = viewer;
|
|
21
|
+
this.nodeType = const_1.NodeType.FakeUser;
|
|
22
|
+
this.data = data;
|
|
23
|
+
this.id = data.id;
|
|
24
|
+
this.createdAt = (0, convert_1.convertDate)(data.created_at);
|
|
25
|
+
this.updatedAt = (0, convert_1.convertDate)(data.updated_at);
|
|
26
|
+
this.displayName = data.display_name;
|
|
27
|
+
this.canonicalName = data.canonical_name;
|
|
28
|
+
this.ownerID = data.owner_id;
|
|
29
|
+
}
|
|
30
|
+
__setRawDBData(data) { }
|
|
31
|
+
static getFields() {
|
|
32
|
+
return [
|
|
33
|
+
"id",
|
|
34
|
+
"created_at",
|
|
35
|
+
"updated_at",
|
|
36
|
+
"display_name",
|
|
37
|
+
"canonical_name",
|
|
38
|
+
"owner_id",
|
|
39
|
+
];
|
|
40
|
+
}
|
|
41
|
+
static getTestTable() {
|
|
42
|
+
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?
|
|
43
|
+
(0, temp_db_1.index)("fake_tags", ["canonical_name", "owner_id"], { unique: true }));
|
|
44
|
+
}
|
|
45
|
+
static loaderOptions() {
|
|
46
|
+
return {
|
|
47
|
+
tableName: "fake_tags",
|
|
48
|
+
fields: FakeTag.getFields(),
|
|
49
|
+
ent: this,
|
|
50
|
+
loaderFactory: exports.tagLoader,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
static async load(v, id) {
|
|
54
|
+
return (0, ent_1.loadEnt)(v, id, FakeTag.loaderOptions());
|
|
55
|
+
}
|
|
56
|
+
static async loadX(v, id) {
|
|
57
|
+
return (0, ent_1.loadEntX)(v, id, FakeTag.loaderOptions());
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.FakeTag = FakeTag;
|
|
61
|
+
exports.FakeTagSchema = (0, builder_1.getBuilderSchemaFromFields)({
|
|
62
|
+
displayName: (0, schema_1.StringType)(),
|
|
63
|
+
canonicalName: (0, schema_1.StringType)().trim().toLowerCase(),
|
|
64
|
+
ownerID: (0, schema_1.UUIDType)({}),
|
|
65
|
+
}, FakeTag);
|
|
66
|
+
function getTagBuilder(viewer, input) {
|
|
67
|
+
const action = getTagAction(viewer, input);
|
|
68
|
+
return action.builder;
|
|
69
|
+
}
|
|
70
|
+
exports.getTagBuilder = getTagBuilder;
|
|
71
|
+
function getTagAction(viewer, input) {
|
|
72
|
+
const m = new Map();
|
|
73
|
+
for (const key in input) {
|
|
74
|
+
m.set(key, input[key]);
|
|
75
|
+
}
|
|
76
|
+
const action = new builder_1.SimpleAction(viewer, exports.FakeTagSchema, m, action_1.WriteOperation.Insert, null);
|
|
77
|
+
return action;
|
|
78
|
+
}
|
|
79
|
+
exports.getTagAction = getTagAction;
|
|
80
|
+
async function createTag(viewer, input) {
|
|
81
|
+
const action = getTagAction(viewer, input);
|
|
82
|
+
return action.saveX();
|
|
83
|
+
}
|
|
84
|
+
exports.createTag = createTag;
|
|
85
|
+
exports.tagLoader = new loaders_1.ObjectLoaderFactory({
|
|
86
|
+
tableName: "fake_tags",
|
|
87
|
+
fields: FakeTag.getFields(),
|
|
88
|
+
key: "id",
|
|
89
|
+
});
|
|
@@ -25,8 +25,9 @@ export declare class FakeUser implements Ent {
|
|
|
25
25
|
protected readonly password: string | null;
|
|
26
26
|
getPrivacyPolicy(): PrivacyPolicy<this>;
|
|
27
27
|
constructor(viewer: Viewer, data: Data);
|
|
28
|
+
__setRawDBData(data: Data): void;
|
|
28
29
|
static getFields(): string[];
|
|
29
|
-
static getTestTable(): import("../db/
|
|
30
|
+
static getTestTable(): import("../db/temp_db").Table;
|
|
30
31
|
static loaderOptions(): LoadEntOptions<FakeUser>;
|
|
31
32
|
static load(v: Viewer, id: ID): Promise<FakeUser | null>;
|
|
32
33
|
static loadX(v: Viewer, id: ID): Promise<FakeUser>;
|
|
@@ -38,12 +39,14 @@ export interface UserCreateInput {
|
|
|
38
39
|
emailAddress: string;
|
|
39
40
|
phoneNumber: string | null;
|
|
40
41
|
password: string | null;
|
|
42
|
+
createdAt?: Date;
|
|
43
|
+
updatedAt?: Date;
|
|
41
44
|
}
|
|
42
|
-
export
|
|
45
|
+
export type UserEditInput = Partial<UserCreateInput>;
|
|
43
46
|
export declare function getUserBuilder(viewer: Viewer, input: UserCreateInput): import("../builder").SimpleBuilder<FakeUser, null>;
|
|
44
47
|
export declare function getUserAction(viewer: Viewer, input: UserCreateInput): SimpleAction<FakeUser, null>;
|
|
45
48
|
export declare function createUser(viewer: Viewer, input: UserCreateInput): Promise<FakeUser>;
|
|
46
|
-
export declare const userLoader: ObjectLoaderFactory<
|
|
47
|
-
export declare const userEmailLoader: ObjectLoaderFactory<
|
|
48
|
-
export declare const userPhoneNumberLoader: ObjectLoaderFactory<
|
|
49
|
+
export declare const userLoader: ObjectLoaderFactory<Data>;
|
|
50
|
+
export declare const userEmailLoader: ObjectLoaderFactory<Data>;
|
|
51
|
+
export declare const userPhoneNumberLoader: ObjectLoaderFactory<Data>;
|
|
49
52
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.userPhoneNumberLoader = exports.userEmailLoader = exports.userLoader = exports.createUser = exports.getUserAction = exports.getUserBuilder = exports.FakeUserSchema = exports.FakeUser = exports.ViewerWithAccessToken = void 0;
|
|
4
|
+
const base_1 = require("../../core/base");
|
|
4
5
|
const ent_1 = require("../../core/ent");
|
|
5
6
|
const privacy_1 = require("../../core/privacy");
|
|
6
7
|
const builder_1 = require("../builder");
|
|
@@ -8,7 +9,7 @@ const schema_1 = require("../../schema");
|
|
|
8
9
|
const internal_1 = require("./internal");
|
|
9
10
|
const const_1 = require("./const");
|
|
10
11
|
const viewer_1 = require("../../core/viewer");
|
|
11
|
-
const
|
|
12
|
+
const temp_db_1 = require("../db/temp_db");
|
|
12
13
|
const loaders_1 = require("../../core/loaders");
|
|
13
14
|
const convert_1 = require("../../core/convert");
|
|
14
15
|
const action_1 = require("../../action");
|
|
@@ -24,26 +25,21 @@ class ViewerWithAccessToken extends viewer_1.IDViewer {
|
|
|
24
25
|
}
|
|
25
26
|
exports.ViewerWithAccessToken = ViewerWithAccessToken;
|
|
26
27
|
class FakeUser {
|
|
27
|
-
constructor(viewer, data) {
|
|
28
|
-
this.viewer = viewer;
|
|
29
|
-
this.nodeType = const_1.NodeType.FakeUser;
|
|
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
28
|
getPrivacyPolicy() {
|
|
41
29
|
return {
|
|
42
30
|
rules: [
|
|
43
31
|
privacy_1.AllowIfViewerRule,
|
|
44
|
-
|
|
32
|
+
{
|
|
33
|
+
async apply(v, ent) {
|
|
34
|
+
if (!(v instanceof ViewerWithAccessToken)) {
|
|
35
|
+
return (0, base_1.Skip)();
|
|
36
|
+
}
|
|
37
|
+
return v.hasToken("always_allow_user") ? (0, base_1.Allow)() : (0, base_1.Skip)();
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
// can view user if friends
|
|
45
41
|
new privacy_1.AllowIfViewerInboundEdgeExistsRule(internal_1.EdgeType.UserToFriends),
|
|
46
|
-
//can view user if following
|
|
42
|
+
// can view user if following
|
|
47
43
|
new privacy_1.AllowIfViewerInboundEdgeExistsRule(internal_1.EdgeType.UserToFollowing),
|
|
48
44
|
new privacy_1.AllowIfConditionAppliesRule((viewer, ent) => {
|
|
49
45
|
if (!(viewer instanceof ViewerWithAccessToken)) {
|
|
@@ -61,6 +57,20 @@ class FakeUser {
|
|
|
61
57
|
],
|
|
62
58
|
};
|
|
63
59
|
}
|
|
60
|
+
constructor(viewer, data) {
|
|
61
|
+
this.viewer = viewer;
|
|
62
|
+
this.nodeType = const_1.NodeType.FakeUser;
|
|
63
|
+
this.data = data;
|
|
64
|
+
this.id = data.id;
|
|
65
|
+
this.createdAt = (0, convert_1.convertDate)(data.created_at);
|
|
66
|
+
this.updatedAt = (0, convert_1.convertDate)(data.updated_at);
|
|
67
|
+
this.firstName = data.first_name;
|
|
68
|
+
this.lastName = data.last_name;
|
|
69
|
+
this.emailAddress = data.email_address;
|
|
70
|
+
this.phoneNumber = data.phone_number;
|
|
71
|
+
this.password = data.password;
|
|
72
|
+
}
|
|
73
|
+
__setRawDBData(data) { }
|
|
64
74
|
static getFields() {
|
|
65
75
|
return [
|
|
66
76
|
"id",
|
|
@@ -74,7 +84,7 @@ class FakeUser {
|
|
|
74
84
|
];
|
|
75
85
|
}
|
|
76
86
|
static getTestTable() {
|
|
77
|
-
return (0,
|
|
87
|
+
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"));
|
|
78
88
|
}
|
|
79
89
|
static loaderOptions() {
|
|
80
90
|
return {
|
|
@@ -112,9 +122,11 @@ function getUserAction(viewer, input) {
|
|
|
112
122
|
m.set(key, input[key]);
|
|
113
123
|
}
|
|
114
124
|
const action = new builder_1.SimpleAction(viewer, exports.FakeUserSchema, m, action_1.WriteOperation.Insert, null);
|
|
115
|
-
action.viewerForEntLoad = (data) => {
|
|
125
|
+
action.viewerForEntLoad = (data, context) => {
|
|
116
126
|
// load the created ent using a VC of the newly created user.
|
|
117
|
-
return new viewer_1.IDViewer(data.id
|
|
127
|
+
return new viewer_1.IDViewer(data.id, {
|
|
128
|
+
context,
|
|
129
|
+
});
|
|
118
130
|
};
|
|
119
131
|
return action;
|
|
120
132
|
}
|
|
@@ -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.
|
|
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];
|
|
@@ -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.
|
|
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,48 @@
|
|
|
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
|
+
primarySortColIsUnique: 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
|
+
orderby: [
|
|
33
|
+
{
|
|
34
|
+
column: "canonical_name",
|
|
35
|
+
direction: "ASC",
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
primarySortColIsUnique: true,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
static query(viewer, src) {
|
|
42
|
+
return new UserToTagsFkeyQueryAsc(viewer, src);
|
|
43
|
+
}
|
|
44
|
+
sourceEnt(id) {
|
|
45
|
+
return internal_1.FakeUser.load(this.viewer, id);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.UserToTagsFkeyQueryAsc = UserToTagsFkeyQueryAsc;
|
|
@@ -1,15 +1,22 @@
|
|
|
1
|
-
import { Data, Ent } from "../../core/base";
|
|
1
|
+
import { Context, Data, Ent } from "../../core/base";
|
|
2
2
|
import { AssocEdge } from "../../core/ent";
|
|
3
|
-
import { TempDB } from "../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";
|
|
7
7
|
export declare function getContactInput(user: FakeUser, input?: Partial<ContactCreateInput>): ContactCreateInput;
|
|
8
8
|
export declare function getUserInput(input?: Partial<UserCreateInput>): UserCreateInput;
|
|
9
9
|
export declare function getEventInput(user: FakeUser, input?: Partial<EventCreateInput>): EventCreateInput;
|
|
10
|
-
export declare function createTestUser(input?: Partial<UserCreateInput
|
|
10
|
+
export declare function createTestUser(input?: Partial<UserCreateInput>, ctx?: Context): Promise<FakeUser>;
|
|
11
11
|
export declare const inputs: Partial<ContactCreateInput>[];
|
|
12
|
-
|
|
12
|
+
interface createContactOptions {
|
|
13
|
+
input?: Partial<UserCreateInput>;
|
|
14
|
+
slice?: number;
|
|
15
|
+
user?: FakeUser;
|
|
16
|
+
start?: number;
|
|
17
|
+
ctx?: Context;
|
|
18
|
+
}
|
|
19
|
+
export declare function createAllContacts(opts?: createContactOptions): Promise<[FakeUser, FakeContact[]]>;
|
|
13
20
|
export declare function createUserPlusFriendRequests(input?: Partial<UserCreateInput>, slice?: number): Promise<[FakeUser, FakeUser[]]>;
|
|
14
21
|
export declare function addEdge<T extends Ent>(source: T, schema: BuilderSchema<T>, edgeType: string, inbound: boolean, // inbound or outbound
|
|
15
22
|
...dest: Ent[]): Promise<void>;
|
|
@@ -19,13 +26,14 @@ export declare function verifyUserToContacts(user: FakeUser, ents: FakeContact[]
|
|
|
19
26
|
export declare function createEdges(): Promise<void>;
|
|
20
27
|
export declare function edgeTableNames(): string[];
|
|
21
28
|
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/
|
|
29
|
+
export declare function setupTempDB(global?: boolean): Promise<TempDB>;
|
|
30
|
+
export declare function tempDBTables(global?: boolean): import("../db/temp_db").Table[];
|
|
24
31
|
interface options {
|
|
25
32
|
howMany: number;
|
|
26
33
|
interval: number;
|
|
27
34
|
userInput?: Partial<UserCreateInput>;
|
|
28
35
|
eventInputs?: Partial<EventCreateInput>[];
|
|
36
|
+
startTime?: number | Date;
|
|
29
37
|
}
|
|
30
38
|
export declare function createAllEvents(opts: options): Promise<[FakeUser, FakeEvent[]]>;
|
|
31
39
|
export {};
|