@cedarjs/structure 0.0.4

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 (138) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +145 -0
  3. package/dist/errors.d.ts +11 -0
  4. package/dist/errors.d.ts.map +1 -0
  5. package/dist/errors.js +19 -0
  6. package/dist/hosts.d.ts +23 -0
  7. package/dist/hosts.d.ts.map +1 -0
  8. package/dist/hosts.js +45 -0
  9. package/dist/ide.d.ts +122 -0
  10. package/dist/ide.d.ts.map +1 -0
  11. package/dist/ide.js +240 -0
  12. package/dist/index.d.ts +12 -0
  13. package/dist/index.d.ts.map +1 -0
  14. package/dist/index.js +79 -0
  15. package/dist/interactive_cli/RedwoodCommandString.d.ts +20 -0
  16. package/dist/interactive_cli/RedwoodCommandString.d.ts.map +1 -0
  17. package/dist/interactive_cli/RedwoodCommandString.js +72 -0
  18. package/dist/interactive_cli/command_builder.d.ts +10 -0
  19. package/dist/interactive_cli/command_builder.d.ts.map +1 -0
  20. package/dist/interactive_cli/command_builder.js +196 -0
  21. package/dist/interactive_cli/dry_run.d.ts +28 -0
  22. package/dist/interactive_cli/dry_run.d.ts.map +1 -0
  23. package/dist/interactive_cli/dry_run.js +101 -0
  24. package/dist/interactive_cli/ui.d.ts +32 -0
  25. package/dist/interactive_cli/ui.d.ts.map +1 -0
  26. package/dist/interactive_cli/ui.js +84 -0
  27. package/dist/language_server/RWLanguageServer.d.ts +30 -0
  28. package/dist/language_server/RWLanguageServer.d.ts.map +1 -0
  29. package/dist/language_server/RWLanguageServer.js +201 -0
  30. package/dist/language_server/commands.d.ts +14 -0
  31. package/dist/language_server/commands.d.ts.map +1 -0
  32. package/dist/language_server/commands.js +122 -0
  33. package/dist/language_server/diagnostics.d.ts +10 -0
  34. package/dist/language_server/diagnostics.d.ts.map +1 -0
  35. package/dist/language_server/diagnostics.js +61 -0
  36. package/dist/language_server/outline.d.ts +7 -0
  37. package/dist/language_server/outline.d.ts.map +1 -0
  38. package/dist/language_server/outline.js +37 -0
  39. package/dist/language_server/start.d.ts +2 -0
  40. package/dist/language_server/start.d.ts.map +1 -0
  41. package/dist/language_server/start.js +4 -0
  42. package/dist/language_server/xmethods.d.ts +11 -0
  43. package/dist/language_server/xmethods.d.ts.map +1 -0
  44. package/dist/language_server/xmethods.js +42 -0
  45. package/dist/model/RWCell.d.ts +22 -0
  46. package/dist/model/RWCell.d.ts.map +1 -0
  47. package/dist/model/RWCell.js +111 -0
  48. package/dist/model/RWComponent.d.ts +11 -0
  49. package/dist/model/RWComponent.d.ts.map +1 -0
  50. package/dist/model/RWComponent.js +42 -0
  51. package/dist/model/RWEnvHelper.d.ts +64 -0
  52. package/dist/model/RWEnvHelper.d.ts.map +1 -0
  53. package/dist/model/RWEnvHelper.js +295 -0
  54. package/dist/model/RWFunction.d.ts +11 -0
  55. package/dist/model/RWFunction.d.ts.map +1 -0
  56. package/dist/model/RWFunction.js +19 -0
  57. package/dist/model/RWLayout.d.ts +11 -0
  58. package/dist/model/RWLayout.d.ts.map +1 -0
  59. package/dist/model/RWLayout.js +19 -0
  60. package/dist/model/RWPage.d.ts +13 -0
  61. package/dist/model/RWPage.d.ts.map +1 -0
  62. package/dist/model/RWPage.js +60 -0
  63. package/dist/model/RWProject.d.ts +61 -0
  64. package/dist/model/RWProject.d.ts.map +1 -0
  65. package/dist/model/RWProject.js +170 -0
  66. package/dist/model/RWRoute.d.ts +58 -0
  67. package/dist/model/RWRoute.d.ts.map +1 -0
  68. package/dist/model/RWRoute.js +416 -0
  69. package/dist/model/RWRouter.d.ts +30 -0
  70. package/dist/model/RWRouter.d.ts.map +1 -0
  71. package/dist/model/RWRouter.js +186 -0
  72. package/dist/model/RWSDL.d.ts +21 -0
  73. package/dist/model/RWSDL.d.ts.map +1 -0
  74. package/dist/model/RWSDL.js +89 -0
  75. package/dist/model/RWSDLField.d.ts +31 -0
  76. package/dist/model/RWSDLField.d.ts.map +1 -0
  77. package/dist/model/RWSDLField.js +132 -0
  78. package/dist/model/RWService.d.ts +26 -0
  79. package/dist/model/RWService.d.ts.map +1 -0
  80. package/dist/model/RWService.js +76 -0
  81. package/dist/model/RWServiceFunction.d.ts +20 -0
  82. package/dist/model/RWServiceFunction.d.ts.map +1 -0
  83. package/dist/model/RWServiceFunction.js +100 -0
  84. package/dist/model/RWTOML.d.ts +12 -0
  85. package/dist/model/RWTOML.d.ts.map +1 -0
  86. package/dist/model/RWTOML.js +56 -0
  87. package/dist/model/index.d.ts +2 -0
  88. package/dist/model/index.d.ts.map +1 -0
  89. package/dist/model/index.js +13 -0
  90. package/dist/model/util/advanced_path_parser.d.ts +12 -0
  91. package/dist/model/util/advanced_path_parser.d.ts.map +1 -0
  92. package/dist/model/util/advanced_path_parser.js +38 -0
  93. package/dist/model/util/process_env.d.ts +23 -0
  94. package/dist/model/util/process_env.d.ts.map +1 -0
  95. package/dist/model/util/process_env.js +76 -0
  96. package/dist/outline/index.d.ts +3 -0
  97. package/dist/outline/index.d.ts.map +1 -0
  98. package/dist/outline/index.js +31 -0
  99. package/dist/outline/outline.d.ts +4 -0
  100. package/dist/outline/outline.d.ts.map +1 -0
  101. package/dist/outline/outline.js +260 -0
  102. package/dist/outline/types.d.ts +88 -0
  103. package/dist/outline/types.d.ts.map +1 -0
  104. package/dist/outline/types.js +73 -0
  105. package/dist/util.d.ts +2 -0
  106. package/dist/util.d.ts.map +1 -0
  107. package/dist/util.js +34 -0
  108. package/dist/x/Array.d.ts +4 -0
  109. package/dist/x/Array.d.ts.map +1 -0
  110. package/dist/x/Array.js +26 -0
  111. package/dist/x/URL.d.ts +15 -0
  112. package/dist/x/URL.d.ts.map +1 -0
  113. package/dist/x/URL.js +99 -0
  114. package/dist/x/child_process.d.ts +15 -0
  115. package/dist/x/child_process.d.ts.map +1 -0
  116. package/dist/x/child_process.js +51 -0
  117. package/dist/x/decorators.d.ts +3 -0
  118. package/dist/x/decorators.d.ts.map +1 -0
  119. package/dist/x/decorators.js +26 -0
  120. package/dist/x/path.d.ts +6 -0
  121. package/dist/x/path.d.ts.map +1 -0
  122. package/dist/x/path.js +53 -0
  123. package/dist/x/prisma.d.ts +19 -0
  124. package/dist/x/prisma.d.ts.map +1 -0
  125. package/dist/x/prisma.js +65 -0
  126. package/dist/x/ts-morph.d.ts +10 -0
  127. package/dist/x/ts-morph.d.ts.map +1 -0
  128. package/dist/x/ts-morph.js +56 -0
  129. package/dist/x/vscode-languageserver-types.d.ts +93 -0
  130. package/dist/x/vscode-languageserver-types.d.ts.map +1 -0
  131. package/dist/x/vscode-languageserver-types.js +421 -0
  132. package/dist/x/vscode-languageserver.d.ts +12 -0
  133. package/dist/x/vscode-languageserver.d.ts.map +1 -0
  134. package/dist/x/vscode-languageserver.js +61 -0
  135. package/dist/x/vscode.d.ts +126 -0
  136. package/dist/x/vscode.d.ts.map +1 -0
  137. package/dist/x/vscode.js +294 -0
  138. package/package.json +67 -0
