@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/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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
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
|
|
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(): 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
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
67
|
+
} catch (e) {
|
|
68
|
+
throw new Error(e.message);
|
|
69
|
+
}
|
|
70
|
+
}
|
package/dist/model/RWCell.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as tsm from 'ts-morph';
|
|
2
|
-
import { DiagnosticSeverity } from '../x/diagnostics
|
|
3
|
-
import { RWComponent } from './RWComponent
|
|
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
|
|
14
|
+
diagnostics(): Generator<import("../x/diagnostics").ExtendedDiagnostic | {
|
|
15
15
|
uri: string;
|
|
16
16
|
diagnostic: {
|
|
17
|
-
range: import("../x/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,
|
|
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"}
|
package/dist/model/RWCell.js
CHANGED
|
@@ -1,118 +1,110 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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
|
-
|
|
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
|
|
2
|
-
import type { RWProject } from './RWProject
|
|
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,
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
|
3
|
-
import type { ExtendedDiagnostic } from '../x/diagnostics
|
|
4
|
-
import type { Location } from '../x/Location
|
|
5
|
-
import type { RWProject } from './RWProject
|
|
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,
|
|
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"}
|