Skip to content

Conversation

@ChiragAgg5k
Copy link
Member

@ChiragAgg5k ChiragAgg5k commented Dec 24, 2025

This PR contains updates to the Command Line SDK for version 13.0.0-rc.2.

Summary by CodeRabbit

  • New Features

    • Added comprehensive enum types for API services, authentication methods, and deployment configurations.
    • Introduced FileInput and UploadProgress types for improved file upload handling.
  • Improvements

    • Enhanced type safety throughout the codebase with stricter parameter typing.
    • Upgraded build workflow with extended platform support and improved publishing logic.
    • Modernized module imports to ES module standards.
  • Chores

    • Updated version to 13.0.0-rc.2 across all manifests and configuration files.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 24, 2025

Walkthrough

This pull request updates the Appwrite CLI from version 13.0.0-rc.1 to 13.0.0-rc.2 with significant structural refactoring. Key changes include: modernizing the npm-publish workflow with upgraded actions and multi-platform build support, standardizing imports from CommonJS to ES modules across command files, adding approximately 40 new enum definitions for type-safe constants, refactoring the configuration and type system with more specific interfaces (ProjectSettings, RawProjectSettings, and detailed config schemas), converting multiple public API parameters from object/object[] to string/string[] types with corresponding JSON parsing, introducing FileInput and UploadProgress types for improved file upload handling, and updating install scripts and package manifests to reference the new version. No behavioral changes to core functionality; modifications are primarily structural, type-system improvements, and modernization.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: Command Line SDK update for version 13.0.0-rc.2' clearly describes the main change—a version bump and corresponding updates to the CLI SDK. It is concise, specific, and highlights the primary objective of the PR.
✨ 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

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Appwrite Command Line SDK from version 13.0.0-rc.1 to 13.0.0-rc.2, primarily focusing on fixing TypeScript errors throughout the codebase.

Key changes:

  • Improved TypeScript type safety with proper type definitions and imports
  • Fixed import statements for the ignore library (from CommonJS to ES module style)
  • Added type casting for array parameters to handle CLI boolean defaults
  • Enhanced file upload handling with proper typing

Reviewed changes

Copilot reviewed 95 out of 95 changed files in this pull request and generated 27 comments.

