Skip to content

Conversation

@abnegate
Copy link
Member

@abnegate abnegate commented Oct 9, 2025

This PR contains updates to the Web SDK for version 21.2.0.

Summary by CodeRabbit

  • New Features

    • Added transaction support across Databases and TablesDB, including optional transactionId in CRUD and counter operations.
    • Introduced transaction APIs: create, list, get, update (commit/rollback), delete, and batch createOperations.
  • Documentation

    • Added comprehensive transaction examples for Databases and TablesDB.
    • Updated examples to include transactionId across create/get/list/update/delete and increment/decrement operations.
  • Chores

    • Bumped SDK to 21.2.0 and updated CDN link.
    • Added changelog entry highlighting transaction support.

@coderabbitai
Copy link

coderabbitai bot commented Oct 9, 2025

Walkthrough

Version updated from 21.1.0 to 21.2.0 across package.json, client headers, README CDN link, and CHANGELOG entry. Introduces transaction support in Databases and TablesDB: new APIs for list/get/create/update/delete transactions and createOperations. Existing Databases and TablesDB methods now accept an optional transactionId (documents/rows CRUD and increment/decrement attribute/column). Models add Transaction and TransactionList types (Transaction declared twice). Extensive docs/examples added or updated to demonstrate transaction flows and inclusion of transactionId across create, read, update, delete, operations, and listing endpoints. No other behavioral changes indicated.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly communicates the primary change—a feature release updating the Web SDK to version 21.2.0—which aligns with the package and client version bumps and new transaction support added in the PR. It is concise, clear, and directly related to the changeset without extraneous detail.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • 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: 9

🧹 Nitpick comments (1)
docs/examples/tablesdb/create-operations.md (1)

12-21: Replace the hard tabs with spaces.

Lines 12‑21 use tabs, tripping our markdownlint MD010 “no hard tabs” rule and causing CI noise. Swap them for spaces.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0c95b17 and 4a219c9.

