@cedarjs/structure 2.8.1-next.116 → 2.8.1
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/README.md +1 -1
- package/dist/errors.js +15 -9
- package/dist/index.d.ts +7 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +67 -40
- package/dist/model/RWCell.d.ts +4 -4
- package/dist/model/RWCell.d.ts.map +1 -1
- package/dist/model/RWCell.js +103 -111
- package/dist/model/RWComponent.d.ts +2 -2
- package/dist/model/RWComponent.d.ts.map +1 -1
- package/dist/model/RWComponent.js +41 -46
- package/dist/model/RWEnvHelper.d.ts +4 -4
- package/dist/model/RWEnvHelper.d.ts.map +1 -1
- package/dist/model/RWEnvHelper.js +205 -212
- package/dist/model/RWFunction.d.ts +2 -2
- package/dist/model/RWFunction.d.ts.map +1 -1
- package/dist/model/RWFunction.js +15 -10
- package/dist/model/RWLayout.d.ts +2 -2
- package/dist/model/RWLayout.d.ts.map +1 -1
- package/dist/model/RWLayout.js +15 -10
- package/dist/model/RWPage.d.ts +3 -3
- package/dist/model/RWPage.d.ts.map +1 -1
- package/dist/model/RWPage.js +57 -61
- package/dist/model/RWProject.d.ts +17 -11
- package/dist/model/RWProject.d.ts.map +1 -1
- package/dist/model/RWProject.js +164 -218
- package/dist/model/RWRoute.d.ts +5 -5
- package/dist/model/RWRoute.d.ts.map +1 -1
- package/dist/model/RWRoute.js +262 -312
- package/dist/model/RWRouter.d.ts +4 -4
- package/dist/model/RWRouter.d.ts.map +1 -1
- package/dist/model/RWRouter.js +126 -130
- package/dist/model/RWSDL.d.ts +5 -5
- package/dist/model/RWSDL.d.ts.map +1 -1
- package/dist/model/RWSDL.js +84 -96
- package/dist/model/RWSDLField.d.ts +6 -6
- package/dist/model/RWSDLField.d.ts.map +1 -1
- package/dist/model/RWSDLField.js +81 -79
- package/dist/model/RWService.d.ts +4 -4
- package/dist/model/RWService.d.ts.map +1 -1
- package/dist/model/RWService.js +76 -76
- package/dist/model/RWServiceFunction.d.ts +4 -4
- package/dist/model/RWServiceFunction.d.ts.map +1 -1
- package/dist/model/RWServiceFunction.js +97 -95
- package/dist/model/RWTOML.d.ts +3 -3
- package/dist/model/RWTOML.d.ts.map +1 -1
- package/dist/model/RWTOML.js +55 -53
- package/dist/model/index.d.ts +2 -2
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +20 -3
- package/dist/model/util/process_env.js +62 -44
- package/dist/nodes.d.ts +2 -2
- package/dist/nodes.d.ts.map +1 -1
- package/dist/nodes.js +164 -171
- package/dist/util.js +33 -23
- package/dist/x/Array.js +25 -15
- package/dist/x/Location.d.ts +1 -1
- package/dist/x/Location.d.ts.map +1 -1
- package/dist/x/Location.js +17 -11
- package/dist/x/Position.js +29 -18
- package/dist/x/Range.d.ts +1 -1
- package/dist/x/Range.d.ts.map +1 -1
- package/dist/x/Range.js +22 -17
- package/dist/x/URL.js +75 -59
- package/dist/x/child_process.d.ts +1 -1
- package/dist/x/child_process.d.ts.map +1 -1
- package/dist/x/child_process.js +49 -35
- package/dist/x/decorators.d.ts +2 -2
- package/dist/x/decorators.d.ts.map +1 -1
- package/dist/x/decorators.js +26 -46
- package/dist/x/diagnostics.d.ts +3 -3
- package/dist/x/diagnostics.d.ts.map +1 -1
- package/dist/x/diagnostics.js +259 -163
- package/dist/x/path.js +55 -36
- package/dist/x/prisma.d.ts +2 -2
- package/dist/x/prisma.d.ts.map +1 -1
- package/dist/x/prisma.js +55 -32
- package/dist/x/ts-morph.js +45 -34
- package/package.json +17 -38
- package/dist/errors.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/model/RWCell.js.map +0 -1
- package/dist/model/RWComponent.js.map +0 -1
- package/dist/model/RWEnvHelper.js.map +0 -1
- package/dist/model/RWFunction.js.map +0 -1
- package/dist/model/RWLayout.js.map +0 -1
- package/dist/model/RWPage.js.map +0 -1
- package/dist/model/RWProject.js.map +0 -1
- package/dist/model/RWRoute.js.map +0 -1
- package/dist/model/RWRouter.js.map +0 -1
- package/dist/model/RWSDL.js.map +0 -1
- package/dist/model/RWSDLField.js.map +0 -1
- package/dist/model/RWService.js.map +0 -1
- package/dist/model/RWServiceFunction.js.map +0 -1
- package/dist/model/RWTOML.js.map +0 -1
- package/dist/model/index.js.map +0 -1
- package/dist/model/util/process_env.js.map +0 -1
- package/dist/nodes.js.map +0 -1
- package/dist/util.js.map +0 -1
- package/dist/x/Array.js.map +0 -1
- package/dist/x/Location.js.map +0 -1
- package/dist/x/Position.js.map +0 -1
- package/dist/x/Range.js.map +0 -1
- package/dist/x/URL.js.map +0 -1
- package/dist/x/child_process.js.map +0 -1
- package/dist/x/decorators.js.map +0 -1
- package/dist/x/diagnostics.js.map +0 -1
- package/dist/x/path.js.map +0 -1
- package/dist/x/prisma.js.map +0 -1
- package/dist/x/ts-morph.js.map +0 -1
package/dist/model/RWRouter.js
CHANGED
|
@@ -1,139 +1,135 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js/object/define-property");
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
5
|
+
var _interopRequireWildcard = require("@babel/runtime-corejs3/helpers/interopRequireWildcard").default;
|
|
6
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
exports.RWRouter = void 0;
|
|
10
|
+
var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/find"));
|
|
11
|
+
var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/includes"));
|
|
12
|
+
var _bind = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/bind"));
|
|
13
|
+
var _filter = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/filter"));
|
|
14
|
+
var _getOwnPropertyDescriptor = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/object/get-own-property-descriptor"));
|
|
15
|
+
var _applyDecoratedDescriptor2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/applyDecoratedDescriptor"));
|
|
16
|
+
var tsm = _interopRequireWildcard(require("ts-morph"));
|
|
17
|
+
var _projectConfig = require("@cedarjs/project-config");
|
|
18
|
+
var _errors = require("../errors");
|
|
19
|
+
var _nodes = require("../nodes");
|
|
20
|
+
var _Array = require("../x/Array");
|
|
21
|
+
var _decorators = require("../x/decorators");
|
|
22
|
+
var _diagnostics = require("../x/diagnostics");
|
|
23
|
+
var _URL = require("../x/URL");
|
|
24
|
+
var _RWRoute = require("./RWRoute");
|
|
25
|
+
var _dec, _dec2, _dec3, _dec4, _dec5, _class;
|
|
17
26
|
/**
|
|
18
27
|
* one per Routes.js
|
|
19
28
|
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
let RWRouter = exports.RWRouter = (_dec = (0, _decorators.memo)(), _dec2 = (0, _decorators.memo)(), _dec3 = (0, _decorators.lazy)(), _dec4 = (0, _decorators.lazy)(), _dec5 = (0, _decorators.lazy)(), _class = class RWRouter extends _nodes.FileNode {
|
|
30
|
+
constructor(filePath, parent) {
|
|
31
|
+
super();
|
|
32
|
+
this.filePath = filePath;
|
|
33
|
+
this.parent = parent;
|
|
34
|
+
}
|
|
35
|
+
// this is used by the live preview
|
|
36
|
+
getFilePathForRoutePath(routePath) {
|
|
37
|
+
var _context;
|
|
38
|
+
// TODO: params
|
|
39
|
+
return (0, _find.default)(_context = this.routes).call(_context, r => r.path === routePath)?.page?.filePath;
|
|
40
|
+
}
|
|
41
|
+
// this is used by the live preview
|
|
42
|
+
getRoutePathForFilePath(filePath) {
|
|
43
|
+
var _context2, _context3, _context4;
|
|
44
|
+
// TODO: params
|
|
45
|
+
const path = (0, _find.default)(_context2 = this.parent.pages).call(_context2, p => p.filePath === filePath)?.route?.path;
|
|
46
|
+
if (((_context3 = path) == null ? void 0 : (0, _bind.default)(_context4 = Function.call).call(_context4, (0, _includes.default)(_context3), _context3))?.('{')) {
|
|
47
|
+
return;
|
|
27
48
|
}
|
|
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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
.filter((x) => {
|
|
66
|
-
const tagName = x.getOpeningElement().getTagNameNode().getText();
|
|
67
|
-
return (tagName === 'Set' ||
|
|
68
|
-
tagName === 'Private' ||
|
|
69
|
-
tagName === 'PrivateSet');
|
|
49
|
+
return path;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* the `<Router>` tag
|
|
54
|
+
*/
|
|
55
|
+
get jsxNode() {
|
|
56
|
+
var _context5;
|
|
57
|
+
return (0, _find.default)(_context5 = this.sf.getDescendantsOfKind(tsm.SyntaxKind.JsxOpeningElement)).call(_context5, x => x.getTagNameNode().getText() === 'Router');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* One per `<Route>`
|
|
62
|
+
*/
|
|
63
|
+
get routes() {
|
|
64
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
65
|
+
const self = this;
|
|
66
|
+
return (0, _Array.iter)(function* () {
|
|
67
|
+
var _context6;
|
|
68
|
+
if (!self.jsxNode) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
// TODO: make sure that they are nested within the <Router> tag
|
|
72
|
+
// we are not checking it right now
|
|
73
|
+
|
|
74
|
+
const sets = (0, _filter.default)(_context6 = self.sf.getDescendantsOfKind(tsm.SyntaxKind.JsxElement)).call(_context6, x => {
|
|
75
|
+
const tagName = x.getOpeningElement().getTagNameNode().getText();
|
|
76
|
+
return tagName === 'Set' || tagName === 'Private' || tagName === 'PrivateSet';
|
|
77
|
+
});
|
|
78
|
+
const prerenderSets = (0, _filter.default)(sets).call(sets, set => set.getOpeningElement().getAttribute('prerender'));
|
|
79
|
+
for (const set of prerenderSets) {
|
|
80
|
+
for (const x of set.getDescendantsOfKind(tsm.SyntaxKind.JsxSelfClosingElement)) {
|
|
81
|
+
const tagName = x.getTagNameNode().getText();
|
|
82
|
+
// Add prerender prop from <Set> if not already present
|
|
83
|
+
if (tagName === 'Route' && !x.getAttribute('prerender')) {
|
|
84
|
+
x.insertAttribute(0, {
|
|
85
|
+
name: 'prerender'
|
|
70
86
|
});
|
|
71
|
-
|
|
72
|
-
for (const set of prerenderSets) {
|
|
73
|
-
for (const x of set.getDescendantsOfKind(tsm.SyntaxKind.JsxSelfClosingElement)) {
|
|
74
|
-
const tagName = x.getTagNameNode().getText();
|
|
75
|
-
// Add prerender prop from <Set> if not already present
|
|
76
|
-
if (tagName === 'Route' && !x.getAttribute('prerender')) {
|
|
77
|
-
x.insertAttribute(0, { name: 'prerender' });
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
for (const x of self.sf.getDescendantsOfKind(tsm.SyntaxKind.JsxSelfClosingElement)) {
|
|
82
|
-
const tagName = x.getTagNameNode().getText();
|
|
83
|
-
if (tagName === 'Route') {
|
|
84
|
-
yield new RWRoute(x, self);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
get numNotFoundPages() {
|
|
90
|
-
return this.routes.filter((r) => r.isNotFound).length;
|
|
91
|
-
}
|
|
92
|
-
*diagnostics() {
|
|
93
|
-
if (!this.fileExists) {
|
|
94
|
-
// should we assign this error to the project? to cedar.toml?
|
|
95
|
-
const uri = URL_file(getConfigPath());
|
|
96
|
-
const message = `Routes.js does not exist`;
|
|
97
|
-
yield err(uri, message);
|
|
98
|
-
// TODO: add quickFix (create a simple Routes.js)
|
|
99
|
-
return; // stop checking for errors if the file doesn't exist
|
|
100
|
-
}
|
|
101
|
-
if (!this.jsxNode) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
if (this.numNotFoundPages === 0) {
|
|
105
|
-
const { uri, range } = LocationLike_toLocation(this.jsxNode);
|
|
106
|
-
yield {
|
|
107
|
-
uri,
|
|
108
|
-
diagnostic: {
|
|
109
|
-
range,
|
|
110
|
-
message: "You must specify a 'notfound' page",
|
|
111
|
-
severity: DiagnosticSeverity.Error,
|
|
112
|
-
},
|
|
113
|
-
};
|
|
87
|
+
}
|
|
114
88
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
89
|
+
}
|
|
90
|
+
for (const x of self.sf.getDescendantsOfKind(tsm.SyntaxKind.JsxSelfClosingElement)) {
|
|
91
|
+
const tagName = x.getTagNameNode().getText();
|
|
92
|
+
if (tagName === 'Route') {
|
|
93
|
+
yield new _RWRoute.RWRoute(x, self);
|
|
118
94
|
}
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
get numNotFoundPages() {
|
|
99
|
+
var _context7;
|
|
100
|
+
return (0, _filter.default)(_context7 = this.routes).call(_context7, r => r.isNotFound).length;
|
|
101
|
+
}
|
|
102
|
+
*diagnostics() {
|
|
103
|
+
if (!this.fileExists) {
|
|
104
|
+
// should we assign this error to the project? to cedar.toml?
|
|
105
|
+
const uri = (0, _URL.URL_file)((0, _projectConfig.getConfigPath)(this.parent.projectRoot));
|
|
106
|
+
const message = `Routes.js does not exist`;
|
|
107
|
+
yield (0, _diagnostics.err)(uri, message);
|
|
108
|
+
// TODO: add quickFix (create a simple Routes.js)
|
|
109
|
+
return; // stop checking for errors if the file doesn't exist
|
|
119
110
|
}
|
|
120
|
-
|
|
121
|
-
|
|
111
|
+
if (!this.jsxNode) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if (this.numNotFoundPages === 0) {
|
|
115
|
+
const {
|
|
116
|
+
uri,
|
|
117
|
+
range
|
|
118
|
+
} = (0, _diagnostics.LocationLike_toLocation)(this.jsxNode);
|
|
119
|
+
yield {
|
|
120
|
+
uri,
|
|
121
|
+
diagnostic: {
|
|
122
|
+
range,
|
|
123
|
+
message: "You must specify a 'notfound' page",
|
|
124
|
+
severity: _diagnostics.DiagnosticSeverity.Error
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
} else if (this.numNotFoundPages > 1) {
|
|
128
|
+
const e = (0, _diagnostics.err)(this.jsxNode, "You must specify exactly one 'notfound' page", _errors.RWError.NOTFOUND_PAGE_NOT_DEFINED);
|
|
129
|
+
yield e;
|
|
122
130
|
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
memo()
|
|
129
|
-
], RWRouter.prototype, "getRoutePathForFilePath", null);
|
|
130
|
-
__decorate([
|
|
131
|
-
lazy()
|
|
132
|
-
], RWRouter.prototype, "jsxNode", null);
|
|
133
|
-
__decorate([
|
|
134
|
-
lazy()
|
|
135
|
-
], RWRouter.prototype, "routes", null);
|
|
136
|
-
__decorate([
|
|
137
|
-
lazy()
|
|
138
|
-
], RWRouter.prototype, "numNotFoundPages", null);
|
|
139
|
-
//# sourceMappingURL=RWRouter.js.map
|
|
131
|
+
}
|
|
132
|
+
children() {
|
|
133
|
+
return [...this.routes];
|
|
134
|
+
}
|
|
135
|
+
}, (0, _applyDecoratedDescriptor2.default)(_class.prototype, "getFilePathForRoutePath", [_dec], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "getFilePathForRoutePath"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "getRoutePathForFilePath", [_dec2], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "getRoutePathForFilePath"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "jsxNode", [_dec3], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "jsxNode"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "routes", [_dec4], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "routes"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "numNotFoundPages", [_dec5], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "numNotFoundPages"), _class.prototype), _class);
|
package/dist/model/RWSDL.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as tsm from 'ts-morph';
|
|
2
|
-
import { FileNode } from '../nodes
|
|
3
|
-
import type { RWProject } from './RWProject
|
|
4
|
-
import { RWSDLField } from './RWSDLField
|
|
2
|
+
import { FileNode } from '../nodes';
|
|
3
|
+
import type { RWProject } from './RWProject';
|
|
4
|
+
import { RWSDLField } from './RWSDLField';
|
|
5
5
|
export declare class RWSDL extends FileNode {
|
|
6
6
|
filePath: string;
|
|
7
7
|
parent: RWProject;
|
|
@@ -12,10 +12,10 @@ export declare class RWSDL extends FileNode {
|
|
|
12
12
|
get schemaStringNode(): tsm.NoSubstitutionTemplateLiteral | undefined;
|
|
13
13
|
get schemaString(): string | undefined;
|
|
14
14
|
get serviceFilePath(): string;
|
|
15
|
-
get service(): import("./RWService
|
|
15
|
+
get service(): import("./RWService").RWService | undefined;
|
|
16
16
|
get name(): string;
|
|
17
17
|
get implementableFields(): RWSDLField[];
|
|
18
18
|
children(): RWSDLField[];
|
|
19
|
-
diagnostics(): Generator<import("../x/diagnostics
|
|
19
|
+
diagnostics(): Generator<import("../x/diagnostics").ExtendedDiagnostic, void, unknown>;
|
|
20
20
|
}
|
|
21
21
|
//# sourceMappingURL=RWSDL.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RWSDL.d.ts","sourceRoot":"","sources":["../../src/model/RWSDL.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RWSDL.d.ts","sourceRoot":"","sources":["../../src/model/RWSDL.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAG/B,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAKnC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,qBAAa,KAAM,SAAQ,QAAQ;IAExB,QAAQ,EAAE,MAAM;IAChB,MAAM,EAAE,SAAS;gBADjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,SAAS;IAI1B;;OAEG;IACH,IAAY,gBAAgB,kDAa3B;IACD,IAAY,YAAY,IAAI,MAAM,GAAG,SAAS,CAE7C;IACD,IAAY,eAAe,WAE1B;IACD,IAAY,OAAO,gDAElB;IACD,IAAY,IAAI,WAIf;IACD,IAAY,mBAAmB,iBAkB9B;IAED,QAAQ;IAGP,WAAW;CASb"}
|
package/dist/model/RWSDL.js
CHANGED
|
@@ -1,101 +1,89 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js/object/define-property");
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
5
|
+
var _interopRequireWildcard = require("@babel/runtime-corejs3/helpers/interopRequireWildcard").default;
|
|
6
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
exports.RWSDL = void 0;
|
|
10
|
+
var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/find"));
|
|
11
|
+
var _getOwnPropertyDescriptor = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/object/get-own-property-descriptor"));
|
|
12
|
+
var _applyDecoratedDescriptor2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/applyDecoratedDescriptor"));
|
|
13
|
+
var _path = require("path");
|
|
14
|
+
var _graphql = require("graphql");
|
|
15
|
+
var _parser = require("graphql/language/parser");
|
|
16
|
+
var tsm = _interopRequireWildcard(require("ts-morph"));
|
|
17
|
+
var _errors = require("../errors");
|
|
18
|
+
var _nodes = require("../nodes");
|
|
19
|
+
var _Array = require("../x/Array");
|
|
20
|
+
var _decorators = require("../x/decorators");
|
|
21
|
+
var _diagnostics = require("../x/diagnostics");
|
|
22
|
+
var _RWSDLField = require("./RWSDLField");
|
|
23
|
+
var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _class;
|
|
24
|
+
let RWSDL = exports.RWSDL = (_dec = (0, _decorators.lazy)(), _dec2 = (0, _decorators.lazy)(), _dec3 = (0, _decorators.lazy)(), _dec4 = (0, _decorators.lazy)(), _dec5 = (0, _decorators.lazy)(), _dec6 = (0, _decorators.lazy)(), _class = class RWSDL extends _nodes.FileNode {
|
|
25
|
+
constructor(filePath, parent) {
|
|
26
|
+
super();
|
|
27
|
+
this.filePath = filePath;
|
|
28
|
+
this.parent = parent;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The Template Literal node (string) that contains the schema
|
|
32
|
+
*/
|
|
33
|
+
get schemaStringNode() {
|
|
34
|
+
const i = this.sf.getVariableDeclaration('schema')?.getInitializer();
|
|
35
|
+
if (!i) {
|
|
36
|
+
return undefined;
|
|
23
37
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return undefined;
|
|
31
|
-
}
|
|
32
|
-
// TODO: do we allow other kinds of strings? or just tagged literals?
|
|
33
|
-
if (tsm.Node.isTaggedTemplateExpression(i)) {
|
|
34
|
-
const t = i.getTemplate(); //?
|
|
35
|
-
if (tsm.Node.isNoSubstitutionTemplateLiteral(t)) {
|
|
36
|
-
return t;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return undefined;
|
|
40
|
-
}
|
|
41
|
-
get schemaString() {
|
|
42
|
-
return this.schemaStringNode?.getLiteralText();
|
|
43
|
-
}
|
|
44
|
-
get serviceFilePath() {
|
|
45
|
-
return this.parent.servicesFilePath(this.name);
|
|
38
|
+
// TODO: do we allow other kinds of strings? or just tagged literals?
|
|
39
|
+
if (tsm.Node.isTaggedTemplateExpression(i)) {
|
|
40
|
+
const t = i.getTemplate(); //?
|
|
41
|
+
if (tsm.Node.isNoSubstitutionTemplateLiteral(t)) {
|
|
42
|
+
return t;
|
|
43
|
+
}
|
|
46
44
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
get schemaString() {
|
|
48
|
+
return this.schemaStringNode?.getLiteralText();
|
|
49
|
+
}
|
|
50
|
+
get serviceFilePath() {
|
|
51
|
+
return this.parent.servicesFilePath(this.name);
|
|
52
|
+
}
|
|
53
|
+
get service() {
|
|
54
|
+
var _context;
|
|
55
|
+
return (0, _find.default)(_context = this.parent.services).call(_context, s => s.name === this.name);
|
|
56
|
+
}
|
|
57
|
+
get name() {
|
|
58
|
+
// TODO: support TS
|
|
59
|
+
const base = (0, _path.basename)(this.filePath);
|
|
60
|
+
return base.substr(0, base.length - '.sdl.js'.length);
|
|
61
|
+
}
|
|
62
|
+
get implementableFields() {
|
|
63
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
64
|
+
const self = this;
|
|
65
|
+
return (0, _Array.iter)(function* () {
|
|
66
|
+
if (!self.schemaString) {
|
|
67
|
+
return;
|
|
68
|
+
} //?
|
|
69
|
+
const ast = (0, _parser.parse)(self.schemaString);
|
|
70
|
+
for (const def of ast.definitions) {
|
|
71
|
+
if (def.kind === _graphql.Kind.OBJECT_TYPE_DEFINITION) {
|
|
72
|
+
if (def.name.value === 'Query' || def.name.value === 'Mutation') {
|
|
73
|
+
for (const field of def.fields ?? []) {
|
|
74
|
+
yield new _RWSDLField.RWSDLField(def, field, self);
|
|
71
75
|
}
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
children() {
|
|
75
|
-
return [...this.implementableFields];
|
|
76
|
-
}
|
|
77
|
-
*diagnostics() {
|
|
78
|
-
if (!this.schemaStringNode) {
|
|
79
|
-
yield err(this.uri, "Each SDL file must export a variable named 'schema' with a GraphQL schema string", RWError.SCHEMA_NOT_DEFINED);
|
|
76
|
+
}
|
|
80
77
|
}
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
children() {
|
|
82
|
+
return [...this.implementableFields];
|
|
83
|
+
}
|
|
84
|
+
*diagnostics() {
|
|
85
|
+
if (!this.schemaStringNode) {
|
|
86
|
+
yield (0, _diagnostics.err)(this.uri, "Each SDL file must export a variable named 'schema' with a GraphQL schema string", _errors.RWError.SCHEMA_NOT_DEFINED);
|
|
81
87
|
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
lazy()
|
|
85
|
-
], RWSDL.prototype, "schemaStringNode", null);
|
|
86
|
-
__decorate([
|
|
87
|
-
lazy()
|
|
88
|
-
], RWSDL.prototype, "schemaString", null);
|
|
89
|
-
__decorate([
|
|
90
|
-
lazy()
|
|
91
|
-
], RWSDL.prototype, "serviceFilePath", null);
|
|
92
|
-
__decorate([
|
|
93
|
-
lazy()
|
|
94
|
-
], RWSDL.prototype, "service", null);
|
|
95
|
-
__decorate([
|
|
96
|
-
lazy()
|
|
97
|
-
], RWSDL.prototype, "name", null);
|
|
98
|
-
__decorate([
|
|
99
|
-
lazy()
|
|
100
|
-
], RWSDL.prototype, "implementableFields", null);
|
|
101
|
-
//# sourceMappingURL=RWSDL.js.map
|
|
88
|
+
}
|
|
89
|
+
}, (0, _applyDecoratedDescriptor2.default)(_class.prototype, "schemaStringNode", [_dec], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "schemaStringNode"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "schemaString", [_dec2], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "schemaString"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "serviceFilePath", [_dec3], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "serviceFilePath"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "service", [_dec4], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "service"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "name", [_dec5], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "name"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "implementableFields", [_dec6], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "implementableFields"), _class.prototype), _class);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { FieldDefinitionNode, ObjectTypeDefinitionNode } from 'graphql';
|
|
2
|
-
import { BaseNode } from '../nodes
|
|
3
|
-
import type { ExtendedDiagnostic } from '../x/diagnostics
|
|
4
|
-
import type { Location } from '../x/Location
|
|
5
|
-
import type { RWSDL } from './RWSDL
|
|
6
|
-
import type { RWServiceFunction } from './RWServiceFunction
|
|
1
|
+
import type { FieldDefinitionNode, ObjectTypeDefinitionNode } from 'graphql/language/ast';
|
|
2
|
+
import { BaseNode } from '../nodes';
|
|
3
|
+
import type { ExtendedDiagnostic } from '../x/diagnostics';
|
|
4
|
+
import type { Location } from '../x/Location';
|
|
5
|
+
import type { RWSDL } from './RWSDL';
|
|
6
|
+
import type { RWServiceFunction } from './RWServiceFunction';
|
|
7
7
|
export declare class RWSDLField extends BaseNode {
|
|
8
8
|
objectTypeDef: ObjectTypeDefinitionNode;
|
|
9
9
|
field: FieldDefinitionNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RWSDLField.d.ts","sourceRoot":"","sources":["../../src/model/RWSDLField.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"RWSDLField.d.ts","sourceRoot":"","sources":["../../src/model/RWSDLField.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,wBAAwB,EACzB,MAAM,sBAAsB,CAAA;AAG7B,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAEnC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAG1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAE7C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAE5D,qBAAa,UAAW,SAAQ,QAAQ;IAE7B,aAAa,EAAE,wBAAwB;IACvC,KAAK,EAAE,mBAAmB;IAC1B,MAAM,EAAE,KAAK;gBAFb,aAAa,EAAE,wBAAwB,EACvC,KAAK,EAAE,mBAAmB,EAC1B,MAAM,EAAE,KAAK;IAItB,IAAY,EAAE,WAIb;IACD;;;OAGG;IACH,IAAY,QAAQ,IAAI,QAAQ,CAQ/B;IACD,IAAY,IAAI,WAEf;IACD,IAAY,aAAa,aAExB;IAED;;;OAGG;IACH,IAAY,IAAI,IAAI,iBAAiB,GAAG,SAAS,CAEhD;IAEA,WAAW;CAcb"}
|