@snowtop/ent 0.0.40-alpha6 → 0.1.0-alpha10
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 +14 -14
- package/action/executor.d.ts +1 -1
- package/action/experimental_action.d.ts +20 -20
- package/action/experimental_action.js +1 -1
- package/action/orchestrator.d.ts +10 -10
- package/action/orchestrator.js +14 -14
- package/core/base.d.ts +6 -6
- package/core/ent.d.ts +2 -1
- package/core/ent.js +14 -10
- package/core/privacy.d.ts +1 -1
- package/core/query/assoc_query.js +2 -2
- package/core/query/query.d.ts +1 -1
- package/graphql/builtins/connection.js +3 -3
- package/graphql/builtins/edge.js +2 -2
- package/graphql/builtins/node.js +1 -1
- package/graphql/graphql.js +2 -2
- 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/query/connection_type.js +6 -6
- 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/imports/index.d.ts +0 -1
- package/imports/index.js +3 -36
- package/package.json +2 -2
- package/parse_schema/parse.d.ts +15 -3
- package/parse_schema/parse.js +42 -7
- package/schema/base_schema.d.ts +36 -1
- package/schema/base_schema.js +63 -17
- package/schema/field.d.ts +25 -25
- package/schema/field.js +42 -33
- package/schema/index.d.ts +4 -2
- package/schema/index.js +5 -1
- package/schema/json_field.d.ts +6 -6
- package/schema/json_field.js +2 -2
- package/schema/schema.d.ts +11 -6
- package/schema/schema.js +46 -12
- package/schema/struct_field.d.ts +17 -0
- package/schema/struct_field.js +102 -0
- package/schema/union_field.d.ts +23 -0
- package/schema/union_field.js +79 -0
- package/scripts/custom_compiler.js +2 -19
- package/scripts/read_schema.js +15 -1
- package/scripts/transform_code.d.ts +1 -0
- package/scripts/transform_code.js +114 -0
- package/scripts/transform_schema.d.ts +1 -0
- package/scripts/transform_schema.js +357 -0
- package/testutils/builder.d.ts +19 -15
- package/testutils/builder.js +41 -7
- package/testutils/db/test_db.js +9 -9
- package/testutils/ent-graphql-tests/index.js +19 -12
- package/testutils/fake_data/fake_contact.d.ts +3 -7
- package/testutils/fake_data/fake_contact.js +14 -26
- package/testutils/fake_data/fake_event.d.ts +3 -7
- package/testutils/fake_data/fake_event.js +20 -33
- package/testutils/fake_data/fake_user.d.ts +3 -7
- package/testutils/fake_data/fake_user.js +22 -36
- package/testutils/fake_data/test_helpers.js +1 -1
- package/testutils/fake_data/user_query.d.ts +2 -2
- package/tsc/ast.d.ts +20 -0
- package/tsc/ast.js +131 -0
- package/tsc/compilerOptions.d.ts +7 -0
- package/tsc/compilerOptions.js +95 -0
package/testutils/builder.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.SimpleAction = exports.SimpleBuilder = exports.getTableName = exports.getSchemaName = exports.Address = exports.Message = exports.Group = exports.Contact = exports.Event = exports.User = void 0;
|
|
6
|
+
exports.SimpleAction = exports.SimpleBuilder = exports.getTableName = exports.getSchemaName = exports.getBuilderSchemaTZFromFields = exports.getBuilderSchemaFromFields = exports.getBuilderSchema = exports.Address = exports.Message = exports.Group = exports.Contact = exports.Event = exports.User = void 0;
|
|
7
7
|
const privacy_1 = require("../core/privacy");
|
|
8
8
|
const orchestrator_1 = require("../action/orchestrator");
|
|
9
9
|
const action_1 = require("../action");
|
|
@@ -14,18 +14,21 @@ const snake_case_1 = require("snake-case");
|
|
|
14
14
|
const loaders_1 = require("../core/loaders");
|
|
15
15
|
const convert_1 = require("../core/convert");
|
|
16
16
|
const camel_case_1 = require("camel-case");
|
|
17
|
+
const base_schema_1 = require("../schema/base_schema");
|
|
17
18
|
class User {
|
|
18
19
|
constructor(viewer, data) {
|
|
19
20
|
this.viewer = viewer;
|
|
20
21
|
this.data = data;
|
|
21
22
|
this.accountID = "";
|
|
22
23
|
this.nodeType = "User";
|
|
23
|
-
this.privacyPolicy = privacy_1.AlwaysAllowPrivacyPolicy;
|
|
24
24
|
this.data.created_at = (0, convert_1.convertDate)(data.created_at);
|
|
25
25
|
this.data.updated_at = (0, convert_1.convertDate)(data.updated_at);
|
|
26
26
|
this.id = data.id;
|
|
27
27
|
this.firstName = data.first_name;
|
|
28
28
|
}
|
|
29
|
+
getPrivacyPolicy() {
|
|
30
|
+
return privacy_1.AlwaysAllowPrivacyPolicy;
|
|
31
|
+
}
|
|
29
32
|
}
|
|
30
33
|
exports.User = User;
|
|
31
34
|
class Event {
|
|
@@ -34,9 +37,11 @@ class Event {
|
|
|
34
37
|
this.data = data;
|
|
35
38
|
this.accountID = "";
|
|
36
39
|
this.nodeType = "Event";
|
|
37
|
-
this.privacyPolicy = privacy_1.AlwaysAllowPrivacyPolicy;
|
|
38
40
|
this.id = data.id;
|
|
39
41
|
}
|
|
42
|
+
getPrivacyPolicy() {
|
|
43
|
+
return privacy_1.AlwaysAllowPrivacyPolicy;
|
|
44
|
+
}
|
|
40
45
|
}
|
|
41
46
|
exports.Event = Event;
|
|
42
47
|
class Contact {
|
|
@@ -45,11 +50,13 @@ class Contact {
|
|
|
45
50
|
this.data = data;
|
|
46
51
|
this.accountID = "";
|
|
47
52
|
this.nodeType = "Contact";
|
|
48
|
-
this.privacyPolicy = privacy_1.AlwaysAllowPrivacyPolicy;
|
|
49
53
|
this.data.created_at = (0, convert_1.convertDate)(data.created_at);
|
|
50
54
|
this.data.updated_at = (0, convert_1.convertDate)(data.updated_at);
|
|
51
55
|
this.id = data.id;
|
|
52
56
|
}
|
|
57
|
+
getPrivacyPolicy() {
|
|
58
|
+
return privacy_1.AlwaysAllowPrivacyPolicy;
|
|
59
|
+
}
|
|
53
60
|
}
|
|
54
61
|
exports.Contact = Contact;
|
|
55
62
|
class Group {
|
|
@@ -58,9 +65,11 @@ class Group {
|
|
|
58
65
|
this.data = data;
|
|
59
66
|
this.accountID = "";
|
|
60
67
|
this.nodeType = "Group";
|
|
61
|
-
this.privacyPolicy = privacy_1.AlwaysAllowPrivacyPolicy;
|
|
62
68
|
this.id = data.id;
|
|
63
69
|
}
|
|
70
|
+
getPrivacyPolicy() {
|
|
71
|
+
return privacy_1.AlwaysAllowPrivacyPolicy;
|
|
72
|
+
}
|
|
64
73
|
}
|
|
65
74
|
exports.Group = Group;
|
|
66
75
|
class Message {
|
|
@@ -69,9 +78,11 @@ class Message {
|
|
|
69
78
|
this.data = data;
|
|
70
79
|
this.accountID = "";
|
|
71
80
|
this.nodeType = "Message";
|
|
72
|
-
this.privacyPolicy = privacy_1.AlwaysAllowPrivacyPolicy;
|
|
73
81
|
this.id = data.id;
|
|
74
82
|
}
|
|
83
|
+
getPrivacyPolicy() {
|
|
84
|
+
return privacy_1.AlwaysAllowPrivacyPolicy;
|
|
85
|
+
}
|
|
75
86
|
}
|
|
76
87
|
exports.Message = Message;
|
|
77
88
|
class Address {
|
|
@@ -80,11 +91,34 @@ class Address {
|
|
|
80
91
|
this.data = data;
|
|
81
92
|
this.accountID = "";
|
|
82
93
|
this.nodeType = "Address";
|
|
83
|
-
this.privacyPolicy = privacy_1.AlwaysAllowPrivacyPolicy;
|
|
84
94
|
this.id = data.id;
|
|
85
95
|
}
|
|
96
|
+
getPrivacyPolicy() {
|
|
97
|
+
return privacy_1.AlwaysAllowPrivacyPolicy;
|
|
98
|
+
}
|
|
86
99
|
}
|
|
87
100
|
exports.Address = Address;
|
|
101
|
+
function getBuilderSchema(cfg, ent) {
|
|
102
|
+
return {
|
|
103
|
+
...new base_schema_1.EntSchema(cfg),
|
|
104
|
+
ent,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
exports.getBuilderSchema = getBuilderSchema;
|
|
108
|
+
function getBuilderSchemaFromFields(fields, ent) {
|
|
109
|
+
return {
|
|
110
|
+
...new base_schema_1.EntSchema({ fields }),
|
|
111
|
+
ent,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
exports.getBuilderSchemaFromFields = getBuilderSchemaFromFields;
|
|
115
|
+
function getBuilderSchemaTZFromFields(fields, ent) {
|
|
116
|
+
return {
|
|
117
|
+
...new base_schema_1.EntSchemaWithTZ({ fields }),
|
|
118
|
+
ent,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
exports.getBuilderSchemaTZFromFields = getBuilderSchemaTZFromFields;
|
|
88
122
|
function getSchemaName(value) {
|
|
89
123
|
return value.ent.name;
|
|
90
124
|
}
|
package/testutils/db/test_db.js
CHANGED
|
@@ -488,8 +488,8 @@ exports.setupSqlite = setupSqlite;
|
|
|
488
488
|
function getSchemaTable(schema, dialect) {
|
|
489
489
|
const fields = (0, schema_1.getFields)(schema);
|
|
490
490
|
const columns = [];
|
|
491
|
-
for (const [
|
|
492
|
-
columns.push(getColumnFromField(field, dialect));
|
|
491
|
+
for (const [fieldName, field] of fields) {
|
|
492
|
+
columns.push(getColumnFromField(fieldName, field, dialect));
|
|
493
493
|
}
|
|
494
494
|
return table((0, builder_1.getTableName)(schema), ...columns);
|
|
495
495
|
}
|
|
@@ -529,7 +529,7 @@ function getColumnForDbType(t, dialect) {
|
|
|
529
529
|
return undefined;
|
|
530
530
|
}
|
|
531
531
|
}
|
|
532
|
-
function getColumnFromField(f, dialect) {
|
|
532
|
+
function getColumnFromField(fieldName, f, dialect) {
|
|
533
533
|
switch (f.type.dbType) {
|
|
534
534
|
case schema_1.DBType.List:
|
|
535
535
|
const elemType = f.type.listElemType;
|
|
@@ -540,17 +540,17 @@ function getColumnFromField(f, dialect) {
|
|
|
540
540
|
if (elemFn === undefined) {
|
|
541
541
|
throw new Error(`unsupported type for ${elemType}`);
|
|
542
542
|
}
|
|
543
|
-
return list(storageKey(f), elemFn("ignore"), buildOpts(f));
|
|
543
|
+
return list(storageKey(fieldName, f), elemFn("ignore"), buildOpts(f));
|
|
544
544
|
default:
|
|
545
545
|
const fn = getColumnForDbType(f.type.dbType, dialect);
|
|
546
546
|
if (fn === undefined) {
|
|
547
547
|
throw new Error(`unsupported type ${f.type.dbType}`);
|
|
548
548
|
}
|
|
549
|
-
return getColumn(f, fn);
|
|
549
|
+
return getColumn(fieldName, f, fn);
|
|
550
550
|
}
|
|
551
551
|
}
|
|
552
|
-
function getColumn(f, col) {
|
|
553
|
-
return col(storageKey(f), buildOpts(f));
|
|
552
|
+
function getColumn(fieldName, f, col) {
|
|
553
|
+
return col(storageKey(fieldName, f), buildOpts(f));
|
|
554
554
|
}
|
|
555
555
|
function buildOpts(f) {
|
|
556
556
|
let ret = {};
|
|
@@ -569,11 +569,11 @@ function buildOpts(f) {
|
|
|
569
569
|
}
|
|
570
570
|
return ret;
|
|
571
571
|
}
|
|
572
|
-
function storageKey(f) {
|
|
572
|
+
function storageKey(fieldName, f) {
|
|
573
573
|
if (f.storageKey) {
|
|
574
574
|
return f.storageKey;
|
|
575
575
|
}
|
|
576
|
-
return (0, snake_case_1.snakeCase)(
|
|
576
|
+
return (0, snake_case_1.snakeCase)(fieldName);
|
|
577
577
|
}
|
|
578
578
|
function isSyncClient(client) {
|
|
579
579
|
return client.execSync !== undefined;
|
|
@@ -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,17 +45,22 @@ 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
|
-
|
|
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
|
+
});
|
|
59
64
|
app.use(config.graphQLPath || "/graphql", ...handlers);
|
|
60
65
|
return app;
|
|
61
66
|
}
|
|
@@ -355,7 +360,9 @@ async function expectFromRoot(config, ...options) {
|
|
|
355
360
|
else {
|
|
356
361
|
expect(res.ok, `expected ok response. instead got ${res.status} and result ${JSON.stringify(res.body)}`);
|
|
357
362
|
}
|
|
358
|
-
|
|
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)) {
|
|
359
366
|
let errors = res.body.errors;
|
|
360
367
|
expect(errors.length).toBeGreaterThan(0);
|
|
361
368
|
if (config.expectedError) {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ID, Ent, Viewer, Data, LoadEntOptions, PrivacyPolicy } from "../../core/base";
|
|
2
|
-
import {
|
|
3
|
-
import { Field, BaseEntSchema } 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,10 +21,7 @@ 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: Field[];
|
|
28
|
-
}
|
|
24
|
+
export declare const FakeContactSchema: import("../builder").BuilderSchema<FakeContact>;
|
|
29
25
|
export interface ContactCreateInput {
|
|
30
26
|
firstName: string;
|
|
31
27
|
lastName: string;
|
|
@@ -13,9 +13,6 @@ class FakeContact {
|
|
|
13
13
|
constructor(viewer, data) {
|
|
14
14
|
this.viewer = viewer;
|
|
15
15
|
this.nodeType = const_1.NodeType.FakeContact;
|
|
16
|
-
this.privacyPolicy = {
|
|
17
|
-
rules: [new privacy_1.AllowIfViewerIsRule("userID"), privacy_1.AlwaysDenyRule],
|
|
18
|
-
};
|
|
19
16
|
this.data = data;
|
|
20
17
|
this.id = data.id;
|
|
21
18
|
this.createdAt = (0, convert_1.convertDate)(data.created_at);
|
|
@@ -25,6 +22,11 @@ class FakeContact {
|
|
|
25
22
|
this.emailAddress = data.email_address;
|
|
26
23
|
this.userID = data.user_id;
|
|
27
24
|
}
|
|
25
|
+
getPrivacyPolicy() {
|
|
26
|
+
return {
|
|
27
|
+
rules: [new privacy_1.AllowIfViewerIsRule("userID"), privacy_1.AlwaysDenyRule],
|
|
28
|
+
};
|
|
29
|
+
}
|
|
28
30
|
static getFields() {
|
|
29
31
|
return [
|
|
30
32
|
"id",
|
|
@@ -59,28 +61,14 @@ class FakeContact {
|
|
|
59
61
|
}
|
|
60
62
|
}
|
|
61
63
|
exports.FakeContact = FakeContact;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
(0, schema_1.StringType)({
|
|
71
|
-
name: "lastName",
|
|
72
|
-
}),
|
|
73
|
-
(0, schema_1.StringType)({
|
|
74
|
-
name: "emailAddress",
|
|
75
|
-
}),
|
|
76
|
-
(0, schema_1.UUIDType)({
|
|
77
|
-
name: "userID",
|
|
78
|
-
foreignKey: { schema: "User", column: "ID" },
|
|
79
|
-
}),
|
|
80
|
-
];
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
exports.FakeContactSchema = FakeContactSchema;
|
|
64
|
+
exports.FakeContactSchema = (0, builder_1.getBuilderSchemaFromFields)({
|
|
65
|
+
firstName: (0, schema_1.StringType)(),
|
|
66
|
+
lastName: (0, schema_1.StringType)(),
|
|
67
|
+
emailAddress: (0, schema_1.StringType)(),
|
|
68
|
+
userID: (0, schema_1.UUIDType)({
|
|
69
|
+
foreignKey: { schema: "User", column: "ID" },
|
|
70
|
+
}),
|
|
71
|
+
}, FakeContact);
|
|
84
72
|
function getContactBuilder(viewer, input) {
|
|
85
73
|
const m = new Map();
|
|
86
74
|
for (const key in input) {
|
|
@@ -89,7 +77,7 @@ function getContactBuilder(viewer, input) {
|
|
|
89
77
|
//To lock in the value of Date now incase of advanceTo/advanceBy
|
|
90
78
|
m.set("createdAt", new Date());
|
|
91
79
|
m.set("updatedAt", new Date());
|
|
92
|
-
return new builder_1.SimpleBuilder(viewer,
|
|
80
|
+
return new builder_1.SimpleBuilder(viewer, exports.FakeContactSchema, m);
|
|
93
81
|
}
|
|
94
82
|
exports.getContactBuilder = getContactBuilder;
|
|
95
83
|
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 { Field, BaseEntSchema } 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: Field[];
|
|
29
|
-
}
|
|
25
|
+
export declare const FakeEventSchema: import("../builder").BuilderSchema<FakeEvent>;
|
|
30
26
|
export interface EventCreateInput {
|
|
31
27
|
startTime: Date;
|
|
32
28
|
endTime?: Date | null;
|
|
@@ -13,7 +13,6 @@ class FakeEvent {
|
|
|
13
13
|
constructor(viewer, data) {
|
|
14
14
|
this.viewer = viewer;
|
|
15
15
|
this.nodeType = const_1.NodeType.FakeEvent;
|
|
16
|
-
this.privacyPolicy = privacy_1.AlwaysAllowPrivacyPolicy;
|
|
17
16
|
this.data = data;
|
|
18
17
|
this.id = data.id;
|
|
19
18
|
this.createdAt = (0, convert_1.convertDate)(data.created_at);
|
|
@@ -25,6 +24,9 @@ class FakeEvent {
|
|
|
25
24
|
this.description = data.description;
|
|
26
25
|
this.userID = data.user_id;
|
|
27
26
|
}
|
|
27
|
+
getPrivacyPolicy() {
|
|
28
|
+
return privacy_1.AlwaysAllowPrivacyPolicy;
|
|
29
|
+
}
|
|
28
30
|
static getFields() {
|
|
29
31
|
return [
|
|
30
32
|
"id",
|
|
@@ -63,43 +65,28 @@ class FakeEvent {
|
|
|
63
65
|
}
|
|
64
66
|
}
|
|
65
67
|
exports.FakeEvent = FakeEvent;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
(0, schema_1.StringType)({
|
|
83
|
-
name: "location",
|
|
84
|
-
}),
|
|
85
|
-
(0, schema_1.StringType)({
|
|
86
|
-
name: "description",
|
|
87
|
-
nullable: true,
|
|
88
|
-
}),
|
|
89
|
-
(0, schema_1.UUIDType)({
|
|
90
|
-
name: "userID",
|
|
91
|
-
foreignKey: { schema: "User", column: "ID" },
|
|
92
|
-
}),
|
|
93
|
-
];
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
exports.FakeEventSchema = FakeEventSchema;
|
|
68
|
+
exports.FakeEventSchema = (0, builder_1.getBuilderSchemaFromFields)({
|
|
69
|
+
startTime: (0, schema_1.TimestampType)({
|
|
70
|
+
index: true,
|
|
71
|
+
}),
|
|
72
|
+
endTime: (0, schema_1.TimestampType)({
|
|
73
|
+
nullable: true,
|
|
74
|
+
}),
|
|
75
|
+
title: (0, schema_1.StringType)(),
|
|
76
|
+
location: (0, schema_1.StringType)(),
|
|
77
|
+
description: (0, schema_1.StringType)({
|
|
78
|
+
nullable: true,
|
|
79
|
+
}),
|
|
80
|
+
userID: (0, schema_1.UUIDType)({
|
|
81
|
+
foreignKey: { schema: "User", column: "ID" },
|
|
82
|
+
}),
|
|
83
|
+
}, FakeEvent);
|
|
97
84
|
function getEventBuilder(viewer, input) {
|
|
98
85
|
const m = new Map();
|
|
99
86
|
for (const key in input) {
|
|
100
87
|
m.set(key, input[key]);
|
|
101
88
|
}
|
|
102
|
-
return new builder_1.SimpleBuilder(viewer,
|
|
89
|
+
return new builder_1.SimpleBuilder(viewer, exports.FakeEventSchema, m);
|
|
103
90
|
}
|
|
104
91
|
exports.getEventBuilder = getEventBuilder;
|
|
105
92
|
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 { Field, BaseEntSchema } 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: Field[];
|
|
38
|
-
}
|
|
34
|
+
export declare const FakeUserSchema: import("../builder").BuilderSchema<FakeUser>;
|
|
39
35
|
export interface UserCreateInput {
|
|
40
36
|
firstName: string;
|
|
41
37
|
lastName: string;
|
|
@@ -26,7 +26,18 @@ class FakeUser {
|
|
|
26
26
|
constructor(viewer, data) {
|
|
27
27
|
this.viewer = viewer;
|
|
28
28
|
this.nodeType = const_1.NodeType.FakeUser;
|
|
29
|
-
this.
|
|
29
|
+
this.data = data;
|
|
30
|
+
this.id = data.id;
|
|
31
|
+
this.createdAt = (0, convert_1.convertDate)(data.created_at);
|
|
32
|
+
this.updatedAt = (0, convert_1.convertDate)(data.updated_at);
|
|
33
|
+
this.firstName = data.first_name;
|
|
34
|
+
this.lastName = data.last_name;
|
|
35
|
+
this.emailAddress = data.email_address;
|
|
36
|
+
this.phoneNumber = data.phone_number;
|
|
37
|
+
this.password = data.password;
|
|
38
|
+
}
|
|
39
|
+
getPrivacyPolicy() {
|
|
40
|
+
return {
|
|
30
41
|
rules: [
|
|
31
42
|
privacy_1.AllowIfViewerRule,
|
|
32
43
|
//can view user if friends
|
|
@@ -48,15 +59,6 @@ class FakeUser {
|
|
|
48
59
|
privacy_1.AlwaysDenyRule,
|
|
49
60
|
],
|
|
50
61
|
};
|
|
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
62
|
}
|
|
61
63
|
static getFields() {
|
|
62
64
|
return [
|
|
@@ -89,31 +91,15 @@ class FakeUser {
|
|
|
89
91
|
}
|
|
90
92
|
}
|
|
91
93
|
exports.FakeUser = FakeUser;
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
name: "lastName",
|
|
102
|
-
}),
|
|
103
|
-
(0, schema_1.StringType)({
|
|
104
|
-
name: "emailAddress",
|
|
105
|
-
}),
|
|
106
|
-
(0, schema_1.StringType)({
|
|
107
|
-
name: "phoneNumber",
|
|
108
|
-
}),
|
|
109
|
-
(0, schema_1.StringType)({
|
|
110
|
-
name: "password",
|
|
111
|
-
nullable: true,
|
|
112
|
-
}),
|
|
113
|
-
];
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
exports.FakeUserSchema = FakeUserSchema;
|
|
94
|
+
exports.FakeUserSchema = (0, builder_1.getBuilderSchemaFromFields)({
|
|
95
|
+
firstName: (0, schema_1.StringType)(),
|
|
96
|
+
lastName: (0, schema_1.StringType)(),
|
|
97
|
+
emailAddress: (0, schema_1.StringType)(),
|
|
98
|
+
phoneNumber: (0, schema_1.StringType)(),
|
|
99
|
+
password: (0, schema_1.StringType)({
|
|
100
|
+
nullable: true,
|
|
101
|
+
}),
|
|
102
|
+
}, FakeUser);
|
|
117
103
|
function getUserBuilder(viewer, input) {
|
|
118
104
|
const action = getUserAction(viewer, input);
|
|
119
105
|
return action.builder;
|
|
@@ -124,7 +110,7 @@ function getUserAction(viewer, input) {
|
|
|
124
110
|
for (const key in input) {
|
|
125
111
|
m.set(key, input[key]);
|
|
126
112
|
}
|
|
127
|
-
const action = new builder_1.SimpleAction(viewer,
|
|
113
|
+
const action = new builder_1.SimpleAction(viewer, exports.FakeUserSchema, m);
|
|
128
114
|
action.viewerForEntLoad = (data) => {
|
|
129
115
|
// load the created ent using a VC of the newly created user.
|
|
130
116
|
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
|
|
56
|
+
getPrivacyPolicy(): import("../../core/base").PrivacyPolicy<Ent>;
|
|
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
|
|
93
|
+
getPrivacyPolicy(): import("../../core/base").PrivacyPolicy<Ent>;
|
|
94
94
|
}
|
|
95
95
|
export declare class UserToFollowingQuery extends AssocEdgeQueryBase<FakeUser, Ent, AssocEdge> {
|
|
96
96
|
constructor(viewer: Viewer, src: EdgeQuerySource<FakeUser, FakeUser>);
|
package/tsc/ast.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
}
|
|
19
|
+
export declare function transformImport(fileContents: string, importNode: ts.ImportDeclaration, sourceFile: ts.SourceFile, opts?: transformOpts): string | undefined;
|
|
20
|
+
export {};
|