@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.
Files changed (110) hide show
  1. package/README.md +1 -1
  2. package/dist/errors.js +15 -9
  3. package/dist/index.d.ts +7 -7
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +67 -40
  6. package/dist/model/RWCell.d.ts +4 -4
  7. package/dist/model/RWCell.d.ts.map +1 -1
  8. package/dist/model/RWCell.js +103 -111
  9. package/dist/model/RWComponent.d.ts +2 -2
  10. package/dist/model/RWComponent.d.ts.map +1 -1
  11. package/dist/model/RWComponent.js +41 -46
  12. package/dist/model/RWEnvHelper.d.ts +4 -4
  13. package/dist/model/RWEnvHelper.d.ts.map +1 -1
  14. package/dist/model/RWEnvHelper.js +205 -212
  15. package/dist/model/RWFunction.d.ts +2 -2
  16. package/dist/model/RWFunction.d.ts.map +1 -1
  17. package/dist/model/RWFunction.js +15 -10
  18. package/dist/model/RWLayout.d.ts +2 -2
  19. package/dist/model/RWLayout.d.ts.map +1 -1
  20. package/dist/model/RWLayout.js +15 -10
  21. package/dist/model/RWPage.d.ts +3 -3
  22. package/dist/model/RWPage.d.ts.map +1 -1
  23. package/dist/model/RWPage.js +57 -61
  24. package/dist/model/RWProject.d.ts +17 -11
  25. package/dist/model/RWProject.d.ts.map +1 -1
  26. package/dist/model/RWProject.js +164 -218
  27. package/dist/model/RWRoute.d.ts +5 -5
  28. package/dist/model/RWRoute.d.ts.map +1 -1
  29. package/dist/model/RWRoute.js +262 -312
  30. package/dist/model/RWRouter.d.ts +4 -4
  31. package/dist/model/RWRouter.d.ts.map +1 -1
  32. package/dist/model/RWRouter.js +126 -130
  33. package/dist/model/RWSDL.d.ts +5 -5
  34. package/dist/model/RWSDL.d.ts.map +1 -1
  35. package/dist/model/RWSDL.js +84 -96
  36. package/dist/model/RWSDLField.d.ts +6 -6
  37. package/dist/model/RWSDLField.d.ts.map +1 -1
  38. package/dist/model/RWSDLField.js +81 -79
  39. package/dist/model/RWService.d.ts +4 -4
  40. package/dist/model/RWService.d.ts.map +1 -1
  41. package/dist/model/RWService.js +76 -76
  42. package/dist/model/RWServiceFunction.d.ts +4 -4
  43. package/dist/model/RWServiceFunction.d.ts.map +1 -1
  44. package/dist/model/RWServiceFunction.js +97 -95
  45. package/dist/model/RWTOML.d.ts +3 -3
  46. package/dist/model/RWTOML.d.ts.map +1 -1
  47. package/dist/model/RWTOML.js +55 -53
  48. package/dist/model/index.d.ts +2 -2
  49. package/dist/model/index.d.ts.map +1 -1
  50. package/dist/model/index.js +20 -3
  51. package/dist/model/util/process_env.js +62 -44
  52. package/dist/nodes.d.ts +2 -2
  53. package/dist/nodes.d.ts.map +1 -1
  54. package/dist/nodes.js +164 -171
  55. package/dist/util.js +33 -23
  56. package/dist/x/Array.js +25 -15
  57. package/dist/x/Location.d.ts +1 -1
  58. package/dist/x/Location.d.ts.map +1 -1
  59. package/dist/x/Location.js +17 -11
  60. package/dist/x/Position.js +29 -18
  61. package/dist/x/Range.d.ts +1 -1
  62. package/dist/x/Range.d.ts.map +1 -1
  63. package/dist/x/Range.js +22 -17
  64. package/dist/x/URL.js +75 -59
  65. package/dist/x/child_process.d.ts +1 -1
  66. package/dist/x/child_process.d.ts.map +1 -1
  67. package/dist/x/child_process.js +49 -35
  68. package/dist/x/decorators.d.ts +2 -2
  69. package/dist/x/decorators.d.ts.map +1 -1
  70. package/dist/x/decorators.js +26 -46
  71. package/dist/x/diagnostics.d.ts +3 -3
  72. package/dist/x/diagnostics.d.ts.map +1 -1
  73. package/dist/x/diagnostics.js +259 -163
  74. package/dist/x/path.js +55 -36
  75. package/dist/x/prisma.d.ts +2 -2
  76. package/dist/x/prisma.d.ts.map +1 -1
  77. package/dist/x/prisma.js +55 -32
  78. package/dist/x/ts-morph.js +45 -34
  79. package/package.json +17 -38
  80. package/dist/errors.js.map +0 -1
  81. package/dist/index.js.map +0 -1
  82. package/dist/model/RWCell.js.map +0 -1
  83. package/dist/model/RWComponent.js.map +0 -1
  84. package/dist/model/RWEnvHelper.js.map +0 -1
  85. package/dist/model/RWFunction.js.map +0 -1
  86. package/dist/model/RWLayout.js.map +0 -1
  87. package/dist/model/RWPage.js.map +0 -1
  88. package/dist/model/RWProject.js.map +0 -1
  89. package/dist/model/RWRoute.js.map +0 -1
  90. package/dist/model/RWRouter.js.map +0 -1
  91. package/dist/model/RWSDL.js.map +0 -1
  92. package/dist/model/RWSDLField.js.map +0 -1
  93. package/dist/model/RWService.js.map +0 -1
  94. package/dist/model/RWServiceFunction.js.map +0 -1
  95. package/dist/model/RWTOML.js.map +0 -1
  96. package/dist/model/index.js.map +0 -1
  97. package/dist/model/util/process_env.js.map +0 -1
  98. package/dist/nodes.js.map +0 -1
  99. package/dist/util.js.map +0 -1
  100. package/dist/x/Array.js.map +0 -1
  101. package/dist/x/Location.js.map +0 -1
  102. package/dist/x/Position.js.map +0 -1
  103. package/dist/x/Range.js.map +0 -1
  104. package/dist/x/URL.js.map +0 -1
  105. package/dist/x/child_process.js.map +0 -1
  106. package/dist/x/decorators.js.map +0 -1
  107. package/dist/x/diagnostics.js.map +0 -1
  108. package/dist/x/path.js.map +0 -1
  109. package/dist/x/prisma.js.map +0 -1
  110. package/dist/x/ts-morph.js.map +0 -1
