@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.
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
package/README.md CHANGED
@@ -21,7 +21,7 @@ The most common use-case is getting the diagnostics of a complete Cedar project:
21
21
  ```ts
22
22
  import { getProject } from '@cedarjs/structure'
23
23
  async function test() {
24
- const project = getProject()
24
+ const project = getProject('/path/to/app') // or "file:///path/to/app"
25
25
  for (const d of await project.collectDiagnostics()) {
26
26
  console.log(d.diagnostic.severity + ': ' + d.diagnostic.message)
27
27
  }
package/dist/errors.js CHANGED
@@ -1,13 +1,19 @@
1
+ "use strict";
2
+
3
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js/object/define-property");
4
+ _Object$defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.RWError = void 0;
1
8
  /**
2
9
  * Stable error codes
3
10
  * TODO: use numbers? they tend to be more resilient to changes.
4
11
  */
5
- export var RWError;
6
- (function (RWError) {
7
- RWError["SERVICE_NOT_IMPLEMENTED"] = "SERVICE_NOT_IMPLEMENTED";
8
- RWError["NOTFOUND_PAGE_NOT_DEFINED"] = "NOTFOUND_PAGE_NOT_DEFINED";
9
- // this error should be broken down into more specialized errors: syntax error, duplicate parameters
10
- RWError["INVALID_ROUTE_PATH_SYNTAX"] = "INVALID_ROUTE_PATH_SYNTAX";
11
- RWError["SCHEMA_NOT_DEFINED"] = "SCHEMA_NOT_DEFINED";
12
- })(RWError || (RWError = {}));
13
- //# sourceMappingURL=errors.js.map
12
+ let RWError = exports.RWError = /*#__PURE__*/function (RWError) {
13
+ RWError["SERVICE_NOT_IMPLEMENTED"] = "SERVICE_NOT_IMPLEMENTED";
14
+ RWError["NOTFOUND_PAGE_NOT_DEFINED"] = "NOTFOUND_PAGE_NOT_DEFINED";
15
+ // this error should be broken down into more specialized errors: syntax error, duplicate parameters
16
+ RWError["INVALID_ROUTE_PATH_SYNTAX"] = "INVALID_ROUTE_PATH_SYNTAX";
17
+ RWError["SCHEMA_NOT_DEFINED"] = "SCHEMA_NOT_DEFINED";
18
+ return RWError;
19
+ }({});
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- export { DiagnosticSeverity } from './x/diagnostics.js';
2
- export { RWProject, RWRoute } from './model/index.js';
3
- export { URL_file } from './x/URL.js';
4
- import { RWProject } from './model/index.js';
5
- import type { GetSeverityLabelFunction } from './x/diagnostics.js';
6
- export declare function getProject(): RWProject;
7
- export declare function printDiagnostics(opts?: {
1
+ export { DiagnosticSeverity } from './x/diagnostics';
2
+ export { RWProject, RWRoute } from './model';
3
+ export { URL_file } from './x/URL';
4
+ import { RWProject } from './model';
5
+ import type { GetSeverityLabelFunction } from './x/diagnostics';
6
+ export declare function getProject(projectRoot: string): RWProject;
7
+ export declare function printDiagnostics(projectRoot: string, opts?: {
8
8
  getSeverityLabel?: GetSeverityLabelFunction;
9
9
  }): Promise<void>;
10
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAA;AAMlE,wBAAgB,UAAU,cAEzB;AAED,wBAAsB,gBAAgB,CAAC,IAAI,CAAC,EAAE;IAC5C,gBAAgB,CAAC,EAAE,wBAAwB,CAAA;CAC5C,iBAkCA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AACnC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAA;AAG/D,wBAAgB,UAAU,CAAC,WAAW,EAAE,MAAM,aAI7C;AAED,wBAAsB,gBAAgB,CACpC,WAAW,EAAE,MAAM,EACnB,IAAI,CAAC,EAAE;IAAE,gBAAgB,CAAC,EAAE,wBAAwB,CAAA;CAAE,iBA8BvD"}
package/dist/index.js CHANGED
@@ -1,43 +1,70 @@
1
- import { getPaths } from '@cedarjs/project-config';
2
- export { DiagnosticSeverity } from './x/diagnostics.js';
3
- export { RWProject, RWRoute } from './model/index.js';
4
- export { URL_file } from './x/URL.js';
5
- import { RWProject } from './model/index.js';
6
- import { ExtendedDiagnostic_format, DiagnosticSeverity, } from './x/diagnostics.js';
7
- export function getProject() {
8
- return new RWProject();
1
+ "use strict";
2
+
3
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js/object/define-property");
4
+ _Object$defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ _Object$defineProperty(exports, "DiagnosticSeverity", {
8
+ enumerable: true,
9
+ get: function () {
10
+ return _diagnostics.DiagnosticSeverity;
11
+ }
12
+ });
13
+ _Object$defineProperty(exports, "RWProject", {
14
+ enumerable: true,
15
+ get: function () {
16
+ return _model.RWProject;
17
+ }
18
+ });
19
+ _Object$defineProperty(exports, "RWRoute", {
20
+ enumerable: true,
21
+ get: function () {
22
+ return _model.RWRoute;
23
+ }
24
+ });
25
+ _Object$defineProperty(exports, "URL_file", {
26
+ enumerable: true,
27
+ get: function () {
28
+ return _URL.URL_file;
29
+ }
30
+ });
31
+ exports.getProject = getProject;
32
+ exports.printDiagnostics = printDiagnostics;
33
+ var _diagnostics = require("./x/diagnostics");
34
+ var _model = require("./model");
35
+ var _URL = require("./x/URL");
36
+ function getProject(projectRoot) {
37
+ return new _model.RWProject({
38
+ projectRoot
39
+ });
9
40
  }
10
- export async function printDiagnostics(opts) {
11
- const base = getPaths().base;
12
- const project = getProject();
13
- const formatOpts = { cwd: base, ...opts };
14
- try {
15
- let warnings = 0;
16
- let errors = 0;
17
- for (const d of await project.collectDiagnostics()) {
18
- const str = ExtendedDiagnostic_format(d, formatOpts);
19
- console.log(`\n${str}`);
20
- // counts number of warnings and errors encountered
21
- if (d.diagnostic.severity === DiagnosticSeverity.Warning) {
22
- warnings++;
23
- }
24
- if (d.diagnostic.severity === DiagnosticSeverity.Error) {
25
- errors++;
26
- }
27
- }
28
- if (warnings === 0 && errors === 0) {
29
- console.log('\nSuccess: no errors or warnings were detected\n');
30
- }
31
- else if (errors > 0) {
32
- console.error(`\nFailure: ${errors} errors and ${warnings} warnings detected\n`);
33
- process.exit(1);
34
- }
41
+ async function printDiagnostics(projectRoot, opts) {
42
+ const project = getProject(projectRoot);
43
+ const formatOpts = {
44
+ cwd: projectRoot,
45
+ ...opts
46
+ };
47
+ try {
48
+ let warnings = 0;
49
+ let errors = 0;
50
+ for (const d of await project.collectDiagnostics()) {
51
+ const str = (0, _diagnostics.ExtendedDiagnostic_format)(d, formatOpts);
52
+ console.log(`\n${str}`);
53
+ // counts number of warnings and errors encountered
54
+ if (d.diagnostic.severity === _diagnostics.DiagnosticSeverity.Warning) {
55
+ warnings++;
56
+ }
57
+ if (d.diagnostic.severity === _diagnostics.DiagnosticSeverity.Error) {
58
+ errors++;
59
+ }
35
60
  }
36
- catch (e) {
37
- if (e instanceof Error) {
38
- throw e;
39
- }
40
- throw new Error(String(e));
61
+ if (warnings === 0 && errors === 0) {
62
+ console.log('\nSuccess: no errors or warnings were detected\n');
63
+ } else if (errors > 0) {
64
+ console.error(`\nFailure: ${errors} errors and ${warnings} warnings detected\n`);
65
+ process.exit(1);
41
66
  }
42
- }
43
- //# sourceMappingURL=index.js.map
67
+ } catch (e) {
68
+ throw new Error(e.message);
69
+ }
70
+ }
@@ -1,6 +1,6 @@
1
1
  import * as tsm from 'ts-morph';
2
- import { DiagnosticSeverity } from '../x/diagnostics.js';
3
- import { RWComponent } from './RWComponent.js';
2
+ import { DiagnosticSeverity } from '../x/diagnostics';
3
+ import { RWComponent } from './RWComponent';
4
4
  export declare class RWCell extends RWComponent {
5
5
  /**
6
6
  * A "Cell" is a component that ends in `Cell.{js, jsx, tsx}`, has no
@@ -11,10 +11,10 @@ export declare class RWCell extends RWComponent {
11
11
  get queryString(): string | undefined;
12
12
  get queryAst(): import("graphql").DocumentNode | undefined;
13
13
  get queryOperationName(): string | undefined;
14
- diagnostics(): Generator<import("../x/diagnostics.js").ExtendedDiagnostic | {
14
+ diagnostics(): Generator<import("../x/diagnostics").ExtendedDiagnostic | {
15
15
  uri: string;
16
16
  diagnostic: {
17
- range: import("../x/Range.js").Range;
17
+ range: import("../x/Range").Range;
18
18
  message: any;
19
19
  severity: DiagnosticSeverity;
20
20
  };
@@ -1 +1 @@
1
- {"version":3,"file":"RWCell.d.ts","sourceRoot":"","sources":["../../src/model/RWCell.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAI/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAExD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,qBAAa,MAAO,SAAQ,WAAW;IACrC;;;QAGI;IACJ,IAAY,MAAM,YAEjB;IAGD,IAAY,eAAe,kDAa1B;IAGD,IAAY,WAAW,IAAI,MAAM,GAAG,SAAS,CAE5C;IAGD,IAAY,QAAQ,+CAanB;IAGD,IAAY,kBAAkB,IAAI,MAAM,GAAG,SAAS,CAWnD;IAEA,WAAW;;;;;;;;CAyCb"}
1
+ {"version":3,"file":"RWCell.d.ts","sourceRoot":"","sources":["../../src/model/RWCell.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAI/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAErD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C,qBAAa,MAAO,SAAQ,WAAW;IACrC;;;QAGI;IACJ,IAAY,MAAM,YAEjB;IAGD,IAAY,eAAe,kDAa1B;IAGD,IAAY,WAAW,IAAI,MAAM,GAAG,SAAS,CAE5C;IAGD,IAAY,QAAQ,+CAanB;IAGD,IAAY,kBAAkB,IAAI,MAAM,GAAG,SAAS,CAWnD;IAEA,WAAW;;;;;;;;CAyCb"}
@@ -1,118 +1,110 @@
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 { Kind, parse as parseGraphQL } from 'graphql';
8
- import * as tsm from 'ts-morph';
9
- import { lazy } from '../x/decorators.js';
10
- import { err, Range_fromNode } from '../x/diagnostics.js';
11
- import { DiagnosticSeverity } from '../x/diagnostics.js';
12
- import { RWComponent } from './RWComponent.js';
13
- export class RWCell extends RWComponent {
14
- /**
15
- * A "Cell" is a component that ends in `Cell.{js, jsx, tsx}`, has no
16
- * default export AND exports `QUERY`
17
- **/
18
- get isCell() {
19
- return !this.hasDefaultExport && this.exportedSymbols.has('QUERY');
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.RWCell = void 0;
10
+ var _getOwnPropertyDescriptor = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/object/get-own-property-descriptor"));
11
+ var _applyDecoratedDescriptor2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/applyDecoratedDescriptor"));
12
+ var _graphql = require("graphql");
13
+ var tsm = _interopRequireWildcard(require("ts-morph"));
14
+ var _decorators = require("../x/decorators");
15
+ var _diagnostics = require("../x/diagnostics");
16
+ var _RWComponent = require("./RWComponent");
17
+ var _dec, _dec2, _dec3, _dec4, _dec5, _class;
18
+ let RWCell = exports.RWCell = (_dec = (0, _decorators.lazy)(), _dec2 = (0, _decorators.lazy)(), _dec3 = (0, _decorators.lazy)(), _dec4 = (0, _decorators.lazy)(), _dec5 = (0, _decorators.lazy)(), _class = class RWCell extends _RWComponent.RWComponent {
19
+ /**
20
+ * A "Cell" is a component that ends in `Cell.{js, jsx, tsx}`, has no
21
+ * default export AND exports `QUERY`
22
+ **/
23
+ get isCell() {
24
+ return !this.hasDefaultExport && this.exportedSymbols.has('QUERY');
25
+ }
26
+
27
+ // TODO: Move to RWCellQuery
28
+ get queryStringNode() {
29
+ const i = this.sf.getVariableDeclaration('QUERY')?.getInitializer();
30
+ if (!i) {
31
+ return undefined;
20
32
  }
21
- // TODO: Move to RWCellQuery
22
- get queryStringNode() {
23
- const i = this.sf.getVariableDeclaration('QUERY')?.getInitializer();
24
- if (!i) {
25
- return undefined;
26
- }
27
- // TODO: do we allow other kinds of strings? or just tagged literals?
28
- if (tsm.Node.isTaggedTemplateExpression(i)) {
29
- const t = i.getTemplate();
30
- if (tsm.Node.isNoSubstitutionTemplateLiteral(t)) {
31
- return t;
32
- }
33
- }
34
- return undefined;
33
+ // TODO: do we allow other kinds of strings? or just tagged literals?
34
+ if (tsm.Node.isTaggedTemplateExpression(i)) {
35
+ const t = i.getTemplate();
36
+ if (tsm.Node.isNoSubstitutionTemplateLiteral(t)) {
37
+ return t;
38
+ }
35
39
  }
36
- // TODO: Move to RWCellQuery
37
- get queryString() {
38
- return this.queryStringNode?.getLiteralText();
40
+ return undefined;
41
+ }
42
+
43
+ // TODO: Move to RWCellQuery
44
+ get queryString() {
45
+ return this.queryStringNode?.getLiteralText();
46
+ }
47
+
48
+ // TODO: Move to RWCellQuery
49
+ get queryAst() {
50
+ const qs = this.queryString;
51
+ if (!qs) {
52
+ return undefined;
39
53
  }
40
- // TODO: Move to RWCellQuery
41
- get queryAst() {
42
- const qs = this.queryString;
43
- if (!qs) {
44
- return undefined;
45
- }
46
- try {
47
- return parseGraphQL(qs);
48
- }
49
- catch (e) {
50
- console.error("Can't parse the graphql query string in", this.filePath);
51
- console.error(e);
52
- return undefined;
53
- }
54
+ try {
55
+ return (0, _graphql.parse)(qs);
56
+ } catch (e) {
57
+ console.error("Can't parse the graphql query string in", this.filePath);
58
+ console.error(e);
59
+ return undefined;
54
60
  }
55
- // TODO: Move to RWCellQuery
56
- get queryOperationName() {
57
- const ast = this.queryAst;
58
- if (!ast) {
59
- return undefined;
60
- }
61
- for (const def of ast.definitions) {
62
- if (def.kind == Kind.OPERATION_DEFINITION) {
63
- return def?.name?.value;
64
- }
65
- }
66
- return undefined;
61
+ }
62
+
63
+ // TODO: Move to RWCellQuery
64
+ get queryOperationName() {
65
+ const ast = this.queryAst;
66
+ if (!ast) {
67
+ return undefined;
67
68
  }
68
- *diagnostics() {
69
- // check that QUERY and Success are exported
70
- if (!this.exportedSymbols.has('QUERY')) {
71
- yield err(this.uri, 'Every Cell MUST export a QUERY variable (GraphQL query string)');
72
- }
73
- try {
74
- if (!this.queryOperationName) {
75
- yield {
76
- uri: this.uri,
77
- diagnostic: {
78
- range: Range_fromNode(this.queryStringNode),
79
- message: 'We recommend that you name your query operation',
80
- severity: DiagnosticSeverity.Warning,
81
- },
82
- };
83
- }
84
- }
85
- catch (e) {
86
- // Maybe the AST has a syntax error...
87
- yield {
88
- uri: this.uri,
89
- diagnostic: {
90
- // TODO: Try to figure out if we can point directly to the syntax error.
91
- range: Range_fromNode(this.sf.getVariableDeclaration('QUERY')),
92
- message: e.message,
93
- severity: DiagnosticSeverity.Error,
94
- },
95
- };
96
- }
97
- // TODO: check that exported QUERY is semantically valid GraphQL (fields exist)
98
- if (!this.exportedSymbols.has('Success')) {
99
- yield err(this.uri, 'Every Cell MUST export a Success variable (React Component)');
69
+ for (const def of ast.definitions) {
70
+ if (def.kind == _graphql.Kind.OPERATION_DEFINITION) {
71
+ return def?.name?.value;
72
+ }
73
+ }
74
+ return undefined;
75
+ }
76
+ *diagnostics() {
77
+ // check that QUERY and Success are exported
78
+ if (!this.exportedSymbols.has('QUERY')) {
79
+ yield (0, _diagnostics.err)(this.uri, 'Every Cell MUST export a QUERY variable (GraphQL query string)');
80
+ }
81
+ try {
82
+ if (!this.queryOperationName) {
83
+ yield {
84
+ uri: this.uri,
85
+ diagnostic: {
86
+ range: (0, _diagnostics.Range_fromNode)(this.queryStringNode),
87
+ message: 'We recommend that you name your query operation',
88
+ severity: _diagnostics.DiagnosticSeverity.Warning
89
+ }
90
+ };
91
+ }
92
+ } catch (e) {
93
+ // Maybe the AST has a syntax error...
94
+ yield {
95
+ uri: this.uri,
96
+ diagnostic: {
97
+ // TODO: Try to figure out if we can point directly to the syntax error.
98
+ range: (0, _diagnostics.Range_fromNode)(this.sf.getVariableDeclaration('QUERY')),
99
+ message: e.message,
100
+ severity: _diagnostics.DiagnosticSeverity.Error
100
101
  }
102
+ };
103
+ }
104
+
105
+ // TODO: check that exported QUERY is semantically valid GraphQL (fields exist)
106
+ if (!this.exportedSymbols.has('Success')) {
107
+ yield (0, _diagnostics.err)(this.uri, 'Every Cell MUST export a Success variable (React Component)');
101
108
  }
102
- }
103
- __decorate([
104
- lazy()
105
- ], RWCell.prototype, "isCell", null);
106
- __decorate([
107
- lazy()
108
- ], RWCell.prototype, "queryStringNode", null);
109
- __decorate([
110
- lazy()
111
- ], RWCell.prototype, "queryString", null);
112
- __decorate([
113
- lazy()
114
- ], RWCell.prototype, "queryAst", null);
115
- __decorate([
116
- lazy()
117
- ], RWCell.prototype, "queryOperationName", null);
118
- //# sourceMappingURL=RWCell.js.map
109
+ }
110
+ }, (0, _applyDecoratedDescriptor2.default)(_class.prototype, "isCell", [_dec], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "isCell"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "queryStringNode", [_dec2], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "queryStringNode"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "queryString", [_dec3], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "queryString"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "queryAst", [_dec4], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "queryAst"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "queryOperationName", [_dec5], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "queryOperationName"), _class.prototype), _class);
@@ -1,5 +1,5 @@
1
- import { FileNode } from '../nodes.js';
2
- import type { RWProject } from './RWProject.js';
1
+ import { FileNode } from '../nodes';
2
+ import type { RWProject } from './RWProject';
3
3
  export declare class RWComponent extends FileNode {
4
4
  filePath: string;
5
5
  parent: RWProject;
@@ -1 +1 @@
1
- {"version":3,"file":"RWComponent.d.ts","sourceRoot":"","sources":["../../src/model/RWComponent.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAGtC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE/C,qBAAa,WAAY,SAAQ,QAAQ;IAE9B,QAAQ,EAAE,MAAM;IAChB,MAAM,EAAE,SAAS;gBADjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,SAAS;IAK1B,IAAY,gBAAgB,IAAI,OAAO,CAKtC;IAED,IAAY,OAAO,YAIlB;IAED,IAAY,eAAe,gBAW1B;CACF"}
1
+ {"version":3,"file":"RWComponent.d.ts","sourceRoot":"","sources":["../../src/model/RWComponent.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAGnC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAE5C,qBAAa,WAAY,SAAQ,QAAQ;IAE9B,QAAQ,EAAE,MAAM;IAChB,MAAM,EAAE,SAAS;gBADjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,SAAS;IAK1B,IAAY,gBAAgB,IAAI,OAAO,CAKtC;IAED,IAAY,OAAO,YAIlB;IAED,IAAY,eAAe,gBAW1B;CACF"}
@@ -1,47 +1,42 @@
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 { lazy } from '../x/decorators.js';
10
- export class RWComponent extends FileNode {
11
- filePath;
12
- parent;
13
- constructor(filePath, parent) {
14
- super();
15
- this.filePath = filePath;
16
- this.parent = parent;
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.RWComponent = void 0;
10
+ var _set = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/set"));
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 _decorators = require("../x/decorators");
16
+ var _dec, _dec2, _dec3, _class;
17
+ let RWComponent = exports.RWComponent = (_dec = (0, _decorators.lazy)(), _dec2 = (0, _decorators.lazy)(), _dec3 = (0, _decorators.lazy)(), _class = class RWComponent extends _nodes.FileNode {
18
+ constructor(filePath, parent) {
19
+ super();
20
+ this.filePath = filePath;
21
+ this.parent = parent;
22
+ }
23
+ get hasDefaultExport() {
24
+ // TODO: Is this enough to test a default export?
25
+ return this.sf.getDescendantsOfKind(tsm.SyntaxKind.ExportAssignment).length > 0;
26
+ }
27
+ get stories() {
28
+ // TODO: this is a placeholder
29
+ // we could list all the (storybook) stories related to this component here
30
+ return [];
31
+ }
32
+ get exportedSymbols() {
33
+ // KLUDGE!
34
+ const ss = new _set.default();
35
+ for (const d of this.sf.getDescendantsOfKind(tsm.SyntaxKind.VariableDeclaration)) {
36
+ if (d.isExported()) {
37
+ ss.add(d.getName());
38
+ }
17
39
  }
18
- get hasDefaultExport() {
19
- // TODO: Is this enough to test a default export?
20
- return (this.sf.getDescendantsOfKind(tsm.SyntaxKind.ExportAssignment).length > 0);
21
- }
22
- get stories() {
23
- // TODO: this is a placeholder
24
- // we could list all the (storybook) stories related to this component here
25
- return [];
26
- }
27
- get exportedSymbols() {
28
- // KLUDGE!
29
- const ss = new Set();
30
- for (const d of this.sf.getDescendantsOfKind(tsm.SyntaxKind.VariableDeclaration)) {
31
- if (d.isExported()) {
32
- ss.add(d.getName());
33
- }
34
- }
35
- return ss;
36
- }
37
- }
38
- __decorate([
39
- lazy()
40
- ], RWComponent.prototype, "hasDefaultExport", null);
41
- __decorate([
42
- lazy()
43
- ], RWComponent.prototype, "stories", null);
44
- __decorate([
45
- lazy()
46
- ], RWComponent.prototype, "exportedSymbols", null);
47
- //# sourceMappingURL=RWComponent.js.map
40
+ return ss;
41
+ }
42
+ }, (0, _applyDecoratedDescriptor2.default)(_class.prototype, "hasDefaultExport", [_dec], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "hasDefaultExport"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "stories", [_dec2], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "stories"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "exportedSymbols", [_dec3], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "exportedSymbols"), _class.prototype), _class);
@@ -1,8 +1,8 @@
1
1
  import type * as tsm from 'ts-morph';
2
- import { BaseNode } from '../nodes.js';
3
- import type { ExtendedDiagnostic } from '../x/diagnostics.js';
4
- import type { Location } from '../x/Location.js';
5
- import type { RWProject } from './RWProject.js';
2
+ import { BaseNode } from '../nodes';
3
+ import type { ExtendedDiagnostic } from '../x/diagnostics';
4
+ import type { Location } from '../x/Location';
5
+ import type { RWProject } from './RWProject';
6
6
  type EnvVarMap = Record<string, string>;
7
7
  export declare class RWEnvHelper extends BaseNode {
8
8
  parent: RWProject;
@@ -1 +1 @@
1
- {"version":3,"file":"RWEnvHelper.d.ts","sourceRoot":"","sources":["../../src/model/RWEnvHelper.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,GAAG,MAAM,UAAU,CAAA;AAIpC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAM7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAGhD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAG/C,KAAK,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAEvC,qBAAa,WAAY,SAAQ,QAAQ;IACpB,MAAM,EAAE,SAAS;gBAAjB,MAAM,EAAE,SAAS;IAIpC,IAAY,EAAE,WAGb;IAED,mBAAmB;IAMnB;;;;OAIG;IACH,IAAY,GAAG,IAAI,SAAS,GAAG,SAAS,CAEvC;IAED;;;OAGG;IACH,IAAY,YAAY,IAAI,SAAS,GAAG,SAAS,CAEhD;IAED,IAAY,cAAc,mDAEzB;IAED;;;OAGG;IACH,IAAY,kBAAkB,IAAI,SAAS,CAE1C;IAED;;;;;OAKG;IACH,OAAO,CAAC,2BAA2B;IAOnC,OAAO,CAAC,OAAO;IAQf,IAAY,oBAAoB,cAM/B;IAED,IAAY,oBAAoB,cAI/B;IAEK,QAAQ;IAIR,uBAAuB;CAe9B;AAED;;GAEG;AACH,cAAM,uBAAwB,SAAQ,QAAQ;IAEnC,MAAM,EAAE,WAAW;IACnB,IAAI,EAAE,KAAK,GAAG,KAAK,GAAG,QAAQ;IAC9B,GAAG,EAAE,MAAM;IACX,IAAI,EAAE,GAAG,CAAC,IAAI,GAAG,QAAQ;gBAHzB,MAAM,EAAE,WAAW,EACnB,IAAI,EAAE,KAAK,GAAG,KAAK,GAAG,QAAQ,EAC9B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,GAAG,CAAC,IAAI,GAAG,QAAQ;IAKlC,mBAAmB,CAAC,GAAG,EAAE,MAAM;IAO/B,IAAY,EAAE,WAIb;IAED,IAAY,IAAI,kBAEf;IAED,IAAY,QAAQ,aAEnB;IAEA,WAAW;IAwCZ,IAAY,8BAA8B,yCAYzC;IAED,IAAY,kBAAkB,WAM7B;CACF"}
1
+ {"version":3,"file":"RWEnvHelper.d.ts","sourceRoot":"","sources":["../../src/model/RWEnvHelper.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,GAAG,MAAM,UAAU,CAAA;AAIpC,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAEnC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAM1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAG7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAG5C,KAAK,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAEvC,qBAAa,WAAY,SAAQ,QAAQ;IACpB,MAAM,EAAE,SAAS;gBAAjB,MAAM,EAAE,SAAS;IAIpC,IAAY,EAAE,WAGb;IAED,mBAAmB;IAMnB;;;;OAIG;IACH,IAAY,GAAG,IAAI,SAAS,GAAG,SAAS,CAEvC;IAED;;;OAGG;IACH,IAAY,YAAY,IAAI,SAAS,GAAG,SAAS,CAEhD;IAED,IAAY,cAAc,mDAEzB;IAED;;;OAGG;IACH,IAAY,kBAAkB,IAAI,SAAS,CAE1C;IAED;;;;;OAKG;IACH,OAAO,CAAC,2BAA2B;IAOnC,OAAO,CAAC,OAAO;IAQf,IAAY,oBAAoB,cAM/B;IAED,IAAY,oBAAoB,cAI/B;IAEK,QAAQ;IAIR,uBAAuB;CAe9B;AAED;;GAEG;AACH,cAAM,uBAAwB,SAAQ,QAAQ;IAEnC,MAAM,EAAE,WAAW;IACnB,IAAI,EAAE,KAAK,GAAG,KAAK,GAAG,QAAQ;IAC9B,GAAG,EAAE,MAAM;IACX,IAAI,EAAE,GAAG,CAAC,IAAI,GAAG,QAAQ;gBAHzB,MAAM,EAAE,WAAW,EACnB,IAAI,EAAE,KAAK,GAAG,KAAK,GAAG,QAAQ,EAC9B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,GAAG,CAAC,IAAI,GAAG,QAAQ;IAKlC,mBAAmB,CAAC,GAAG,EAAE,MAAM;IAO/B,IAAY,EAAE,WAIb;IAED,IAAY,IAAI,kBAEf;IAED,IAAY,QAAQ,aAEnB;IAEA,WAAW;IAwCZ,IAAY,8BAA8B,yCAYzC;IAED,IAAY,kBAAkB,WAM7B;CACF"}