@snowtop/ent 0.1.0-alpha123 → 0.1.0-alpha125
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/core/ent.d.ts +4 -0
- package/core/ent.js +27 -18
- package/core/query/shared_test.js +1 -2
- package/graphql/graphql.d.ts +19 -12
- package/graphql/graphql.js +65 -126
- package/graphql/index.d.ts +1 -1
- package/graphql/index.js +1 -2
- package/imports/dataz/example1/_auth.js +128 -47
- package/imports/dataz/example1/_viewer.js +87 -39
- package/index.d.ts +1 -2
- package/index.js +1 -2
- package/package.json +4 -5
- package/parse_schema/parse.d.ts +1 -2
- package/parse_schema/parse.js +2 -10
- package/schema/field.d.ts +3 -5
- package/schema/field.js +15 -69
- package/schema/schema.d.ts +0 -2
- package/schema/struct_field.d.ts +6 -8
- package/schema/struct_field.js +8 -67
- package/schema/union_field.d.ts +1 -1
- package/scripts/custom_compiler.js +2 -2
- package/scripts/move_types.js +4 -1
- package/testutils/db_mock.js +1 -1
- package/testutils/fake_comms.js +1 -1
- package/testutils/fake_log.js +1 -1
- package/core/global_schema.d.ts +0 -7
- package/core/global_schema.js +0 -51
|
@@ -1,54 +1,135 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
3
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
4
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
5
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
6
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
7
|
+
var _, done = false;
|
|
8
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
9
|
+
var context = {};
|
|
10
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
11
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
12
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
13
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
14
|
+
if (kind === "accessor") {
|
|
15
|
+
if (result === void 0) continue;
|
|
16
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
17
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
18
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
19
|
+
if (_ = accept(result.init)) initializers.push(_);
|
|
20
|
+
}
|
|
21
|
+
else if (_ = accept(result)) {
|
|
22
|
+
if (kind === "field") initializers.push(_);
|
|
23
|
+
else descriptor[key] = _;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
27
|
+
done = true;
|
|
7
28
|
};
|
|
8
|
-
var
|
|
9
|
-
|
|
29
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
30
|
+
var useValue = arguments.length > 2;
|
|
31
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
32
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
33
|
+
}
|
|
34
|
+
return useValue ? value : void 0;
|
|
10
35
|
};
|
|
11
|
-
var
|
|
12
|
-
|
|
36
|
+
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
37
|
+
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
38
|
+
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
13
39
|
};
|
|
14
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
41
|
const graphql_1 = require("../../../graphql/graphql");
|
|
16
42
|
const graphql_2 = require("graphql");
|
|
17
|
-
let UserAuthInput =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
UserAuthInput =
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
]
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
43
|
+
let UserAuthInput = (() => {
|
|
44
|
+
let _classDecorators = [(0, graphql_1.gqlInputObjectType)()];
|
|
45
|
+
let _classDescriptor;
|
|
46
|
+
let _classExtraInitializers = [];
|
|
47
|
+
let _classThis;
|
|
48
|
+
let _instanceExtraInitializers = [];
|
|
49
|
+
let _emailAddress_decorators;
|
|
50
|
+
let _emailAddress_initializers = [];
|
|
51
|
+
let _password_decorators;
|
|
52
|
+
let _password_initializers = [];
|
|
53
|
+
var UserAuthInput = _classThis = class {
|
|
54
|
+
constructor() {
|
|
55
|
+
this.emailAddress = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _emailAddress_initializers, void 0));
|
|
56
|
+
this.password = __runInitializers(this, _password_initializers, void 0);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
__setFunctionName(_classThis, "UserAuthInput");
|
|
60
|
+
(() => {
|
|
61
|
+
_emailAddress_decorators = [(0, graphql_1.gqlField)({
|
|
62
|
+
nodeName: "UserAuthInput",
|
|
63
|
+
type: graphql_2.GraphQLString,
|
|
64
|
+
})];
|
|
65
|
+
_password_decorators = [(0, graphql_1.gqlField)({
|
|
66
|
+
nodeName: "UserAuthInput",
|
|
67
|
+
type: graphql_2.GraphQLString,
|
|
68
|
+
})];
|
|
69
|
+
__esDecorate(null, null, _emailAddress_decorators, { kind: "field", name: "emailAddress", static: false, private: false, access: { has: obj => "emailAddress" in obj, get: obj => obj.emailAddress, set: (obj, value) => { obj.emailAddress = value; } } }, _emailAddress_initializers, _instanceExtraInitializers);
|
|
70
|
+
__esDecorate(null, null, _password_decorators, { kind: "field", name: "password", static: false, private: false, access: { has: obj => "password" in obj, get: obj => obj.password, set: (obj, value) => { obj.password = value; } } }, _password_initializers, _instanceExtraInitializers);
|
|
71
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers);
|
|
72
|
+
UserAuthInput = _classThis = _classDescriptor.value;
|
|
73
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
74
|
+
})();
|
|
75
|
+
return UserAuthInput = _classThis;
|
|
76
|
+
})();
|
|
77
|
+
let UserAuthResponse = (() => {
|
|
78
|
+
let _classDecorators_1 = [(0, graphql_1.gqlObjectType)()];
|
|
79
|
+
let _classDescriptor_1;
|
|
80
|
+
let _classExtraInitializers_1 = [];
|
|
81
|
+
let _classThis_1;
|
|
82
|
+
let _instanceExtraInitializers_1 = [];
|
|
83
|
+
let _token_decorators;
|
|
84
|
+
let _token_initializers = [];
|
|
85
|
+
let _viewerID_decorators;
|
|
86
|
+
let _viewerID_initializers = [];
|
|
87
|
+
var UserAuthResponse = _classThis_1 = class {
|
|
88
|
+
constructor() {
|
|
89
|
+
this.token = (__runInitializers(this, _instanceExtraInitializers_1), __runInitializers(this, _token_initializers, void 0));
|
|
90
|
+
this.viewerID = __runInitializers(this, _viewerID_initializers, void 0);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
__setFunctionName(_classThis_1, "UserAuthResponse");
|
|
94
|
+
(() => {
|
|
95
|
+
_token_decorators = [(0, graphql_1.gqlField)({
|
|
96
|
+
nodeName: "UserAuthResponse",
|
|
97
|
+
type: graphql_2.GraphQLString,
|
|
98
|
+
})];
|
|
99
|
+
_viewerID_decorators = [(0, graphql_1.gqlField)({ nodeName: "UserAuthResponses", type: graphql_2.GraphQLID })];
|
|
100
|
+
__esDecorate(null, null, _token_decorators, { kind: "field", name: "token", static: false, private: false, access: { has: obj => "token" in obj, get: obj => obj.token, set: (obj, value) => { obj.token = value; } } }, _token_initializers, _instanceExtraInitializers_1);
|
|
101
|
+
__esDecorate(null, null, _viewerID_decorators, { kind: "field", name: "viewerID", static: false, private: false, access: { has: obj => "viewerID" in obj, get: obj => obj.viewerID, set: (obj, value) => { obj.viewerID = value; } } }, _viewerID_initializers, _instanceExtraInitializers_1);
|
|
102
|
+
__esDecorate(null, _classDescriptor_1 = { value: _classThis_1 }, _classDecorators_1, { kind: "class", name: _classThis_1.name }, null, _classExtraInitializers_1);
|
|
103
|
+
UserAuthResponse = _classThis_1 = _classDescriptor_1.value;
|
|
104
|
+
__runInitializers(_classThis_1, _classExtraInitializers_1);
|
|
105
|
+
})();
|
|
106
|
+
return UserAuthResponse = _classThis_1;
|
|
107
|
+
})();
|
|
108
|
+
let AuthResolver = (() => {
|
|
109
|
+
var _a;
|
|
110
|
+
let _instanceExtraInitializers_2 = [];
|
|
111
|
+
let _userAuth_decorators;
|
|
112
|
+
return _a = class AuthResolver {
|
|
113
|
+
async userAuth(input) {
|
|
114
|
+
throw new Error("not implemented");
|
|
115
|
+
}
|
|
116
|
+
constructor() {
|
|
117
|
+
__runInitializers(this, _instanceExtraInitializers_2);
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
(() => {
|
|
121
|
+
_userAuth_decorators = [(0, graphql_1.gqlMutation)({
|
|
122
|
+
nodeName: "AuthResolver",
|
|
123
|
+
name: "userAuth",
|
|
124
|
+
type: UserAuthResponse,
|
|
125
|
+
args: [
|
|
126
|
+
{
|
|
127
|
+
name: "input",
|
|
128
|
+
type: UserAuthInput,
|
|
129
|
+
},
|
|
130
|
+
],
|
|
131
|
+
})];
|
|
132
|
+
__esDecorate(_a, null, _userAuth_decorators, { kind: "method", name: "userAuth", static: false, private: false, access: { has: obj => "userAuth" in obj, get: obj => obj.userAuth } }, null, _instanceExtraInitializers_2);
|
|
133
|
+
})(),
|
|
134
|
+
_a;
|
|
135
|
+
})();
|
|
@@ -1,46 +1,94 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
3
|
+
var useValue = arguments.length > 2;
|
|
4
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
5
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
6
|
+
}
|
|
7
|
+
return useValue ? value : void 0;
|
|
7
8
|
};
|
|
8
|
-
var
|
|
9
|
-
if (
|
|
9
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
10
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
11
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
12
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
13
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
14
|
+
var _, done = false;
|
|
15
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
16
|
+
var context = {};
|
|
17
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
18
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
19
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
20
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
21
|
+
if (kind === "accessor") {
|
|
22
|
+
if (result === void 0) continue;
|
|
23
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
24
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
25
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
26
|
+
if (_ = accept(result.init)) initializers.push(_);
|
|
27
|
+
}
|
|
28
|
+
else if (_ = accept(result)) {
|
|
29
|
+
if (kind === "field") initializers.push(_);
|
|
30
|
+
else descriptor[key] = _;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
34
|
+
done = true;
|
|
10
35
|
};
|
|
11
|
-
var
|
|
12
|
-
|
|
36
|
+
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
37
|
+
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
38
|
+
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
13
39
|
};
|
|
14
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
41
|
const graphql_1 = require("../../../graphql/graphql");
|
|
16
42
|
const graphql_2 = require("graphql");
|
|
17
|
-
let ViewerType =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
exports.default =
|
|
43
|
+
let ViewerType = (() => {
|
|
44
|
+
let _classDecorators = [(0, graphql_1.gqlObjectType)({ name: "Viewer" })];
|
|
45
|
+
let _classDescriptor;
|
|
46
|
+
let _classExtraInitializers = [];
|
|
47
|
+
let _classThis;
|
|
48
|
+
let _instanceExtraInitializers = [];
|
|
49
|
+
let _get_viewerID_decorators;
|
|
50
|
+
var ViewerType = _classThis = class {
|
|
51
|
+
constructor(viewer) {
|
|
52
|
+
this.viewer = (__runInitializers(this, _instanceExtraInitializers), viewer);
|
|
53
|
+
}
|
|
54
|
+
get viewerID() {
|
|
55
|
+
return this.viewer.viewerID;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
__setFunctionName(_classThis, "ViewerType");
|
|
59
|
+
(() => {
|
|
60
|
+
_get_viewerID_decorators = [(0, graphql_1.gqlField)({
|
|
61
|
+
nodeName: "ViewerType",
|
|
62
|
+
type: graphql_2.GraphQLID,
|
|
63
|
+
nullable: true,
|
|
64
|
+
})];
|
|
65
|
+
__esDecorate(_classThis, null, _get_viewerID_decorators, { kind: "getter", name: "viewerID", static: false, private: false, access: { has: obj => "viewerID" in obj, get: obj => obj.viewerID } }, null, _instanceExtraInitializers);
|
|
66
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers);
|
|
67
|
+
ViewerType = _classThis = _classDescriptor.value;
|
|
68
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
69
|
+
})();
|
|
70
|
+
return ViewerType = _classThis;
|
|
71
|
+
})();
|
|
72
|
+
exports.default = (() => {
|
|
73
|
+
var _a;
|
|
74
|
+
let _instanceExtraInitializers_1 = [];
|
|
75
|
+
let _viewer_decorators;
|
|
76
|
+
return _a = class ViewerResolver {
|
|
77
|
+
viewer(context) {
|
|
78
|
+
return new ViewerType(context.getViewer());
|
|
79
|
+
}
|
|
80
|
+
constructor() {
|
|
81
|
+
__runInitializers(this, _instanceExtraInitializers_1);
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
(() => {
|
|
85
|
+
_viewer_decorators = [(0, graphql_1.gqlQuery)({
|
|
86
|
+
nodeName: "ViewerResolver",
|
|
87
|
+
name: "viewer",
|
|
88
|
+
type: ViewerType,
|
|
89
|
+
args: [(0, graphql_1.gqlContextType)()],
|
|
90
|
+
})];
|
|
91
|
+
__esDecorate(_a, null, _viewer_decorators, { kind: "method", name: "viewer", static: false, private: false, access: { has: obj => "viewer" in obj, get: obj => obj.viewer } }, null, _instanceExtraInitializers_1);
|
|
92
|
+
})(),
|
|
93
|
+
_a;
|
|
94
|
+
})();
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * from "./core/base";
|
|
2
|
-
export { loadEnt, loadCustomData, loadCustomEnts, loadCustomCount, loadEntX, loadEnts, CustomQuery, loadDerivedEnt, loadDerivedEntX, loadEntViaKey, loadEntXViaKey, performRawQuery, loadRowX, loadRow, loadRows, DataOperation, EditNodeOptions, EditNodeOperation, RawQueryOperation, EdgeOperation, DeleteNodeOperation, AssocEdge, AssocEdgeInputOptions, AssocEdgeInput, AssocEdgeData, loadEdgeData, loadEdgeDatas, loadEdges, loadUniqueEdge, loadUniqueNode, loadRawEdgeCountX, loadEdgeForID2, loadNodesByEdge, getEdgeTypeInGroup, } from "./core/ent";
|
|
3
|
-
export { setGlobalSchema } from "./core/global_schema";
|
|
2
|
+
export { loadEnt, loadCustomData, loadCustomEnts, loadCustomCount, loadEntX, loadEnts, CustomQuery, loadDerivedEnt, loadDerivedEntX, loadEntViaKey, loadEntXViaKey, performRawQuery, loadRowX, loadRow, loadRows, DataOperation, EditNodeOptions, EditNodeOperation, RawQueryOperation, EdgeOperation, DeleteNodeOperation, AssocEdge, AssocEdgeInputOptions, AssocEdgeInput, AssocEdgeData, loadEdgeData, loadEdgeDatas, loadEdges, loadUniqueEdge, loadUniqueNode, loadRawEdgeCountX, loadEdgeForID2, loadNodesByEdge, getEdgeTypeInGroup, setGlobalSchema, } from "./core/ent";
|
|
4
3
|
import DB from "./core/db";
|
|
5
4
|
export * from "./core/loaders";
|
|
6
5
|
export { DB };
|
package/index.js
CHANGED
|
@@ -63,8 +63,7 @@ Object.defineProperty(exports, "loadRawEdgeCountX", { enumerable: true, get: fun
|
|
|
63
63
|
Object.defineProperty(exports, "loadEdgeForID2", { enumerable: true, get: function () { return ent_1.loadEdgeForID2; } });
|
|
64
64
|
Object.defineProperty(exports, "loadNodesByEdge", { enumerable: true, get: function () { return ent_1.loadNodesByEdge; } });
|
|
65
65
|
Object.defineProperty(exports, "getEdgeTypeInGroup", { enumerable: true, get: function () { return ent_1.getEdgeTypeInGroup; } });
|
|
66
|
-
|
|
67
|
-
Object.defineProperty(exports, "setGlobalSchema", { enumerable: true, get: function () { return global_schema_1.setGlobalSchema; } });
|
|
66
|
+
Object.defineProperty(exports, "setGlobalSchema", { enumerable: true, get: function () { return ent_1.setGlobalSchema; } });
|
|
68
67
|
const db_1 = __importDefault(require("./core/db"));
|
|
69
68
|
exports.DB = db_1.default;
|
|
70
69
|
__exportStar(require("./core/loaders"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@snowtop/ent",
|
|
3
|
-
"version": "0.1.0-
|
|
3
|
+
"version": "0.1.0-alpha125",
|
|
4
4
|
"description": "snowtop ent framework",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -22,12 +22,11 @@
|
|
|
22
22
|
"pascal-case": "^3.1.2",
|
|
23
23
|
"pg": "^8.8.0",
|
|
24
24
|
"prettier": "^2.8.1",
|
|
25
|
-
"reflect-metadata": "^0.1.13",
|
|
26
25
|
"snake-case": "^3.0.4",
|
|
27
26
|
"ts-node": "^10.9.1",
|
|
28
|
-
"tsconfig-paths": "^4.
|
|
29
|
-
"tslib": "^2.
|
|
30
|
-
"typescript": "^
|
|
27
|
+
"tsconfig-paths": "^4.2.0",
|
|
28
|
+
"tslib": "^2.5.0",
|
|
29
|
+
"typescript": "^5.0.4",
|
|
31
30
|
"uuid": "^9.0.0"
|
|
32
31
|
},
|
|
33
32
|
"peerDependencies": {
|
package/parse_schema/parse.d.ts
CHANGED
package/parse_schema/parse.js
CHANGED
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.parseSchema = void 0;
|
|
4
4
|
const cosmiconfig_1 = require("cosmiconfig");
|
|
5
5
|
const const_1 = require("../core/const");
|
|
6
|
-
const global_schema_1 = require("../core/global_schema");
|
|
7
6
|
async function processFields(src, patternName) {
|
|
8
7
|
const ret = [];
|
|
9
8
|
let m = {};
|
|
@@ -237,9 +236,6 @@ async function parseSchema(potentialSchemas, globalSchema) {
|
|
|
237
236
|
let parsedGlobalSchema;
|
|
238
237
|
if (globalSchema) {
|
|
239
238
|
parsedGlobalSchema = await parseGlobalSchema(globalSchema);
|
|
240
|
-
// set this so that we can use it, if we're trying to process server default or anything
|
|
241
|
-
// that ends up parsing,validating and formatting fields
|
|
242
|
-
(0, global_schema_1.setGlobalSchema)(globalSchema);
|
|
243
239
|
}
|
|
244
240
|
for (const key in potentialSchemas) {
|
|
245
241
|
const value = potentialSchemas[key];
|
|
@@ -358,10 +354,9 @@ async function parseGlobalSchema(s) {
|
|
|
358
354
|
const ret = {
|
|
359
355
|
globalEdges: [],
|
|
360
356
|
extraEdgeFields: [],
|
|
361
|
-
|
|
357
|
+
initForEdges: !!s.extraEdgeFields ||
|
|
362
358
|
s.transformEdgeRead !== undefined ||
|
|
363
|
-
s.transformEdgeWrite !== undefined
|
|
364
|
-
s.fields !== undefined,
|
|
359
|
+
s.transformEdgeWrite !== undefined,
|
|
365
360
|
};
|
|
366
361
|
if (s.extraEdgeFields) {
|
|
367
362
|
ret.extraEdgeFields = await processFields(s.extraEdgeFields);
|
|
@@ -369,8 +364,5 @@ async function parseGlobalSchema(s) {
|
|
|
369
364
|
if (s.edges) {
|
|
370
365
|
ret.globalEdges = processEdges(s.edges);
|
|
371
366
|
}
|
|
372
|
-
if (s.fields) {
|
|
373
|
-
ret.globalFields = await processFields(s.fields);
|
|
374
|
-
}
|
|
375
367
|
return ret;
|
|
376
368
|
}
|
package/schema/field.d.ts
CHANGED
|
@@ -149,7 +149,6 @@ export interface EnumOptions extends FieldOptions {
|
|
|
149
149
|
graphQLType?: string;
|
|
150
150
|
createEnumType?: boolean;
|
|
151
151
|
disableUnknownType?: boolean;
|
|
152
|
-
globalType?: string;
|
|
153
152
|
}
|
|
154
153
|
/**
|
|
155
154
|
* @deprecated Use StringEnumField
|
|
@@ -159,7 +158,7 @@ export declare class EnumField extends BaseField implements Field {
|
|
|
159
158
|
private values?;
|
|
160
159
|
private map?;
|
|
161
160
|
constructor(options: StringEnumOptions);
|
|
162
|
-
valid(val: any):
|
|
161
|
+
valid(val: any): boolean;
|
|
163
162
|
format(val: any): any;
|
|
164
163
|
}
|
|
165
164
|
export declare class StringEnumField extends EnumField {
|
|
@@ -174,18 +173,17 @@ declare type IntEnumMap = {
|
|
|
174
173
|
[key: string]: number;
|
|
175
174
|
};
|
|
176
175
|
export interface IntegerEnumOptions extends FieldOptions {
|
|
177
|
-
map
|
|
176
|
+
map: IntEnumMap;
|
|
178
177
|
deprecated?: IntEnumMap;
|
|
179
178
|
tsType?: string;
|
|
180
179
|
graphQLType?: string;
|
|
181
180
|
disableUnknownType?: boolean;
|
|
182
|
-
globalType?: string;
|
|
183
181
|
}
|
|
184
182
|
export declare class IntegerEnumField extends BaseField implements Field {
|
|
185
183
|
type: Type;
|
|
186
184
|
private map;
|
|
187
185
|
constructor(options: IntegerEnumOptions);
|
|
188
|
-
valid(val: any):
|
|
186
|
+
valid(val: any): boolean;
|
|
189
187
|
format(val: any): any;
|
|
190
188
|
}
|
|
191
189
|
export declare function IntegerEnumType(options: IntegerEnumOptions): IntegerEnumField;
|
package/schema/field.js
CHANGED
|
@@ -31,8 +31,6 @@ const uuid_1 = require("uuid");
|
|
|
31
31
|
const base_1 = require("../core/base");
|
|
32
32
|
const db_1 = __importStar(require("../core/db"));
|
|
33
33
|
const schema_1 = require("./schema");
|
|
34
|
-
const global_schema_1 = require("../core/global_schema");
|
|
35
|
-
const logger_1 = require("../core/logger");
|
|
36
34
|
class BaseField {
|
|
37
35
|
logValue(val) {
|
|
38
36
|
if (this.sensitive) {
|
|
@@ -527,11 +525,10 @@ class EnumField extends BaseField {
|
|
|
527
525
|
type: options.tsType,
|
|
528
526
|
graphQLType: options.graphQLType,
|
|
529
527
|
disableUnknownType: options.disableUnknownType,
|
|
530
|
-
globalType: options.globalType,
|
|
531
528
|
};
|
|
532
529
|
if (!options.foreignKey) {
|
|
533
|
-
if (!options.values && !options.map
|
|
534
|
-
throw new Error("values
|
|
530
|
+
if (!options.values && !options.map) {
|
|
531
|
+
throw new Error("values or map required if not look up table enum. Look-up table enum indicated by foreignKey field");
|
|
535
532
|
}
|
|
536
533
|
if (options.values) {
|
|
537
534
|
if (!options.values.length) {
|
|
@@ -550,8 +547,8 @@ class EnumField extends BaseField {
|
|
|
550
547
|
}
|
|
551
548
|
}
|
|
552
549
|
else {
|
|
553
|
-
if (options.values || options.map
|
|
554
|
-
throw new Error("cannot specify values
|
|
550
|
+
if (options.values || options.map) {
|
|
551
|
+
throw new Error("cannot specify values or map and foreign key for lookup table enum type");
|
|
555
552
|
}
|
|
556
553
|
if (options.createEnumType) {
|
|
557
554
|
throw new Error("cannot specify createEnumType without specifying values");
|
|
@@ -566,20 +563,7 @@ class EnumField extends BaseField {
|
|
|
566
563
|
this.values = options.values;
|
|
567
564
|
this.map = options.map;
|
|
568
565
|
}
|
|
569
|
-
|
|
570
|
-
if (this.type.globalType) {
|
|
571
|
-
const f = (0, global_schema_1.__getGlobalSchemaField)(this.type.globalType);
|
|
572
|
-
if (f) {
|
|
573
|
-
if (f.valid) {
|
|
574
|
-
return f.valid(val);
|
|
575
|
-
}
|
|
576
|
-
return true;
|
|
577
|
-
}
|
|
578
|
-
else {
|
|
579
|
-
(0, logger_1.log)("error", `globalType ${this.type.globalType} not found in global schema`);
|
|
580
|
-
return false;
|
|
581
|
-
}
|
|
582
|
-
}
|
|
566
|
+
valid(val) {
|
|
583
567
|
// lookup table enum and indicated via presence of foreignKey
|
|
584
568
|
if (!this.values && !this.map) {
|
|
585
569
|
return true;
|
|
@@ -597,13 +581,6 @@ class EnumField extends BaseField {
|
|
|
597
581
|
return false;
|
|
598
582
|
}
|
|
599
583
|
format(val) {
|
|
600
|
-
if (this.type.globalType) {
|
|
601
|
-
const f = (0, global_schema_1.__getGlobalSchemaField)(this.type.globalType);
|
|
602
|
-
if (f && f.format) {
|
|
603
|
-
return f.format(val);
|
|
604
|
-
}
|
|
605
|
-
return val;
|
|
606
|
-
}
|
|
607
584
|
return val;
|
|
608
585
|
}
|
|
609
586
|
}
|
|
@@ -626,46 +603,21 @@ class IntegerEnumField extends BaseField {
|
|
|
626
603
|
graphQLType: options.graphQLType,
|
|
627
604
|
deprecatedIntEnumMap: options.deprecated,
|
|
628
605
|
disableUnknownType: options.disableUnknownType,
|
|
629
|
-
globalType: options.globalType,
|
|
630
606
|
};
|
|
631
|
-
|
|
632
|
-
|
|
607
|
+
let count = 0;
|
|
608
|
+
for (const _ in options.map) {
|
|
609
|
+
count++;
|
|
610
|
+
break;
|
|
633
611
|
}
|
|
634
|
-
if (
|
|
635
|
-
|
|
636
|
-
throw new Error(`cannot specify map and globalType`);
|
|
637
|
-
}
|
|
638
|
-
this.map = {};
|
|
612
|
+
if (!count) {
|
|
613
|
+
throw new Error("need at least one entry in enum map");
|
|
639
614
|
}
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
for (const _ in options.map) {
|
|
643
|
-
count++;
|
|
644
|
-
break;
|
|
645
|
-
}
|
|
646
|
-
if (!count) {
|
|
647
|
-
throw new Error("need at least one entry in enum map");
|
|
648
|
-
}
|
|
649
|
-
if (!options.map) {
|
|
650
|
-
throw new Error("map required if not globalType");
|
|
651
|
-
}
|
|
652
|
-
this.map = options.map;
|
|
615
|
+
if (options.foreignKey) {
|
|
616
|
+
throw new Error(`foreignKey on intEnum not supported`);
|
|
653
617
|
}
|
|
618
|
+
this.map = options.map;
|
|
654
619
|
}
|
|
655
|
-
|
|
656
|
-
if (this.type?.globalType) {
|
|
657
|
-
const f = (0, global_schema_1.__getGlobalSchemaField)(this.type.globalType);
|
|
658
|
-
if (f) {
|
|
659
|
-
if (f.valid) {
|
|
660
|
-
return f.valid(val);
|
|
661
|
-
}
|
|
662
|
-
return true;
|
|
663
|
-
}
|
|
664
|
-
else {
|
|
665
|
-
(0, logger_1.log)("error", `globalType ${this.type.globalType} not found in global schema`);
|
|
666
|
-
return false;
|
|
667
|
-
}
|
|
668
|
-
}
|
|
620
|
+
valid(val) {
|
|
669
621
|
// lookup table enum and indicated via presence of foreignKey
|
|
670
622
|
for (const k in this.map) {
|
|
671
623
|
const v = this.map[k];
|
|
@@ -676,12 +628,6 @@ class IntegerEnumField extends BaseField {
|
|
|
676
628
|
return false;
|
|
677
629
|
}
|
|
678
630
|
format(val) {
|
|
679
|
-
if (this.type.globalType) {
|
|
680
|
-
const f = (0, global_schema_1.__getGlobalSchemaField)(this.type.globalType);
|
|
681
|
-
if (f && f.format) {
|
|
682
|
-
return f.format(val);
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
631
|
return parseInt(val);
|
|
686
632
|
}
|
|
687
633
|
}
|
package/schema/schema.d.ts
CHANGED
|
@@ -17,7 +17,6 @@ export interface GlobalSchema {
|
|
|
17
17
|
extraEdgeFields?: FieldMap;
|
|
18
18
|
transformEdgeRead?: () => Clause;
|
|
19
19
|
transformEdgeWrite?: (stmt: EdgeUpdateOperation) => TransformedEdgeUpdateOperation | null;
|
|
20
|
-
fields?: FieldMap;
|
|
21
20
|
}
|
|
22
21
|
type FieldOverride = Pick<FieldOptions, "nullable" | "storageKey" | "serverDefault" | "unique" | "hideFromGraphQL" | "graphqlName" | "index">;
|
|
23
22
|
export type FieldOverrideMap = {
|
|
@@ -172,7 +171,6 @@ export interface Type {
|
|
|
172
171
|
intEnumMap?: IntEnumMap;
|
|
173
172
|
deprecatedIntEnumMap?: IntEnumMap;
|
|
174
173
|
disableUnknownType?: boolean;
|
|
175
|
-
globalType?: string;
|
|
176
174
|
importType?: DeprecatedImportType;
|
|
177
175
|
subFields?: FieldMap;
|
|
178
176
|
unionFields?: FieldMap;
|
package/schema/struct_field.d.ts
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
import { BaseField, ListField } from "./field";
|
|
2
2
|
import { FieldOptions, Field, Type, FieldMap } from "./schema";
|
|
3
|
-
interface
|
|
3
|
+
export interface StructOptions extends FieldOptions {
|
|
4
4
|
tsType: string;
|
|
5
5
|
fields: FieldMap;
|
|
6
6
|
graphQLType?: string;
|
|
7
7
|
jsonNotJSONB?: boolean;
|
|
8
8
|
}
|
|
9
|
-
interface
|
|
10
|
-
|
|
9
|
+
interface allStructOptions extends StructOptions {
|
|
10
|
+
jsonAsList?: boolean;
|
|
11
11
|
}
|
|
12
|
-
export type StructOptions = structFieldOptions | GlobalStructOptions;
|
|
13
12
|
export declare class StructField extends BaseField implements Field {
|
|
14
13
|
private options;
|
|
15
|
-
private jsonAsList?;
|
|
16
14
|
type: Type;
|
|
17
|
-
constructor(options:
|
|
15
|
+
constructor(options: allStructOptions);
|
|
18
16
|
formatImpl(obj: any, nested?: boolean): string | Object;
|
|
19
|
-
format(obj: any, nested?: boolean):
|
|
17
|
+
format(obj: any, nested?: boolean): string | Object;
|
|
20
18
|
private validImpl;
|
|
21
19
|
valid(obj: any): Promise<boolean>;
|
|
22
20
|
}
|
|
@@ -25,5 +23,5 @@ export declare function StructType(options: StructOptions): StructField & Struct
|
|
|
25
23
|
* @deprecated use StructTypeAsList
|
|
26
24
|
*/
|
|
27
25
|
export declare function StructListType(options: StructOptions): ListField;
|
|
28
|
-
export declare function StructTypeAsList(options:
|
|
26
|
+
export declare function StructTypeAsList(options: allStructOptions): StructField & allStructOptions;
|
|
29
27
|
export {};
|