@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 @@
1
+ {"version":3,"file":"URL.d.ts","sourceRoot":"","sources":["../../src/x/URL.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAQrE;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,aAAa,EAAE,MAAM,EAAE,GAAG,aAAW,GAAG,MAAM,CAYxE"}
package/dist/x/URL.js ADDED
@@ -0,0 +1,99 @@
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.URL_file = URL_file;
9
+ exports.URL_toFile = URL_toFile;
10
+ var _startsWith = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/starts-with"));
11
+ var _url = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/url"));
12
+ var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/index-of"));
13
+ var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/includes"));
14
+ var _path = require("path");
15
+ /**
16
+ * Creates a file:// URL
17
+ * Works with linux and windows paths
18
+ * If the passed in value is already as file:// URL, it returns that same value
19
+ * TODO: rename to URL_fromFile
20
+ * @param filePath
21
+ */
22
+ function URL_file(filePath, ...parts) {
23
+ if ((0, _startsWith.default)(filePath).call(filePath, FILE_SCHEME)) {
24
+ filePath = filePath.substr(FILE_SCHEME.length);
25
+ }
26
+ if (parts.length > 0) {
27
+ filePath = (0, _path.join)(filePath, ...parts);
28
+ }
29
+ return new _url.default(FILE_SCHEME + (0, _path.normalize)(filePath)).href;
30
+ }
31
+
32
+ /**
33
+ *
34
+ * @param uriOrFilePath
35
+ * @param sep separator string, defaults to `require('path').sep`
36
+ */
37
+ function URL_toFile(uriOrFilePath, sep = _path.sep) {
38
+ if (typeof uriOrFilePath !== 'string') {
39
+ throw new Error('arg error');
40
+ }
41
+ if ((0, _startsWith.default)(uriOrFilePath).call(uriOrFilePath, FILE_SCHEME)) {
42
+ return fileUriToPath(uriOrFilePath, sep);
43
+ }
44
+ const p = (0, _path.normalize)(uriOrFilePath);
45
+ if (!(0, _path.isAbsolute)(p)) {
46
+ throw new Error('absolute path expected: ' + p);
47
+ }
48
+ return p;
49
+ }
50
+ const FILE_SCHEME = 'file://';
51
+
52
+ /**
53
+ * based on https://github.com/TooTallNate/file-uri-to-path/blob/master/src/index.ts
54
+ * main changes:
55
+ * - modified to work with VSCode Language Server URIs (they encode colons: "file:///c%3A/a/b.c" )
56
+ * - you can pass "sep", the system separator, (for tests)
57
+ *
58
+ * @param uri
59
+ * @param sep
60
+ */
61
+ function fileUriToPath(uri, sep = _path.sep) {
62
+ var _context;
63
+ if (typeof uri !== 'string' || uri.length <= 7 || !(0, _startsWith.default)(uri).call(uri, FILE_SCHEME)) {
64
+ throw new TypeError('must pass in a file:// URI to convert to a file path');
65
+ }
66
+ const rest = decodeURIComponent(uri.substring(7));
67
+ const firstSlash = (0, _indexOf.default)(rest).call(rest, '/');
68
+ let host = rest.substring(0, firstSlash);
69
+ let path = rest.substring(firstSlash + 1);
70
+
71
+ // 2. Scheme Definition
72
+ // As a special case, <host> can be the string "localhost" or the empty
73
+ // string; this is interpreted as "the machine from which the URL is
74
+ // being interpreted".
75
+ if (host === 'localhost') {
76
+ host = '';
77
+ }
78
+ if (host) {
79
+ host = sep + sep + host;
80
+ }
81
+
82
+ // 3.2 Drives, drive letters, mount points, file system root
83
+ // Drive letters are mapped into the top of a file URI in various ways,
84
+ // depending on the implementation; some applications substitute
85
+ // vertical bar ("|") for the colon after the drive letter, yielding
86
+ // "file:///c|/tmp/test.txt". In some cases, the colon is left
87
+ // unchanged, as in "file:///c:/tmp/test.txt". In other cases, the
88
+ // colon is simply omitted, as in "file:///c/tmp/test.txt".
89
+ path = path.replace(/^(.+)\|/, '$1:');
90
+ const parts = path.split('/');
91
+
92
+ // if the first segment is NOT a windows drive
93
+ // we insert an extra empty segment
94
+ // this will result in an initial slash (unix style)
95
+ if (!(0, _includes.default)(_context = parts[0]).call(_context, ':')) {
96
+ parts.unshift('');
97
+ }
98
+ return parts.join(sep);
99
+ }
@@ -0,0 +1,15 @@
1
+ import * as child_process from 'child_process';
2
+ export type SpawnOut = {
3
+ stderr: string;
4
+ stdout: string;
5
+ code: number | null;
6
+ };
7
+ export declare function spawnCancellable(cmd: string, args: string[], opts?: child_process.SpawnOptions & {
8
+ stdout_cb?: (x: any) => void;
9
+ stderr_cb?: (x: any) => void;
10
+ }): CancellablePromise<SpawnOut>;
11
+ export type CancellablePromise<T> = Promise<T> & {
12
+ cancel: () => void;
13
+ };
14
+ export declare function CancellablePromise_then<T, U>(p: CancellablePromise<T>, f: (t: T) => U): CancellablePromise<T>;
15
+ //# sourceMappingURL=child_process.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"child_process.d.ts","sourceRoot":"","sources":["../../src/x/child_process.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,eAAe,CAAA;AAE9C,MAAM,MAAM,QAAQ,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAA;AAE9E,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EAAE,EACd,IAAI,CAAC,EAAE,aAAa,CAAC,YAAY,GAAG;IAClC,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,IAAI,CAAA;IAC5B,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,IAAI,CAAA;CAC7B,GACA,kBAAkB,CAAC,QAAQ,CAAC,CA6B9B;AAED,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG;IAAE,MAAM,EAAE,MAAM,IAAI,CAAA;CAAE,CAAA;AAEvE,wBAAgB,uBAAuB,CAAC,CAAC,EAAE,CAAC,EAC1C,CAAC,EAAE,kBAAkB,CAAC,CAAC,CAAC,EACxB,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,GACb,kBAAkB,CAAC,CAAC,CAAC,CAIvB"}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js/object/define-property");
4
+ var _interopRequireWildcard = require("@babel/runtime-corejs3/helpers/interopRequireWildcard").default;
5
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
6
+ _Object$defineProperty(exports, "__esModule", {
7
+ value: true
8
+ });
9
+ exports.CancellablePromise_then = CancellablePromise_then;
10
+ exports.spawnCancellable = spawnCancellable;
11
+ var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/promise"));
12
+ var child_process = _interopRequireWildcard(require("child_process"));
13
+ function spawnCancellable(cmd, args, opts) {
14
+ let cp;
15
+ const promise = new _promise.default((resolve, reject) => {
16
+ cp = child_process.spawn(cmd, args, opts);
17
+ let stderr = '',
18
+ stdout = '';
19
+ cp.stdout.on('data', data => {
20
+ stdout += data;
21
+ opts?.stdout_cb?.(data);
22
+ });
23
+ cp.stderr.on('data', data => {
24
+ stderr += data;
25
+ opts?.stderr_cb?.(data);
26
+ });
27
+ cp.on('close', code => {
28
+ resolve({
29
+ stdout,
30
+ stderr,
31
+ code
32
+ });
33
+ });
34
+ cp.on('error', err => {
35
+ reject(err);
36
+ });
37
+ });
38
+ promise.cancel = () => {
39
+ try {
40
+ cp.kill();
41
+ } catch {
42
+ // intentionally left empty
43
+ }
44
+ };
45
+ return promise;
46
+ }
47
+ function CancellablePromise_then(p, f) {
48
+ const p2 = p.then(f);
49
+ p2.cancel = p.cancel;
50
+ return p2;
51
+ }
@@ -0,0 +1,3 @@
1
+ export { LazyGetter as lazy } from 'lazy-get-decorator';
2
+ export { Debounce as debounce, Memoize as memo } from 'lodash-decorators';
3
+ //# sourceMappingURL=decorators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../src/x/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,IAAI,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,EAAE,QAAQ,IAAI,QAAQ,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,mBAAmB,CAAA"}
@@ -0,0 +1,26 @@
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, "debounce", {
8
+ enumerable: true,
9
+ get: function () {
10
+ return _lodashDecorators.Debounce;
11
+ }
12
+ });
13
+ _Object$defineProperty(exports, "lazy", {
14
+ enumerable: true,
15
+ get: function () {
16
+ return _lazyGetDecorator.LazyGetter;
17
+ }
18
+ });
19
+ _Object$defineProperty(exports, "memo", {
20
+ enumerable: true,
21
+ get: function () {
22
+ return _lodashDecorators.Memoize;
23
+ }
24
+ });
25
+ var _lazyGetDecorator = require("lazy-get-decorator");
26
+ var _lodashDecorators = require("lodash-decorators");
@@ -0,0 +1,6 @@
1
+ export declare function directoryNameResolver(dirName: string): string | undefined;
2
+ export declare function followsDirNameConvention(filePath: string): boolean;
3
+ export declare function basenameNoExt(path: string): string;
4
+ export declare function isLayoutFileName(f: string): boolean;
5
+ export declare function isCellFileName(f: string): boolean;
6
+ //# sourceMappingURL=path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../src/x/path.ts"],"names":[],"mappings":"AAGA,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAazE;AAED,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAIlE;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAOlD;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAGnD;AAED,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAGjD"}
package/dist/x/path.js ADDED
@@ -0,0 +1,53 @@
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.basenameNoExt = basenameNoExt;
9
+ exports.directoryNameResolver = directoryNameResolver;
10
+ exports.followsDirNameConvention = followsDirNameConvention;
11
+ exports.isCellFileName = isCellFileName;
12
+ exports.isLayoutFileName = isLayoutFileName;
13
+ var _endsWith = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/ends-with"));
14
+ require("core-js/modules/es.array.push.js");
15
+ var _fs = require("fs");
16
+ var _path = require("path");
17
+ function directoryNameResolver(dirName) {
18
+ dirName = (0, _path.normalize)(dirName);
19
+ const parts = dirName.split(_path.sep);
20
+ const pp = parts[parts.length - 1];
21
+ parts.push(pp);
22
+ const extensions = ['.js', '.jsx', '.ts', '.tsx'];
23
+ const pathNoExt = parts.join(_path.sep);
24
+ for (const ext of extensions) {
25
+ const path = pathNoExt + ext;
26
+ if ((0, _fs.existsSync)(path)) {
27
+ return path;
28
+ }
29
+ }
30
+ }
31
+ function followsDirNameConvention(filePath) {
32
+ filePath = (0, _path.normalize)(filePath);
33
+ const ending = basenameNoExt(filePath) + _path.sep + (0, _path.basename)(filePath);
34
+ return (0, _endsWith.default)(filePath).call(filePath, ending);
35
+ }
36
+ function basenameNoExt(path) {
37
+ path = (0, _path.normalize)(path);
38
+ const parts = (0, _path.basename)(path).split('.');
39
+ if (parts.length > 1) {
40
+ parts.pop();
41
+ }
42
+ return parts.join('.');
43
+ }
44
+ function isLayoutFileName(f) {
45
+ var _context;
46
+ f = (0, _path.normalize)(f);
47
+ return (0, _endsWith.default)(_context = basenameNoExt(f)).call(_context, 'Layout');
48
+ }
49
+ function isCellFileName(f) {
50
+ var _context2;
51
+ f = (0, _path.normalize)(f);
52
+ return (0, _endsWith.default)(_context2 = basenameNoExt(f)).call(_context2, 'Cell');
53
+ }
@@ -0,0 +1,19 @@
1
+ import type { Location } from 'vscode-languageserver';
2
+ import { Range } from 'vscode-languageserver';
3
+ /**
4
+ * find "env()" expressions in a prisma file using regex
5
+ * @param prismaSchemaFilePath
6
+ */
7
+ export declare function prisma_parseEnvExpressionsInFile(prismaSchemaFilePath: string): Generator<{
8
+ location: Location;
9
+ key: any;
10
+ }, never[] | undefined, unknown>;
11
+ /**
12
+ * find "env()" expressions in a prisma file using regex
13
+ * @param src
14
+ */
15
+ export declare function prisma_parseEnvExpressions(src: string): Generator<{
16
+ range: Range;
17
+ key: any;
18
+ }, void, unknown>;
19
+ //# sourceMappingURL=prisma.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prisma.d.ts","sourceRoot":"","sources":["../../src/x/prisma.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAK7C;;;GAGG;AACH,wBAAiB,gCAAgC,CAC/C,oBAAoB,EAAE,MAAM;;;iCAa7B;AAED;;;GAGG;AACH,wBAAiB,0BAA0B,CAAC,GAAG,EAAE,MAAM;;;kBActD"}
@@ -0,0 +1,65 @@
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.prisma_parseEnvExpressions = prisma_parseEnvExpressions;
9
+ exports.prisma_parseEnvExpressionsInFile = prisma_parseEnvExpressionsInFile;
10
+ require("core-js/modules/esnext.json.parse.js");
11
+ var _matchAll = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/match-all"));
12
+ var _fsExtra = require("fs-extra");
13
+ var _vscodeLanguageserver = require("vscode-languageserver");
14
+ var _URL = require("./URL");
15
+ var _vscodeLanguageserverTypes = require("./vscode-languageserver-types");
16
+ /**
17
+ * find "env()" expressions in a prisma file using regex
18
+ * @param prismaSchemaFilePath
19
+ */
20
+ function* prisma_parseEnvExpressionsInFile(prismaSchemaFilePath) {
21
+ const uri = (0, _URL.URL_file)(prismaSchemaFilePath);
22
+ const file = (0, _URL.URL_toFile)(uri); // convert back and forth in case someone passed a uri
23
+ if (!(0, _fsExtra.existsSync)(file)) {
24
+ return [];
25
+ } // fail silently
26
+ const src = (0, _fsExtra.readFileSync)(file).toString();
27
+ const exprs = prisma_parseEnvExpressions(src);
28
+ for (const {
29
+ range,
30
+ key
31
+ } of exprs) {
32
+ const location = {
33
+ uri,
34
+ range
35
+ };
36
+ yield {
37
+ location,
38
+ key
39
+ };
40
+ }
41
+ }
42
+
43
+ /**
44
+ * find "env()" expressions in a prisma file using regex
45
+ * @param src
46
+ */
47
+ function* prisma_parseEnvExpressions(src) {
48
+ const re = /env\(([^)]+)\)/gm;
49
+ for (const match of (0, _matchAll.default)(_context = src).call(_context, re)) {
50
+ var _context;
51
+ try {
52
+ const start = (0, _vscodeLanguageserverTypes.Position_fromOffsetOrFail)(match.index, src);
53
+ const end = (0, _vscodeLanguageserverTypes.Position_fromOffsetOrFail)(match.index + match[0].length, src);
54
+ const range = _vscodeLanguageserver.Range.create(start, end);
55
+ const key = JSON.parse(match[1]);
56
+ yield {
57
+ range,
58
+ key
59
+ };
60
+ } catch {
61
+ // we don't care about malformed env() calls
62
+ // that should be picked up by the prisma parser
63
+ }
64
+ }
65
+ }
@@ -0,0 +1,10 @@
1
+ import * as tsm from 'ts-morph';
2
+ export declare function createTSMSourceFile(filePath: string, src: string): tsm.SourceFile;
3
+ export declare function createTSMSourceFile(src: string): tsm.SourceFile;
4
+ /**
5
+ * warning: do NOT modify this file. treat it as immutable
6
+ * @param filePath
7
+ * @param text
8
+ */
9
+ export declare function createTSMSourceFile_cached(filePath: string, text: string): tsm.SourceFile;
10
+ //# sourceMappingURL=ts-morph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ts-morph.d.ts","sourceRoot":"","sources":["../../src/x/ts-morph.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAE/B,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,GACV,GAAG,CAAC,UAAU,CAAA;AACjB,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC,UAAU,CAAA;AA4BhE;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,GACX,GAAG,CAAC,UAAU,CAWhB"}
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+
3
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js/object/define-property");
4
+ var _interopRequireWildcard = require("@babel/runtime-corejs3/helpers/interopRequireWildcard").default;
5
+ _Object$defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.createTSMSourceFile = createTSMSourceFile;
9
+ exports.createTSMSourceFile_cached = createTSMSourceFile_cached;
10
+ var crypto = _interopRequireWildcard(require("crypto"));
11
+ var _lodash = require("lodash");
12
+ var _lruCache = require("lru-cache");
13
+ var tsm = _interopRequireWildcard(require("ts-morph"));
14
+ /**
15
+ * Creates a cheap in-memory ts-morph source file
16
+ * @param a1
17
+ * @param a2
18
+ */
19
+ function createTSMSourceFile(a1, a2) {
20
+ let [filePath, src] = [a1, a2];
21
+ if (!a2) {
22
+ src = filePath;
23
+ filePath = '/file.tsx';
24
+ }
25
+ return new tsm.Project({
26
+ useInMemoryFileSystem: true,
27
+ skipLoadingLibFiles: true,
28
+ compilerOptions: {
29
+ skipLibCheck: true,
30
+ noLib: true,
31
+ skipDefaultLibCheck: true,
32
+ noResolve: true
33
+ }
34
+ }).createSourceFile(filePath, src);
35
+ }
36
+ const getCache = (0, _lodash.memoize)(() => new _lruCache.LRUCache({
37
+ max: 200
38
+ }));
39
+
40
+ /**
41
+ * warning: do NOT modify this file. treat it as immutable
42
+ * @param filePath
43
+ * @param text
44
+ */
45
+ function createTSMSourceFile_cached(filePath, text) {
46
+ const key = filePath + '\n' + text;
47
+ const cache = getCache();
48
+ const key2 = crypto.createHash('sha1').update(key).digest('base64');
49
+ if (cache.has(key2)) {
50
+ return cache.get(key2);
51
+ } else {
52
+ const sf = createTSMSourceFile(filePath, text);
53
+ cache.set(key2, sf);
54
+ return sf;
55
+ }
56
+ }
@@ -0,0 +1,93 @@
1
+ import * as tsm from 'ts-morph';
2
+ import type { TextDocuments } from 'vscode-languageserver';
3
+ import type { TextDocument } from 'vscode-languageserver-textdocument';
4
+ import type { CodeAction, CodeActionContext, DocumentUri, WorkspaceEdit } from 'vscode-languageserver-types';
5
+ import { Diagnostic, DiagnosticSeverity, Location, Position, Range } from 'vscode-languageserver-types';
6
+ export declare function Range_contains(range: Range, pos: Position): boolean;
7
+ export declare function Range_overlaps(range1: Range, range2: Range, consider0000: boolean): boolean;
8
+ /**
9
+ * p1 is greater|smaller|equal than/to p2
10
+ * @param p1
11
+ * @param p2
12
+ */
13
+ export declare function Position_compare(p1: Position, p2: Position): 'greater' | 'smaller' | 'equal';
14
+ /**
15
+ * Create a new position relative to this position.
16
+ *
17
+ * @param lineDelta Delta value for the line value, default is `0`.
18
+ * @param characterDelta Delta value for the character value, default is `0`.
19
+ * @return A position which line and character is the sum of the current line and
20
+ * character and the corresponding deltas.
21
+ */
22
+ export declare function Position_translate(pos: Position, lineDelta?: number, characterDelta?: number): Position;
23
+ export declare function Range_fromNode(node: tsm.Node): Range;
24
+ export declare function Location_fromNode(node: tsm.Node): Location;
25
+ export declare function Location_fromFilePath(filePath: string): Location;
26
+ /**
27
+ * returns vscode-terminal-friendly (clickable) link with line/column information
28
+ * ex: "file:///foo.ts:2:3"
29
+ * @param loc
30
+ */
31
+ export declare function LocationLike_toTerminalLink(loc: LocationLike): string;
32
+ /**
33
+ * returns vscode-terminal-friendly (clickable) link with line/column information
34
+ * ex: "file:///foo.ts:2:3"
35
+ * @param loc
36
+ */
37
+ export declare function LocationLike_toHashLink(loc: LocationLike): string;
38
+ export type LocationLike = tsm.Node | string | Location | ExtendedDiagnostic;
39
+ export declare function LocationLike_toLocation(x: LocationLike): Location;
40
+ export declare function Location_overlaps(loc1: Location, loc2: Location, consider0000?: boolean): boolean;
41
+ export declare function ExtendedDiagnostic_is(x: any): x is ExtendedDiagnostic;
42
+ export declare function ExtendedDiagnostic_groupByUri(ds: ExtendedDiagnostic[]): {
43
+ [uri: string]: Diagnostic[];
44
+ };
45
+ export declare function ExtendedDiagnostic_findRelevantQuickFixes(xd: ExtendedDiagnostic, context: CodeActionContext): Promise<CodeAction[]>;
46
+ export declare function Position_fromTSMorphOffset(offset: number, sf: tsm.SourceFile): Position;
47
+ export declare function Position_fromOffset(offset: number, text: string): Position | undefined;
48
+ export declare function Position_fromOffsetOrFail(offset: number, text: string): Position;
49
+ /**
50
+ * The Diagnostic interface defined in vscode-languageserver-types
51
+ * does not include the document URI.
52
+ * This interface adds that, and a few other things.
53
+ */
54
+ export interface ExtendedDiagnostic {
55
+ uri: DocumentUri;
56
+ diagnostic: Diagnostic;
57
+ /**
58
+ * A function that returns a quickfix associated to this diagnostic.
59
+ */
60
+ quickFix?: () => Promise<CodeAction | undefined>;
61
+ }
62
+ /**
63
+ * Helper method to create diagnostics
64
+ * @param node
65
+ * @param message
66
+ */
67
+ export declare function err(loc: LocationLike, message: string, code?: number | string): ExtendedDiagnostic;
68
+ export declare function Diagnostic_compare(d1: Diagnostic, d2: Diagnostic): boolean;
69
+ export declare function Range_equals(r1: Range, r2: Range): boolean;
70
+ declare function DiagnosticSeverity_getLabel(severity?: DiagnosticSeverity): string;
71
+ export type GetSeverityLabelFunction = typeof DiagnosticSeverity_getLabel;
72
+ interface ExtendedDiagnosticFormatOpts {
73
+ cwd?: string;
74
+ getSeverityLabel?: GetSeverityLabelFunction;
75
+ }
76
+ /**
77
+ * Returns a string representation of a diagnostic.
78
+ * TSC style single-line errors:
79
+ * ex: "b.ts:1:2: error: this is a message"
80
+ * ex: "/path/to/app/b.ts:1:2: info: this is a message"
81
+ */
82
+ export declare function ExtendedDiagnostic_format(d: ExtendedDiagnostic, opts?: ExtendedDiagnosticFormatOpts): string;
83
+ /**
84
+ * a value of "null" means this file needs to be deleted
85
+ */
86
+ export type FileSet = {
87
+ [fileURI: string]: string | null;
88
+ };
89
+ export declare function FileSet_fromTextDocuments(documents: TextDocuments<TextDocument>): FileSet;
90
+ export declare function WorkspaceEdit_fromFileSet(files: FileSet, getExistingFileText?: (fileURI: string) => string | undefined): WorkspaceEdit;
91
+ export declare function Range_full(text: string, cr?: string): Range;
92
+ export {};
93
+ //# sourceMappingURL=vscode-languageserver-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vscode-languageserver-types.d.ts","sourceRoot":"","sources":["../../src/x/vscode-languageserver-types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAA;AACtE,OAAO,KAAK,EACV,UAAU,EACV,iBAAiB,EACjB,WAAW,EACX,aAAa,EACd,MAAM,6BAA6B,CAAA;AACpC,OAAO,EACL,UAAU,EACV,kBAAkB,EAClB,QAAQ,EACR,QAAQ,EACR,KAAK,EAEN,MAAM,6BAA6B,CAAA;AAIpC,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,GAAG,OAAO,CAQnE;AAED,wBAAgB,cAAc,CAC5B,MAAM,EAAE,KAAK,EACb,MAAM,EAAE,KAAK,EACb,YAAY,EAAE,OAAO,GACpB,OAAO,CAcT;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,EAAE,EAAE,QAAQ,EACZ,EAAE,EAAE,QAAQ,GACX,SAAS,GAAG,SAAS,GAAG,OAAO,CAcjC;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,QAAQ,EACb,SAAS,SAAI,EACb,cAAc,SAAI,GACjB,QAAQ,CAKV;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,GAAG,KAAK,CAOpD;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,GAAG,QAAQ,CAK1D;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,G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