@snowtop/ent 0.0.1 → 0.0.3-5.alpha
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 +6 -6
- package/action/action.js +2 -2
- package/action/executor.d.ts +7 -12
- package/action/executor.js +39 -33
- package/action/experimental_action.d.ts +4 -2
- package/action/experimental_action.js +27 -2
- package/action/index.d.ts +1 -1
- package/action/orchestrator.d.ts +14 -6
- package/action/orchestrator.js +188 -99
- package/action/privacy.js +4 -4
- package/auth/auth.js +2 -2
- package/core/base.d.ts +6 -0
- package/core/base.js +12 -9
- package/core/clause.d.ts +1 -0
- package/core/clause.js +6 -2
- package/core/config.d.ts +21 -1
- package/core/config.js +20 -12
- package/core/context.js +3 -3
- package/core/convert.d.ts +4 -0
- package/core/convert.js +25 -2
- package/core/db.d.ts +19 -2
- package/core/db.js +4 -7
- package/core/ent.d.ts +17 -10
- package/core/ent.js +38 -15
- package/core/loaders/assoc_count_loader.js +5 -5
- package/core/loaders/assoc_edge_loader.js +10 -10
- package/core/loaders/loader.js +3 -3
- package/core/loaders/object_loader.js +6 -6
- package/core/loaders/query_loader.js +7 -7
- package/core/loaders/raw_count_loader.js +4 -4
- package/core/logger.js +2 -2
- package/core/privacy.d.ts +21 -1
- package/core/privacy.js +91 -47
- package/core/query/assoc_query.d.ts +12 -12
- package/core/query/assoc_query.js +86 -51
- package/core/query/custom_query.d.ts +10 -7
- package/core/query/custom_query.js +29 -3
- package/core/query/query.d.ts +24 -8
- package/core/query/query.js +41 -4
- package/core/query/shared_assoc_test.js +257 -13
- package/core/query/shared_test.d.ts +1 -1
- package/core/query/shared_test.js +11 -11
- package/core/viewer.js +1 -0
- package/graphql/builtins/connection.js +4 -3
- package/graphql/builtins/edge.js +3 -2
- package/graphql/builtins/node.js +2 -1
- package/graphql/graphql.d.ts +2 -0
- package/graphql/graphql.js +83 -61
- package/graphql/index.d.ts +1 -1
- package/graphql/index.js +2 -1
- package/graphql/node_resolver.d.ts +1 -0
- package/graphql/node_resolver.js +14 -1
- package/graphql/query/connection_type.d.ts +5 -4
- package/graphql/query/connection_type.js +6 -6
- package/graphql/query/edge_connection.d.ts +7 -7
- package/graphql/query/page_info.js +5 -4
- package/graphql/query/shared_assoc_test.js +9 -9
- package/graphql/query/shared_edge_connection.d.ts +1 -1
- package/graphql/query/shared_edge_connection.js +4 -4
- package/graphql/scalars/time.js +1 -1
- package/imports/dataz/example1/_auth.js +8 -8
- package/imports/dataz/example1/_viewer.js +4 -4
- package/imports/index.d.ts +1 -1
- package/imports/index.js +3 -5
- package/index.d.ts +2 -1
- package/index.js +6 -2
- package/package.json +17 -10
- package/parse_schema/parse.d.ts +48 -0
- package/parse_schema/parse.js +156 -0
- package/schema/base_schema.d.ts +2 -0
- package/schema/base_schema.js +17 -7
- package/schema/field.d.ts +52 -15
- package/schema/field.js +234 -47
- package/schema/index.d.ts +1 -0
- package/schema/index.js +1 -0
- package/schema/json_field.d.ts +17 -0
- package/schema/json_field.js +48 -0
- package/schema/schema.d.ts +39 -4
- package/schema/schema.js +2 -0
- package/scripts/custom_compiler.js +8 -10
- package/scripts/custom_graphql.js +45 -10
- package/scripts/read_schema.js +6 -108
- package/testutils/builder.d.ts +6 -3
- package/testutils/builder.js +31 -15
- package/testutils/db/test_db.d.ts +16 -8
- package/testutils/db/test_db.js +65 -9
- package/testutils/db_mock.js +5 -5
- package/testutils/ent-graphql-tests/index.d.ts +1 -0
- package/testutils/ent-graphql-tests/index.js +13 -13
- package/testutils/fake_comms.d.ts +1 -0
- package/testutils/fake_comms.js +4 -0
- package/testutils/fake_data/const.d.ts +5 -1
- package/testutils/fake_data/const.js +19 -1
- package/testutils/fake_data/events_query.d.ts +16 -11
- package/testutils/fake_data/events_query.js +15 -0
- package/testutils/fake_data/fake_contact.js +9 -9
- package/testutils/fake_data/fake_event.js +14 -14
- package/testutils/fake_data/fake_user.js +12 -10
- package/testutils/fake_data/test_helpers.d.ts +5 -1
- package/testutils/fake_data/test_helpers.js +49 -16
- package/testutils/fake_data/user_query.d.ts +25 -9
- package/testutils/fake_data/user_query.js +52 -5
- package/testutils/parse_sql.js +19 -3
- package/testutils/write.js +6 -6
package/graphql/builtins/edge.js
CHANGED
|
@@ -3,15 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.GraphQLEdgeInterface = void 0;
|
|
4
4
|
const graphql_1 = require("graphql");
|
|
5
5
|
const node_1 = require("./node");
|
|
6
|
+
// NB: if this changes, need to update renderer.go also
|
|
6
7
|
exports.GraphQLEdgeInterface = new graphql_1.GraphQLInterfaceType({
|
|
7
8
|
name: "Edge",
|
|
8
9
|
description: "edge interface",
|
|
9
10
|
fields: () => ({
|
|
10
11
|
node: {
|
|
11
|
-
type: graphql_1.GraphQLNonNull(node_1.GraphQLNodeInterface),
|
|
12
|
+
type: (0, graphql_1.GraphQLNonNull)(node_1.GraphQLNodeInterface),
|
|
12
13
|
},
|
|
13
14
|
cursor: {
|
|
14
|
-
type: graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
15
|
+
type: (0, graphql_1.GraphQLNonNull)(graphql_1.GraphQLString),
|
|
15
16
|
},
|
|
16
17
|
}),
|
|
17
18
|
});
|
package/graphql/builtins/node.js
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.GraphQLNodeInterface = void 0;
|
|
4
4
|
const graphql_1 = require("graphql");
|
|
5
|
+
// NB: if this changes, need to update renderer.go also
|
|
5
6
|
exports.GraphQLNodeInterface = new graphql_1.GraphQLInterfaceType({
|
|
6
7
|
name: "Node",
|
|
7
8
|
description: "node interface",
|
|
8
9
|
fields: () => ({
|
|
9
10
|
id: {
|
|
10
|
-
type: graphql_1.GraphQLNonNull(graphql_1.GraphQLID),
|
|
11
|
+
type: (0, graphql_1.GraphQLNonNull)(graphql_1.GraphQLID),
|
|
11
12
|
},
|
|
12
13
|
}),
|
|
13
14
|
});
|
package/graphql/graphql.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export interface CustomType {
|
|
|
8
8
|
importPath: string;
|
|
9
9
|
tsType?: string;
|
|
10
10
|
tsImportPath?: string;
|
|
11
|
+
[x: string]: any;
|
|
11
12
|
}
|
|
12
13
|
declare type Type = GraphQLScalarType | ClassType | string | CustomType;
|
|
13
14
|
export declare type GraphQLConnection<T> = {
|
|
@@ -81,6 +82,7 @@ declare enum NullableResult {
|
|
|
81
82
|
CONTENTS_AND_LIST = "contentsAndList",
|
|
82
83
|
ITEM = "true"
|
|
83
84
|
}
|
|
85
|
+
export declare const addCustomType: (type: CustomType) => void;
|
|
84
86
|
export declare class GQLCapture {
|
|
85
87
|
private static enabled;
|
|
86
88
|
static enable(enabled: boolean): void;
|
package/graphql/graphql.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.gqlFileUpload = exports.gqlConnection = exports.gqlContextType = exports.gqlMutation = exports.gqlQuery = exports.gqlObjectType = exports.gqlInputObjectType = exports.gqlArgType = exports.gqlArg = exports.gqlField = exports.GQLCapture = exports.CustomFieldType = void 0;
|
|
3
|
+
exports.gqlFileUpload = exports.gqlConnection = exports.gqlContextType = exports.gqlMutation = exports.gqlQuery = exports.gqlObjectType = exports.gqlInputObjectType = exports.gqlArgType = exports.gqlArg = exports.gqlField = exports.GQLCapture = exports.addCustomType = exports.CustomFieldType = void 0;
|
|
4
4
|
require("reflect-metadata");
|
|
5
5
|
// export interface gqlTopLevelOptions
|
|
6
6
|
// name?: string;
|
|
@@ -20,6 +20,88 @@ var NullableResult;
|
|
|
20
20
|
NullableResult["CONTENTS_AND_LIST"] = "contentsAndList";
|
|
21
21
|
NullableResult["ITEM"] = "true";
|
|
22
22
|
})(NullableResult || (NullableResult = {}));
|
|
23
|
+
const isArray = (type) => {
|
|
24
|
+
if (typeof type === "function") {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
return type.push !== undefined;
|
|
28
|
+
};
|
|
29
|
+
const isConnection = (type) => {
|
|
30
|
+
if (typeof type !== "object") {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
return type.node !== undefined;
|
|
34
|
+
};
|
|
35
|
+
const isString = (type) => {
|
|
36
|
+
if (type.lastIndexOf !== undefined) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
return false;
|
|
40
|
+
};
|
|
41
|
+
const isCustomType = (type) => {
|
|
42
|
+
return type.importPath !== undefined;
|
|
43
|
+
};
|
|
44
|
+
const isGraphQLScalarType = (type) => {
|
|
45
|
+
return type.serialize !== undefined;
|
|
46
|
+
};
|
|
47
|
+
const addCustomType = (type) => {
|
|
48
|
+
// TODO these should return ReadOnly objects...
|
|
49
|
+
const customType = GQLCapture.getCustomTypes().get(type.type);
|
|
50
|
+
if (customType && customType !== type) {
|
|
51
|
+
throw new Error(`cannot add multiple custom types of name ${type.type}`);
|
|
52
|
+
}
|
|
53
|
+
if (customType) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
const r = require(type.importPath);
|
|
58
|
+
const ct = r[type.type];
|
|
59
|
+
// this gets us the information needed for scalars
|
|
60
|
+
if (ct && isGraphQLScalarType(ct)) {
|
|
61
|
+
type.scalarInfo = {
|
|
62
|
+
description: ct.description,
|
|
63
|
+
name: ct.name,
|
|
64
|
+
};
|
|
65
|
+
if (ct.specifiedByUrl) {
|
|
66
|
+
type.scalarInfo.specifiedByUrl = ct.specifiedByUrl;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
catch (e) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
GQLCapture.getCustomTypes().set(type.type, type);
|
|
74
|
+
};
|
|
75
|
+
exports.addCustomType = addCustomType;
|
|
76
|
+
const getType = (typ, result) => {
|
|
77
|
+
if (isConnection(typ)) {
|
|
78
|
+
result.connection = true;
|
|
79
|
+
return getType(typ.node, result);
|
|
80
|
+
}
|
|
81
|
+
if (isArray(typ)) {
|
|
82
|
+
result.list = true;
|
|
83
|
+
return getType(typ[0], result);
|
|
84
|
+
}
|
|
85
|
+
if (isString(typ)) {
|
|
86
|
+
if (typ.lastIndexOf("]") !== -1) {
|
|
87
|
+
result.list = true;
|
|
88
|
+
result.type = typ.substr(1, typ.length - 2);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
result.type = typ;
|
|
92
|
+
}
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if (isCustomType(typ)) {
|
|
96
|
+
result.type = typ.type;
|
|
97
|
+
(0, exports.addCustomType)(typ);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
// GraphQLScalarType or ClassType
|
|
101
|
+
result.scalarType = isGraphQLScalarType(typ);
|
|
102
|
+
result.type = typ.name;
|
|
103
|
+
return;
|
|
104
|
+
};
|
|
23
105
|
class GQLCapture {
|
|
24
106
|
static enable(enabled) {
|
|
25
107
|
this.enabled = enabled;
|
|
@@ -104,66 +186,6 @@ class GQLCapture {
|
|
|
104
186
|
if ((type === "Number" || type === "Object") && !options?.type) {
|
|
105
187
|
throw new Error(`type is required when accessor/function/property returns a ${type}`);
|
|
106
188
|
}
|
|
107
|
-
const isArray = (type) => {
|
|
108
|
-
if (typeof type === "function") {
|
|
109
|
-
return false;
|
|
110
|
-
}
|
|
111
|
-
return type.push !== undefined;
|
|
112
|
-
};
|
|
113
|
-
const isConnection = (type) => {
|
|
114
|
-
if (typeof type !== "object") {
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
|
-
return type.node !== undefined;
|
|
118
|
-
};
|
|
119
|
-
const isString = (type) => {
|
|
120
|
-
if (type.lastIndexOf !== undefined) {
|
|
121
|
-
return true;
|
|
122
|
-
}
|
|
123
|
-
return false;
|
|
124
|
-
};
|
|
125
|
-
const isCustomType = (type) => {
|
|
126
|
-
return type.importPath !== undefined;
|
|
127
|
-
};
|
|
128
|
-
const isGraphQLScalarType = (type) => {
|
|
129
|
-
return type.serialize !== undefined;
|
|
130
|
-
};
|
|
131
|
-
const addCustomType = (type) => {
|
|
132
|
-
const customType = this.customTypes.get(type.type);
|
|
133
|
-
if (customType && customType !== type) {
|
|
134
|
-
throw new Error(`cannot add multiple custom types of name ${type.type}`);
|
|
135
|
-
}
|
|
136
|
-
this.customTypes.set(type.type, type);
|
|
137
|
-
};
|
|
138
|
-
const getType = (typ, result) => {
|
|
139
|
-
if (isConnection(typ)) {
|
|
140
|
-
result.connection = true;
|
|
141
|
-
return getType(typ.node, result);
|
|
142
|
-
}
|
|
143
|
-
if (isArray(typ)) {
|
|
144
|
-
result.list = true;
|
|
145
|
-
return getType(typ[0], result);
|
|
146
|
-
}
|
|
147
|
-
if (isString(typ)) {
|
|
148
|
-
if (typ.lastIndexOf("]") !== -1) {
|
|
149
|
-
result.list = true;
|
|
150
|
-
result.type = typ.substr(1, typ.length - 2);
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
result.type = typ;
|
|
154
|
-
}
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
if (isCustomType(typ)) {
|
|
158
|
-
result.type = typ.type;
|
|
159
|
-
addCustomType(typ);
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
// GraphQLScalarType or ClassType
|
|
163
|
-
result.scalarType = isGraphQLScalarType(typ);
|
|
164
|
-
result.type = typ.name;
|
|
165
|
-
return;
|
|
166
|
-
};
|
|
167
189
|
let list;
|
|
168
190
|
let scalarType = false;
|
|
169
191
|
let connection;
|
package/graphql/index.d.ts
CHANGED
|
@@ -6,5 +6,5 @@ export { GraphQLEdgeType, GraphQLConnectionType, } from "./query/connection_type
|
|
|
6
6
|
export { GraphQLNodeInterface } from "./builtins/node";
|
|
7
7
|
export { GraphQLConnectionInterface } from "./builtins/connection";
|
|
8
8
|
export { GraphQLEdgeInterface } from "./builtins/edge";
|
|
9
|
-
export { NodeResolver, EntNodeResolver, registerResolver, clearResolvers, resolveID, nodeIDEncoder, mustDecodeIDFromGQLID, encodeGQLID, } from "./node_resolver";
|
|
9
|
+
export { NodeResolver, EntNodeResolver, registerResolver, clearResolvers, resolveID, nodeIDEncoder, mustDecodeIDFromGQLID, mustDecodeNullableIDFromGQLID, encodeGQLID, } from "./node_resolver";
|
|
10
10
|
export { convertFromGQLEnum, convertToGQLEnum } from "./enums";
|
package/graphql/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.convertToGQLEnum = exports.convertFromGQLEnum = exports.encodeGQLID = exports.mustDecodeIDFromGQLID = exports.nodeIDEncoder = exports.resolveID = exports.clearResolvers = exports.registerResolver = exports.EntNodeResolver = exports.GraphQLEdgeInterface = exports.GraphQLConnectionInterface = exports.GraphQLNodeInterface = exports.GraphQLConnectionType = exports.GraphQLEdgeType = exports.GraphQLEdgeConnection = exports.GraphQLPageInfo = exports.GraphQLTime = exports.gqlFileUpload = exports.GQLCapture = exports.gqlConnection = exports.gqlContextType = exports.gqlMutation = exports.gqlQuery = exports.gqlObjectType = exports.gqlInputObjectType = exports.gqlArgType = exports.gqlArg = exports.gqlField = void 0;
|
|
3
|
+
exports.convertToGQLEnum = exports.convertFromGQLEnum = exports.encodeGQLID = exports.mustDecodeNullableIDFromGQLID = exports.mustDecodeIDFromGQLID = exports.nodeIDEncoder = exports.resolveID = exports.clearResolvers = exports.registerResolver = exports.EntNodeResolver = exports.GraphQLEdgeInterface = exports.GraphQLConnectionInterface = exports.GraphQLNodeInterface = exports.GraphQLConnectionType = exports.GraphQLEdgeType = exports.GraphQLEdgeConnection = exports.GraphQLPageInfo = exports.GraphQLTime = exports.gqlFileUpload = exports.GQLCapture = exports.gqlConnection = exports.gqlContextType = exports.gqlMutation = exports.gqlQuery = exports.gqlObjectType = exports.gqlInputObjectType = exports.gqlArgType = exports.gqlArg = exports.gqlField = void 0;
|
|
4
4
|
var graphql_1 = require("./graphql");
|
|
5
5
|
Object.defineProperty(exports, "gqlField", { enumerable: true, get: function () { return graphql_1.gqlField; } });
|
|
6
6
|
Object.defineProperty(exports, "gqlArg", { enumerable: true, get: function () { return graphql_1.gqlArg; } });
|
|
@@ -35,6 +35,7 @@ Object.defineProperty(exports, "clearResolvers", { enumerable: true, get: functi
|
|
|
35
35
|
Object.defineProperty(exports, "resolveID", { enumerable: true, get: function () { return node_resolver_1.resolveID; } });
|
|
36
36
|
Object.defineProperty(exports, "nodeIDEncoder", { enumerable: true, get: function () { return node_resolver_1.nodeIDEncoder; } });
|
|
37
37
|
Object.defineProperty(exports, "mustDecodeIDFromGQLID", { enumerable: true, get: function () { return node_resolver_1.mustDecodeIDFromGQLID; } });
|
|
38
|
+
Object.defineProperty(exports, "mustDecodeNullableIDFromGQLID", { enumerable: true, get: function () { return node_resolver_1.mustDecodeNullableIDFromGQLID; } });
|
|
38
39
|
Object.defineProperty(exports, "encodeGQLID", { enumerable: true, get: function () { return node_resolver_1.encodeGQLID; } });
|
|
39
40
|
var enums_1 = require("./enums");
|
|
40
41
|
Object.defineProperty(exports, "convertFromGQLEnum", { enumerable: true, get: function () { return enums_1.convertFromGQLEnum; } });
|
|
@@ -24,5 +24,6 @@ export declare function clearResolvers(): Promise<void>;
|
|
|
24
24
|
export declare function resolveID(viewer: Viewer, id: string): Promise<Node | null>;
|
|
25
25
|
export declare const nodeIDEncoder: GraphQLFieldResolver<Ent, {}>;
|
|
26
26
|
export declare function mustDecodeIDFromGQLID(id: string): ID;
|
|
27
|
+
export declare function mustDecodeNullableIDFromGQLID(id: string | null | undefined): any;
|
|
27
28
|
export declare function encodeGQLID(node: Ent): string;
|
|
28
29
|
export {};
|
package/graphql/node_resolver.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.encodeGQLID = exports.mustDecodeIDFromGQLID = exports.nodeIDEncoder = exports.resolveID = exports.clearResolvers = exports.registerResolver = exports.EntNodeResolver = void 0;
|
|
3
|
+
exports.encodeGQLID = exports.mustDecodeNullableIDFromGQLID = exports.mustDecodeIDFromGQLID = exports.nodeIDEncoder = exports.resolveID = exports.clearResolvers = exports.registerResolver = exports.EntNodeResolver = void 0;
|
|
4
4
|
class EntNodeResolver {
|
|
5
5
|
constructor(loader) {
|
|
6
6
|
this.loader = loader;
|
|
@@ -76,6 +76,19 @@ function mustDecodeIDFromGQLID(id) {
|
|
|
76
76
|
return decoded;
|
|
77
77
|
}
|
|
78
78
|
exports.mustDecodeIDFromGQLID = mustDecodeIDFromGQLID;
|
|
79
|
+
// TODO get the right (non-any) return type here. may need to change codegen to do the right thing here
|
|
80
|
+
function mustDecodeNullableIDFromGQLID(id) {
|
|
81
|
+
// support undefined because fields in action
|
|
82
|
+
if (id === null || id === undefined) {
|
|
83
|
+
return id;
|
|
84
|
+
}
|
|
85
|
+
const decoded = EntNodeResolver.decode(id);
|
|
86
|
+
if (!decoded) {
|
|
87
|
+
throw new Error(`wasn't able to decode invalid ${id}`);
|
|
88
|
+
}
|
|
89
|
+
return decoded;
|
|
90
|
+
}
|
|
91
|
+
exports.mustDecodeNullableIDFromGQLID = mustDecodeNullableIDFromGQLID;
|
|
79
92
|
// This takes an ent and returns the graphql id
|
|
80
93
|
function encodeGQLID(node) {
|
|
81
94
|
// let's do 3 parts. we take the "node" prefix
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { GraphQLFieldConfigMap, GraphQLObjectType } from "graphql";
|
|
1
|
+
import { GraphQLFieldConfigMap, GraphQLObjectType, GraphQLInterfaceType } from "graphql";
|
|
2
2
|
import { RequestContext } from "../../core/context";
|
|
3
3
|
import { GraphQLEdge } from "./edge_connection";
|
|
4
4
|
import { Data } from "../../core/base";
|
|
5
|
-
|
|
5
|
+
declare type nodeType = GraphQLObjectType | GraphQLInterfaceType;
|
|
6
|
+
export declare class GraphQLEdgeType<TNode extends nodeType, TEdge extends Data> extends GraphQLObjectType {
|
|
6
7
|
constructor(name: string, nodeType: TNode, optionalFields?: () => GraphQLFieldConfigMap<GraphQLEdge<TEdge>, RequestContext>);
|
|
7
8
|
}
|
|
8
9
|
interface connectionOptions<T extends Data> {
|
|
9
10
|
fields?(): GraphQLFieldConfigMap<GraphQLEdge<T>, RequestContext>;
|
|
10
11
|
}
|
|
11
|
-
export declare class GraphQLConnectionType<TNode extends
|
|
12
|
+
export declare class GraphQLConnectionType<TNode extends nodeType, TEdge extends Data> extends GraphQLObjectType {
|
|
12
13
|
edgeType: GraphQLEdgeType<TNode, TEdge>;
|
|
13
|
-
constructor(name: string, nodeType: TNode, options?: connectionOptions<
|
|
14
|
+
constructor(name: string, nodeType: TNode, options?: connectionOptions<TEdge>);
|
|
14
15
|
}
|
|
15
16
|
export {};
|
|
@@ -15,10 +15,10 @@ class GraphQLEdgeType extends graphql_1.GraphQLObjectType {
|
|
|
15
15
|
name: `${name}Edge`,
|
|
16
16
|
fields: () => ({
|
|
17
17
|
node: {
|
|
18
|
-
type: graphql_1.GraphQLNonNull(nodeType),
|
|
18
|
+
type: (0, graphql_1.GraphQLNonNull)(nodeType),
|
|
19
19
|
},
|
|
20
20
|
cursor: {
|
|
21
|
-
type: graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
21
|
+
type: (0, graphql_1.GraphQLNonNull)(graphql_1.GraphQLString),
|
|
22
22
|
},
|
|
23
23
|
...optional,
|
|
24
24
|
}),
|
|
@@ -34,25 +34,25 @@ class GraphQLConnectionType extends graphql_1.GraphQLObjectType {
|
|
|
34
34
|
name: `${name}Connection`,
|
|
35
35
|
fields: () => ({
|
|
36
36
|
edges: {
|
|
37
|
-
type: graphql_1.GraphQLNonNull(graphql_1.GraphQLList(graphql_1.GraphQLNonNull(edgeType))),
|
|
37
|
+
type: (0, graphql_1.GraphQLNonNull)((0, graphql_1.GraphQLList)((0, graphql_1.GraphQLNonNull)(edgeType))),
|
|
38
38
|
resolve: (source) => {
|
|
39
39
|
return source.queryEdges();
|
|
40
40
|
},
|
|
41
41
|
},
|
|
42
42
|
nodes: {
|
|
43
|
-
type: graphql_1.GraphQLNonNull(graphql_1.GraphQLList(graphql_1.GraphQLNonNull(nodeType))),
|
|
43
|
+
type: (0, graphql_1.GraphQLNonNull)((0, graphql_1.GraphQLList)((0, graphql_1.GraphQLNonNull)(nodeType))),
|
|
44
44
|
resolve: (source) => {
|
|
45
45
|
return source.queryNodes();
|
|
46
46
|
},
|
|
47
47
|
},
|
|
48
48
|
pageInfo: {
|
|
49
|
-
type: graphql_1.GraphQLNonNull(page_info_1.GraphQLPageInfo),
|
|
49
|
+
type: (0, graphql_1.GraphQLNonNull)(page_info_1.GraphQLPageInfo),
|
|
50
50
|
resolve: (source) => {
|
|
51
51
|
return source.queryPageInfo();
|
|
52
52
|
},
|
|
53
53
|
},
|
|
54
54
|
rawCount: {
|
|
55
|
-
type: graphql_1.GraphQLNonNull(graphql_1.GraphQLInt),
|
|
55
|
+
type: (0, graphql_1.GraphQLNonNull)(graphql_1.GraphQLInt),
|
|
56
56
|
resolve: (source) => {
|
|
57
57
|
return source.queryTotalCount();
|
|
58
58
|
},
|
|
@@ -6,22 +6,22 @@ export interface GraphQLEdge<T extends Data> {
|
|
|
6
6
|
cursor: string;
|
|
7
7
|
}
|
|
8
8
|
interface edgeQueryCtr<T extends Ent, TEdge extends Data> {
|
|
9
|
-
(v: Viewer, src:
|
|
9
|
+
(v: Viewer, src: T): EdgeQuery<T, Ent, TEdge>;
|
|
10
10
|
}
|
|
11
11
|
interface edgeQueryCtr2<T extends Ent, TEdge extends Data> {
|
|
12
|
-
(v: Viewer): EdgeQuery<T, TEdge>;
|
|
12
|
+
(v: Viewer): EdgeQuery<T, Ent, TEdge>;
|
|
13
13
|
}
|
|
14
|
-
export declare class GraphQLEdgeConnection<TEdge extends Data> {
|
|
15
|
-
query: EdgeQuery<Ent, TEdge>;
|
|
14
|
+
export declare class GraphQLEdgeConnection<TSource extends Ent, TEdge extends Data> {
|
|
15
|
+
query: EdgeQuery<TSource, Ent, TEdge>;
|
|
16
16
|
private results;
|
|
17
17
|
private viewer;
|
|
18
18
|
private source?;
|
|
19
19
|
private args?;
|
|
20
|
-
constructor(viewer: Viewer, source:
|
|
21
|
-
constructor(viewer: Viewer, getQuery: edgeQueryCtr2<
|
|
20
|
+
constructor(viewer: Viewer, source: TSource, getQuery: edgeQueryCtr<TSource, TEdge>, args?: Data);
|
|
21
|
+
constructor(viewer: Viewer, getQuery: edgeQueryCtr2<TSource, TEdge>, args?: Data);
|
|
22
22
|
first(limit: number, cursor?: string): void;
|
|
23
23
|
last(limit: number, cursor?: string): void;
|
|
24
|
-
modifyQuery(fn: (query: EdgeQuery<Ent, TEdge>) => EdgeQuery<Ent, TEdge>): void;
|
|
24
|
+
modifyQuery(fn: (query: EdgeQuery<TSource, Ent, TEdge>) => EdgeQuery<TSource, Ent, TEdge>): void;
|
|
25
25
|
queryTotalCount(): Promise<number>;
|
|
26
26
|
queryEdges(): Promise<GraphQLEdge<TEdge>[]>;
|
|
27
27
|
queryNodes(): Promise<Ent[]>;
|
|
@@ -2,26 +2,27 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.GraphQLPageInfo = void 0;
|
|
4
4
|
const graphql_1 = require("graphql");
|
|
5
|
+
// NB: if this changes, need to update renderer.go also
|
|
5
6
|
exports.GraphQLPageInfo = new graphql_1.GraphQLObjectType({
|
|
6
7
|
name: "PageInfo",
|
|
7
8
|
fields: () => ({
|
|
8
9
|
hasNextPage: {
|
|
9
|
-
type: graphql_1.GraphQLNonNull(graphql_1.GraphQLBoolean),
|
|
10
|
+
type: (0, graphql_1.GraphQLNonNull)(graphql_1.GraphQLBoolean),
|
|
10
11
|
resolve: (source) => {
|
|
11
12
|
return source.hasNextPage || false;
|
|
12
13
|
},
|
|
13
14
|
},
|
|
14
15
|
hasPreviousPage: {
|
|
15
|
-
type: graphql_1.GraphQLNonNull(graphql_1.GraphQLBoolean),
|
|
16
|
+
type: (0, graphql_1.GraphQLNonNull)(graphql_1.GraphQLBoolean),
|
|
16
17
|
resolve: (source) => {
|
|
17
18
|
return source.hasPreviousPage || false;
|
|
18
19
|
},
|
|
19
20
|
},
|
|
20
21
|
startCursor: {
|
|
21
|
-
type: graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
22
|
+
type: (0, graphql_1.GraphQLNonNull)(graphql_1.GraphQLString),
|
|
22
23
|
},
|
|
23
24
|
endCursor: {
|
|
24
|
-
type: graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
25
|
+
type: (0, graphql_1.GraphQLNonNull)(graphql_1.GraphQLString),
|
|
25
26
|
},
|
|
26
27
|
}),
|
|
27
28
|
});
|
|
@@ -22,13 +22,13 @@ function sharedAssocTests() {
|
|
|
22
22
|
let friendsInput = [...test_helpers_1.inputs, ...test_helpers_1.inputs, ...test_helpers_1.inputs, ...test_helpers_1.inputs];
|
|
23
23
|
beforeEach(async () => {
|
|
24
24
|
friendCount = 0;
|
|
25
|
-
user = await test_helpers_1.createTestUser();
|
|
26
|
-
event = await test_helpers_1.createTestEvent(user);
|
|
25
|
+
user = await (0, test_helpers_1.createTestUser)();
|
|
26
|
+
event = await (0, test_helpers_1.createTestEvent)(user);
|
|
27
27
|
let promises = [];
|
|
28
28
|
for (let i = 0; i < friendsInput.length; i++) {
|
|
29
|
-
jest_date_mock_1.advanceBy(100);
|
|
29
|
+
(0, jest_date_mock_1.advanceBy)(100);
|
|
30
30
|
let input = friendsInput[i];
|
|
31
|
-
const builder = index_1.getUserBuilder(user.viewer, test_helpers_1.getUserInput(input));
|
|
31
|
+
const builder = (0, index_1.getUserBuilder)(user.viewer, (0, test_helpers_1.getUserInput)(input));
|
|
32
32
|
if (i % 2 == 1) {
|
|
33
33
|
builder.orchestrator.addOutboundEdge(user.id, index_1.EdgeType.UserToFriends, "User");
|
|
34
34
|
friendCount++;
|
|
@@ -110,7 +110,7 @@ function sharedAssocTests() {
|
|
|
110
110
|
name: "User",
|
|
111
111
|
fields: {
|
|
112
112
|
id: {
|
|
113
|
-
type: graphql_1.GraphQLNonNull(graphql_1.GraphQLID),
|
|
113
|
+
type: (0, graphql_1.GraphQLNonNull)(graphql_1.GraphQLID),
|
|
114
114
|
},
|
|
115
115
|
firstName: {
|
|
116
116
|
type: graphql_1.GraphQLString,
|
|
@@ -128,7 +128,7 @@ function sharedAssocTests() {
|
|
|
128
128
|
name: "Event",
|
|
129
129
|
fields: {
|
|
130
130
|
id: {
|
|
131
|
-
type: graphql_1.GraphQLNonNull(graphql_1.GraphQLID),
|
|
131
|
+
type: (0, graphql_1.GraphQLNonNull)(graphql_1.GraphQLID),
|
|
132
132
|
},
|
|
133
133
|
},
|
|
134
134
|
interfaces: [node_1.GraphQLNodeInterface],
|
|
@@ -164,8 +164,8 @@ function sharedAssocTests() {
|
|
|
164
164
|
expect(fields2["bar"]).toBeDefined();
|
|
165
165
|
expect(fields2["node"]).toBeDefined();
|
|
166
166
|
expect(fields2["cursor"]).toBeDefined();
|
|
167
|
-
const user = await test_helpers_1.createTestUser();
|
|
168
|
-
const event = await test_helpers_1.createTestEvent(user);
|
|
167
|
+
const user = await (0, test_helpers_1.createTestUser)();
|
|
168
|
+
const event = await (0, test_helpers_1.createTestEvent)(user);
|
|
169
169
|
let rootQuery = new graphql_1.GraphQLObjectType({
|
|
170
170
|
name: "RootQueryType",
|
|
171
171
|
fields: {
|
|
@@ -187,7 +187,7 @@ function sharedAssocTests() {
|
|
|
187
187
|
viewer: new viewer_1.IDViewer(user.id),
|
|
188
188
|
args: {},
|
|
189
189
|
};
|
|
190
|
-
await ent_graphql_tests_1.expectQueryFromRoot(cfg, [
|
|
190
|
+
await (0, ent_graphql_tests_1.expectQueryFromRoot)(cfg, [
|
|
191
191
|
"edges",
|
|
192
192
|
[
|
|
193
193
|
{
|
|
@@ -2,7 +2,7 @@ import { Viewer, Data, Ent } from "../../core/base";
|
|
|
2
2
|
import { FakeContact } from "../../testutils/fake_data/index";
|
|
3
3
|
import { EdgeQuery } from "../../core/query/query";
|
|
4
4
|
interface options<TEnt extends Ent, TEdge extends Data> {
|
|
5
|
-
getQuery: (v: Viewer, src: Ent) => EdgeQuery<TEnt, TEdge>;
|
|
5
|
+
getQuery: (v: Viewer, src: Ent) => EdgeQuery<TEnt, Ent, TEdge>;
|
|
6
6
|
tableName: string;
|
|
7
7
|
sortCol: string;
|
|
8
8
|
}
|
|
@@ -17,7 +17,7 @@ class TestConnection {
|
|
|
17
17
|
this.filteredContacts = [];
|
|
18
18
|
}
|
|
19
19
|
async beforeEach() {
|
|
20
|
-
[this.user, this.allContacts] = await test_helpers_1.createAllContacts();
|
|
20
|
+
[this.user, this.allContacts] = await (0, test_helpers_1.createAllContacts)();
|
|
21
21
|
this.allContacts = this.allContacts.reverse();
|
|
22
22
|
this.conn = new edge_connection_1.GraphQLEdgeConnection(new viewer_1.IDViewer(this.user.id), this.user, (v, user) => this.getQuery(v, user));
|
|
23
23
|
if (this.filter) {
|
|
@@ -52,7 +52,7 @@ const commonTests = (opts) => {
|
|
|
52
52
|
// based on getContactBuilder
|
|
53
53
|
// so regardless of if we're doing assoc or custom queries, we can get the time
|
|
54
54
|
// from the created_at field
|
|
55
|
-
return ent_1.getCursor({
|
|
55
|
+
return (0, ent_1.getCursor)({
|
|
56
56
|
row: contacts[idx],
|
|
57
57
|
col: "createdAt",
|
|
58
58
|
conv: (t) => {
|
|
@@ -180,7 +180,7 @@ const commonTests = (opts) => {
|
|
|
180
180
|
});
|
|
181
181
|
describe("no source", () => {
|
|
182
182
|
test("no filter", async () => {
|
|
183
|
-
const [user, allContacts] = await test_helpers_1.createAllContacts();
|
|
183
|
+
const [user, allContacts] = await (0, test_helpers_1.createAllContacts)();
|
|
184
184
|
const conn = new edge_connection_1.GraphQLEdgeConnection(new viewer_1.IDViewer(user.id), (v) => opts.getQuery(v, user));
|
|
185
185
|
allContacts.reverse();
|
|
186
186
|
const nodes = await conn.queryNodes();
|
|
@@ -193,7 +193,7 @@ const commonTests = (opts) => {
|
|
|
193
193
|
expect(pagination.hasPreviousPage).toBe(false);
|
|
194
194
|
});
|
|
195
195
|
test("with filter", async () => {
|
|
196
|
-
const [user, allContacts] = await test_helpers_1.createAllContacts();
|
|
196
|
+
const [user, allContacts] = await (0, test_helpers_1.createAllContacts)();
|
|
197
197
|
const conn = new edge_connection_1.GraphQLEdgeConnection(new viewer_1.IDViewer(user.id), (v) => opts.getQuery(v, user).first(2));
|
|
198
198
|
allContacts.reverse();
|
|
199
199
|
const filtered = allContacts.slice(0, 2);
|
package/graphql/scalars/time.js
CHANGED
|
@@ -7,7 +7,7 @@ const luxon_1 = require("luxon");
|
|
|
7
7
|
const date_1 = require("../../core/date");
|
|
8
8
|
// Time refers to a Timestamp or Date scalar
|
|
9
9
|
function parseValue(input) {
|
|
10
|
-
return date_1.parseDate(input, (msg) => {
|
|
10
|
+
return (0, date_1.parseDate)(input, (msg) => {
|
|
11
11
|
return new graphql_1.GraphQLError(msg);
|
|
12
12
|
}).toJSDate();
|
|
13
13
|
}
|
|
@@ -17,28 +17,28 @@ const graphql_2 = require("graphql");
|
|
|
17
17
|
let UserAuthInput = class UserAuthInput {
|
|
18
18
|
};
|
|
19
19
|
__decorate([
|
|
20
|
-
graphql_1.gqlField(),
|
|
20
|
+
(0, graphql_1.gqlField)(),
|
|
21
21
|
__metadata("design:type", String)
|
|
22
22
|
], UserAuthInput.prototype, "emailAddress", void 0);
|
|
23
23
|
__decorate([
|
|
24
|
-
graphql_1.gqlField(),
|
|
24
|
+
(0, graphql_1.gqlField)(),
|
|
25
25
|
__metadata("design:type", String)
|
|
26
26
|
], UserAuthInput.prototype, "password", void 0);
|
|
27
27
|
UserAuthInput = __decorate([
|
|
28
|
-
graphql_1.gqlInputObjectType()
|
|
28
|
+
(0, graphql_1.gqlInputObjectType)()
|
|
29
29
|
], UserAuthInput);
|
|
30
30
|
let UserAuthResponse = class UserAuthResponse {
|
|
31
31
|
};
|
|
32
32
|
__decorate([
|
|
33
|
-
graphql_1.gqlField(),
|
|
33
|
+
(0, graphql_1.gqlField)(),
|
|
34
34
|
__metadata("design:type", String)
|
|
35
35
|
], UserAuthResponse.prototype, "token", void 0);
|
|
36
36
|
__decorate([
|
|
37
|
-
graphql_1.gqlField({ type: graphql_2.GraphQLID }),
|
|
37
|
+
(0, graphql_1.gqlField)({ type: graphql_2.GraphQLID }),
|
|
38
38
|
__metadata("design:type", Object)
|
|
39
39
|
], UserAuthResponse.prototype, "viewerID", void 0);
|
|
40
40
|
UserAuthResponse = __decorate([
|
|
41
|
-
graphql_1.gqlObjectType()
|
|
41
|
+
(0, graphql_1.gqlObjectType)()
|
|
42
42
|
], UserAuthResponse);
|
|
43
43
|
class AuthResolver {
|
|
44
44
|
async userAuth(input) {
|
|
@@ -46,8 +46,8 @@ class AuthResolver {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
__decorate([
|
|
49
|
-
graphql_1.gqlMutation({ name: "userAuth", type: UserAuthResponse }),
|
|
50
|
-
__param(0, graphql_1.gqlArg("input")),
|
|
49
|
+
(0, graphql_1.gqlMutation)({ name: "userAuth", type: UserAuthResponse }),
|
|
50
|
+
__param(0, (0, graphql_1.gqlArg)("input")),
|
|
51
51
|
__metadata("design:type", Function),
|
|
52
52
|
__metadata("design:paramtypes", [UserAuthInput]),
|
|
53
53
|
__metadata("design:returntype", Promise)
|
|
@@ -23,12 +23,12 @@ let ViewerType = class ViewerType {
|
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
25
|
__decorate([
|
|
26
|
-
graphql_1.gqlField({ type: graphql_2.GraphQLID, nullable: true }),
|
|
26
|
+
(0, graphql_1.gqlField)({ type: graphql_2.GraphQLID, nullable: true }),
|
|
27
27
|
__metadata("design:type", Object),
|
|
28
28
|
__metadata("design:paramtypes", [])
|
|
29
29
|
], ViewerType.prototype, "viewerID", null);
|
|
30
30
|
ViewerType = __decorate([
|
|
31
|
-
graphql_1.gqlObjectType({ name: "Viewer" }),
|
|
31
|
+
(0, graphql_1.gqlObjectType)({ name: "Viewer" }),
|
|
32
32
|
__metadata("design:paramtypes", [Object])
|
|
33
33
|
], ViewerType);
|
|
34
34
|
class ViewerResolver {
|
|
@@ -37,8 +37,8 @@ class ViewerResolver {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
__decorate([
|
|
40
|
-
graphql_1.gqlQuery({ name: "viewer", type: ViewerType }),
|
|
41
|
-
__param(0, graphql_1.gqlContextType()),
|
|
40
|
+
(0, graphql_1.gqlQuery)({ name: "viewer", type: ViewerType }),
|
|
41
|
+
__param(0, (0, graphql_1.gqlContextType)()),
|
|
42
42
|
__metadata("design:type", Function),
|
|
43
43
|
__metadata("design:paramtypes", [Object]),
|
|
44
44
|
__metadata("design:returntype", ViewerType)
|
package/imports/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ interface classResult {
|
|
|
10
10
|
class: classInfo;
|
|
11
11
|
file: file;
|
|
12
12
|
}
|
|
13
|
-
export declare function
|
|
13
|
+
export declare function parseCustomImports(filePath: string, opts?: Options): PathResult;
|
|
14
14
|
export declare function findTSConfigFile(filePath: string): string | null;
|
|
15
15
|
export interface importInfo {
|
|
16
16
|
name: string;
|
package/imports/index.js
CHANGED
|
@@ -22,7 +22,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
22
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.findTSConfigFile = exports.
|
|
25
|
+
exports.findTSConfigFile = exports.parseCustomImports = void 0;
|
|
26
26
|
const glob_1 = __importDefault(require("glob"));
|
|
27
27
|
const typescript_1 = __importDefault(require("typescript"));
|
|
28
28
|
const json5_1 = __importDefault(require("json5"));
|
|
@@ -42,10 +42,9 @@ function getFiles(filePath, opts) {
|
|
|
42
42
|
}
|
|
43
43
|
return files;
|
|
44
44
|
}
|
|
45
|
-
function
|
|
45
|
+
function parseCustomImports(filePath, opts) {
|
|
46
46
|
const files = getFiles(filePath, opts);
|
|
47
47
|
const options = readCompilerOptions(filePath);
|
|
48
|
-
// classMap
|
|
49
48
|
let classMap = new Map();
|
|
50
49
|
files.forEach((file) => {
|
|
51
50
|
const sourceFile = typescript_1.default.createSourceFile(file, fs.readFileSync(file).toString(), options.target || typescript_1.default.ScriptTarget.ES2015);
|
|
@@ -77,7 +76,7 @@ function parseCustomInput(filePath, opts) {
|
|
|
77
76
|
},
|
|
78
77
|
};
|
|
79
78
|
}
|
|
80
|
-
exports.
|
|
79
|
+
exports.parseCustomImports = parseCustomImports;
|
|
81
80
|
function findTSConfigFile(filePath) {
|
|
82
81
|
while (filePath != "/") {
|
|
83
82
|
let configPath = `${filePath}/tsconfig.json`;
|
|
@@ -95,7 +94,6 @@ function readCompilerOptions(filePath) {
|
|
|
95
94
|
if (!configPath) {
|
|
96
95
|
return {};
|
|
97
96
|
}
|
|
98
|
-
const root = path.join(filePath, "..");
|
|
99
97
|
let json = {};
|
|
100
98
|
try {
|
|
101
99
|
json = json5_1.default.parse(fs.readFileSync(configPath, {
|