Show a summary per file
File Description
package.json Updated version to 13.0.0-rc.2, removed error suppression from build script
lib/types.ts Reorganized and expanded type definitions with new interfaces for project settings, sites, tables, and columns
lib/emulation/docker.ts Changed ignore import style and used FunctionConfig from types
lib/config.ts Improved type safety with readonly properties, explicit type annotations, and stricter type guards
lib/paginate.ts Added function overloads for better type inference based on wrapper parameter
lib/questions.ts Added generic type support for choices function and typed API responses
lib/parser.ts Updated version string reference
lib/commands/* Consistent changes: ignore import fix, type imports for enums, array parameter type casting
lib/client.ts Updated SDK version and improved FileUpload type handling
.github/workflows/npm-publish.yml Updated to Node 22, added provenance publishing, fixed dependency typo
install.sh, install.ps1, scoop/appwrite.config.json Version string updates to 13.0.0-rc.2
Comments suppressed due to low confidence (5)

lib/commands/functions.ts:629

  • Avoid automated semicolon insertion (92% of all statements in the enclosing function have an explicit semicolon).
    let archivePath = fs.realpathSync(archiveFileName)

lib/commands/functions.ts:734

  • Avoid automated semicolon insertion (92% of all statements in the enclosing function have an explicit semicolon).
        parse(response)

lib/commands/sites.ts:629

  • Avoid automated semicolon insertion (93% of all statements in the enclosing function have an explicit semicolon).
    let archivePath = fs.realpathSync(archiveFileName)

lib/commands/sites.ts:734

  • Avoid automated semicolon insertion (93% of all statements in the enclosing function have an explicit semicolon).
        parse(response)

lib/commands/storage.ts:447

  • Avoid automated semicolon insertion (93% of all statements in the enclosing function have an explicit semicolon).
        parse(response)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

adapter: site.adapter,
buildCommand: site.buildCommand,
installCommand: site.installCommand,
outputDirectory: site.outputDirectory,
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

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

Multiple parameters have been removed from the sitesUpdate function call including fallbackFile and vars. This appears to be a breaking change that could cause existing site configurations to lose these settings during updates. Verify this is intentional and document the breaking change.

Suggested change
outputDirectory: site.outputDirectory,
outputDirectory: site.outputDirectory,
fallbackFile: (site as any).fallbackFile,
vars: (site as any).vars,

Copilot uses AI. Check for mistakes.
}
await Promise.all(envVariables.map(async (variable) => {
await functionsCreateVariable({
functionId: func['$id'],
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

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

The variableId parameter has been removed from functionsCreateVariable call. This changes the API behavior - if the server expects this ID, the call will fail or create variables with auto-generated IDs only. Verify this matches the server-side API changes.

Suggested change
functionId: func['$id'],
functionId: func['$id'],
variableId: ID.unique(),

Copilot uses AI. Check for mistakes.
uploadableChunk = new Uint8Array(client.CHUNK_SIZE);
currentChunk++;
currentPosition = 0;
}
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

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

Avoid automated semicolon insertion (92% of all statements in the enclosing function have an explicit semicolon).

Copilot uses AI. Check for mistakes.
uploadableChunk = new Uint8Array(client.CHUNK_SIZE);
currentChunk++;
currentPosition = 0;
}
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

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

Avoid automated semicolon insertion (93% of all statements in the enclosing function have an explicit semicolon).

Copilot uses AI. Check for mistakes.
uploadableChunk = new Uint8Array(client.CHUNK_SIZE);
currentChunk++;
currentPosition = 0;
}
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

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

Avoid automated semicolon insertion (93% of all statements in the enclosing function have an explicit semicolon).

Copilot uses AI. Check for mistakes.
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: 6

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (6)
lib/commands/users.ts (1)

1037-1052: Add error handling for JSON.parse to prevent unhandled exceptions.

The prefs parameter is now a string that gets parsed via JSON.parse(). If the user provides malformed JSON, this will throw a SyntaxError and crash the command without a helpful message.

🔎 Proposed fix with error handling
 export const usersUpdatePrefs = async ({userId,prefs,parseOutput = true, overrideForCli = false, sdk = undefined}: UsersUpdatePrefsRequestParams): Promise<any> => {
     let client = !sdk ? await sdkForProject() :
     sdk;
     let apiPath = '/users/{userId}/prefs'.replace('{userId}', userId);
     let payload = {};
     if (typeof prefs !== 'undefined') {
-        payload['prefs'] = JSON.parse(prefs);
+        try {
+            payload['prefs'] = JSON.parse(prefs);
+        } catch (e) {
+            throw new Error(`Invalid JSON for prefs: ${(e as Error).message}`);
+        }
     }
lib/commands/teams.ts (1)

470-485: Add error handling for JSON.parse to prevent unhandled exceptions.

Same issue as usersUpdatePrefs – malformed JSON input will throw an unhandled SyntaxError.

🔎 Proposed fix with error handling
 export const teamsUpdatePrefs = async ({teamId,prefs,parseOutput = true, overrideForCli = false, sdk = undefined}: TeamsUpdatePrefsRequestParams): Promise<any> => {
     let client = !sdk ? await sdkForProject() :
     sdk;
     let apiPath = '/teams/{teamId}/prefs'.replace('{teamId}', teamId);
     let payload = {};
     if (typeof prefs !== 'undefined') {
-        payload['prefs'] = JSON.parse(prefs);
+        try {
+            payload['prefs'] = JSON.parse(prefs);
+        } catch (e) {
+            throw new Error(`Invalid JSON for prefs: ${(e as Error).message}`);
+        }
     }
lib/commands/messaging.ts (1)

237-245: Guard JSON parsing of data and serviceAccountJSON

JSON.parse(data) and JSON.parse(serviceAccountJSON) run directly on CLI input; malformed JSON will throw and likely surface as a generic error.

Consider wrapping these in a small parse helper that:

  • Catches SyntaxError
  • Emits a clear message like “--data must be valid JSON” / “--service-account-json must be valid JSON”
  • Optionally exits with a non‑zero code

This keeps the CLI failure mode user-friendly without changing the serialized payload shape.

Also applies to: 288-290, 341-349, 389-391, 831-834, 851-853, 872-876, 892-894

lib/commands/functions.ts (1)

1031-1063: Guard JSON parsing for headers in functionsCreateExecution

headers is now a string and you’re doing:

if (typeof headers !== 'undefined') {
    payload['headers'] = JSON.parse(headers);
}

If a user passes malformed JSON, JSON.parse will throw and crash the CLI with an unhelpful stack trace. It would be better to catch this and surface a clear validation error instead of an unhandled exception.

Suggested guarded parse
-    if (typeof headers !== 'undefined') {
-        payload['headers'] = JSON.parse(headers);
-    }
+    if (typeof headers !== 'undefined') {
+        try {
+            payload['headers'] = JSON.parse(headers);
+        } catch (e) {
+            throw new Error(`Invalid JSON for --headers: ${(e as Error).message}`);
+        }
+    }
lib/commands/tables-db.ts (2)

2080-2121: Guard JSON parsing for data payloads

For several operations you now accept data: string and immediately JSON.parse it:

if (typeof data !== 'undefined') {
    payload['data'] = JSON.parse(data);
}

This applies to tablesDBCreateRow, tablesDBUpdateRows, tablesDBUpsertRow, and tablesDBUpdateRow.

If the user passes invalid JSON on the CLI, the process will throw with a raw stack trace instead of a clear error message. Consider wrapping these parses in try/catch and surfacing a concise “invalid JSON for --data” error instead.

Example guarded parse for one site
-    if (typeof data !== 'undefined') {
-        payload['data'] = JSON.parse(data);
-    }
+    if (typeof data !== 'undefined') {
+        try {
+            payload['data'] = JSON.parse(data);
+        } catch (e) {
+            throw new Error(`Invalid JSON for --data: ${(e as Error).message}`);
+        }
+    }

You can apply the same pattern to the other data sites.

Also applies to: 2199-2214, 2316-2335, 2357-2376


273-289: rows/operations are sent as string[] but API expects arrays of JSON objects

operations and rows are now typed as string[] and forwarded directly:

// create-operations
operations = (operations as unknown) === true ? [] : operations;
if (typeof operations !== 'undefined') {
    payload['operations'] = operations;
}

// create-rows / upsert-rows
rows = (rows as unknown) === true ? [] : rows;
if (typeof rows !== 'undefined') {
    payload['rows'] = rows;
}

However, the TablesDB REST and server SDK docs describe these parameters as arrays of JSON objects, not strings, for both createRows and upsertRows, and similarly for createOperations where each element is an operation object.

With the current implementation, the CLI sends rows/operations as string[], which will serialize to JSON as an array of strings instead of row/operation objects. Unless the backend explicitly supports stringified JSON here, this is very likely to break these commands.

I’d strongly recommend normalizing these values to actual objects before sending, while still tolerating direct object arrays for programmatic use.

Proposed normalization for rows and operations
 interface TablesDBCreateOperationsRequestParams {
     transactionId: string;
-    operations?: string[];
+    operations?: string[];
 }

 export const tablesDBCreateOperations = async ({transactionId,operations, ...}: TablesDBCreateOperationsRequestParams) => {
@@
-    operations = (operations as unknown) === true ? [] : operations;
-    if (typeof operations !== 'undefined') {
-        payload['operations'] = operations;
-    }
+    operations = (operations as unknown) === true ? [] : operations;
+    if (typeof operations !== 'undefined') {
+        payload['operations'] = operations.map((op: any) =>
+            typeof op === 'string' ? JSON.parse(op) : op
+        );
+    }
@@
 interface TablesDBCreateRowsRequestParams {
@@
-    rows: string[];
+    rows: string[];
 }
@@
-    rows = (rows as unknown) === true ? [] : rows;
-    if (typeof rows !== 'undefined') {
-        payload['rows'] = rows;
-    }
+    rows = (rows as unknown) === true ? [] : rows;
+    if (typeof rows !== 'undefined') {
+        payload['rows'] = rows.map((row: any) =>
+            typeof row === 'string' ? JSON.parse(row) : row
+        );
+    }
@@
 interface TablesDBUpsertRowsRequestParams {
@@
-    rows: string[];
+    rows: string[];
 }
@@
-    rows = (rows as unknown) === true ? [] : rows;
-    if (typeof rows !== 'undefined') {
-        payload['rows'] = rows;
-    }
+    rows = (rows as unknown) === true ? [] : rows;
+    if (typeof rows !== 'undefined') {
+        payload['rows'] = rows.map((row: any) =>
+            typeof row === 'string' ? JSON.parse(row) : row
+        );
+    }

You may also want to add try/catch around the JSON.parse calls to provide clear error messages if a given --rows or --operations item is invalid JSON.

Also applies to: 2124-2142, 2160-2178

🧹 Nitpick comments (24)
lib/enums/database-type.ts (1)

1-4: Consider improving the casing of Tablesdb for better readability.

The enum member Tablesdb (line 3) would be more readable as TablesDB or TablesDb to follow conventional PascalCase patterns. The current casing makes it appear as a single lowercase word.

🔎 Suggested improvement
 export enum DatabaseType {
     Legacy = 'legacy',
-    Tablesdb = 'tablesdb',
+    TablesDB = 'tablesdb',
 }

Additionally, if these enum values correspond to an external API specification, you may want to verify that the string values 'legacy' and 'tablesdb' match the expected API contract.

lib/enums/health-antivirus-status.ts (1)

1-5: LGTM! Clean enum implementation.

The enum is well-structured with appropriate string values and follows TypeScript best practices. The three status values (Disabled, Offline, Online) provide a clear, type-safe representation of health antivirus states.

Optional: Consider adding JSDoc documentation

Adding documentation would help consumers understand when each status applies:

+/**
+ * Health status of the antivirus service.
+ */
 export enum HealthAntivirusStatus {
+    /** Antivirus service is disabled */
     Disabled = 'disabled',
+    /** Antivirus service is offline/unavailable */
     Offline = 'offline',
+    /** Antivirus service is online and operational */
     Online = 'online',
 }
lib/enums/sms-template-type.ts (1)

5-5: Consider using MfaChallenge for PascalCase consistency.

The member Mfachallenge breaks the PascalCase convention used elsewhere (e.g., OneToOne, ManyToMany). Suggest renaming to MfaChallenge.

🔎 Proposed fix
-    Mfachallenge = 'mfachallenge',
+    MfaChallenge = 'mfachallenge',
lib/enums/runtime.ts (2)

8-8: Consider consistent naming convention for runtime versions.

Line 8 uses Node22 without a patch version, while other Node versions (e.g., Node145, Node160) include patch numbers in the member name. This inconsistency may cause confusion.

🔎 Suggested naming consistency
-    Node22 = 'node-22',
+    Node220 = 'node-22',

Apply similar changes to Line 49 (Java22) for consistency.


22-23: Inconsistent casing in Python ML runtime identifiers.

The member names Pythonml311 and Pythonml312 use lowercase "ml", breaking the PascalCase convention followed elsewhere (e.g., Python38, Python312).

🔎 Suggested naming improvement
-    Pythonml311 = 'python-ml-3.11',
-    Pythonml312 = 'python-ml-3.12',
+    PythonMl311 = 'python-ml-3.11',
+    PythonMl312 = 'python-ml-3.12',
lib/enums/output.ts (1)

1-9: Consider removing the unused Output enum.

Both Output and ImageFormat enums are identical with the same seven members (Jpg, Jpeg, Png, Webp, Heic, Avif, Gif). The Output enum is not imported or used anywhere in the codebase, while ImageFormat is actively used in lib/commands/storage.ts. Remove the duplicate Output enum to eliminate dead code.

CHANGELOG.md (1)

3-6: Consider more concise wording.

The phrase "a lot of" could be replaced with "many" or "numerous" for a more professional tone in the changelog.

🔎 Suggested alternatives
 ## 13.0.0-rc.2
 
