-
Notifications
You must be signed in to change notification settings - Fork 188
chore: update type generation in js/ts to use Models.Row #1173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThe 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
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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.
📒 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.
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