@cedarjs/structure 2.2.2-next.0 → 2.2.2-next.31
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 +8 -24
- package/dist/index.d.ts +3 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -23
- package/dist/model/RWCell.d.ts +4 -3
- package/dist/model/RWCell.d.ts.map +1 -1
- package/dist/model/RWCell.js +7 -8
- package/dist/model/RWComponent.d.ts +1 -1
- package/dist/model/RWComponent.d.ts.map +1 -1
- package/dist/model/RWComponent.js +2 -2
- package/dist/model/RWEnvHelper.d.ts +3 -7
- package/dist/model/RWEnvHelper.d.ts.map +1 -1
- package/dist/model/RWEnvHelper.js +33 -114
- package/dist/model/RWFunction.d.ts +1 -1
- package/dist/model/RWFunction.d.ts.map +1 -1
- package/dist/model/RWFunction.js +2 -2
- package/dist/model/RWLayout.d.ts +1 -1
- package/dist/model/RWLayout.d.ts.map +1 -1
- package/dist/model/RWLayout.js +2 -2
- package/dist/model/RWPage.d.ts +1 -1
- package/dist/model/RWPage.d.ts.map +1 -1
- package/dist/model/RWPage.js +2 -2
- package/dist/model/RWProject.d.ts +1 -4
- package/dist/model/RWProject.d.ts.map +1 -1
- package/dist/model/RWProject.js +17 -19
- package/dist/model/RWRoute.d.ts +3 -16
- package/dist/model/RWRoute.d.ts.map +1 -1
- package/dist/model/RWRoute.js +11 -137
- package/dist/model/RWRouter.d.ts +2 -6
- package/dist/model/RWRouter.d.ts.map +1 -1
- package/dist/model/RWRouter.js +10 -62
- package/dist/model/RWSDL.d.ts +2 -2
- package/dist/model/RWSDL.d.ts.map +1 -1
- package/dist/model/RWSDL.js +4 -4
- package/dist/model/RWSDLField.d.ts +3 -7
- package/dist/model/RWSDLField.d.ts.map +1 -1
- package/dist/model/RWSDLField.js +10 -59
- package/dist/model/RWService.d.ts +1 -1
- package/dist/model/RWService.d.ts.map +1 -1
- package/dist/model/RWService.js +2 -2
- package/dist/model/RWServiceFunction.d.ts +2 -2
- package/dist/model/RWServiceFunction.d.ts.map +1 -1
- package/dist/model/RWServiceFunction.js +5 -6
- package/dist/model/RWTOML.d.ts +2 -2
- package/dist/model/RWTOML.d.ts.map +1 -1
- package/dist/model/RWTOML.js +6 -6
- package/dist/model/util/process_env.d.ts +9 -18
- package/dist/model/util/process_env.d.ts.map +1 -1
- package/dist/model/util/process_env.js +25 -34
- package/dist/nodes.d.ts +62 -0
- package/dist/nodes.d.ts.map +1 -0
- package/dist/nodes.js +175 -0
- package/dist/x/Location.d.ts +9 -0
- package/dist/x/Location.d.ts.map +1 -0
- package/dist/x/Location.js +18 -0
- package/dist/x/Position.d.ts +12 -0
- package/dist/x/Position.d.ts.map +1 -0
- package/dist/x/Position.js +35 -0
- package/dist/x/Range.d.ts +8 -0
- package/dist/x/Range.d.ts.map +1 -0
- package/dist/x/Range.js +22 -0
- package/dist/x/{vscode-languageserver-types.d.ts → diagnostics.d.ts} +27 -36
- package/dist/x/diagnostics.d.ts.map +1 -0
- package/dist/x/{vscode-languageserver-types.js → diagnostics.js} +30 -135
- package/dist/x/path.d.ts +1 -0
- package/dist/x/path.d.ts.map +1 -1
- package/dist/x/path.js +25 -17
- package/dist/x/prisma.d.ts +2 -3
- package/dist/x/prisma.d.ts.map +1 -1
- package/dist/x/prisma.js +5 -5
- package/package.json +3 -8
- package/dist/hosts.d.ts +0 -23
- package/dist/hosts.d.ts.map +0 -1
- package/dist/hosts.js +0 -44
- package/dist/ide.d.ts +0 -122
- package/dist/ide.d.ts.map +0 -1
- package/dist/ide.js +0 -240
- package/dist/interactive_cli/RedwoodCommandString.d.ts +0 -20
- package/dist/interactive_cli/RedwoodCommandString.d.ts.map +0 -1
- package/dist/interactive_cli/RedwoodCommandString.js +0 -72
- package/dist/interactive_cli/command_builder.d.ts +0 -10
- package/dist/interactive_cli/command_builder.d.ts.map +0 -1
- package/dist/interactive_cli/command_builder.js +0 -196
- package/dist/interactive_cli/dry_run.d.ts +0 -28
- package/dist/interactive_cli/dry_run.d.ts.map +0 -1
- package/dist/interactive_cli/dry_run.js +0 -104
- package/dist/interactive_cli/ui.d.ts +0 -32
- package/dist/interactive_cli/ui.d.ts.map +0 -1
- package/dist/interactive_cli/ui.js +0 -84
- package/dist/language_server/RWLanguageServer.d.ts +0 -30
- package/dist/language_server/RWLanguageServer.d.ts.map +0 -1
- package/dist/language_server/RWLanguageServer.js +0 -201
- package/dist/language_server/commands.d.ts +0 -14
- package/dist/language_server/commands.d.ts.map +0 -1
- package/dist/language_server/commands.js +0 -122
- package/dist/language_server/diagnostics.d.ts +0 -10
- package/dist/language_server/diagnostics.d.ts.map +0 -1
- package/dist/language_server/diagnostics.js +0 -61
- package/dist/language_server/outline.d.ts +0 -7
- package/dist/language_server/outline.d.ts.map +0 -1
- package/dist/language_server/outline.js +0 -37
- package/dist/language_server/start.d.ts +0 -2
- package/dist/language_server/start.d.ts.map +0 -1
- package/dist/language_server/start.js +0 -4
- package/dist/language_server/xmethods.d.ts +0 -11
- package/dist/language_server/xmethods.d.ts.map +0 -1
- package/dist/language_server/xmethods.js +0 -42
- package/dist/model/util/advanced_path_parser.d.ts +0 -12
- package/dist/model/util/advanced_path_parser.d.ts.map +0 -1
- package/dist/model/util/advanced_path_parser.js +0 -38
- package/dist/outline/index.d.ts +0 -3
- package/dist/outline/index.d.ts.map +0 -1
- package/dist/outline/index.js +0 -31
- package/dist/outline/outline.d.ts +0 -4
- package/dist/outline/outline.d.ts.map +0 -1
- package/dist/outline/outline.js +0 -262
- package/dist/outline/types.d.ts +0 -87
- package/dist/outline/types.d.ts.map +0 -1
- package/dist/outline/types.js +0 -72
- package/dist/x/vscode-languageserver-types.d.ts.map +0 -1
- package/dist/x/vscode-languageserver.d.ts +0 -12
- package/dist/x/vscode-languageserver.d.ts.map +0 -1
- package/dist/x/vscode-languageserver.js +0 -61
- package/dist/x/vscode.d.ts +0 -126
- package/dist/x/vscode.d.ts.map +0 -1
- package/dist/x/vscode.js +0 -294
package/dist/model/RWProject.js
CHANGED
|
@@ -10,12 +10,13 @@ var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instan
|
|
|
10
10
|
var _filter = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/filter"));
|
|
11
11
|
var _getOwnPropertyDescriptor = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/object/get-own-property-descriptor"));
|
|
12
12
|
var _applyDecoratedDescriptor2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/applyDecoratedDescriptor"));
|
|
13
|
-
var
|
|
13
|
+
var _nodeFs = require("node:fs");
|
|
14
|
+
var _nodePath = require("node:path");
|
|
14
15
|
var _internals = require("@prisma/internals");
|
|
15
16
|
var _projectConfig = require("@cedarjs/project-config");
|
|
16
|
-
var
|
|
17
|
+
var _nodes = require("../nodes");
|
|
17
18
|
var _decorators = require("../x/decorators");
|
|
18
|
-
var
|
|
19
|
+
var _path = require("../x/path");
|
|
19
20
|
var _URL = require("../x/URL");
|
|
20
21
|
var _RWCell = require("./RWCell");
|
|
21
22
|
var _RWComponent = require("./RWComponent");
|
|
@@ -34,7 +35,7 @@ const allFilesGlob = '/**/*.{js,jsx,ts,tsx}';
|
|
|
34
35
|
* Represents a Redwood project.
|
|
35
36
|
* This is the root node.
|
|
36
37
|
*/
|
|
37
|
-
let RWProject = exports.RWProject = (_dec = (0, _decorators.lazy)(), _dec2 = (0, _decorators.lazy)(), _dec3 = (0, _decorators.lazy)(), _dec4 = (0, _decorators.memo)(), _dec5 = (0, _decorators.memo)(), _dec6 = (0, _decorators.lazy)(), _dec7 = (0, _decorators.lazy)(), _dec8 = (0, _decorators.lazy)(), _dec9 = (0, _decorators.lazy)(), _dec0 = (0, _decorators.lazy)(), _dec1 = (0, _decorators.lazy)(), _dec10 = (0, _decorators.lazy)(), _dec11 = (0, _decorators.lazy)(), _dec12 = (0, _decorators.lazy)(), _dec13 = (0, _decorators.lazy)(), _dec14 = (0, _decorators.lazy)(), _dec15 = (0, _decorators.lazy)(), _dec16 = (0, _decorators.lazy)(), _dec17 = (0, _decorators.lazy)(), _class = class RWProject extends
|
|
38
|
+
let RWProject = exports.RWProject = (_dec = (0, _decorators.lazy)(), _dec2 = (0, _decorators.lazy)(), _dec3 = (0, _decorators.lazy)(), _dec4 = (0, _decorators.memo)(), _dec5 = (0, _decorators.memo)(), _dec6 = (0, _decorators.lazy)(), _dec7 = (0, _decorators.lazy)(), _dec8 = (0, _decorators.lazy)(), _dec9 = (0, _decorators.lazy)(), _dec0 = (0, _decorators.lazy)(), _dec1 = (0, _decorators.lazy)(), _dec10 = (0, _decorators.lazy)(), _dec11 = (0, _decorators.lazy)(), _dec12 = (0, _decorators.lazy)(), _dec13 = (0, _decorators.lazy)(), _dec14 = (0, _decorators.lazy)(), _dec15 = (0, _decorators.lazy)(), _dec16 = (0, _decorators.lazy)(), _dec17 = (0, _decorators.lazy)(), _class = class RWProject extends _nodes.BaseNode {
|
|
38
39
|
constructor(opts) {
|
|
39
40
|
super();
|
|
40
41
|
this.parent = undefined;
|
|
@@ -43,9 +44,6 @@ let RWProject = exports.RWProject = (_dec = (0, _decorators.lazy)(), _dec2 = (0,
|
|
|
43
44
|
};
|
|
44
45
|
this.opts = opts;
|
|
45
46
|
}
|
|
46
|
-
get host() {
|
|
47
|
-
return this.opts.host;
|
|
48
|
-
}
|
|
49
47
|
get projectRoot() {
|
|
50
48
|
return this.opts.projectRoot;
|
|
51
49
|
}
|
|
@@ -66,7 +64,7 @@ let RWProject = exports.RWProject = (_dec = (0, _decorators.lazy)(), _dec2 = (0,
|
|
|
66
64
|
* Checks for the presence of a tsconfig.json at the root.
|
|
67
65
|
*/
|
|
68
66
|
get isTypeScriptProject() {
|
|
69
|
-
return
|
|
67
|
+
return (0, _nodeFs.existsSync)((0, _nodePath.join)(this.pathHelper.web.base, 'tsconfig.json')) || (0, _nodeFs.existsSync)((0, _nodePath.join)(this.pathHelper.api.base, 'tsconfig.json'));
|
|
70
68
|
}
|
|
71
69
|
// TODO: do we move this to a separate node? (ex: RWDatabase)
|
|
72
70
|
async prismaDMMF() {
|
|
@@ -91,7 +89,7 @@ let RWProject = exports.RWProject = (_dec = (0, _decorators.lazy)(), _dec2 = (0,
|
|
|
91
89
|
return (0, _map.default)(_context = dmmf.datamodel.models).call(_context, m => m.name);
|
|
92
90
|
}
|
|
93
91
|
get redwoodTOML() {
|
|
94
|
-
return new _RWTOML.RWTOML((0,
|
|
92
|
+
return new _RWTOML.RWTOML((0, _nodePath.join)(this.projectRoot, 'redwood.toml'), this);
|
|
95
93
|
}
|
|
96
94
|
get processPagesDir() {
|
|
97
95
|
try {
|
|
@@ -111,38 +109,38 @@ let RWProject = exports.RWProject = (_dec = (0, _decorators.lazy)(), _dec2 = (0,
|
|
|
111
109
|
servicesFilePath(name) {
|
|
112
110
|
// name = blog,posts
|
|
113
111
|
const ext = this.isTypeScriptProject ? '.ts' : '.js';
|
|
114
|
-
return (0,
|
|
112
|
+
return (0, _nodePath.join)(this.pathHelper.api.services, name, name + ext);
|
|
115
113
|
}
|
|
116
114
|
|
|
117
115
|
// TODO: move to path helper
|
|
118
116
|
get defaultNotFoundPageFilePath() {
|
|
119
117
|
const ext = this.isTypeScriptProject ? '.tsx' : '.jsx';
|
|
120
|
-
return (0,
|
|
118
|
+
return (0, _nodePath.join)(this.pathHelper.web.pages, 'NotFoundPage', 'NotFoundPage' + ext);
|
|
121
119
|
}
|
|
122
120
|
get services() {
|
|
123
121
|
var _context3, _context4;
|
|
124
122
|
// TODO: what is the official logic?
|
|
125
123
|
// TODO: Support both `/services/todos/todos.js` AND `/services/todos.js`
|
|
126
|
-
return (0, _map.default)(_context3 = (0, _filter.default)(_context4 =
|
|
124
|
+
return (0, _map.default)(_context3 = (0, _filter.default)(_context4 = (0, _path.globSync)(this.pathHelper.api.services + allFilesGlob)).call(_context4, _path.followsDirNameConvention)).call(_context3, x => new _RWService.RWService(x, this));
|
|
127
125
|
}
|
|
128
126
|
get sdls() {
|
|
129
127
|
var _context5;
|
|
130
|
-
return (0, _map.default)(_context5 =
|
|
128
|
+
return (0, _map.default)(_context5 = (0, _path.globSync)(this.pathHelper.api.graphql + '/**/*.sdl.{js,ts}')).call(_context5, x => new _RWSDL.RWSDL(x, this));
|
|
131
129
|
}
|
|
132
130
|
get layouts() {
|
|
133
131
|
var _context6, _context7, _context8;
|
|
134
132
|
// TODO: what is the official logic?
|
|
135
|
-
return (0, _map.default)(_context6 = (0, _filter.default)(_context7 = (0, _filter.default)(_context8 =
|
|
133
|
+
return (0, _map.default)(_context6 = (0, _filter.default)(_context7 = (0, _filter.default)(_context8 = (0, _path.globSync)(this.pathHelper.web.layouts + allFilesGlob)).call(_context8, _path.followsDirNameConvention)).call(_context7, _path.isLayoutFileName)).call(_context6, x => new _RWLayout.RWLayout(x, this));
|
|
136
134
|
}
|
|
137
135
|
get functions() {
|
|
138
136
|
var _context9;
|
|
139
137
|
// TODO: what is the official logic?
|
|
140
|
-
return (0, _map.default)(_context9 =
|
|
138
|
+
return (0, _map.default)(_context9 = (0, _path.globSync)(this.pathHelper.api.functions + allFilesGlob)).call(_context9, x => new _RWFunction.RWFunction(x, this));
|
|
141
139
|
}
|
|
142
140
|
get components() {
|
|
143
141
|
var _context0;
|
|
144
|
-
return (0, _map.default)(_context0 =
|
|
145
|
-
if ((0,
|
|
142
|
+
return (0, _map.default)(_context0 = (0, _path.globSync)(this.pathHelper.web.components + allFilesGlob)).call(_context0, file => {
|
|
143
|
+
if ((0, _path.isCellFileName)(file)) {
|
|
146
144
|
const possibleCell = new _RWCell.RWCell(file, this);
|
|
147
145
|
return possibleCell.isCell ? possibleCell : new _RWComponent.RWComponent(file, this);
|
|
148
146
|
}
|
|
@@ -155,7 +153,7 @@ let RWProject = exports.RWProject = (_dec = (0, _decorators.lazy)(), _dec2 = (0,
|
|
|
155
153
|
|
|
156
154
|
// TODO: Wrap these in a real model.
|
|
157
155
|
get mocks() {
|
|
158
|
-
return
|
|
156
|
+
return (0, _path.globSync)(this.pathHelper.web.base + '/**/*.mock.{js,ts}');
|
|
159
157
|
}
|
|
160
158
|
|
|
161
159
|
/**
|
|
@@ -164,7 +162,7 @@ let RWProject = exports.RWProject = (_dec = (0, _decorators.lazy)(), _dec2 = (0,
|
|
|
164
162
|
**/
|
|
165
163
|
get cells() {
|
|
166
164
|
var _context1, _context10;
|
|
167
|
-
return (0, _filter.default)(_context1 = (0, _map.default)(_context10 =
|
|
165
|
+
return (0, _filter.default)(_context1 = (0, _map.default)(_context10 = (0, _path.globSync)(this.pathHelper.web.base + '/**/*Cell.{js,jsx,tsx}')).call(_context10, file => new _RWCell.RWCell(file, this))).call(_context1, file => file.isCell);
|
|
168
166
|
}
|
|
169
167
|
get envHelper() {
|
|
170
168
|
return new _RWEnvHelper.RWEnvHelper(this);
|
package/dist/model/RWRoute.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as tsm from 'ts-morph';
|
|
2
|
-
import
|
|
3
|
-
import type {
|
|
4
|
-
import { BaseNode } from '../ide';
|
|
2
|
+
import { BaseNode } from '../nodes';
|
|
3
|
+
import type { Location } from '../x/Location';
|
|
5
4
|
import type { RWRouter } from './RWRouter';
|
|
6
5
|
export declare class RWRoute extends BaseNode {
|
|
7
6
|
/**
|
|
@@ -21,9 +20,6 @@ export declare class RWRoute extends BaseNode {
|
|
|
21
20
|
get roles(): string | any[] | undefined;
|
|
22
21
|
get hasParameters(): boolean;
|
|
23
22
|
get hasPrerender(): boolean;
|
|
24
|
-
get outlineLabel(): string;
|
|
25
|
-
get outlineDescription(): string | undefined;
|
|
26
|
-
get outlineLink(): string;
|
|
27
23
|
/**
|
|
28
24
|
* The associated Redwood Page node, if any
|
|
29
25
|
*/
|
|
@@ -41,18 +37,9 @@ export declare class RWRoute extends BaseNode {
|
|
|
41
37
|
get path_literal_node(): tsm.StringLiteral | undefined;
|
|
42
38
|
get isNotFound(): boolean;
|
|
43
39
|
get redirect(): string | undefined;
|
|
44
|
-
diagnostics(): Generator<import("../x/
|
|
45
|
-
ideInfo(): Generator<Definition | HoverX | Decoration | DocumentLinkX, void, any>;
|
|
40
|
+
diagnostics(): Generator<import("../x/diagnostics").ExtendedDiagnostic, void, unknown>;
|
|
46
41
|
private get hasPathCollision();
|
|
47
42
|
private getBoolAttr;
|
|
48
43
|
private getStringAttr;
|
|
49
|
-
get parsedPath(): {
|
|
50
|
-
punctuationIndexes: number[];
|
|
51
|
-
slashIndexes: number[];
|
|
52
|
-
paramRanges: [number, number][];
|
|
53
|
-
paramTypeRanges: [number, number][];
|
|
54
|
-
} | undefined;
|
|
55
|
-
private decorations;
|
|
56
|
-
get sampleLocalPreviewURL(): string | undefined;
|
|
57
44
|
}
|
|
58
45
|
//# sourceMappingURL=RWRoute.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RWRoute.d.ts","sourceRoot":"","sources":["../../src/model/RWRoute.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RWRoute.d.ts","sourceRoot":"","sources":["../../src/model/RWRoute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAG/B,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAInC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAE7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAE1C,qBAAa,OAAQ,SAAQ,QAAQ;IAEjC;;OAEG;IACI,OAAO,EAAE,GAAG,CAAC,qBAAqB;IAClC,MAAM,EAAE,QAAQ;;IAJvB;;OAEG;IACI,OAAO,EAAE,GAAG,CAAC,qBAAqB,EAClC,MAAM,EAAE,QAAQ;IAKzB,IAAY,EAAE,WAIb;IAED,IAAY,QAAQ,IAAI,QAAQ,CAE/B;IAED,IAAY,SAAS,YAOpB;IAED,IAAY,eAAe,uBAoB1B;IAED,IACI,KAAK,+BA0DR;IAED,IAAY,aAAa,IAAI,OAAO,CAMnC;IAED,IAAY,YAAY,YAEvB;IAED;;OAEG;IAEH,IAAY,IAAI,0CAOf;IACD;;OAEG;IACK,OAAO,KAAK,eAAe,GAelC;IACD,IAAY,mBAAmB,IAAI,MAAM,GAAG,SAAS,CAEpD;IACD,IAAY,IAAI,IAAI,MAAM,GAAG,SAAS,CAErC;IACD,IAAY,iBAAiB,IAAI,MAAM,GAAG,SAAS,CAWlD;IACD,IAAY,IAAI,IAAI,MAAM,GAAG,SAAS,CAErC;IAED,IAAY,SAAS,IAAI,OAAO,CAE/B;IAGD,IAAY,UAAU,IAAI,MAAM,GAAG,SAAS,CAE3C;IAED,IAAY,iBAAiB,kCAY5B;IAED,IAAY,UAAU,IAAI,OAAO,CAEhC;IAED,IAAY,QAAQ,uBAEnB;IAEA,WAAW;IA8BJ,OAAO,KAAK,gBAAgB,GAsBnC;IAED,OAAO,CAAC,WAAW;IAgCnB,OAAO,CAAC,aAAa;CAatB"}
|
package/dist/model/RWRoute.js
CHANGED
|
@@ -15,20 +15,16 @@ var _filter = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/ins
|
|
|
15
15
|
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/map"));
|
|
16
16
|
var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/includes"));
|
|
17
17
|
var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/find"));
|
|
18
|
-
var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/object/keys"));
|
|
19
18
|
var _getOwnPropertyDescriptor = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/object/get-own-property-descriptor"));
|
|
20
19
|
var _applyDecoratedDescriptor2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/applyDecoratedDescriptor"));
|
|
21
|
-
var _path = require("path");
|
|
22
20
|
var tsm = _interopRequireWildcard(require("ts-morph"));
|
|
23
|
-
var _vscodeLanguageserverTypes = require("vscode-languageserver-types");
|
|
24
21
|
var _errors = require("../errors");
|
|
25
|
-
var
|
|
22
|
+
var _nodes = require("../nodes");
|
|
26
23
|
var _util = require("../util");
|
|
27
24
|
var _decorators = require("../x/decorators");
|
|
28
|
-
var
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
let RWRoute = exports.RWRoute = (_dec = (0, _decorators.lazy)(), _dec2 = (0, _decorators.lazy)(), _dec3 = (0, _decorators.lazy)(), _dec4 = (0, _decorators.lazy)(), _dec5 = (0, _decorators.lazy)(), _dec6 = (0, _decorators.lazy)(), _dec7 = (0, _decorators.lazy)(), _dec8 = (0, _decorators.lazy)(), _dec9 = (0, _decorators.lazy)(), _dec0 = (0, _decorators.lazy)(), _dec1 = (0, _decorators.lazy)(), _dec10 = (0, _decorators.lazy)(), _dec11 = (0, _decorators.lazy)(), _dec12 = (0, _decorators.lazy)(), _dec13 = (0, _decorators.lazy)(), _dec14 = (0, _decorators.lazy)(), _dec15 = (0, _decorators.lazy)(), _dec16 = (0, _decorators.lazy)(), _dec17 = (0, _decorators.lazy)(), _dec18 = (0, _decorators.lazy)(), _dec19 = (0, _decorators.lazy)(), _dec20 = (0, _decorators.lazy)(), _dec21 = (0, _decorators.lazy)(), _dec22 = (0, _decorators.lazy)(), _class = class RWRoute extends _ide.BaseNode {
|
|
25
|
+
var _diagnostics = require("../x/diagnostics");
|
|
26
|
+
var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec0, _dec1, _dec10, _dec11, _dec12, _dec13, _dec14, _dec15, _dec16, _dec17, _class;
|
|
27
|
+
let RWRoute = exports.RWRoute = (_dec = (0, _decorators.lazy)(), _dec2 = (0, _decorators.lazy)(), _dec3 = (0, _decorators.lazy)(), _dec4 = (0, _decorators.lazy)(), _dec5 = (0, _decorators.lazy)(), _dec6 = (0, _decorators.lazy)(), _dec7 = (0, _decorators.lazy)(), _dec8 = (0, _decorators.lazy)(), _dec9 = (0, _decorators.lazy)(), _dec0 = (0, _decorators.lazy)(), _dec1 = (0, _decorators.lazy)(), _dec10 = (0, _decorators.lazy)(), _dec11 = (0, _decorators.lazy)(), _dec12 = (0, _decorators.lazy)(), _dec13 = (0, _decorators.lazy)(), _dec14 = (0, _decorators.lazy)(), _dec15 = (0, _decorators.lazy)(), _dec16 = (0, _decorators.lazy)(), _dec17 = (0, _decorators.lazy)(), _class = class RWRoute extends _nodes.BaseNode {
|
|
32
28
|
constructor(
|
|
33
29
|
/**
|
|
34
30
|
* the <Route> tag
|
|
@@ -44,7 +40,7 @@ let RWRoute = exports.RWRoute = (_dec = (0, _decorators.lazy)(), _dec2 = (0, _de
|
|
|
44
40
|
return this.parent.id + ' ' + this.jsxNode.getStart();
|
|
45
41
|
}
|
|
46
42
|
get location() {
|
|
47
|
-
return (0,
|
|
43
|
+
return (0, _diagnostics.LocationLike_toLocation)(this.jsxNode);
|
|
48
44
|
}
|
|
49
45
|
get isPrivate() {
|
|
50
46
|
const tagText = this.jsxNode.getParentIfKind(tsm.SyntaxKind.JsxElement)?.getOpeningElement()?.getTagNameNode()?.getText();
|
|
@@ -128,23 +124,6 @@ let RWRoute = exports.RWRoute = (_dec = (0, _decorators.lazy)(), _dec2 = (0, _de
|
|
|
128
124
|
get hasPrerender() {
|
|
129
125
|
return this.prerender;
|
|
130
126
|
}
|
|
131
|
-
get outlineLabel() {
|
|
132
|
-
if (this.isNotFound) {
|
|
133
|
-
return '404';
|
|
134
|
-
}
|
|
135
|
-
return this.path ?? '';
|
|
136
|
-
}
|
|
137
|
-
get outlineDescription() {
|
|
138
|
-
const fp = this.page?.filePath;
|
|
139
|
-
if (!fp) {
|
|
140
|
-
return undefined;
|
|
141
|
-
}
|
|
142
|
-
return (0, _path.basename)(fp);
|
|
143
|
-
}
|
|
144
|
-
get outlineLink() {
|
|
145
|
-
return (0, _vscodeLanguageserverTypes2.LocationLike_toHashLink)(this.location);
|
|
146
|
-
//return LocationLike_toTerminalLink(this.location)
|
|
147
|
-
}
|
|
148
127
|
|
|
149
128
|
/**
|
|
150
129
|
* The associated Redwood Page node, if any
|
|
@@ -228,69 +207,19 @@ let RWRoute = exports.RWRoute = (_dec = (0, _decorators.lazy)(), _dec2 = (0, _de
|
|
|
228
207
|
if (this.page_identifier && !this.page) {
|
|
229
208
|
// normally this would be caught by TypeScript
|
|
230
209
|
// but Redwood has some "magic" import behavior going on
|
|
231
|
-
yield (0,
|
|
210
|
+
yield (0, _diagnostics.err)(this.page_identifier, 'Page component not found');
|
|
232
211
|
}
|
|
233
212
|
if (this.path_errorMessage && this.path_literal_node) {
|
|
234
|
-
yield (0,
|
|
213
|
+
yield (0, _diagnostics.err)(this.path_literal_node, this.path_errorMessage, _errors.RWError.INVALID_ROUTE_PATH_SYNTAX);
|
|
235
214
|
}
|
|
236
215
|
if (this.hasPathCollision) {
|
|
237
|
-
yield (0,
|
|
216
|
+
yield (0, _diagnostics.err)(this.path_literal_node, 'Duplicate Path');
|
|
238
217
|
}
|
|
239
218
|
if (this.isPrivate && this.isNotFound) {
|
|
240
|
-
yield (0,
|
|
219
|
+
yield (0, _diagnostics.err)(this.jsxNode, "The 'Not Found' page cannot be within a <PrivateSet> or a <Private> tag");
|
|
241
220
|
}
|
|
242
221
|
if (this.isNotFound && this.path) {
|
|
243
|
-
yield (0,
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
*ideInfo() {
|
|
247
|
-
// definition: page identifier --> page
|
|
248
|
-
if (this.page && this.page_identifier) {
|
|
249
|
-
yield {
|
|
250
|
-
kind: 'Definition',
|
|
251
|
-
location: (0, _vscodeLanguageserverTypes2.Location_fromNode)(this.page_identifier),
|
|
252
|
-
target: (0, _vscodeLanguageserverTypes2.Location_fromFilePath)(this.page.filePath)
|
|
253
|
-
};
|
|
254
|
-
}
|
|
255
|
-
if (this.path && this.page) {
|
|
256
|
-
// const location = Location_fromNode(this.jsxNode!)
|
|
257
|
-
// yield { kind: 'Hover', location, text: 'Open Preview' }
|
|
258
|
-
}
|
|
259
|
-
yield* this.decorations();
|
|
260
|
-
const {
|
|
261
|
-
sampleLocalPreviewURL
|
|
262
|
-
} = this;
|
|
263
|
-
if (sampleLocalPreviewURL) {
|
|
264
|
-
const range = (0, _vscodeLanguageserverTypes2.Range_fromNode)(this.jsxNode);
|
|
265
|
-
yield {
|
|
266
|
-
kind: 'Hover',
|
|
267
|
-
location: {
|
|
268
|
-
uri: this.parent.uri,
|
|
269
|
-
range
|
|
270
|
-
},
|
|
271
|
-
hover: {
|
|
272
|
-
range,
|
|
273
|
-
contents: `[Open Preview](${sampleLocalPreviewURL})`
|
|
274
|
-
}
|
|
275
|
-
};
|
|
276
|
-
const {
|
|
277
|
-
path_literal_node
|
|
278
|
-
} = this;
|
|
279
|
-
if (path_literal_node) {
|
|
280
|
-
const range = (0, _vscodeLanguageserverTypes2.Range_fromNode)(this.path_literal_node);
|
|
281
|
-
yield {
|
|
282
|
-
kind: 'DocumentLink',
|
|
283
|
-
location: {
|
|
284
|
-
uri: this.parent.uri,
|
|
285
|
-
range
|
|
286
|
-
},
|
|
287
|
-
link: {
|
|
288
|
-
range,
|
|
289
|
-
target: sampleLocalPreviewURL,
|
|
290
|
-
tooltip: sampleLocalPreviewURL
|
|
291
|
-
}
|
|
292
|
-
};
|
|
293
|
-
}
|
|
222
|
+
yield (0, _diagnostics.err)(this.path_literal_node, "The 'Not Found' page cannot have a path");
|
|
294
223
|
}
|
|
295
224
|
}
|
|
296
225
|
get hasPathCollision() {
|
|
@@ -358,59 +287,4 @@ let RWRoute = exports.RWRoute = (_dec = (0, _decorators.lazy)(), _dec2 = (0, _de
|
|
|
358
287
|
}
|
|
359
288
|
return undefined;
|
|
360
289
|
}
|
|
361
|
-
|
|
362
|
-
if (!this.path) {
|
|
363
|
-
return undefined;
|
|
364
|
-
}
|
|
365
|
-
return (0, _advanced_path_parser.advanced_path_parser)(this.path);
|
|
366
|
-
}
|
|
367
|
-
*decorations() {
|
|
368
|
-
const pp = this.parsedPath;
|
|
369
|
-
if (!pp) {
|
|
370
|
-
return;
|
|
371
|
-
}
|
|
372
|
-
const uri = this.parent.uri;
|
|
373
|
-
const pos = (0, _vscodeLanguageserverTypes2.Range_fromNode)(this.path_literal_node).start;
|
|
374
|
-
const xxx = {
|
|
375
|
-
path_punctuation: pp.punctuationIndexes,
|
|
376
|
-
path_slash: pp.slashIndexes,
|
|
377
|
-
path_parameter: pp.paramRanges,
|
|
378
|
-
path_parameter_type: pp.paramTypeRanges
|
|
379
|
-
};
|
|
380
|
-
for (const style of (0, _keys.default)(xxx)) {
|
|
381
|
-
for (const x of xxx[style]) {
|
|
382
|
-
yield {
|
|
383
|
-
kind: 'Decoration',
|
|
384
|
-
style: style,
|
|
385
|
-
location: loc(x)
|
|
386
|
-
};
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
function loc(x) {
|
|
390
|
-
if (typeof x === 'number') {
|
|
391
|
-
return loc([x, x + 1]);
|
|
392
|
-
} else {
|
|
393
|
-
const start = (0, _vscodeLanguageserverTypes2.Position_translate)(pos, 0, x[0] + 1);
|
|
394
|
-
const end = (0, _vscodeLanguageserverTypes2.Position_translate)(pos, 0, x[1] + 1);
|
|
395
|
-
return {
|
|
396
|
-
uri,
|
|
397
|
-
range: _vscodeLanguageserverTypes.Range.create(start, end)
|
|
398
|
-
};
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
// TODO: we should get the URL of the server dynamically
|
|
404
|
-
get sampleLocalPreviewURL() {
|
|
405
|
-
const {
|
|
406
|
-
path
|
|
407
|
-
} = this;
|
|
408
|
-
if (!path) {
|
|
409
|
-
return undefined;
|
|
410
|
-
}
|
|
411
|
-
if ((0, _includes.default)(path).call(path, '{')) {
|
|
412
|
-
return undefined;
|
|
413
|
-
}
|
|
414
|
-
return `http://localhost:8910${path}`;
|
|
415
|
-
}
|
|
416
|
-
}, (0, _applyDecoratedDescriptor2.default)(_class.prototype, "id", [_dec], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "id"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "location", [_dec2], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "location"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "isPrivate", [_dec3], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "isPrivate"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "unauthenticated", [_dec4], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "unauthenticated"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "roles", [_dec5], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "roles"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "hasParameters", [_dec6], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "hasParameters"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "hasPrerender", [_dec7], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "hasPrerender"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "outlineLabel", [_dec8], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "outlineLabel"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "outlineDescription", [_dec9], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "outlineDescription"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "outlineLink", [_dec0], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "outlineLink"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "page", [_dec1], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "page"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "page_identifier", [_dec10], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "page_identifier"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "page_identifier_str", [_dec11], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "page_identifier_str"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "name", [_dec12], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "name"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "path_errorMessage", [_dec13], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "path_errorMessage"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "path", [_dec14], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "path"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "prerender", [_dec15], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "prerender"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "renderMode", [_dec16], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "renderMode"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "path_literal_node", [_dec17], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "path_literal_node"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "isNotFound", [_dec18], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "isNotFound"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "redirect", [_dec19], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "redirect"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "hasPathCollision", [_dec20], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "hasPathCollision"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "parsedPath", [_dec21], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "parsedPath"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "sampleLocalPreviewURL", [_dec22], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "sampleLocalPreviewURL"), _class.prototype), _class);
|
|
290
|
+
}, (0, _applyDecoratedDescriptor2.default)(_class.prototype, "id", [_dec], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "id"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "location", [_dec2], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "location"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "isPrivate", [_dec3], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "isPrivate"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "unauthenticated", [_dec4], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "unauthenticated"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "roles", [_dec5], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "roles"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "hasParameters", [_dec6], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "hasParameters"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "hasPrerender", [_dec7], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "hasPrerender"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "page", [_dec8], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "page"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "page_identifier", [_dec9], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "page_identifier"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "page_identifier_str", [_dec0], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "page_identifier_str"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "name", [_dec1], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "name"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "path_errorMessage", [_dec10], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "path_errorMessage"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "path", [_dec11], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "path"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "prerender", [_dec12], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "prerender"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "renderMode", [_dec13], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "renderMode"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "path_literal_node", [_dec14], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "path_literal_node"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "isNotFound", [_dec15], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "isNotFound"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "redirect", [_dec16], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "redirect"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "hasPathCollision", [_dec17], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "hasPathCollision"), _class.prototype), _class);
|
package/dist/model/RWRouter.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type {
|
|
3
|
-
import { FileNode } from '../ide';
|
|
4
|
-
import type { ExtendedDiagnostic } from '../x/vscode-languageserver-types';
|
|
1
|
+
import { FileNode } from '../nodes';
|
|
2
|
+
import type { ExtendedDiagnostic } from '../x/diagnostics';
|
|
5
3
|
import type { RWProject } from './RWProject';
|
|
6
4
|
import { RWRoute } from './RWRoute';
|
|
7
5
|
/**
|
|
@@ -22,8 +20,6 @@ export declare class RWRouter extends FileNode {
|
|
|
22
20
|
*/
|
|
23
21
|
get routes(): RWRoute[];
|
|
24
22
|
private get numNotFoundPages();
|
|
25
|
-
ideInfo(): Generator<CodeLensX, void, unknown>;
|
|
26
|
-
get quickFix_addNotFoundpage(): CodeAction | undefined;
|
|
27
23
|
diagnostics(): Generator<ExtendedDiagnostic, void, unknown>;
|
|
28
24
|
children(): RWRoute[];
|
|
29
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RWRouter.d.ts","sourceRoot":"","sources":["../../src/model/RWRouter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RWRouter.d.ts","sourceRoot":"","sources":["../../src/model/RWRouter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAGnC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAK1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC;;GAEG;AACH,qBAAa,QAAS,SAAQ,QAAQ;IAE3B,QAAQ,EAAE,MAAM;IAChB,MAAM,EAAE,SAAS;gBADjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,SAAS;IAKlB,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAK9D,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAUrE;;OAEG;IACK,OAAO,KAAK,OAAO,GAI1B;IAED;;OAEG;IACH,IAAY,MAAM,cA+CjB;IAEO,OAAO,KAAK,gBAAgB,GAEnC;IAEA,WAAW;IAiCZ,QAAQ;CAGT"}
|
package/dist/model/RWRouter.js
CHANGED
|
@@ -11,23 +11,21 @@ var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/insta
|
|
|
11
11
|
var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/includes"));
|
|
12
12
|
var _bind = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/bind"));
|
|
13
13
|
var _filter = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/filter"));
|
|
14
|
-
var _repeat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/repeat"));
|
|
15
14
|
var _getOwnPropertyDescriptor = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/object/get-own-property-descriptor"));
|
|
16
15
|
var _applyDecoratedDescriptor2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/applyDecoratedDescriptor"));
|
|
17
16
|
var tsm = _interopRequireWildcard(require("ts-morph"));
|
|
18
|
-
var _vscodeLanguageserverTypes = require("vscode-languageserver-types");
|
|
19
17
|
var _errors = require("../errors");
|
|
20
|
-
var
|
|
18
|
+
var _nodes = require("../nodes");
|
|
21
19
|
var _Array = require("../x/Array");
|
|
22
20
|
var _decorators = require("../x/decorators");
|
|
21
|
+
var _diagnostics = require("../x/diagnostics");
|
|
23
22
|
var _URL = require("../x/URL");
|
|
24
|
-
var _vscodeLanguageserverTypes2 = require("../x/vscode-languageserver-types");
|
|
25
23
|
var _RWRoute = require("./RWRoute");
|
|
26
|
-
var _dec, _dec2, _dec3, _dec4, _dec5,
|
|
24
|
+
var _dec, _dec2, _dec3, _dec4, _dec5, _class;
|
|
27
25
|
/**
|
|
28
26
|
* one per Routes.js
|
|
29
27
|
*/
|
|
30
|
-
let RWRouter = exports.RWRouter = (_dec = (0, _decorators.memo)(), _dec2 = (0, _decorators.memo)(), _dec3 = (0, _decorators.lazy)(), _dec4 = (0, _decorators.lazy)(), _dec5 = (0, _decorators.lazy)(),
|
|
28
|
+
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 {
|
|
31
29
|
constructor(filePath, parent) {
|
|
32
30
|
super();
|
|
33
31
|
this.filePath = filePath;
|
|
@@ -100,61 +98,12 @@ let RWRouter = exports.RWRouter = (_dec = (0, _decorators.memo)(), _dec2 = (0, _
|
|
|
100
98
|
var _context7;
|
|
101
99
|
return (0, _filter.default)(_context7 = this.routes).call(_context7, r => r.isNotFound).length;
|
|
102
100
|
}
|
|
103
|
-
*ideInfo() {
|
|
104
|
-
if (this.jsxNode) {
|
|
105
|
-
const location = (0, _vscodeLanguageserverTypes2.Location_fromNode)(this.jsxNode);
|
|
106
|
-
const codeLens = {
|
|
107
|
-
range: location.range,
|
|
108
|
-
command: _vscodeLanguageserverTypes.Command.create('Create Page...', 'redwoodjs.cli', 'generate page...', this.parent.projectRoot)
|
|
109
|
-
};
|
|
110
|
-
yield {
|
|
111
|
-
kind: 'CodeLens',
|
|
112
|
-
location,
|
|
113
|
-
codeLens
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
get quickFix_addNotFoundpage() {
|
|
118
|
-
var _context8, _context9;
|
|
119
|
-
if (!this.jsxNode) {
|
|
120
|
-
return undefined;
|
|
121
|
-
}
|
|
122
|
-
const change = new _vscodeLanguageserverTypes.WorkspaceChange({
|
|
123
|
-
documentChanges: []
|
|
124
|
-
});
|
|
125
|
-
let uri = (0, _URL.URL_file)(this.parent.defaultNotFoundPageFilePath);
|
|
126
|
-
const p = (0, _find.default)(_context8 = this.parent.pages).call(_context8, p => p.basenameNoExt === 'NotFoundPage');
|
|
127
|
-
if (p) {
|
|
128
|
-
uri = p.uri;
|
|
129
|
-
// page already exists, we just need to add the <Route/>
|
|
130
|
-
} else {
|
|
131
|
-
change.createFile(uri);
|
|
132
|
-
change.getTextEditChange({
|
|
133
|
-
uri,
|
|
134
|
-
version: null
|
|
135
|
-
}).insert(_vscodeLanguageserverTypes.Position.create(0, 0), `export default () => <div>Not Found</div>`);
|
|
136
|
-
}
|
|
137
|
-
// add <Route/>
|
|
138
|
-
const loc = (0, _vscodeLanguageserverTypes2.LocationLike_toLocation)(this.jsxNode);
|
|
139
|
-
const lastRoute = this.routes[this.routes.length - 1];
|
|
140
|
-
const lastRouteLoc = (0, _vscodeLanguageserverTypes2.LocationLike_toLocation)(lastRoute.jsxNode);
|
|
141
|
-
const textEditChange = change.getTextEditChange({
|
|
142
|
-
uri: loc.uri,
|
|
143
|
-
version: null
|
|
144
|
-
});
|
|
145
|
-
const indent = (0, _repeat.default)(_context9 = ' ').call(_context9, lastRouteLoc.range.start.character);
|
|
146
|
-
textEditChange.insert(lastRouteLoc.range.end, `\n${indent}<Route notfound page={NotFoundPage}/>\n`);
|
|
147
|
-
return {
|
|
148
|
-
title: 'Create default Not Found Page',
|
|
149
|
-
edit: change.edit
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
101
|
*diagnostics() {
|
|
153
102
|
if (!this.fileExists) {
|
|
154
103
|
// should we assign this error to the project? to redwood.toml?
|
|
155
104
|
const uri = (0, _URL.URL_file)(this.parent.projectRoot, 'redwood.toml');
|
|
156
105
|
const message = `Routes.js does not exist`;
|
|
157
|
-
yield (0,
|
|
106
|
+
yield (0, _diagnostics.err)(uri, message);
|
|
158
107
|
// TODO: add quickFix (create a simple Routes.js)
|
|
159
108
|
return; // stop checking for errors if the file doesn't exist
|
|
160
109
|
}
|
|
@@ -165,22 +114,21 @@ let RWRouter = exports.RWRouter = (_dec = (0, _decorators.memo)(), _dec2 = (0, _
|
|
|
165
114
|
const {
|
|
166
115
|
uri,
|
|
167
116
|
range
|
|
168
|
-
} = (0,
|
|
117
|
+
} = (0, _diagnostics.LocationLike_toLocation)(this.jsxNode);
|
|
169
118
|
yield {
|
|
170
119
|
uri,
|
|
171
120
|
diagnostic: {
|
|
172
121
|
range,
|
|
173
122
|
message: "You must specify a 'notfound' page",
|
|
174
|
-
severity:
|
|
175
|
-
}
|
|
176
|
-
quickFix: async () => this.quickFix_addNotFoundpage
|
|
123
|
+
severity: _diagnostics.DiagnosticSeverity.Error
|
|
124
|
+
}
|
|
177
125
|
};
|
|
178
126
|
} else if (this.numNotFoundPages > 1) {
|
|
179
|
-
const e = (0,
|
|
127
|
+
const e = (0, _diagnostics.err)(this.jsxNode, "You must specify exactly one 'notfound' page", _errors.RWError.NOTFOUND_PAGE_NOT_DEFINED);
|
|
180
128
|
yield e;
|
|
181
129
|
}
|
|
182
130
|
}
|
|
183
131
|
children() {
|
|
184
132
|
return [...this.routes];
|
|
185
133
|
}
|
|
186
|
-
}, (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),
|
|
134
|
+
}, (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,5 +1,5 @@
|
|
|
1
1
|
import * as tsm from 'ts-morph';
|
|
2
|
-
import { FileNode } from '../
|
|
2
|
+
import { FileNode } from '../nodes';
|
|
3
3
|
import type { RWProject } from './RWProject';
|
|
4
4
|
import { RWSDLField } from './RWSDLField';
|
|
5
5
|
export declare class RWSDL extends FileNode {
|
|
@@ -16,6 +16,6 @@ export declare class RWSDL extends FileNode {
|
|
|
16
16
|
get name(): string;
|
|
17
17
|
get implementableFields(): RWSDLField[];
|
|
18
18
|
children(): RWSDLField[];
|
|
19
|
-
diagnostics(): Generator<import("../x/
|
|
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":"AAIA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAG/B,OAAO,EAAE,QAAQ,EAAE,MAAM,
|
|
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
|
@@ -15,13 +15,13 @@ var _graphql = require("graphql");
|
|
|
15
15
|
var _parser = require("graphql/language/parser");
|
|
16
16
|
var tsm = _interopRequireWildcard(require("ts-morph"));
|
|
17
17
|
var _errors = require("../errors");
|
|
18
|
-
var
|
|
18
|
+
var _nodes = require("../nodes");
|
|
19
19
|
var _Array = require("../x/Array");
|
|
20
20
|
var _decorators = require("../x/decorators");
|
|
21
|
-
var
|
|
21
|
+
var _diagnostics = require("../x/diagnostics");
|
|
22
22
|
var _RWSDLField = require("./RWSDLField");
|
|
23
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
|
|
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
25
|
constructor(filePath, parent) {
|
|
26
26
|
super();
|
|
27
27
|
this.filePath = filePath;
|
|
@@ -83,7 +83,7 @@ let RWSDL = exports.RWSDL = (_dec = (0, _decorators.lazy)(), _dec2 = (0, _decora
|
|
|
83
83
|
}
|
|
84
84
|
*diagnostics() {
|
|
85
85
|
if (!this.schemaStringNode) {
|
|
86
|
-
yield (0,
|
|
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);
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
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,8 +1,7 @@
|
|
|
1
1
|
import type { FieldDefinitionNode, ObjectTypeDefinitionNode } from 'graphql/language/ast';
|
|
2
|
-
import
|
|
3
|
-
import type {
|
|
4
|
-
import {
|
|
5
|
-
import type { ExtendedDiagnostic } from '../x/vscode-languageserver-types';
|
|
2
|
+
import { BaseNode } from '../nodes';
|
|
3
|
+
import type { ExtendedDiagnostic } from '../x/diagnostics';
|
|
4
|
+
import type { Location } from '../x/Location';
|
|
6
5
|
import type { RWSDL } from './RWSDL';
|
|
7
6
|
import type { RWServiceFunction } from './RWServiceFunction';
|
|
8
7
|
export declare class RWSDLField extends BaseNode {
|
|
@@ -18,14 +17,11 @@ export declare class RWSDLField extends BaseNode {
|
|
|
18
17
|
get location(): Location;
|
|
19
18
|
get name(): string;
|
|
20
19
|
get argumentNames(): string[];
|
|
21
|
-
ideInfo(): Generator<Implementation, void, unknown>;
|
|
22
20
|
/**
|
|
23
21
|
* TODO: describe in prose what is going on here.
|
|
24
22
|
* this is an important rule
|
|
25
23
|
*/
|
|
26
24
|
get impl(): RWServiceFunction | undefined;
|
|
27
|
-
private get defaultImplSnippet();
|
|
28
|
-
get quickFix_addImplementation(): CodeAction;
|
|
29
25
|
diagnostics(): Generator<ExtendedDiagnostic, void, unknown>;
|
|
30
26
|
}
|
|
31
27
|
//# sourceMappingURL=RWSDLField.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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"}
|