@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
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"esbuild-plugin-cedar-otel-wrapping.d.ts","sourceRoot":"","sources":["../../src/build/esbuild-plugin-cedar-otel-wrapping.ts"],"names":[],"mappings":"AASA;;;;;;;;;;GAUG;AAEH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,GACb,MAAM,GAAG,IAAI,CAmFf"}
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { parseSync } from "oxc-parser";
|
|
3
|
-
function applyOtelWrapping(code, filename, apiSrc) {
|
|
4
|
-
const relative = path.relative(apiSrc, filename);
|
|
5
|
-
const apiFolder = relative.split(path.sep)[0] ?? "?";
|
|
6
|
-
const parseResult = parseSync(filename, code, { sourceType: "module" });
|
|
7
|
-
const replacements = [];
|
|
8
|
-
for (const node of parseResult.program.body) {
|
|
9
|
-
if (node.type !== "ExportNamedDeclaration") {
|
|
10
|
-
continue;
|
|
11
|
-
}
|
|
12
|
-
const decl = node.declaration;
|
|
13
|
-
if (decl?.type !== "VariableDeclaration") {
|
|
14
|
-
continue;
|
|
15
|
-
}
|
|
16
|
-
const declarator = decl.declarations[0];
|
|
17
|
-
if (!declarator) {
|
|
18
|
-
continue;
|
|
19
|
-
}
|
|
20
|
-
const fn = declarator.init;
|
|
21
|
-
if (fn?.type !== "ArrowFunctionExpression") {
|
|
22
|
-
continue;
|
|
23
|
-
}
|
|
24
|
-
if (declarator.id.type !== "Identifier") {
|
|
25
|
-
continue;
|
|
26
|
-
}
|
|
27
|
-
const fnName = declarator.id.name;
|
|
28
|
-
const innerArgs = buildInnerArgs(fn.params);
|
|
29
|
-
if (innerArgs === null) {
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
const fnHeader = code.slice(fn.start, fn.body.start);
|
|
33
|
-
const originalFnSrc = code.slice(fn.start, fn.end);
|
|
34
|
-
const isAsync = fn.async;
|
|
35
|
-
const awaitKw = isAsync ? "await " : "";
|
|
36
|
-
const asyncKw = isAsync ? "async " : "";
|
|
37
|
-
replacements.push({
|
|
38
|
-
start: node.start,
|
|
39
|
-
end: node.end,
|
|
40
|
-
src: buildWrappedExport(
|
|
41
|
-
fnName,
|
|
42
|
-
fnHeader,
|
|
43
|
-
originalFnSrc,
|
|
44
|
-
innerArgs,
|
|
45
|
-
awaitKw,
|
|
46
|
-
asyncKw,
|
|
47
|
-
apiFolder,
|
|
48
|
-
filename
|
|
49
|
-
)
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
if (replacements.length === 0) {
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
let output = code;
|
|
56
|
-
for (let i = replacements.length - 1; i >= 0; i--) {
|
|
57
|
-
const r = replacements[i];
|
|
58
|
-
output = output.slice(0, r.start) + r.src + output.slice(r.end);
|
|
59
|
-
}
|
|
60
|
-
return `import { trace as OTEL_TRACE } from '@opentelemetry/api'
|
|
61
|
-
` + output;
|
|
62
|
-
}
|
|
63
|
-
function buildInnerArgs(params) {
|
|
64
|
-
const args = [];
|
|
65
|
-
for (const param of params) {
|
|
66
|
-
if (param.type === "RestElement" || param.type === "ArrayPattern" || param.type === "TSParameterProperty") {
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
if (param.type === "Identifier") {
|
|
70
|
-
args.push(param.name);
|
|
71
|
-
continue;
|
|
72
|
-
}
|
|
73
|
-
if (param.type === "ObjectPattern") {
|
|
74
|
-
for (const prop of param.properties) {
|
|
75
|
-
if (prop.type === "RestElement") {
|
|
76
|
-
return null;
|
|
77
|
-
}
|
|
78
|
-
if (prop.key.type !== "Identifier") {
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
|
-
const value = prop.value;
|
|
82
|
-
if (value.type !== "Identifier" && value.type !== "AssignmentPattern" && value.type !== "ObjectPattern") {
|
|
83
|
-
return null;
|
|
84
|
-
}
|
|
85
|
-
if (value.type === "AssignmentPattern") {
|
|
86
|
-
if (value.left.type !== "Identifier" && value.left.type !== "ObjectPattern") {
|
|
87
|
-
return null;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
const obj = buildObjectCallArg(param);
|
|
92
|
-
if (obj === null) {
|
|
93
|
-
return null;
|
|
94
|
-
}
|
|
95
|
-
args.push(obj);
|
|
96
|
-
continue;
|
|
97
|
-
}
|
|
98
|
-
if (param.type === "AssignmentPattern") {
|
|
99
|
-
const ap = param;
|
|
100
|
-
if (ap.left.type === "Identifier") {
|
|
101
|
-
args.push(ap.left.name);
|
|
102
|
-
} else if (ap.left.type === "ObjectPattern") {
|
|
103
|
-
const obj = buildObjectCallArg(ap.left);
|
|
104
|
-
if (obj === null) {
|
|
105
|
-
return null;
|
|
106
|
-
}
|
|
107
|
-
args.push(obj);
|
|
108
|
-
} else {
|
|
109
|
-
return null;
|
|
110
|
-
}
|
|
111
|
-
continue;
|
|
112
|
-
}
|
|
113
|
-
return null;
|
|
114
|
-
}
|
|
115
|
-
return args.join(", ");
|
|
116
|
-
}
|
|
117
|
-
function buildObjectCallArg(pattern) {
|
|
118
|
-
const keys = [];
|
|
119
|
-
for (const prop of pattern.properties) {
|
|
120
|
-
if (prop.type === "RestElement") {
|
|
121
|
-
return null;
|
|
122
|
-
}
|
|
123
|
-
if (prop.key.type !== "Identifier") {
|
|
124
|
-
return null;
|
|
125
|
-
}
|
|
126
|
-
const keyName = prop.key.name;
|
|
127
|
-
let valueName = null;
|
|
128
|
-
if (prop.value.type === "Identifier") {
|
|
129
|
-
valueName = prop.value.name;
|
|
130
|
-
} else if (prop.value.type === "AssignmentPattern") {
|
|
131
|
-
if (prop.value.left.type === "Identifier") {
|
|
132
|
-
valueName = prop.value.left.name;
|
|
133
|
-
} else {
|
|
134
|
-
return null;
|
|
135
|
-
}
|
|
136
|
-
} else {
|
|
137
|
-
return null;
|
|
138
|
-
}
|
|
139
|
-
if (valueName !== keyName) {
|
|
140
|
-
keys.push(`${keyName}: ${valueName}`);
|
|
141
|
-
} else {
|
|
142
|
-
keys.push(keyName);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
return `{ ${keys.join(", ")} }`;
|
|
146
|
-
}
|
|
147
|
-
function buildWrappedExport(fnName, fnHeader, originalFnSrc, innerArgs, awaitKw, asyncKw, apiFolder, filename) {
|
|
148
|
-
const privateName = `__${fnName}`;
|
|
149
|
-
const spanName = `redwoodjs:api:${apiFolder}:${fnName}`;
|
|
150
|
-
return `export const ${fnName} = ${fnHeader}{
|
|
151
|
-
const ${privateName} = ${originalFnSrc}
|
|
152
|
-
const OTEL_TRACER = OTEL_TRACE.getTracer('redwoodjs')
|
|
153
|
-
const OTEL_RESULT = ${awaitKw}OTEL_TRACER.startActiveSpan(
|
|
154
|
-
'${spanName}',
|
|
155
|
-
${asyncKw}(span) => {
|
|
156
|
-
span.setAttribute('code.function', '${fnName}')
|
|
157
|
-
span.setAttribute('code.filepath', ${JSON.stringify(filename)})
|
|
158
|
-
try {
|
|
159
|
-
const OTEL_INNER_RESULT = ${awaitKw}${privateName}(${innerArgs})
|
|
160
|
-
span.end()
|
|
161
|
-
return OTEL_INNER_RESULT
|
|
162
|
-
} catch (error) {
|
|
163
|
-
span.recordException(error)
|
|
164
|
-
span.setStatus({
|
|
165
|
-
code: 2,
|
|
166
|
-
message:
|
|
167
|
-
error?.message?.split('\\n')[0] ??
|
|
168
|
-
error?.toString()?.split('\\n')[0],
|
|
169
|
-
})
|
|
170
|
-
span.end()
|
|
171
|
-
throw error
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
)
|
|
175
|
-
return OTEL_RESULT
|
|
176
|
-
}`;
|
|
177
|
-
}
|
|
178
|
-
export {
|
|
179
|
-
applyOtelWrapping
|
|
180
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
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,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* For ESM projects using esbuild with `bundle: false`, rewrites extensionless
|
|
3
|
-
* relative imports to include `.js` extension so that Node's ESM resolver can
|
|
4
|
-
* locate the compiled output files at runtime.
|
|
5
|
-
*
|
|
6
|
-
* Handles both static imports (`from '../lib/db'`) and dynamic imports
|
|
7
|
-
* (`import('../lib/db')`).
|
|
8
|
-
*
|
|
9
|
-
* Always outputs `.js` because esbuild with `loader: 'js'` compiles all source
|
|
10
|
-
* files (`.ts`, `.tsx`, `.jsx`) to `.js` output. For a source file `api/src/lib/db.ts`
|
|
11
|
-
* or `api/src/lib/db.tsx`, the output is always `api/dist/lib/db.js`, so all
|
|
12
|
-
* import specifiers must use `.js` at runtime.
|
|
13
|
-
*
|
|
14
|
-
* This replaces the `resolvePath` hook in `babel-plugin-module-resolver` for
|
|
15
|
-
* the standalone esbuild build path (`runCedarBabelTransformsPlugin`), which
|
|
16
|
-
* was previously responsible for this extension-appending behaviour. Vite
|
|
17
|
-
* and Rollup resolve extensions themselves during bundling; only the esbuild
|
|
18
|
-
* `bundle: false` path needs explicit extension suffixes in the source.
|
|
19
|
-
*
|
|
20
|
-
* It is a plain function called inline — not an esbuild plugin — following
|
|
21
|
-
* the same pattern as `applySrcAlias`, `applyTsconfigPaths`, etc.
|
|
22
|
-
*
|
|
23
|
-
* Also handles Cedar SDL files whose names include a compound extension:
|
|
24
|
-
* `contacts.sdl.ts` compiles to `contacts.sdl.js`, so an import specifier
|
|
25
|
-
* `../graphql/contacts.sdl` (generated by applyImportDir's glob expansion)
|
|
26
|
-
* is rewritten to `../graphql/contacts.sdl.js`.
|
|
27
|
-
*
|
|
28
|
-
* Example: in `api/src/functions/graphql.ts` importing `../lib/db`, this
|
|
29
|
-
* rewrites it to `../lib/db.js` when `api/src/lib/db.ts` (or `db.tsx`)
|
|
30
|
-
* exists on disk.
|
|
31
|
-
*/
|
|
32
|
-
export declare function applyEsmExtensions(code: string, fromFile: string): string;
|
|
33
|
-
//# sourceMappingURL=esm-extensions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"esm-extensions.d.ts","sourceRoot":"","sources":["../../src/build/esm-extensions.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAiEzE"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
function applyEsmExtensions(code, fromFile) {
|
|
4
|
-
const fromDir = path.dirname(fromFile);
|
|
5
|
-
const rewriteImportPath = (importPath, preservePrefix, preserveSuffix) => {
|
|
6
|
-
const existingExt = path.extname(importPath);
|
|
7
|
-
const absImport = path.join(fromDir, importPath);
|
|
8
|
-
if (existingExt && existingExt !== ".js" && existingExt !== ".jsx") {
|
|
9
|
-
if (fs.existsSync(absImport + ".ts") || fs.existsSync(absImport + ".js") || fs.existsSync(absImport + ".tsx") || fs.existsSync(absImport + ".jsx")) {
|
|
10
|
-
return preservePrefix + importPath + ".js" + preserveSuffix;
|
|
11
|
-
}
|
|
12
|
-
return preservePrefix + importPath + preserveSuffix;
|
|
13
|
-
}
|
|
14
|
-
const base = existingExt ? importPath.slice(0, -existingExt.length) : importPath;
|
|
15
|
-
const absBase = path.join(fromDir, base);
|
|
16
|
-
if (fs.existsSync(absBase + ".ts") || fs.existsSync(absBase + ".js") || fs.existsSync(absBase + ".tsx") || fs.existsSync(absBase + ".jsx")) {
|
|
17
|
-
return preservePrefix + base + ".js" + preserveSuffix;
|
|
18
|
-
}
|
|
19
|
-
return preservePrefix + importPath + preserveSuffix;
|
|
20
|
-
};
|
|
21
|
-
let result = code.replace(
|
|
22
|
-
/\bfrom\s+(['"])(\.\.?\/[^'"]+)\1/g,
|
|
23
|
-
(match, quote, importPath) => {
|
|
24
|
-
return `from ${rewriteImportPath(importPath, quote, quote)}`;
|
|
25
|
-
}
|
|
26
|
-
);
|
|
27
|
-
result = result.replace(
|
|
28
|
-
/\bimport\s*\(\s*(['"])(\.\.?\/[^'"]+)\1\s*\)/g,
|
|
29
|
-
(match, quote, importPath) => {
|
|
30
|
-
return `import(${rewriteImportPath(importPath, quote, quote)})`;
|
|
31
|
-
}
|
|
32
|
-
);
|
|
33
|
-
return result;
|
|
34
|
-
}
|
|
35
|
-
export {
|
|
36
|
-
applyEsmExtensions
|
|
37
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { SourceMap } from 'magic-string';
|
|
2
|
-
/**
|
|
3
|
-
* Expands glob directory imports such as:
|
|
4
|
-
* import services from 'src/services/**\/*.{js,ts}'
|
|
5
|
-
* into individual namespace imports:
|
|
6
|
-
* let services = {}
|
|
7
|
-
* import * as services_a from 'src/services/a'
|
|
8
|
-
* services.a = services_a
|
|
9
|
-
*
|
|
10
|
-
* This is the esbuild-path equivalent of:
|
|
11
|
-
* - babel-plugin-redwood-import-dir (kept for Jest / console / data-migrate)
|
|
12
|
-
* - cedarImportDirPlugin (Vite plugin, for Vite build paths)
|
|
13
|
-
*
|
|
14
|
-
* Code duplication between the two non-Babel plugins is intentional.
|
|
15
|
-
*
|
|
16
|
-
* Returns the transformed source code, or null if no glob imports were found.
|
|
17
|
-
*/
|
|
18
|
-
export declare function applyImportDir(code: string, filePath: string): {
|
|
19
|
-
code: string;
|
|
20
|
-
map?: SourceMap;
|
|
21
|
-
} | null;
|
|
22
|
-
//# sourceMappingURL=import-dir.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"import-dir.d.ts","sourceRoot":"","sources":["../../src/build/import-dir.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAI7C;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GACf;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,SAAS,CAAA;CAAE,GAAG,IAAI,CAyE1C"}
|
package/dist/build/import-dir.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import MagicString from "magic-string";
|
|
4
|
-
import { getPaths, importStatementPath } from "@cedarjs/project-config";
|
|
5
|
-
function applyImportDir(code, filePath) {
|
|
6
|
-
if (!code.includes("**")) {
|
|
7
|
-
return null;
|
|
8
|
-
}
|
|
9
|
-
const GLOB_IMPORT_RE = /^import\s+(\w+)\s+from\s+['"]([^'"]+)['"]\s*;?/gm;
|
|
10
|
-
const s = new MagicString(code);
|
|
11
|
-
let hasTransformations = false;
|
|
12
|
-
for (const match of code.matchAll(GLOB_IMPORT_RE)) {
|
|
13
|
-
const importName = match[1];
|
|
14
|
-
const sourceValue = match[2];
|
|
15
|
-
if (!sourceValue.includes("**")) {
|
|
16
|
-
continue;
|
|
17
|
-
}
|
|
18
|
-
const importGlob = importStatementPath(sourceValue);
|
|
19
|
-
const cwd = importGlob.startsWith("src/") ? getPaths().api.base : path.dirname(filePath);
|
|
20
|
-
let dirFiles;
|
|
21
|
-
try {
|
|
22
|
-
dirFiles = fs.globSync(importGlob, {
|
|
23
|
-
cwd,
|
|
24
|
-
exclude: (n) => n.includes(".test.") || n.includes(".scenarios.") || n.includes(".d.ts")
|
|
25
|
-
});
|
|
26
|
-
} catch {
|
|
27
|
-
continue;
|
|
28
|
-
}
|
|
29
|
-
const staticGlob = importGlob.split("*")[0];
|
|
30
|
-
const filePathToVarName = (fp) => fp.replace(staticGlob, "").replace(/\.(js|ts)$/, "").replace(/[^a-zA-Z0-9]/g, "_");
|
|
31
|
-
hasTransformations = true;
|
|
32
|
-
let replacement = `let ${importName} = {};
|
|
33
|
-
`;
|
|
34
|
-
for (const fp of dirFiles) {
|
|
35
|
-
const { dir: fileDir, name: fileName } = path.parse(fp);
|
|
36
|
-
const normalizedDir = importStatementPath(fileDir);
|
|
37
|
-
const varName = filePathToVarName(fp);
|
|
38
|
-
const nsImport = `${importName}_${varName}`;
|
|
39
|
-
replacement += `import * as ${nsImport} from '${normalizedDir}/${fileName}';
|
|
40
|
-
`;
|
|
41
|
-
replacement += `${importName}.${varName} = ${nsImport};
|
|
42
|
-
`;
|
|
43
|
-
}
|
|
44
|
-
s.overwrite(
|
|
45
|
-
match.index,
|
|
46
|
-
match.index + match[0].length,
|
|
47
|
-
replacement.trimEnd()
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
return hasTransformations ? { code: s.toString(), map: s.generateMap({ hires: true }) } : null;
|
|
51
|
-
}
|
|
52
|
-
export {
|
|
53
|
-
applyImportDir
|
|
54
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Injects `path` and `name` properties into `createJob()` definitions so the
|
|
3
|
-
* jobs runner can locate and identify the job's module at runtime.
|
|
4
|
-
*
|
|
5
|
-
* Standalone equivalent of the Vite cedarjsJobPathInjectorPlugin (used by
|
|
6
|
-
* buildApp and apiDevMiddleware) and the Babel pluginRedwoodJobPathInjector
|
|
7
|
-
* override they replaced. Applied inline in the esbuild API build and the
|
|
8
|
-
* standalone-Vite API build so neither path depends on Babel for job path
|
|
9
|
-
* injection.
|
|
10
|
-
*
|
|
11
|
-
* Keep this in sync with
|
|
12
|
-
* packages/vite/src/plugins/vite-plugin-cedarjs-job-path-injector.ts.
|
|
13
|
-
*/
|
|
14
|
-
export declare function applyJobPathInjector(code: string, filePath: string, jobsDir: string): string | null;
|
|
15
|
-
//# sourceMappingURL=job-path-injector.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"job-path-injector.d.ts","sourceRoot":"","sources":["../../src/build/job-path-injector.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GACd,MAAM,GAAG,IAAI,CA8Ff"}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { parseSync } from "oxc-parser";
|
|
3
|
-
function applyJobPathInjector(code, filePath, jobsDir) {
|
|
4
|
-
if (!code.includes("createJob")) {
|
|
5
|
-
return null;
|
|
6
|
-
}
|
|
7
|
-
let program;
|
|
8
|
-
try {
|
|
9
|
-
program = parseSync(filePath, code, { sourceType: "module" }).program;
|
|
10
|
-
} catch (error) {
|
|
11
|
-
console.warn("Failed to parse file:", filePath);
|
|
12
|
-
console.warn(error);
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
const importPath = path.relative(jobsDir, filePath);
|
|
16
|
-
const importPathWithoutExtension = importPath.replace(/\.[^/.]+$/, "");
|
|
17
|
-
const insertions = [];
|
|
18
|
-
for (const node of program.body) {
|
|
19
|
-
if (node.type !== "ExportNamedDeclaration") {
|
|
20
|
-
continue;
|
|
21
|
-
}
|
|
22
|
-
const decl = node.declaration;
|
|
23
|
-
if (decl?.type !== "VariableDeclaration") {
|
|
24
|
-
continue;
|
|
25
|
-
}
|
|
26
|
-
for (const declarator of decl.declarations) {
|
|
27
|
-
if (declarator.id.type !== "Identifier") {
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
30
|
-
const init = declarator.init;
|
|
31
|
-
if (init?.type !== "CallExpression") {
|
|
32
|
-
continue;
|
|
33
|
-
}
|
|
34
|
-
const callee = init.callee;
|
|
35
|
-
if (callee.type !== "MemberExpression" || callee.computed || callee.property.type !== "Identifier" || callee.property.name !== "createJob") {
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
const configArg = init.arguments[0];
|
|
39
|
-
if (configArg?.type !== "ObjectExpression") {
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
const pathProperty = `path: ${JSON.stringify(importPathWithoutExtension)}`;
|
|
43
|
-
const nameProperty = `name: ${JSON.stringify(declarator.id.name)}`;
|
|
44
|
-
const lastProperty = configArg.properties.at(-1);
|
|
45
|
-
if (lastProperty) {
|
|
46
|
-
insertions.push({
|
|
47
|
-
pos: lastProperty.end,
|
|
48
|
-
text: `, ${pathProperty}, ${nameProperty}`
|
|
49
|
-
});
|
|
50
|
-
} else {
|
|
51
|
-
insertions.push({
|
|
52
|
-
pos: configArg.start + 1,
|
|
53
|
-
text: `${pathProperty}, ${nameProperty}`
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
if (insertions.length === 0) {
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
let result = code;
|
|
62
|
-
for (const { pos, text } of insertions.sort((a, b) => b.pos - a.pos)) {
|
|
63
|
-
result = result.slice(0, pos) + text + result.slice(pos);
|
|
64
|
-
}
|
|
65
|
-
return result;
|
|
66
|
-
}
|
|
67
|
-
export {
|
|
68
|
-
applyJobPathInjector
|
|
69
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Rewrites `src/` bare specifiers in source code to relative paths, so that the
|
|
3
|
-
* esbuild API build (with `bundle: false`) produces output files with
|
|
4
|
-
* resolvable import paths at runtime.
|
|
5
|
-
*
|
|
6
|
-
* This replaces the `babel-plugin-module-resolver` `src: './src'` alias for the
|
|
7
|
-
* esbuild build paths. It is a plain function called inline from the existing
|
|
8
|
-
* esbuild `onLoad` handlers — not an esbuild plugin itself.
|
|
9
|
-
*
|
|
10
|
-
* For a file at `api/src/functions/graphql.ts` importing `src/lib/db`, this
|
|
11
|
-
* rewrites it to `../lib/db`.
|
|
12
|
-
*/
|
|
13
|
-
export declare function applySrcAlias(code: string, fromDirRelativeToApiSrc: string): string;
|
|
14
|
-
//# sourceMappingURL=src-alias.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"src-alias.d.ts","sourceRoot":"","sources":["../../src/build/src-alias.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AAEH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,uBAAuB,EAAE,MAAM,GAC9B,MAAM,CAWR"}
|
package/dist/build/src-alias.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { importStatementPath } from "@cedarjs/project-config";
|
|
3
|
-
function applySrcAlias(code, fromDirRelativeToApiSrc) {
|
|
4
|
-
return code.replace(
|
|
5
|
-
/from\s+['"]src\/(.+?)['"]/g,
|
|
6
|
-
(_match, rest) => {
|
|
7
|
-
const target = path.relative(fromDirRelativeToApiSrc, rest);
|
|
8
|
-
const formatted = importStatementPath(
|
|
9
|
-
target.startsWith(".") ? target : "./" + target
|
|
10
|
-
);
|
|
11
|
-
return `from '${formatted}'`;
|
|
12
|
-
}
|
|
13
|
-
);
|
|
14
|
-
}
|
|
15
|
-
export {
|
|
16
|
-
applySrcAlias
|
|
17
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tsconfig-paths.d.ts","sourceRoot":"","sources":["../../src/build/tsconfig-paths.ts"],"names":[],"mappings":"AA8FA,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,GACV,MAAM,CAyCR"}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { createMatchPath, loadConfig } from "tsconfig-paths";
|
|
3
|
-
import { importStatementPath, resolveFile } from "@cedarjs/project-config";
|
|
4
|
-
const EXCLUDED_PATH_KEY_RE = /src\/|\$api\/\*|types\/\*|@cedarjs\/.*/;
|
|
5
|
-
const RESOLVE_EXTENSIONS = [
|
|
6
|
-
".js",
|
|
7
|
-
".tsx",
|
|
8
|
-
".ts",
|
|
9
|
-
".jsx",
|
|
10
|
-
".mjs",
|
|
11
|
-
".mts",
|
|
12
|
-
".cjs"
|
|
13
|
-
];
|
|
14
|
-
const BARE_IMPORT_RE = /\bfrom\s+(['"])([^'"./][^'"]*)\1/g;
|
|
15
|
-
function getMatchPath(cwd) {
|
|
16
|
-
const config = loadConfig(cwd);
|
|
17
|
-
if (config.resultType === "failed") {
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
const paths = Object.fromEntries(
|
|
21
|
-
Object.entries(config.paths).filter(
|
|
22
|
-
([key]) => !EXCLUDED_PATH_KEY_RE.test(key)
|
|
23
|
-
)
|
|
24
|
-
);
|
|
25
|
-
if (Object.keys(paths).length === 0) {
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
return createMatchPath(config.absoluteBaseUrl, paths);
|
|
29
|
-
}
|
|
30
|
-
function resolveToFile(candidate) {
|
|
31
|
-
if (resolveFile(candidate)) {
|
|
32
|
-
return candidate;
|
|
33
|
-
}
|
|
34
|
-
if (resolveFile(path.join(candidate, "index"))) {
|
|
35
|
-
return path.join(candidate, "index");
|
|
36
|
-
}
|
|
37
|
-
const basename = path.basename(candidate);
|
|
38
|
-
if (resolveFile(path.join(candidate, basename))) {
|
|
39
|
-
return path.join(candidate, basename);
|
|
40
|
-
}
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
function applyTsconfigPaths(code, filePath, cwd) {
|
|
44
|
-
const matchPath = getMatchPath(cwd);
|
|
45
|
-
if (!matchPath) {
|
|
46
|
-
return code;
|
|
47
|
-
}
|
|
48
|
-
return code.replace(
|
|
49
|
-
BARE_IMPORT_RE,
|
|
50
|
-
(full, quote, importPath) => {
|
|
51
|
-
const basename = importPath.split("/").pop();
|
|
52
|
-
const rawMatch = matchPath(importPath, void 0, void 0, RESOLVE_EXTENSIONS) ?? (basename && matchPath(
|
|
53
|
-
`${importPath}/${basename}`,
|
|
54
|
-
void 0,
|
|
55
|
-
void 0,
|
|
56
|
-
RESOLVE_EXTENSIONS
|
|
57
|
-
));
|
|
58
|
-
const resolved = rawMatch && resolveToFile(rawMatch);
|
|
59
|
-
if (!resolved) {
|
|
60
|
-
return full;
|
|
61
|
-
}
|
|
62
|
-
const relativePath = path.relative(path.dirname(filePath), resolved);
|
|
63
|
-
const formatted = importStatementPath(
|
|
64
|
-
relativePath.startsWith(".") ? relativePath : "./" + relativePath
|
|
65
|
-
);
|
|
66
|
-
return `from ${quote}${formatted}${quote}`;
|
|
67
|
-
}
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
export {
|
|
71
|
-
applyTsconfigPaths
|
|
72
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import * as Cell from './${name}.js'
|
|
2
|
-
import type { ${fragmentType} } from 'types/graphql'
|
|
3
|
-
|
|
4
|
-
type SuccessType = typeof Cell.Success
|
|
5
|
-
|
|
6
|
-
export * from './${name}.js'
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* ${fragmentPropName} is the slice of a parent Cell's query result that
|
|
10
|
-
* matches this Cell's FRAGMENT. The parent spreads the fragment in its QUERY
|
|
11
|
-
* and passes the fetched data object down, e.g.
|
|
12
|
-
* <Cell ${fragmentPropName}={data.someField} />
|
|
13
|
-
*/
|
|
14
|
-
type FragmentCellInputs = { ${fragmentPropName}: ${fragmentType} } & Record<string, unknown>
|
|
15
|
-
|
|
16
|
-
export default function (props: FragmentCellInputs): ReturnType<SuccessType>
|
|
17
|
-
|
|
18
|
-
//# sourceMappingURL=index.d.ts.map
|