@cedarjs/internal 0.6.1-next.0 → 0.7.0

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 (127) hide show
  1. package/dist/ast.d.ts.map +1 -1
  2. package/dist/ast.js +28 -64
  3. package/dist/build/api.js +22 -56
  4. package/dist/cjs/ast.d.ts +26 -0
  5. package/dist/cjs/ast.d.ts.map +1 -0
  6. package/dist/cjs/ast.js +201 -0
  7. package/dist/cjs/build/api.d.ts +6 -0
  8. package/dist/cjs/build/api.d.ts.map +1 -0
  9. package/dist/cjs/build/api.js +109 -0
  10. package/dist/cjs/cliLogger.d.ts +11 -0
  11. package/dist/cjs/cliLogger.d.ts.map +1 -0
  12. package/dist/cjs/cliLogger.js +36 -0
  13. package/dist/cjs/dev.d.ts +2 -0
  14. package/dist/cjs/dev.d.ts.map +1 -0
  15. package/dist/cjs/dev.js +41 -0
  16. package/dist/cjs/files.d.ts +56 -0
  17. package/dist/cjs/files.d.ts.map +1 -0
  18. package/dist/cjs/files.js +230 -0
  19. package/dist/cjs/generate/clientPreset.d.ts +17 -0
  20. package/dist/cjs/generate/clientPreset.d.ts.map +1 -0
  21. package/dist/cjs/generate/clientPreset.js +85 -0
  22. package/dist/cjs/generate/generate.d.ts +10 -0
  23. package/dist/cjs/generate/generate.d.ts.map +1 -0
  24. package/dist/cjs/generate/generate.js +91 -0
  25. package/dist/cjs/generate/graphqlCodeGen.d.ts +16 -0
  26. package/dist/cjs/generate/graphqlCodeGen.d.ts.map +1 -0
  27. package/dist/cjs/generate/graphqlCodeGen.js +346 -0
  28. package/dist/cjs/generate/graphqlSchema.d.ts +8 -0
  29. package/dist/cjs/generate/graphqlSchema.d.ts.map +1 -0
  30. package/dist/cjs/generate/graphqlSchema.js +154 -0
  31. package/dist/cjs/generate/plugins/rw-typescript-resolvers/index.d.ts +7 -0
  32. package/dist/cjs/generate/plugins/rw-typescript-resolvers/index.d.ts.map +1 -0
  33. package/dist/cjs/generate/plugins/rw-typescript-resolvers/index.js +65 -0
  34. package/dist/cjs/generate/plugins/rw-typescript-resolvers/visitor.d.ts +9 -0
  35. package/dist/cjs/generate/plugins/rw-typescript-resolvers/visitor.d.ts.map +1 -0
  36. package/dist/cjs/generate/plugins/rw-typescript-resolvers/visitor.js +84 -0
  37. package/dist/cjs/generate/possibleTypes.d.ts +36 -0
  38. package/dist/cjs/generate/possibleTypes.d.ts.map +1 -0
  39. package/dist/cjs/generate/possibleTypes.js +106 -0
  40. package/dist/cjs/generate/templates/all-currentUser.d.ts.template +30 -0
  41. package/dist/cjs/generate/templates/api-globImports.d.ts.template +9 -0
  42. package/dist/cjs/generate/templates/api-globalContext.d.ts.template +7 -0
  43. package/dist/cjs/generate/templates/api-scenarios.d.ts.template +10 -0
  44. package/dist/cjs/generate/templates/api-test-globals.d.ts.template +5 -0
  45. package/dist/cjs/generate/templates/mirror-cell.d.ts.template +13 -0
  46. package/dist/cjs/generate/templates/mirror-directoryNamedModule.d.ts.template +5 -0
  47. package/dist/cjs/generate/templates/web-routerRoutes.d.ts.template +20 -0
  48. package/dist/cjs/generate/templates/web-routesPages.d.ts.template +13 -0
  49. package/dist/cjs/generate/templates/web-test-globals.d.ts.template +7 -0
  50. package/dist/cjs/generate/templates.d.ts +6 -0
  51. package/dist/cjs/generate/templates.d.ts.map +1 -0
  52. package/dist/cjs/generate/templates.js +68 -0
  53. package/dist/cjs/generate/trustedDocuments.d.ts +3 -0
  54. package/dist/cjs/generate/trustedDocuments.d.ts.map +1 -0
  55. package/dist/cjs/generate/trustedDocuments.js +95 -0
  56. package/dist/cjs/generate/typeDefinitions.d.ts +30 -0
  57. package/dist/cjs/generate/typeDefinitions.d.ts.map +1 -0
  58. package/dist/cjs/generate/typeDefinitions.js +369 -0
  59. package/dist/cjs/generate/types.d.ts +6 -0
  60. package/dist/cjs/generate/types.d.ts.map +1 -0
  61. package/dist/cjs/generate/types.js +16 -0
  62. package/dist/cjs/generate/watch.d.ts +3 -0
  63. package/dist/cjs/generate/watch.d.ts.map +1 -0
  64. package/dist/cjs/generate/watch.js +124 -0
  65. package/dist/cjs/gql.d.ts +14 -0
  66. package/dist/cjs/gql.d.ts.map +1 -0
  67. package/dist/cjs/gql.js +108 -0
  68. package/dist/cjs/index.d.ts +11 -0
  69. package/dist/cjs/index.d.ts.map +1 -0
  70. package/dist/cjs/index.js +49 -0
  71. package/dist/cjs/jsx.d.ts +16 -0
  72. package/dist/cjs/jsx.d.ts.map +1 -0
  73. package/dist/cjs/jsx.js +101 -0
  74. package/dist/cjs/jsxAttributeValue.d.ts +2 -0
  75. package/dist/cjs/jsxAttributeValue.d.ts.map +1 -0
  76. package/dist/cjs/jsxAttributeValue.js +129 -0
  77. package/dist/cjs/package.json +1 -0
  78. package/dist/cjs/project.d.ts +8 -0
  79. package/dist/cjs/project.d.ts.map +1 -0
  80. package/dist/cjs/project.js +82 -0
  81. package/dist/cjs/routes.d.ts +42 -0
  82. package/dist/cjs/routes.d.ts.map +1 -0
  83. package/dist/cjs/routes.js +111 -0
  84. package/dist/cjs/ts2js.d.ts +40 -0
  85. package/dist/cjs/ts2js.d.ts.map +1 -0
  86. package/dist/cjs/ts2js.js +159 -0
  87. package/dist/cjs/validateSchema.d.ts +14 -0
  88. package/dist/cjs/validateSchema.d.ts.map +1 -0
  89. package/dist/cjs/validateSchema.js +194 -0
  90. package/dist/cliLogger.js +4 -28
  91. package/dist/dev.js +4 -38
  92. package/dist/files.d.ts.map +1 -1
  93. package/dist/files.js +46 -95
  94. package/dist/generate/clientPreset.js +17 -39
  95. package/dist/generate/generate.js +14 -39
  96. package/dist/generate/graphqlCodeGen.d.ts.map +1 -1
  97. package/dist/generate/graphqlCodeGen.js +49 -79
  98. package/dist/generate/graphqlSchema.d.ts.map +1 -1
  99. package/dist/generate/graphqlSchema.js +26 -59
  100. package/dist/generate/plugins/rw-typescript-resolvers/index.d.ts +4 -3
  101. package/dist/generate/plugins/rw-typescript-resolvers/index.d.ts.map +1 -1
  102. package/dist/generate/plugins/rw-typescript-resolvers/index.js +11 -35
  103. package/dist/generate/plugins/rw-typescript-resolvers/visitor.js +10 -31
  104. package/dist/generate/possibleTypes.js +19 -53
  105. package/dist/generate/templates.d.ts.map +1 -1
  106. package/dist/generate/templates.js +14 -42
  107. package/dist/generate/trustedDocuments.js +13 -48
  108. package/dist/generate/typeDefinitions.d.ts +2 -2
  109. package/dist/generate/typeDefinitions.d.ts.map +1 -1
  110. package/dist/generate/typeDefinitions.js +83 -123
  111. package/dist/generate/types.js +0 -16
  112. package/dist/generate/watch.js +55 -63
  113. package/dist/gql.js +16 -42
  114. package/dist/index.d.ts +8 -8
  115. package/dist/index.d.ts.map +1 -1
  116. package/dist/index.js +13 -47
  117. package/dist/jsx.d.ts.map +1 -1
  118. package/dist/jsx.js +7 -40
  119. package/dist/jsxAttributeValue.js +2 -26
  120. package/dist/project.js +21 -58
  121. package/dist/routes.d.ts +1 -1
  122. package/dist/routes.d.ts.map +1 -1
  123. package/dist/routes.js +12 -48
  124. package/dist/ts2js.d.ts +1 -1
  125. package/dist/ts2js.js +33 -73
  126. package/dist/validateSchema.js +19 -47
  127. package/package.json +91 -31
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var index_exports = {};
21
+ __export(index_exports, {
22
+ buildApi: () => import_api.buildApi,
23
+ generate: () => import_generate.generate,
24
+ listQueryTypeFieldsInProject: () => import_gql.listQueryTypeFieldsInProject
25
+ });
26
+ module.exports = __toCommonJS(index_exports);
27
+ __reExport(index_exports, require("@cedarjs/project-config"), module.exports);
28
+ __reExport(index_exports, require("./ts2js.js"), module.exports);
29
+ __reExport(index_exports, require("./dev.js"), module.exports);
30
+ __reExport(index_exports, require("./routes.js"), module.exports);
31
+ __reExport(index_exports, require("./files.js"), module.exports);
32
+ var import_generate = require("./generate/generate.js");
33
+ var import_api = require("./build/api.js");
34
+ __reExport(index_exports, require("./validateSchema.js"), module.exports);
35
+ __reExport(index_exports, require("@cedarjs/babel-config"), module.exports);
36
+ var import_gql = require("./gql.js");
37
+ // Annotate the CommonJS export names for ESM import in node:
38
+ 0 && (module.exports = {
39
+ buildApi,
40
+ generate,
41
+ listQueryTypeFieldsInProject,
42
+ ...require("@cedarjs/project-config"),
43
+ ...require("./ts2js.js"),
44
+ ...require("./dev.js"),
45
+ ...require("./routes.js"),
46
+ ...require("./files.js"),
47
+ ...require("./validateSchema.js"),
48
+ ...require("@cedarjs/babel-config")
49
+ });
@@ -0,0 +1,16 @@
1
+ import type { types } from '@babel/core';
2
+ interface JsxElement {
3
+ name: string;
4
+ props: Record<string, any>;
5
+ children?: JsxElement[];
6
+ location: {
7
+ line: number;
8
+ column: number;
9
+ };
10
+ }
11
+ /**
12
+ * Extract JSX elements, children and props from static code.
13
+ */
14
+ export declare const getJsxElements: (ast: types.Node, name: string) => JsxElement[];
15
+ export {};
16
+ //# sourceMappingURL=jsx.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsx.d.ts","sourceRoot":"","sources":["../../src/jsx.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAUxC,UAAU,UAAU;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC1B,QAAQ,CAAC,EAAE,UAAU,EAAE,CAAA;IACvB,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,CAAA;QACZ,MAAM,EAAE,MAAM,CAAA;KACf,CAAA;CACF;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,QAAS,KAAK,CAAC,IAAI,QAAQ,MAAM,iBAgB3D,CAAA"}
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var jsx_exports = {};
30
+ __export(jsx_exports, {
31
+ getJsxElements: () => getJsxElements
32
+ });
33
+ module.exports = __toCommonJS(jsx_exports);
34
+ var import_traverse = __toESM(require("@babel/traverse"), 1);
35
+ var import_jsxAttributeValue = require("./jsxAttributeValue.js");
36
+ const traverse = import_traverse.default.default || import_traverse.default;
37
+ const getJsxElements = (ast, name) => {
38
+ let elements = [];
39
+ traverse(ast, {
40
+ JSXIdentifier(path) {
41
+ if (path.node.name === name && path.parentPath.type === "JSXOpeningElement") {
42
+ if (path?.parentPath?.parentPath?.type === "JSXElement") {
43
+ const element = reduceJsxElement([], path.parentPath.parentPath.node);
44
+ elements = elements.concat(element);
45
+ }
46
+ }
47
+ }
48
+ });
49
+ return elements;
50
+ };
51
+ const getJsxAttributes = (jsxElement) => {
52
+ return jsxElement.openingElement.attributes.filter(
53
+ ({ type }) => type === "JSXAttribute"
54
+ );
55
+ };
56
+ const getJsxProps = (jsxElement) => {
57
+ const attributes = getJsxAttributes(jsxElement);
58
+ const props = {};
59
+ for (const a of attributes) {
60
+ if (typeof a.name.name === "string") {
61
+ props[a.name.name] = (0, import_jsxAttributeValue.getJsxAttributeValue)(a.value);
62
+ }
63
+ }
64
+ return props;
65
+ };
66
+ const reduceJsxElement = (oldNode, currentNode) => {
67
+ let element = {
68
+ name: "",
69
+ props: {},
70
+ children: [],
71
+ location: {
72
+ line: 1,
73
+ column: 0
74
+ }
75
+ };
76
+ if (currentNode.type === "JSXElement") {
77
+ const props = getJsxProps(currentNode);
78
+ if (currentNode.openingElement.name.type === "JSXIdentifier") {
79
+ element = {
80
+ name: currentNode.openingElement.name.name,
81
+ props,
82
+ children: [],
83
+ location: {
84
+ line: currentNode.openingElement.loc?.start.line ?? 1,
85
+ column: currentNode.openingElement.loc?.start.column ?? 0
86
+ }
87
+ };
88
+ oldNode.push(element);
89
+ }
90
+ }
91
+ if ("children" in currentNode) {
92
+ currentNode.children.forEach(
93
+ (node) => oldNode.length > 0 ? reduceJsxElement(element.children, node) : reduceJsxElement(oldNode, node)
94
+ );
95
+ }
96
+ return oldNode;
97
+ };
98
+ // Annotate the CommonJS export names for ESM import in node:
99
+ 0 && (module.exports = {
100
+ getJsxElements
101
+ });
@@ -0,0 +1,2 @@
1
+ export declare const getJsxAttributeValue: (expression: any) => any;
2
+ //# sourceMappingURL=jsxAttributeValue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsxAttributeValue.d.ts","sourceRoot":"","sources":["../../src/jsxAttributeValue.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,oBAAoB,eAAgB,GAAG,KAAG,GAsLtD,CAAA"}
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var jsxAttributeValue_exports = {};
20
+ __export(jsxAttributeValue_exports, {
21
+ getJsxAttributeValue: () => getJsxAttributeValue
22
+ });
23
+ module.exports = __toCommonJS(jsxAttributeValue_exports);
24
+ const getJsxAttributeValue = (expression) => {
25
+ if (expression === null) {
26
+ return true;
27
+ }
28
+ if (expression.type === "StringLiteral") {
29
+ return expression.value;
30
+ }
31
+ if (expression.type === "JSXExpressionContainer") {
32
+ return getJsxAttributeValue(expression.expression);
33
+ }
34
+ if (expression.type === "ArrayExpression") {
35
+ return expression.elements.map((element) => getJsxAttributeValue(element));
36
+ }
37
+ if (expression.type === "TemplateLiteral") {
38
+ const expressions = expression.expressions.map((element) => ({
39
+ ...element,
40
+ value: {
41
+ raw: element.value,
42
+ cooked: getJsxAttributeValue(element)
43
+ }
44
+ }));
45
+ return expressions.concat(expression.quasis).sort((elementA, elementB) => elementA.start - elementB.start).reduce(
46
+ (string, element) => `${string}${element.value.cooked.toString()}`,
47
+ ""
48
+ );
49
+ }
50
+ if (expression.type === "ObjectExpression") {
51
+ const entries = expression.properties.map((property) => {
52
+ const key = getJsxAttributeValue(property.key);
53
+ const value = getJsxAttributeValue(property.value);
54
+ if (key === void 0 || value === void 0) {
55
+ return null;
56
+ }
57
+ return { key, value };
58
+ }).filter((property) => property).reduce((properties, property) => {
59
+ return { ...properties, [property.key]: property.value };
60
+ }, {});
61
+ return entries;
62
+ }
63
+ if (expression.type === "Identifier") {
64
+ return expression.name;
65
+ }
66
+ if (expression.type === "BinaryExpression") {
67
+ switch (expression.operator) {
68
+ case "+":
69
+ return getJsxAttributeValue(expression.left) + getJsxAttributeValue(expression.right);
70
+ case "-":
71
+ return getJsxAttributeValue(expression.left) - getJsxAttributeValue(expression.right);
72
+ case "*":
73
+ return getJsxAttributeValue(expression.left) * getJsxAttributeValue(expression.right);
74
+ case "**":
75
+ return getJsxAttributeValue(expression.left) ** getJsxAttributeValue(expression.right);
76
+ case "/":
77
+ return getJsxAttributeValue(expression.left) / getJsxAttributeValue(expression.right);
78
+ case "%":
79
+ return getJsxAttributeValue(expression.left) % getJsxAttributeValue(expression.right);
80
+ case "==":
81
+ return getJsxAttributeValue(expression.left) == getJsxAttributeValue(expression.right);
82
+ case "===":
83
+ return getJsxAttributeValue(expression.left) === getJsxAttributeValue(expression.right);
84
+ case "!=":
85
+ return getJsxAttributeValue(expression.left) != getJsxAttributeValue(expression.right);
86
+ case "!==":
87
+ return getJsxAttributeValue(expression.left) !== getJsxAttributeValue(expression.right);
88
+ case "<":
89
+ return getJsxAttributeValue(expression.left) < getJsxAttributeValue(expression.right);
90
+ case "<=":
91
+ return getJsxAttributeValue(expression.left) <= getJsxAttributeValue(expression.right);
92
+ case ">":
93
+ return getJsxAttributeValue(expression.left) > getJsxAttributeValue(expression.right);
94
+ case ">=":
95
+ return getJsxAttributeValue(expression.left) >= getJsxAttributeValue(expression.right);
96
+ case "<<":
97
+ return getJsxAttributeValue(expression.left) << getJsxAttributeValue(expression.right);
98
+ case ">>":
99
+ return getJsxAttributeValue(expression.left) >> getJsxAttributeValue(expression.right);
100
+ case ">>>":
101
+ return getJsxAttributeValue(expression.left) >>> getJsxAttributeValue(expression.right);
102
+ case "|":
103
+ return getJsxAttributeValue(expression.left) | getJsxAttributeValue(expression.right);
104
+ case "&":
105
+ return getJsxAttributeValue(expression.left) & getJsxAttributeValue(expression.right);
106
+ case "^":
107
+ return getJsxAttributeValue(expression.left) ^ getJsxAttributeValue(expression.right);
108
+ default:
109
+ return `BinaryExpression with "${expression.operator}" is not supported`;
110
+ }
111
+ }
112
+ if (expression.type === "UnaryExpression") {
113
+ switch (expression.operator) {
114
+ case "+":
115
+ return +getJsxAttributeValue(expression.argument);
116
+ case "-":
117
+ return -getJsxAttributeValue(expression.argument);
118
+ case "~":
119
+ return ~getJsxAttributeValue(expression.argument);
120
+ default:
121
+ return `UnaryExpression with "${expression.operator}" is not supported`;
122
+ }
123
+ }
124
+ return `${expression.type} is not supported`;
125
+ };
126
+ // Annotate the CommonJS export names for ESM import in node:
127
+ 0 && (module.exports = {
128
+ getJsxAttributeValue
129
+ });
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -0,0 +1,8 @@
1
+ export declare const getTsConfigs: () => {
2
+ api: any;
3
+ web: any;
4
+ };
5
+ export declare const isTypeScriptProject: () => boolean;
6
+ export declare const isServerFileSetup: () => boolean;
7
+ export declare const isRealtimeSetup: () => boolean;
8
+ //# sourceMappingURL=project.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/project.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,YAAY;;;CAuBxB,CAAA;AAED,eAAO,MAAM,mBAAmB,eAM/B,CAAA;AAED,eAAO,MAAM,iBAAiB,eAO7B,CAAA;AAED,eAAO,MAAM,eAAe,eAO3B,CAAA"}
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var project_exports = {};
30
+ __export(project_exports, {
31
+ getTsConfigs: () => getTsConfigs,
32
+ isRealtimeSetup: () => isRealtimeSetup,
33
+ isServerFileSetup: () => isServerFileSetup,
34
+ isTypeScriptProject: () => isTypeScriptProject
35
+ });
36
+ module.exports = __toCommonJS(project_exports);
37
+ var import_fs = __toESM(require("fs"), 1);
38
+ var import_path = __toESM(require("path"), 1);
39
+ var import_typescript = require("typescript");
40
+ var import_project_config = require("@cedarjs/project-config");
41
+ const getTsConfigs = () => {
42
+ const rwPaths = (0, import_project_config.getPaths)();
43
+ const apiTsConfigPath = import_path.default.join(rwPaths.api.base, "tsconfig.json");
44
+ const webTsConfigPath = import_path.default.join(rwPaths.web.base, "tsconfig.json");
45
+ const apiTsConfig = import_fs.default.existsSync(apiTsConfigPath) ? (0, import_typescript.parseConfigFileTextToJson)(
46
+ apiTsConfigPath,
47
+ import_fs.default.readFileSync(apiTsConfigPath, "utf-8")
48
+ ) : null;
49
+ const webTsConfig = import_fs.default.existsSync(webTsConfigPath) ? (0, import_typescript.parseConfigFileTextToJson)(
50
+ webTsConfigPath,
51
+ import_fs.default.readFileSync(webTsConfigPath, "utf-8")
52
+ ) : null;
53
+ return {
54
+ api: apiTsConfig?.config ?? null,
55
+ web: webTsConfig?.config ?? null
56
+ };
57
+ };
58
+ const isTypeScriptProject = () => {
59
+ const paths = (0, import_project_config.getPaths)();
60
+ return import_fs.default.existsSync(import_path.default.join(paths.web.base, "tsconfig.json")) || import_fs.default.existsSync(import_path.default.join(paths.api.base, "tsconfig.json"));
61
+ };
62
+ const isServerFileSetup = () => {
63
+ const serverFilePath = import_path.default.join(
64
+ (0, import_project_config.getPaths)().api.src,
65
+ `server.${isTypeScriptProject() ? "ts" : "js"}`
66
+ );
67
+ return import_fs.default.existsSync(serverFilePath);
68
+ };
69
+ const isRealtimeSetup = () => {
70
+ const realtimePath = import_path.default.join(
71
+ (0, import_project_config.getPaths)().api.lib,
72
+ `realtime.${isTypeScriptProject() ? "ts" : "js"}`
73
+ );
74
+ return import_fs.default.existsSync(realtimePath);
75
+ };
76
+ // Annotate the CommonJS export names for ESM import in node:
77
+ 0 && (module.exports = {
78
+ getTsConfigs,
79
+ isRealtimeSetup,
80
+ isServerFileSetup,
81
+ isTypeScriptProject
82
+ });
@@ -0,0 +1,42 @@
1
+ export interface RouteInformation {
2
+ name?: string;
3
+ path?: string;
4
+ page?: string;
5
+ }
6
+ /**
7
+ * Returns an array of routes which conflict on their defined names
8
+ */
9
+ export declare function getDuplicateRoutes(): RouteInformation[];
10
+ /**
11
+ * Detects any potential duplicate routes and returns a formatted warning message
12
+ * @see {@link getDuplicateRoutes} for how duplicate routes are detected
13
+ * @return Warning message when duplicate routes found, empty string if not
14
+ */
15
+ export declare function warningForDuplicateRoutes(): string;
16
+ export interface RWRouteManifestItem {
17
+ name: string;
18
+ pathDefinition: string;
19
+ matchRegexString: string | null;
20
+ routeHooks: string | null;
21
+ bundle: string | null;
22
+ hasParams: boolean;
23
+ relativeFilePath: string;
24
+ redirect: {
25
+ to: string;
26
+ permanent: boolean;
27
+ } | null;
28
+ isPrivate: boolean;
29
+ unauthenticated: string | null;
30
+ roles: string | string[] | null;
31
+ pageIdentifier: string | null;
32
+ }
33
+ export interface RouteSpec extends RWRouteManifestItem {
34
+ id: string;
35
+ isNotFound: boolean;
36
+ filePath: string | undefined;
37
+ isPrivate: boolean;
38
+ unauthenticated: string | null;
39
+ relativeFilePath: string;
40
+ }
41
+ export declare const getProjectRoutes: () => RouteSpec[];
42
+ //# sourceMappingURL=routes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/routes.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,gBAAgB,EAAE,CAyBvD;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,WAgBxC;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAA;IACZ,cAAc,EAAE,MAAM,CAAA;IACtB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,SAAS,EAAE,OAAO,CAAA;IAClB,gBAAgB,EAAE,MAAM,CAAA;IACxB,QAAQ,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAA;IACnD,SAAS,EAAE,OAAO,CAAA;IAClB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CAAA;IAC/B,cAAc,EAAE,MAAM,GAAG,IAAI,CAAA;CAE9B;AAED,MAAM,WAAW,SAAU,SAAQ,mBAAmB;IACpD,EAAE,EAAE,MAAM,CAAA;IACV,UAAU,EAAE,OAAO,CAAA;IACnB,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B,SAAS,EAAE,OAAO,CAAA;IAClB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,gBAAgB,EAAE,MAAM,CAAA;CACzB;AAED,eAAO,MAAM,gBAAgB,QAAO,SAAS,EAkC5C,CAAA"}
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var routes_exports = {};
30
+ __export(routes_exports, {
31
+ getDuplicateRoutes: () => getDuplicateRoutes,
32
+ getProjectRoutes: () => getProjectRoutes,
33
+ warningForDuplicateRoutes: () => warningForDuplicateRoutes
34
+ });
35
+ module.exports = __toCommonJS(routes_exports);
36
+ var import_node_path = __toESM(require("node:path"), 1);
37
+ var import_ansis = __toESM(require("ansis"), 1);
38
+ var import_project_config = require("@cedarjs/project-config");
39
+ var import_util = require("@cedarjs/router/dist/util");
40
+ var import_dist = require("@cedarjs/structure/dist/index.js");
41
+ function getDuplicateRoutes() {
42
+ const duplicateRoutes = [];
43
+ const allRoutes = (0, import_dist.getProject)((0, import_project_config.getPaths)().base).router.routes;
44
+ const uniqueNames = new Set(
45
+ allRoutes.filter((route) => route.name !== void 0).map((route) => route.name)
46
+ );
47
+ uniqueNames.forEach((name) => {
48
+ const routesWithName = allRoutes.filter((route) => {
49
+ return route.name === name;
50
+ });
51
+ if (routesWithName.length > 1) {
52
+ duplicateRoutes.push(
53
+ ...routesWithName.map((route) => {
54
+ return {
55
+ name: route.name,
56
+ page: route.page_identifier_str,
57
+ path: route.path
58
+ };
59
+ })
60
+ );
61
+ }
62
+ });
63
+ return duplicateRoutes;
64
+ }
65
+ function warningForDuplicateRoutes() {
66
+ const duplicatedRoutes = getDuplicateRoutes();
67
+ let message = "";
68
+ if (duplicatedRoutes.length > 0) {
69
+ message += import_ansis.default.hex("#ffa500")(
70
+ `Warning: ${duplicatedRoutes.length} duplicate routes have been detected, only the route(s) closest to the top of the file will be used.
71
+ `
72
+ );
73
+ duplicatedRoutes.forEach((route) => {
74
+ message += ` ${import_ansis.default.hex("#ffa500")("->")} Name: "${route.name}", Path: "${route.path}", Page: "${route.page}"
75
+ `;
76
+ });
77
+ }
78
+ return message.trimEnd();
79
+ }
80
+ const getProjectRoutes = () => {
81
+ const rwProject = (0, import_dist.getProject)((0, import_project_config.getPaths)().base);
82
+ const routes = rwProject.getRouter().routes;
83
+ return routes.map((route) => {
84
+ const { matchRegexString, routeParams } = route.isNotFound ? { matchRegexString: null, routeParams: null } : (0, import_util.getRouteRegexAndParams)(route.path);
85
+ return {
86
+ name: route.isNotFound ? "NotFoundPage" : route.name,
87
+ pathDefinition: route.isNotFound ? "notfound" : route.path,
88
+ hasParams: route.hasParameters,
89
+ id: route.id,
90
+ isNotFound: route.isNotFound,
91
+ filePath: route.page?.filePath,
92
+ relativeFilePath: route.page?.filePath ? import_node_path.default.relative((0, import_project_config.getPaths)().web.src, route.page?.filePath) : void 0,
93
+ routeHooks: (0, import_project_config.getRouteHookForPage)(route.page?.filePath),
94
+ renderMode: route.renderMode,
95
+ matchRegexString,
96
+ paramNames: routeParams,
97
+ // TODO (STREAMING) deal with permanent/temp later
98
+ redirect: route.redirect ? { to: route.redirect, permanent: false } : null,
99
+ isPrivate: route.isPrivate,
100
+ unauthenticated: route.unauthenticated,
101
+ roles: route.roles,
102
+ pageIdentifier: route.page_identifier_str
103
+ };
104
+ });
105
+ };
106
+ // Annotate the CommonJS export names for ESM import in node:
107
+ 0 && (module.exports = {
108
+ getDuplicateRoutes,
109
+ getProjectRoutes,
110
+ warningForDuplicateRoutes
111
+ });
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Converts all the TypeScript files in the `api` and `web` sides to JavaScript.
3
+ *
4
+ * @param {string} cwd - The base path to the project.
5
+ */
6
+ export declare const convertTsProjectToJs: (cwd?: string) => void;
7
+ /**
8
+ * Converts all the TypeScript files in the `api` and `web` sides to JavaScript.
9
+ *
10
+ * @param {string} cwd - The base path to the project.
11
+ */
12
+ export declare const convertTsScriptsToJs: (cwd?: string) => void;
13
+ /**
14
+ * Converts TypeScript files to JavaScript.
15
+ *
16
+ * @param {string} cwd - Current directory
17
+ * @param {string[]} files - Collection of files to convert
18
+ */
19
+ export declare const convertTsFilesToJs: (cwd: string, files: string[]) => Promise<void>;
20
+ /**
21
+ * Get all the source code from a Redwood project
22
+ */
23
+ export declare const typeScriptSourceFiles: (cwd: string, globPattern?: string) => string[];
24
+ /**
25
+ * Read the contents of a TypeScript file, transpile it to JavaScript,
26
+ * but leave the JSX intact and format via Prettier.
27
+ *
28
+ * @param {string} file - The path to the TypeScript file.
29
+ */
30
+ export declare const transformTSToJS: (file: string) => Promise<string> | undefined;
31
+ export declare const getPrettierConfig: () => Promise<any>;
32
+ /**
33
+ * Prettify `code` according to the extension in `filename`.
34
+ * This will also read a user's `prettier.config.cjs` file if it exists.
35
+ *
36
+ * @param {string} code
37
+ * @param {string} filename
38
+ */
39
+ export declare const prettify: (code: string, filename: string) => Promise<string>;
40
+ //# sourceMappingURL=ts2js.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ts2js.d.ts","sourceRoot":"","sources":["../../src/ts2js.ts"],"names":[],"mappings":"AASA;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,wBAGhC,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,wBAGhC,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,QAAe,MAAM,SAAS,MAAM,EAAE,kBAkCpE,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB,QAC3B,MAAM,mCAUZ,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,eAAe,SAAU,MAAM,gCAwB3C,CAAA;AAED,eAAO,MAAM,iBAAiB,oBAS7B,CAAA;AAsBD;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,SAAgB,MAAM,YAAY,MAAM,oBAa5D,CAAA"}