-* Fixes a lot of typescript errors throughout the codebase
+* Fixes many TypeScript errors throughout the codebase

or

 ## 13.0.0-rc.2
 
-* Fixes a lot of typescript errors throughout the codebase
+* Fixes numerous TypeScript errors throughout the codebase
lib/commands/locale.ts (1)

14-14: Remove unused type imports UploadProgress and FileInput.

The imported types on line 14 are not used anywhere in this file and can be safely removed.

lib/commands/tokens.ts (1)

14-14: Unused type imports.

UploadProgress and FileInput are imported but not used anywhere in this file. Given this appears to be auto-generated SDK code, this may be intentional for consistency across command files.

lib/commands/account.ts (1)

676-689: Consider adding error handling for JSON.parse.

The prefs parameter type changed from object to string, and JSON.parse(prefs) is called without error handling. If users provide malformed JSON, this will throw an unhandled exception with a cryptic error message.

🔎 Proposed fix with user-friendly error handling
     if (typeof prefs !== 'undefined') {
-        payload['prefs'] = JSON.parse(prefs);
+        try {
+            payload['prefs'] = JSON.parse(prefs);
+        } catch (e) {
+            throw new Error(`Invalid JSON for prefs: ${(e as Error).message}`);
+        }
     }
lib/enums/email-template-type.ts (1)

1-9: Consider consistent PascalCase for multi-word enum members.

The enum members mix different casing styles. For better readability and consistency with TypeScript conventions, consider:

  • MagicsessionMagicSession
  • MfachallengeMfaChallenge
  • SessionalertSessionAlert
  • OtpsessionOtpSession
🔎 Proposed refactor
 export enum EmailTemplateType {
     Verification = 'verification',
-    Magicsession = 'magicsession',
+    MagicSession = 'magicsession',
     Recovery = 'recovery',
     Invitation = 'invitation',
-    Mfachallenge = 'mfachallenge',
-    Sessionalert = 'sessionalert',
-    Otpsession = 'otpsession',
+    MfaChallenge = 'mfachallenge',
+    SessionAlert = 'sessionalert',
+    OtpSession = 'otpsession',
 }
lib/commands/graphql.ts (1)

14-14: Consider removing unused type imports.

The UploadProgress and FileInput types are imported but not used in this file. If they're not needed, consider removing them to keep the imports clean.

🔎 Proposed refactor
-import type { UploadProgress, FileInput } from '../types';
lib/enums/framework.ts (1)

1-17: Consider verifying official framework name casing.

Some enum members use non-standard PascalCase (e.g., Nextjs, Sveltekit, Tanstackstart, Reactnative). While the lowercase string values are correct, consider aligning member names with official branding if consistency is desired:

  • NextjsNextJs (if following Next.js branding)
  • SveltekitSvelteKit
  • TanstackstartTanstackStart
  • ReactnativeReactNative

However, if this casing matches your API or documentation standards, the current naming is acceptable.

lib/commands/messaging.ts (1)

114-137: Boolean-to-array normalization is sensible but a bit opaque

Normalizing variadic options like topics, users, targets, cc, bcc, attachments, and subscribe via (value as unknown) === true ? [] : value avoids sending a bare true when the flag is provided without values, which is helpful.

If you want to make this more obvious/robust later, consider extracting a small helper (e.g., normalizeArrayFlag<T>(value: T[] | boolean | undefined)) and using it everywhere to centralize the behavior and documentation.

Also applies to: 184-221, 276-287, 371-382, 466-477, 516-527, 2075-2078, 2140-2143

lib/commands/push.ts (1)

1008-1031: Using shared questionsPush* prompts keeps push flows consistent

Wiring pushResources, pushSite, pushFunction, pushTable, pushBucket, pushTeam, and pushMessagingTopic through the shared questionsPush* definitions simplifies CLI interactions and centralizes validation.

The fallback behavior when no IDs are selected (logging “No X found” and exiting) is preserved.

Also applies to: 1147-1152, 1471-1476, 2022-2037, 2295-2300, 2457-2462

lib/questions.ts (1)

756-771: Push-related question sets line up cleanly with push command behavior

The new/updated questionsPushResources, questionsPushSites, questionsPushFunctions, questionsPushCollections, questionsPushTables, questionsPushBuckets, questionsPushMessagingTopics, and questionsPushTeams mirror the available push commands and use localConfig plus validateRequired appropriately.

This centralization should make it easier to keep prompts and push behavior in sync.

Also applies to: 790-809, 811-830, 832-851, 853-872, 890-909, 911-929, 946-965

lib/commands/storage.ts (2)

112-115: Array flag normalization for permissions and extensions is a good safeguard

Normalizing permissions and allowedFileExtensions via (value as unknown) === true ? [] : value ensures that a bare --permissions or --allowed-file-extensions flag doesn’t result in a literal true being sent to the API.

If you want to reuse this pattern across modules, consider a small shared helper; otherwise this is fine as-is.

Also applies to: 125-128, 210-213, 223-226, 501-504


321-333: File upload typing and progress callback are wired correctly

storageCreateFile now:

  • Wraps the source file as a FileInput (stream + filename + size) for local size/metadata.
  • Supports chunked uploads with appropriate content-range headers and reuses the existing resume logic.
  • Invokes onProgress with $id, percentage, bytes uploaded, and chunk counts after each successful chunk.

This preserves existing behavior while exposing a typed progress hook for callers.

Also applies to: 340-351, 356-367, 379-427, 429-443

lib/commands/sites.ts (1)

572-738: FileInput-based upload wiring is sound; consider tightening onProgress typing

The codeUpload: FileInput wrapper, size calculation, streaming via for await (const chunk of codeUpload.stream), and per-chunk File construction all look correct and consistent with the expected multipart/chunked upload behavior. The UploadProgress payload you pass into onProgress also matches the new type.

The only minor nit is the default onProgress = (progress: any) => {}; using (_: UploadProgress) => {} would preserve type safety without changing behavior.