📒 Files selected for processing (35)
  • CHANGELOG.md (1 hunks)
  • README.md (1 hunks)
  • docs/examples/databases/create-document.md (1 hunks)
  • docs/examples/databases/create-operations.md (1 hunks)
  • docs/examples/databases/create-transaction.md (1 hunks)
  • docs/examples/databases/decrement-document-attribute.md (1 hunks)
  • docs/examples/databases/delete-document.md (1 hunks)
  • docs/examples/databases/delete-transaction.md (1 hunks)
  • docs/examples/databases/get-document.md (1 hunks)
  • docs/examples/databases/get-transaction.md (1 hunks)
  • docs/examples/databases/increment-document-attribute.md (1 hunks)
  • docs/examples/databases/list-documents.md (1 hunks)
  • docs/examples/databases/list-transactions.md (1 hunks)
  • docs/examples/databases/update-document.md (1 hunks)
  • docs/examples/databases/update-transaction.md (1 hunks)
  • docs/examples/databases/upsert-document.md (1 hunks)
  • docs/examples/tablesdb/create-operations.md (1 hunks)
  • docs/examples/tablesdb/create-row.md (1 hunks)
  • docs/examples/tablesdb/create-transaction.md (1 hunks)
  • docs/examples/tablesdb/decrement-row-column.md (1 hunks)
  • docs/examples/tablesdb/delete-row.md (1 hunks)
  • docs/examples/tablesdb/delete-transaction.md (1 hunks)
  • docs/examples/tablesdb/get-row.md (1 hunks)
  • docs/examples/tablesdb/get-transaction.md (1 hunks)
  • docs/examples/tablesdb/increment-row-column.md (1 hunks)
  • docs/examples/tablesdb/list-rows.md (1 hunks)
  • docs/examples/tablesdb/list-transactions.md (1 hunks)
  • docs/examples/tablesdb/update-row.md (1 hunks)
  • docs/examples/tablesdb/update-transaction.md (1 hunks)
  • docs/examples/tablesdb/upsert-row.md (1 hunks)
  • package.json (1 hunks)
  • src/client.ts (1 hunks)
  • src/models.ts (2 hunks)
  • src/services/databases.ts (26 hunks)
  • src/services/tables-db.ts (26 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
src/services/tables-db.ts (1)
src/models.ts (5)
  • TransactionList (224-233)
  • Transaction (1261-1286)
  • Row (238-267)
  • DefaultRow (269-272)
  • RowList (14-23)
src/services/databases.ts (1)
src/models.ts (5)
  • TransactionList (224-233)
  • Transaction (1261-1286)
  • Document (277-306)
  • DefaultDocument (308-311)
  • DocumentList (28-37)
🪛 markdownlint-cli2 (0.18.1)
docs/examples/tablesdb/create-operations.md

12-12: Hard tabs
Column: 1

(MD010, no-hard-tabs)


13-13: Hard tabs
Column: 1

(MD010, no-hard-tabs)


14-14: Hard tabs
Column: 1

(MD010, no-hard-tabs)


15-15: Hard tabs
Column: 1

(MD010, no-hard-tabs)


16-16: Hard tabs
Column: 1

(MD010, no-hard-tabs)


17-17: Hard tabs
Column: 1

(MD010, no-hard-tabs)


18-18: Hard tabs
Column: 1

(MD010, no-hard-tabs)


19-19: Hard tabs
Column: 1

(MD010, no-hard-tabs)


20-20: Hard tabs
Column: 1

(MD010, no-hard-tabs)


21-21: Hard tabs
Column: 1

(MD010, no-hard-tabs)

🔇 Additional comments (9)
docs/examples/databases/delete-transaction.md (1)

1-13: LGTM! Clear transaction deletion example.

The example demonstrates the deleteTransaction API usage correctly with proper client initialization and parameter passing.

src/models.ts (2)

221-233: LGTM! TransactionList type added correctly.

The TransactionList type follows the established pattern for list types in the Models namespace, with appropriate documentation and structure.


1258-1287: LGTM! Transaction type defined correctly.

The Transaction type includes all necessary fields with appropriate documentation. The structure aligns with the transaction support being added in version 21.2.0.

src/client.ts (1)

319-319: LGTM! SDK version header updated correctly.

The x-sdk-version header is updated to 21.2.0, consistent with the version bump in package.json and CHANGELOG.md.

CHANGELOG.md (1)

3-5: LGTM! CHANGELOG entry appropriately documents the release.

The 21.2.0 entry clearly describes the new transaction support feature for Databases and TablesDB, aligning with the changes in this PR.

docs/examples/tablesdb/list-transactions.md (1)

1-13: LGTM! Clear transaction listing example.

The example demonstrates the listTransactions API usage correctly with proper client initialization and shows the optional queries parameter.

docs/examples/tablesdb/increment-row-column.md (1)

15-16: LGTM! Transaction support added to incrementRowColumn.

The addition of the optional transactionId parameter demonstrates the extension of transaction support to row operations, aligning with the broader transaction feature set.

package.json (1)

5-5: LGTM! Version bumped to 21.2.0.

The version update is consistent with the changes in client.ts and CHANGELOG.md, properly reflecting the new transaction support feature.

docs/examples/databases/create-transaction.md (1)

1-13: LGTM! Clear transaction creation example.

The example demonstrates the createTransaction API usage correctly with proper client initialization and shows the optional ttl parameter.

Comment on lines +20 to +21
permissions: ["read("any")"], // optional
transactionId: '<TRANSACTION_ID>' // optional
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Correct the permissions string literal.

["read("any")"] breaks due to unescaped quotes. Update the example so it’s valid JavaScript.

-    permissions: ["read("any")"], // optional
+    permissions: ['read("any")'], // optional
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
permissions: ["read("any")"], // optional
transactionId: '<TRANSACTION_ID>' // optional
permissions: ['read("any")'], // optional
transactionId: '<TRANSACTION_ID>' // optional
🤖 Prompt for AI Agents
In docs/examples/databases/create-document.md around lines 20 to 21, the
permissions example uses ["read("any")"] which contains unescaped quotes and is
invalid JavaScript; replace that entry with a properly quoted string (for
example use single quotes around the outer string and keep the inner double
quotes, or escape the inner quotes) so the permissions array contains a valid
string literal like read("any") without syntax errors.

Comment on lines +14 to +15
permissions: ["read("any")"], // optional
transactionId: '<TRANSACTION_ID>' // optional
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Use valid quoting for the permissions entry.

The example currently reads ["read("any")"], which is invalid. Switch the outer quotes or escape the inner quotes.

-    permissions: ["read("any")"], // optional
+    permissions: ['read("any")'], // optional
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
permissions: ["read("any")"], // optional
transactionId: '<TRANSACTION_ID>' // optional
permissions: ['read("any")'], // optional
transactionId: '<TRANSACTION_ID>' // optional
🤖 Prompt for AI Agents
In docs/examples/databases/update-document.md around lines 14 to 15, the
permissions entry uses invalid nesting of double quotes (["read("any")"]) — fix
by using valid quoting or escaping so the permission string is syntactically
correct, e.g., switch outer quotes to single quotes or escape inner quotes so
the permissions array contains a single valid string like 'read("any")' or
"read(\"any\")".

Comment on lines +14 to +15
permissions: ["read("any")"], // optional
transactionId: '<TRANSACTION_ID>' // optional
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Repair the permissions string literal.

["read("any")"] cannot be parsed. Please adopt single quotes externally or escape appropriately.

-    permissions: ["read("any")"], // optional
+    permissions: ['read("any")'], // optional
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
permissions: ["read("any")"], // optional
transactionId: '<TRANSACTION_ID>' // optional
permissions: ['read("any")'], // optional
transactionId: '<TRANSACTION_ID>' // optional
🤖 Prompt for AI Agents
In docs/examples/databases/upsert-document.md around lines 14 to 15, the
permissions string literal is invalid: replace the current ["read("any")"] with
a validly quoted string such as ["read('any')"] (or alternatively use
single-quoted outer strings with double quotes inside: ['read("any")']), or
escape the inner quotes so the JSON/JS parser can parse it.

Comment on lines +20 to +21
permissions: ["read("any")"], // optional
transactionId: '<TRANSACTION_ID>' // optional
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Fix the permissions string literal.

"read("any")" is invalid JS/TS because the inner quotes terminate the string. The example will throw before it ever reaches the new transactionId field—escape the inner quotes or switch to single quotes. e.g. permissions: ['read("any")'],.

🤖 Prompt for AI Agents
In docs/examples/tablesdb/create-row.md around lines 20 to 21, the permissions
string literal uses double quotes inside double quotes ("read("any")") which is
invalid JS/TS and will throw; fix by either switching to single quotes for the
outer string (e.g. permissions: ['read("any")']) or escaping the inner quotes
(e.g. permissions: ["read(\"any\")"]) so the example is valid and the subsequent
transactionId field can be reached.

Comment on lines +13 to +14
queries: [], // optional
transactionId: '<TRANSACTION_ID>' // optional
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Remove unsupported queries option from getRow example.

TablesDB.getRow only accepts databaseId, tableId, rowId, and optional transactionId. It does not accept a queries array, so copying this example will throw a validation error. Please drop the queries line.

🤖 Prompt for AI Agents
In docs/examples/tablesdb/get-row.md around lines 13 to 14, the example wrongly
includes a queries: [] option which TablesDB.getRow does not support; remove the
entire queries line so the example only provides databaseId, tableId, rowId, and
the optional transactionId, ensuring the example matches the method signature
and will not trigger validation errors.

Comment on lines +14 to +15
permissions: ["read("any")"], // optional
transactionId: '<TRANSACTION_ID>' // optional
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Fix invalid string quoting in permissions example.

["read("any")"] is not valid JavaScript because the inner quotes terminate the string early, making this snippet unusable as-is. Please wrap the outer string in single quotes (or escape the inner quotes) so developers can copy-paste without hitting a syntax error.

-    permissions: ["read("any")"], // optional
+    permissions: ['read("any")'], // optional
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
permissions: ["read("any")"], // optional
transactionId: '<TRANSACTION_ID>' // optional
permissions: ['read("any")'], // optional
transactionId: '<TRANSACTION_ID>' // optional
🤖 Prompt for AI Agents
In docs/examples/tablesdb/update-row.md around lines 14 to 15, the permissions
example uses invalid double-quote nesting: ["read("any")"] which breaks
JavaScript parsing; update the snippet to either wrap the outer string in single
quotes (e.g., ['read("any")']) or escape the inner quotes (e.g.,
["read(\"any\")"]) so the permissions array is valid and copy-pastable; ensure
the chosen style matches surrounding examples for consistency.

rowId: '<ROW_ID>',
data: {}, // optional
permissions: ["read("any")"] // optional
permissions: ["read("any")"], // optional
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Fix malformed string literal in permissions.

["read("any")"] is invalid JavaScript because the inner quotes terminate the string. Restore the previous escaping (['read("any")'] or "read(\"any\")") so the snippet runs as-is.

🤖 Prompt for AI Agents
In docs/examples/tablesdb/upsert-row.md around line 14, the permissions array
contains a malformed string literal permissions: ["read("any")"] which breaks JS
parsing; change it to use a string that preserves the inner quotes, e.g. use
single outer quotes with double inner quotes ['read("any")'] or escape the inner
quotes with backslashes "read(\"any\")", so the snippet is valid and runs as-is.

Comment on lines +86 to +93
if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
params = (paramsOrFirst || {}) as { ttl?: number };
} else {
params = {
ttl: paramsOrFirst as number
};
}

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Preserve an explicit ttl of 0.

