@snowtop/ent 0.1.0-alpha3 → 0.1.0-alpha30
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 +28 -24
- package/action/executor.d.ts +4 -4
- package/action/executor.js +2 -2
- package/action/experimental_action.d.ts +21 -20
- package/action/experimental_action.js +11 -5
- package/action/orchestrator.d.ts +31 -16
- package/action/orchestrator.js +156 -43
- package/action/privacy.d.ts +2 -2
- package/core/base.d.ts +25 -21
- package/core/base.js +16 -0
- package/core/clause.d.ts +24 -3
- package/core/clause.js +246 -5
- package/core/config.d.ts +23 -0
- package/core/config.js +17 -0
- package/core/context.d.ts +2 -2
- package/core/convert.d.ts +1 -1
- package/core/db.d.ts +3 -3
- package/core/db.js +2 -0
- package/core/ent.d.ts +19 -21
- package/core/ent.js +76 -25
- package/core/loaders/assoc_count_loader.d.ts +2 -2
- package/core/loaders/assoc_edge_loader.d.ts +3 -3
- package/core/loaders/assoc_edge_loader.js +5 -4
- package/core/loaders/index_loader.js +1 -0
- package/core/loaders/object_loader.d.ts +10 -5
- package/core/loaders/object_loader.js +59 -4
- package/core/loaders/query_loader.d.ts +2 -2
- package/core/loaders/raw_count_loader.d.ts +2 -2
- package/core/privacy.d.ts +25 -25
- package/core/privacy.js +3 -0
- package/core/query/assoc_query.d.ts +6 -6
- package/core/query/custom_query.d.ts +5 -5
- package/core/query/query.d.ts +1 -1
- package/core/viewer.d.ts +4 -3
- package/core/viewer.js +4 -0
- package/graphql/builtins/connection.js +3 -3
- package/graphql/builtins/edge.js +2 -2
- package/graphql/builtins/node.js +1 -1
- package/graphql/graphql.d.ts +3 -2
- package/graphql/graphql.js +24 -23
- package/graphql/index.d.ts +1 -0
- package/graphql/index.js +3 -1
- package/graphql/mutations/union.d.ts +2 -0
- package/graphql/mutations/union.js +35 -0
- package/graphql/node_resolver.d.ts +0 -1
- package/graphql/query/connection_type.js +6 -6
- package/graphql/query/edge_connection.d.ts +9 -9
- package/graphql/query/page_info.d.ts +1 -1
- package/graphql/query/page_info.js +4 -4
- package/graphql/query/shared_assoc_test.js +2 -2
- package/graphql/scalars/time.d.ts +1 -1
- package/index.d.ts +16 -1
- package/index.js +18 -5
- package/package.json +3 -3
- package/parse_schema/parse.d.ts +18 -5
- package/parse_schema/parse.js +55 -6
- package/schema/base_schema.d.ts +36 -1
- package/schema/base_schema.js +51 -2
- package/schema/field.d.ts +1 -1
- package/schema/field.js +1 -1
- package/schema/index.d.ts +2 -2
- package/schema/index.js +8 -1
- package/schema/schema.d.ts +61 -1
- package/schema/schema.js +126 -5
- package/schema/union_field.d.ts +2 -1
- package/schema/union_field.js +32 -14
- package/scripts/custom_graphql.js +122 -15
- package/scripts/{transform_schema.d.ts → migrate_v0.1.d.ts} +0 -0
- package/scripts/migrate_v0.1.js +36 -0
- package/scripts/read_schema.js +15 -1
- package/testutils/builder.d.ts +31 -21
- package/testutils/builder.js +98 -13
- package/testutils/context/test_context.d.ts +2 -2
- package/testutils/context/test_context.js +7 -1
- package/testutils/db/test_db.d.ts +2 -1
- package/testutils/db/test_db.js +13 -4
- package/testutils/ent-graphql-tests/index.d.ts +2 -0
- package/testutils/ent-graphql-tests/index.js +26 -17
- package/testutils/fake_data/fake_contact.d.ts +4 -8
- package/testutils/fake_data/fake_contact.js +15 -19
- package/testutils/fake_data/fake_event.d.ts +4 -8
- package/testutils/fake_data/fake_event.js +21 -25
- package/testutils/fake_data/fake_user.d.ts +5 -9
- package/testutils/fake_data/fake_user.js +23 -27
- package/testutils/fake_data/test_helpers.js +1 -1
- package/testutils/fake_data/user_query.d.ts +2 -2
- package/testutils/fake_log.d.ts +3 -3
- package/tsc/ast.d.ts +43 -0
- package/tsc/ast.js +264 -0
- package/tsc/compilerOptions.d.ts +6 -0
- package/tsc/compilerOptions.js +40 -1
- package/tsc/move_generated.d.ts +1 -0
- package/tsc/move_generated.js +160 -0
- package/tsc/transform.d.ts +21 -0
- package/tsc/transform.js +167 -0
- package/tsc/transform_action.d.ts +20 -0
- package/tsc/transform_action.js +169 -0
- package/tsc/transform_ent.d.ts +17 -0
- package/tsc/transform_ent.js +59 -0
- package/tsc/transform_schema.d.ts +27 -0
- package/tsc/transform_schema.js +354 -0
- package/scripts/transform_schema.js +0 -288
|
@@ -26,7 +26,7 @@ exports.expectMutation = exports.expectQueryFromRoot = void 0;
|
|
|
26
26
|
// NB: this is copied from ent-graphql-tests package until I have time to figure out how to share code here effectively
|
|
27
27
|
// the circular dependencies btw this package and ent-graphql-tests seems to imply something needs to change
|
|
28
28
|
const express_1 = __importDefault(require("express"));
|
|
29
|
-
const
|
|
29
|
+
const graphql_helix_1 = require("graphql-helix");
|
|
30
30
|
const graphql_1 = require("graphql");
|
|
31
31
|
const auth_1 = require("../../auth");
|
|
32
32
|
const supertest_1 = __importDefault(require("supertest"));
|
|
@@ -45,18 +45,23 @@ function server(config) {
|
|
|
45
45
|
if (config.init) {
|
|
46
46
|
config.init(app);
|
|
47
47
|
}
|
|
48
|
+
app.use(express_1.default.json());
|
|
48
49
|
let handlers = config.customHandlers || [];
|
|
49
|
-
handlers.push(
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
50
|
+
handlers.push(async (req, res) => {
|
|
51
|
+
const { operationName, query, variables } = (0, graphql_helix_1.getGraphQLParameters)(req);
|
|
52
|
+
const result = await (0, graphql_helix_1.processRequest)({
|
|
53
|
+
operationName,
|
|
54
|
+
query,
|
|
55
|
+
variables,
|
|
56
|
+
request: req,
|
|
57
|
+
schema: config.schema,
|
|
58
|
+
contextFactory: async (executionContext) => {
|
|
59
|
+
return (0, auth_1.buildContext)(req, res);
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
await (0, graphql_helix_1.sendResult)(result, res);
|
|
63
|
+
});
|
|
64
|
+
app.use(config.graphQLPath || "/graphql", ...handlers);
|
|
60
65
|
return app;
|
|
61
66
|
}
|
|
62
67
|
function getInnerType(typ, list) {
|
|
@@ -72,14 +77,14 @@ function makeGraphQLRequest(config, query, fieldArgs) {
|
|
|
72
77
|
let test;
|
|
73
78
|
if (config.test) {
|
|
74
79
|
if (typeof config.test === "function") {
|
|
75
|
-
test = config.test(server(config));
|
|
80
|
+
test = config.test(config.server ? config.server : server(config));
|
|
76
81
|
}
|
|
77
82
|
else {
|
|
78
83
|
test = config.test;
|
|
79
84
|
}
|
|
80
85
|
}
|
|
81
86
|
else {
|
|
82
|
-
test = (0, supertest_1.default)(server(config));
|
|
87
|
+
test = (0, supertest_1.default)(config.server ? config.server : server(config));
|
|
83
88
|
}
|
|
84
89
|
let files = new Map();
|
|
85
90
|
// handle files
|
|
@@ -104,7 +109,9 @@ function makeGraphQLRequest(config, query, fieldArgs) {
|
|
|
104
109
|
}
|
|
105
110
|
});
|
|
106
111
|
if (files.size) {
|
|
107
|
-
let ret = test
|
|
112
|
+
let ret = test
|
|
113
|
+
.post(config.graphQLPath || "/graphql")
|
|
114
|
+
.set(config.headers || {});
|
|
108
115
|
ret.field("operations", JSON.stringify({
|
|
109
116
|
query: query,
|
|
110
117
|
variables: config.args,
|
|
@@ -130,7 +137,7 @@ function makeGraphQLRequest(config, query, fieldArgs) {
|
|
|
130
137
|
return [
|
|
131
138
|
test,
|
|
132
139
|
test
|
|
133
|
-
.post("/graphql")
|
|
140
|
+
.post(config.graphQLPath || "/graphql")
|
|
134
141
|
.set(config.headers || {})
|
|
135
142
|
.send({
|
|
136
143
|
query: query,
|
|
@@ -353,7 +360,9 @@ async function expectFromRoot(config, ...options) {
|
|
|
353
360
|
else {
|
|
354
361
|
expect(res.ok, `expected ok response. instead got ${res.status} and result ${JSON.stringify(res.body)}`);
|
|
355
362
|
}
|
|
356
|
-
|
|
363
|
+
// res.ok = true in graphql-helix when there's errors...
|
|
364
|
+
// res.ok = false in express-graphql when there's errors...
|
|
365
|
+
if (!res.ok || (res.body.errors && res.body.errors.length > 0)) {
|
|
357
366
|
let errors = res.body.errors;
|
|
358
367
|
expect(errors.length).toBeGreaterThan(0);
|
|
359
368
|
if (config.expectedError) {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ID, Ent, Viewer, Data, LoadEntOptions, PrivacyPolicy } from "../../core/base";
|
|
2
|
-
import {
|
|
3
|
-
import { BaseEntSchema, FieldMap } from "../../schema";
|
|
2
|
+
import { SimpleBuilder } from "../builder";
|
|
4
3
|
import { NodeType } from "./const";
|
|
5
4
|
import { ObjectLoaderFactory } from "../../core/loaders";
|
|
6
5
|
export declare class FakeContact implements Ent {
|
|
@@ -14,7 +13,7 @@ export declare class FakeContact implements Ent {
|
|
|
14
13
|
readonly lastName: string;
|
|
15
14
|
readonly emailAddress: string;
|
|
16
15
|
readonly userID: ID;
|
|
17
|
-
|
|
16
|
+
getPrivacyPolicy(): PrivacyPolicy<this>;
|
|
18
17
|
constructor(viewer: Viewer, data: Data);
|
|
19
18
|
static getFields(): string[];
|
|
20
19
|
static getTestTable(): import("../db/test_db").Table;
|
|
@@ -22,16 +21,13 @@ export declare class FakeContact implements Ent {
|
|
|
22
21
|
static load(v: Viewer, id: ID): Promise<FakeContact | null>;
|
|
23
22
|
static loadX(v: Viewer, id: ID): Promise<FakeContact>;
|
|
24
23
|
}
|
|
25
|
-
export declare
|
|
26
|
-
ent: typeof FakeContact;
|
|
27
|
-
fields: FieldMap;
|
|
28
|
-
}
|
|
24
|
+
export declare const FakeContactSchema: import("../builder").BuilderSchema<FakeContact>;
|
|
29
25
|
export interface ContactCreateInput {
|
|
30
26
|
firstName: string;
|
|
31
27
|
lastName: string;
|
|
32
28
|
emailAddress: string;
|
|
33
29
|
userID: ID;
|
|
34
30
|
}
|
|
35
|
-
export declare function getContactBuilder(viewer: Viewer, input: ContactCreateInput): SimpleBuilder<FakeContact>;
|
|
31
|
+
export declare function getContactBuilder(viewer: Viewer, input: ContactCreateInput): SimpleBuilder<FakeContact, null>;
|
|
36
32
|
export declare function createContact(viewer: Viewer, input: ContactCreateInput): Promise<void>;
|
|
37
33
|
export declare const contactLoader: ObjectLoaderFactory<unknown>;
|
|
@@ -9,13 +9,11 @@ const const_1 = require("./const");
|
|
|
9
9
|
const test_db_1 = require("../db/test_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",
|
|
@@ -59,21 +62,14 @@ class FakeContact {
|
|
|
59
62
|
}
|
|
60
63
|
}
|
|
61
64
|
exports.FakeContact = FakeContact;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
userID: (0, schema_1.UUIDType)({
|
|
71
|
-
foreignKey: { schema: "User", column: "ID" },
|
|
72
|
-
}),
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
exports.FakeContactSchema = FakeContactSchema;
|
|
65
|
+
exports.FakeContactSchema = (0, builder_1.getBuilderSchemaFromFields)({
|
|
66
|
+
firstName: (0, schema_1.StringType)(),
|
|
67
|
+
lastName: (0, schema_1.StringType)(),
|
|
68
|
+
emailAddress: (0, schema_1.StringType)(),
|
|
69
|
+
userID: (0, schema_1.UUIDType)({
|
|
70
|
+
foreignKey: { schema: "User", column: "ID" },
|
|
71
|
+
}),
|
|
72
|
+
}, FakeContact);
|
|
77
73
|
function getContactBuilder(viewer, input) {
|
|
78
74
|
const m = new Map();
|
|
79
75
|
for (const key in input) {
|
|
@@ -82,7 +78,7 @@ function getContactBuilder(viewer, input) {
|
|
|
82
78
|
//To lock in the value of Date now incase of advanceTo/advanceBy
|
|
83
79
|
m.set("createdAt", new Date());
|
|
84
80
|
m.set("updatedAt", new Date());
|
|
85
|
-
return new builder_1.SimpleBuilder(viewer,
|
|
81
|
+
return new builder_1.SimpleBuilder(viewer, exports.FakeContactSchema, m, action_1.WriteOperation.Insert, null);
|
|
86
82
|
}
|
|
87
83
|
exports.getContactBuilder = getContactBuilder;
|
|
88
84
|
async function createContact(viewer, input) {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ID, Ent, Viewer, Data, LoadEntOptions, PrivacyPolicy } from "../../core/base";
|
|
2
|
-
import {
|
|
3
|
-
import { BaseEntSchema, FieldMap } from "../../schema";
|
|
2
|
+
import { SimpleBuilder } from "../builder";
|
|
4
3
|
import { NodeType } from "./const";
|
|
5
4
|
export declare class FakeEvent implements Ent {
|
|
6
5
|
viewer: Viewer;
|
|
@@ -15,7 +14,7 @@ export declare class FakeEvent implements Ent {
|
|
|
15
14
|
readonly title: string;
|
|
16
15
|
readonly description: string | null;
|
|
17
16
|
readonly userID: ID;
|
|
18
|
-
|
|
17
|
+
getPrivacyPolicy(): PrivacyPolicy<this>;
|
|
19
18
|
constructor(viewer: Viewer, data: Data);
|
|
20
19
|
private static getFields;
|
|
21
20
|
static getTestTable(): import("../db/test_db").Table;
|
|
@@ -23,10 +22,7 @@ export declare class FakeEvent implements Ent {
|
|
|
23
22
|
static load(v: Viewer, id: ID): Promise<FakeEvent | null>;
|
|
24
23
|
static loadX(v: Viewer, id: ID): Promise<FakeEvent>;
|
|
25
24
|
}
|
|
26
|
-
export declare
|
|
27
|
-
ent: typeof FakeEvent;
|
|
28
|
-
fields: FieldMap;
|
|
29
|
-
}
|
|
25
|
+
export declare const FakeEventSchema: import("../builder").BuilderSchema<FakeEvent>;
|
|
30
26
|
export interface EventCreateInput {
|
|
31
27
|
startTime: Date;
|
|
32
28
|
endTime?: Date | null;
|
|
@@ -35,5 +31,5 @@ export interface EventCreateInput {
|
|
|
35
31
|
description?: string | null;
|
|
36
32
|
userID: ID;
|
|
37
33
|
}
|
|
38
|
-
export declare function getEventBuilder(viewer: Viewer, input: EventCreateInput): SimpleBuilder<FakeEvent>;
|
|
34
|
+
export declare function getEventBuilder(viewer: Viewer, input: EventCreateInput): SimpleBuilder<FakeEvent, null>;
|
|
39
35
|
export declare function createEvent(viewer: Viewer, input: EventCreateInput): Promise<void>;
|
|
@@ -9,11 +9,11 @@ const const_1 = require("./const");
|
|
|
9
9
|
const test_db_1 = require("../db/test_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",
|
|
@@ -63,35 +66,28 @@ class FakeEvent {
|
|
|
63
66
|
}
|
|
64
67
|
}
|
|
65
68
|
exports.FakeEvent = FakeEvent;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
userID: (0, schema_1.UUIDType)({
|
|
83
|
-
foreignKey: { schema: "User", column: "ID" },
|
|
84
|
-
}),
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
exports.FakeEventSchema = FakeEventSchema;
|
|
69
|
+
exports.FakeEventSchema = (0, builder_1.getBuilderSchemaFromFields)({
|
|
70
|
+
startTime: (0, schema_1.TimestampType)({
|
|
71
|
+
index: true,
|
|
72
|
+
}),
|
|
73
|
+
endTime: (0, schema_1.TimestampType)({
|
|
74
|
+
nullable: true,
|
|
75
|
+
}),
|
|
76
|
+
title: (0, schema_1.StringType)(),
|
|
77
|
+
location: (0, schema_1.StringType)(),
|
|
78
|
+
description: (0, schema_1.StringType)({
|
|
79
|
+
nullable: true,
|
|
80
|
+
}),
|
|
81
|
+
userID: (0, schema_1.UUIDType)({
|
|
82
|
+
foreignKey: { schema: "User", column: "ID" },
|
|
83
|
+
}),
|
|
84
|
+
}, FakeEvent);
|
|
89
85
|
function getEventBuilder(viewer, input) {
|
|
90
86
|
const m = new Map();
|
|
91
87
|
for (const key in input) {
|
|
92
88
|
m.set(key, input[key]);
|
|
93
89
|
}
|
|
94
|
-
return new builder_1.SimpleBuilder(viewer,
|
|
90
|
+
return new builder_1.SimpleBuilder(viewer, exports.FakeEventSchema, m, action_1.WriteOperation.Insert, null);
|
|
95
91
|
}
|
|
96
92
|
exports.getEventBuilder = getEventBuilder;
|
|
97
93
|
async function createEvent(viewer, input) {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ID, Ent, Viewer, Data, LoadEntOptions, PrivacyPolicy } from "../../core/base";
|
|
2
|
-
import {
|
|
3
|
-
import { BaseEntSchema, FieldMap } from "../../schema";
|
|
2
|
+
import { SimpleAction } from "../builder";
|
|
4
3
|
import { NodeType } from "./const";
|
|
5
4
|
import { IDViewer, IDViewerOptions } from "../../core/viewer";
|
|
6
5
|
import { ObjectLoaderFactory } from "../../core/loaders";
|
|
@@ -24,7 +23,7 @@ export declare class FakeUser implements Ent {
|
|
|
24
23
|
readonly emailAddress: string;
|
|
25
24
|
readonly phoneNumber: string | null;
|
|
26
25
|
protected readonly password: string | null;
|
|
27
|
-
|
|
26
|
+
getPrivacyPolicy(): PrivacyPolicy<this>;
|
|
28
27
|
constructor(viewer: Viewer, data: Data);
|
|
29
28
|
static getFields(): string[];
|
|
30
29
|
static getTestTable(): import("../db/test_db").Table;
|
|
@@ -32,10 +31,7 @@ export declare class FakeUser implements Ent {
|
|
|
32
31
|
static load(v: Viewer, id: ID): Promise<FakeUser | null>;
|
|
33
32
|
static loadX(v: Viewer, id: ID): Promise<FakeUser>;
|
|
34
33
|
}
|
|
35
|
-
export declare
|
|
36
|
-
ent: typeof FakeUser;
|
|
37
|
-
fields: FieldMap;
|
|
38
|
-
}
|
|
34
|
+
export declare const FakeUserSchema: import("../builder").BuilderSchema<FakeUser>;
|
|
39
35
|
export interface UserCreateInput {
|
|
40
36
|
firstName: string;
|
|
41
37
|
lastName: string;
|
|
@@ -44,8 +40,8 @@ export interface UserCreateInput {
|
|
|
44
40
|
password: string | null;
|
|
45
41
|
}
|
|
46
42
|
export declare type UserEditInput = Partial<UserCreateInput>;
|
|
47
|
-
export declare function getUserBuilder(viewer: Viewer, input: UserCreateInput): import("../builder").SimpleBuilder<FakeUser>;
|
|
48
|
-
export declare function getUserAction(viewer: Viewer, input: UserCreateInput): SimpleAction<FakeUser>;
|
|
43
|
+
export declare function getUserBuilder(viewer: Viewer, input: UserCreateInput): import("../builder").SimpleBuilder<FakeUser, null>;
|
|
44
|
+
export declare function getUserAction(viewer: Viewer, input: UserCreateInput): SimpleAction<FakeUser, null>;
|
|
49
45
|
export declare function createUser(viewer: Viewer, input: UserCreateInput): Promise<FakeUser>;
|
|
50
46
|
export declare const userLoader: ObjectLoaderFactory<unknown>;
|
|
51
47
|
export declare const userEmailLoader: ObjectLoaderFactory<unknown>;
|
|
@@ -11,6 +11,7 @@ const viewer_1 = require("../../core/viewer");
|
|
|
11
11
|
const test_db_1 = require("../db/test_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.
|
|
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 [
|
|
@@ -89,22 +92,15 @@ class FakeUser {
|
|
|
89
92
|
}
|
|
90
93
|
}
|
|
91
94
|
exports.FakeUser = FakeUser;
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
password: (0, schema_1.StringType)({
|
|
102
|
-
nullable: true,
|
|
103
|
-
}),
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
exports.FakeUserSchema = FakeUserSchema;
|
|
95
|
+
exports.FakeUserSchema = (0, builder_1.getBuilderSchemaFromFields)({
|
|
96
|
+
firstName: (0, schema_1.StringType)(),
|
|
97
|
+
lastName: (0, schema_1.StringType)(),
|
|
98
|
+
emailAddress: (0, schema_1.StringType)(),
|
|
99
|
+
phoneNumber: (0, schema_1.StringType)(),
|
|
100
|
+
password: (0, schema_1.StringType)({
|
|
101
|
+
nullable: true,
|
|
102
|
+
}),
|
|
103
|
+
}, FakeUser);
|
|
108
104
|
function getUserBuilder(viewer, input) {
|
|
109
105
|
const action = getUserAction(viewer, input);
|
|
110
106
|
return action.builder;
|
|
@@ -115,7 +111,7 @@ function getUserAction(viewer, input) {
|
|
|
115
111
|
for (const key in input) {
|
|
116
112
|
m.set(key, input[key]);
|
|
117
113
|
}
|
|
118
|
-
const action = new builder_1.SimpleAction(viewer,
|
|
114
|
+
const action = new builder_1.SimpleAction(viewer, exports.FakeUserSchema, m, action_1.WriteOperation.Insert, null);
|
|
119
115
|
action.viewerForEntLoad = (data) => {
|
|
120
116
|
// load the created ent using a VC of the newly created user.
|
|
121
117
|
return new viewer_1.IDViewer(data.id);
|
|
@@ -107,7 +107,7 @@ async function createUserPlusFriendRequests(input, slice) {
|
|
|
107
107
|
return createTestUser(input);
|
|
108
108
|
}));
|
|
109
109
|
expect(friendRequests.length).toBe(userInputs.length);
|
|
110
|
-
await addEdge(user,
|
|
110
|
+
await addEdge(user, _1.FakeUserSchema, _1.EdgeType.UserToFriendRequests, true, ...friendRequests);
|
|
111
111
|
return [user, friendRequests];
|
|
112
112
|
}
|
|
113
113
|
exports.createUserPlusFriendRequests = createUserPlusFriendRequests;
|
|
@@ -53,7 +53,7 @@ export declare class UserToFriendRequestsQuery extends AssocEdgeQueryBase<FakeUs
|
|
|
53
53
|
}
|
|
54
54
|
export declare class UserToIncomingFriendRequestsQuery extends AssocEdgeQueryBase<FakeUser, FakeUser, AssocEdge> {
|
|
55
55
|
constructor(viewer: Viewer, src: EdgeQuerySource<FakeUser, FakeUser>);
|
|
56
|
-
getPrivacyPolicy(): import("../../core/base").PrivacyPolicy<Ent
|
|
56
|
+
getPrivacyPolicy(): import("../../core/base").PrivacyPolicy<Ent<Viewer<Ent<any> | null, ID | null>>, Viewer<Ent<any> | null, ID | null>>;
|
|
57
57
|
sourceEnt(id: ID): Promise<FakeUser | null>;
|
|
58
58
|
static query(viewer: Viewer, src: EdgeQuerySource<FakeUser, FakeUser>): UserToIncomingFriendRequestsQuery;
|
|
59
59
|
queryContacts(): UserToContactsQuery;
|
|
@@ -90,7 +90,7 @@ export declare class UserToEventsInNextWeekQuery extends CustomEdgeQueryBase<Fak
|
|
|
90
90
|
constructor(viewer: Viewer, src: ID | FakeUser);
|
|
91
91
|
static query(viewer: Viewer, src: FakeUser | ID): UserToEventsInNextWeekQuery;
|
|
92
92
|
sourceEnt(id: ID): Promise<FakeUser | null>;
|
|
93
|
-
getPrivacyPolicy(): import("../../core/base").PrivacyPolicy<Ent
|
|
93
|
+
getPrivacyPolicy(): import("../../core/base").PrivacyPolicy<Ent<Viewer<Ent<any> | null, ID | null>>, Viewer<Ent<any> | null, ID | null>>;
|
|
94
94
|
}
|
|
95
95
|
export declare class UserToFollowingQuery extends AssocEdgeQueryBase<FakeUser, Ent, AssocEdge> {
|
|
96
96
|
constructor(viewer: Viewer, src: EdgeQuerySource<FakeUser, FakeUser>);
|
package/testutils/fake_log.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Ent } from "../core/base";
|
|
1
|
+
import { Ent, Viewer } from "../core/base";
|
|
2
2
|
import { Builder } from "./../action";
|
|
3
3
|
export declare class FakeLogger {
|
|
4
4
|
private static logs;
|
|
@@ -8,6 +8,6 @@ export declare class FakeLogger {
|
|
|
8
8
|
static contains(line: string): boolean;
|
|
9
9
|
static clear(): void;
|
|
10
10
|
}
|
|
11
|
-
export declare class EntCreationObserver<
|
|
12
|
-
observe(builder: Builder<
|
|
11
|
+
export declare class EntCreationObserver<TEnt extends Ent<TViewer>, TViewer extends Viewer = Viewer> {
|
|
12
|
+
observe(builder: Builder<TEnt, TViewer>): Promise<void>;
|
|
13
13
|
}
|
package/tsc/ast.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
export declare function getPreText(fileContents: string, node: ts.Node, sourceFile: ts.SourceFile): string;
|
|
3
|
+
export interface ClassInfo {
|
|
4
|
+
extends?: string;
|
|
5
|
+
comment: string;
|
|
6
|
+
name: string;
|
|
7
|
+
export?: boolean;
|
|
8
|
+
default?: boolean;
|
|
9
|
+
implements?: string[];
|
|
10
|
+
wrapClassContents(inner: string): string;
|
|
11
|
+
}
|
|
12
|
+
export declare function getClassInfo(fileContents: string, sourceFile: ts.SourceFile, node: ts.ClassDeclaration): ClassInfo | undefined;
|
|
13
|
+
declare type transformImportFn = (imp: string) => string;
|
|
14
|
+
interface transformOpts {
|
|
15
|
+
removeImports?: string[];
|
|
16
|
+
newImports?: string[];
|
|
17
|
+
transform?: transformImportFn;
|
|
18
|
+
transformPath: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function transformImport(fileContents: string, importNode: ts.ImportDeclaration, sourceFile: ts.SourceFile, opts: transformOpts): string | undefined;
|
|
21
|
+
export declare function updateImportPath(fileContents: string, importNode: ts.ImportDeclaration, sourceFile: ts.SourceFile, newPath: string): string | undefined;
|
|
22
|
+
export declare function isRelativeImport(node: ts.ImportDeclaration, sourceFile: ts.SourceFile): boolean;
|
|
23
|
+
export declare function isRelativeGeneratedImport(node: ts.ImportDeclaration, sourceFile: ts.SourceFile): boolean;
|
|
24
|
+
export declare function isSrcGeneratedImport(node: ts.ImportDeclaration, sourceFile: ts.SourceFile): boolean;
|
|
25
|
+
interface importInfo {
|
|
26
|
+
imports: string[];
|
|
27
|
+
start: number;
|
|
28
|
+
end: number;
|
|
29
|
+
importText: string;
|
|
30
|
+
importPath: string;
|
|
31
|
+
default?: string;
|
|
32
|
+
}
|
|
33
|
+
export declare function getImportInfo(imp: ts.ImportDeclaration, sourceFile: ts.SourceFile): importInfo | undefined;
|
|
34
|
+
export declare function transformRelative(file: string, importPath: string, relative?: boolean): string;
|
|
35
|
+
export interface customInfo {
|
|
36
|
+
viewerInfo: {
|
|
37
|
+
path: string;
|
|
38
|
+
name: string;
|
|
39
|
+
};
|
|
40
|
+
relativeImports?: boolean;
|
|
41
|
+
}
|
|
42
|
+
export declare function getCustomInfo(): customInfo;
|
|
43
|
+
export {};
|