Skip to content

Fix Kotlin CLI integer type generation#1557

Merged
abnegate merged 1 commit into
masterfrom
codex/kotlin-integer-long
May 24, 2026
Merged

Fix Kotlin CLI integer type generation#1557
abnegate merged 1 commit into
masterfrom
codex/kotlin-integer-long

Conversation

@abnegate
Copy link
Copy Markdown
Member

@abnegate abnegate commented May 24, 2026

Summary

  • Map CLI Kotlin type generation integer attributes to Long instead of Int, matching Kotlin/Android SDK models.
  • Add a CLI type-generation regression that generates Kotlin table row types from an integer column and asserts Long, not Int.
  • Make generated CLI config resource keys stable so sites is part of ConfigResourceKey even when a test spec omits the Sites service; this keeps copied CLI command files type-checking from the real config schema keys.

Test plan

  • php example.php cli
  • vendor/bin/phpunit --filter 'CLIBun10Test|CLIBun11Test|CLIBun13Test' tests/CLIBun10Test.php tests/CLIBun11Test.php tests/CLIBun13Test.php\n- /tmp/codex-djlint-sdk-generator/bin/djlint templates/ --lint\n- composer lint\n- git diff --check\n\nNote: this repo has master as the default branch and no origin/main, so the PR targets master.

Copilot AI review requested due to automatic review settings May 24, 2026 02:13
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 24, 2026

Greptile Summary

This PR fixes a type mismatch in the Kotlin CLI type generator by mapping AttributeType.INTEGER to Long instead of Int, aligning it with the Appwrite Kotlin/Android SDK models. It also hardcodes CONFIG_RESOURCE_KEYS in the constants template and adds a regression test that asserts the generated Kotlin field is Long? rather than Int?.

  • kotlin.ts: One-line change, clearly correct — Long is the right Kotlin 64-bit integer type matching the SDK models.
  • constants.ts.twig: Replaces the Twig loop/conditional with a static list so all keys are always emitted regardless of which services exist in the target spec; downstream Zod schemas are optional so no runtime breakage, but narrower spec builds will carry extra keys.
  • test.js: Adds a focused regression test with a muteStdout async helper; appwrite.config.json and generated/kotlin/ are left on disk after the test run but cleanup is handled by the PHP test runner's temp-directory lifecycle.

Confidence Score: 5/5

Safe to merge — the core fix is a straightforward one-liner and the new regression test locks in the correct behaviour.

The IntLong change is correct and well-tested. The constants template change is intentional and does not break runtime behaviour because all downstream consumers treat every key as optional. No data-loss or correctness risk was found across any of the three changed files.

The hardcoded CONFIG_RESOURCE_KEYS in constants.ts.twig is worth a second look if any future spec variant intentionally omits sites, tablesDB, or messaging.

Important Files Changed

Filename Overview
templates/cli/lib/type-generation/languages/kotlin.ts Single-line fix mapping AttributeType.INTEGER to Long instead of Int, matching Kotlin/Android SDK model conventions.
templates/cli/lib/constants.ts.twig Replaces dynamic Twig loop+conditional generation of CONFIG_RESOURCE_KEYS with a hardcoded list; all keys are now always emitted regardless of whether the matching service exists in the spec.
tests/languages/cli/test.js Adds a Kotlin type-generation regression test that writes a table config with an integer column, runs the CLI types command, and asserts Long (not Int) in the output; introduces muteStdout async helper.

Reviews (2): Last reviewed commit: "fix: emit Long for Kotlin integer attrib..." | Re-trigger Greptile

Comment thread tests/languages/cli/test.js
Comment thread templates/cli/lib/type-generation/languages/kotlin.ts
Copy link
Copy Markdown
Contributor

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

Updates the CLI’s Kotlin type-generation to treat integer attributes as Long (aligning with Kotlin/Android SDK expectations), and adds a regression test to ensure the CLI-generated Kotlin models keep using Long? for nullable integers. It also broadens CLI config include-path typing to accept resource path keys used by site/function commands in stricter Bun/TypeScript builds.

Changes:

  • Map Kotlin CLI AttributeType.INTEGER to Long instead of Int.
  • Add a CLI regression test that generates Kotlin table row types from an integer column and asserts Long? (not Int?).
  • Widen config resource-path typing (ConfigIncludePaths / getResourceDirname / resolveResourcePath) to accept "functions" and "sites" keys.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
tests/languages/cli/test.js Adds a Kotlin CLI typegen regression (and a stdout mute helper) to assert integer columns generate Long?.
templates/cli/lib/type-generation/languages/kotlin.ts Switches Kotlin integer attribute mapping from Int to Long.
templates/cli/lib/config.ts Expands resource path key typing used for resolving include/resource paths for functions/sites commands.

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

@abnegate abnegate force-pushed the codex/kotlin-integer-long branch from e3c3714 to b08e5ee Compare May 24, 2026 02:33
@abnegate abnegate merged commit 54f8bb4 into master May 24, 2026
56 checks passed
@abnegate abnegate deleted the codex/kotlin-integer-long branch May 24, 2026 02:50
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