createTransaction(0) should forward the caller’s explicit TTL, but the falsy check treats 0 the same as “not provided” and strips it from the payload. Please guard specifically for undefined so that 0 (or any other falsy numeric value) is honored.

Apply this diff:

-        if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
-            params = (paramsOrFirst || {}) as { ttl?: number };
-        } else {
-            params = {
-                ttl: paramsOrFirst as number            
-            };
-        }
+        if (typeof paramsOrFirst === 'number') {
+            params = {
+                ttl: paramsOrFirst
+            };
+        } else {
+            params = (paramsOrFirst || {}) as { ttl?: number };
+        }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
params = (paramsOrFirst || {}) as { ttl?: number };
} else {
params = {
ttl: paramsOrFirst as number
};
}
if (typeof paramsOrFirst === 'number') {
params = {
ttl: paramsOrFirst
};
} else {
params = (paramsOrFirst || {}) as { ttl?: number };
}
🤖 Prompt for AI Agents
In src/services/databases.ts around lines 86 to 93, the current falsy check
treats 0 as "not provided" and drops an explicit ttl of 0; change the guard to
test for undefined instead of falsy values so numeric 0 is preserved.
Specifically, detect whether paramsOrFirst is undefined (or an object) rather
than using a truthy check, and when paramsOrFirst is a number allow ttl:
paramsOrFirst (including 0) to be set; otherwise cast the object to { ttl?:
number } as before.

