feat: Console SDK update for version 2.3.1#60
Conversation
WalkthroughThis pull request represents a minor version bump from 2.3.0 to 2.3.1, introducing the Activities service for fetching activity events alongside encryption support for text-based database attributes and table columns. The release includes removal of three deprecated Deno runtime versions (1.21, 1.24, 1.35), adds new ActivityEvent models, and extends method signatures across the Databases and TablesDB services to support an optional encrypt parameter. Documentation examples are added for the new Activities API and updated across database example files to demonstrate the encryption capability. Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@docs/examples/activities/list-events.md`:
- Around line 10-12: The listEvents API's queries parameter is mismatched:
change the TypeScript signature in src/services/activities.ts from queries?:
string to queries?: string[] on the listEvents function, update any related
JSDoc/type comments to reflect "Array of query strings", and update the example
in docs/examples/activities/list-events.md to pass an array (e.g., queries:
['q1', 'q2']) instead of a single string so the docs match the corrected type
and other SDK services.
In `@src/services/activities.ts`:
- Around line 13-50: The listEvents overloads and normalization treat queries as
a single string; change all occurrences to use string[] (update the two method
signatures and the local params type to { queries?: string[] }) and adjust the
normalization in listEvents(paramsOrFirst) so it: 1) recognizes when
paramsOrFirst is an object (and not an array) and assigns params = paramsOrFirst
as { queries?: string[] }, 2) when paramsOrFirst is an array assign params = {
queries: paramsOrFirst as string[] }, and 3) when paramsOrFirst is a string
(deprecated path) assign params = { queries: [paramsOrFirst as string] };
finally ensure the local const queries is treated as string[] and
payload['queries'] = queries (so arrays serialize correctly). Use the existing
symbols listEvents, paramsOrFirst, params, queries, apiPath, payload to locate
and update the code.
| const result = await activities.listEvents({ | ||
| queries: '' // optional | ||
| }); |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# First, let's locate the services directory and check type definitions
find . -type f -name "*.ts" | grep -E "(service|activity)" | head -20Repository: appwrite/sdk-for-console
Length of output: 603
🏁 Script executed:
#!/bin/bash
# Search for queries parameter type definitions in TypeScript files
rg -n "queries\?:\s*string\[\]" --type=ts
rg -n "queries\?:\s*string" --type=ts | head -20Repository: appwrite/sdk-for-console
Length of output: 50380
🏁 Script executed:
#!/bin/bash
# Read the documentation file to see current example
cat -n docs/examples/activities/list-events.mdRepository: appwrite/sdk-for-console
Length of output: 560
🏁 Script executed:
#!/bin/bash
# Search for listEvents in activities.ts
rg -n "listEvents" src/services/activities.ts -A 5Repository: appwrite/sdk-for-console
Length of output: 955
🏁 Script executed:
#!/bin/bash
# Get the full definition context
head -100 src/services/activities.ts | tail -50Repository: appwrite/sdk-for-console
Length of output: 1575
Fix the type definition and documentation example for listEvents queries parameter.
The listEvents method has inconsistent type definitions. The JSDoc states "Array of query strings," but the TypeScript signature defines queries as string, while every other service in the SDK uses string[]. The example should show an array once the type signature is corrected to match the documented intent and other services.
Suggested changes
- In
src/services/activities.ts, update the type signature fromqueries?: stringtoqueries?: string[] - Update the documentation example:
-const result = await activities.listEvents({
- queries: '' // optional
-});
+const result = await activities.listEvents({
+ queries: [] // optional
+});🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@docs/examples/activities/list-events.md` around lines 10 - 12, The listEvents
API's queries parameter is mismatched: change the TypeScript signature in
src/services/activities.ts from queries?: string to queries?: string[] on the
listEvents function, update any related JSDoc/type comments to reflect "Array of
query strings", and update the example in
docs/examples/activities/list-events.md to pass an array (e.g., queries: ['q1',
'q2']) instead of a single string so the docs match the corrected type and other
SDK services.
| /** | ||
| * List all events for selected filters. | ||
| * | ||
| * @param {string} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on attributes such as userId, teamId, etc. | ||
| * @throws {AppwriteException} | ||
| * @returns {Promise<Models.ActivityEventList>} | ||
| */ | ||
| listEvents(params?: { queries?: string }): Promise<Models.ActivityEventList>; | ||
| /** | ||
| * List all events for selected filters. | ||
| * | ||
| * @param {string} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on attributes such as userId, teamId, etc. | ||
| * @throws {AppwriteException} | ||
| * @returns {Promise<Models.ActivityEventList>} | ||
| * @deprecated Use the object parameter style method for a better developer experience. | ||
| */ | ||
| listEvents(queries?: string): Promise<Models.ActivityEventList>; | ||
| listEvents( | ||
| paramsOrFirst?: { queries?: string } | string | ||
| ): Promise<Models.ActivityEventList> { | ||
| let params: { queries?: string }; | ||
|
|
||
| if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { | ||
| params = (paramsOrFirst || {}) as { queries?: string }; | ||
| } else { | ||
| params = { | ||
| queries: paramsOrFirst as string | ||
| }; | ||
| } | ||
|
|
||
| const queries = params.queries; | ||
|
|
||
|
|
||
| const apiPath = '/activities/events'; | ||
| const payload: Payload = {}; | ||
| if (typeof queries !== 'undefined') { | ||
| payload['queries'] = queries; | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check queries parameter types across services
rg -n --type=ts "queries\?:\s*string\[\]" src/services | head -20
echo "---"
rg -n --type=ts "queries\?:\s*string\b" src/services | head -20Repository: appwrite/sdk-for-console
Length of output: 5686
🏁 Script executed:
#!/bin/bash
# Also check the current listEvents implementation in activities.ts
cat -n src/services/activities.ts | head -60Repository: appwrite/sdk-for-console
Length of output: 2922
Align queries typing with SDK standard string[] pattern.
The docstring describes an array of query strings, but the type signatures use string instead of string[]. All other services in the SDK (users, organizations, vcs) use string[] for queries. The current normalization logic at line 35 checks Array.isArray() but then treats it as the deprecated string path, which will serialize arrays incorrectly.
🛠️ Proposed fix
- listEvents(params?: { queries?: string }): Promise<Models.ActivityEventList>;
+ listEvents(params?: { queries?: string[] }): Promise<Models.ActivityEventList>;
/**
* List all events for selected filters.
*
- * `@param` {string} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on attributes such as userId, teamId, etc.
+ * `@param` {string[]} queries - Array of query strings generated using the Query class provided by the SDK. Maximum of 100 queries are allowed, each 4096 characters long. You may filter on attributes such as userId, teamId, etc.
* `@throws` {AppwriteException}
* `@returns` {Promise<Models.ActivityEventList>}
* `@deprecated` Use the object parameter style method for a better developer experience.
*/
- listEvents(queries?: string): Promise<Models.ActivityEventList>;
+ listEvents(queries?: string[]): Promise<Models.ActivityEventList>;
listEvents(
- paramsOrFirst?: { queries?: string } | string
+ paramsOrFirst?: { queries?: string[] } | string[]
): Promise<Models.ActivityEventList> {
- let params: { queries?: string };
+ let params: { queries?: string[] };
- if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
- params = (paramsOrFirst || {}) as { queries?: string };
+ if (!paramsOrFirst || (typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
+ params = (paramsOrFirst || {}) as { queries?: string[] };
} else {
params = {
- queries: paramsOrFirst as string
+ queries: paramsOrFirst as string[]
};
}📝 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.
| /** | |
| * List all events for selected filters. | |
| * | |
| * @param {string} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on attributes such as userId, teamId, etc. | |
| * @throws {AppwriteException} | |
| * @returns {Promise<Models.ActivityEventList>} | |
| */ | |
| listEvents(params?: { queries?: string }): Promise<Models.ActivityEventList>; | |
| /** | |
| * List all events for selected filters. | |
| * | |
| * @param {string} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on attributes such as userId, teamId, etc. | |
| * @throws {AppwriteException} | |
| * @returns {Promise<Models.ActivityEventList>} | |
| * @deprecated Use the object parameter style method for a better developer experience. | |
| */ | |
| listEvents(queries?: string): Promise<Models.ActivityEventList>; | |
| listEvents( | |
| paramsOrFirst?: { queries?: string } | string | |
| ): Promise<Models.ActivityEventList> { | |
| let params: { queries?: string }; | |
| if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { | |
| params = (paramsOrFirst || {}) as { queries?: string }; | |
| } else { | |
| params = { | |
| queries: paramsOrFirst as string | |
| }; | |
| } | |
| const queries = params.queries; | |
| const apiPath = '/activities/events'; | |
| const payload: Payload = {}; | |
| if (typeof queries !== 'undefined') { | |
| payload['queries'] = queries; | |
| } | |
| /** | |
| * List all events for selected filters. | |
| * | |
| * `@param` {string} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on attributes such as userId, teamId, etc. | |
| * `@throws` {AppwriteException} | |
| * `@returns` {Promise<Models.ActivityEventList>} | |
| */ | |
| listEvents(params?: { queries?: string[] }): Promise<Models.ActivityEventList>; | |
| /** | |
| * List all events for selected filters. | |
| * | |
| * `@param` {string[]} queries - Array of query strings generated using the Query class provided by the SDK. Maximum of 100 queries are allowed, each 4096 characters long. You may filter on attributes such as userId, teamId, etc. | |
| * `@throws` {AppwriteException} | |
| * `@returns` {Promise<Models.ActivityEventList>} | |
| * `@deprecated` Use the object parameter style method for a better developer experience. | |
| */ | |
| listEvents(queries?: string[]): Promise<Models.ActivityEventList>; | |
| listEvents( | |
| paramsOrFirst?: { queries?: string[] } | string[] | |
| ): Promise<Models.ActivityEventList> { | |
| let params: { queries?: string[] }; | |
| if (!paramsOrFirst || (typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { | |
| params = (paramsOrFirst || {}) as { queries?: string[] }; | |
| } else { | |
| params = { | |
| queries: paramsOrFirst as string[] | |
| }; | |
| } | |
| const queries = params.queries; | |
| const apiPath = '/activities/events'; | |
| const payload: Payload = {}; | |
| if (typeof queries !== 'undefined') { | |
| payload['queries'] = queries; | |
| } |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/services/activities.ts` around lines 13 - 50, The listEvents overloads
and normalization treat queries as a single string; change all occurrences to
use string[] (update the two method signatures and the local params type to {
queries?: string[] }) and adjust the normalization in listEvents(paramsOrFirst)
so it: 1) recognizes when paramsOrFirst is an object (and not an array) and
assigns params = paramsOrFirst as { queries?: string[] }, 2) when paramsOrFirst
is an array assign params = { queries: paramsOrFirst as string[] }, and 3) when
paramsOrFirst is a string (deprecated path) assign params = { queries:
[paramsOrFirst as string] }; finally ensure the local const queries is treated
as string[] and payload['queries'] = queries (so arrays serialize correctly).
Use the existing symbols listEvents, paramsOrFirst, params, queries, apiPath,
payload to locate and update the code.
This PR contains updates to the Console SDK for version 2.3.1.
Summary by CodeRabbit
Release Notes v2.3.1
New Features
Updates
Documentation