@cedarjs/internal 8.0.0-canary.3483 → 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.
@@ -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>) => void;
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,SAY7C,CAAA"}
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 template = templatized(templateString, templateValues);
10
- fs.writeFileSync(
11
- destination,
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,WAiFnE,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"}
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 = cellQuery ? void 0 : getCellGqlFragment(fileContents);
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("templates/mirror-cell.d.ts.template", typeDefPath, {
129
- name,
130
- queryResultType: `${gqlDoc?.name}`,
131
- queryVariablesType: `${gqlDoc?.name}Variables`
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("templates/mirror-cell-fragment.d.ts.template", typeDefPath, {
135
- name,
136
- fragmentType: cellFragmentName,
137
- fragmentPropName: cellFragmentPropName
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("templates/mirror-cell.d.ts.template", typeDefPath, {
141
- name,
142
- queryResultType: "any",
143
- queryVariablesType: "any"
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
- line: 12,
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.3483",
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.3483",
124
- "@cedarjs/babel-config": "8.0.0-canary.3483",
125
- "@cedarjs/cli-helpers": "8.0.0-canary.3483",
126
- "@cedarjs/graphql-server": "8.0.0-canary.3483",
127
- "@cedarjs/project-config": "8.0.0-canary.3483",
128
- "@cedarjs/router": "8.0.0-canary.3483",
129
- "@cedarjs/structure": "8.0.0-canary.3483",
130
- "@cedarjs/utils": "8.0.0-canary.3483",
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.3483",
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",