Comment on lines +86 to +93
if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
params = (paramsOrFirst || {}) as { ttl?: number };
} else {
params = {
ttl: paramsOrFirst as number
};
}

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Honor positional ttl = 0.

With the current falsy guard, calling createTransaction(0) drops the TTL from the payload. Please test explicitly for undefined so zero remains a valid input.

Apply this diff:

-        if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
-            params = (paramsOrFirst || {}) as { ttl?: number };
-        } else {
-            params = {
-                ttl: paramsOrFirst as number            
-            };
-        }
+        if (typeof paramsOrFirst === 'number') {
+            params = {
+                ttl: paramsOrFirst
+            };
+        } else {
+            params = (paramsOrFirst || {}) as { ttl?: number };
+        }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
params = (paramsOrFirst || {}) as { ttl?: number };
} else {
params = {
ttl: paramsOrFirst as number
};
}
if (typeof paramsOrFirst === 'number') {
params = {
ttl: paramsOrFirst
};
} else {
params = (paramsOrFirst || {}) as { ttl?: number };
}
🤖 Prompt for AI Agents
In src/services/tables-db.ts around lines 86 to 93, the current falsy check
drops a positional ttl when ttl === 0; change the guard to explicitly check for
undefined instead of falsy. Update the conditional to treat paramsOrFirst as the
params object only when paramsOrFirst === undefined or (typeof paramsOrFirst ===
'object' && !Array.isArray(paramsOrFirst)); otherwise treat it as the numeric
ttl so that createTransaction(0) preserves ttl: 0.

@abnegate abnegate merged commit a51cddc into main Oct 9, 2025
2 checks passed
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