@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/RWSDLField.js
CHANGED
|
@@ -1,81 +1,83 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.RWSDLField = void 0;
|
|
9
|
+
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/map"));
|
|
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 _errors = require("../errors");
|
|
14
|
+
var _nodes = require("../nodes");
|
|
15
|
+
var _decorators = require("../x/decorators");
|
|
16
|
+
var _diagnostics = require("../x/diagnostics");
|
|
17
|
+
var _dec, _dec2, _dec3, _dec4, _dec5, _class;
|
|
18
|
+
let RWSDLField = exports.RWSDLField = (_dec = (0, _decorators.lazy)(), _dec2 = (0, _decorators.lazy)(), _dec3 = (0, _decorators.lazy)(), _dec4 = (0, _decorators.lazy)(), _dec5 = (0, _decorators.lazy)(), _class = class RWSDLField extends _nodes.BaseNode {
|
|
19
|
+
constructor(objectTypeDef, field, parent) {
|
|
20
|
+
super();
|
|
21
|
+
this.objectTypeDef = objectTypeDef;
|
|
22
|
+
this.field = field;
|
|
23
|
+
this.parent = parent;
|
|
24
|
+
}
|
|
25
|
+
get id() {
|
|
26
|
+
return this.parent.id + ' ' + this.objectTypeDef.name.value + '.' + this.name;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The location of this field.
|
|
30
|
+
* Calculating this is slightly complicated since it is embedded within a TaggedTemplateLiteral
|
|
31
|
+
*/
|
|
32
|
+
get location() {
|
|
33
|
+
let {
|
|
34
|
+
start,
|
|
35
|
+
end
|
|
36
|
+
} = this.field.loc;
|
|
37
|
+
const node = this.parent.schemaStringNode;
|
|
38
|
+
start += node.getPos() + 1; // we add one to account for the quote (`)
|
|
39
|
+
end += node.getPos() + 1;
|
|
40
|
+
const startPos = (0, _diagnostics.Position_fromTSMorphOffset)(start, node.getSourceFile());
|
|
41
|
+
const endPos = (0, _diagnostics.Position_fromTSMorphOffset)(end, node.getSourceFile());
|
|
42
|
+
return {
|
|
43
|
+
uri: this.parent.uri,
|
|
44
|
+
range: {
|
|
45
|
+
start: startPos,
|
|
46
|
+
end: endPos
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
get name() {
|
|
51
|
+
return this.field.name.value;
|
|
52
|
+
}
|
|
53
|
+
get argumentNames() {
|
|
54
|
+
var _context;
|
|
55
|
+
return (0, _map.default)(_context = this.field.arguments ?? []).call(_context, a => a.name.value);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* TODO: describe in prose what is going on here.
|
|
60
|
+
* this is an important rule
|
|
61
|
+
*/
|
|
62
|
+
get impl() {
|
|
63
|
+
var _context2;
|
|
64
|
+
return (0, _find.default)(_context2 = this.parent.service?.funcs ?? []).call(_context2, f => f.name === this.name);
|
|
65
|
+
}
|
|
66
|
+
*diagnostics() {
|
|
67
|
+
if (!this.impl) {
|
|
68
|
+
const {
|
|
69
|
+
uri,
|
|
70
|
+
range
|
|
71
|
+
} = this.location;
|
|
72
|
+
yield {
|
|
73
|
+
uri,
|
|
74
|
+
diagnostic: {
|
|
75
|
+
range,
|
|
76
|
+
message: 'Service Not Implemented',
|
|
77
|
+
severity: _diagnostics.DiagnosticSeverity.Error,
|
|
78
|
+
code: _errors.RWError.SERVICE_NOT_IMPLEMENTED
|
|
63
79
|
}
|
|
80
|
+
};
|
|
64
81
|
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
lazy()
|
|
68
|
-
], RWSDLField.prototype, "id", null);
|
|
69
|
-
__decorate([
|
|
70
|
-
lazy()
|
|
71
|
-
], RWSDLField.prototype, "location", null);
|
|
72
|
-
__decorate([
|
|
73
|
-
lazy()
|
|
74
|
-
], RWSDLField.prototype, "name", null);
|
|
75
|
-
__decorate([
|
|
76
|
-
lazy()
|
|
77
|
-
], RWSDLField.prototype, "argumentNames", null);
|
|
78
|
-
__decorate([
|
|
79
|
-
lazy()
|
|
80
|
-
], RWSDLField.prototype, "impl", null);
|
|
81
|
-
//# sourceMappingURL=RWSDLField.js.map
|
|
82
|
+
}
|
|
83
|
+
}, (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, "name", [_dec3], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "name"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "argumentNames", [_dec4], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "argumentNames"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "impl", [_dec5], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "impl"), _class.prototype), _class);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { FileNode } from '../nodes
|
|
2
|
-
import type { RWProject } from './RWProject
|
|
3
|
-
import type { RWSDL } from './RWSDL
|
|
4
|
-
import { RWServiceFunction } from './RWServiceFunction
|
|
1
|
+
import { FileNode } from '../nodes';
|
|
2
|
+
import type { RWProject } from './RWProject';
|
|
3
|
+
import type { RWSDL } from './RWSDL';
|
|
4
|
+
import { RWServiceFunction } from './RWServiceFunction';
|
|
5
5
|
export declare class RWService extends FileNode {
|
|
6
6
|
filePath: string;
|
|
7
7
|
parent: RWProject;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RWService.d.ts","sourceRoot":"","sources":["../../src/model/RWService.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"RWService.d.ts","sourceRoot":"","sources":["../../src/model/RWService.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAKnC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAEvD,qBAAa,SAAU,SAAQ,QAAQ;IAE5B,QAAQ,EAAE,MAAM;IAChB,MAAM,EAAE,SAAS;gBADjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,SAAS;IAI1B;;;OAGG;IACH,IAAY,IAAI,WAEf;IAED;;;OAGG;IAEH,IAAY,GAAG,IAAI,KAAK,GAAG,SAAS,CAEnC;IAED,QAAQ;IAIR;;;OAGG;IAEH,IAAY,KAAK,wBAuBhB;CACF"}
|
package/dist/model/RWService.js
CHANGED
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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.RWService = 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 tsm = _interopRequireWildcard(require("ts-morph"));
|
|
14
|
+
var _nodes = require("../nodes");
|
|
15
|
+
var _Array = require("../x/Array");
|
|
16
|
+
var _decorators = require("../x/decorators");
|
|
17
|
+
var _path = require("../x/path");
|
|
18
|
+
var _RWServiceFunction = require("./RWServiceFunction");
|
|
19
|
+
var _dec, _dec2, _dec3, _class;
|
|
20
|
+
let RWService = exports.RWService = (_dec = (0, _decorators.lazy)(), _dec2 = (0, _decorators.lazy)(), _dec3 = (0, _decorators.lazy)(), _class = class RWService extends _nodes.FileNode {
|
|
21
|
+
constructor(filePath, parent) {
|
|
22
|
+
super();
|
|
23
|
+
this.filePath = filePath;
|
|
24
|
+
this.parent = parent;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The name of this service:
|
|
28
|
+
* services/todos/todos.js --> todos
|
|
29
|
+
*/
|
|
30
|
+
get name() {
|
|
31
|
+
return (0, _path.basenameNoExt)(this.filePath);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Returns the SDL associated with this service (if any).
|
|
36
|
+
* Match is performed by name.
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
get sdl() {
|
|
40
|
+
var _context;
|
|
41
|
+
return (0, _find.default)(_context = this.parent.sdls).call(_context, sdl => sdl.name === this.name);
|
|
42
|
+
}
|
|
43
|
+
children() {
|
|
44
|
+
return [...this.funcs];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* All the exported functions declared in this service file.
|
|
49
|
+
* They can be both ArrowFunctions (with name) or FunctionDeclarations (with name)
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
get funcs() {
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
54
|
+
const self = this;
|
|
55
|
+
return (0, _Array.iter)(function* () {
|
|
56
|
+
// export const foo = () => {}
|
|
57
|
+
for (const vd of self.sf.getVariableDeclarations()) {
|
|
58
|
+
if (vd.isExported()) {
|
|
59
|
+
const init = vd.getInitializerIfKind(tsm.SyntaxKind.ArrowFunction);
|
|
60
|
+
if (init) {
|
|
61
|
+
yield new _RWServiceFunction.RWServiceFunction(vd.getName(), init, self);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// export function foo(){}
|
|
66
|
+
for (const fd of self.sf.getFunctions()) {
|
|
67
|
+
if (fd.isExported() && !fd.isDefaultExport()) {
|
|
68
|
+
const nn = fd.getNameNode();
|
|
69
|
+
if (nn) {
|
|
70
|
+
yield new _RWServiceFunction.RWServiceFunction(nn.getText(), fd, self);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}, (0, _applyDecoratedDescriptor2.default)(_class.prototype, "name", [_dec], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "name"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "sdl", [_dec2], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "sdl"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "funcs", [_dec3], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "funcs"), _class.prototype), _class);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as tsm from 'ts-morph';
|
|
2
|
-
import { BaseNode } from '../nodes
|
|
3
|
-
import type { ExtendedDiagnostic } from '../x/diagnostics
|
|
4
|
-
import type { RWSDLField } from './RWSDLField
|
|
5
|
-
import type { RWService } from './RWService
|
|
2
|
+
import { BaseNode } from '../nodes';
|
|
3
|
+
import type { ExtendedDiagnostic } from '../x/diagnostics';
|
|
4
|
+
import type { RWSDLField } from './RWSDLField';
|
|
5
|
+
import type { RWService } from './RWService';
|
|
6
6
|
export declare class RWServiceFunction extends BaseNode {
|
|
7
7
|
name: string;
|
|
8
8
|
node: tsm.FunctionDeclaration | tsm.ArrowFunction;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RWServiceFunction.d.ts","sourceRoot":"","sources":["../../src/model/RWServiceFunction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAE/B,OAAO,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"RWServiceFunction.d.ts","sourceRoot":"","sources":["../../src/model/RWServiceFunction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAE/B,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAGnC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAI1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAE5C,qBAAa,iBAAkB,SAAQ,QAAQ;IAEpC,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,GAAG,CAAC,mBAAmB,GAAG,GAAG,CAAC,aAAa;IACjD,MAAM,EAAE,SAAS;gBAFjB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,GAAG,CAAC,mBAAmB,GAAG,GAAG,CAAC,aAAa,EACjD,MAAM,EAAE,SAAS;IAK1B,IAAY,EAAE,WAGb;IAED;;;OAGG;IAEH,IAAY,QAAQ,IAAI,UAAU,GAAG,SAAS,CAI7C;IAED,IAAY,cAAc,aAczB;IAEA,WAAW;CAwCb"}
|
|
@@ -1,97 +1,99 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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.RWServiceFunction = void 0;
|
|
10
|
+
var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/find"));
|
|
11
|
+
var _bind = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/bind"));
|
|
12
|
+
var _sort = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/sort"));
|
|
13
|
+
var _getOwnPropertyDescriptor = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/object/get-own-property-descriptor"));
|
|
14
|
+
var _applyDecoratedDescriptor2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/applyDecoratedDescriptor"));
|
|
15
|
+
var tsm = _interopRequireWildcard(require("ts-morph"));
|
|
16
|
+
var _nodes = require("../nodes");
|
|
17
|
+
var _Array = require("../x/Array");
|
|
18
|
+
var _decorators = require("../x/decorators");
|
|
19
|
+
var _diagnostics = require("../x/diagnostics");
|
|
20
|
+
var _dec, _dec2, _dec3, _class;
|
|
21
|
+
let RWServiceFunction = exports.RWServiceFunction = (_dec = (0, _decorators.lazy)(), _dec2 = (0, _decorators.lazy)(), _dec3 = (0, _decorators.lazy)(), _class = class RWServiceFunction extends _nodes.BaseNode {
|
|
22
|
+
constructor(name, node, parent) {
|
|
23
|
+
super();
|
|
24
|
+
this.name = name;
|
|
25
|
+
this.node = node;
|
|
26
|
+
this.parent = parent;
|
|
27
|
+
}
|
|
28
|
+
get id() {
|
|
29
|
+
// This is a compound ID (because it points to an internal node - one within a file)
|
|
30
|
+
return this.parent.id + ' ' + this.name;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The SDL field that this function implements, if any
|
|
35
|
+
* TODO: describe this in prose.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
get sdlField() {
|
|
39
|
+
var _context, _context2;
|
|
40
|
+
return ((_context = this.parent.sdl?.implementableFields) == null ? void 0 : (0, _bind.default)(_context2 = Function.call).call(_context2, (0, _find.default)(_context), _context))?.(f => f.name === this.name);
|
|
41
|
+
}
|
|
42
|
+
get parameterNames() {
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
44
|
+
const self = this;
|
|
45
|
+
return (0, _Array.iter)(function* () {
|
|
46
|
+
for (const p of self.node.getParameters()) {
|
|
47
|
+
const nn = p.getNameNode();
|
|
48
|
+
if (nn instanceof tsm.ObjectBindingPattern) {
|
|
49
|
+
for (const element of nn.getElements()) {
|
|
50
|
+
yield element.getNameNode().getText();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
// TODO: handle other cases
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
*diagnostics() {
|
|
58
|
+
if (this.sdlField) {
|
|
59
|
+
var _context3, _context4;
|
|
60
|
+
// this service function is implementing a field
|
|
61
|
+
// parameter names should match
|
|
62
|
+
const p1 = (0, _sort.default)(_context3 = this.sdlField.argumentNames).call(_context3).join(' '); //?
|
|
63
|
+
const p2 = (0, _sort.default)(_context4 = this.parameterNames).call(_context4).join(' '); //?
|
|
64
|
+
if (p1 !== p2) {
|
|
65
|
+
const locationNode = this.node.getParameters()[0] ?? this.node;
|
|
66
|
+
const {
|
|
67
|
+
uri,
|
|
68
|
+
range
|
|
69
|
+
} = (0, _diagnostics.Location_fromNode)(locationNode);
|
|
70
|
+
const message = `Parameter mismatch between SDL and implementation ("${p1}" !== "${p2}")`;
|
|
71
|
+
const diagnostic = {
|
|
72
|
+
uri,
|
|
73
|
+
diagnostic: {
|
|
74
|
+
range,
|
|
75
|
+
message,
|
|
76
|
+
severity: _diagnostics.DiagnosticSeverity.Error,
|
|
77
|
+
// add related information so developers can jump to the SDL definition
|
|
78
|
+
relatedInformation: [{
|
|
79
|
+
location: this.sdlField.location,
|
|
80
|
+
message: 'SDL field is defined here'
|
|
81
|
+
}]
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
// comment out for now (see https://github.com/redwoodjs/redwood/issues/943)
|
|
85
|
+
|
|
86
|
+
// comment out for now (see https://github.com/redwoodjs/redwood/issues/943)
|
|
87
|
+
// eslint-disable-next-line no-constant-condition
|
|
88
|
+
if (false) {
|
|
89
|
+
yield diagnostic;
|
|
85
90
|
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// TODO: check that types match
|
|
94
|
+
// to do this it is probably easier to leverage a graphql code generator and the typescript compiler
|
|
95
|
+
// the trick is to create a source file with an interface assignment that will fail if there is a mismatch
|
|
96
|
+
// we then simply "bubble up" the type errors from the typescript compiler
|
|
86
97
|
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
lazy()
|
|
90
|
-
], RWServiceFunction.prototype, "id", null);
|
|
91
|
-
__decorate([
|
|
92
|
-
lazy()
|
|
93
|
-
], RWServiceFunction.prototype, "sdlField", null);
|
|
94
|
-
__decorate([
|
|
95
|
-
lazy()
|
|
96
|
-
], RWServiceFunction.prototype, "parameterNames", null);
|
|
97
|
-
//# sourceMappingURL=RWServiceFunction.js.map
|
|
98
|
+
}
|
|
99
|
+
}, (0, _applyDecoratedDescriptor2.default)(_class.prototype, "id", [_dec], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "id"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "sdlField", [_dec2], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "sdlField"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "parameterNames", [_dec3], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "parameterNames"), _class.prototype), _class);
|
package/dist/model/RWTOML.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as toml from 'smol-toml';
|
|
2
|
-
import { FileNode } from '../nodes
|
|
3
|
-
import type { RWProject } from './RWProject
|
|
2
|
+
import { FileNode } from '../nodes';
|
|
3
|
+
import type { RWProject } from './RWProject';
|
|
4
4
|
export declare class RWTOML extends FileNode {
|
|
5
5
|
filePath: string;
|
|
6
6
|
parent: RWProject;
|
|
7
7
|
constructor(filePath: string, parent: RWProject);
|
|
8
8
|
get parsedTOML(): toml.TomlTable;
|
|
9
9
|
get web_includeEnvironmentVariables(): string[] | undefined;
|
|
10
|
-
diagnostics(): Generator<import("../x/diagnostics
|
|
10
|
+
diagnostics(): Generator<import("../x/diagnostics").ExtendedDiagnostic, void, unknown>;
|
|
11
11
|
}
|
|
12
12
|
//# sourceMappingURL=RWTOML.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RWTOML.d.ts","sourceRoot":"","sources":["../../src/model/RWTOML.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AAEjC,OAAO,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"RWTOML.d.ts","sourceRoot":"","sources":["../../src/model/RWTOML.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AAEjC,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAKnC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAE5C,qBAAa,MAAO,SAAQ,QAAQ;IAEzB,QAAQ,EAAE,MAAM;IAChB,MAAM,EAAE,SAAS;gBADjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,SAAS;IAQ1B,IAAY,UAAU,mBAErB;IACD,IAAY,+BAA+B,IAAI,MAAM,EAAE,GAAG,SAAS,CAElE;IACA,WAAW;CAgBb"}
|