@@ -1,81 +1,83 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- import { RWError } from '../errors.js';
8
- import { BaseNode } from '../nodes.js';
9
- import { lazy } from '../x/decorators.js';
10
- import { Position_fromTSMorphOffset } from '../x/diagnostics.js';
11
- import { DiagnosticSeverity } from '../x/diagnostics.js';
12
- export class RWSDLField extends BaseNode {
13
- objectTypeDef;
14
- field;
15
- parent;
16
- constructor(objectTypeDef, field, parent) {
17
- super();
18
- this.objectTypeDef = objectTypeDef;
19
- this.field = field;
20
- this.parent = parent;
21
- }
22
- get id() {
23
- return (this.parent.id + ' ' + this.objectTypeDef.name.value + '.' + this.name);
24
- }
25
- /**
26
- * The location of this field.
27
- * Calculating this is slightly complicated since it is embedded within a TaggedTemplateLiteral
28
- */
29
- get location() {
30
- let { start, end } = this.field.loc;
31
- const node = this.parent.schemaStringNode;
32
- start += node.getPos() + 1; // we add one to account for the quote (`)
33
- end += node.getPos() + 1;
34
- const startPos = Position_fromTSMorphOffset(start, node.getSourceFile());
35
- const endPos = Position_fromTSMorphOffset(end, node.getSourceFile());
36
- return { uri: this.parent.uri, range: { start: startPos, end: endPos } };
37
- }
38
- get name() {
39
- return this.field.name.value;
40
- }
41
- get argumentNames() {
42
- return (this.field.arguments ?? []).map((a) => a.name.value);
43
- }
44
- /**
45
- * TODO: describe in prose what is going on here.
46
- * this is an important rule
47
- */
48
- get impl() {
49
- return (this.parent.service?.funcs ?? []).find((f) => f.name === this.name);
50
- }
51
- *diagnostics() {
52
- if (!this.impl) {
53
- const { uri, range } = this.location;
54
- yield {
55
- uri,
56
- diagnostic: {
57
- range,
58
- message: 'Service Not Implemented',
59
- severity: DiagnosticSeverity.Error,
60
- code: RWError.SERVICE_NOT_IMPLEMENTED,
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
- __decorate([
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.js';
2
- import type { RWProject } from './RWProject.js';
3
- import type { RWSDL } from './RWSDL.js';
4
- import { RWServiceFunction } from './RWServiceFunction.js';
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,aAAa,CAAA;AAKtC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE1D,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"}
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"}
@@ -1,76 +1,76 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- import * as tsm from 'ts-morph';
8
- import { FileNode } from '../nodes.js';
9
- import { iter } from '../x/Array.js';
10
- import { lazy } from '../x/decorators.js';
11
- import { basenameNoExt } from '../x/path.js';
12
- import { RWServiceFunction } from './RWServiceFunction.js';
13
- export class RWService extends FileNode {
14
- filePath;
15
- parent;
16
- constructor(filePath, parent) {
17
- super();
18
- this.filePath = filePath;
19
- this.parent = parent;
20
- }
21
- /**
22
- * The name of this service:
23
- * services/todos/todos.js --> todos
24
- */
25
- get name() {
26
- return basenameNoExt(this.filePath);
27
- }
28
- /**
29
- * Returns the SDL associated with this service (if any).
30
- * Match is performed by name.
31
- */
32
- get sdl() {
33
- return this.parent.sdls.find((sdl) => sdl.name === this.name);
34
- }
35
- children() {
36
- return [...this.funcs];
37
- }
38
- /**
39
- * All the exported functions declared in this service file.
40
- * They can be both ArrowFunctions (with name) or FunctionDeclarations (with name)
41
- */
42
- get funcs() {
43
- // eslint-disable-next-line @typescript-eslint/no-this-alias
44
- const self = this;
45
- return iter(function* () {
46
- // export const foo = () => {}
47
- for (const vd of self.sf.getVariableDeclarations()) {
48
- if (vd.isExported()) {
49
- const init = vd.getInitializerIfKind(tsm.SyntaxKind.ArrowFunction);
50
- if (init) {
51
- yield new RWServiceFunction(vd.getName(), init, self);
52
- }
53
- }
54
- }
55
- // export function foo(){}
56
- for (const fd of self.sf.getFunctions()) {
57
- if (fd.isExported() && !fd.isDefaultExport()) {
58
- const nn = fd.getNameNode();
59
- if (nn) {
60
- yield new RWServiceFunction(nn.getText(), fd, self);
61
- }
62
- }
63
- }
64
- });
65
- }
66
- }
67
- __decorate([
68
- lazy()
69
- ], RWService.prototype, "name", null);
70
- __decorate([
71
- lazy()
72
- ], RWService.prototype, "sdl", null);
73
- __decorate([
74
- lazy()
75
- ], RWService.prototype, "funcs", null);
76
- //# sourceMappingURL=RWService.js.map
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.js';
3
- import type { ExtendedDiagnostic } from '../x/diagnostics.js';
4
- import type { RWSDLField } from './RWSDLField.js';
5
- import type { RWService } from './RWService.js';
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,aAAa,CAAA;AAGtC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAI7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE/C,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
+ {"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
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- import * as tsm from 'ts-morph';
8
- import { BaseNode } from '../nodes.js';
9
- import { iter } from '../x/Array.js';
10
- import { lazy } from '../x/decorators.js';
11
- import { Location_fromNode } from '../x/diagnostics.js';
12
- import { DiagnosticSeverity } from '../x/diagnostics.js';
13
- export class RWServiceFunction extends BaseNode {
14
- name;
15
- node;
16
- parent;
17
- constructor(name, node, parent) {
18
- super();
19
- this.name = name;
20
- this.node = node;
21
- this.parent = parent;
22
- }
23
- get id() {
24
- // This is a compound ID (because it points to an internal node - one within a file)
25
- return this.parent.id + ' ' + this.name;
26
- }
27
- /**
28
- * The SDL field that this function implements, if any
29
- * TODO: describe this in prose.
30
- */
31
- get sdlField() {
32
- return this.parent.sdl?.implementableFields?.find((f) => f.name === this.name);
33
- }
34
- get parameterNames() {
35
- // eslint-disable-next-line @typescript-eslint/no-this-alias
36
- const self = this;
37
- return iter(function* () {
38
- for (const p of self.node.getParameters()) {
39
- const nn = p.getNameNode();
40
- if (nn instanceof tsm.ObjectBindingPattern) {
41
- for (const element of nn.getElements()) {
42
- yield element.getNameNode().getText();
43
- }
44
- }
45
- // TODO: handle other cases
46
- }
47
- });
48
- }
49
- *diagnostics() {
50
- if (this.sdlField) {
51
- // this service function is implementing a field
52
- // parameter names should match
53
- const p1 = this.sdlField.argumentNames.sort().join(' '); //?
54
- const p2 = this.parameterNames.sort().join(' '); //?
55
- if (p1 !== p2) {
56
- const locationNode = this.node.getParameters()[0] ?? this.node;
57
- const { uri, range } = Location_fromNode(locationNode);
58
- const message = `Parameter mismatch between SDL and implementation ("${p1}" !== "${p2}")`;
59
- const diagnostic = {
60
- uri,
61
- diagnostic: {
62
- range,
63
- message,
64
- severity: DiagnosticSeverity.Error,
65
- // add related information so developers can jump to the SDL definition
66
- relatedInformation: [
67
- {
68
- location: this.sdlField.location,
69
- message: 'SDL field is defined here',
70
- },
71
- ],
72
- },
73
- };
74
- // comment out for now (see https://github.com/redwoodjs/redwood/issues/943)
75
- // comment out for now (see https://github.com/redwoodjs/redwood/issues/943)
76
- // eslint-disable-next-line no-constant-condition
77
- if (false) {
78
- yield diagnostic;
79
- }
80
- }
81
- // TODO: check that types match
82
- // to do this it is probably easier to leverage a graphql code generator and the typescript compiler
83
- // the trick is to create a source file with an interface assignment that will fail if there is a mismatch
84
- // we then simply "bubble up" the type errors from the typescript compiler
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
- __decorate([
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);
@@ -1,12 +1,12 @@
1
1
  import * as toml from 'smol-toml';
2
- import { FileNode } from '../nodes.js';
3
- import type { RWProject } from './RWProject.js';
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.js").ExtendedDiagnostic, void, unknown>;
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,aAAa,CAAA;AAKtC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE/C,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"}
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"}