@@ -0,0 +1,60 @@
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.RWPage = void 0;
10
+ var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/find"));
11
+ var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/map"));
12
+ var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/includes"));
13
+ var _map2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/map"));
14
+ var _getOwnPropertyDescriptor = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/object/get-own-property-descriptor"));
15
+ var _applyDecoratedDescriptor2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/applyDecoratedDescriptor"));
16
+ var _path = require("path");
17
+ var tsm = _interopRequireWildcard(require("ts-morph"));
18
+ var _ide = require("../ide");
19
+ var _decorators = require("../x/decorators");
20
+ var _dec, _dec2, _dec3, _dec4, _class;
21
+ let RWPage = exports.RWPage = (_dec = (0, _decorators.lazy)(), _dec2 = (0, _decorators.lazy)(), _dec3 = (0, _decorators.lazy)(), _dec4 = (0, _decorators.lazy)(), _class = class RWPage extends _ide.FileNode {
22
+ constructor(constName, path, parent) {
23
+ super();
24
+ this.constName = constName;
25
+ this.path = path;
26
+ this.parent = parent;
27
+ }
28
+ get filePath() {
29
+ return this.path;
30
+ }
31
+ get route() {
32
+ var _context;
33
+ return (0, _find.default)(_context = this.parent.router.routes).call(_context, r => r.page_identifier_str === this.constName);
34
+ }
35
+ get layoutName() {
36
+ var _context2;
37
+ const candidates = (0, _map.default)(_context2 = this.parent.layouts).call(_context2, l => l.basenameNoExt);
38
+ if (candidates.length === 0) {
39
+ return undefined;
40
+ }
41
+ for (const tag of this.sf.getDescendantsOfKind(tsm.SyntaxKind.JsxOpeningElement)) {
42
+ const t = tag.getTagNameNode().getText(); //?
43
+ if ((0, _includes.default)(candidates).call(candidates, t)) {
44
+ return t;
45
+ }
46
+ }
47
+ return undefined;
48
+ }
49
+ get actionRemove() {
50
+ const edits = new _map2.default();
51
+ // delete directory (MyPage/...)
52
+ edits.set((0, _path.dirname)(this.filePath), undefined);
53
+ // removing a page also removes its route
54
+ if (this.route) {
55
+ edits.set(this.route.jsxNode, undefined);
56
+ }
57
+ // TODO: we need to transform this edits map to a standard edits map (with locations)
58
+ return edits;
59
+ }
60
+ }, (0, _applyDecoratedDescriptor2.default)(_class.prototype, "filePath", [_dec], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "filePath"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "route", [_dec2], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "route"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "layoutName", [_dec3], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "layoutName"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "actionRemove", [_dec4], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "actionRemove"), _class.prototype), _class);
@@ -0,0 +1,61 @@
1
+ import type { DMMF } from '@prisma/generator-helper';
2
+ import type { Host } from '../hosts';
3
+ import { BaseNode } from '../ide';
4
+ import { RWCell } from './RWCell';
5
+ import { RWComponent } from './RWComponent';
6
+ import { RWEnvHelper } from './RWEnvHelper';
7
+ import { RWFunction } from './RWFunction';
8
+ import { RWLayout } from './RWLayout';
9
+ import { RWPage } from './RWPage';
10
+ import { RWRouter } from './RWRouter';
11
+ import { RWSDL } from './RWSDL';
12
+ import { RWService } from './RWService';
13
+ import { RWTOML } from './RWTOML';
14
+ export interface RWProjectOptions {
15
+ projectRoot: string;
16
+ host: Host;
17
+ }
18
+ /**
19
+ * Represents a Redwood project.
20
+ * This is the root node.
21
+ */
22
+ export declare class RWProject extends BaseNode {
23
+ opts: RWProjectOptions;
24
+ constructor(opts: RWProjectOptions);
25
+ parent: undefined;
26
+ get host(): Host;
27
+ get projectRoot(): string;
28
+ get id(): string;
29
+ children(): (RWComponent | RWTOML | RWPage | RWRouter | RWService | RWSDL | RWLayout | RWEnvHelper)[];
30
+ /**
31
+ * Path constants that are relevant to a Redwood project.
32
+ */
33
+ get pathHelper(): import("@cedarjs/project-config").Paths;
34
+ /**
35
+ * Checks for the presence of a tsconfig.json at the root.
36
+ */
37
+ get isTypeScriptProject(): boolean;
38
+ prismaDMMF(): Promise<DMMF.Document | undefined>;
39
+ prismaDMMFModelNames(): Promise<string[]>;
40
+ get redwoodTOML(): RWTOML;
41
+ private get processPagesDir();
42
+ get pages(): RWPage[];
43
+ get router(): RWRouter;
44
+ getRouter: () => RWRouter;
45
+ servicesFilePath(name: string): string;
46
+ get defaultNotFoundPageFilePath(): string;
47
+ get services(): RWService[];
48
+ get sdls(): RWSDL[];
49
+ get layouts(): RWLayout[];
50
+ get functions(): RWFunction[];
51
+ get components(): RWComponent[];
52
+ get sides(): string[];
53
+ get mocks(): string[];
54
+ /**
55
+ * A "Cell" is a component that ends in `Cell.{js, jsx, tsx}`, but does not
56
+ * have a default export AND does not export `QUERY`
57
+ **/
58
+ get cells(): RWCell[];
59
+ get envHelper(): RWEnvHelper;
60
+ }
61
+ //# sourceMappingURL=RWProject.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RWProject.d.ts","sourceRoot":"","sources":["../../src/model/RWProject.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AAKpD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AASjC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEjC,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,IAAI,CAAA;CACX;AAID;;;GAGG;AACH,qBAAa,SAAU,SAAQ,QAAQ;IAClB,IAAI,EAAE,gBAAgB;gBAAtB,IAAI,EAAE,gBAAgB;IAGzC,MAAM,YAAY;IAElB,IAAI,IAAI,SAEP;IAED,IAAI,WAAW,WAEd;IAED,IAAY,EAAE,WAEb;IAED,QAAQ;IAaR;;OAEG;IACH,IAAY,UAAU,4CAErB;IACD;;OAEG;IACH,IAAY,mBAAmB,IAAI,OAAO,CAKzC;IAEa,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;IAShD,oBAAoB;IAOlC,IAAY,WAAW,IAAI,MAAM,CAEhC;IACO,OAAO,KAAK,eAAe,GAMlC;IACD,IAAY,KAAK,IAAI,MAAM,EAAE,CAI5B;IACD,IAAY,MAAM,aAEjB;IACD,SAAS,iBAER;IAGD,gBAAgB,CAAC,IAAI,EAAE,MAAM;IAO7B,IAAY,2BAA2B,WAGtC;IAED,IAAY,QAAQ,gBAOnB;IAED,IAAY,IAAI,YAIf;IAED,IAAY,OAAO,IAAI,QAAQ,EAAE,CAOhC;IAED,IAAY,SAAS,IAAI,UAAU,EAAE,CAKpC;IAED,IAAY,UAAU,IAAI,WAAW,EAAE,CAYtC;IAED,IAAY,KAAK,aAEhB;IAGD,IAAY,KAAK,aAEhB;IAED;;;QAGI;IACJ,IAAY,KAAK,IAAI,MAAM,EAAE,CAK5B;IAED,IAAY,SAAS,IAAI,WAAW,CAEnC;CACF"}
@@ -0,0 +1,170 @@
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.RWProject = void 0;
9
+ var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/map"));
10
+ var _filter = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/filter"));
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 _path = require("path");
14
+ var _internals = require("@prisma/internals");
15
+ var _projectConfig = require("@cedarjs/project-config");
16
+ var _ide = require("../ide");
17
+ var _decorators = require("../x/decorators");
18
+ var _path2 = require("../x/path");
19
+ var _URL = require("../x/URL");
20
+ var _RWCell = require("./RWCell");
21
+ var _RWComponent = require("./RWComponent");
22
+ var _RWEnvHelper = require("./RWEnvHelper");
23
+ var _RWFunction = require("./RWFunction");
24
+ var _RWLayout = require("./RWLayout");
25
+ var _RWPage = require("./RWPage");
26
+ var _RWRouter = require("./RWRouter");
27
+ var _RWSDL = require("./RWSDL");
28
+ var _RWService = require("./RWService");
29
+ var _RWTOML = require("./RWTOML");
30
+ var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _dec11, _dec12, _dec13, _dec14, _dec15, _dec16, _dec17, _dec18, _dec19, _class;
31
+ const allFilesGlob = '/**/*.{js,jsx,ts,tsx}';
32
+
33
+ /**
34
+ * Represents a Redwood project.
35
+ * This is the root node.
36
+ */
37
+ let RWProject = exports.RWProject = (_dec = (0, _decorators.lazy)(), _dec2 = (0, _decorators.lazy)(), _dec3 = (0, _decorators.lazy)(), _dec4 = (0, _decorators.memo)(), _dec5 = (0, _decorators.memo)(), _dec6 = (0, _decorators.lazy)(), _dec7 = (0, _decorators.lazy)(), _dec8 = (0, _decorators.lazy)(), _dec9 = (0, _decorators.lazy)(), _dec10 = (0, _decorators.lazy)(), _dec11 = (0, _decorators.lazy)(), _dec12 = (0, _decorators.lazy)(), _dec13 = (0, _decorators.lazy)(), _dec14 = (0, _decorators.lazy)(), _dec15 = (0, _decorators.lazy)(), _dec16 = (0, _decorators.lazy)(), _dec17 = (0, _decorators.lazy)(), _dec18 = (0, _decorators.lazy)(), _dec19 = (0, _decorators.lazy)(), _class = class RWProject extends _ide.BaseNode {
38
+ constructor(opts) {
39
+ super();
40
+ this.parent = undefined;
41
+ this.getRouter = () => {
42
+ return new _RWRouter.RWRouter(this.pathHelper.web.routes, this);
43
+ };
44
+ this.opts = opts;
45
+ }
46
+ get host() {
47
+ return this.opts.host;
48
+ }
49
+ get projectRoot() {
50
+ return this.opts.projectRoot;
51
+ }
52
+ get id() {
53
+ return (0, _URL.URL_file)(this.projectRoot);
54
+ }
55
+ children() {
56
+ return [this.redwoodTOML, ...this.pages, this.router, ...this.services, ...this.sdls, ...this.layouts, ...this.components, this.envHelper];
57
+ }
58
+
59
+ /**
60
+ * Path constants that are relevant to a Redwood project.
61
+ */
62
+ get pathHelper() {
63
+ return (0, _projectConfig.getPaths)(this.projectRoot);
64
+ }
65
+ /**
66
+ * Checks for the presence of a tsconfig.json at the root.
67
+ */
68
+ get isTypeScriptProject() {
69
+ return this.host.existsSync((0, _path.join)(this.pathHelper.web.base, 'tsconfig.json')) || this.host.existsSync((0, _path.join)(this.pathHelper.api.base, 'tsconfig.json'));
70
+ }
71
+ // TODO: do we move this to a separate node? (ex: RWDatabase)
72
+ async prismaDMMF() {
73
+ try {
74
+ const datamodel = await (0, _internals.getSchema)(this.pathHelper.api.dbSchema);
75
+ // consider case where dmmf doesn't exist (or fails to parse)
76
+ return await (0, _internals.getDMMF)({
77
+ datamodel
78
+ });
79
+ } catch {
80
+ return undefined;
81
+ }
82
+ }
83
+ async prismaDMMFModelNames() {
84
+ var _context;
85
+ const dmmf = await this.prismaDMMF();
86
+ if (!dmmf) {
87
+ return [];
88
+ }
89
+ return (0, _map.default)(_context = dmmf.datamodel.models).call(_context, m => m.name);
90
+ }
91
+ get redwoodTOML() {
92
+ return new _RWTOML.RWTOML((0, _path.join)(this.projectRoot, 'redwood.toml'), this);
93
+ }
94
+ get processPagesDir() {
95
+ try {
96
+ return (0, _projectConfig.processPagesDir)(this.pathHelper.web.pages);
97
+ } catch {
98
+ return [];
99
+ }
100
+ }
101
+ get pages() {
102
+ var _context2;
103
+ return (0, _map.default)(_context2 = this.processPagesDir).call(_context2, p => new _RWPage.RWPage(p.constName, p.path, this));
104
+ }
105
+ get router() {
106
+ return this.getRouter();
107
+ }
108
+ // TODO: move to path helper
109
+ servicesFilePath(name) {
110
+ // name = blog,posts
111
+ const ext = this.isTypeScriptProject ? '.ts' : '.js';
112
+ return (0, _path.join)(this.pathHelper.api.services, name, name + ext);
113
+ }
114
+
115
+ // TODO: move to path helper
116
+ get defaultNotFoundPageFilePath() {
117
+ const ext = this.isTypeScriptProject ? '.tsx' : '.jsx';
118
+ return (0, _path.join)(this.pathHelper.web.pages, 'NotFoundPage', 'NotFoundPage' + ext);
119
+ }
120
+ get services() {
121
+ var _context3, _context4;
122
+ // TODO: what is the official logic?
123
+ // TODO: Support both `/services/todos/todos.js` AND `/services/todos.js`
124
+ return (0, _map.default)(_context3 = (0, _filter.default)(_context4 = this.host.globSync(this.pathHelper.api.services + allFilesGlob)).call(_context4, _path2.followsDirNameConvention)).call(_context3, x => new _RWService.RWService(x, this));
125
+ }
126
+ get sdls() {
127
+ var _context5;
128
+ return (0, _map.default)(_context5 = this.host.globSync(this.pathHelper.api.graphql + '/**/*.sdl.{js,ts}')).call(_context5, x => new _RWSDL.RWSDL(x, this));
129
+ }
130
+ get layouts() {
131
+ var _context6, _context7, _context8;
132
+ // TODO: what is the official logic?
133
+ return (0, _map.default)(_context6 = (0, _filter.default)(_context7 = (0, _filter.default)(_context8 = this.host.globSync(this.pathHelper.web.layouts + allFilesGlob)).call(_context8, _path2.followsDirNameConvention)).call(_context7, _path2.isLayoutFileName)).call(_context6, x => new _RWLayout.RWLayout(x, this));
134
+ }
135
+ get functions() {
136
+ var _context9;
137
+ // TODO: what is the official logic?
138
+ return (0, _map.default)(_context9 = this.host.globSync(this.pathHelper.api.functions + allFilesGlob)).call(_context9, x => new _RWFunction.RWFunction(x, this));
139
+ }
140
+ get components() {
141
+ var _context10;
142
+ return (0, _map.default)(_context10 = this.host.globSync(this.pathHelper.web.components + allFilesGlob)).call(_context10, file => {
143
+ if ((0, _path2.isCellFileName)(file)) {
144
+ const possibleCell = new _RWCell.RWCell(file, this);
145
+ return possibleCell.isCell ? possibleCell : new _RWComponent.RWComponent(file, this);
146
+ }
147
+ return new _RWComponent.RWComponent(file, this);
148
+ });
149
+ }
150
+ get sides() {
151
+ return ['web', 'api'];
152
+ }
153
+
154
+ // TODO: Wrap these in a real model.
155
+ get mocks() {
156
+ return this.host.globSync(this.pathHelper.web.base + '/**/*.mock.{js,ts}');
157
+ }
158
+
159
+ /**
160
+ * A "Cell" is a component that ends in `Cell.{js, jsx, tsx}`, but does not
161
+ * have a default export AND does not export `QUERY`
162
+ **/
163
+ get cells() {
164
+ var _context11, _context12;
165
+ return (0, _filter.default)(_context11 = (0, _map.default)(_context12 = this.host.globSync(this.pathHelper.web.base + '/**/*Cell.{js,jsx,tsx}')).call(_context12, file => new _RWCell.RWCell(file, this))).call(_context11, file => file.isCell);
166
+ }
167
+ get envHelper() {
168
+ return new _RWEnvHelper.RWEnvHelper(this);
169
+ }
170
+ }, (0, _applyDecoratedDescriptor2.default)(_class.prototype, "id", [_dec], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "id"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "pathHelper", [_dec2], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "pathHelper"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "isTypeScriptProject", [_dec3], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "isTypeScriptProject"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "prismaDMMF", [_dec4], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "prismaDMMF"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "prismaDMMFModelNames", [_dec5], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "prismaDMMFModelNames"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "redwoodTOML", [_dec6], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "redwoodTOML"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "processPagesDir", [_dec7], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "processPagesDir"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "pages", [_dec8], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "pages"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "router", [_dec9], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "router"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "defaultNotFoundPageFilePath", [_dec10], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "defaultNotFoundPageFilePath"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "services", [_dec11], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "services"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "sdls", [_dec12], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "sdls"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "layouts", [_dec13], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "layouts"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "functions", [_dec14], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "functions"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "components", [_dec15], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "components"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "sides", [_dec16], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "sides"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "mocks", [_dec17], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "mocks"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "cells", [_dec18], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "cells"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "envHelper", [_dec19], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "envHelper"), _class.prototype), _class);
@@ -0,0 +1,58 @@
1
+ import * as tsm from 'ts-morph';
2
+ import type { Location } from 'vscode-languageserver-types';
3
+ import type { Decoration, Definition, DocumentLinkX, HoverX } from '../ide';
4
+ import { BaseNode } from '../ide';
5
+ import type { RWRouter } from './RWRouter';
6
+ export declare class RWRoute extends BaseNode {
7
+ /**
8
+ * the <Route> tag
9
+ */
10
+ jsxNode: tsm.JsxSelfClosingElement;
11
+ parent: RWRouter;
12
+ constructor(
13
+ /**
14
+ * the <Route> tag
15
+ */
16
+ jsxNode: tsm.JsxSelfClosingElement, parent: RWRouter);
17
+ get id(): string;
18
+ get location(): Location;
19
+ get isPrivate(): boolean;
20
+ get unauthenticated(): string | undefined;
21
+ get roles(): string | any[] | undefined;
22
+ get hasParameters(): boolean;
23
+ get hasPrerender(): boolean;
24
+ get outlineLabel(): string;
25
+ get outlineDescription(): string | undefined;
26
+ get outlineLink(): string;
27
+ /**
28
+ * The associated Redwood Page node, if any
29
+ */
30
+ get page(): import("./RWPage").RWPage | undefined;
31
+ /**
32
+ * <Route path="" page={THIS_IDENTIFIER}/>
33
+ */
34
+ private get page_identifier();
35
+ get page_identifier_str(): string | undefined;
36
+ get name(): string | undefined;
37
+ get path_errorMessage(): string | undefined;
38
+ get path(): string | undefined;
39
+ get prerender(): boolean;
40
+ get renderMode(): string | undefined;
41
+ get path_literal_node(): tsm.StringLiteral | undefined;
42
+ get isNotFound(): boolean;
43
+ get redirect(): string | undefined;
44
+ diagnostics(): Generator<import("../x/vscode-languageserver-types").ExtendedDiagnostic, void, unknown>;
45
+ ideInfo(): Generator<Definition | HoverX | Decoration | DocumentLinkX, void, any>;
46
+ private get hasPathCollision();
47
+ private getBoolAttr;
48
+ private getStringAttr;
49
+ get parsedPath(): {
50
+ punctuationIndexes: number[];
51
+ slashIndexes: number[];
52
+ paramRanges: [number, number][];
53
+ paramTypeRanges: [number, number][];
54
+ } | undefined;
55
+ private decorations;
56
+ get sampleLocalPreviewURL(): string | undefined;
57
+ }
58
+ //# sourceMappingURL=RWRoute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RWRoute.d.ts","sourceRoot":"","sources":["../../src/model/RWRoute.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAI3D,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC3E,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAajC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAG1C,qBAAa,OAAQ,SAAQ,QAAQ;IAEjC;;OAEG;IACI,OAAO,EAAE,GAAG,CAAC,qBAAqB;IAClC,MAAM,EAAE,QAAQ;;IAJvB;;OAEG;IACI,OAAO,EAAE,GAAG,CAAC,qBAAqB,EAClC,MAAM,EAAE,QAAQ;IAKzB,IAAY,EAAE,WAIb;IAED,IAAY,QAAQ,IAAI,QAAQ,CAE/B;IAED,IAAY,SAAS,YAOpB;IAED,IAAY,eAAe,uBAoB1B;IAED,IACI,KAAK,+BA0DR;IAED,IAAY,aAAa,IAAI,OAAO,CAMnC;IAED,IAAY,YAAY,YAEvB;IAED,IAAY,YAAY,IAAI,MAAM,CAKjC;IAED,IAAY,kBAAkB,IAAI,MAAM,GAAG,SAAS,CAMnD;IAED,IAAY,WAAW,IAAI,MAAM,CAGhC;IAED;;OAEG;IAEH,IAAY,IAAI,0CAOf;IACD;;OAEG;IACK,OAAO,KAAK,eAAe,GAelC;IACD,IAAY,mBAAmB,IAAI,MAAM,GAAG,SAAS,CAEpD;IACD,IAAY,IAAI,IAAI,MAAM,GAAG,SAAS,CAErC;IACD,IAAY,iBAAiB,IAAI,MAAM,GAAG,SAAS,CAWlD;IACD,IAAY,IAAI,IAAI,MAAM,GAAG,SAAS,CAErC;IAED,IAAY,SAAS,IAAI,OAAO,CAE/B;IAGD,IAAY,UAAU,IAAI,MAAM,GAAG,SAAS,CAE3C;IAED,IAAY,iBAAiB,kCAY5B;IAED,IAAY,UAAU,IAAI,OAAO,CAEhC;IAED,IAAY,QAAQ,uBAEnB;IAEA,WAAW;IA6BX,OAAO;IA4CA,OAAO,KAAK,gBAAgB,GAsBnC;IAED,OAAO,CAAC,WAAW;IAgCnB,OAAO,CAAC,aAAa;IAcrB,IAAY,UAAU;;;;;kBAKrB;IAED,OAAO,CAAE,WAAW;IAkCpB,IAAY,qBAAqB,IAAI,MAAM,GAAG,SAAS,CAStD;CACF"}