Skip to content

Conversation

@larbish
Copy link
Contributor

@larbish larbish commented Nov 7, 2025

TODO:

  • Expose generateIdFromFsPath from app to avoid duplication and use a more complete implementation in app
  • Update generateIdFromFsPath calls from the app
  • Create related an missing tests for generateIdFromFsPath

@larbish larbish requested a review from farnabaz November 7, 2025 16:59
@vercel
Copy link

vercel bot commented Nov 7, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
content-studio Ready Ready Preview Comment Nov 7, 2025 5:00pm

}
}

export function generateIdFromFsPath(path: string, collectionInfo: CollectionInfo) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function signature mismatch: generateIdFromFsPath now expects a CollectionInfo object, but all call sites throughout the codebase are passing collection name strings instead, which will cause TypeScript compilation errors.

View Details
📝 Patch Details
diff --git a/src/app/src/utils/collection.ts b/src/app/src/utils/collection.ts
index 2974184..3b377c9 100644
--- a/src/app/src/utils/collection.ts
+++ b/src/app/src/utils/collection.ts
@@ -9,7 +9,37 @@ export function parseSourceBase(source: CollectionSource) {
   }
 }
 
-export function generateIdFromFsPath(path: string, collectionInfo: CollectionInfo) {
+// Helper function to create basic CollectionInfo for standard collections
+function createStandardCollectionInfo(name: string): CollectionInfo {
+  return {
+    name,
+    pascalName: name.charAt(0).toUpperCase() + name.slice(1),
+    tableName: `_content_${name}`,
+    source: [{
+      _resolved: true,
+      prefix: '/',
+      cwd: '',
+      include: '**',
+    }],
+    type: 'page' as const,
+    fields: {},
+    schema: {
+      $schema: 'http://json-schema.org/draft-07/schema#',
+      $ref: `#/definitions/${name}`,
+      definitions: {},
+    },
+    tableDefinition: '',
+  }
+}
+
+// Function overloads for backward compatibility
+export function generateIdFromFsPath(path: string, collection: CollectionInfo): string
+export function generateIdFromFsPath(path: string, collection: string): string
+export function generateIdFromFsPath(path: string, collection: CollectionInfo | string): string {
+  const collectionInfo = typeof collection === 'string' 
+    ? createStandardCollectionInfo(collection)
+    : collection
+    
   const { fixed } = parseSourceBase(collectionInfo.source[0]!)
 
   const pathWithoutFixed = path.substring(fixed.length)

Analysis

Function signature mismatch causes TypeScript compilation errors in generateIdFromFsPath

What fails: generateIdFromFsPath function expects CollectionInfo object but call sites pass collection name strings, causing TypeScript errors in useContext.ts (8 calls) and useTree.ts (1 call)

How to reproduce:

pnpm exec vue-tsc -p src/app/tsconfig.app.json --noEmit

Result: TypeScript compilation errors:

src/app/src/composables/useContext.ts(110,49): error TS2345: Argument of type 'TreeRootId' is not assignable to parameter of type 'CollectionInfo'.
src/app/src/composables/useContext.ts(132,61): error TS2345: Argument of type 'TreeRootId' is not assignable to parameter of type 'CollectionInfo'. 
src/app/src/composables/useContext.ts(145,54): error TS2345: Argument of type 'string' is not assignable to parameter of type 'CollectionInfo'.

Expected: TypeScript compilation should pass without errors as the function should accept collection name strings for backward compatibility with app-side code that uses TreeRootId.Media, TreeRootId.Content, and item.collections[0] string values.

@larbish
Copy link
Contributor Author

larbish commented Nov 11, 2025

Closing in favor of #91

@larbish larbish closed this Nov 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants