@cedarjs/structure 2.8.1-next.116 → 2.8.1-rc.3
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/RWRoute.js
CHANGED
|
@@ -1,340 +1,290 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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.RWRoute = void 0;
|
|
10
|
+
require("core-js/modules/es.json.parse.js");
|
|
11
|
+
var _startsWith = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/starts-with"));
|
|
12
|
+
var _endsWith = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/ends-with"));
|
|
13
|
+
var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/array/is-array"));
|
|
14
|
+
var _filter = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/filter"));
|
|
15
|
+
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/map"));
|
|
16
|
+
var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/includes"));
|
|
17
|
+
var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/find"));
|
|
18
|
+
var _getOwnPropertyDescriptor = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/object/get-own-property-descriptor"));
|
|
19
|
+
var _applyDecoratedDescriptor2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/applyDecoratedDescriptor"));
|
|
20
|
+
var tsm = _interopRequireWildcard(require("ts-morph"));
|
|
21
|
+
var _errors = require("../errors");
|
|
22
|
+
var _nodes = require("../nodes");
|
|
23
|
+
var _util = require("../util");
|
|
24
|
+
var _decorators = require("../x/decorators");
|
|
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 {
|
|
28
|
+
constructor(
|
|
29
|
+
/**
|
|
30
|
+
* the <Route> tag
|
|
31
|
+
*/
|
|
32
|
+
jsxNode, parent) {
|
|
33
|
+
super();
|
|
34
|
+
this.jsxNode = jsxNode;
|
|
35
|
+
this.parent = parent;
|
|
36
|
+
}
|
|
37
|
+
get id() {
|
|
38
|
+
// we cannot rely on the "path" attribute of the node
|
|
39
|
+
// it might not be unique (which is an error state, but valid while editing)
|
|
40
|
+
return this.parent.id + ' ' + this.jsxNode.getStart();
|
|
41
|
+
}
|
|
42
|
+
get location() {
|
|
43
|
+
return (0, _diagnostics.LocationLike_toLocation)(this.jsxNode);
|
|
44
|
+
}
|
|
45
|
+
get isPrivate() {
|
|
46
|
+
const tagText = this.jsxNode.getParentIfKind(tsm.SyntaxKind.JsxElement)?.getOpeningElement()?.getTagNameNode()?.getText();
|
|
47
|
+
return tagText === 'Private' || tagText === 'PrivateSet';
|
|
48
|
+
}
|
|
49
|
+
get unauthenticated() {
|
|
50
|
+
if (!this.isPrivate) {
|
|
51
|
+
return undefined;
|
|
24
52
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return this.parent.id + ' ' + this.jsxNode.getStart();
|
|
53
|
+
const a = this.jsxNode.getParentIfKind(tsm.SyntaxKind.JsxElement)?.getOpeningElement().getAttribute('unauthenticated');
|
|
54
|
+
if (!a) {
|
|
55
|
+
return undefined;
|
|
29
56
|
}
|
|
30
|
-
|
|
31
|
-
|
|
57
|
+
if (tsm.Node.isJsxAttribute(a)) {
|
|
58
|
+
const init = a.getInitializer();
|
|
59
|
+
if (tsm.Node.isStringLiteral(init)) {
|
|
60
|
+
return init.getLiteralValue();
|
|
61
|
+
}
|
|
32
62
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
?.getText();
|
|
39
|
-
return tagText === 'Private' || tagText === 'PrivateSet';
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
get roles() {
|
|
66
|
+
if (!this.isPrivate) {
|
|
67
|
+
return undefined;
|
|
40
68
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
const a = this.jsxNode
|
|
46
|
-
.getParentIfKind(tsm.SyntaxKind.JsxElement)
|
|
47
|
-
?.getOpeningElement()
|
|
48
|
-
.getAttribute('unauthenticated');
|
|
49
|
-
if (!a) {
|
|
50
|
-
return undefined;
|
|
51
|
-
}
|
|
52
|
-
if (tsm.Node.isJsxAttribute(a)) {
|
|
53
|
-
const init = a.getInitializer();
|
|
54
|
-
if (tsm.Node.isStringLiteral(init)) {
|
|
55
|
-
return init.getLiteralValue();
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return undefined;
|
|
69
|
+
const a = this.jsxNode.getParentIfKind(tsm.SyntaxKind.JsxElement)?.getOpeningElement().getAttribute('roles');
|
|
70
|
+
if (!a) {
|
|
71
|
+
return undefined;
|
|
59
72
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
if (
|
|
73
|
+
if (tsm.Node.isJsxAttribute(a)) {
|
|
74
|
+
const init = a.getInitializer();
|
|
75
|
+
|
|
76
|
+
// Handle string literals
|
|
77
|
+
if (tsm.Node.isStringLiteral(init)) {
|
|
78
|
+
const literalValue = init.getLiteralValue();
|
|
79
|
+
|
|
80
|
+
// Check if the string looks like an array with single quotes
|
|
81
|
+
if ((0, _startsWith.default)(literalValue).call(literalValue, '[') && (0, _endsWith.default)(literalValue).call(literalValue, ']')) {
|
|
82
|
+
try {
|
|
83
|
+
// Unescape the string by replacing single quotes with double quotes
|
|
84
|
+
const correctedLiteralValue = literalValue.replace(/'/g, '"');
|
|
85
|
+
// Attempt to parse as JSON array
|
|
86
|
+
const parsedValue = JSON.parse(correctedLiteralValue);
|
|
87
|
+
if ((0, _isArray.default)(parsedValue)) {
|
|
88
|
+
return parsedValue;
|
|
89
|
+
}
|
|
90
|
+
} catch {
|
|
91
|
+
// If parsing fails, return undefined
|
|
69
92
|
return undefined;
|
|
93
|
+
}
|
|
70
94
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
return parsedValue;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
catch {
|
|
88
|
-
// If parsing fails, return undefined
|
|
89
|
-
return undefined;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
// If not an array, return the string value
|
|
93
|
-
return literalValue;
|
|
94
|
-
}
|
|
95
|
-
// Handle JSX expressions with array literals
|
|
96
|
-
if (tsm.Node.isJsxExpression(init)) {
|
|
97
|
-
const expr = init.getExpression();
|
|
98
|
-
if (tsm.Node.isArrayLiteralExpression(expr)) {
|
|
99
|
-
return expr
|
|
100
|
-
.getElements()
|
|
101
|
-
.map((element) => {
|
|
102
|
-
if (tsm.Node.isStringLiteral(element)) {
|
|
103
|
-
return element.getLiteralValue();
|
|
104
|
-
}
|
|
105
|
-
return undefined;
|
|
106
|
-
})
|
|
107
|
-
.filter((val) => val !== undefined);
|
|
108
|
-
}
|
|
95
|
+
|
|
96
|
+
// If not an array, return the string value
|
|
97
|
+
return literalValue;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Handle JSX expressions with array literals
|
|
101
|
+
if (tsm.Node.isJsxExpression(init)) {
|
|
102
|
+
const expr = init.getExpression();
|
|
103
|
+
if (tsm.Node.isArrayLiteralExpression(expr)) {
|
|
104
|
+
var _context, _context2;
|
|
105
|
+
return (0, _filter.default)(_context = (0, _map.default)(_context2 = expr.getElements()).call(_context2, element => {
|
|
106
|
+
if (tsm.Node.isStringLiteral(element)) {
|
|
107
|
+
return element.getLiteralValue();
|
|
109
108
|
}
|
|
109
|
+
return undefined;
|
|
110
|
+
})).call(_context, val => val !== undefined);
|
|
110
111
|
}
|
|
111
|
-
|
|
112
|
+
}
|
|
112
113
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
114
|
+
return undefined;
|
|
115
|
+
}
|
|
116
|
+
get hasParameters() {
|
|
117
|
+
var _context3;
|
|
118
|
+
if (!this.path) {
|
|
119
|
+
return false;
|
|
119
120
|
}
|
|
120
|
-
|
|
121
|
-
|
|
121
|
+
// KLUDGE: we need a good path parsing library here
|
|
122
|
+
return (0, _includes.default)(_context3 = this.path).call(_context3, '{');
|
|
123
|
+
}
|
|
124
|
+
get hasPrerender() {
|
|
125
|
+
return this.prerender;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* The associated Redwood Page node, if any
|
|
130
|
+
*/
|
|
131
|
+
|
|
132
|
+
get page() {
|
|
133
|
+
var _context4;
|
|
134
|
+
if (!this.page_identifier_str) {
|
|
135
|
+
return undefined;
|
|
122
136
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
137
|
+
return (0, _find.default)(_context4 = this.parent.parent.pages).call(_context4, p => p.constName === this.page_identifier_str);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* <Route path="" page={THIS_IDENTIFIER}/>
|
|
141
|
+
*/
|
|
142
|
+
get page_identifier() {
|
|
143
|
+
const a = this.jsxNode.getAttribute('page');
|
|
144
|
+
if (!a) {
|
|
145
|
+
return undefined;
|
|
131
146
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
return undefined;
|
|
139
|
-
}
|
|
140
|
-
if (tsm.Node.isJsxAttribute(a)) {
|
|
141
|
-
const init = a.getInitializer();
|
|
142
|
-
if (tsm.Node.isJsxExpression(init)) {
|
|
143
|
-
const expr = init.getExpression();
|
|
144
|
-
if (tsm.Node.isIdentifier(expr)) {
|
|
145
|
-
return expr;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
147
|
+
if (tsm.Node.isJsxAttribute(a)) {
|
|
148
|
+
const init = a.getInitializer();
|
|
149
|
+
if (tsm.Node.isJsxExpression(init)) {
|
|
150
|
+
const expr = init.getExpression();
|
|
151
|
+
if (tsm.Node.isIdentifier(expr)) {
|
|
152
|
+
return expr;
|
|
148
153
|
}
|
|
149
|
-
|
|
154
|
+
}
|
|
150
155
|
}
|
|
151
|
-
|
|
152
|
-
|
|
156
|
+
return undefined;
|
|
157
|
+
}
|
|
158
|
+
get page_identifier_str() {
|
|
159
|
+
return this.page_identifier?.getText();
|
|
160
|
+
}
|
|
161
|
+
get name() {
|
|
162
|
+
return this.getStringAttr('name');
|
|
163
|
+
}
|
|
164
|
+
get path_errorMessage() {
|
|
165
|
+
// TODO: path validation is not strong enough
|
|
166
|
+
if (typeof this.path === 'undefined') {
|
|
167
|
+
return undefined;
|
|
153
168
|
}
|
|
154
|
-
|
|
155
|
-
|
|
169
|
+
try {
|
|
170
|
+
(0, _util.validateRoutePath)(this.path);
|
|
171
|
+
return undefined;
|
|
172
|
+
} catch (e) {
|
|
173
|
+
return e.toString();
|
|
156
174
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
175
|
+
}
|
|
176
|
+
get path() {
|
|
177
|
+
return this.getStringAttr('path');
|
|
178
|
+
}
|
|
179
|
+
get prerender() {
|
|
180
|
+
return this.getBoolAttr('prerender');
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// TODO (STREAMING) Remove this once we're sure we don't want to do Render Modes
|
|
184
|
+
get renderMode() {
|
|
185
|
+
return this.getStringAttr('renderMode') || 'stream';
|
|
186
|
+
}
|
|
187
|
+
get path_literal_node() {
|
|
188
|
+
const a = this.jsxNode.getAttribute('path');
|
|
189
|
+
if (!a) {
|
|
190
|
+
return undefined;
|
|
169
191
|
}
|
|
170
|
-
|
|
171
|
-
|
|
192
|
+
if (tsm.Node.isJsxAttribute(a)) {
|
|
193
|
+
const init = a.getInitializer();
|
|
194
|
+
if (tsm.Node.isStringLiteral(init)) {
|
|
195
|
+
return init;
|
|
196
|
+
}
|
|
172
197
|
}
|
|
173
|
-
|
|
174
|
-
|
|
198
|
+
return undefined;
|
|
199
|
+
}
|
|
200
|
+
get isNotFound() {
|
|
201
|
+
return typeof this.jsxNode.getAttribute('notfound') !== 'undefined';
|
|
202
|
+
}
|
|
203
|
+
get redirect() {
|
|
204
|
+
return this.getStringAttr('redirect');
|
|
205
|
+
}
|
|
206
|
+
*diagnostics() {
|
|
207
|
+
if (this.page_identifier && !this.page) {
|
|
208
|
+
// normally this would be caught by TypeScript
|
|
209
|
+
// but Redwood has some "magic" import behavior going on
|
|
210
|
+
yield (0, _diagnostics.err)(this.page_identifier, 'Page component not found');
|
|
175
211
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
return this.getStringAttr('renderMode') || 'stream';
|
|
212
|
+
if (this.path_errorMessage && this.path_literal_node) {
|
|
213
|
+
yield (0, _diagnostics.err)(this.path_literal_node, this.path_errorMessage, _errors.RWError.INVALID_ROUTE_PATH_SYNTAX);
|
|
179
214
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
if (!a) {
|
|
183
|
-
return undefined;
|
|
184
|
-
}
|
|
185
|
-
if (tsm.Node.isJsxAttribute(a)) {
|
|
186
|
-
const init = a.getInitializer();
|
|
187
|
-
if (tsm.Node.isStringLiteral(init)) {
|
|
188
|
-
return init;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
return undefined;
|
|
215
|
+
if (this.hasPathCollision) {
|
|
216
|
+
yield (0, _diagnostics.err)(this.path_literal_node, 'Duplicate Path');
|
|
192
217
|
}
|
|
193
|
-
|
|
194
|
-
|
|
218
|
+
if (this.isPrivate && this.isNotFound) {
|
|
219
|
+
yield (0, _diagnostics.err)(this.jsxNode, "The 'Not Found' page cannot be within a <PrivateSet> or a <Private> tag");
|
|
195
220
|
}
|
|
196
|
-
|
|
197
|
-
|
|
221
|
+
if (this.isNotFound && this.path) {
|
|
222
|
+
yield (0, _diagnostics.err)(this.path_literal_node, "The 'Not Found' page cannot have a path");
|
|
198
223
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
yield err(this.page_identifier, 'Page component not found');
|
|
204
|
-
}
|
|
205
|
-
if (this.path_errorMessage && this.path_literal_node) {
|
|
206
|
-
yield err(this.path_literal_node, this.path_errorMessage, RWError.INVALID_ROUTE_PATH_SYNTAX);
|
|
207
|
-
}
|
|
208
|
-
if (this.hasPathCollision) {
|
|
209
|
-
yield err(this.path_literal_node, 'Duplicate Path');
|
|
210
|
-
}
|
|
211
|
-
if (this.isPrivate && this.isNotFound) {
|
|
212
|
-
yield err(this.jsxNode, "The 'Not Found' page cannot be within a <PrivateSet> or a <Private> tag");
|
|
213
|
-
}
|
|
214
|
-
if (this.isNotFound && this.path) {
|
|
215
|
-
yield err(this.path_literal_node, "The 'Not Found' page cannot have a path");
|
|
216
|
-
}
|
|
224
|
+
}
|
|
225
|
+
get hasPathCollision() {
|
|
226
|
+
if (!this.path) {
|
|
227
|
+
return false;
|
|
217
228
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
}
|
|
230
|
-
if (removeParamNames(route2.path) === pathWithNoParamNames) {
|
|
231
|
-
return true;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
return false;
|
|
235
|
-
function removeParamNames(p) {
|
|
236
|
-
// TODO: implement
|
|
237
|
-
// foo/{bar}/baz --> foo/{}/baz
|
|
238
|
-
return p;
|
|
239
|
-
}
|
|
229
|
+
const pathWithNoParamNames = removeParamNames(this.path);
|
|
230
|
+
for (const route2 of this.parent.routes) {
|
|
231
|
+
if (route2 === this) {
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
if (!route2.path) {
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
if (removeParamNames(route2.path) === pathWithNoParamNames) {
|
|
238
|
+
return true;
|
|
239
|
+
}
|
|
240
240
|
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
}
|
|
247
|
-
// Attribute exists
|
|
248
|
-
if (tsm.Node.isJsxAttribute(attr)) {
|
|
249
|
-
const init = attr.getInitializer();
|
|
250
|
-
// Bool attributes with no initializer are true
|
|
251
|
-
// e.g. <Route prerender />
|
|
252
|
-
if (!init) {
|
|
253
|
-
return true;
|
|
254
|
-
}
|
|
255
|
-
if (tsm.Node.isJsxExpression(init)) {
|
|
256
|
-
// If it is explicitly set to true
|
|
257
|
-
// e.g. <Route prerender={true} />
|
|
258
|
-
return tsm.Node.isTrueLiteral(init.getExpression());
|
|
259
|
-
}
|
|
260
|
-
else if (tsm.Node.isStringLiteral(init)) {
|
|
261
|
-
// If its using the incorrect string form, we're accepting it as true
|
|
262
|
-
// e.g. <Route prerender="true" />
|
|
263
|
-
const literalValue = init.getLiteralValue();
|
|
264
|
-
return literalValue === 'true';
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
return false;
|
|
241
|
+
return false;
|
|
242
|
+
function removeParamNames(p) {
|
|
243
|
+
// TODO: implement
|
|
244
|
+
// foo/{bar}/baz --> foo/{}/baz
|
|
245
|
+
return p;
|
|
268
246
|
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
247
|
+
}
|
|
248
|
+
getBoolAttr(name) {
|
|
249
|
+
const attr = this.jsxNode.getAttribute(name);
|
|
250
|
+
// No attribute
|
|
251
|
+
if (!attr) {
|
|
252
|
+
return false;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// Attribute exists
|
|
256
|
+
if (tsm.Node.isJsxAttribute(attr)) {
|
|
257
|
+
const init = attr.getInitializer();
|
|
258
|
+
|
|
259
|
+
// Bool attributes with no initializer are true
|
|
260
|
+
// e.g. <Route prerender />
|
|
261
|
+
if (!init) {
|
|
262
|
+
return true;
|
|
263
|
+
}
|
|
264
|
+
if (tsm.Node.isJsxExpression(init)) {
|
|
265
|
+
// If it is explicitly set to true
|
|
266
|
+
// e.g. <Route prerender={true} />
|
|
267
|
+
return tsm.Node.isTrueLiteral(init.getExpression());
|
|
268
|
+
} else if (tsm.Node.isStringLiteral(init)) {
|
|
269
|
+
// If its using the incorrect string form, we're accepting it as true
|
|
270
|
+
// e.g. <Route prerender="true" />
|
|
271
|
+
const literalValue = init.getLiteralValue();
|
|
272
|
+
return literalValue === 'true';
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
return false;
|
|
276
|
+
}
|
|
277
|
+
getStringAttr(name) {
|
|
278
|
+
const a = this.jsxNode.getAttribute(name);
|
|
279
|
+
if (!a) {
|
|
280
|
+
return undefined;
|
|
281
|
+
}
|
|
282
|
+
if (tsm.Node.isJsxAttribute(a)) {
|
|
283
|
+
const init = a.getInitializer();
|
|
284
|
+
if (tsm.Node.isStringLiteral(init)) {
|
|
285
|
+
return init.getLiteralValue();
|
|
286
|
+
}
|
|
281
287
|
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
], RWRoute.prototype, "id", null);
|
|
286
|
-
__decorate([
|
|
287
|
-
lazy()
|
|
288
|
-
], RWRoute.prototype, "location", null);
|
|
289
|
-
__decorate([
|
|
290
|
-
lazy()
|
|
291
|
-
], RWRoute.prototype, "isPrivate", null);
|
|
292
|
-
__decorate([
|
|
293
|
-
lazy()
|
|
294
|
-
], RWRoute.prototype, "unauthenticated", null);
|
|
295
|
-
__decorate([
|
|
296
|
-
lazy()
|
|
297
|
-
], RWRoute.prototype, "roles", null);
|
|
298
|
-
__decorate([
|
|
299
|
-
lazy()
|
|
300
|
-
], RWRoute.prototype, "hasParameters", null);
|
|
301
|
-
__decorate([
|
|
302
|
-
lazy()
|
|
303
|
-
], RWRoute.prototype, "hasPrerender", null);
|
|
304
|
-
__decorate([
|
|
305
|
-
lazy()
|
|
306
|
-
], RWRoute.prototype, "page", null);
|
|
307
|
-
__decorate([
|
|
308
|
-
lazy()
|
|
309
|
-
], RWRoute.prototype, "page_identifier", null);
|
|
310
|
-
__decorate([
|
|
311
|
-
lazy()
|
|
312
|
-
], RWRoute.prototype, "page_identifier_str", null);
|
|
313
|
-
__decorate([
|
|
314
|
-
lazy()
|
|
315
|
-
], RWRoute.prototype, "name", null);
|
|
316
|
-
__decorate([
|
|
317
|
-
lazy()
|
|
318
|
-
], RWRoute.prototype, "path_errorMessage", null);
|
|
319
|
-
__decorate([
|
|
320
|
-
lazy()
|
|
321
|
-
], RWRoute.prototype, "path", null);
|
|
322
|
-
__decorate([
|
|
323
|
-
lazy()
|
|
324
|
-
], RWRoute.prototype, "prerender", null);
|
|
325
|
-
__decorate([
|
|
326
|
-
lazy()
|
|
327
|
-
], RWRoute.prototype, "renderMode", null);
|
|
328
|
-
__decorate([
|
|
329
|
-
lazy()
|
|
330
|
-
], RWRoute.prototype, "path_literal_node", null);
|
|
331
|
-
__decorate([
|
|
332
|
-
lazy()
|
|
333
|
-
], RWRoute.prototype, "isNotFound", null);
|
|
334
|
-
__decorate([
|
|
335
|
-
lazy()
|
|
336
|
-
], RWRoute.prototype, "redirect", null);
|
|
337
|
-
__decorate([
|
|
338
|
-
lazy()
|
|
339
|
-
], RWRoute.prototype, "hasPathCollision", null);
|
|
340
|
-
//# sourceMappingURL=RWRoute.js.map
|
|
288
|
+
return undefined;
|
|
289
|
+
}
|
|
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,7 @@
|
|
|
1
|
-
import { FileNode } from '../nodes
|
|
2
|
-
import type { ExtendedDiagnostic } from '../x/diagnostics
|
|
3
|
-
import type { RWProject } from './RWProject
|
|
4
|
-
import { RWRoute } from './RWRoute
|
|
1
|
+
import { FileNode } from '../nodes';
|
|
2
|
+
import type { ExtendedDiagnostic } from '../x/diagnostics';
|
|
3
|
+
import type { RWProject } from './RWProject';
|
|
4
|
+
import { RWRoute } from './RWRoute';
|
|
5
5
|
/**
|
|
6
6
|
* one per Routes.js
|
|
7
7
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RWRouter.d.ts","sourceRoot":"","sources":["../../src/model/RWRouter.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"RWRouter.d.ts","sourceRoot":"","sources":["../../src/model/RWRouter.ts"],"names":[],"mappings":"AAKA,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"}
|