@cedarjs/internal 8.0.0-canary.3582 → 8.0.0-canary.3587

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.
@@ -129,7 +129,7 @@ const generateMirrorCell = (p, rwjsPaths = getPaths()) => {
129
129
  const cellQuery = getCellGqlQuery(fileContents);
130
130
  const cellFragment = hasQuery ? void 0 : getCellGqlFragment(fileContents);
131
131
  const cellFragmentName = cellFragment ? parseGqlFragmentName(cellFragment) : void 0;
132
- const cellFragmentPropName = cellFragment ? parseGqlFragmentPropName(cellFragment) : void 0;
132
+ const cellFragmentPropName = cellFragment ? parseGqlFragmentPropName(cellFragment, name) : void 0;
133
133
  let typeDefContents;
134
134
  if (cellQuery) {
135
135
  const gqlDoc = parseGqlQueryToAst(cellQuery)[0];
package/dist/gql.d.ts CHANGED
@@ -11,8 +11,8 @@ export declare const parseGqlQueryToAst: (gqlQuery: string) => Operation[];
11
11
  export declare const parseDocumentAST: (document: DocumentNode) => Operation[];
12
12
  /**
13
13
  * Returns the name of the first fragment definition in the given GraphQL
14
- * source, e.g. `AuthorCell_author` for
15
- * `fragment AuthorCell_author on User { fullName }`
14
+ * source, e.g. `AuthorCellFragment` for
15
+ * `fragment AuthorCellFragment on User { fullName }`
16
16
  */
17
17
  export declare const parseGqlFragmentName: (gqlFragment: string) => string | undefined;
18
18
  /**
@@ -20,15 +20,25 @@ export declare const parseGqlFragmentName: (gqlFragment: string) => string | und
20
20
  * parent Cell passes the fragment data in with, and the prop `Success`
21
21
  * receives the data as.
22
22
  *
23
- * For a fragment named with an underscore, like `AuthorCell_author`, the part
24
- * after the last underscore is used (`author`). Otherwise the type the
25
- * fragment is defined on is used, camelCased (`on User` -> `user`).
23
+ * The first of these rules that applies picks the name:
24
+ *
25
+ * 1. For a fragment named with an underscore, like `AuthorCell_author`, the
26
+ * part after the last underscore is used (`author`).
27
+ * 2. For a fragment named after the Cell, followed by `Fragment` and a
28
+ * PascalCased prop name, like `PostCellFragmentAuthor` in `PostCell`, the
29
+ * camelCased prop name is used (`author`).
30
+ * 3. Otherwise the type the fragment is defined on is used, camelCased
31
+ * (`fragment AuthorCellFragment on User` -> `user`).
32
+ *
33
+ * `cellName` is the Cell's file name without the extension, like
34
+ * `PostCell`. It's the same name the Cell transforms pass to `createCell` as
35
+ * `displayName`.
26
36
  *
27
37
  * Keep this in sync with getFragmentPropName in
28
38
  * packages/web/src/components/cell/createFragmentCell.tsx, which is what the
29
39
  * fragment Cell runtime uses.
30
40
  */
31
- export declare const parseGqlFragmentPropName: (gqlFragment: string) => string | undefined;
41
+ export declare const parseGqlFragmentPropName: (gqlFragment: string, cellName: string) => string | undefined;
32
42
  export declare const listQueryTypeFieldsInProject: () => Promise<string[]>;
33
43
  export {};
34
44
  //# sourceMappingURL=gql.d.ts.map
package/dist/gql.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"gql.d.ts","sourceRoot":"","sources":["../src/gql.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,YAAY,EAKZ,iBAAiB,EAClB,MAAM,SAAS,CAAA;AAMhB,UAAU,SAAS;IACjB,SAAS,EAAE,iBAAiB,CAAA;IAC5B,IAAI,EAAE,MAAM,GAAG,SAAS,CAAA;IACxB,MAAM,EAAE,CAAC,MAAM,GAAG,KAAK,CAAC,EAAE,CAAA;CAC3B;AAED,UAAU,KAAK;IACb,MAAM,EAAE,CAAC,MAAM,GAAG,KAAK,CAAC,EAAE,CAAA;CAC3B;AAED,eAAO,MAAM,kBAAkB,GAAI,UAAU,MAAM,gBAGlD,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,UAAU,YAAY,gBAoBtD,CAAA;AAyCD;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAAI,aAAa,MAAM,uBAEvD,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,wBAAwB,GAAI,aAAa,MAAM,uBAiB3D,CAAA;AAED,eAAO,MAAM,4BAA4B,yBA8BxC,CAAA"}
1
+ {"version":3,"file":"gql.d.ts","sourceRoot":"","sources":["../src/gql.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,YAAY,EAKZ,iBAAiB,EAClB,MAAM,SAAS,CAAA;AAMhB,UAAU,SAAS;IACjB,SAAS,EAAE,iBAAiB,CAAA;IAC5B,IAAI,EAAE,MAAM,GAAG,SAAS,CAAA;IACxB,MAAM,EAAE,CAAC,MAAM,GAAG,KAAK,CAAC,EAAE,CAAA;CAC3B;AAED,UAAU,KAAK;IACb,MAAM,EAAE,CAAC,MAAM,GAAG,KAAK,CAAC,EAAE,CAAA;CAC3B;AAED,eAAO,MAAM,kBAAkB,GAAI,UAAU,MAAM,gBAGlD,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,UAAU,YAAY,gBAoBtD,CAAA;AAyCD;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAAI,aAAa,MAAM,uBAEvD,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,wBAAwB,GACnC,aAAa,MAAM,EACnB,UAAU,MAAM,uBAkCjB,CAAA;AAED,eAAO,MAAM,4BAA4B,yBA8BxC,CAAA"}
package/dist/gql.js CHANGED
@@ -57,7 +57,7 @@ const parseGqlFragmentDefinition = (gqlFragment) => {
57
57
  const parseGqlFragmentName = (gqlFragment) => {
58
58
  return parseGqlFragmentDefinition(gqlFragment)?.name.value;
59
59
  };
60
- const parseGqlFragmentPropName = (gqlFragment) => {
60
+ const parseGqlFragmentPropName = (gqlFragment, cellName) => {
61
61
  const fragmentDefinition = parseGqlFragmentDefinition(gqlFragment);
62
62
  if (!fragmentDefinition) {
63
63
  return void 0;
@@ -67,6 +67,11 @@ const parseGqlFragmentPropName = (gqlFragment) => {
67
67
  if (underscoreIndex > 0 && underscoreIndex < fragmentName.length - 1) {
68
68
  return fragmentName.slice(underscoreIndex + 1);
69
69
  }
70
+ const cellFragmentPrefix = cellName + "Fragment";
71
+ const propNameSuffix = fragmentName.slice(cellFragmentPrefix.length);
72
+ if (fragmentName.startsWith(cellFragmentPrefix) && /^[A-Z]/.test(propNameSuffix)) {
73
+ return propNameSuffix.charAt(0).toLowerCase() + propNameSuffix.slice(1);
74
+ }
70
75
  const typename = fragmentDefinition.typeCondition.name.value;
71
76
  return typename.charAt(0).toLowerCase() + typename.slice(1);
72
77
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/internal",
3
- "version": "8.0.0-canary.3582",
3
+ "version": "8.0.0-canary.3587",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/cedarjs/cedar.git",
@@ -124,16 +124,16 @@
124
124
  },
125
125
  "dependencies": {
126
126
  "@babel/core": "^7.26.10",
127
- "@babel/parser": "7.29.11",
128
- "@babel/traverse": "7.29.10",
129
- "@cedarjs/api": "8.0.0-canary.3582",
130
- "@cedarjs/babel-config": "8.0.0-canary.3582",
131
- "@cedarjs/cli-helpers": "8.0.0-canary.3582",
132
- "@cedarjs/graphql-server": "8.0.0-canary.3582",
133
- "@cedarjs/project-config": "8.0.0-canary.3582",
134
- "@cedarjs/router": "8.0.0-canary.3582",
135
- "@cedarjs/structure": "8.0.0-canary.3582",
136
- "@cedarjs/utils": "8.0.0-canary.3582",
127
+ "@babel/parser": "7.29.12",
128
+ "@babel/traverse": "7.29.12",
129
+ "@cedarjs/api": "8.0.0-canary.3587",
130
+ "@cedarjs/babel-config": "8.0.0-canary.3587",
131
+ "@cedarjs/cli-helpers": "8.0.0-canary.3587",
132
+ "@cedarjs/graphql-server": "8.0.0-canary.3587",
133
+ "@cedarjs/project-config": "8.0.0-canary.3587",
134
+ "@cedarjs/router": "8.0.0-canary.3587",
135
+ "@cedarjs/structure": "8.0.0-canary.3587",
136
+ "@cedarjs/utils": "8.0.0-canary.3587",
137
137
  "@graphql-codegen/add": "6.0.1",
138
138
  "@graphql-codegen/cli": "6.3.1",
139
139
  "@graphql-codegen/client-preset": "5.3.0",
@@ -171,7 +171,7 @@
171
171
  "vite-tsconfig-paths": "6.1.1"
172
172
  },
173
173
  "devDependencies": {
174
- "@cedarjs/framework-tools": "8.0.0-canary.3582",
174
+ "@cedarjs/framework-tools": "8.0.0-canary.3587",
175
175
  "@jridgewell/trace-mapping": "0.3.31",
176
176
  "@oxc-project/types": "^0.155.0",
177
177
  "concurrently": "9.2.5",