@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.
- package/dist/ast.d.ts +0 -1
- package/dist/ast.d.ts.map +1 -1
- package/dist/ast.js +0 -21
- package/dist/build/api.d.ts +0 -2
- package/dist/build/api.d.ts.map +1 -1
- package/dist/build/api.js +39 -202
- package/dist/build/esbuild-plugin-cedar-context-wrapping.d.ts +4 -0
- package/dist/build/esbuild-plugin-cedar-context-wrapping.d.ts.map +1 -0
- package/dist/build/{esbuild-plugin-handler-als-wrapping.js → esbuild-plugin-cedar-context-wrapping.js} +12 -12
- package/dist/cjs/ast.d.ts +26 -0
- package/dist/cjs/ast.d.ts.map +1 -0
- package/dist/cjs/ast.js +201 -0
- package/dist/cjs/build/api.d.ts +7 -0
- package/dist/cjs/build/api.d.ts.map +1 -0
- package/dist/cjs/build/api.js +251 -0
- package/dist/cjs/build/esbuild-plugin-cedar-context-wrapping.d.ts +4 -0
- package/dist/cjs/build/esbuild-plugin-cedar-context-wrapping.d.ts.map +1 -0
- package/dist/cjs/build/esbuild-plugin-cedar-context-wrapping.js +59 -0
- package/dist/cjs/cliLogger.d.ts +11 -0
- package/dist/cjs/cliLogger.d.ts.map +1 -0
- package/dist/cjs/cliLogger.js +36 -0
- package/dist/cjs/dev.d.ts +2 -0
- package/dist/cjs/dev.d.ts.map +1 -0
- package/dist/cjs/dev.js +41 -0
- package/dist/cjs/files.d.ts +56 -0
- package/dist/cjs/files.d.ts.map +1 -0
- package/dist/cjs/files.js +230 -0
- package/dist/cjs/generate/clientPreset.d.ts +17 -0
- package/dist/cjs/generate/clientPreset.d.ts.map +1 -0
- package/dist/cjs/generate/clientPreset.js +84 -0
- package/dist/cjs/generate/generate.d.ts +10 -0
- package/dist/cjs/generate/generate.d.ts.map +1 -0
- package/dist/cjs/generate/generate.js +97 -0
- package/dist/cjs/generate/gqlormSchema.d.ts +113 -0
- package/dist/cjs/generate/gqlormSchema.d.ts.map +1 -0
- package/dist/cjs/generate/gqlormSchema.js +1061 -0
- package/dist/cjs/generate/graphqlCodeGen.d.ts +16 -0
- package/dist/cjs/generate/graphqlCodeGen.d.ts.map +1 -0
- package/dist/cjs/generate/graphqlCodeGen.js +380 -0
- package/dist/cjs/generate/graphqlSchema.d.ts +8 -0
- package/dist/cjs/generate/graphqlSchema.d.ts.map +1 -0
- package/dist/cjs/generate/graphqlSchema.js +157 -0
- package/dist/cjs/generate/plugins/rw-typescript-resolvers/index.d.ts +7 -0
- package/dist/cjs/generate/plugins/rw-typescript-resolvers/index.d.ts.map +1 -0
- package/dist/cjs/generate/plugins/rw-typescript-resolvers/index.js +65 -0
- package/dist/cjs/generate/plugins/rw-typescript-resolvers/visitor.d.ts +10 -0
- package/dist/cjs/generate/plugins/rw-typescript-resolvers/visitor.d.ts.map +1 -0
- package/dist/cjs/generate/plugins/rw-typescript-resolvers/visitor.js +92 -0
- package/dist/cjs/generate/possibleTypes.d.ts +36 -0
- package/dist/cjs/generate/possibleTypes.d.ts.map +1 -0
- package/dist/cjs/generate/possibleTypes.js +106 -0
- package/dist/cjs/generate/templates/all-currentUser.d.ts.template +30 -0
- package/dist/cjs/generate/templates/all-gqlorm.d.ts.template +7 -0
- package/dist/cjs/generate/templates/api-globImports.d.ts.template +9 -0
- package/dist/cjs/generate/templates/api-globalContext.d.ts.template +7 -0
- package/dist/cjs/generate/templates/api-scenarios.d.ts.template +10 -0
- package/dist/cjs/generate/templates/api-test-globals.d.ts.template +5 -0
- package/dist/cjs/generate/templates/mirror-cell.d.ts.template +13 -0
- package/dist/cjs/generate/templates/mirror-directoryNamedModule.d.ts.template +5 -0
- package/dist/cjs/generate/templates/web-routerRoutes.d.ts.template +20 -0
- package/dist/cjs/generate/templates/web-routesPages.d.ts.template +13 -0
- package/dist/cjs/generate/templates/web-test-globals.d.ts.template +7 -0
- package/dist/cjs/generate/templates.d.ts +6 -0
- package/dist/cjs/generate/templates.d.ts.map +1 -0
- package/dist/cjs/generate/templates.js +68 -0
- package/dist/cjs/generate/trustedDocuments.d.ts +3 -0
- package/dist/cjs/generate/trustedDocuments.d.ts.map +1 -0
- package/dist/cjs/generate/trustedDocuments.js +95 -0
- package/dist/cjs/generate/typeDefinitions.d.ts +31 -0
- package/dist/cjs/generate/typeDefinitions.d.ts.map +1 -0
- package/dist/cjs/generate/typeDefinitions.js +372 -0
- package/dist/cjs/generate/types.d.ts +6 -0
- package/dist/cjs/generate/types.d.ts.map +1 -0
- package/dist/cjs/generate/types.js +16 -0
- package/dist/cjs/generate/watch.d.ts +3 -0
- package/dist/cjs/generate/watch.d.ts.map +1 -0
- package/dist/cjs/generate/watch.js +132 -0
- package/dist/cjs/gql.d.ts +14 -0
- package/dist/cjs/gql.d.ts.map +1 -0
- package/dist/cjs/gql.js +108 -0
- package/dist/cjs/index.d.ts +11 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +49 -0
- package/dist/cjs/jsx.d.ts +16 -0
- package/dist/cjs/jsx.d.ts.map +1 -0
- package/dist/cjs/jsx.js +101 -0
- package/dist/cjs/jsxAttributeValue.d.ts +2 -0
- package/dist/cjs/jsxAttributeValue.d.ts.map +1 -0
- package/dist/cjs/jsxAttributeValue.js +129 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/project.d.ts +8 -0
- package/dist/cjs/project.d.ts.map +1 -0
- package/dist/cjs/project.js +82 -0
- package/dist/cjs/routes.d.ts +42 -0
- package/dist/cjs/routes.d.ts.map +1 -0
- package/dist/cjs/routes.js +111 -0
- package/dist/cjs/ts2js.d.ts +40 -0
- package/dist/cjs/ts2js.d.ts.map +1 -0
- package/dist/cjs/ts2js.js +159 -0
- package/dist/cjs/validateSchema.d.ts +14 -0
- package/dist/cjs/validateSchema.d.ts.map +1 -0
- package/dist/cjs/validateSchema.js +195 -0
- package/dist/generate/clientPreset.d.ts.map +1 -1
- package/dist/generate/clientPreset.js +3 -10
- package/dist/generate/typeDefinitions.d.ts.map +1 -1
- package/dist/generate/typeDefinitions.js +1 -15
- package/dist/gql.d.ts +0 -20
- package/dist/gql.d.ts.map +1 -1
- package/dist/gql.js +0 -24
- package/package.json +80 -48
- package/dist/build/api-graphql-transforms.d.ts +0 -34
- package/dist/build/api-graphql-transforms.d.ts.map +0 -1
- package/dist/build/api-graphql-transforms.js +0 -119
- package/dist/build/auto-import.d.ts +0 -10
- package/dist/build/auto-import.d.ts.map +0 -1
- package/dist/build/auto-import.js +0 -120
- package/dist/build/directory-named-import.d.ts +0 -2
- package/dist/build/directory-named-import.d.ts.map +0 -1
- package/dist/build/directory-named-import.js +0 -26
- package/dist/build/esbuild-plugin-api-graphql.d.ts +0 -6
- package/dist/build/esbuild-plugin-api-graphql.d.ts.map +0 -1
- package/dist/build/esbuild-plugin-api-graphql.js +0 -80
- package/dist/build/esbuild-plugin-cedar-otel-wrapping.d.ts +0 -13
- package/dist/build/esbuild-plugin-cedar-otel-wrapping.d.ts.map +0 -1
- package/dist/build/esbuild-plugin-cedar-otel-wrapping.js +0 -180
- package/dist/build/esbuild-plugin-handler-als-wrapping.d.ts +0 -4
- package/dist/build/esbuild-plugin-handler-als-wrapping.d.ts.map +0 -1
- package/dist/build/esm-extensions.d.ts +0 -33
- package/dist/build/esm-extensions.d.ts.map +0 -1
- package/dist/build/esm-extensions.js +0 -37
- package/dist/build/import-dir.d.ts +0 -22
- package/dist/build/import-dir.d.ts.map +0 -1
- package/dist/build/import-dir.js +0 -54
- package/dist/build/job-path-injector.d.ts +0 -15
- package/dist/build/job-path-injector.d.ts.map +0 -1
- package/dist/build/job-path-injector.js +0 -69
- package/dist/build/src-alias.d.ts +0 -14
- package/dist/build/src-alias.d.ts.map +0 -1
- package/dist/build/src-alias.js +0 -17
- package/dist/build/tsconfig-paths.d.ts +0 -2
- package/dist/build/tsconfig-paths.d.ts.map +0 -1
- package/dist/build/tsconfig-paths.js +0 -72
- package/dist/generate/templates/mirror-cell-fragment.d.ts.template +0 -18
package/dist/ast.d.ts
CHANGED
|
@@ -17,7 +17,6 @@ export declare const getNamedExports: (ast: types.Node) => NamedExports[];
|
|
|
17
17
|
*/
|
|
18
18
|
export declare const getGqlQueries: (ast: types.Node) => string[];
|
|
19
19
|
export declare const getCellGqlQuery: (ast: types.Node) => undefined;
|
|
20
|
-
export declare const getCellGqlFragment: (ast: types.Node) => undefined;
|
|
21
20
|
export declare const hasDefaultExport: (ast: types.Node) => boolean;
|
|
22
21
|
export declare const getDefaultExportLocation: (ast: types.Node) => {
|
|
23
22
|
line: number;
|
package/dist/ast.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../src/ast.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAmBnC,eAAO,MAAM,SAAS,GAAI,UAAU,MAAM,KAAG,KAAK,CAAC,IAyBlD,CAAA;AAED,UAAU,YAAY;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,WAAW,GAAG,UAAU,GAAG,UAAU,GAAG,OAAO,CAAA;IACrD,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,CAAA;QACZ,MAAM,EAAE,MAAM,CAAA;KACf,CAAA;CACF;AACD;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,KAAK,KAAK,CAAC,IAAI,KAAG,YAAY,EA4D7D,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,GAAI,KAAK,KAAK,CAAC,IAAI,aAY5C,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,KAAK,KAAK,CAAC,IAAI,cA8B9C,CAAA;AAED,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../src/ast.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAmBnC,eAAO,MAAM,SAAS,GAAI,UAAU,MAAM,KAAG,KAAK,CAAC,IAyBlD,CAAA;AAED,UAAU,YAAY;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,WAAW,GAAG,UAAU,GAAG,UAAU,GAAG,OAAO,CAAA;IACrD,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,CAAA;QACZ,MAAM,EAAE,MAAM,CAAA;KACf,CAAA;CACF;AACD;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,KAAK,KAAK,CAAC,IAAI,KAAG,YAAY,EA4D7D,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,GAAI,KAAK,KAAK,CAAC,IAAI,aAY5C,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,KAAK,KAAK,CAAC,IAAI,cA8B9C,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,KAAK,KAAK,CAAC,IAAI,KAAG,OASlD,CAAA;AAED,eAAO,MAAM,wBAAwB,GACnC,KAAK,KAAK,CAAC,IAAI,KACd;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,IA0CrC,CAAA"}
|
package/dist/ast.js
CHANGED
|
@@ -115,26 +115,6 @@ const getCellGqlQuery = (ast) => {
|
|
|
115
115
|
});
|
|
116
116
|
return cellQuery;
|
|
117
117
|
};
|
|
118
|
-
const getCellGqlFragment = (ast) => {
|
|
119
|
-
let cellFragment = void 0;
|
|
120
|
-
traverse(ast, {
|
|
121
|
-
ExportNamedDeclaration({ node }) {
|
|
122
|
-
if (node.exportKind === "value" && types.isVariableDeclaration(node.declaration)) {
|
|
123
|
-
const exportedFragmentNode = node.declaration.declarations.find(
|
|
124
|
-
(d) => {
|
|
125
|
-
return types.isIdentifier(d.id) && d.id.name === "FRAGMENT" && types.isTaggedTemplateExpression(d.init);
|
|
126
|
-
}
|
|
127
|
-
);
|
|
128
|
-
if (exportedFragmentNode) {
|
|
129
|
-
const templateExpression = exportedFragmentNode.init;
|
|
130
|
-
cellFragment = templateExpression.quasi.quasis[0].value.raw;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
return cellFragment;
|
|
137
|
-
};
|
|
138
118
|
const hasDefaultExport = (ast) => {
|
|
139
119
|
let exported = false;
|
|
140
120
|
traverse(ast, {
|
|
@@ -174,7 +154,6 @@ const getDefaultExportLocation = (ast) => {
|
|
|
174
154
|
};
|
|
175
155
|
export {
|
|
176
156
|
fileToAst,
|
|
177
|
-
getCellGqlFragment,
|
|
178
157
|
getCellGqlQuery,
|
|
179
158
|
getDefaultExportLocation,
|
|
180
159
|
getGqlQueries,
|
package/dist/build/api.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import type { BuildOptions } from 'esbuild';
|
|
2
|
-
export { applySrcAlias } from './src-alias.js';
|
|
3
|
-
export { applyEsmExtensions } from './esm-extensions.js';
|
|
4
2
|
export declare const buildApi: () => Promise<import("esbuild").BuildResult<BuildOptions>>;
|
|
5
3
|
export declare const rebuildApi: () => Promise<import("esbuild").BuildResult<BuildOptions>>;
|
|
6
4
|
export declare const cleanApiBuild: () => Promise<void>;
|
package/dist/build/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/build/api.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAgB,YAAY,EAAe,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/build/api.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAgB,YAAY,EAAe,MAAM,SAAS,CAAA;AAiBtE,eAAO,MAAM,QAAQ,4DAIpB,CAAA;AAED,eAAO,MAAM,UAAU,4DAStB,CAAA;AAED,eAAO,MAAM,aAAa,qBAGzB,CAAA;AA8FD,eAAO,MAAM,gBAAgB,iHAqD5B,CAAA;AAcD,wBAAsB,aAAa,CACjC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAoDf"}
|
package/dist/build/api.js
CHANGED
|
@@ -1,42 +1,14 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { build, context } from "esbuild";
|
|
4
|
-
import MagicString from "magic-string";
|
|
5
4
|
import { build as viteBuild, normalizePath } from "vite";
|
|
6
|
-
import tsPathsMod from "vite-tsconfig-paths";
|
|
7
|
-
const tsconfigPaths = (
|
|
8
|
-
// @ts-expect-error – .default only exists at runtime in CJS double-wrap
|
|
9
|
-
// interop
|
|
10
|
-
tsPathsMod.default?.default || tsPathsMod.default || tsPathsMod
|
|
11
|
-
);
|
|
12
5
|
import {
|
|
13
|
-
|
|
14
|
-
getApiSideBabelPluginsForVite,
|
|
6
|
+
getApiSideBabelPlugins,
|
|
15
7
|
transformWithBabel
|
|
16
8
|
} from "@cedarjs/babel-config";
|
|
17
|
-
import {
|
|
18
|
-
getConfig,
|
|
19
|
-
getPaths,
|
|
20
|
-
projectSideIsEsm,
|
|
21
|
-
resolveFile
|
|
22
|
-
} from "@cedarjs/project-config";
|
|
9
|
+
import { getConfig, getPaths, projectSideIsEsm } from "@cedarjs/project-config";
|
|
23
10
|
import { findApiFiles } from "../files.js";
|
|
24
|
-
import {
|
|
25
|
-
applyGqlormInject,
|
|
26
|
-
applyGraphqlOptionsExtract
|
|
27
|
-
} from "./api-graphql-transforms.js";
|
|
28
|
-
import { applyAutoImports } from "./auto-import.js";
|
|
29
|
-
import { applyDirectoryNamedImport } from "./directory-named-import.js";
|
|
30
|
-
import { cedarApiGraphqlPlugin } from "./esbuild-plugin-api-graphql.js";
|
|
31
|
-
import { applyOtelWrapping } from "./esbuild-plugin-cedar-otel-wrapping.js";
|
|
32
|
-
import { applyHandlerAlsWrapping } from "./esbuild-plugin-handler-als-wrapping.js";
|
|
33
|
-
import { applyEsmExtensions } from "./esm-extensions.js";
|
|
34
|
-
import { applyImportDir } from "./import-dir.js";
|
|
35
|
-
import { applyJobPathInjector } from "./job-path-injector.js";
|
|
36
|
-
import { applySrcAlias } from "./src-alias.js";
|
|
37
|
-
import { applyTsconfigPaths } from "./tsconfig-paths.js";
|
|
38
|
-
import { applySrcAlias as applySrcAlias2 } from "./src-alias.js";
|
|
39
|
-
import { applyEsmExtensions as applyEsmExtensions2 } from "./esm-extensions.js";
|
|
11
|
+
import { applyContextWrapping } from "./esbuild-plugin-cedar-context-wrapping.js";
|
|
40
12
|
let BUILD_CTX = null;
|
|
41
13
|
const buildApi = async () => {
|
|
42
14
|
BUILD_CTX?.dispose();
|
|
@@ -60,124 +32,33 @@ const cleanApiBuild = async () => {
|
|
|
60
32
|
const runCedarBabelTransformsPlugin = {
|
|
61
33
|
name: "cedar-esbuild-babel-transform",
|
|
62
34
|
setup(build2) {
|
|
35
|
+
const cedarConfig = getConfig();
|
|
63
36
|
build2.onLoad({ filter: /\.(js|ts|tsx|jsx)$/ }, async (args) => {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
fileContents,
|
|
67
|
-
path.dirname(
|
|
68
|
-
path.relative(build2.initialOptions.absWorkingDir + "/src", args.path)
|
|
69
|
-
)
|
|
70
|
-
);
|
|
71
|
-
fileContents = applyTsconfigPaths(
|
|
37
|
+
const fileContents = await fs.promises.readFile(args.path, "utf-8");
|
|
38
|
+
const transformedCode = await transformWithBabel(
|
|
72
39
|
fileContents,
|
|
73
40
|
args.path,
|
|
74
|
-
|
|
41
|
+
getApiSideBabelPlugins({
|
|
42
|
+
openTelemetry: cedarConfig.experimental.opentelemetry.enabled && cedarConfig.experimental.opentelemetry.wrapApi,
|
|
43
|
+
projectIsEsm: projectSideIsEsm("api")
|
|
44
|
+
})
|
|
75
45
|
);
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
fileContents = applyJobPathInjector(fileContents, args.path, getPaths().api.jobs) ?? fileContents;
|
|
80
|
-
const normalizedPath = normalizePath(args.path);
|
|
81
|
-
const cedarPaths = getPaths();
|
|
82
|
-
const isEsm = projectSideIsEsm("api");
|
|
83
|
-
const apiBabelConfigPath = getApiSideBabelConfigPath();
|
|
84
|
-
let code = fileContents;
|
|
85
|
-
if (apiBabelConfigPath) {
|
|
86
|
-
const transformedCode = await transformWithBabel(
|
|
87
|
-
fileContents,
|
|
88
|
-
args.path,
|
|
89
|
-
getApiSideBabelPluginsForVite(),
|
|
90
|
-
"inline",
|
|
91
|
-
true
|
|
46
|
+
if (transformedCode?.code) {
|
|
47
|
+
const functionsDir = normalizePath(
|
|
48
|
+
path.join(getPaths().api.src, "functions")
|
|
92
49
|
);
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
const functionsDir = normalizePath(cedarPaths.api.functions);
|
|
102
|
-
if (normalizedPath.startsWith(functionsDir + "/")) {
|
|
103
|
-
code = applyHandlerAlsWrapping(code, {
|
|
104
|
-
projectIsEsm: isEsm
|
|
105
|
-
}) ?? code;
|
|
106
|
-
}
|
|
107
|
-
if (normalizedPath.startsWith(normalizePath(cedarPaths.api.src) + "/")) {
|
|
108
|
-
code = applyOtelWrapping(code, args.path, cedarPaths.api.src) ?? code;
|
|
50
|
+
const code = normalizePath(args.path).startsWith(functionsDir + "/") ? applyContextWrapping(transformedCode.code, {
|
|
51
|
+
projectIsEsm: projectSideIsEsm("api")
|
|
52
|
+
}) ?? transformedCode.code : transformedCode.code;
|
|
53
|
+
return {
|
|
54
|
+
contents: code,
|
|
55
|
+
loader: "js"
|
|
56
|
+
};
|
|
109
57
|
}
|
|
110
|
-
|
|
111
|
-
contents: code,
|
|
112
|
-
// Babel output is always plain JS. Without Babel the contents are
|
|
113
|
-
// still TypeScript/JSX, so pick the loader matching the file's
|
|
114
|
-
// extension and let esbuild do the stripping.
|
|
115
|
-
loader: apiBabelConfigPath ? "js" : getEsbuildLoader(args.path)
|
|
116
|
-
};
|
|
58
|
+
throw new Error(`Could not transform file: ${args.path}`);
|
|
117
59
|
});
|
|
118
60
|
}
|
|
119
61
|
};
|
|
120
|
-
function getEsbuildLoader(filePath) {
|
|
121
|
-
switch (path.extname(filePath)) {
|
|
122
|
-
case ".ts":
|
|
123
|
-
return "ts";
|
|
124
|
-
case ".tsx":
|
|
125
|
-
return "tsx";
|
|
126
|
-
case ".jsx":
|
|
127
|
-
return "jsx";
|
|
128
|
-
default:
|
|
129
|
-
return "js";
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
function createImportDirVitePlugin() {
|
|
133
|
-
return {
|
|
134
|
-
name: "cedar-internal-import-dir",
|
|
135
|
-
enforce: "pre",
|
|
136
|
-
transform(code, id) {
|
|
137
|
-
if (!/\.(js|ts|tsx|jsx)$/.test(id)) {
|
|
138
|
-
return null;
|
|
139
|
-
}
|
|
140
|
-
if (id.includes("node_modules")) {
|
|
141
|
-
return null;
|
|
142
|
-
}
|
|
143
|
-
const result = applyImportDir(code, id);
|
|
144
|
-
if (!result) {
|
|
145
|
-
return null;
|
|
146
|
-
}
|
|
147
|
-
return { code: result.code, map: result.map };
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
function createDirectoryNamedImportVitePlugin() {
|
|
152
|
-
return {
|
|
153
|
-
name: "cedar-internal-directory-named-import",
|
|
154
|
-
enforce: "pre",
|
|
155
|
-
resolveId(id, importer) {
|
|
156
|
-
if (!id.startsWith(".") || !importer) {
|
|
157
|
-
return null;
|
|
158
|
-
}
|
|
159
|
-
if (importer.includes("node_modules")) {
|
|
160
|
-
return null;
|
|
161
|
-
}
|
|
162
|
-
const absolutePath = path.resolve(path.dirname(importer), id);
|
|
163
|
-
if (resolveFile(absolutePath)) {
|
|
164
|
-
return null;
|
|
165
|
-
}
|
|
166
|
-
const indexPath = path.join(absolutePath, "index");
|
|
167
|
-
const resolvedIndex = resolveFile(indexPath);
|
|
168
|
-
if (resolvedIndex) {
|
|
169
|
-
return normalizePath(resolvedIndex);
|
|
170
|
-
}
|
|
171
|
-
const basename = path.basename(absolutePath);
|
|
172
|
-
const dirNamedPath = path.join(absolutePath, basename);
|
|
173
|
-
const resolvedDirNamed = resolveFile(dirNamedPath);
|
|
174
|
-
if (resolvedDirNamed) {
|
|
175
|
-
return normalizePath(resolvedDirNamed);
|
|
176
|
-
}
|
|
177
|
-
return null;
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
62
|
function createCedarViteApiPlugin() {
|
|
182
63
|
const cedarConfig = getConfig();
|
|
183
64
|
const isEsm = projectSideIsEsm("api");
|
|
@@ -195,55 +76,28 @@ function createCedarViteApiPlugin() {
|
|
|
195
76
|
if (!normalizePath(id).startsWith(normalizePath(cedarPaths.api.base))) {
|
|
196
77
|
return null;
|
|
197
78
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
sourceCode = applySrcAlias(
|
|
201
|
-
sourceCode,
|
|
202
|
-
path.dirname(path.relative(cedarPaths.api.src, id))
|
|
203
|
-
);
|
|
204
|
-
sourceCode = applyAutoImports(sourceCode);
|
|
205
|
-
sourceCode = applyJobPathInjector(sourceCode, id, cedarPaths.api.jobs) ?? sourceCode;
|
|
206
|
-
if (normalizedId.endsWith("/graphql.ts") || normalizedId.endsWith("/graphql.js")) {
|
|
207
|
-
sourceCode = applyGraphqlOptionsExtract(sourceCode) ?? sourceCode;
|
|
208
|
-
sourceCode = applyGqlormInject(sourceCode, id) ?? sourceCode;
|
|
209
|
-
}
|
|
210
|
-
const apiBabelConfigPath = getApiSideBabelConfigPath();
|
|
211
|
-
const transformedCode = apiBabelConfigPath ? await transformWithBabel(
|
|
212
|
-
sourceCode,
|
|
79
|
+
const transformedCode = await transformWithBabel(
|
|
80
|
+
code,
|
|
213
81
|
id,
|
|
214
|
-
|
|
215
|
-
|
|
82
|
+
getApiSideBabelPlugins({
|
|
83
|
+
openTelemetry: cedarConfig.experimental.opentelemetry.enabled && cedarConfig.experimental.opentelemetry.wrapApi,
|
|
84
|
+
projectIsEsm: isEsm
|
|
85
|
+
}),
|
|
216
86
|
true
|
|
217
|
-
)
|
|
218
|
-
if (
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
outputCode = applyOtelWrapping(outputCode, id, cedarPaths.api.src) ?? outputCode;
|
|
224
|
-
}
|
|
225
|
-
if (isEsm) {
|
|
226
|
-
outputCode = applyEsmExtensions(outputCode, id);
|
|
227
|
-
}
|
|
228
|
-
const functionsDir = normalizePath(cedarPaths.api.functions);
|
|
229
|
-
if (normalizedId.startsWith(functionsDir + "/")) {
|
|
230
|
-
outputCode = applyHandlerAlsWrapping(outputCode, {
|
|
87
|
+
);
|
|
88
|
+
if (transformedCode?.code) {
|
|
89
|
+
const functionsDir = normalizePath(
|
|
90
|
+
path.join(cedarPaths.api.src, "functions")
|
|
91
|
+
);
|
|
92
|
+
const code2 = normalizePath(id).startsWith(functionsDir + "/") ? applyContextWrapping(transformedCode.code, {
|
|
231
93
|
projectIsEsm: isEsm
|
|
232
|
-
}) ??
|
|
233
|
-
}
|
|
234
|
-
if (!transformedCode) {
|
|
235
|
-
if (outputCode === code) {
|
|
236
|
-
return null;
|
|
237
|
-
}
|
|
94
|
+
}) ?? transformedCode.code : transformedCode.code;
|
|
238
95
|
return {
|
|
239
|
-
code:
|
|
240
|
-
map:
|
|
96
|
+
code: code2,
|
|
97
|
+
map: transformedCode.map ?? null
|
|
241
98
|
};
|
|
242
99
|
}
|
|
243
|
-
|
|
244
|
-
code: outputCode,
|
|
245
|
-
map: transformedCode.map ?? null
|
|
246
|
-
};
|
|
100
|
+
throw new Error(`Could not transform file: ${id}`);
|
|
247
101
|
}
|
|
248
102
|
};
|
|
249
103
|
}
|
|
@@ -287,19 +141,7 @@ const buildApiWithVite = async () => {
|
|
|
287
141
|
}
|
|
288
142
|
}
|
|
289
143
|
},
|
|
290
|
-
|
|
291
|
-
// are expanded before Babel sees the code. The Babel import-dir plugin is
|
|
292
|
-
// not part of getApiSideBabelPluginsForVite(); this inline Vite plugin is
|
|
293
|
-
// its replacement for this code path (both CJS and ESM output via Rollup).
|
|
294
|
-
// tsconfigPaths resolves user-defined tsconfig.json `paths` aliases; it
|
|
295
|
-
// replaces the Babel module-resolver's tsconfig-paths handling for this
|
|
296
|
-
// code path.
|
|
297
|
-
plugins: [
|
|
298
|
-
tsconfigPaths(),
|
|
299
|
-
createImportDirVitePlugin(),
|
|
300
|
-
createDirectoryNamedImportVitePlugin(),
|
|
301
|
-
createCedarViteApiPlugin()
|
|
302
|
-
]
|
|
144
|
+
plugins: [createCedarViteApiPlugin()]
|
|
303
145
|
});
|
|
304
146
|
};
|
|
305
147
|
const transpileApi = async (files) => {
|
|
@@ -357,10 +199,7 @@ function getEsbuildOptions(files) {
|
|
|
357
199
|
format,
|
|
358
200
|
allowOverwrite: true,
|
|
359
201
|
bundle: false,
|
|
360
|
-
|
|
361
|
-
// come first so it claims graphql.ts before runCedarBabelTransformsPlugin
|
|
362
|
-
// (broad filter) can. See the NOTE on cedarApiGraphqlPlugin.
|
|
363
|
-
plugins: [cedarApiGraphqlPlugin, runCedarBabelTransformsPlugin],
|
|
202
|
+
plugins: [runCedarBabelTransformsPlugin],
|
|
364
203
|
outdir: cedarPaths.api.dist,
|
|
365
204
|
// setting this to 'true' will generate an external sourcemap x.js.map
|
|
366
205
|
// AND set the sourceMappingURL comment
|
|
@@ -369,8 +208,6 @@ function getEsbuildOptions(files) {
|
|
|
369
208
|
};
|
|
370
209
|
}
|
|
371
210
|
export {
|
|
372
|
-
applyEsmExtensions2 as applyEsmExtensions,
|
|
373
|
-
applySrcAlias2 as applySrcAlias,
|
|
374
211
|
buildApi,
|
|
375
212
|
buildApiWithVite,
|
|
376
213
|
cleanApiBuild,
|
|
@@ -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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function
|
|
1
|
+
function applyContextWrapping(code, { projectIsEsm = false } = {}) {
|
|
2
2
|
const handlerRe = /^export\s+(?:const|let|var)\s+handler(?:[^=]|=>)*?=(?![>=])/m;
|
|
3
3
|
const handlerMatch = handlerRe.exec(code);
|
|
4
4
|
if (!handlerMatch) {
|
|
@@ -7,29 +7,29 @@ function applyHandlerAlsWrapping(code, { projectIsEsm = false } = {}) {
|
|
|
7
7
|
const afterEquals = code.slice(handlerMatch.index + handlerMatch[0].length).trimStart();
|
|
8
8
|
const isAsync = /^async(?:\s*[\(\*]|\s+function)/.test(afterEquals);
|
|
9
9
|
const storePath = projectIsEsm ? "@cedarjs/context/dist/store.js" : "@cedarjs/context/dist/store";
|
|
10
|
-
const importStatement = `import { getAsyncStoreInstance as
|
|
10
|
+
const importStatement = `import { getAsyncStoreInstance as __rw_getAsyncStoreInstance } from '${storePath}'
|
|
11
11
|
`;
|
|
12
12
|
const handlerStart = handlerMatch.index;
|
|
13
13
|
const before = code.slice(0, handlerStart);
|
|
14
14
|
const after = code.slice(handlerStart);
|
|
15
|
-
const renamed = after.replace(handlerRe, "const
|
|
15
|
+
const renamed = after.replace(handlerRe, "const __rw_handler =");
|
|
16
16
|
const wrappedHandler = `
|
|
17
|
-
export const handler = ${isAsync ? "async " : ""}(
|
|
17
|
+
export const handler = ${isAsync ? "async " : ""}(__rw_event, __rw__context) => {
|
|
18
18
|
// The store will be undefined if no context isolation has been performed yet
|
|
19
|
-
const
|
|
20
|
-
if (
|
|
21
|
-
return
|
|
19
|
+
const __rw_contextStore = __rw_getAsyncStoreInstance().getStore()
|
|
20
|
+
if (__rw_contextStore === undefined) {
|
|
21
|
+
return __rw_getAsyncStoreInstance().run(
|
|
22
22
|
new Map(),
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
__rw_handler,
|
|
24
|
+
__rw_event,
|
|
25
|
+
__rw__context
|
|
26
26
|
)
|
|
27
27
|
}
|
|
28
|
-
return
|
|
28
|
+
return __rw_handler(__rw_event, __rw__context)
|
|
29
29
|
}
|
|
30
30
|
`;
|
|
31
31
|
return before + importStatement + renamed + wrappedHandler;
|
|
32
32
|
}
|
|
33
33
|
export {
|
|
34
|
-
|
|
34
|
+
applyContextWrapping
|
|
35
35
|
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { types } from '@babel/core';
|
|
2
|
+
export declare const fileToAst: (filePath: string) => types.Node;
|
|
3
|
+
interface NamedExports {
|
|
4
|
+
name: string;
|
|
5
|
+
type: 're-export' | 'variable' | 'function' | 'class';
|
|
6
|
+
location: {
|
|
7
|
+
line: number;
|
|
8
|
+
column: number;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* get all the named exports in a given piece of code.
|
|
13
|
+
*/
|
|
14
|
+
export declare const getNamedExports: (ast: types.Node) => NamedExports[];
|
|
15
|
+
/**
|
|
16
|
+
* get all the gql queries from the supplied code
|
|
17
|
+
*/
|
|
18
|
+
export declare const getGqlQueries: (ast: types.Node) => string[];
|
|
19
|
+
export declare const getCellGqlQuery: (ast: types.Node) => undefined;
|
|
20
|
+
export declare const hasDefaultExport: (ast: types.Node) => boolean;
|
|
21
|
+
export declare const getDefaultExportLocation: (ast: types.Node) => {
|
|
22
|
+
line: number;
|
|
23
|
+
column: number;
|
|
24
|
+
} | null;
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=ast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../src/ast.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAmBnC,eAAO,MAAM,SAAS,GAAI,UAAU,MAAM,KAAG,KAAK,CAAC,IAyBlD,CAAA;AAED,UAAU,YAAY;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,WAAW,GAAG,UAAU,GAAG,UAAU,GAAG,OAAO,CAAA;IACrD,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,CAAA;QACZ,MAAM,EAAE,MAAM,CAAA;KACf,CAAA;CACF;AACD;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,KAAK,KAAK,CAAC,IAAI,KAAG,YAAY,EA4D7D,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,GAAI,KAAK,KAAK,CAAC,IAAI,aAY5C,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,KAAK,KAAK,CAAC,IAAI,cA8B9C,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,KAAK,KAAK,CAAC,IAAI,KAAG,OASlD,CAAA;AAED,eAAO,MAAM,wBAAwB,GACnC,KAAK,KAAK,CAAC,IAAI,KACd;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,IA0CrC,CAAA"}
|
package/dist/cjs/ast.js
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
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 ast_exports = {};
|
|
30
|
+
__export(ast_exports, {
|
|
31
|
+
fileToAst: () => fileToAst,
|
|
32
|
+
getCellGqlQuery: () => getCellGqlQuery,
|
|
33
|
+
getDefaultExportLocation: () => getDefaultExportLocation,
|
|
34
|
+
getGqlQueries: () => getGqlQueries,
|
|
35
|
+
getNamedExports: () => getNamedExports,
|
|
36
|
+
hasDefaultExport: () => hasDefaultExport
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(ast_exports);
|
|
39
|
+
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
40
|
+
var import_path = __toESM(require("path"), 1);
|
|
41
|
+
var import_core = require("@babel/core");
|
|
42
|
+
var import_parser = require("@babel/parser");
|
|
43
|
+
var import_traverse = __toESM(require("@babel/traverse"), 1);
|
|
44
|
+
var import_ansis = __toESM(require("ansis"), 1);
|
|
45
|
+
var import_project_config = require("@cedarjs/project-config");
|
|
46
|
+
var import_files = require("./files.js");
|
|
47
|
+
const traverse = import_traverse.default.default || import_traverse.default;
|
|
48
|
+
const fileToAst = (filePath) => {
|
|
49
|
+
const code = import_node_fs.default.readFileSync(filePath, "utf-8");
|
|
50
|
+
const isJsxFile = import_path.default.extname(filePath).match(/[jt]sx$/) || (0, import_files.isFileInsideFolder)(filePath, (0, import_project_config.getPaths)().web.base);
|
|
51
|
+
const plugins = [
|
|
52
|
+
"typescript",
|
|
53
|
+
"nullishCoalescingOperator",
|
|
54
|
+
"objectRestSpread",
|
|
55
|
+
isJsxFile && "jsx"
|
|
56
|
+
].filter(Boolean);
|
|
57
|
+
try {
|
|
58
|
+
return (0, import_parser.parse)(code, {
|
|
59
|
+
sourceType: "module",
|
|
60
|
+
plugins
|
|
61
|
+
});
|
|
62
|
+
} catch (e) {
|
|
63
|
+
console.error(import_ansis.default.red(`Error parsing: ${filePath}`));
|
|
64
|
+
console.error(e);
|
|
65
|
+
throw new Error(e?.message);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
const getNamedExports = (ast) => {
|
|
69
|
+
const namedExports = [];
|
|
70
|
+
traverse(ast, {
|
|
71
|
+
ExportNamedDeclaration(path2) {
|
|
72
|
+
const specifiers = path2.node?.specifiers;
|
|
73
|
+
if (specifiers.length) {
|
|
74
|
+
for (const s of specifiers) {
|
|
75
|
+
const id = s.exported;
|
|
76
|
+
namedExports.push({
|
|
77
|
+
name: id.name,
|
|
78
|
+
type: "re-export",
|
|
79
|
+
location: {
|
|
80
|
+
line: id.loc?.start.line ?? 1,
|
|
81
|
+
column: id.loc?.start.column ?? 0
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const declaration = path2.node.declaration;
|
|
88
|
+
if (!declaration) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (declaration.type === "VariableDeclaration") {
|
|
92
|
+
const id = declaration.declarations[0].id;
|
|
93
|
+
namedExports.push({
|
|
94
|
+
name: id.name,
|
|
95
|
+
type: "variable",
|
|
96
|
+
location: {
|
|
97
|
+
line: id.loc?.start.line ?? 1,
|
|
98
|
+
column: id.loc?.start.column ?? 0
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
} else if (declaration.type === "FunctionDeclaration") {
|
|
102
|
+
namedExports.push({
|
|
103
|
+
name: declaration?.id?.name,
|
|
104
|
+
type: "function",
|
|
105
|
+
location: {
|
|
106
|
+
line: declaration?.id?.loc?.start.line ?? 1,
|
|
107
|
+
column: declaration?.id?.loc?.start.column ?? 0
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
} else if (declaration.type === "ClassDeclaration") {
|
|
111
|
+
namedExports.push({
|
|
112
|
+
name: declaration?.id?.name,
|
|
113
|
+
type: "class",
|
|
114
|
+
location: {
|
|
115
|
+
line: declaration?.id?.loc?.start.line ?? 1,
|
|
116
|
+
column: declaration?.id?.loc?.start.column ?? 0
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
return namedExports;
|
|
123
|
+
};
|
|
124
|
+
const getGqlQueries = (ast) => {
|
|
125
|
+
const gqlQueries = [];
|
|
126
|
+
traverse(ast, {
|
|
127
|
+
TaggedTemplateExpression(path2) {
|
|
128
|
+
const gqlTag = path2.node.tag;
|
|
129
|
+
if (gqlTag.type === "Identifier" && gqlTag.name === "gql") {
|
|
130
|
+
gqlQueries.push(path2.node.quasi.quasis[0].value.raw);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
return gqlQueries;
|
|
135
|
+
};
|
|
136
|
+
const getCellGqlQuery = (ast) => {
|
|
137
|
+
let cellQuery = void 0;
|
|
138
|
+
traverse(ast, {
|
|
139
|
+
ExportNamedDeclaration({ node }) {
|
|
140
|
+
if (node.exportKind === "value" && import_core.types.isVariableDeclaration(node.declaration)) {
|
|
141
|
+
const exportedQueryNode = node.declaration.declarations.find(
|
|
142
|
+
(d) => {
|
|
143
|
+
return import_core.types.isIdentifier(d.id) && d.id.name === "QUERY" && import_core.types.isTaggedTemplateExpression(d.init);
|
|
144
|
+
}
|
|
145
|
+
);
|
|
146
|
+
if (exportedQueryNode) {
|
|
147
|
+
const templateExpression = exportedQueryNode.init;
|
|
148
|
+
cellQuery = templateExpression.quasi.quasis[0].value.raw;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
return cellQuery;
|
|
155
|
+
};
|
|
156
|
+
const hasDefaultExport = (ast) => {
|
|
157
|
+
let exported = false;
|
|
158
|
+
traverse(ast, {
|
|
159
|
+
ExportDefaultDeclaration() {
|
|
160
|
+
exported = true;
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
return exported;
|
|
165
|
+
};
|
|
166
|
+
const getDefaultExportLocation = (ast) => {
|
|
167
|
+
let defaultExport;
|
|
168
|
+
traverse(ast, {
|
|
169
|
+
ExportDefaultDeclaration(path2) {
|
|
170
|
+
defaultExport = path2.node;
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
if (!defaultExport) {
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
if (import_core.types.isIdentifier(defaultExport.declaration) && import_core.types.isFile(ast)) {
|
|
177
|
+
const exportedName = defaultExport.declaration.name;
|
|
178
|
+
const declaration = ast.program.body.find((node) => {
|
|
179
|
+
return import_core.types.isVariableDeclaration(node) && node.declarations.find((d) => {
|
|
180
|
+
return import_core.types.isVariableDeclarator(d) && import_core.types.isIdentifier(d.id) && d.id.name === exportedName;
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
return {
|
|
184
|
+
line: declaration?.loc?.start.line ?? 1,
|
|
185
|
+
column: declaration?.loc?.start.column ?? 0
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
return {
|
|
189
|
+
line: defaultExport.loc?.start.line ?? 1,
|
|
190
|
+
column: defaultExport.loc?.start.column ?? 0
|
|
191
|
+
};
|
|
192
|
+
};
|
|
193
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
194
|
+
0 && (module.exports = {
|
|
195
|
+
fileToAst,
|
|
196
|
+
getCellGqlQuery,
|
|
197
|
+
getDefaultExportLocation,
|
|
198
|
+
getGqlQueries,
|
|
199
|
+
getNamedExports,
|
|
200
|
+
hasDefaultExport
|
|
201
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { BuildOptions } from 'esbuild';
|
|
2
|
+
export declare const buildApi: () => Promise<import("esbuild").BuildResult<BuildOptions>>;
|
|
3
|
+
export declare const rebuildApi: () => Promise<import("esbuild").BuildResult<BuildOptions>>;
|
|
4
|
+
export declare const cleanApiBuild: () => Promise<void>;
|
|
5
|
+
export declare const buildApiWithVite: () => Promise<import("rollup").RollupOutput | import("rollup").RollupOutput[] | import("rollup").RollupWatcher>;
|
|
6
|
+
export declare function fixSourceMaps(distDir: string, srcDir: string): Promise<void>;
|
|
7
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/build/api.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAgB,YAAY,EAAe,MAAM,SAAS,CAAA;AAiBtE,eAAO,MAAM,QAAQ,4DAIpB,CAAA;AAED,eAAO,MAAM,UAAU,4DAStB,CAAA;AAED,eAAO,MAAM,aAAa,qBAGzB,CAAA;AA8FD,eAAO,MAAM,gBAAgB,iHAqD5B,CAAA;AAcD,wBAAsB,aAAa,CACjC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAoDf"}
|