Skip to content

Conversation

ChiragAgg5k
Copy link
Member

@ChiragAgg5k ChiragAgg5k commented Aug 30, 2025

What does this PR do?

fixes to use models.row instead of document

Test Plan

(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work.)

Related PRs and Issues

(If this PR is related to any other PR or resolves any issue or related to any issue link all related PR and issues here.)

Have you read the Contributing Guidelines on issues?

(Write your answer here.)

Summary by CodeRabbit

  • Refactor
    • JavaScript and TypeScript type generation now builds collection typings on Models.Row instead of Models.Document. Generated fields remain unchanged; only the base type differs.
    • Developers relying on Document-specific properties or constraints may need to update references to Row.
  • Documentation
    • Clarified type generation behavior to reflect the switch from Document to Row in JS/TS outputs.

Copy link

coderabbitai bot commented Aug 30, 2025

Walkthrough

The type-generation templates for JavaScript and TypeScript now produce Row-based typings instead of Document-based ones. Per-collection types extend Models.Row rather than Models.Document, while attribute mappings and other template logic remain unchanged. In TypeScript, the exported collection type aliases were updated to reference Models.Row as the base type. No additional behavioral changes were introduced.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch update-type-generation

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
templates/cli/lib/type-generation/languages/javascript.js.twig (1)

57-66: Parity with TS: add Deno detection for the JSDoc import path.

JS template lacks the Deno branch present in TS, so Deno users won’t resolve the type import. Consider adding it.

Apply this diff:

   _getAppwriteDependency() {
     if (fs.existsSync(path.resolve(process.cwd(), 'package.json'))) {
       const packageJsonRaw = fs.readFileSync(path.resolve(process.cwd(), 'package.json'));
       const packageJson = JSON.parse(packageJsonRaw.toString('utf-8'));
       return packageJson.dependencies['node-appwrite'] ? 'node-appwrite' : 'appwrite';
     }
 
+    if (fs.existsSync(path.resolve(process.cwd(), 'deno.json'))) {
+      return "https://deno.land/x/appwrite/mod.ts";
+    }
+
     return "appwrite";
   }
templates/cli/lib/type-generation/languages/typescript.js.twig (1)

71-97: Reduce churn: alias the base model once and reference it.

Using an indirection makes future base-type switches trivial and centralizes the change.

Apply this diff:

   getTemplate() {
-    return `import { type Models } from '${this._getAppwriteDependency()}';
+    return `import { type Models } from '${this._getAppwriteDependency()}';
+
+// Central alias for the base model (helps future migrations)
+type AppwriteBaseRow = Models.Row;
 
 // This file is auto-generated by the Appwrite CLI. 
 // You can regenerate it by running \`appwrite ${process.argv.slice(2).join(' ')}\`.
@@
-<% for (const [index, collection] of Object.entries(collections)) { -%>
-export type <%- toPascalCase(collection.name) %> = Models.Row & {
+<% for (const [index, collection] of Object.entries(collections)) { -%>
+export type <%- toPascalCase(collection.name) %> = AppwriteBaseRow & {
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 8e8e396 and e921db5.

📒 Files selected for processing (2)
  • templates/cli/lib/type-generation/languages/javascript.js.twig (2 hunks)
  • templates/cli/lib/type-generation/languages/typescript.js.twig (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (19)
  • GitHub Check: build (8.3, Ruby31)
  • GitHub Check: build (8.3, WebChromium)
  • GitHub Check: build (8.3, Swift56)
  • GitHub Check: build (8.3, WebNode)
  • GitHub Check: build (8.3, Ruby30)
  • GitHub Check: build (8.3, AppleSwift56)
  • GitHub Check: build (8.3, Python311)
  • GitHub Check: build (8.3, PHP83)
  • GitHub Check: build (8.3, Python313)
  • GitHub Check: build (8.3, Ruby27)
  • GitHub Check: build (8.3, Python310)
  • GitHub Check: build (8.3, FlutterBeta)
  • GitHub Check: build (8.3, KotlinJava11)
  • GitHub Check: build (8.3, Go118)
  • GitHub Check: build (8.3, FlutterStable)
  • GitHub Check: build (8.3, CLINode16)
  • GitHub Check: build (8.3, Deno1303)
  • GitHub Check: build (8.3, Android14Java17)
  • GitHub Check: build (8.3, Android5Java17)
🔇 Additional comments (3)
templates/cli/lib/type-generation/languages/javascript.js.twig (2)

69-71: Switch to Models.Row: confirm minimum SDK compatibility.

Models.Row exists only in newer SDKs. If projects still use SDKs exposing Models.Document, the generated JSDoc import will break. Gate this change with a minimum required appwrite/node-appwrite version or add generator-side validation with a clear error message.


86-91: LGTM: collection typedef now intersects Row with attributes.

The JSDoc intersection Row & { ... } is correct and aligns with the PR goal.

templates/cli/lib/type-generation/languages/typescript.js.twig (1)

91-96: Switch to Models.Row: verify SDK version alignment and migration note.

Ensure the generator enforces or documents the minimum appwrite/node-appwrite version that exposes Models.Row to avoid breaking existing users on Models.Document.

@abnegate abnegate merged commit be7d1a2 into master Sep 1, 2025
39 checks passed
@abnegate abnegate deleted the update-type-generation branch September 1, 2025 08:01
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.

3 participants