Skip to content

Conversation

ChiragAgg5k
Copy link
Member

@ChiragAgg5k ChiragAgg5k commented Sep 8, 2025

This PR contains updates to the Command Line SDK for Appwrite version 1.8.x.\n\nCommit: chore: testing 6

Summary by CodeRabbit

  • New Features

    • Coordinate-array defaults supported for point, line, and polygon attributes/columns in CLI and API.
  • Bug Fixes

    • Generated TypeScript now safely handles invalid property names by quoting them.
    • Spatial defaults normalized: a boolean true is treated as an empty array for point/line/polygon defaults.
  • Documentation

    • CLI --xdefault help updated to describe array formats (2D for points/lines, 3D for polygons) instead of JSON strings.

Copy link

coderabbitai bot commented Sep 8, 2025

Warning

Rate limit exceeded

@abnegate has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 27 minutes and 15 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between af39853 and a00222e.

📒 Files selected for processing (2)
  • lib/commands/databases.js (17 hunks)
  • lib/commands/tables-db.js (13 hunks)

Walkthrough

This change updates spatial attribute/column handling and TypeScript code generation. In lib/commands/databases.js and lib/commands/tables-db.js, xdefault for line/point/polygon is documented and treated as coordinate arrays instead of strings, with runtime normalization mapping boolean true to an empty array before assigning default. CLI help text for --xdefault is updated accordingly. JSDoc/param types reflect the new array formats, including enum-related docs in tables-db. In lib/type-generation/languages/typescript.js, the generator now validates attribute keys and quotes invalid identifiers when emitting TypeScript properties. No function signatures were changed.

Possibly related PRs

  • Dev #193: Adjusts xdefault documentation and normalization for the same geometric attribute/column helpers touched in databases.js and tables-db.js.
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dev

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

Comment @coderabbitai help to get the list of available commands and usage tips.

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: 3

🧹 Nitpick comments (2)
lib/type-generation/languages/typescript.js (1)

93-95: Quote invalid identifiers: good; also guard TS keywords.

The regex covers identifier characters but not reserved keywords. Safer to quote names like "class", "default", etc.

-<% const isValidIdentifier = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(propertyName); -%>
+<% const isValidIdentifier =
+  /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(propertyName) &&
+  !['break','case','class','catch','const','continue','debugger','default','delete','do','else','export','extends','finally','for','function','if','import','in','instanceof','new','return','super','switch','this','throw','try','typeof','var','void','while','with','yield','let','enum','await','implements','package','protected','static','interface','private','public'].includes(propertyName); -%>
lib/commands/databases.js (1)

2860-2861: CLI help: tell users to pass JSON.

Add a short hint so users quote JSON arrays properly at the shell.

-.option(`--xdefault <xdefault>`, `Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required.`)
+.option(`--xdefault <xdefault>`, `Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Pass as JSON (e.g., --xdefault '[[12.34,56.78],[23.45,67.89]]'). Cannot be set when attribute is required.`)

Repeat the same JSON hint for point and polygon options.

Also applies to: 2870-2871, 2881-2882, 2891-2892, 2902-2903, 2912-2913

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 71e8c88 and af39853.

📒 Files selected for processing (3)
  • lib/commands/databases.js (18 hunks)
  • lib/commands/tables-db.js (18 hunks)
  • lib/type-generation/languages/typescript.js (1 hunks)
🔇 Additional comments (2)
lib/commands/databases.js (1)

1188-1188: Docs: spatial xdefault shapes look correct.

The new array-based formats for line/point/polygon defaults are clear and consistent.

Also applies to: 1232-1232, 1277-1277, 1321-1321, 1366-1366, 1410-1410

lib/commands/tables-db.js (1)

1188-1188: Docs: spatial xdefault shapes look correct.

The new array-based formats for line/point/polygon defaults are clear and consistent.

Also applies to: 1232-1232, 1277-1277, 1321-1321, 1366-1366, 1410-1410

Comment on lines +1208 to 1211
xdefault = xdefault === true ? [] : xdefault;
if (typeof xdefault !== 'undefined') {
payload['default'] = xdefault;
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

xdefault passed as string; must JSON.parse before sending.

Commander delivers CLI args as strings. Without parsing, the API receives a string instead of an array and will fail validation for spatial defaults.

Apply parsing in all spatial attribute helpers:

 xdefault = xdefault === true ? [] : xdefault;
+if (typeof xdefault === 'string') {
+  xdefault = JSON.parse(xdefault);
+}
 if (typeof xdefault !== 'undefined') {
   payload['default'] = xdefault;
 }

Also applies to: 1250-1253, 1297-1300, 1339-1342, 1386-1389, 1429-1432

Comment on lines +1208 to 1211
xdefault = xdefault === true ? [] : xdefault;
if (typeof xdefault !== 'undefined') {
payload['default'] = xdefault;
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

xdefault must be JSON-parsed before send.

Same issue here: CLI supplies strings; the API expects arrays.

 xdefault = xdefault === true ? [] : xdefault;
+if (typeof xdefault === 'string') {
+  xdefault = JSON.parse(xdefault);
+}
 if (typeof xdefault !== 'undefined') {
   payload['default'] = xdefault;
 }

Also applies to: 1250-1253, 1297-1300, 1339-1342, 1386-1389, 1429-1432

Comment on lines +2843 to 2844
.option(`--xdefault <xdefault>`, `Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required.`)
.action(actionRunner(tablesDBCreateLineColumn))
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

CLI help: add JSON hint + fix “documents” → “rows”.

  • Add a note to pass xdefault as JSON.
  • Replace “documents” with “rows” in tables-db update command descriptions.
- .description(`Update a line column. Changing the 'default' value will not update already existing documents.`)
+ .description(`Update a line column. Changing the 'default' value will not update already existing rows.`)

-.option(`--xdefault <xdefault>`, `Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required.`)
+.option(`--xdefault <xdefault>`, `Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Pass as JSON (e.g., --xdefault '[[12.34,56.78],[23.45,67.89]]'). Cannot be set when column is required.`)

Apply the same “rows” wording and JSON hint for point and polygon update/create commands.

Also applies to: 2853-2855, 2864-2865, 2874-2876, 2885-2886, 2895-2897

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