Suggested minor typing tweak
-export const sitesCreateDeployment = async ({siteId,code,activate,installCommand,buildCommand,outputDirectory,parseOutput = true, overrideForCli = false, sdk = undefined,onProgress = (progress: any) => {}}: SitesCreateDeploymentRequestParams): Promise<any> => {
+export const sitesCreateDeployment = async ({siteId,code,activate,installCommand,buildCommand,outputDirectory,parseOutput = true, overrideForCli = false, sdk = undefined,onProgress = (_progress: UploadProgress) => {}}: SitesCreateDeploymentRequestParams): Promise<any> => {
lib/commands/functions.ts (2)

124-151: execute/events/scopes normalization is reasonable

The pattern

execute = (execute as unknown) === true ? [] : execute;
events = (events as unknown) === true ? [] : events;
scopes = (scopes as unknown) === true ? [] : scopes;

correctly converts the Commander-style true sentinel (flag present, no values) into an empty array before sending payloads, which avoids leaking a boolean to the API. This is consistent with other commands.

You might eventually centralize this “boolean to empty array” normalization into a small helper to reduce repetition across commands, but it’s not urgent.


576-738: FileInput-based deployment upload path looks correct; minor onProgress typing nit

The deployment upload logic using FileInput (size from fs.statSync, stream from convertReadStreamToReadableStream, per-chunk File objects, and UploadProgress shape passed to onProgress) is internally consistent and mirrors the sites deployment flow.

As with sitesCreateDeployment, consider tightening the default onProgress type to (_: UploadProgress) => {} instead of (progress: any) => {} for better type safety without behavior change.

Suggested minor typing tweak
-export const functionsCreateDeployment = async ({functionId,code,activate,entrypoint,commands,parseOutput = true, overrideForCli = false, sdk = undefined,onProgress = (progress: any) => {}}: FunctionsCreateDeploymentRequestParams): Promise<any> => {
+export const functionsCreateDeployment = async ({functionId,code,activate,entrypoint,commands,parseOutput = true, overrideForCli = false, sdk = undefined,onProgress = (_progress: UploadProgress) => {}}: FunctionsCreateDeploymentRequestParams): Promise<any> => {
lib/commands/tables-db.ts (1)

273-303: Boolean-to-empty-array normalization is reasonable but verbose

Patterns like:

operations = (operations as unknown) === true ? [] : operations;
permissions = (permissions as unknown) === true ? [] : permissions;
columns = (columns as unknown) === true ? [] : columns;
indexes = (indexes as unknown) === true ? [] : indexes;
elements = (elements as unknown) === true ? [] : elements;
columns = (columns as unknown) === true ? [] : columns;
orders = (orders as unknown) === true ? [] : orders;
lengths = (lengths as unknown) === true ? [] : lengths;
xdefault = (xdefault as unknown) === true ? [] : xdefault;

correctly handle the Commander pattern where a ...[values] option with no values results in true, avoiding sending a bare boolean to the API. This matches the intended CLI UX.

Given how often this shows up, you might eventually want a small helper like normalizeListOption<T>(value?: T[] | boolean): T[] | undefined to cut down on repetition, but behavior here is fine.

Also applies to: 469-511, 577-580, 929-985, 1921-1932, 1312-1515

lib/commands/databases.ts (1)

286-289: CLI argument edge case handling is correct but could use documentation.

The pattern (operations as unknown) === true ? [] : operations handles the Commander.js edge case where variadic options passed without values may be coerced to true. This is repeated throughout the file for all array parameters. Consider adding a brief inline comment explaining this behavior for future maintainers.

lib/config.ts (1)

270-272: Type cast may be masking a missing property in interface.

The cast 'endpoint' as keyof ProjectConfigData forces TypeScript to accept endpoint as a valid key, but endpoint doesn't appear to be defined in ProjectConfigData (based on the interface definition in types.ts). If the local config legitimately stores an endpoint, consider adding endpoint?: string to ProjectConfigData rather than using a type assertion.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8c0fed3 and ecfc199.

📒 Files selected for processing (95)
  • .github/workflows/npm-publish.yml
  • CHANGELOG.md
  • README.md
  • index.ts
  • install.ps1
  • install.sh
  • lib/client.ts
  • lib/commands/account.ts
  • lib/commands/console.ts
  • lib/commands/databases.ts
  • lib/commands/functions.ts
  • lib/commands/generic.ts
  • lib/commands/graphql.ts
  • lib/commands/health.ts
  • lib/commands/init.ts
  • lib/commands/locale.ts
  • lib/commands/messaging.ts
  • lib/commands/migrations.ts
  • lib/commands/project.ts
  • lib/commands/projects.ts
  • lib/commands/proxy.ts
  • lib/commands/pull.ts
  • lib/commands/push.ts
  • lib/commands/run.ts
  • lib/commands/sites.ts
  • lib/commands/storage.ts
  • lib/commands/tables-db.ts
  • lib/commands/teams.ts
  • lib/commands/tokens.ts
  • lib/commands/users.ts
  • lib/commands/vcs.ts
  • lib/config.ts
  • lib/emulation/docker.ts
  • lib/enums/adapter.ts
  • lib/enums/api-service.ts
  • lib/enums/api.ts
  • lib/enums/attribute-status.ts
  • lib/enums/auth-method.ts
  • lib/enums/authentication-factor.ts
  • lib/enums/authenticator-type.ts
  • lib/enums/browser.ts
  • lib/enums/build-runtime.ts
  • lib/enums/column-status.ts
  • lib/enums/compression.ts
  • lib/enums/console-resource-type.ts
  • lib/enums/credit-card.ts
  • lib/enums/database-type.ts
  • lib/enums/deployment-download-type.ts
  • lib/enums/deployment-status.ts
  • lib/enums/email-template-locale.ts
  • lib/enums/email-template-type.ts
  • lib/enums/execution-method.ts
  • lib/enums/execution-status.ts
  • lib/enums/execution-trigger.ts
  • lib/enums/flag.ts
  • lib/enums/framework.ts
  • lib/enums/health-antivirus-status.ts
  • lib/enums/health-check-status.ts
  • lib/enums/image-format.ts
  • lib/enums/image-gravity.ts
  • lib/enums/index-status.ts
  • lib/enums/index-type.ts
  • lib/enums/message-priority.ts
  • lib/enums/message-status.ts
  • lib/enums/messaging-provider-type.ts
  • lib/enums/name.ts
  • lib/enums/o-auth-provider.ts
  • lib/enums/output.ts
  • lib/enums/password-hash.ts
  • lib/enums/platform-type.ts
  • lib/enums/project-usage-range.ts
  • lib/enums/proxy-resource-type.ts
  • lib/enums/proxy-rule-deployment-resource-type.ts
  • lib/enums/proxy-rule-status.ts
  • lib/enums/region.ts
  • lib/enums/relation-mutate.ts
  • lib/enums/relationship-type.ts
  • lib/enums/runtime.ts
  • lib/enums/sms-template-locale.ts
  • lib/enums/sms-template-type.ts
  • lib/enums/smtp-encryption.ts
  • lib/enums/smtp-secure.ts
  • lib/enums/status-code.ts
  • lib/enums/template-reference-type.ts
  • lib/enums/theme.ts
  • lib/enums/timezone.ts
  • lib/enums/usage-range.ts
  • lib/enums/vcs-detection-type.ts
  • lib/enums/vcs-reference-type.ts
  • lib/paginate.ts
  • lib/parser.ts
  • lib/questions.ts
  • lib/types.ts
  • package.json
  • scoop/appwrite.config.json
🧰 Additional context used
🧬 Code graph analysis (8)
lib/commands/init.ts (1)
lib/questions.ts (2)
  • questionsInitResources (773-788)
  • questionsInitProject (152-268)
lib/commands/run.ts (1)
lib/questions.ts (1)
  • questionsRunFunctions (1017-1037)
lib/commands/pull.ts (1)
lib/questions.ts (1)
  • questionsPullResources (279-294)
lib/questions.ts (1)
lib/commands/generic.ts (1)
  • client (242-316)
lib/commands/generic.ts (1)
lib/config.ts (1)
  • globalConfig (858-858)
lib/commands/storage.ts (1)
lib/types.ts (2)
  • UploadProgress (27-33)
  • FileInput (20-25)
lib/config.ts (1)
lib/types.ts (11)
  • Entity (39-42)
  • ProjectConfigData (291-303)
  • SiteConfig (261-278)
  • FunctionConfig (242-259)
  • CollectionConfig (179-188)
  • TableConfig (218-227)
  • BucketConfig (229-240)
  • TopicConfig (285-289)
  • TeamConfig (280-283)
  • ProjectSettings (77-113)
  • RawProjectSettings (115-143)
lib/commands/functions.ts (1)
lib/types.ts (2)
  • UploadProgress (27-33)
  • FileInput (20-25)
🪛 actionlint (1.7.9)
.github/workflows/npm-publish.yml

9-9: could not parse as YAML: mapping values are not allowed in this context

(syntax-check)

🪛 LanguageTool
CHANGELOG.md

[style] ~5-~5: Consider using a synonym to be more concise.
Context: # Change Log ## 13.0.0-rc.2 * Fixes a lot of typescript errors throughout the codeba...

(A_LOT_OF)

🪛 YAMLlint (1.37.1)
.github/workflows/npm-publish.yml

[error] 9-9: syntax error: mapping values are not allowed here

(syntax)

🔇 Additional comments (114)
lib/enums/theme.ts (1)

1-4: LGTM!

The Theme enum is correctly defined with appropriate TypeScript conventions and provides type-safe constants for theme selection.

lib/enums/message-priority.ts (1)

1-4: LGTM! The enum implementation is clean and follows TypeScript best practices with string values for serialization. Verified that MessagePriority is properly used in lib/commands/messaging.ts.

lib/enums/execution-trigger.ts (1)

1-5: No changes needed. The enum correctly follows the established pattern in the codebase—all enums consistently use simple declarations without JSDoc documentation.

lib/enums/browser.ts (1)

1-16: No changes needed. The browser code mappings for MicrosoftEdge = 'ps' and MicrosoftEdgeIOS = 'oi' are correct according to Appwrite SDK specifications and match the API requirements.

lib/enums/health-check-status.ts (1)

1-4: LGTM!

Clean enum declaration with appropriate values for health check status representation.

lib/enums/api.ts (1)

1-5: LGTM!

Enum correctly represents the three API protocol types used in the system.

lib/enums/messaging-provider-type.ts (1)

1-5: LGTM!

Enum appropriately represents the messaging provider types used in the system.

lib/enums/index-status.ts (1)

1-7: LGTM!

Comprehensive enum covering the full lifecycle of database indexes, including transitional and error states.

lib/enums/authenticator-type.ts (1)

1-3: LGTM!

Enum correctly defines the TOTP authenticator type. Note that this currently contains only one member, which may be expanded with additional authenticator types (e.g., WebAuthn, U2F) in future iterations.

lib/enums/vcs-detection-type.ts (1)

1-4: LGTM!

Enum appropriately categorizes VCS detection modes for runtime and framework detection.

lib/enums/region.ts (1)

1-3: LGTM!

Enum correctly defines the default region. Note that this currently contains only a single member, which may be expanded with additional regions (e.g., specific geographic regions) when multi-region support is implemented.

lib/enums/usage-range.ts (1)

1-5: LGTM! Clean enum definition for time range constants.

The enum provides clear, type-safe constants for usage time windows that can be used across the codebase.

lib/commands/vcs.ts (1)

4-4: LGTM! Import modernization aligns with ES module standards.

The migration from CommonJS (require) to ES module imports is correct. The type-only imports for UploadProgress and FileInput are properly annotated, and the VCSDetectionType enum import is used appropriately in the interface definitions below.

Also applies to: 14-15

lib/enums/api-service.ts (1)

1-15: LGTM! Centralized API service identifiers.

The enum provides type-safe constants for API service names, improving maintainability and reducing typos across the codebase.

lib/enums/o-auth-provider.ts (1)

1-42: LGTM! Comprehensive OAuth provider enumeration.

The enum covers a wide range of OAuth providers with a Mock option for testing. The naming conventions align with provider identifiers and maintain consistency with the backend API.

lib/enums/authentication-factor.ts (1)

1-6: LGTM! Authentication factor constants defined.

The enum provides type-safe constants for multi-factor authentication methods, maintaining consistency with backend API values.

lib/enums/proxy-rule-deployment-resource-type.ts (1)

1-4: LGTM! Clear resource type enumeration.

The enum provides type-safe constants for proxy rule deployment resource types.

lib/enums/name.ts (1)

1-14: LGTM! Consistent versioned identifier enumeration.

The enum provides centralized v1 resource identifiers with a clear and consistent naming pattern across all members.

lib/enums/column-status.ts (1)

1-7: LGTM! Comprehensive column lifecycle status enumeration.

The enum provides type-safe constants for tracking column state throughout its lifecycle, from creation through deletion and error states.

lib/enums/template-reference-type.ts (1)

1-5: LGTM!

Clean and idiomatic TypeScript string enum following consistent naming conventions.

lib/enums/relationship-type.ts (1)

1-6: LGTM!

Standard relationship type enum with proper naming conventions.

lib/enums/attribute-status.ts (1)

1-7: LGTM!

Well-defined status enum covering the attribute lifecycle states.

lib/enums/compression.ts (1)

1-5: LGTM!

Clean enum covering standard compression options.

lib/enums/execution-status.ts (1)

1-7: LGTM!

Comprehensive execution status enum covering all lifecycle states.

lib/enums/flag.ts (1)

1-197: LGTM!

Comprehensive country flag enum with ISO 3166-1 alpha-2 codes. The ordering appears to be intentional (likely matching the upstream API spec).

lib/enums/relation-mutate.ts (1)

1-5: LGTM!

The enum correctly defines database relation mutation strategies with appropriate string values that align with standard SQL/ORM conventions.

lib/enums/adapter.ts (1)

1-4: LGTM!

Clean enum definition for adapter types with appropriate string values.

lib/enums/deployment-status.ts (1)

1-7: LGTM!

The enum appropriately models the deployment lifecycle with clear, self-documenting state values.

lib/enums/runtime.ts (1)

1-69: Enum structure is correct.

The Runtime enum provides comprehensive coverage of supported runtimes with appropriate version mappings.

lib/enums/proxy-rule-status.ts (1)

1-6: LGTM!

The enum correctly models proxy rule verification states with clear, self-documenting values.

lib/enums/message-status.ts (1)

1-7: LGTM!

The enum appropriately models the message lifecycle with clear state transitions from draft through processing, scheduling, and final delivery states.

lib/enums/status-code.ts (1)

1-6: No action required. The string representation of HTTP status codes in the StatusCode enum is consistent with all other enums in this codebase and is intentional for Appwrite API compatibility. The enum values are correctly passed to the API payload and function as designed.

Likely an incorrect or invalid review comment.

lib/client.ts (4)

2-2: LGTM: File type import supports improved type safety.

The addition of the File type import from undici properly supports the type-safe file handling at line 171.


25-26: LGTM: Version updated consistently.

SDK version correctly updated from rc.1 to rc.2 in both headers, matching the PR objectives.


171-171: LGTM: Removed unsafe type cast.

Excellent improvement removing the as any cast. With the proper File type import, the code is now type-safe without requiring type assertions.


12-12: CHUNK_SIZE public exposure is intentional and necessary.

The CHUNK_SIZE constant is accessed by external modules (lib/commands/functions.ts, lib/commands/storage.ts, and lib/commands/sites.ts) to manage file uploads in chunks. The public visibility is required for these modules to calculate buffer sizes, chunk boundaries, and upload progress.

lib/enums/execution-method.ts (1)

1-9: LGTM: Well-defined HTTP method enum.

The ExecutionMethod enum provides type-safe constants for HTTP methods with appropriate member values.

index.ts (1)

8-8: LGTM: Import modernization.

The update from CommonJS to ES module import syntax for Commander aligns with modern TypeScript practices and the broader import standardization mentioned in the PR summary.

lib/enums/auth-method.ts (1)

1-9: LGTM: Comprehensive authentication method enum.

The AuthMethod enum provides well-defined authentication method constants with appropriate kebab-case string values.

lib/enums/image-gravity.ts (1)

1-11: LGTM: Standard image gravity enum.

The ImageGravity enum provides complete coverage of standard image positioning options with consistent naming.

lib/enums/platform-type.ts (1)

1-17: LGTM: Comprehensive platform type enum.

The PlatformType enum provides extensive coverage of supported platforms with consistent kebab-case naming.

lib/enums/timezone.ts (1)

1-421: LGTM: Comprehensive IANA timezone enum.

The Timezone enum provides extensive coverage of IANA timezone identifiers with proper lowercase formatting. This enables type-safe timezone selection across the codebase.

lib/enums/credit-card.ts (1)

1-19: LGTM with verification needed for one value.

The credit card enum provides comprehensive coverage of card brands. However, verify the spelling at line 13.

lib/enums/password-hash.ts (1)

1-14: LGTM!

The enum provides a clean, type-safe set of password hash algorithm identifiers. The naming is consistent and the values are appropriate.

lib/enums/build-runtime.ts (1)

1-70: LGTM!

Comprehensive enum covering a wide range of build runtimes with consistent naming conventions. This provides excellent type safety for runtime identifiers.

lib/parser.ts (1)

127-127: LGTM!

Version string correctly updated to match the release candidate bump.

lib/commands/project.ts (1)

4-4: LGTM!

Import modernization from CommonJS to ES modules and addition of type/enum imports improve type safety and align with modern TypeScript practices.

Also applies to: 14-15

README.md (1)

32-32: LGTM!

Documentation correctly updated to reflect the version bump to 13.0.0-rc.2.

Also applies to: 63-63

lib/enums/vcs-reference-type.ts (1)

1-6: LGTM!

Clean enum providing type-safe VCS reference type identifiers. The implementation is straightforward and correct.

lib/enums/console-resource-type.ts (1)

1-3: LGTM! Clean enum definition.

The ConsoleResourceType enum is properly defined and exported. It's correctly consumed by lib/commands/console.ts for type-safe resource type handling.

lib/commands/locale.ts (1)

4-4: ES module import modernization looks good.

The migration from require('ignore') to import ignore from 'ignore' aligns with the broader ES module standardization across the codebase.

package.json (2)

5-5: Version bump to 13.0.0-rc.2 looks good.

The version increment aligns with the PR objectives and follows proper semantic versioning for release candidates.


17-17: Build passes successfully with the TypeScript compilation script.

The build script "build": "tsc" executes without errors and enforces strict TypeScript compilation. Note that this is a newly created configuration rather than a modification of an existing script—the git history does not show any prior || true fallback being removed.

Likely an incorrect or invalid review comment.

lib/enums/smtp-encryption.ts (1)

1-5: LGTM! Well-defined SMTP encryption enum.

The SmtpEncryption enum properly defines standard SMTP encryption options (none, SSL, TLS) with appropriate string values.

lib/enums/index-type.ts (1)

1-6: LGTM! Comprehensive database index type enum.

The IndexType enum correctly defines all standard database index types (key, fulltext, unique, spatial) and provides type-safe constants for index-related operations.

lib/enums/deployment-download-type.ts (1)

1-4: LGTM! Clear deployment download type enum.

The DeploymentDownloadType enum appropriately defines the two deployment artifact types (source and output) for download operations.

lib/commands/health.ts (2)

4-4: ES module import modernization approved.

The migration to ES module syntax for the ignore package is consistent with the broader modernization effort across the codebase.


14-15: Remove unused type imports UploadProgress and FileInput.

The Name enum import is correctly used in HealthGetFailedJobsRequestParams (line 305). However, UploadProgress and FileInput are not referenced anywhere in the file and should be removed.

Likely an incorrect or invalid review comment.

lib/commands/console.ts (2)

4-4: ES module import looks good.

The standardized ES module import for the ignore package aligns with the modernization goals of this release.


14-15: Remove unused type imports UploadProgress and FileInput.

The ConsoleResourceType enum import is correctly used in ConsoleGetResourceRequestParams (line 42). However, UploadProgress and FileInput are not used anywhere in this file and should be removed.

Likely an incorrect or invalid review comment.

lib/commands/tokens.ts (1)

4-4: LGTM - ES module import modernization.

The switch from CommonJS require to ES module default import aligns with the codebase modernization effort in this PR.

lib/commands/pull.ts (1)

57-57: LGTM - Consistent array syntax for inquirer.prompt.

Wrapping the question in an array is more explicit and aligns with the function signature. Both forms work, but using an array is the conventional approach when prompting, even for a single question.

lib/enums/smtp-secure.ts (1)

1-4: LGTM - New type-safe enum for SMTP security modes.

The enum provides a clear, type-safe way to specify SMTP security protocols. The distinction from SmtpEncryption (which includes a None option) is appropriate for contexts where security is mandatory.

install.sh (1)

99-99: LGTM - Version bump to 13.0.0-rc.2.

The version update aligns with the PR objective for the CLI SDK update.

lib/commands/proxy.ts (2)

4-4: LGTM - ES module import modernization.

Consistent with the codebase-wide import style update.


14-16: Enum imports are properly utilized; type imports are unused.

StatusCode and ProxyResourceType are correctly used in the ProxyCreateRedirectRuleRequestParams interface (lines 146-148). However, UploadProgress and FileInput are imported but not used in this file.

lib/commands/account.ts (2)

4-4: LGTM - ES module import modernization.

Consistent with the codebase-wide import style update.


15-17: LGTM - Enum imports are properly utilized.

AuthenticatorType, AuthenticationFactor, and OAuthProvider are correctly used in their respective interface definitions throughout the file.

lib/enums/project-usage-range.ts (1)

1-4: LGTM - New type-safe enum for project usage ranges.

Clean enum definition providing type safety for specifying usage data time ranges.

lib/enums/sms-template-locale.ts (1)

1-133: LGTM - Comprehensive SMS template locale enum.

The enum provides a type-safe representation of supported SMS template locales with good coverage of regional variants.

Minor note: Line 123 uses 'ua' for Ukrainian, which is the country code (Ukraine) rather than the ISO 639-1 language code ('uk'). This is likely intentional to match the Appwrite API specification.

scoop/appwrite.config.json (1)

3-3: LGTM!

Version bump from 13.0.0-rc.1 to 13.0.0-rc.2 is consistent across all references.

Also applies to: 9-9, 18-18

lib/commands/graphql.ts (1)

4-4: LGTM!

Import style modernization to ES module default import is consistent with the broader refactoring effort across the codebase.

lib/commands/init.ts (1)

44-44: LGTM!

Wrapping single-question prompts in arrays improves consistency with the inquirer.prompt() API usage across the codebase.

Also applies to: 88-90

lib/commands/run.ts (2)

4-4: LGTM!

Import style modernization and ignore() instantiation updates are consistent with ES module patterns. The array wrapping for inquirer.prompt() aligns with the broader codebase refactoring.

Also applies to: 31-31, 193-193, 258-258


250-256: No changes needed. The tar library (v6.1.11) automatically detects and decompresses gzipped archives on extraction, making the explicit gzip: true option unnecessary. The pattern of omitting the gzip option in tar.extract() while using it in tar.create() is correct and intentional—you explicitly compress when creating, but rely on auto-detection when extracting. This pattern is consistent throughout the codebase.

lib/emulation/docker.ts (1)

1-1: LGTM!

Import modernization and type centralization improve code organization. Moving FunctionConfig to a central types file enhances reusability across the codebase.

Also applies to: 11-11, 54-54

install.ps1 (1)

16-17: LGTM!

Download URL updates to version 13.0.0-rc.2 are consistent with the release candidate bump across the project.

lib/commands/users.ts (2)

4-18: LGTM – Import modernization and new type definitions.

The ES module import style for ignore and the addition of typed imports (UploadProgress, FileInput, and enums) align with the broader SDK update for version 13.0.0-rc.2.


675-675: Boolean-to-empty-array normalization looks correct.

This pattern handles the CLI edge case where --labels without a value becomes true. The cast through unknown properly bypasses TypeScript's type narrowing.

lib/commands/generic.ts (3)

55-57: LGTM – Session now stores endpoint for better multi-account support.

Storing the endpoint with the session enables proper handling of multiple accounts across different Appwrite instances.


282-288: LGTM – Typed health check response and session storage.

The generic type parameter on client.call<{ version?: string }> provides type safety, and the session correctly stores the endpoint.


323-324: LGTM – Explicit string casts for legacy migration.

The as string casts are appropriate here since the preceding has() checks guarantee the values exist, and the legacy config stored these as strings.

lib/commands/projects.ts (6)

4-25: LGTM – Import updates align with SDK modernization.

The ES module import for ignore and the addition of typed enum imports (Region, Api, AuthMethod, OAuthProvider, PlatformType, ApiService, SMTPSecure, EmailTemplateType, EmailTemplateLocale, SmsTemplateType, SmsTemplateLocale) provide better type safety.


482-498: LGTM – Consistent boolean-to-array normalization for numbers.

The pattern (numbers as unknown) === true ? [] : numbers correctly handles the CLI edge case, consistent with other commands in this PR.


869-872: LGTM – Boolean-to-array normalization for scopes in projectsCreateJWT.


942-945: LGTM – Consistent normalization pattern for scopes in key creation/update.

Also applies to: 1013-1016


1431-1434: LGTM – Boolean-to-array normalization for emails in SMTP test.


1752-1755: LGTM – Boolean-to-array normalization for events in webhook create/update.

Also applies to: 1839-1842

lib/enums/email-template-locale.ts (1)

1-134: LGTM – Comprehensive locale enum for email templates.

The EmailTemplateLocale enum provides type-safe constants for all supported locales, using BCP 47-style string values. The coverage is extensive and aligns with internationalization best practices.

lib/commands/migrations.ts (4)

4-14: LGTM – Import modernization for migrations module.

ES module import for ignore and type-only imports for UploadProgress and FileInput align with the SDK update.


90-93: LGTM – Boolean-to-array normalization for resources in Appwrite migration.


183-190: LGTM – Boolean-to-array normalization for columns and queries in CSV export.


274-277: LGTM – Consistent normalization for resources across Firebase, NHost, and Supabase migrations.

Also applies to: 346-349, 459-462

lib/commands/teams.ts (2)

4-14: LGTM – Import modernization for teams module.

ES module import for ignore and type-only imports align with the SDK update.


100-103: LGTM – Consistent boolean-to-array normalization for roles.

The pattern correctly handles CLI edge cases across teamsCreate, teamsCreateMembership, and teamsUpdateMembership.

Also applies to: 301-304, 365-368

lib/commands/messaging.ts (1)

4-4: Imports and enum usage look consistent

Using the default ignore import plus MessagePriority and SmtpEncryption enums matches the rest of the codebase’s style; no issues spotted here.

Also applies to: 14-16

lib/paginate.ts (1)

5-21: Paginate overloads and return union align with existing usage

The new overloads (array vs. wrapped-object + total) match the implementation and the way callers destructure results ({ attributes }, { databases }, etc.). The pagination loop and termination conditions are unchanged, so behavior should remain consistent.

Also applies to: 24-31, 69-76

lib/commands/push.ts (1)

95-96: Enum-typing for project services and auth methods is a solid tightening

Passing service and method through the ApiService and AuthMethod enums improves type safety without changing what’s actually sent over the wire. No behavioral issues noted.

Also applies to: 1080-1088, 1104-1113

lib/questions.ts (2)

34-43: Extending Question.choices to accept string[] matches actual usage

Many questions use simple string arrays for choices; adding string[] to the choices type definition makes those patterns type-correct without affecting runtime behavior.


248-267: Typed region and endpoint validation calls are straightforward

Using minimally-typed responses for /console/regions and /health/version clarifies the expected payload (regions / version) while preserving existing error messages and control flow.

Also applies to: 702-723

lib/commands/storage.ts (1)

14-18: Enum-typing for compression, image, and usage parameters is appropriate

Using Compression, ImageGravity, ImageFormat, and UsageRange for the respective request params makes the allowable values explicit and matches the CLI help text for these options. No behavioral concerns here.

Also applies to: 588-646, 716-760

lib/commands/sites.ts (1)

4-21: Imports and enum typing for sites look consistent

The switch to import ignore from 'ignore' and the addition of UploadProgress, FileInput, and the various enum imports are coherent with the new shared typing model and don’t introduce any obvious issues.

lib/commands/functions.ts (1)

4-20: New imports and enums align with shared types

The introduction of ignore as a default import and the additional type/enum imports (UploadProgress, FileInput, Runtime, UsageRange, TemplateReferenceType, VCSReferenceType, DeploymentDownloadType, ExecutionMethod) fit the broader typing refactor and don’t present functional issues.

lib/types.ts (1)

1-4: New shared types and config schemas look coherent

The additions and adjustments here—ResponseType, FileUpload now using File, the new FileInput and UploadProgress interfaces, helper types (Entity, ParsedData, CommandDescription, CliConfig), as well as the expanded config models (ProjectSettings, RawProjectSettings, DatabaseConfig/CollectionConfig/TableConfig/ColumnConfig/TableIndexConfig, FunctionConfig, SiteConfig, and the updated ProjectConfigData)—are internally consistent and match how the commands are now consuming them.

They should make the rest of the codebase’s typing around uploads, progress reporting, and project configuration more explicit without introducing runtime risk.

Also applies to: 14-33, 39-60, 69-76, 77-113, 115-149, 151-177, 190-227, 242-259, 261-303

lib/commands/databases.ts (4)

4-18: LGTM! Import modernization and type additions.

The switch to ES module import for ignore and the addition of typed imports for UploadProgress, FileInput, and enums improves type safety and consistency across the codebase.


1896-1906: Type change from object to string aligns with CLI input model.

The change from data: object to data: string correctly reflects that CLI users pass JSON as string arguments. The subsequent JSON.parse(data) converts it to an object for the API call.


2418-2429: LGTM!

Consistent application of the array fallback pattern for index creation parameters.


1955-1958: Pattern inconsistency: Single document function parses JSON, batch operations do not.

The databasesCreateDocument function parses its data parameter with JSON.parse(data) before sending it to the API. However, databasesCreateDocuments and databasesUpsertDocuments accept documents: string[] and pass it directly to the payload without parsing. Both use the same API endpoint. Verify whether each document string in the array should be individually parsed, or if the API handles string deserialization internally.

lib/config.ts (6)

6-21: LGTM! Comprehensive type imports improve type safety.

The expanded type imports from ./types provide proper typing for all configuration entities used throughout the file. This is a significant improvement over the previous any usage.


120-121: Good change: readonly modifier for immutable property.

Changing path from protected to readonly correctly expresses that this property should not be modified after construction.


183-227: Improved typing for database entity methods.

Using the Entity type instead of any provides better type safety. The type casts for this.set are a reasonable workaround for TypeScript's strict generic constraints when dealing with dynamic entity types.


278-323: LGTM! Strongly typed config accessors.

The typed getter/setter methods using SiteConfig, FunctionConfig, etc., provide excellent type safety. The return type pattern TypeConfig | Record<string, never> correctly represents that either a valid config object or an empty object is returned.


606-670: Well-structured settings transformation.

The createSettingsObject method cleanly transforms the flat RawProjectSettings from the API into the nested ProjectSettings structure. This separation provides a better developer experience while handling API compatibility internally.


676-695: LGTM! Const assertions improve type safety.

Using as const for static preference keys provides literal types instead of string, enabling better type checking. The readonly modifier on IGNORE_ATTRIBUTES prevents accidental mutation of the array.

Comment on lines +7 to +9
permissions:
id-token: write
contents: read
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Fix YAML indentation syntax error.

The permissions block has inconsistent indentation. Line 8 (id-token: write) is missing proper indentation, causing a YAML syntax error that will prevent the workflow from executing.

🔎 Proposed fix
 permissions:
-id-token: write
+  id-token: write
   contents: read
📝 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:
id-token: write
contents: read
permissions:
id-token: write
contents: read
🧰 Tools
🪛 actionlint (1.7.9)

9-9: could not parse as YAML: mapping values are not allowed in this context

(syntax-check)

🪛 YAMLlint (1.37.1)

[error] 9-9: syntax error: mapping values are not allowed here

(syntax)

🤖 Prompt for AI Agents
In .github/workflows/npm-publish.yml around lines 7 to 9, the permissions block
has incorrect indentation (line 8 'id-token: write' is not indented to align
under permissions), causing a YAML syntax error; fix by indenting the keys under
permissions consistently (make 'id-token: write' and 'contents: read' children
of 'permissions') so the permissions block is valid YAML.

Comment on lines 1916 to 1918
if (typeof data !== 'undefined') {
payload['data'] = JSON.parse(data);
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Add error handling for JSON.parse to improve CLI UX.

JSON.parse(data) can throw a SyntaxError if the user provides malformed JSON. This would result in an unhandled exception with a cryptic error message. Consider wrapping in try-catch with a user-friendly error message.

This same pattern appears at lines 2029, 2146, and 2187.

🔎 Proposed fix
     if (typeof data !== 'undefined') {
-        payload['data'] = JSON.parse(data);
+        try {
+            payload['data'] = JSON.parse(data);
+        } catch (e) {
+            throw new Error(`Invalid JSON provided for --data: ${(e as Error).message}`);
+        }
     }
📝 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 (typeof data !== 'undefined') {
payload['data'] = JSON.parse(data);
}
if (typeof data !== 'undefined') {
try {
payload['data'] = JSON.parse(data);
} catch (e) {
throw new Error(`Invalid JSON provided for --data: ${(e as Error).message}`);
}
}
🤖 Prompt for AI Agents
In lib/commands/databases.ts around lines 1916-1918, calling JSON.parse(data)
can throw on malformed JSON; wrap the parse in a try/catch, validate that data
is non-empty, and on failure print a clear user-facing error (e.g., "Invalid
JSON for --data: <error message>") and exit with a non-zero code or return a
rejected Promise so the CLI fails gracefully. Apply the same change to the
identical patterns at lines ~2029, ~2146, and ~2187 so all user-provided JSON is
safely parsed with consistent, friendly error handling.


interface GraphqlQueryRequestParams {
query: object;
query: string;
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

head -100 lib/commands/graphql.ts | cat -n

Repository: appwrite/sdk-for-cli

Length of output: 3561


🏁 Script executed:

# Run the provided search for usages
rg -nP --type=ts -C3 '\b(graphqlQuery|graphqlMutation)\s*\(' -g '!lib/commands/graphql.ts'

Repository: appwrite/sdk-for-cli

Length of output: 46


🏁 Script executed:

# Also search for JSON.parse usage in the graphql.ts file
rg -nP --type=ts 'JSON\.parse' lib/commands/graphql.ts

Repository: appwrite/sdk-for-cli

Length of output: 161


🏁 Script executed:

rg -nP --type=ts 'graphqlQuery|graphqlMutation' lib/commands/graphql.ts | head -20

Repository: appwrite/sdk-for-cli

Length of output: 466


🏁 Script executed:

# Search for usages of graphqlQuery and graphqlMutation in other files
rg -nP --type=ts '(graphqlQuery|graphqlMutation)' --max-count=50

Repository: appwrite/sdk-for-cli

Length of output: 562


🏁 Script executed:

rg -nP --type=ts 'actionRunner' lib/parser.ts -A 20 | head -50

Repository: appwrite/sdk-for-cli

Length of output: 949


🏁 Script executed:

# Also check if there's any validation of query parameter before it's passed
rg -nP --type=ts 'query.*valid|validate.*query' -g '!node_modules'

Repository: appwrite/sdk-for-cli

Length of output: 4212


🏁 Script executed:

rg -nP --type=ts 'parseError' lib/parser.ts -B 5 -A 10

Repository: appwrite/sdk-for-cli

Length of output: 1282


🏁 Script executed:

# Let's look at the full context of how these functions are called through the CLI
rg -nP --type=ts 'graphql.*query|graphql.*mutation' lib/commands/graphql.ts -A 5 | head -30

Repository: appwrite/sdk-for-cli

Length of output: 777


Add error handling for JSON.parse operations to provide clearer error messages.

The query parameter type is string, and JSON.parse(query) is called at lines 52 and 82 without explicit error handling. While errors are caught at the actionRunner level, they will surface as generic JSON SyntaxError messages. Consider wrapping the JSON.parse() calls in try-catch blocks to provide more user-friendly error messages, e.g., "Invalid JSON format in query parameter."

🤖 Prompt for AI Agents
In lib/commands/graphql.ts around line 40 (and specifically where JSON.parse is
used at ~lines 52 and 82), the code calls JSON.parse(query) without local error
handling; wrap each JSON.parse(...) in a try-catch and on failure throw a new,
descriptive Error (for example: "Invalid JSON format in query parameter:
<originalError.message>") or return a user-friendly error so callers receive a
clear message instead of a generic SyntaxError; preserve the original error
message for debugging and keep stack trace by rethrowing a new Error that
includes the original.message.

JCB = 'jcb',
Mastercard = 'mastercard',
Naranja = 'naranja',
TarjetaShopping = 'targeta-shopping',
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

cd /tmp && find . -type f -name "credit-card.ts" 2>/dev/null | head -20

Repository: appwrite/sdk-for-cli

Length of output: 46


🏁 Script executed:

rg "targeta-shopping|tarjeta-shopping" --type ts --type js

Repository: appwrite/sdk-for-cli

Length of output: 130


🏁 Script executed:

cat -n lib/enums/credit-card.ts

Repository: appwrite/sdk-for-cli

Length of output: 662


🌐 Web query:

Tarjeta Shopping credit card identifier payment API official spelling

💡 Result:

  • Official name (brand): "Tarjeta Shopping".
  • Common payment-API identifier (used by MercadoPago / MercadoLibre APIs): tarshop. [1][2]

Sources:
[1] MercadoPago / MercadoLibre developers — payment methods list (shows id "tarshop", name "Tarjeta Shopping").
[2] Nuvei APM page listing "Tarjeta Shopping".


Fix spelling: 'targeta-shopping' should be 'tarjeta-shopping'.

The enum value contains a typo. The correct Spanish spelling is "tarjeta" (meaning "card"), which matches the official brand name "Tarjeta Shopping" and your enum name TarjetaShopping. Change 'targeta-shopping' to 'tarjeta-shopping'.

🤖 Prompt for AI Agents
In lib/enums/credit-card.ts around line 13, the enum value string has a typo:
replace 'targeta-shopping' with the correct spelling 'tarjeta-shopping' so the
exported enum value matches the enum key TarjetaShopping and the official brand
name.

Comment on lines +1 to +9
export enum ImageFormat {
Jpg = 'jpg',
Jpeg = 'jpeg',
Png = 'png',
Webp = 'webp',
Heic = 'heic',
Avif = 'avif',
Gif = 'gif',
}
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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Check for duplicate enum definitions and their usage patterns

# Find the Output enum definition
echo "=== Output enum definition ==="
fd -e ts -e js output.ts lib/enums/ --exec cat {}

echo -e "\n=== ImageFormat usage ==="
rg -n --type=ts "ImageFormat\." -C 2

echo -e "\n=== Output enum usage ==="
rg -n --type=ts "Output\.(Jpg|Jpeg|Png|Webp|Heic|Avif|Gif)" -C 2

Repository: appwrite/sdk-for-cli

Length of output: 299


Remove duplicate enum or consolidate usage.

Verification confirms that ImageFormat and Output enums are identical in structure and mappings. Additionally, neither enum is currently used in the codebase. This represents unintentional duplication and dead code. Either remove the ImageFormat enum if Output is the canonical version, or consolidate to a single enum and update any future usage to reference only that enum.

🤖 Prompt for AI Agents
In lib/enums/image-format.ts lines 1-9 the ImageFormat enum duplicates the
Output enum elsewhere and is unused; remove this duplication by deleting
ImageFormat and consolidating to the canonical Output enum (or replace
ImageFormat with a re-export/alias pointing to Output if backward compatibility
is needed), update any imports to reference the single enum (export from the
canonical file), and run TypeScript compile/tests to ensure no remaining
references to ImageFormat remain.

Comment on lines +1 to +4
export enum ProxyResourceType {
Site = 'site',
Function = 'function',
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Find both enum files and compare their contents
echo "=== Searching for proxy-related enum files ==="
fd -e ts 'proxy.*resource.*type' lib/enums/

echo -e "\n=== Checking ProxyResourceType ==="
cat lib/enums/proxy-resource-type.ts 2>/dev/null || echo "File not found"

echo -e "\n=== Checking ProxyRuleDeploymentResourceType ==="
cat lib/enums/proxy-rule-deployment-resource-type.ts 2>/dev/null || echo "File not found"

Repository: appwrite/sdk-for-cli

Length of output: 454


🏁 Script executed:

#!/bin/bash
# Search for imports and usages of both enums
echo "=== Usages of ProxyResourceType ==="
rg 'ProxyResourceType' --type ts -A 2 -B 2

echo -e "\n=== Usages of ProxyRuleDeploymentResourceType ==="
rg 'ProxyRuleDeploymentResourceType' --type ts -A 2 -B 2

Repository: appwrite/sdk-for-cli

Length of output: 1203


Remove the unused ProxyRuleDeploymentResourceType enum or consolidate with ProxyResourceType.

ProxyRuleDeploymentResourceType has identical members (Site = 'site', Function = 'function') and is not used anywhere in the codebase. ProxyResourceType is the active enum used in lib/commands/proxy.ts. Remove the duplicate or consolidate both into a single enum if they were intended to coexist.

🤖 Prompt for AI Agents
In lib/enums/proxy-resource-type.ts lines 1-4: there is a duplicate enum
situation — remove the unused ProxyRuleDeploymentResourceType (or consolidate
it) so only the active ProxyResourceType remains; search the codebase for any
references to ProxyRuleDeploymentResourceType and either replace them with
ProxyResourceType if intended to be the same, or delete the unused enum
file/definition; ensure imports are updated and run a type-check to confirm no
references remain.

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