@cedarjs/internal 5.0.4-next.167 → 5.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 (143) hide show
  1. package/dist/ast.d.ts +0 -1
  2. package/dist/ast.d.ts.map +1 -1
  3. package/dist/ast.js +0 -21
  4. package/dist/build/api.d.ts +0 -2
  5. package/dist/build/api.d.ts.map +1 -1
  6. package/dist/build/api.js +39 -202
  7. package/dist/build/esbuild-plugin-cedar-context-wrapping.d.ts +4 -0
  8. package/dist/build/esbuild-plugin-cedar-context-wrapping.d.ts.map +1 -0
  9. package/dist/build/{esbuild-plugin-handler-als-wrapping.js → esbuild-plugin-cedar-context-wrapping.js} +12 -12
  10. package/dist/cjs/ast.d.ts +26 -0
  11. package/dist/cjs/ast.d.ts.map +1 -0
  12. package/dist/cjs/ast.js +201 -0
  13. package/dist/cjs/build/api.d.ts +7 -0
  14. package/dist/cjs/build/api.d.ts.map +1 -0
  15. package/dist/cjs/build/api.js +251 -0
  16. package/dist/cjs/build/esbuild-plugin-cedar-context-wrapping.d.ts +4 -0
  17. package/dist/cjs/build/esbuild-plugin-cedar-context-wrapping.d.ts.map +1 -0
  18. package/dist/cjs/build/esbuild-plugin-cedar-context-wrapping.js +59 -0
  19. package/dist/cjs/cliLogger.d.ts +11 -0
  20. package/dist/cjs/cliLogger.d.ts.map +1 -0
  21. package/dist/cjs/cliLogger.js +36 -0
  22. package/dist/cjs/dev.d.ts +2 -0
  23. package/dist/cjs/dev.d.ts.map +1 -0
  24. package/dist/cjs/dev.js +41 -0
  25. package/dist/cjs/files.d.ts +56 -0
  26. package/dist/cjs/files.d.ts.map +1 -0
  27. package/dist/cjs/files.js +230 -0
  28. package/dist/cjs/generate/clientPreset.d.ts +17 -0
  29. package/dist/cjs/generate/clientPreset.d.ts.map +1 -0
  30. package/dist/cjs/generate/clientPreset.js +84 -0
  31. package/dist/cjs/generate/generate.d.ts +10 -0
  32. package/dist/cjs/generate/generate.d.ts.map +1 -0
  33. package/dist/cjs/generate/generate.js +97 -0
  34. package/dist/cjs/generate/gqlormSchema.d.ts +113 -0
  35. package/dist/cjs/generate/gqlormSchema.d.ts.map +1 -0
  36. package/dist/cjs/generate/gqlormSchema.js +1061 -0
  37. package/dist/cjs/generate/graphqlCodeGen.d.ts +16 -0
  38. package/dist/cjs/generate/graphqlCodeGen.d.ts.map +1 -0
  39. package/dist/cjs/generate/graphqlCodeGen.js +380 -0
  40. package/dist/cjs/generate/graphqlSchema.d.ts +8 -0
  41. package/dist/cjs/generate/graphqlSchema.d.ts.map +1 -0
  42. package/dist/cjs/generate/graphqlSchema.js +157 -0
  43. package/dist/cjs/generate/plugins/rw-typescript-resolvers/index.d.ts +7 -0
  44. package/dist/cjs/generate/plugins/rw-typescript-resolvers/index.d.ts.map +1 -0
  45. package/dist/cjs/generate/plugins/rw-typescript-resolvers/index.js +65 -0
  46. package/dist/cjs/generate/plugins/rw-typescript-resolvers/visitor.d.ts +10 -0
  47. package/dist/cjs/generate/plugins/rw-typescript-resolvers/visitor.d.ts.map +1 -0
  48. package/dist/cjs/generate/plugins/rw-typescript-resolvers/visitor.js +92 -0
  49. package/dist/cjs/generate/possibleTypes.d.ts +36 -0
  50. package/dist/cjs/generate/possibleTypes.d.ts.map +1 -0
  51. package/dist/cjs/generate/possibleTypes.js +106 -0
  52. package/dist/cjs/generate/templates/all-currentUser.d.ts.template +30 -0
  53. package/dist/cjs/generate/templates/all-gqlorm.d.ts.template +7 -0
  54. package/dist/cjs/generate/templates/api-globImports.d.ts.template +9 -0
  55. package/dist/cjs/generate/templates/api-globalContext.d.ts.template +7 -0
  56. package/dist/cjs/generate/templates/api-scenarios.d.ts.template +10 -0
  57. package/dist/cjs/generate/templates/api-test-globals.d.ts.template +5 -0
  58. package/dist/cjs/generate/templates/mirror-cell.d.ts.template +13 -0
  59. package/dist/cjs/generate/templates/mirror-directoryNamedModule.d.ts.template +5 -0
  60. package/dist/cjs/generate/templates/web-routerRoutes.d.ts.template +20 -0
  61. package/dist/cjs/generate/templates/web-routesPages.d.ts.template +13 -0
  62. package/dist/cjs/generate/templates/web-test-globals.d.ts.template +7 -0
  63. package/dist/cjs/generate/templates.d.ts +6 -0
  64. package/dist/cjs/generate/templates.d.ts.map +1 -0
  65. package/dist/cjs/generate/templates.js +68 -0
  66. package/dist/cjs/generate/trustedDocuments.d.ts +3 -0
  67. package/dist/cjs/generate/trustedDocuments.d.ts.map +1 -0
  68. package/dist/cjs/generate/trustedDocuments.js +95 -0
  69. package/dist/cjs/generate/typeDefinitions.d.ts +31 -0
  70. package/dist/cjs/generate/typeDefinitions.d.ts.map +1 -0
  71. package/dist/cjs/generate/typeDefinitions.js +372 -0
  72. package/dist/cjs/generate/types.d.ts +6 -0
  73. package/dist/cjs/generate/types.d.ts.map +1 -0
  74. package/dist/cjs/generate/types.js +16 -0
  75. package/dist/cjs/generate/watch.d.ts +3 -0
  76. package/dist/cjs/generate/watch.d.ts.map +1 -0
  77. package/dist/cjs/generate/watch.js +132 -0
  78. package/dist/cjs/gql.d.ts +14 -0
  79. package/dist/cjs/gql.d.ts.map +1 -0
  80. package/dist/cjs/gql.js +108 -0
  81. package/dist/cjs/index.d.ts +11 -0
  82. package/dist/cjs/index.d.ts.map +1 -0
  83. package/dist/cjs/index.js +49 -0
  84. package/dist/cjs/jsx.d.ts +16 -0
  85. package/dist/cjs/jsx.d.ts.map +1 -0
  86. package/dist/cjs/jsx.js +101 -0
  87. package/dist/cjs/jsxAttributeValue.d.ts +2 -0
  88. package/dist/cjs/jsxAttributeValue.d.ts.map +1 -0
  89. package/dist/cjs/jsxAttributeValue.js +129 -0
  90. package/dist/cjs/package.json +1 -0
  91. package/dist/cjs/project.d.ts +8 -0
  92. package/dist/cjs/project.d.ts.map +1 -0
  93. package/dist/cjs/project.js +82 -0
  94. package/dist/cjs/routes.d.ts +42 -0
  95. package/dist/cjs/routes.d.ts.map +1 -0
  96. package/dist/cjs/routes.js +111 -0
  97. package/dist/cjs/ts2js.d.ts +40 -0
  98. package/dist/cjs/ts2js.d.ts.map +1 -0
  99. package/dist/cjs/ts2js.js +159 -0
  100. package/dist/cjs/validateSchema.d.ts +14 -0
  101. package/dist/cjs/validateSchema.d.ts.map +1 -0
  102. package/dist/cjs/validateSchema.js +195 -0
  103. package/dist/generate/clientPreset.d.ts.map +1 -1
  104. package/dist/generate/clientPreset.js +3 -10
  105. package/dist/generate/typeDefinitions.d.ts.map +1 -1
  106. package/dist/generate/typeDefinitions.js +1 -15
  107. package/dist/gql.d.ts +0 -20
  108. package/dist/gql.d.ts.map +1 -1
  109. package/dist/gql.js +0 -24
  110. package/package.json +80 -48
  111. package/dist/build/api-graphql-transforms.d.ts +0 -34
  112. package/dist/build/api-graphql-transforms.d.ts.map +0 -1
  113. package/dist/build/api-graphql-transforms.js +0 -119
  114. package/dist/build/auto-import.d.ts +0 -10
  115. package/dist/build/auto-import.d.ts.map +0 -1
  116. package/dist/build/auto-import.js +0 -120
  117. package/dist/build/directory-named-import.d.ts +0 -2
  118. package/dist/build/directory-named-import.d.ts.map +0 -1
  119. package/dist/build/directory-named-import.js +0 -26
  120. package/dist/build/esbuild-plugin-api-graphql.d.ts +0 -6
  121. package/dist/build/esbuild-plugin-api-graphql.d.ts.map +0 -1
  122. package/dist/build/esbuild-plugin-api-graphql.js +0 -80
  123. package/dist/build/esbuild-plugin-cedar-otel-wrapping.d.ts +0 -13
  124. package/dist/build/esbuild-plugin-cedar-otel-wrapping.d.ts.map +0 -1
  125. package/dist/build/esbuild-plugin-cedar-otel-wrapping.js +0 -180
  126. package/dist/build/esbuild-plugin-handler-als-wrapping.d.ts +0 -4
  127. package/dist/build/esbuild-plugin-handler-als-wrapping.d.ts.map +0 -1
  128. package/dist/build/esm-extensions.d.ts +0 -33
  129. package/dist/build/esm-extensions.d.ts.map +0 -1
  130. package/dist/build/esm-extensions.js +0 -37
  131. package/dist/build/import-dir.d.ts +0 -22
  132. package/dist/build/import-dir.d.ts.map +0 -1
  133. package/dist/build/import-dir.js +0 -54
  134. package/dist/build/job-path-injector.d.ts +0 -15
  135. package/dist/build/job-path-injector.d.ts.map +0 -1
  136. package/dist/build/job-path-injector.js +0 -69
  137. package/dist/build/src-alias.d.ts +0 -14
  138. package/dist/build/src-alias.d.ts.map +0 -1
  139. package/dist/build/src-alias.js +0 -17
  140. package/dist/build/tsconfig-paths.d.ts +0 -2
  141. package/dist/build/tsconfig-paths.d.ts.map +0 -1
  142. package/dist/build/tsconfig-paths.js +0 -72
  143. package/dist/generate/templates/mirror-cell-fragment.d.ts.template +0 -18
