@cedarjs/internal 8.0.0-canary.3487 → 8.0.0-canary.3489
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/generate/templates/mirror-typed-cell.d.ts.template +14 -0
- package/dist/generate/templates.d.ts +1 -1
- package/dist/generate/templates.d.ts.map +1 -1
- package/dist/generate/templates.js +3 -5
- package/dist/generate/typeDefinitions.d.ts.map +1 -1
- package/dist/generate/typeDefinitions.js +47 -18
- package/package.json +10 -10
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as Cell from './${name}.js'
|
|
2
|
+
import type { CellProps } from '@cedarjs/web'
|
|
3
|
+
import type { CellQueryTypes } from '@cedarjs/web/cellTypes'
|
|
4
|
+
|
|
5
|
+
type SuccessType = typeof Cell.Success
|
|
6
|
+
type QueryTypes = CellQueryTypes<typeof Cell.QUERY>
|
|
7
|
+
|
|
8
|
+
export * from './${name}.js'
|
|
9
|
+
|
|
10
|
+
type CellInputs = CellProps<SuccessType, QueryTypes[0], typeof Cell, QueryTypes[1]>
|
|
11
|
+
|
|
12
|
+
export default function (props: CellInputs): ReturnType<SuccessType>
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Write the contents of the template to the destination and interpolate the variables.
|
|
3
3
|
* The template is a string that uses standard es6 template literals which allow embded expression.
|
|
4
4
|
*/
|
|
5
|
-
export declare const writeTemplate: (templatePath: string, destination: string, templateValues?: Record<string, unknown>) =>
|
|
5
|
+
export declare const writeTemplate: (templatePath: string, destination: string, templateValues?: Record<string, unknown>) => string;
|
|
6
6
|
//# sourceMappingURL=templates.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/generate/templates.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,eAAO,MAAM,aAAa,GACxB,cAAc,MAAM,EACpB,aAAa,MAAM,EACnB,iBAAgB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,
|
|
1
|
+
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/generate/templates.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,eAAO,MAAM,aAAa,GACxB,cAAc,MAAM,EACpB,aAAa,MAAM,EACnB,iBAAgB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,WAa7C,CAAA"}
|
|
@@ -6,11 +6,9 @@ const writeTemplate = (templatePath, destination, templateValues = {}) => {
|
|
|
6
6
|
path.join(___dirname, templatePath),
|
|
7
7
|
"utf-8"
|
|
8
8
|
);
|
|
9
|
-
const
|
|
10
|
-
fs.writeFileSync(
|
|
11
|
-
|
|
12
|
-
"// This file was generated by CedarJS\n" + template
|
|
13
|
-
);
|
|
9
|
+
const contents = "// This file was generated by CedarJS\n" + templatized(templateString, templateValues);
|
|
10
|
+
fs.writeFileSync(destination, contents);
|
|
11
|
+
return contents;
|
|
14
12
|
};
|
|
15
13
|
const templatized = (template, vars = {}) => {
|
|
16
14
|
const handler = new Function(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeDefinitions.d.ts","sourceRoot":"","sources":["../../src/generate/typeDefinitions.ts"],"names":[],"mappings":"AA8CA;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;;;;EA0B5B,CAAA;AAED,eAAO,MAAM,mCAAmC,gBAK/C,CAAA;AAED,eAAO,MAAM,kCAAkC,GAC7C,GAAG,MAAM,EACT,mDAAsB,aASvB,CAAA;AAED,eAAO,MAAM,kCAAkC,GAC7C,GAAG,MAAM,EACT,mDAAsB,WAoDvB,CAAA;AAED,eAAO,MAAM,mBAAmB,gBAG/B,CAAA;AAED,eAAO,MAAM,iBAAiB,GAAI,GAAG,MAAM,EAAE,mDAAsB,aAQlE,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,GAAG,MAAM,EAAE,mDAAsB,
|
|
1
|
+
{"version":3,"file":"typeDefinitions.d.ts","sourceRoot":"","sources":["../../src/generate/typeDefinitions.ts"],"names":[],"mappings":"AA8CA;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;;;;EA0B5B,CAAA;AAED,eAAO,MAAM,mCAAmC,gBAK/C,CAAA;AAED,eAAO,MAAM,kCAAkC,GAC7C,GAAG,MAAM,EACT,mDAAsB,aASvB,CAAA;AAED,eAAO,MAAM,kCAAkC,GAC7C,GAAG,MAAM,EACT,mDAAsB,WAoDvB,CAAA;AAED,eAAO,MAAM,mBAAmB,gBAG/B,CAAA;AAED,eAAO,MAAM,iBAAiB,GAAI,GAAG,MAAM,EAAE,mDAAsB,aAQlE,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,GAAG,MAAM,EAAE,mDAAsB,WAmHnE,CAAA;AAiBD,eAAO,MAAM,2BAA2B,gBAmEvC,CAAA;AAED,eAAO,MAAM,0BAA0B,gBA8CtC,CAAA;AAED,eAAO,MAAM,0BAA0B,gBAEtC,CAAA;AAED,eAAO,MAAM,qBAAqB,gBAEjC,CAAA;AAED,eAAO,MAAM,wBAAwB,gBAEpC,CAAA;AAED,eAAO,MAAM,wBAAwB,gBAKpC,CAAA;AAED,eAAO,MAAM,0BAA0B,gBAEtC,CAAA;AAED,eAAO,MAAM,4BAA4B,gBAExC,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,gCAAgC,gBAW5C,CAAA"}
|
|
@@ -119,32 +119,56 @@ const generateMirrorCell = (p, rwjsPaths = getPaths()) => {
|
|
|
119
119
|
const typeDefPath = path.join(mirrorDir, typeDef);
|
|
120
120
|
const { name } = path.parse(p);
|
|
121
121
|
const fileContents = fileToAst(p);
|
|
122
|
+
const exportedComponents = getNamedExports(fileContents);
|
|
123
|
+
const hasQuery = exportedComponents.some(
|
|
124
|
+
(component) => component.name === "QUERY"
|
|
125
|
+
);
|
|
122
126
|
const cellQuery = getCellGqlQuery(fileContents);
|
|
123
|
-
const cellFragment =
|
|
127
|
+
const cellFragment = hasQuery ? void 0 : getCellGqlFragment(fileContents);
|
|
124
128
|
const cellFragmentName = cellFragment ? parseGqlFragmentName(cellFragment) : void 0;
|
|
125
129
|
const cellFragmentPropName = cellFragment ? parseGqlFragmentPropName(cellFragment) : void 0;
|
|
130
|
+
let typeDefContents;
|
|
126
131
|
if (cellQuery) {
|
|
127
132
|
const gqlDoc = parseGqlQueryToAst(cellQuery)[0];
|
|
128
|
-
writeTemplate(
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
+
typeDefContents = writeTemplate(
|
|
134
|
+
"templates/mirror-cell.d.ts.template",
|
|
135
|
+
typeDefPath,
|
|
136
|
+
{
|
|
137
|
+
name,
|
|
138
|
+
queryResultType: `${gqlDoc?.name}`,
|
|
139
|
+
queryVariablesType: `${gqlDoc?.name}Variables`
|
|
140
|
+
}
|
|
141
|
+
);
|
|
133
142
|
} else if (cellFragmentName && cellFragmentPropName) {
|
|
134
|
-
writeTemplate(
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
143
|
+
typeDefContents = writeTemplate(
|
|
144
|
+
"templates/mirror-cell-fragment.d.ts.template",
|
|
145
|
+
typeDefPath,
|
|
146
|
+
{
|
|
147
|
+
name,
|
|
148
|
+
fragmentType: cellFragmentName,
|
|
149
|
+
fragmentPropName: cellFragmentPropName
|
|
150
|
+
}
|
|
151
|
+
);
|
|
152
|
+
} else if (hasQuery) {
|
|
153
|
+
typeDefContents = writeTemplate(
|
|
154
|
+
"templates/mirror-typed-cell.d.ts.template",
|
|
155
|
+
typeDefPath,
|
|
156
|
+
{
|
|
157
|
+
name
|
|
158
|
+
}
|
|
159
|
+
);
|
|
139
160
|
} else {
|
|
140
|
-
writeTemplate(
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
161
|
+
typeDefContents = writeTemplate(
|
|
162
|
+
"templates/mirror-cell.d.ts.template",
|
|
163
|
+
typeDefPath,
|
|
164
|
+
{
|
|
165
|
+
name,
|
|
166
|
+
queryResultType: "any",
|
|
167
|
+
queryVariablesType: "any"
|
|
168
|
+
}
|
|
169
|
+
);
|
|
145
170
|
}
|
|
146
171
|
try {
|
|
147
|
-
const exportedComponents = getNamedExports(fileContents);
|
|
148
172
|
const successComponent = exportedComponents.find(
|
|
149
173
|
(x) => x.name === "Success"
|
|
150
174
|
);
|
|
@@ -154,9 +178,14 @@ const generateMirrorCell = (p, rwjsPaths = getPaths()) => {
|
|
|
154
178
|
const map = new SourceMapGenerator({
|
|
155
179
|
file: "index.d.ts"
|
|
156
180
|
});
|
|
181
|
+
const defaultExportIndex = typeDefContents.split("\n").findIndex((line) => line.startsWith("export default function"));
|
|
182
|
+
if (defaultExportIndex === -1) {
|
|
183
|
+
throw new Error("No default export found in the generated mirror type");
|
|
184
|
+
}
|
|
157
185
|
map.addMapping({
|
|
158
186
|
generated: {
|
|
159
|
-
|
|
187
|
+
// Source map lines are 1-based
|
|
188
|
+
line: defaultExportIndex + 1,
|
|
160
189
|
column: 0
|
|
161
190
|
},
|
|
162
191
|
source: path.relative(path.dirname(typeDefPath), p),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/internal",
|
|
3
|
-
"version": "8.0.0-canary.
|
|
3
|
+
"version": "8.0.0-canary.3489",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/cedarjs/cedar.git",
|
|
@@ -120,14 +120,14 @@
|
|
|
120
120
|
"@babel/core": "^7.26.10",
|
|
121
121
|
"@babel/parser": "7.29.9",
|
|
122
122
|
"@babel/traverse": "7.29.10",
|
|
123
|
-
"@cedarjs/api": "8.0.0-canary.
|
|
124
|
-
"@cedarjs/babel-config": "8.0.0-canary.
|
|
125
|
-
"@cedarjs/cli-helpers": "8.0.0-canary.
|
|
126
|
-
"@cedarjs/graphql-server": "8.0.0-canary.
|
|
127
|
-
"@cedarjs/project-config": "8.0.0-canary.
|
|
128
|
-
"@cedarjs/router": "8.0.0-canary.
|
|
129
|
-
"@cedarjs/structure": "8.0.0-canary.
|
|
130
|
-
"@cedarjs/utils": "8.0.0-canary.
|
|
123
|
+
"@cedarjs/api": "8.0.0-canary.3489",
|
|
124
|
+
"@cedarjs/babel-config": "8.0.0-canary.3489",
|
|
125
|
+
"@cedarjs/cli-helpers": "8.0.0-canary.3489",
|
|
126
|
+
"@cedarjs/graphql-server": "8.0.0-canary.3489",
|
|
127
|
+
"@cedarjs/project-config": "8.0.0-canary.3489",
|
|
128
|
+
"@cedarjs/router": "8.0.0-canary.3489",
|
|
129
|
+
"@cedarjs/structure": "8.0.0-canary.3489",
|
|
130
|
+
"@cedarjs/utils": "8.0.0-canary.3489",
|
|
131
131
|
"@graphql-codegen/add": "6.0.1",
|
|
132
132
|
"@graphql-codegen/cli": "6.3.1",
|
|
133
133
|
"@graphql-codegen/client-preset": "5.3.0",
|
|
@@ -165,7 +165,7 @@
|
|
|
165
165
|
"vite-tsconfig-paths": "^6.1.1"
|
|
166
166
|
},
|
|
167
167
|
"devDependencies": {
|
|
168
|
-
"@cedarjs/framework-tools": "8.0.0-canary.
|
|
168
|
+
"@cedarjs/framework-tools": "8.0.0-canary.3489",
|
|
169
169
|
"@jridgewell/trace-mapping": "0.3.31",
|
|
170
170
|
"@oxc-project/types": "^0.154.0",
|
|
171
171
|
"concurrently": "9.2.5",
|