@cedarjs/internal 5.0.0 → 6.0.0-canary.2615
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/build/api-graphql-transforms.d.ts +34 -0
- package/dist/build/api-graphql-transforms.d.ts.map +1 -0
- package/dist/build/api-graphql-transforms.js +119 -0
- package/dist/build/api.d.ts.map +1 -1
- package/dist/build/api.js +34 -15
- package/dist/build/esbuild-plugin-api-graphql.d.ts +6 -0
- package/dist/build/esbuild-plugin-api-graphql.d.ts.map +1 -0
- package/dist/build/esbuild-plugin-api-graphql.js +44 -0
- package/dist/build/esbuild-plugin-handler-als-wrapping.d.ts +4 -0
- package/dist/build/esbuild-plugin-handler-als-wrapping.d.ts.map +1 -0
- package/dist/build/{esbuild-plugin-cedar-context-wrapping.js → esbuild-plugin-handler-als-wrapping.js} +2 -2
- package/dist/cjs/build/api-graphql-transforms.d.ts +34 -0
- package/dist/cjs/build/api-graphql-transforms.d.ts.map +1 -0
- package/dist/cjs/build/api-graphql-transforms.js +150 -0
- package/dist/cjs/build/api.d.ts.map +1 -1
- package/dist/cjs/build/api.js +31 -15
- package/dist/cjs/build/esbuild-plugin-api-graphql.d.ts +6 -0
- package/dist/cjs/build/esbuild-plugin-api-graphql.d.ts.map +1 -0
- package/dist/cjs/build/esbuild-plugin-api-graphql.js +72 -0
- package/dist/cjs/build/esbuild-plugin-handler-als-wrapping.d.ts +4 -0
- package/dist/cjs/build/esbuild-plugin-handler-als-wrapping.d.ts.map +1 -0
- package/dist/cjs/build/{esbuild-plugin-cedar-context-wrapping.js → esbuild-plugin-handler-als-wrapping.js} +6 -6
- package/package.json +21 -9
- package/dist/build/esbuild-plugin-cedar-context-wrapping.d.ts +0 -4
- package/dist/build/esbuild-plugin-cedar-context-wrapping.d.ts.map +0 -1
- package/dist/cjs/build/esbuild-plugin-cedar-context-wrapping.d.ts +0 -4
- package/dist/cjs/build/esbuild-plugin-cedar-context-wrapping.d.ts.map +0 -1
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extracts the options argument from createGraphQLHandler calls and stores
|
|
3
|
+
* them in an exported variable. Returns the transformed code, or null if no
|
|
4
|
+
* transformation was needed.
|
|
5
|
+
*
|
|
6
|
+
* Transforms:
|
|
7
|
+
* export const handler = createGraphQLHandler({ options })
|
|
8
|
+
* into:
|
|
9
|
+
* export const __cedar_graphqlOptions = { options }
|
|
10
|
+
* export const handler = createGraphQLHandler(__cedar_graphqlOptions)
|
|
11
|
+
*/
|
|
12
|
+
export declare function applyGraphqlOptionsExtract(code: string): string | null;
|
|
13
|
+
/**
|
|
14
|
+
* Injects the auto-generated gqlorm backend into graphql.ts at build time.
|
|
15
|
+
*
|
|
16
|
+
* When `experimental.gqlorm.enabled = true` and `.cedar/gqlorm/backend.ts`
|
|
17
|
+
* exists, this function:
|
|
18
|
+
*
|
|
19
|
+
* 1. Adds imports at the top of graphql.ts:
|
|
20
|
+
* import * as __gqlorm_sdl__ from '../../../.cedar/gqlorm/backend'
|
|
21
|
+
* import { db as __gqlorm_db__ } from 'src/lib/db'
|
|
22
|
+
*
|
|
23
|
+
* 2. Inserts a statement immediately before the `createGraphQLHandler` call:
|
|
24
|
+
* Object.assign(sdls, {
|
|
25
|
+
* __gqlorm__: {
|
|
26
|
+
* schema: __gqlorm_sdl__.schema,
|
|
27
|
+
* resolvers: __gqlorm_sdl__.createGqlormResolvers(__gqlorm_db__),
|
|
28
|
+
* },
|
|
29
|
+
* })
|
|
30
|
+
*
|
|
31
|
+
* Returns the transformed code, or null if no transformation was needed.
|
|
32
|
+
*/
|
|
33
|
+
export declare function applyGqlormInject(code: string, id: string, dbExt?: '.ts' | '.js'): string | null;
|
|
34
|
+
//# sourceMappingURL=api-graphql-transforms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-graphql-transforms.d.ts","sourceRoot":"","sources":["../../src/build/api-graphql-transforms.ts"],"names":[],"mappings":"AAYA;;;;;;;;;;GAUG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA6FtE;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,KAAK,GAAE,KAAK,GAAG,KAAa,GAC3B,MAAM,GAAG,IAAI,CAmFf"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { parseSync, Visitor } from "oxc-parser";
|
|
4
|
+
import {
|
|
5
|
+
getConfig,
|
|
6
|
+
getPaths,
|
|
7
|
+
importStatementPath
|
|
8
|
+
} from "@cedarjs/project-config";
|
|
9
|
+
function applyGraphqlOptionsExtract(code) {
|
|
10
|
+
if (code.includes("__cedar_graphqlOptions")) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
const { program } = parseSync("graphql.ts", code, {
|
|
14
|
+
// lang is only a parse hint; 'ts' also parses JS (the graphql handler can
|
|
15
|
+
// be graphql.js in JS projects), so this is safe for both file types.
|
|
16
|
+
lang: "ts",
|
|
17
|
+
sourceType: "module"
|
|
18
|
+
});
|
|
19
|
+
const importNames = /* @__PURE__ */ new Set();
|
|
20
|
+
for (const node of program.body) {
|
|
21
|
+
if (node.type === "ImportDeclaration") {
|
|
22
|
+
if (node.source.value !== "@cedarjs/graphql-server") {
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
for (const specifier of node.specifiers) {
|
|
26
|
+
if (specifier.type === "ImportSpecifier" && specifier.imported.type === "Identifier" && specifier.imported.name === "createGraphQLHandler") {
|
|
27
|
+
importNames.add(specifier.local.name);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (importNames.size === 0) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
const callExpressionPaths = [];
|
|
36
|
+
new Visitor({
|
|
37
|
+
CallExpression(node) {
|
|
38
|
+
if (node.callee.type === "Identifier" && importNames.has(node.callee.name)) {
|
|
39
|
+
callExpressionPaths.push(node);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}).visit(program);
|
|
43
|
+
if (callExpressionPaths.length > 1) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
const callExpression = callExpressionPaths[0];
|
|
47
|
+
if (!callExpression) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
const options = callExpression.arguments[0];
|
|
51
|
+
if (!options) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
if (options.type !== "Identifier" && options.type !== "ObjectExpression" && options.type !== "CallExpression" && options.type !== "ConditionalExpression") {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
const optionsStart = options.start;
|
|
58
|
+
const optionsEnd = options.end;
|
|
59
|
+
const lineStart = code.lastIndexOf("\n", callExpression.start) + 1;
|
|
60
|
+
const indentMatch = /^[ \t]*/.exec(code.slice(lineStart));
|
|
61
|
+
const indent = indentMatch ? indentMatch[0] : "";
|
|
62
|
+
const optionsConst = `${indent}export const __cedar_graphqlOptions = ${code.slice(
|
|
63
|
+
optionsStart,
|
|
64
|
+
optionsEnd
|
|
65
|
+
)}
|
|
66
|
+
`;
|
|
67
|
+
const before = code.slice(0, lineStart);
|
|
68
|
+
const between = code.slice(lineStart, optionsStart);
|
|
69
|
+
const after = code.slice(optionsEnd);
|
|
70
|
+
return before + optionsConst + between + "__cedar_graphqlOptions" + after;
|
|
71
|
+
}
|
|
72
|
+
function applyGqlormInject(code, id, dbExt = ".ts") {
|
|
73
|
+
if (code.includes("__gqlorm_sdl__")) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
if (!code.includes("createGraphQLHandler")) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
if (!getConfig().experimental?.gqlorm?.enabled) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
const backendPathWithoutExt = path.join(
|
|
83
|
+
getPaths().generated.base,
|
|
84
|
+
"gqlorm",
|
|
85
|
+
"backend"
|
|
86
|
+
);
|
|
87
|
+
if (!fs.existsSync(backendPathWithoutExt + ".ts")) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
const handlerPattern = /^export\s+const\s+(\w+)\s*=\s*createGraphQLHandler\s*\(/m;
|
|
91
|
+
const handlerMatch = handlerPattern.exec(code);
|
|
92
|
+
if (!handlerMatch) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
const handlerLineStart = code.lastIndexOf("\n", handlerMatch.index) + 1;
|
|
96
|
+
const relPath = importStatementPath(
|
|
97
|
+
path.relative(path.dirname(id), backendPathWithoutExt)
|
|
98
|
+
) + ".ts";
|
|
99
|
+
const dbSrcPath = path.join(getPaths().api.src, "lib", "db");
|
|
100
|
+
const relDbPath = importStatementPath(path.relative(path.dirname(id), dbSrcPath)) + dbExt;
|
|
101
|
+
const importDb = `import { db as __gqlorm_db__ } from '${relDbPath}'`;
|
|
102
|
+
const importSdl = `import * as __gqlorm_sdl__ from '${relPath}'`;
|
|
103
|
+
const importsToAdd = `${importDb}
|
|
104
|
+
${importSdl}
|
|
105
|
+
`;
|
|
106
|
+
const sdlsMutation = `Object.assign(sdls, {
|
|
107
|
+
__gqlorm__: {
|
|
108
|
+
schema: __gqlorm_sdl__.schema,
|
|
109
|
+
resolvers: __gqlorm_sdl__.createGqlormResolvers(__gqlorm_db__),
|
|
110
|
+
},
|
|
111
|
+
})
|
|
112
|
+
`;
|
|
113
|
+
const transformed = importsToAdd + code.slice(0, handlerLineStart) + sdlsMutation + code.slice(handlerLineStart);
|
|
114
|
+
return transformed;
|
|
115
|
+
}
|
|
116
|
+
export {
|
|
117
|
+
applyGqlormInject,
|
|
118
|
+
applyGraphqlOptionsExtract
|
|
119
|
+
};
|
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;AAsBtE,eAAO,MAAM,QAAQ,4DAIpB,CAAA;AAED,eAAO,MAAM,UAAU,4DAStB,CAAA;AAED,eAAO,MAAM,aAAa,qBAGzB,CAAA;AA8HD,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
|
@@ -8,7 +8,12 @@ import {
|
|
|
8
8
|
} from "@cedarjs/babel-config";
|
|
9
9
|
import { getConfig, getPaths, projectSideIsEsm } from "@cedarjs/project-config";
|
|
10
10
|
import { findApiFiles } from "../files.js";
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
applyGqlormInject,
|
|
13
|
+
applyGraphqlOptionsExtract
|
|
14
|
+
} from "./api-graphql-transforms.js";
|
|
15
|
+
import { cedarApiGraphqlPlugin } from "./esbuild-plugin-api-graphql.js";
|
|
16
|
+
import { applyHandlerAlsWrapping } from "./esbuild-plugin-handler-als-wrapping.js";
|
|
12
17
|
let BUILD_CTX = null;
|
|
13
18
|
const buildApi = async () => {
|
|
14
19
|
BUILD_CTX?.dispose();
|
|
@@ -44,12 +49,16 @@ const runCedarBabelTransformsPlugin = {
|
|
|
44
49
|
})
|
|
45
50
|
);
|
|
46
51
|
if (transformedCode?.code) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
);
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
let code = transformedCode.code;
|
|
53
|
+
const normalizedPath = normalizePath(args.path);
|
|
54
|
+
const cedarPaths = getPaths();
|
|
55
|
+
const isEsm = projectSideIsEsm("api");
|
|
56
|
+
const functionsDir = normalizePath(cedarPaths.api.functions);
|
|
57
|
+
if (normalizedPath.startsWith(functionsDir + "/")) {
|
|
58
|
+
code = applyHandlerAlsWrapping(code, {
|
|
59
|
+
projectIsEsm: isEsm
|
|
60
|
+
}) ?? code;
|
|
61
|
+
}
|
|
53
62
|
return {
|
|
54
63
|
contents: code,
|
|
55
64
|
loader: "js"
|
|
@@ -76,8 +85,14 @@ function createCedarViteApiPlugin() {
|
|
|
76
85
|
if (!normalizePath(id).startsWith(normalizePath(cedarPaths.api.base))) {
|
|
77
86
|
return null;
|
|
78
87
|
}
|
|
88
|
+
let sourceCode = code;
|
|
89
|
+
const normalizedId = normalizePath(id);
|
|
90
|
+
if (normalizedId.endsWith("/graphql.ts") || normalizedId.endsWith("/graphql.js")) {
|
|
91
|
+
sourceCode = applyGraphqlOptionsExtract(sourceCode) ?? sourceCode;
|
|
92
|
+
sourceCode = applyGqlormInject(sourceCode, id) ?? sourceCode;
|
|
93
|
+
}
|
|
79
94
|
const transformedCode = await transformWithBabel(
|
|
80
|
-
|
|
95
|
+
sourceCode,
|
|
81
96
|
id,
|
|
82
97
|
getApiSideBabelPlugins({
|
|
83
98
|
openTelemetry: cedarConfig.experimental.opentelemetry.enabled && cedarConfig.experimental.opentelemetry.wrapApi,
|
|
@@ -86,12 +101,13 @@ function createCedarViteApiPlugin() {
|
|
|
86
101
|
true
|
|
87
102
|
);
|
|
88
103
|
if (transformedCode?.code) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
)
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
104
|
+
let code2 = transformedCode.code;
|
|
105
|
+
const functionsDir = normalizePath(cedarPaths.api.functions);
|
|
106
|
+
if (normalizedId.startsWith(functionsDir + "/")) {
|
|
107
|
+
code2 = applyHandlerAlsWrapping(code2, {
|
|
108
|
+
projectIsEsm: isEsm
|
|
109
|
+
}) ?? code2;
|
|
110
|
+
}
|
|
95
111
|
return {
|
|
96
112
|
code: code2,
|
|
97
113
|
map: transformedCode.map ?? null
|
|
@@ -199,7 +215,10 @@ function getEsbuildOptions(files) {
|
|
|
199
215
|
format,
|
|
200
216
|
allowOverwrite: true,
|
|
201
217
|
bundle: false,
|
|
202
|
-
|
|
218
|
+
// Registration order matters: cedarApiGraphqlPlugin (narrow filter) must
|
|
219
|
+
// come first so it claims graphql.ts before runCedarBabelTransformsPlugin
|
|
220
|
+
// (broad filter) can. See the NOTE on cedarApiGraphqlPlugin.
|
|
221
|
+
plugins: [cedarApiGraphqlPlugin, runCedarBabelTransformsPlugin],
|
|
203
222
|
outdir: cedarPaths.api.dist,
|
|
204
223
|
// setting this to 'true' will generate an external sourcemap x.js.map
|
|
205
224
|
// AND set the sourceMappingURL comment
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"esbuild-plugin-api-graphql.d.ts","sourceRoot":"","sources":["../../src/build/esbuild-plugin-api-graphql.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAc1C,eAAO,MAAM,qBAAqB;;iBAEnB,WAAW;CAmDzB,CAAA"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import {
|
|
3
|
+
getApiSideBabelPlugins,
|
|
4
|
+
transformWithBabel
|
|
5
|
+
} from "@cedarjs/babel-config";
|
|
6
|
+
import { getConfig, projectSideIsEsm } from "@cedarjs/project-config";
|
|
7
|
+
import {
|
|
8
|
+
applyGqlormInject,
|
|
9
|
+
applyGraphqlOptionsExtract
|
|
10
|
+
} from "./api-graphql-transforms.js";
|
|
11
|
+
import { applyHandlerAlsWrapping } from "./esbuild-plugin-handler-als-wrapping.js";
|
|
12
|
+
const cedarApiGraphqlPlugin = {
|
|
13
|
+
name: "cedar-api-graphql",
|
|
14
|
+
setup(build) {
|
|
15
|
+
build.onLoad({ filter: /[/\\]graphql\.(ts|js)$/ }, async (args) => {
|
|
16
|
+
const cedarConfig = getConfig();
|
|
17
|
+
let fileContents = await fs.promises.readFile(args.path, "utf-8");
|
|
18
|
+
fileContents = applyGraphqlOptionsExtract(fileContents) ?? fileContents;
|
|
19
|
+
fileContents = applyGqlormInject(fileContents, args.path, ".js") ?? fileContents;
|
|
20
|
+
const transformedCode = await transformWithBabel(
|
|
21
|
+
fileContents,
|
|
22
|
+
args.path,
|
|
23
|
+
getApiSideBabelPlugins({
|
|
24
|
+
openTelemetry: cedarConfig.experimental.opentelemetry.enabled && cedarConfig.experimental.opentelemetry.wrapApi,
|
|
25
|
+
projectIsEsm: projectSideIsEsm("api")
|
|
26
|
+
})
|
|
27
|
+
);
|
|
28
|
+
if (!transformedCode?.code) {
|
|
29
|
+
throw new Error(`Could not transform file: ${args.path}`);
|
|
30
|
+
}
|
|
31
|
+
let code = transformedCode.code;
|
|
32
|
+
code = applyHandlerAlsWrapping(code, {
|
|
33
|
+
projectIsEsm: projectSideIsEsm("api")
|
|
34
|
+
}) ?? code;
|
|
35
|
+
return {
|
|
36
|
+
contents: code,
|
|
37
|
+
loader: "js"
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
export {
|
|
43
|
+
cedarApiGraphqlPlugin
|
|
44
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"esbuild-plugin-handler-als-wrapping.d.ts","sourceRoot":"","sources":["../../src/build/esbuild-plugin-handler-als-wrapping.ts"],"names":[],"mappings":"AAOA,wBAAgB,uBAAuB,CACrC,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 applyHandlerAlsWrapping(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) {
|
|
@@ -31,5 +31,5 @@ export const handler = ${isAsync ? "async " : ""}(__rw_event, __rw__context) =>
|
|
|
31
31
|
return before + importStatement + renamed + wrappedHandler;
|
|
32
32
|
}
|
|
33
33
|
export {
|
|
34
|
-
|
|
34
|
+
applyHandlerAlsWrapping
|
|
35
35
|
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extracts the options argument from createGraphQLHandler calls and stores
|
|
3
|
+
* them in an exported variable. Returns the transformed code, or null if no
|
|
4
|
+
* transformation was needed.
|
|
5
|
+
*
|
|
6
|
+
* Transforms:
|
|
7
|
+
* export const handler = createGraphQLHandler({ options })
|
|
8
|
+
* into:
|
|
9
|
+
* export const __cedar_graphqlOptions = { options }
|
|
10
|
+
* export const handler = createGraphQLHandler(__cedar_graphqlOptions)
|
|
11
|
+
*/
|
|
12
|
+
export declare function applyGraphqlOptionsExtract(code: string): string | null;
|
|
13
|
+
/**
|
|
14
|
+
* Injects the auto-generated gqlorm backend into graphql.ts at build time.
|
|
15
|
+
*
|
|
16
|
+
* When `experimental.gqlorm.enabled = true` and `.cedar/gqlorm/backend.ts`
|
|
17
|
+
* exists, this function:
|
|
18
|
+
*
|
|
19
|
+
* 1. Adds imports at the top of graphql.ts:
|
|
20
|
+
* import * as __gqlorm_sdl__ from '../../../.cedar/gqlorm/backend'
|
|
21
|
+
* import { db as __gqlorm_db__ } from 'src/lib/db'
|
|
22
|
+
*
|
|
23
|
+
* 2. Inserts a statement immediately before the `createGraphQLHandler` call:
|
|
24
|
+
* Object.assign(sdls, {
|
|
25
|
+
* __gqlorm__: {
|
|
26
|
+
* schema: __gqlorm_sdl__.schema,
|
|
27
|
+
* resolvers: __gqlorm_sdl__.createGqlormResolvers(__gqlorm_db__),
|
|
28
|
+
* },
|
|
29
|
+
* })
|
|
30
|
+
*
|
|
31
|
+
* Returns the transformed code, or null if no transformation was needed.
|
|
32
|
+
*/
|
|
33
|
+
export declare function applyGqlormInject(code: string, id: string, dbExt?: '.ts' | '.js'): string | null;
|
|
34
|
+
//# sourceMappingURL=api-graphql-transforms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-graphql-transforms.d.ts","sourceRoot":"","sources":["../../../src/build/api-graphql-transforms.ts"],"names":[],"mappings":"AAYA;;;;;;;;;;GAUG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA6FtE;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,KAAK,GAAE,KAAK,GAAG,KAAa,GAC3B,MAAM,GAAG,IAAI,CAmFf"}
|
|
@@ -0,0 +1,150 @@
|
|
|
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_graphql_transforms_exports = {};
|
|
30
|
+
__export(api_graphql_transforms_exports, {
|
|
31
|
+
applyGqlormInject: () => applyGqlormInject,
|
|
32
|
+
applyGraphqlOptionsExtract: () => applyGraphqlOptionsExtract
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(api_graphql_transforms_exports);
|
|
35
|
+
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
36
|
+
var import_node_path = __toESM(require("node:path"), 1);
|
|
37
|
+
var import_oxc_parser = require("oxc-parser");
|
|
38
|
+
var import_project_config = require("@cedarjs/project-config");
|
|
39
|
+
function applyGraphqlOptionsExtract(code) {
|
|
40
|
+
if (code.includes("__cedar_graphqlOptions")) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
const { program } = (0, import_oxc_parser.parseSync)("graphql.ts", code, {
|
|
44
|
+
// lang is only a parse hint; 'ts' also parses JS (the graphql handler can
|
|
45
|
+
// be graphql.js in JS projects), so this is safe for both file types.
|
|
46
|
+
lang: "ts",
|
|
47
|
+
sourceType: "module"
|
|
48
|
+
});
|
|
49
|
+
const importNames = /* @__PURE__ */ new Set();
|
|
50
|
+
for (const node of program.body) {
|
|
51
|
+
if (node.type === "ImportDeclaration") {
|
|
52
|
+
if (node.source.value !== "@cedarjs/graphql-server") {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
for (const specifier of node.specifiers) {
|
|
56
|
+
if (specifier.type === "ImportSpecifier" && specifier.imported.type === "Identifier" && specifier.imported.name === "createGraphQLHandler") {
|
|
57
|
+
importNames.add(specifier.local.name);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (importNames.size === 0) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
const callExpressionPaths = [];
|
|
66
|
+
new import_oxc_parser.Visitor({
|
|
67
|
+
CallExpression(node) {
|
|
68
|
+
if (node.callee.type === "Identifier" && importNames.has(node.callee.name)) {
|
|
69
|
+
callExpressionPaths.push(node);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}).visit(program);
|
|
73
|
+
if (callExpressionPaths.length > 1) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
const callExpression = callExpressionPaths[0];
|
|
77
|
+
if (!callExpression) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
const options = callExpression.arguments[0];
|
|
81
|
+
if (!options) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
if (options.type !== "Identifier" && options.type !== "ObjectExpression" && options.type !== "CallExpression" && options.type !== "ConditionalExpression") {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
const optionsStart = options.start;
|
|
88
|
+
const optionsEnd = options.end;
|
|
89
|
+
const lineStart = code.lastIndexOf("\n", callExpression.start) + 1;
|
|
90
|
+
const indentMatch = /^[ \t]*/.exec(code.slice(lineStart));
|
|
91
|
+
const indent = indentMatch ? indentMatch[0] : "";
|
|
92
|
+
const optionsConst = `${indent}export const __cedar_graphqlOptions = ${code.slice(
|
|
93
|
+
optionsStart,
|
|
94
|
+
optionsEnd
|
|
95
|
+
)}
|
|
96
|
+
`;
|
|
97
|
+
const before = code.slice(0, lineStart);
|
|
98
|
+
const between = code.slice(lineStart, optionsStart);
|
|
99
|
+
const after = code.slice(optionsEnd);
|
|
100
|
+
return before + optionsConst + between + "__cedar_graphqlOptions" + after;
|
|
101
|
+
}
|
|
102
|
+
function applyGqlormInject(code, id, dbExt = ".ts") {
|
|
103
|
+
if (code.includes("__gqlorm_sdl__")) {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
if (!code.includes("createGraphQLHandler")) {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
if (!(0, import_project_config.getConfig)().experimental?.gqlorm?.enabled) {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
const backendPathWithoutExt = import_node_path.default.join(
|
|
113
|
+
(0, import_project_config.getPaths)().generated.base,
|
|
114
|
+
"gqlorm",
|
|
115
|
+
"backend"
|
|
116
|
+
);
|
|
117
|
+
if (!import_node_fs.default.existsSync(backendPathWithoutExt + ".ts")) {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
const handlerPattern = /^export\s+const\s+(\w+)\s*=\s*createGraphQLHandler\s*\(/m;
|
|
121
|
+
const handlerMatch = handlerPattern.exec(code);
|
|
122
|
+
if (!handlerMatch) {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
const handlerLineStart = code.lastIndexOf("\n", handlerMatch.index) + 1;
|
|
126
|
+
const relPath = (0, import_project_config.importStatementPath)(
|
|
127
|
+
import_node_path.default.relative(import_node_path.default.dirname(id), backendPathWithoutExt)
|
|
128
|
+
) + ".ts";
|
|
129
|
+
const dbSrcPath = import_node_path.default.join((0, import_project_config.getPaths)().api.src, "lib", "db");
|
|
130
|
+
const relDbPath = (0, import_project_config.importStatementPath)(import_node_path.default.relative(import_node_path.default.dirname(id), dbSrcPath)) + dbExt;
|
|
131
|
+
const importDb = `import { db as __gqlorm_db__ } from '${relDbPath}'`;
|
|
132
|
+
const importSdl = `import * as __gqlorm_sdl__ from '${relPath}'`;
|
|
133
|
+
const importsToAdd = `${importDb}
|
|
134
|
+
${importSdl}
|
|
135
|
+
`;
|
|
136
|
+
const sdlsMutation = `Object.assign(sdls, {
|
|
137
|
+
__gqlorm__: {
|
|
138
|
+
schema: __gqlorm_sdl__.schema,
|
|
139
|
+
resolvers: __gqlorm_sdl__.createGqlormResolvers(__gqlorm_db__),
|
|
140
|
+
},
|
|
141
|
+
})
|
|
142
|
+
`;
|
|
143
|
+
const transformed = importsToAdd + code.slice(0, handlerLineStart) + sdlsMutation + code.slice(handlerLineStart);
|
|
144
|
+
return transformed;
|
|
145
|
+
}
|
|
146
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
147
|
+
0 && (module.exports = {
|
|
148
|
+
applyGqlormInject,
|
|
149
|
+
applyGraphqlOptionsExtract
|
|
150
|
+
});
|
|
@@ -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;AAsBtE,eAAO,MAAM,QAAQ,4DAIpB,CAAA;AAED,eAAO,MAAM,UAAU,4DAStB,CAAA;AAED,eAAO,MAAM,aAAa,qBAGzB,CAAA;AA8HD,eAAO,MAAM,gBAAgB,iHAqD5B,CAAA;AAcD,wBAAsB,aAAa,CACjC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAoDf"}
|
package/dist/cjs/build/api.js
CHANGED
|
@@ -42,7 +42,9 @@ var import_vite = require("vite");
|
|
|
42
42
|
var import_babel_config = require("@cedarjs/babel-config");
|
|
43
43
|
var import_project_config = require("@cedarjs/project-config");
|
|
44
44
|
var import_files = require("../files.js");
|
|
45
|
-
var
|
|
45
|
+
var import_api_graphql_transforms = require("./api-graphql-transforms.js");
|
|
46
|
+
var import_esbuild_plugin_api_graphql = require("./esbuild-plugin-api-graphql.js");
|
|
47
|
+
var import_esbuild_plugin_handler_als_wrapping = require("./esbuild-plugin-handler-als-wrapping.js");
|
|
46
48
|
let BUILD_CTX = null;
|
|
47
49
|
const buildApi = async () => {
|
|
48
50
|
BUILD_CTX?.dispose();
|
|
@@ -78,12 +80,16 @@ const runCedarBabelTransformsPlugin = {
|
|
|
78
80
|
})
|
|
79
81
|
);
|
|
80
82
|
if (transformedCode?.code) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
);
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
let code = transformedCode.code;
|
|
84
|
+
const normalizedPath = (0, import_vite.normalizePath)(args.path);
|
|
85
|
+
const cedarPaths = (0, import_project_config.getPaths)();
|
|
86
|
+
const isEsm = (0, import_project_config.projectSideIsEsm)("api");
|
|
87
|
+
const functionsDir = (0, import_vite.normalizePath)(cedarPaths.api.functions);
|
|
88
|
+
if (normalizedPath.startsWith(functionsDir + "/")) {
|
|
89
|
+
code = (0, import_esbuild_plugin_handler_als_wrapping.applyHandlerAlsWrapping)(code, {
|
|
90
|
+
projectIsEsm: isEsm
|
|
91
|
+
}) ?? code;
|
|
92
|
+
}
|
|
87
93
|
return {
|
|
88
94
|
contents: code,
|
|
89
95
|
loader: "js"
|
|
@@ -110,8 +116,14 @@ function createCedarViteApiPlugin() {
|
|
|
110
116
|
if (!(0, import_vite.normalizePath)(id).startsWith((0, import_vite.normalizePath)(cedarPaths.api.base))) {
|
|
111
117
|
return null;
|
|
112
118
|
}
|
|
119
|
+
let sourceCode = code;
|
|
120
|
+
const normalizedId = (0, import_vite.normalizePath)(id);
|
|
121
|
+
if (normalizedId.endsWith("/graphql.ts") || normalizedId.endsWith("/graphql.js")) {
|
|
122
|
+
sourceCode = (0, import_api_graphql_transforms.applyGraphqlOptionsExtract)(sourceCode) ?? sourceCode;
|
|
123
|
+
sourceCode = (0, import_api_graphql_transforms.applyGqlormInject)(sourceCode, id) ?? sourceCode;
|
|
124
|
+
}
|
|
113
125
|
const transformedCode = await (0, import_babel_config.transformWithBabel)(
|
|
114
|
-
|
|
126
|
+
sourceCode,
|
|
115
127
|
id,
|
|
116
128
|
(0, import_babel_config.getApiSideBabelPlugins)({
|
|
117
129
|
openTelemetry: cedarConfig.experimental.opentelemetry.enabled && cedarConfig.experimental.opentelemetry.wrapApi,
|
|
@@ -120,12 +132,13 @@ function createCedarViteApiPlugin() {
|
|
|
120
132
|
true
|
|
121
133
|
);
|
|
122
134
|
if (transformedCode?.code) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
)
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
135
|
+
let code2 = transformedCode.code;
|
|
136
|
+
const functionsDir = (0, import_vite.normalizePath)(cedarPaths.api.functions);
|
|
137
|
+
if (normalizedId.startsWith(functionsDir + "/")) {
|
|
138
|
+
code2 = (0, import_esbuild_plugin_handler_als_wrapping.applyHandlerAlsWrapping)(code2, {
|
|
139
|
+
projectIsEsm: isEsm
|
|
140
|
+
}) ?? code2;
|
|
141
|
+
}
|
|
129
142
|
return {
|
|
130
143
|
code: code2,
|
|
131
144
|
map: transformedCode.map ?? null
|
|
@@ -233,7 +246,10 @@ function getEsbuildOptions(files) {
|
|
|
233
246
|
format,
|
|
234
247
|
allowOverwrite: true,
|
|
235
248
|
bundle: false,
|
|
236
|
-
|
|
249
|
+
// Registration order matters: cedarApiGraphqlPlugin (narrow filter) must
|
|
250
|
+
// come first so it claims graphql.ts before runCedarBabelTransformsPlugin
|
|
251
|
+
// (broad filter) can. See the NOTE on cedarApiGraphqlPlugin.
|
|
252
|
+
plugins: [import_esbuild_plugin_api_graphql.cedarApiGraphqlPlugin, runCedarBabelTransformsPlugin],
|
|
237
253
|
outdir: cedarPaths.api.dist,
|
|
238
254
|
// setting this to 'true' will generate an external sourcemap x.js.map
|
|
239
255
|
// AND set the sourceMappingURL comment
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"esbuild-plugin-api-graphql.d.ts","sourceRoot":"","sources":["../../../src/build/esbuild-plugin-api-graphql.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAc1C,eAAO,MAAM,qBAAqB;;iBAEnB,WAAW;CAmDzB,CAAA"}
|
|
@@ -0,0 +1,72 @@
|
|
|
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 esbuild_plugin_api_graphql_exports = {};
|
|
30
|
+
__export(esbuild_plugin_api_graphql_exports, {
|
|
31
|
+
cedarApiGraphqlPlugin: () => cedarApiGraphqlPlugin
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(esbuild_plugin_api_graphql_exports);
|
|
34
|
+
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
35
|
+
var import_babel_config = require("@cedarjs/babel-config");
|
|
36
|
+
var import_project_config = require("@cedarjs/project-config");
|
|
37
|
+
var import_api_graphql_transforms = require("./api-graphql-transforms.js");
|
|
38
|
+
var import_esbuild_plugin_handler_als_wrapping = require("./esbuild-plugin-handler-als-wrapping.js");
|
|
39
|
+
const cedarApiGraphqlPlugin = {
|
|
40
|
+
name: "cedar-api-graphql",
|
|
41
|
+
setup(build) {
|
|
42
|
+
build.onLoad({ filter: /[/\\]graphql\.(ts|js)$/ }, async (args) => {
|
|
43
|
+
const cedarConfig = (0, import_project_config.getConfig)();
|
|
44
|
+
let fileContents = await import_node_fs.default.promises.readFile(args.path, "utf-8");
|
|
45
|
+
fileContents = (0, import_api_graphql_transforms.applyGraphqlOptionsExtract)(fileContents) ?? fileContents;
|
|
46
|
+
fileContents = (0, import_api_graphql_transforms.applyGqlormInject)(fileContents, args.path, ".js") ?? fileContents;
|
|
47
|
+
const transformedCode = await (0, import_babel_config.transformWithBabel)(
|
|
48
|
+
fileContents,
|
|
49
|
+
args.path,
|
|
50
|
+
(0, import_babel_config.getApiSideBabelPlugins)({
|
|
51
|
+
openTelemetry: cedarConfig.experimental.opentelemetry.enabled && cedarConfig.experimental.opentelemetry.wrapApi,
|
|
52
|
+
projectIsEsm: (0, import_project_config.projectSideIsEsm)("api")
|
|
53
|
+
})
|
|
54
|
+
);
|
|
55
|
+
if (!transformedCode?.code) {
|
|
56
|
+
throw new Error(`Could not transform file: ${args.path}`);
|
|
57
|
+
}
|
|
58
|
+
let code = transformedCode.code;
|
|
59
|
+
code = (0, import_esbuild_plugin_handler_als_wrapping.applyHandlerAlsWrapping)(code, {
|
|
60
|
+
projectIsEsm: (0, import_project_config.projectSideIsEsm)("api")
|
|
61
|
+
}) ?? code;
|
|
62
|
+
return {
|
|
63
|
+
contents: code,
|
|
64
|
+
loader: "js"
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
70
|
+
0 && (module.exports = {
|
|
71
|
+
cedarApiGraphqlPlugin
|
|
72
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"esbuild-plugin-handler-als-wrapping.d.ts","sourceRoot":"","sources":["../../../src/build/esbuild-plugin-handler-als-wrapping.ts"],"names":[],"mappings":"AAOA,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,MAAM,EACZ,EAAE,YAAoB,EAAE,GAAE;IAAE,YAAY,CAAC,EAAE,OAAO,CAAA;CAAO,GACxD,MAAM,GAAG,IAAI,CA0Cf"}
|
|
@@ -16,12 +16,12 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
21
|
-
|
|
19
|
+
var esbuild_plugin_handler_als_wrapping_exports = {};
|
|
20
|
+
__export(esbuild_plugin_handler_als_wrapping_exports, {
|
|
21
|
+
applyHandlerAlsWrapping: () => applyHandlerAlsWrapping
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
24
|
-
function
|
|
23
|
+
module.exports = __toCommonJS(esbuild_plugin_handler_als_wrapping_exports);
|
|
24
|
+
function applyHandlerAlsWrapping(code, { projectIsEsm = false } = {}) {
|
|
25
25
|
const handlerRe = /^export\s+(?:const|let|var)\s+handler(?:[^=]|=>)*?=(?![>=])/m;
|
|
26
26
|
const handlerMatch = handlerRe.exec(code);
|
|
27
27
|
if (!handlerMatch) {
|
|
@@ -55,5 +55,5 @@ export const handler = ${isAsync ? "async " : ""}(__rw_event, __rw__context) =>
|
|
|
55
55
|
}
|
|
56
56
|
// Annotate the CommonJS export names for ESM import in node:
|
|
57
57
|
0 && (module.exports = {
|
|
58
|
-
|
|
58
|
+
applyHandlerAlsWrapping
|
|
59
59
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/internal",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0-canary.2615",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/cedarjs/cedar.git",
|
|
@@ -110,6 +110,16 @@
|
|
|
110
110
|
"default": "./dist/cjs/build/api.js"
|
|
111
111
|
}
|
|
112
112
|
},
|
|
113
|
+
"./dist/build/api-graphql-transforms.js": {
|
|
114
|
+
"import": {
|
|
115
|
+
"types": "./dist/build/api-graphql-transforms.d.ts",
|
|
116
|
+
"default": "./dist/build/api-graphql-transforms.js"
|
|
117
|
+
},
|
|
118
|
+
"require": {
|
|
119
|
+
"types": "./dist/cjs/build/api-graphql-transforms.d.ts",
|
|
120
|
+
"default": "./dist/cjs/build/api-graphql-transforms.js"
|
|
121
|
+
}
|
|
122
|
+
},
|
|
113
123
|
"./dist/generate/generate": {
|
|
114
124
|
"import": {
|
|
115
125
|
"types": "./dist/generate/generate.d.ts",
|
|
@@ -159,13 +169,13 @@
|
|
|
159
169
|
"@babel/plugin-transform-react-jsx": "7.29.7",
|
|
160
170
|
"@babel/plugin-transform-typescript": "^7.26.8",
|
|
161
171
|
"@babel/traverse": "7.29.7",
|
|
162
|
-
"@cedarjs/babel-config": "
|
|
163
|
-
"@cedarjs/cli-helpers": "
|
|
164
|
-
"@cedarjs/graphql-server": "
|
|
165
|
-
"@cedarjs/project-config": "
|
|
166
|
-
"@cedarjs/router": "
|
|
167
|
-
"@cedarjs/structure": "
|
|
168
|
-
"@cedarjs/utils": "
|
|
172
|
+
"@cedarjs/babel-config": "6.0.0-canary.2615",
|
|
173
|
+
"@cedarjs/cli-helpers": "6.0.0-canary.2615",
|
|
174
|
+
"@cedarjs/graphql-server": "6.0.0-canary.2615",
|
|
175
|
+
"@cedarjs/project-config": "6.0.0-canary.2615",
|
|
176
|
+
"@cedarjs/router": "6.0.0-canary.2615",
|
|
177
|
+
"@cedarjs/structure": "6.0.0-canary.2615",
|
|
178
|
+
"@cedarjs/utils": "6.0.0-canary.2615",
|
|
169
179
|
"@graphql-codegen/add": "6.0.1",
|
|
170
180
|
"@graphql-codegen/cli": "6.3.1",
|
|
171
181
|
"@graphql-codegen/client-preset": "5.3.0",
|
|
@@ -194,6 +204,7 @@
|
|
|
194
204
|
"fast-glob": "3.3.3",
|
|
195
205
|
"graphql": "16.14.2",
|
|
196
206
|
"kill-port": "1.6.1",
|
|
207
|
+
"oxc-parser": "0.137.0",
|
|
197
208
|
"prettier": "3.8.4",
|
|
198
209
|
"rimraf": "6.1.3",
|
|
199
210
|
"source-map": "0.7.6",
|
|
@@ -206,10 +217,11 @@
|
|
|
206
217
|
},
|
|
207
218
|
"devDependencies": {
|
|
208
219
|
"@arethetypeswrong/cli": "0.18.4",
|
|
209
|
-
"@cedarjs/framework-tools": "
|
|
220
|
+
"@cedarjs/framework-tools": "6.0.0-canary.2615",
|
|
210
221
|
"concurrently": "9.2.1",
|
|
211
222
|
"graphql-tag": "2.12.6",
|
|
212
223
|
"publint": "0.3.21",
|
|
224
|
+
"ts-dedent": "2.3.0",
|
|
213
225
|
"vitest": "3.2.6"
|
|
214
226
|
},
|
|
215
227
|
"engines": {
|
|
@@ -1 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
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"}
|