@@ -0,0 +1,251 @@
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 api_exports = {};
30
+ __export(api_exports, {
31
+ buildApi: () => buildApi,
32
+ buildApiWithVite: () => buildApiWithVite,
33
+ cleanApiBuild: () => cleanApiBuild,
34
+ fixSourceMaps: () => fixSourceMaps,
35
+ rebuildApi: () => rebuildApi
36
+ });
37
+ module.exports = __toCommonJS(api_exports);
38
+ var import_node_fs = __toESM(require("node:fs"), 1);
39
+ var import_node_path = __toESM(require("node:path"), 1);
40
+ var import_esbuild = require("esbuild");
41
+ var import_vite = require("vite");
42
+ var import_babel_config = require("@cedarjs/babel-config");
43
+ var import_project_config = require("@cedarjs/project-config");
44
+ var import_files = require("../files.js");
45
+ var import_esbuild_plugin_cedar_context_wrapping = require("./esbuild-plugin-cedar-context-wrapping.js");
46
+ let BUILD_CTX = null;
47
+ const buildApi = async () => {
48
+ BUILD_CTX?.dispose();
49
+ BUILD_CTX = null;
50
+ return transpileApi((0, import_files.findApiFiles)());
51
+ };
52
+ const rebuildApi = async () => {
53
+ const apiFiles = (0, import_files.findApiFiles)();
54
+ if (!BUILD_CTX) {
55
+ BUILD_CTX = await (0, import_esbuild.context)(getEsbuildOptions(apiFiles));
56
+ }
57
+ const result = await BUILD_CTX.rebuild();
58
+ const cedarPaths = (0, import_project_config.getPaths)();
59
+ await fixSourceMaps(cedarPaths.api.dist, cedarPaths.api.src);
60
+ return result;
61
+ };
62
+ const cleanApiBuild = async () => {
63
+ const cedarPaths = (0, import_project_config.getPaths)();
64
+ return import_node_fs.default.promises.rm(cedarPaths.api.dist, { recursive: true, force: true });
65
+ };
66
+ const runCedarBabelTransformsPlugin = {
67
+ name: "cedar-esbuild-babel-transform",
68
+ setup(build2) {
69
+ const cedarConfig = (0, import_project_config.getConfig)();
70
+ build2.onLoad({ filter: /\.(js|ts|tsx|jsx)$/ }, async (args) => {
71
+ const fileContents = await import_node_fs.default.promises.readFile(args.path, "utf-8");
72
+ const transformedCode = await (0, import_babel_config.transformWithBabel)(
73
+ fileContents,
74
+ args.path,
75
+ (0, import_babel_config.getApiSideBabelPlugins)({
76
+ openTelemetry: cedarConfig.experimental.opentelemetry.enabled && cedarConfig.experimental.opentelemetry.wrapApi,
77
+ projectIsEsm: (0, import_project_config.projectSideIsEsm)("api")
78
+ })
79
+ );
80
+ if (transformedCode?.code) {
81
+ const functionsDir = (0, import_vite.normalizePath)(
82
+ import_node_path.default.join((0, import_project_config.getPaths)().api.src, "functions")
83
+ );
84
+ const code = (0, import_vite.normalizePath)(args.path).startsWith(functionsDir + "/") ? (0, import_esbuild_plugin_cedar_context_wrapping.applyContextWrapping)(transformedCode.code, {
85
+ projectIsEsm: (0, import_project_config.projectSideIsEsm)("api")
86
+ }) ?? transformedCode.code : transformedCode.code;
87
+ return {
88
+ contents: code,
89
+ loader: "js"
90
+ };
91
+ }
92
+ throw new Error(`Could not transform file: ${args.path}`);
93
+ });
94
+ }
95
+ };
96
+ function createCedarViteApiPlugin() {
97
+ const cedarConfig = (0, import_project_config.getConfig)();
98
+ const isEsm = (0, import_project_config.projectSideIsEsm)("api");
99
+ return {
100
+ name: "cedar-vite-api-babel-transform",
101
+ enforce: "pre",
102
+ async transform(code, id) {
103
+ if (!/\.(js|ts|tsx|jsx)$/.test(id)) {
104
+ return null;
105
+ }
106
+ if (id.includes("node_modules")) {
107
+ return null;
108
+ }
109
+ const cedarPaths = (0, import_project_config.getPaths)();
110
+ if (!(0, import_vite.normalizePath)(id).startsWith((0, import_vite.normalizePath)(cedarPaths.api.base))) {
111
+ return null;
112
+ }
113
+ const transformedCode = await (0, import_babel_config.transformWithBabel)(
114
+ code,
115
+ id,
116
+ (0, import_babel_config.getApiSideBabelPlugins)({
117
+ openTelemetry: cedarConfig.experimental.opentelemetry.enabled && cedarConfig.experimental.opentelemetry.wrapApi,
118
+ projectIsEsm: isEsm
119
+ }),
120
+ true
121
+ );
122
+ if (transformedCode?.code) {
123
+ const functionsDir = (0, import_vite.normalizePath)(
124
+ import_node_path.default.join(cedarPaths.api.src, "functions")
125
+ );
126
+ const code2 = (0, import_vite.normalizePath)(id).startsWith(functionsDir + "/") ? (0, import_esbuild_plugin_cedar_context_wrapping.applyContextWrapping)(transformedCode.code, {
127
+ projectIsEsm: isEsm
128
+ }) ?? transformedCode.code : transformedCode.code;
129
+ return {
130
+ code: code2,
131
+ map: transformedCode.map ?? null
132
+ };
133
+ }
134
+ throw new Error(`Could not transform file: ${id}`);
135
+ }
136
+ };
137
+ }
138
+ const buildApiWithVite = async () => {
139
+ const cedarPaths = (0, import_project_config.getPaths)();
140
+ const isEsm = (0, import_project_config.projectSideIsEsm)("api");
141
+ const format = isEsm ? "es" : "cjs";
142
+ const apiFiles = (0, import_files.findApiFiles)();
143
+ const input = {};
144
+ for (const f of apiFiles) {
145
+ const key = import_node_path.default.relative(cedarPaths.api.src, f).replace(/\.(ts|tsx|mts|js|jsx|mjs)$/, "");
146
+ input[key] = f;
147
+ }
148
+ return (0, import_vite.build)({
149
+ root: cedarPaths.api.base,
150
+ logLevel: "warn",
151
+ build: {
152
+ ssr: true,
153
+ sourcemap: true,
154
+ outDir: cedarPaths.api.dist,
155
+ rollupOptions: {
156
+ input,
157
+ output: {
158
+ format,
159
+ preserveModules: true,
160
+ preserveModulesRoot: cedarPaths.api.src,
161
+ entryFileNames: "[name].js",
162
+ // Directives (and other entry modules) intentionally use both named
163
+ // and default exports (e.g. `export const schema` + `export default`).
164
+ // Tell Rollup to expect this so it doesn't warn about mixed exports.
165
+ exports: "named"
166
+ },
167
+ external: (id) => {
168
+ if (id.startsWith("node:")) {
169
+ return true;
170
+ }
171
+ if (!id.startsWith(".") && !import_node_path.default.isAbsolute(id)) {
172
+ return true;
173
+ }
174
+ return false;
175
+ }
176
+ }
177
+ },
178
+ plugins: [createCedarViteApiPlugin()]
179
+ });
180
+ };
181
+ const transpileApi = async (files) => {
182
+ const result = await (0, import_esbuild.build)(getEsbuildOptions(files));
183
+ const cedarPaths = (0, import_project_config.getPaths)();
184
+ await fixSourceMaps(cedarPaths.api.dist, cedarPaths.api.src);
185
+ return result;
186
+ };
187
+ async function fixSourceMaps(distDir, srcDir) {
188
+ let entries;
189
+ try {
190
+ entries = await import_node_fs.default.promises.readdir(distDir, {
191
+ recursive: true,
192
+ withFileTypes: true
193
+ });
194
+ } catch {
195
+ return;
196
+ }
197
+ const mapFiles = entries.filter((e) => e.isFile() && e.name.endsWith(".js.map")).map((e) => import_node_path.default.join(e.parentPath ?? e.path, e.name));
198
+ await Promise.all(
199
+ mapFiles.map(async (mapFile) => {
200
+ try {
201
+ const raw = await import_node_fs.default.promises.readFile(mapFile, "utf8");
202
+ const map = JSON.parse(raw);
203
+ if (!Array.isArray(map.sources) || map.sources.length === 0) {
204
+ return;
205
+ }
206
+ const jsFile = mapFile.slice(0, -4);
207
+ const baseName = import_node_path.default.relative(distDir, jsFile).replace(/\.js$/, "");
208
+ const srcFile = [".ts", ".tsx", ".jsx", ".js"].map((ext) => import_node_path.default.join(srcDir, baseName + ext)).find((f) => import_node_fs.default.existsSync(f));
209
+ if (!srcFile) {
210
+ return;
211
+ }
212
+ const correctRelPath = (0, import_vite.normalizePath)(
213
+ import_node_path.default.relative(import_node_path.default.dirname(mapFile), srcFile)
214
+ );
215
+ if (map.sources[0] === correctRelPath) {
216
+ return;
217
+ }
218
+ map.sources = [correctRelPath];
219
+ await import_node_fs.default.promises.writeFile(mapFile, JSON.stringify(map), "utf8");
220
+ } catch {
221
+ }
222
+ })
223
+ );
224
+ }
225
+ function getEsbuildOptions(files) {
226
+ const cedarPaths = (0, import_project_config.getPaths)();
227
+ const format = (0, import_project_config.projectSideIsEsm)("api") ? "esm" : "cjs";
228
+ return {
229
+ absWorkingDir: cedarPaths.api.base,
230
+ entryPoints: files,
231
+ platform: "node",
232
+ target: "node24",
233
+ format,
234
+ allowOverwrite: true,
235
+ bundle: false,
236
+ plugins: [runCedarBabelTransformsPlugin],
237
+ outdir: cedarPaths.api.dist,
238
+ // setting this to 'true' will generate an external sourcemap x.js.map
239
+ // AND set the sourceMappingURL comment
240
+ // (setting it to 'external' will ONLY generate the file, but won't add the comment)
241
+ sourcemap: true
242
+ };
243
+ }
244
+ // Annotate the CommonJS export names for ESM import in node:
245
+ 0 && (module.exports = {
246
+ buildApi,
247
+ buildApiWithVite,
248
+ cleanApiBuild,
249
+ fixSourceMaps,
250
+ rebuildApi
251
+ });
@@ -0,0 +1,4 @@
1
+ export declare function applyContextWrapping(code: string, { projectIsEsm }?: {
2
+ projectIsEsm?: boolean;
3
+ }): string | null;
4
+ //# sourceMappingURL=esbuild-plugin-cedar-context-wrapping.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"esbuild-plugin-cedar-context-wrapping.d.ts","sourceRoot":"","sources":["../../../src/build/esbuild-plugin-cedar-context-wrapping.ts"],"names":[],"mappings":"AAOA,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,EACZ,EAAE,YAAoB,EAAE,GAAE;IAAE,YAAY,CAAC,EAAE,OAAO,CAAA;CAAO,GACxD,MAAM,GAAG,IAAI,CA0Cf"}
@@ -0,0 +1,59 @@
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 esbuild_plugin_cedar_context_wrapping_exports = {};
20
+ __export(esbuild_plugin_cedar_context_wrapping_exports, {
21
+ applyContextWrapping: () => applyContextWrapping
22
+ });
23
+ module.exports = __toCommonJS(esbuild_plugin_cedar_context_wrapping_exports);
24
+ function applyContextWrapping(code, { projectIsEsm = false } = {}) {
25
+ const handlerRe = /^export\s+(?:const|let|var)\s+handler(?:[^=]|=>)*?=(?![>=])/m;
26
+ const handlerMatch = handlerRe.exec(code);
27
+ if (!handlerMatch) {
28
+ return null;
29
+ }
30
+ const afterEquals = code.slice(handlerMatch.index + handlerMatch[0].length).trimStart();
31
+ const isAsync = /^async(?:\s*[\(\*]|\s+function)/.test(afterEquals);
32
+ const storePath = projectIsEsm ? "@cedarjs/context/dist/store.js" : "@cedarjs/context/dist/store";
33
+ const importStatement = `import { getAsyncStoreInstance as __rw_getAsyncStoreInstance } from '${storePath}'
34
+ `;
35
+ const handlerStart = handlerMatch.index;
36
+ const before = code.slice(0, handlerStart);
37
+ const after = code.slice(handlerStart);
38
+ const renamed = after.replace(handlerRe, "const __rw_handler =");
39
+ const wrappedHandler = `
40
+ export const handler = ${isAsync ? "async " : ""}(__rw_event, __rw__context) => {
41
+ // The store will be undefined if no context isolation has been performed yet
42
+ const __rw_contextStore = __rw_getAsyncStoreInstance().getStore()
43
+ if (__rw_contextStore === undefined) {
44
+ return __rw_getAsyncStoreInstance().run(
45
+ new Map(),
46
+ __rw_handler,
47
+ __rw_event,
48
+ __rw__context
49
+ )
50
+ }
51
+ return __rw_handler(__rw_event, __rw__context)
52
+ }
53
+ `;
54
+ return before + importStatement + renamed + wrappedHandler;
55
+ }
56
+ // Annotate the CommonJS export names for ESM import in node:
57
+ 0 && (module.exports = {
58
+ applyContextWrapping
59
+ });
@@ -0,0 +1,11 @@
1
+ type CLog = (typeof console)['log'];
2
+ /**
3
+ * An alternative to createLogger which supports the same logging levels
4
+ * but allows for full ANSI when printing to the console.
5
+ */
6
+ export declare const cliLogger: CLog & {
7
+ trace: CLog;
8
+ debug: CLog;
9
+ };
10
+ export {};
11
+ //# sourceMappingURL=cliLogger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cliLogger.d.ts","sourceRoot":"","sources":["../../src/cliLogger.ts"],"names":[],"mappings":"AAIA,KAAK,IAAI,GAAG,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,CAAC,CAAA;AAEnC;;;GAGG;AACH,eAAO,MAAM,SAAS,EAAE,IAAI,GAAG;IAC7B,KAAK,EAAE,IAAI,CAAA;IACX,KAAK,EAAE,IAAI,CAAA;CAGZ,CAAA"}
@@ -0,0 +1,36 @@
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 cliLogger_exports = {};
20
+ __export(cliLogger_exports, {
21
+ cliLogger: () => cliLogger
22
+ });
23
+ module.exports = __toCommonJS(cliLogger_exports);
24
+ var import_logger = require("@cedarjs/api/logger");
25
+ const logLevel = import_logger.defaultLoggerOptions.level;
26
+ const cliLogger = function(...data) {
27
+ console.log(...data);
28
+ };
29
+ cliLogger.trace = logLevel === "trace" ? console.log : () => {
30
+ };
31
+ cliLogger.debug = logLevel === "trace" || logLevel === "debug" ? console.log : () => {
32
+ };
33
+ // Annotate the CommonJS export names for ESM import in node:
34
+ 0 && (module.exports = {
35
+ cliLogger
36
+ });
@@ -0,0 +1,2 @@
1
+ export declare const shutdownPort: (port: number, method?: "tcp" | "udp") => Promise<void>;
2
+ //# sourceMappingURL=dev.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/dev.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,EAAE,SAAQ,KAAK,GAAG,KAAa,kBAEvE,CAAA"}
@@ -0,0 +1,41 @@
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 dev_exports = {};
30
+ __export(dev_exports, {
31
+ shutdownPort: () => shutdownPort
32
+ });
33
+ module.exports = __toCommonJS(dev_exports);
34
+ var import_kill_port = __toESM(require("kill-port"), 1);
35
+ const shutdownPort = (port, method = "tcp") => {
36
+ return (0, import_kill_port.default)(port, method);
37
+ };
38
+ // Annotate the CommonJS export names for ESM import in node:
39
+ 0 && (module.exports = {
40
+ shutdownPort
41
+ });
@@ -0,0 +1,56 @@
1
+ import { type Options as FastGlobOptions } from 'fast-glob';
2
+ export declare const findCells: (cwd?: string) => string[];
3
+ export declare const findPages: (cwd?: string) => string[];
4
+ /**
5
+ * This function finds all modules in the 'web' and 'api' directories excluding 'node_modules' and Cell files.
6
+ * Cell files are also directory named modules but they have their special type mirror file, so they are ignored.
7
+ *
8
+ * @param {string} cwd - The directory path to start searching from. By default, it is the base path of the project.
9
+ * @returns {Array} modules - An array of absolute paths for the found modules.
10
+ *
11
+ * @example
12
+ * // Assuming the base directory of your project is '/Users/user/myproject'
13
+ * findDirectoryNamedModules('/Users/user/myproject');
14
+ * // This will return an array with the absolute paths of all matching files, e.g.:
15
+ * // ['/Users/user/myproject/web/src/components/Author/Author.tsx', '/Users/user/myproject/web/src/pages/AboutPage/AboutPage.tsx']
16
+ */
17
+ export declare const findDirectoryNamedModules: (cwd?: string) => string[];
18
+ export declare const findGraphQLSchemas: (cwd?: string) => string[];
19
+ export declare const findApiFiles: (cwd?: string) => string[];
20
+ export declare const findWebFiles: (cwd?: string) => string[];
21
+ export declare const findApiServerFunctions: (cwd?: string) => string[];
22
+ export declare const findApiDistFunctions: (params: {
23
+ cwd: string;
24
+ options?: FastGlobOptions;
25
+ discoverFunctionsGlob?: string | string[];
26
+ }) => string[];
27
+ export declare const findRouteHooksSrc: (cwd?: string) => string[];
28
+ export declare const isCellFile: (p: string) => boolean;
29
+ export declare const findScripts: (cwd?: string) => string[];
30
+ export declare const isPageFile: (p: string) => boolean;
31
+ /**
32
+ * This function checks if the given path belongs to a directory named module.
33
+ * A directory named module is where the filename (without extension) is the same as the directory it is in.
34
+ *
35
+ * @param {string} p - The absolute path of the file.
36
+ * @returns {boolean} - Returns true if the path belongs to a directory named module, false otherwise.
37
+ *
38
+ * @example
39
+ * isDirectoryNamedModuleFile('/Users/user/myproject/web/src/components/Author/Author.tsx');
40
+ * // Returns: true
41
+ *
42
+ * isDirectoryNamedModuleFile('/Users/user/myproject/web/src/components/Author/AuthorInfo.tsx');
43
+ * // Returns: false
44
+ */
45
+ export declare const isDirectoryNamedModuleFile: (p: string) => boolean;
46
+ export declare const isGraphQLSchemaFile: (p: string) => boolean;
47
+ /**
48
+ * The following patterns are supported for api functions:
49
+ *
50
+ * 1. a module at the top level: `/graphql.js`
51
+ * 2. a module in a folder with a module of the same name: `/health/health.js`
52
+ * 3. a module in a folder named index: `/x/index.js`
53
+ */
54
+ export declare const isApiFunction: (p: string, functionsPath: string) => boolean;
55
+ export declare const isFileInsideFolder: (filePath: string, folderPath: string) => boolean;
56
+ //# sourceMappingURL=files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../src/files.ts"],"names":[],"mappings":"AAEA,OAAW,EAAE,KAAK,OAAO,IAAI,eAAe,EAAE,MAAM,WAAW,CAAA;AAM/D,eAAO,MAAM,SAAS,GAAI,MAAK,MAA2B,aAOzD,CAAA;AAED,eAAO,MAAM,SAAS,GAAI,MAAK,MAA6B,aAQ3D,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,yBAAyB,GAAI,MAAK,MAAwB,aAUtE,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,MAAK,MAA+B,aAItE,CAAA;AASD,eAAO,MAAM,YAAY,GAAI,MAAK,MAA2B,aAO5D,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,MAAK,MAA2B,aAY5D,CAAA;AAED,eAAO,MAAM,sBAAsB,GACjC,MAAK,MAAiC,aAUvC,CAAA;AAKD,eAAO,MAAM,oBAAoB,GAAI,QAAQ;IAC3C,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,CAAC,EAAE,eAAe,CAAA;IACzB,qBAAqB,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;CAC1C,aAcA,CAAA;AAED,eAAO,MAAM,iBAAiB,GAAI,MAAK,MAA2B,aAKjE,CAAA;AAED,eAAO,MAAM,UAAU,GAAI,GAAG,MAAM,YA6BnC,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,MAAK,MAA2B,aAM3D,CAAA;AAED,eAAO,MAAM,UAAU,GAAI,GAAG,MAAM,YAoBnC,CAAA;AACD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,0BAA0B,GAAI,GAAG,MAAM,YAGnD,CAAA;AAED,eAAO,MAAM,mBAAmB,GAAI,GAAG,MAAM,YAQ5C,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,GAAI,GAAG,MAAM,EAAE,eAAe,MAAM,YAc7D,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,UAAU,MAAM,EAAE,YAAY,MAAM,YAYtE,CAAA"}